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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] num = new int[6];
         for (int i=0; i<6; i++) {
            num[i] = sc.nextInt();
        }
        int count = sc.nextInt();
        int a,b,c;
        for (int i=0; i<count; i++) {
            a = sc.nextInt();
            b = sc.nextInt();
            c = 0;
            if(a==num[0]) {
                if (b==num[1]) {
                    c=num[2];
                } else if (b==num[2]) {
                    c=num[4];
                } else if (b==num[4]) {
                    c=num[3];
                } else {
                    c=num[1];
                }
            } else if(a==num[1]) {
                if (b==num[5]) {
                    c=num[2];
                } else if (b==num[2]) {
                    c=num[0];
                } else if (b==num[0]) {
                    c=num[3];
                } else {
                    c=num[5];
                }
            } else if(a==num[2]) {
                if (b==num[5]) {
                    c=num[4];
                } else if (b==num[4]) {
                    c=num[0];
                } else if (b==num[0]) {
                    c=num[1];
                } else {
                    c=num[5];
                } 
            } else if (a==num[3]) {
                if (b==num[1]) {
                    c=num[0];
                } else if (b==num[0]) {
                    c=num[4];
                } else if (b==num[4]) {
                    c=num[5];
                } else {
                    c=num[1];
                } 
            } else if (a==num[4]) {
                if (b==num[2]) {
                    c=num[5];
                } else if (b==num[5]) {
                    c=num[3];
                } else if (b==num[3]) {
                    c=num[0];
                } else {
                    c=num[2];
                }
            } else {
                if (b==num[1]) {
                    c=num[3];
                } else if (b==num[2]) {
                    c=num[1];
                } else if (b==num[4]) {
                    c=num[2];
                } else {
                    c=num[4];
                }
            }
            System.out.println(c);
        }
        
    }
}



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

using namespace std;
vector<string>vs;
int h,w,k;
int chk(int msk){
    vector<int>vcnt(__builtin_popcount(msk)+1);
    int ret=0;
    for(int i=0;i<w;i++){
        int iv=0;
        int icnt=0;
        for(int j=0;j<h;j++){
            if(j>0&&((1<<(j-1))&msk)){
                vcnt[iv]+=icnt;
                if(vcnt[iv]>k){
                    vcnt=vector<int>(__builtin_popcount(msk)+1,0);
                    i--;
                    ret++;
                    break;
                }
                icnt=0;
                iv++;
            }
            if(vs[j][i]=='1'){
                icnt++;
                if(icnt>k)
                    return 1e6;
            }
            if(j==h-1){
                vcnt[iv]+=icnt;
                if(vcnt[iv]>k){
                    vcnt=vector<int>(__builtin_popcount(msk)+1,0);
                    i--;
                    ret++;
                    break;
                }
            }
        }
    }

    return ret;
}
int main()
{///{}
    cin>>h>>w>>k;
    vs.resize(h);
    for(int i=0;i<h;i++)
        cin>>vs[i];
    int mn=INT_MAX;
    for(int msk=0;msk<(1<<h);msk++){
        int ret=__builtin_popcount(msk)+chk(msk);
        mn=min(mn,ret);
    }
    cout<<mn<<'\n';
    return 0;
}

/**
4 10 4
1110010010
1000101110
0011101001
1101000111


3 5 4
11100
10001
00111
*/


Measured memory_bytes: 3656
#include<stdio.h>

void swap(int*, int*);

int main()
{
	int num[31], w, n, i;
	scanf("%d", &w);
	for (i = 0; i < w; i++)
	{
		num[i] = i + 1;
	}
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d,%d", &a, &b);
		swap(&num[a - 1], &num[b - 1]);
	}
	for (i = 0; i < w; i++)
	{
		printf("%d\n", num[i]);
	}
	return 0;
}

void swap(int *a, int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	string s;
	int k;
	cin >> s >> k;
	const int n = s.size();
	for(int i = 0; i < n; ++i){
		if(s[i] == 'a'){ continue; }
		const int t = 'z' + 1 - s[i];
		if(t > k){ continue; }
		s[i] = 'a';
		k -= t;
	}
	s[n - 1] = (s[n - 1] - 'a' + k) % 26 + 'a';
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int d[] = new int[N];
		for(int i=0;i<N;i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		
		int i = 0;
		if(d.length%2 == 0) {
			int center = d.length/2;
			i = d[center] - d[center - 1];
		}
		System.out.println(i);
		
		sc.close();	
	}
}

Measured memory_bytes: 50720
fun main(args: Array<String>) {
    val (H, W, M) = readLine()!!.split(' ').map { it.toInt() }
    val arrH = mutableMapOf<Int, Int>()
    val arrW = mutableMapOf<Int, Int>()
    val arr = mutableMapOf<Int, MutableMap<Int, Int>>()

    val pos = arrayOfNulls<Pair<Int,Int>>(M)
    arrH[0] = 0
    arrW[0] = 0

    var maxH = 0
    var maxW = 0

    repeat(M) {
        val (h, w) = readLine()!!.split(' ').map { it.toInt() }

        if (arrH[h] == null) arrH[h] = 0
        arrH[h] = arrH[h]!! + 1
        if (arrH[h]!! > arrH[maxH]!!) maxH = h

        if (arrW[w] == null) arrW[w] = 0
        arrW[w] = arrW[w]!! + 1
        if (arrW[w]!! > arrW[maxW]!!) maxW = w

        if (arr[h] == null) arr[h] = mutableMapOf()
        if (arr[h]!![w] == null) arr[h]!![w] = 0
        arr[h]!![w] = arr[h]!![w]!! + 1

        pos[it] = h to w
    }

    var d = arr[maxH] != null && arr[maxH]!![maxW] != null
    val ans = arrH[maxH]!! + arrW[maxW]!!
    if (!d) println(ans)
    else {
        val pairH = arrH.toList().sortedBy { it.second }.filter { it.second == arrH[maxH]!! }
        val pairW = arrW.toList().sortedBy { it.second }.filter { it.second == arrW[maxW]!! }

        pairH.forEach { (i, _) ->
            pairW.forEach { (j, _) ->
                d = d && (arr[i] != null && arr[i]!![j] != null)
                if (!d) {
                    println(ans)
                    return
                }
            }
        }
        println(ans - 1)
    }
}


Measured memory_bytes: 273488
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], time;

void visit(int);
void dfs(void);

  int main(){
  int u, k, v;
  int i, j;

  scanf("%d", &n);

  for ( i = 0; i <n; i++ ){
    for ( j = 0; j <n; j++ ) M[i][j] = 0;
  }
  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    u--;
    for ( j = 0; j < k; j++ ){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}

void visit(int u){
  int v;
  
  color[u] = GRAY;
  time++;
  d[u] = time;
  for ( v = 0; v < n; v++ ){
    if ( M[u][v] == 0 ) continue;
    if ( color[v] == WHITE ){
      visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

void dfs(){
  int i, u;
  for ( i = 0; i < n; i++ ) color[i] = WHITE;
  time = 0;
  for ( u = 0; u < n; u++ ){
    if ( color[u] == WHITE ) visit(u);
  }
  for ( i = 0; i < n; i++ ){
    printf("%d %d %d\n", i+1, d[i], f[i]);
  }
}

Measured memory_bytes: 636
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

cnt = 0
for i in range(n):
  if a[i] >= b[i]:
    cnt += b[i]
  elif b[i] > a[i] :
    if b[i] - a[i]  > a[i+1]:
      cnt += a[i] + a[i+1]
      a[i+1] = 0
    else:
      cnt += b[i]
      a[i+1] = a[i]+ a[i+1] - b[i]


print(cnt)

Measured memory_bytes: 18396
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n;
    vector<int>v;
    for(long long int i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout<<v[v.size()-1]-v[0]<<endl;
    return 0;
}


Measured memory_bytes: 256
<?php

function chmin(&$a, $b) {
    if ($a > $b) {
        $a = $b;
    }
}

fscanf(STDIN, "%d %d", $n, $k);
$h = explode(' ', trim(fgets(STDIN)));

$dp = array_fill(0, $n, PHP_INT_MAX);
$dp[0] = 0;
$dp[1] = abs($h[0] - $h[1]);

for ($i = 2; $i < $n; ++$i) {
    for ($j = 1; $j <= $k; ++$j) {
        if ($i - $j < 0) {
            continue;
        }
        /* chmin($dp[$i], $dp[$i - $j] + abs($h[$i] - $h[$i - $j])); */
        $dp[$i] = min($dp[$i], $dp[$i - $j] + abs($h[$i] - $h[$i - $j]));
    }
}

echo $dp[$n - 1];


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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> G[100];
  for (int i=0;i<m;++i){
    int a,b;
    cin >> a >> b;
    --a,--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  for (int i=0;i<n;++i){
    cout << G[i].size() << endl;
  }


}


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

int A[5], K;

int main() {
	for (int i = 0; i < 5; i++) cin >> A[i];
	cin >> K;
	sort(A, A + 5);
	if (A[4] - A[0] > K) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N,M;
  cin >> N >> M;
  int A[N];
  int sum = 0;
  bool ans = true;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sum += A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);
  if (A[M - 1] >= (double)sum / (double)(4 * M)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    map<string,ll>m;
    string p;
    cin>>p;
    m[p]=1;
    bool flag = 0;
    ll M =p.size();
    rep(i,N-1){
        string w;
        cin>>w;
        
        if(m[w]==1 || p[M-1]!=w[0]){
            
            flag = 1;
            
        }
        m[w]=1;
        p=w;
        M=w.size();
    }
    if(flag){
        cout<<"No"<<endl;
    }else{
        cout << "Yes" << endl;
    }
    


    return 0;
    

}

Measured memory_bytes: 3640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007; // 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
/*-------------------------------------------------*/
int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<long long> l(n, 0);
  REP(i, n) l[i] = (i - 1 >= 0 ? l[i - 1] : 0) + a[i];
  reverse(ALL(a));
  vector<long long> r(n, 0);
  REP(i, n) r[i] = (i - 1 >= 0 ? r[i - 1] : 0) + a[i];
  vector<pair<long long, long long> > left(n, {-LINF, LINF});
  FOR(i, 1, n - 2) {
    int idx = lower_bound(ALL(l), (l[i] + 1) / 2) - l.begin();
    left[i] = {l[idx], l[i] - l[idx]};
    --idx;
    if (idx >= 0) {
      if (abs(left[i].first - left[i].second) > abs(l[i] - l[idx] * 2)) {
        left[i] = {l[idx], l[i] - l[idx]};
      }
    }
  }
  vector<pair<long long, long long> > right(n, {-LINF, LINF});
  FOR(i, 1, n - 2) {
    int idx = lower_bound(ALL(r), (r[i] + 1) / 2) - r.begin();
    right[i] = {r[idx], r[i] - r[idx]};
    --idx;
    if (idx >= 0) {
      if (abs(right[i].first - right[i].second) > abs(r[i] - r[idx] * 2)) {
        right[i] = {r[idx], r[i] - r[idx]};
      }
    }
  }
  long long ans = LINF;
  FOR(i, 1, n - 2) {
    vector<long long> tmp{left[i].first, left[i].second, right[n - i - 2].first, right[n - i - 2].second};
    sort(ALL(tmp));
    ans = min(ans, tmp[3] - tmp[0]);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 10368
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	std::int64_t N;
	std::cin >> N;
	std::cout << N * (N - 1) / 2 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

const int MOD = 1000000007;

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

  int strLen = S.length();

  int a[6];
  int sSum = 0;
  int qNum = 0;

  int restL[6][10];
  for(int i = 0; i < 6; i++){
    for(int j = 0; j < 10; j++){
      int t = pow(10, i) * j;
      restL[i][j] = t % 13;
    }
  }
  
  vector<int> ab;
  for(int i= 0; i < 6; i++) a[i] = 0;
  for(int i = 0; i < strLen; i++){
    if(S[i] == '?'){
      int pos = (strLen - i - 1) % 6;
      ab.push_back(pos);
      a[pos] += 1;
      qNum += 1;
    } else {
      int c = S[i] - '0';
      int pos = (strLen - i - 1) % 6;
      ll cT = restL[pos][c];
      sSum += cT % 13;
    }
  }

  sSum %= 13;
 
  vector<vector<ll>> dp(100050, vector<ll>(13,0));
  dp[0][0] = 1;
 


  for(int i = 1; i < qNum+1; i++){
    int cp = ab[i-1];
    for(int j = 0; j < 10; j++){
      int plus = restL[cp][j];
      for(int k = 0; k < 13; k++){
        int l = k - plus;
        if(l < 0) l+= 13;
        dp[i][k] += dp[i-1][l];
        dp[i][k] %= MOD;
      }
    }
  }

  int u = 5 -sSum;
  if(u < 0) u+= 13;
  ll ans = dp[qNum][u];
  ans %= MOD;
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 14008
import re
s = input()
s = s.replace("BC", "X")
m = re.search(r"[AX]+", s)
count = 0
res = 0
for m in re.finditer(r"([AX]+)", s):
    t = str(m.groups()[0])
    t = ''.join(list(reversed(t)))
    count = 0
    for i in range(len(t)):
        if t[i] == "A":
            res += (i - count)
            count += 1
print(res)

Measured memory_bytes: 5096
// Hacheylight
#include <map>
#include <set>
#include <ctime>
#include <queue>
#include <stack>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <numeric>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define loop(it, v) for (auto it = v.begin(); it != v.end(); it++)
#define cont(i, x) for (int i = head[x]; i; i = e[i].nxt)
#define clr(a) memset(a, 0, sizeof(a))
#define ass(a, sum) memset(a, sum, sizeof(a))
#define lowbit(x) (x & -x)
#define all(x) x.begin(), x.end()
#define SC(t, x) static_cast <t> (x)
#define ub upper_bound
#define lb lower_bound
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define pof pop_front
#define pob pop_back
#define fi first
#define se second
#define y1 y1_
#define Pi acos(-1.0)
#define iv inline void
#define enter cout << endl
#define siz(x) ((int)x.size())
#define file(x) freopen(x".in", "r", stdin),freopen(x".out", "w", stdout)
typedef double db ;
typedef long long ll ;
typedef unsigned long long ull ;
typedef pair <int, int> pii ;
typedef vector <int> vi ;
typedef vector <pii> vii ;
typedef queue <int> qi ;
typedef queue <pii> qii ;
typedef set <int> si ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
const int N = 110 ;
const int INF = 0x3f3f3f3f ;
const int iinf = 1 << 30 ;
const ll linf = 2e18 ;
const int MOD = 1000000007 ;
const double eps = 1e-7 ;
void douout(double x){ printf("%lf\n", x + 0.0000000001) ; }
template <class T> void print(T a) { cout << a << endl ; exit(0) ; }
template <class T> void chmin(T &a, T b) { if (a > b) a = b ; }
template <class T> void chmax(T &a, T b) { if (a < b) a = b ; }
template <class T> void add(T &a, T b) { a = (1ll * a + b) % MOD ; }
template <class T> void sub(T &a, T b) { a = (a - b + MOD) % MOD ; }
template <class T> void mul(T &a, T b) { a = (ll) a * b % MOD ; }
template <class T> T read() {
    int f = 1 ; T x = 0 ;
    char ch = getchar() ;
    while (!isdigit(ch)) { if (ch == '-') f = -1 ; ch = getchar() ; }
    while (isdigit(ch)) { x = x * 10 + ch -'0' ; ch = getchar() ; }
    return x * f ;
}


int ans, n, m, lst ;
int f[N][40 * N] ;

signed main() {
	scanf("%lld%lld", &n, &m) ;
	ans = n * m * (m + 1) / 2 ;
	rep(i, 1, n - 1) mul(ans, m + 1) ;
	f[n + 1][0] = 1 ;
	for (int i = n; i >= 1; lst += (lst + min(i, m)) / i, i--)
	rep(j, 0, lst)
	rep(k, 0, m)
	if (k <= i)
	add(f[i][j + (j + k) / i], f[i + 1][j]) ;
	else add(f[i][j], f[i + 1][j]) ;
	rep(i, 1, lst) sub(ans, f[1][i] * i % MOD) ;
	printf("%lld\n", ans) ;
	return 0 ;
}

/*
写代码时请注意：
	1.ll？数组大小，边界？数据范围？
	2.精度？
	3.特判？
	4.至少做一些
思考提醒：
	1.最大值最小->二分？
	2.可以贪心么？不行dp可以么
	3.可以优化么
	4.维护区间用什么数据结构？
	5.统计方案是用dp？模了么？
	6.逆向思维？
*/





Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int main() {
  ll n, K;
  cin >> n >> K;
  vector<ll> x(n), y(n);
  for(int i=0;i<n;i++)
    cin >> x[i] >> y[i];

  ll ans = 4*1e18;
  for(int i=0;i<n;i++) {
    for(int j=i+1;j<n;j++) {
      for(int k=0;k<n;k++) {
        for(int l=k+1;l<n;l++) {
          ll left = min<ll>(x[i], x[j]);
          ll right = max<ll>(x[i], x[j]);
          ll low = min<ll>(y[k], y[l]);
          ll high = max<ll>(y[k], y[l]);
          ll cnt = 0;
          for(int r=0;r<n;r++) {
            if(left<=x[r] && x[r]<=right && low<=y[r] && y[r]<=high) {
              cnt++;
            }
          }
          if(cnt >= K) {
            ans = min<ll>(ans, (high-low)*(right-left));
          }

        }
      }
    }
  }
  cout << ans << endl;
}



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

int main()
{
  int n;
  cin >> n;
  cin .ignore();
  char s[n];
  for(int i = 0; i < n; i++){
    cin >> s[i];
  }
  set<int> num;
  int x = 0;
  for(int i = 0; i < n; i++){
    num.insert(s[i] - '0');
    x = min(x, s[i] - '0');
  }
  for(int i = 0; i < n - 1; i++){
    if(s[i] == '0')
      continue;
    int m = (s[i] - '0') * 10 + s[i + 1] - '0';
    num.insert(m);
    x = min(x, m);
  }
  for(int i = 0; i < n - 2; i++){
    if(s[i] == '0')
      continue;
    int m = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + s[i + 2] - '0';
    num.insert(m);
    x = min(x, m);
  }
  for(int i = 0; i < n - 3; i++){
    if(s[i] == '0')
      continue;
    int m = (s[i] - '0') * 1000 + (s[i + 1] - '0') * (100 + s[i + 2] - '0') * 10 + s[i + 3] - '0';
    num.insert(m);
    x = min(x, m);
  }
  while(num.find(x) != num.end()){
    x++;
  }
    cout << x << endl;
}

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

int main(void){
    string t,str[4] = {"dream","dreamer","erase","eraser"};
    bool check = true;
    cin >> t;
    reverse(t.begin(),t.end());
    for(int i = 0;i < 4;i++)reverse(str[i].begin(),str[i].end());
    for(int i = 0;i < t.size();){
        bool check2 = false;
        for(int j = 0;j < 4;j++){
            if(str[j] == t.substr(i,str[j].size())){
                check2 = true;
                i += str[j].size();
            }
        }
        if(!check2){
            check = false;
            break;
        }
    }
    if(check)cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <iostream>

int main() {
	int w, h, x, y, r;
	std::cin >> w >> h >> x >> y >> r;
	bool sol = x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0;
	std::cout << (sol? "Yes" : "No") << "\n";
	return 0;
}




Measured memory_bytes: 3084
//Abraao Caiana de Freitas - UFCG

#include <bits/stdc++.h>
#define mod 1000000007
#define maxx 100010
using namespace std;
long long dp[200][maxx],arr[200];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
	cin>>n>>m;
	for(int i = 1; i <= n; i++){cin>>arr[i];dp[i][0]=1;}
	for(int i = 0; i <= m; i++)dp[1][i]=(i<=arr[1]?1:0);
	for(int i = 2; i <= n; i ++){
		for(int j = 1; j <= m; j++){
			long long extra=0;
			if(j>arr[i])extra=dp[i-1][j-arr[i]-1];
			dp[i][j]=((mod+dp[i-1][j]+dp[i][j-1])-extra)%mod;
		}
	}
	cout<<dp[n][m]<<"\n";
	return 0;
}

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

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

int main()
{
	int N;
	cin >> N;
	vector<long long> A(N);
	for (auto &x : A) {
		cin >> x;
	}

	long long ans = 0;
	for (int b = 0; b < 60; ++b) {
		int c = 0;
		for (int i = 0; i < N; ++i) {
			if ((A[i] >> b) & 1) {
				++c;
			}
		}
		long long t = (1LL << b) % MOD;
		t = (t * c) % MOD;
		t = (t * (N - c)) % MOD;
		ans = (ans + t) % MOD;
	}
	cout << ans << endl;
}


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

using namespace std ;

int main ()
{
    long long a , b , c ;
    cin >> a >> b ;
    c = b ;
    b -= ( a * 2 ) ;
    if ( b <= 0 ){
        cout << c / 2 ;
        return 0 ;
    }
    cout << a + b / 4 ;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int n; cin >> n&&n;) {
		int cnt[2][110] = {};
		int s[110] = {};
		rep(i, 0, n) {
			cin >> s[i];
			cnt[0][s[i]]++;
		}
		int ans = 0;
		while (true) {
			fill(cnt[1], cnt[2], 0);
			rep(i, 0, n) {
				s[i] = cnt[0][s[i]];
				cnt[1][s[i]]++;
			}
			bool flag = true;
			rep(i, 0, n) {
				if (cnt[0][i] != cnt[1][i]) {
					flag = false; break;
				}
			}
			if (flag)break;
			swap(cnt[0], cnt[1]);
			ans++;
		}
		cout << ans << endl;
		cout << s[0];
		rep(i, 1, n)cout << " " << s[i];
		cout << endl;
	}
	return 0;
}

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

int dp[5010][5010];
int dpR[5010][5010];
//int dpSumR[5010][5010];
int A[5010];
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	dp[0][0] = 1;
	{
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= K; ++j) {
				if (dp[i][j]) {
					dp[i+1][j] = 1;
					if (j + A[i] <= K) {
						dp[i + 1][j + A[i]] = 1;
					}
				}
			}
		}
	}
	dpR[0][1] = 1;
	{
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j <= K; ++j) {
				if (dpR[i][j+1]) {
					dpR[i+1][j+1] = 1;
					if (j + A[N - 1 - i] <= K) {
						dpR[i + 1][j + A[N - 1 - i]+1] = 1;
					}
				}
			}
		}
	} 
	{
		for (int i = 0; i < N+1; ++i) {
			for (int j = 1; j < K+2; ++j) {
				dpR[i][j] += dpR[i][j - 1];
			}
		}
	}
	/*{
		for (int i = 0; i < N+1; ++i) {
			for (int j = 0; j < K+2; ++j) {
				cout << dpR[i][j];
			}
			cout << endl;
		}
	}*/
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0;j<K;++j) {
			if (dp[i][j]) {
				if (dpR[N-i-1][K-j] > dpR[N-i-1][max(0, K - A[i]-j)]) {
					ans++;
					break;
				}
			}
		}
	}
	cout << N - ans <<  endl;
	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a < 3200) cout << "red\n";
    else cout << s << "\n";
    return 0;
}

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

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
 int a, b, c, d;
 cin >> a >> b >> c >> d;
 (c - a == 1) ? cout << 1 : cout << 0;
 cout << "\n";
return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool sushu(int x){
	for(int i=2;i*i<=x;i++)
	    if(x%i==0)return false;
	return true; 
}
int main(){
	int n;
	cin>>n;
	for(int i=n;;i++)
	    if(sushu(i)){
		    cout<<i;
		    break;
		}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MOD = 1e9+7;
const int MAX = 2e5+100;

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

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  IN(H); IN(W); IN(A); IN(B);

  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR(i, 2, H+W) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }

  ll ans = 0;
  REP(a, (H-1-A)+1)
    ans = (ans + (comb(B+a-1, a) * comb(W-1+H-1-(B+a), W-1-B)) % MOD) % MOD;

  OUT(ans);

  return 0;
}


Measured memory_bytes: 4992
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DLuckyPIN solver = new DLuckyPIN();
        solver.solve(1, in, out);
        out.close();
    }

    static class DLuckyPIN {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();

            int answer = f(s, 3);
            out.println(answer);
        }

        private int f(String s, int k) {
            if (k == 0)
                return 1;
            int res = 0;
            for (char d = '0'; d <= '9'; d++) {
                int j = s.lastIndexOf(d);
                if (j != -1)
                    res += f(s.substring(0, j), k - 1);
            }
            return res;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 55252
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
//Atcoder Educational DP
//N-Slimes
/*
    I ♥ CLARICE STARLING

    EXPLAINATION BELOW->
    Dp + bitmask
    
   
*/
//Iterative Solution
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(x) x.begin(),x.end()
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define MOD7 1000000007
const ll INF=(ll)1e18+5;
int n;
int A[25][25];
void solve()
{
   int i,j;cin>>n;
   fo(i,0,n)
   fo(j,0,n)cin>>A[i][j];
   
   vector<int>dp((1<<n),0);
   dp[0]=1;//There is one way to match no pairs
   int mask;
   for(mask=0;mask<(1<<n)-1;mask++)
   {
       int num=__builtin_popcount(mask);
       for(i=0;i<n;i++)
       {
          if((A[num][i]==1)&&!(mask&(1<<i)))
          {
              dp[(mask|(1<<i))]+=dp[mask];
              dp[(mask|(1<<i))]%=MOD7;
          }
       }
   }
   cout<<dp[mask]%MOD7<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}



Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int main(void){
    int x, y, ans = 0;
    cin >> x >> y;
    if(x == 3) ans += 100000;
    if(x == 2) ans += 200000;
    if(x == 1) ans += 300000;
    if(y == 3) ans += 100000;
    if(y == 2) ans += 200000;
    if(y == 1) ans += 300000;
    if(x == 1 && y == 1) ans+= 400000;
    cout << ans << endl;
    return 0;
}


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,q;
    string s;
    int cnt[100005];

    cin >> n >> q >> s;

    memset(cnt,0,sizeof(cnt));

    FOR(i,0,n-1){
        cnt[i+1]=(s[i]=='A' && s[i+1]=='C')+cnt[i];
    }

    while(q--){
        int l,r;
        cin >> l >> r;
        l--;
        r--;

        cout << cnt[r]-cnt[l] << endl;
    }

    return 0;
}


Measured memory_bytes: 1488
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define nmax 200001
#define pll pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].insert(b-1); adj[b-1].insert(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].insert(b-1);}

vector<ll> B(nmax,0);

int main() {
    
    ll n;
    cin>>n;

    multiset<ll> se;
    for(int i=0;i<n;i++) {
        ll a;
        cin>>a;

        multiset<ll>::iterator it = se.lower_bound(a);
        if(i==0 || it == se.begin())
            se.insert(a);
        else {
            it--;
            se.erase(it);
            se.insert(a);
        }
    }
    cout<<se.size()<<endl;

    return 0;
}




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

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


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
using ll = long long;

int main() {
  int N;
  cin >> N;
  int xsum = 0;
  set<int> masks;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    xsum ^= a;
    masks.insert(a ^ (a - 1));
  }
  int res = 0;
  for (auto it = masks.rbegin(); it != masks.rend(); it++) {
    if ((xsum ^ *it) < xsum) {
      xsum ^= *it;
      ++res;
    }
  }
  cout << (xsum == 0 ? res : -1) << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[9] = {1, 0, -1, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 1, 0, -1, 1, -1, -1, 1, 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 main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N,K; cin>>N>>K;
  vector<vector<ll>> A(N,vector<ll>(N)); rep(i,N) rep(j,N) cin>>A[i][j];
  
  mcf_graph<ll,ll> graph(N*N+2*N+2);
  ll s=N*N+2*N,g=N*N+2*N+1;
  
  //s,g側の辺を張る
  for(int i=N*N;i<N*N+N;i++) graph.add_edge(s,i,K,0);
  for(int i=N*N+N;i<N*N+2*N;i++) graph.add_edge(i,g,K,0);
  
  const ll MAX=1000000000;
  rep(i,N){
    rep(j,N){
      ll v=N*i+j;
      graph.add_edge(N*N+j,v,1,MAX-A[i][j]);
      graph.add_edge(v,N*N+N+i,1,0);
    }
  }
  
  auto sgraph=graph;
  ll limit=0,cost=0;
  for(auto p:sgraph.slope(s,g)){
    ll l,c; tie(l,c)=p;
    if(chmax(cost,MAX*l-c)) limit=l;
  }
  
  //cout<<limit<<'\n';
  
  cout<<MAX*limit-graph.flow(s,g,limit).second<<'\n';
  
  string hoge=""; rep(i,N) hoge+='.';
  vector<string> grid(N,hoge);
  for(auto edge:graph.edges()){
    if(edge.from>=N*N+2*N||edge.to>=N*N+2*N) continue;
    if(edge.flow<1) continue;
    ll v=min(edge.from,edge.to);
    ll y=v/N,x=v%N;
    grid[y][x]='X';
  }
  
  for(auto str:grid) cout<<str<<'\n';
  
  return 0;
}

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

typedef long long ll;
typedef long double ld;
const ll M=1e9+7;
const ll MAXN=1e6+7;
const ld pi=acos(-1);

#define gi(n) ll n=read()
#define endl '\n'
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define per(i,a,b) for(ll i=b-1; i>=a; --i)

typedef vector<ll> V;
typedef vector<V> VV;
typedef set<ll> S;
typedef pair<ll,ll> pl;
typedef vector<pl> Vp;

#define all(v) v.begin(),v.end()
#define pb push_back
#define fs first
#define sc second

inline ll read(){
	ll x=0,ff=1;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') ff=-1;ch=getchar();}
	while(isdigit(ch)) {x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
	return x*ff;
}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll pow1(ll p,ll d, ll P){return d?(pow1(p*p%P,d>>1,P)*(d&1?p:1))%P:1;}

V prime;
bool is_composite[MAXN];
void sieve (ll n){
	std::fill (is_composite, is_composite + n, false);
	rep(i,2,n){
		if(!is_composite[i]) prime.pb(i);
		for(ll j = 0; j < prime.size() && i*prime[j] < n; ++j){
			is_composite[i*prime[j]] = true;
			if(i % prime[j] == 0) break;
		}
	}
}
ll modInverse(ll a, ll m){
	ll m0=m,y=0,x=1;
	if(m==1) return 0;
	while(a>1){
		ll q=a/m,t=m;
		m=a%m;
		a=t; 
		t=y;

		y = x-q*y; 
		x = t;
	}
	if(x<0) x += m0;
	return x; 
}

void doit(){
	gi(n);
	ll a[n],b=0;
	rep(i,0,n) a[i]=read(), b^=a[i];
	rep(i,0,n) cout<<(a[i]^b)<<' ';
}
int main(){
//	for(gi(t);t--;cout<<endl)
		doit();
	return 0;
}

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

#define vec(v) vector<int>(v)
#define be(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define mapci(mp) map<char*,int>(mp)
#define mapcc(mp) map<char*,char*>(mp)
typedef long long ll;
using namespace std;

int main(){
	string s;
	int a,b,c,d;
	cin>>s;
	a=s[0]-'0';
	b=s[1]-'0';
	c=s[2]-'0';
	d=s[3]-'0';
	if(a+b+c+d==7){
		cout << a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b+c-d==7){
		cout << a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a+b-c+d==7){
		cout << a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a+b-c-d==7){
		cout << a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b+c+d==7){
		cout << a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a-b+c-d==7){
		cout << a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
	}
	else if(a-b-c+d==7){
		cout << a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
	}
	else if(a-b-c-d==7){
		cout << a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
X, Y = list(map(int, input().split()))

ans = 0

def nasu(x):
  if x == 1:
    return 300000
  if x == 2:
    return 200000
  if x == 3:
    return 100000
  return 0

ans += nasu(X)
ans += nasu(Y)

if X == 1 and Y == 1:
  ans += 400000

print(ans)

Measured memory_bytes: 38384
from math import cos, sqrt, radians


A, B, H, M = map(int, input().split())
Md = M * 6
Hd = (H * 30) + ((M/60) * 30)
Cd = (Hd - Md)
As = A ** 2
Bs = B ** 2
D = 2 * A * B
X = sqrt(As + Bs - (D * cos(radians(Cd))))
print(X)

Measured memory_bytes: 9508
#include<iostream>
using namespace std;
int main()
{
	int arlong;
	cin >> arlong;
	int ar[100];
	int color[8] = { 0 };
	int more = 0;
	for (int i = 0; i<arlong; i++) {
		cin >> ar[i];
	}
	for (int i = 0; i < arlong; i++) {
		if (ar[i]<3200) {
			if (color[ar[i] / 400] == 0) {
				color[ar[i] / 400] = 1;
			}
		}
		else {
			more++;
		}
	}
	int sum = 0;
	for (int i = 0; i < 8; i++) {
		sum += color[i];    // 合計に追加
	}
	if (sum > 0) {
		cout << sum << " " << (sum + more) << endl;
	}
	else {
		cout << 1 << " " << more << endl;
	}
	return 0;
}

Measured memory_bytes: 256
// C - Chocolate Bar

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	ll H, W;
	cin >> H >> W;

	// 横だけで分割
	ll ans1;
	if (H % 3 == 0) ans1 = 0;
	else ans1 = W;

	// 縦だけで分割
	ll ans2;
	if (W % 3 == 0) ans2 = 0;
	else ans2 = H;

	// 横で分割し、残りを縦で分割
	ll ans3 = INF;
	ll W1, W2;
	if (W % 2 == 0) {
		W1 = W / 2;
		W2 = W1;
	} else {
		W1 = W / 2;
		W2 = W1 + 1;
	}

	for (int i=1; i<H; i++) {
		ll T = W * i;
		ll S1 = W1 * (H - i);
		ll S2 = W2 * (H - i);

		if (T < S1) {
			ans3 = min(ans3, S2 - T);
		} else if (T < S2) {
			ans3 = min(ans3, S2 - S1);
		} else {
			ans3 = min(ans3, T - S1);
		}
	}

	// 縦で分割し、残りを横で分割
	ll ans4 = INF;
	ll H1, H2;
	if (H % 2 == 0) {
		H1 = H / 2;
		H2 = H1;
	} else {
		H1 = H / 2;
		H2 = H1 + 1;
	}

	for (int i=1; i<W; i++) {
		ll T = H * i;
		ll S1 = H1 * (W - i);
		ll S2 = H2 * (W - i);

		if (T < S1) {
			ans4 = min(ans4, S2 - T);
		} else if (T < S2) {
			ans4 = min(ans4, S2 - S1);
		} else {
			ans4 = min(ans4, T - S1);
		}
	}

	ll ans = min(ans1, min(ans2, min(ans3, ans4)));

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 

    class Program
    {
        static void Main(string[] args)
        {
            int[] xy = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine("{0} {1}",xy[0]*xy[1],2*(xy[0]+xy[1]));
        }
        
    }
}

Measured memory_bytes: 9528
#include<cstdio>
#include<map>
#define ll long long 

using namespace std;

const int MOD = 1e9+7;
const int N = 1e4+5;
const int maxn = 1e6+5;

map<int,int> factor;
int a[N];
bool notPrime[maxn];
int prime[maxn];

void GetPrime(){
	notPrime[1] = true;
	for(int i = 2;i < maxn;i++){
		if(!notPrime[i]){
			prime[++prime[0]] = i;
		}
		for(int j = 1;j <= prime[0]&&prime[j]*i<=maxn;j++){
			notPrime[prime[j]*i] = true;
			if(!(i%prime[j])) break;
		}
	}
}

void solve(int x){
	for(int i = 1;i <= prime[0]&&prime[i]*prime[i]<=x;i++){
		int cnt = 0;
		while(x%prime[i]==0){
			cnt++;
			x/=prime[i];
		}
		if(cnt!=0){
			if(factor.count(prime[i])==0) factor.insert({prime[i],cnt});
			else{
				factor[prime[i]] = max(factor[prime[i]],cnt);
			}
		}
	}
	if(x > 1){
		if(factor.count(x)==0) factor[x] = 1;
	}
}

ll ppow(ll a,ll b){
	ll res = 1;
	a %= MOD;
	while(b){
		if(b&1) res = (res*a)%MOD;
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

int main(){
	//freopen("in","r",stdin);
	int n;
	scanf("%d",&n);
	GetPrime();
	for(int i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	for(int i = 0;i < n;i++){
		solve(a[i]);
	}
	/*
	for(auto item : factor){
		printf("%d %d\n", item.first,item.second);
	}
	*/
	ll mul = 1ll;
	for(auto& item : factor){
		mul = (mul*ppow(item.first,item.second))%MOD;
	}
	ll res = 0;
	for(int i = 0;i < n;i++){
		res = (res + (mul*ppow(a[i],MOD-2))%MOD)%MOD;
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

struct Edge{ll from, to, dist;};
vector<vector<Edge> > path;
ll col[100010];
Edge e[200010];
void solve() {
    ll N;
    cin >> N;
    path.resize(N);
    for(int i = 0; i < N; i++) {
        col[i] = -1;
    }
    REP(i, N - 1) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;b--;
        Edge e1 = {a, b, c};
        Edge e2 = {b, a, c};
        path[a].push_back(e1);
        path[b].push_back(e2);
    }
    queue<ll> q;
    q.push(0);
    col[0] = 0;
    while(!q.empty()) {
        ll f = q.front();
        q.pop();
        auto routes = path[f];
        for(auto &route:routes) {
            if(col[route.to] == -1) {
                if(route.dist % 2 == 0) {
                    col[route.to] = col[route.from];
                }else {
                    col[route.to] = 1 - col[route.from];
                }
                q.push(route.to);
            }
        }
    }
    REP(i, N) {
        out(col[i]);
    }
}

int main() {
    fast_io;
    solve();
    return 0;
}


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

using namespace std;

int main(){
	long long a, b, c;
	cin >> a >> b >> c;
	if(a + b <= c){
		cout << "0 0";
		return 0;
	}
	if(c - a > 0){
		cout << '0' << " ";
		c = c - a;
		cout << b - c;
	} else if(c - a <= 0){
		cout << a - c << " " << b;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, m;
string s;
bool b[1<<21];
int dp[1<<21][21];

string enc(llint mask, llint len)
{
	string ret;
	for(int i = 0; i < len; i++){
		ret += mask%2 + '0';
		mask /= 2;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> m;
	for(int i = 0; i <= n; i++){
		cin >> s;
		llint M = 1<<i;
		for(int j = 0; j < M; j++){
			if(s[j]%2) b[M+j] = true;
		}
	}
	
	for(int i = n; i >= 0; i--){
		llint M = 1<<i;
		for(int j = 0; j < M; j++){
			llint x = M+j;
			for(int k = i; k >= 0; k--){
				if(b[x]) dp[x][k] = 1;
				if(i == n) continue;
				dp[x][k] += dp[x*2][0] + dp[x*2+1][0];
				for(int l = 0; l < k; l++){
					llint y = (x >> (l+1)) << (l+2);
					y |= (((x >> l) & 1) ^ 1) << (l+1);
					y |= x & ((1<<(l+1))-1);
					dp[x][k] += dp[y][l+1];
				}
			}
		}
	}
	
	string ans;
	for(int i = n; i >= 0; i--){
		llint M = 1<<i;
		for(int j = 0; j < M; j++){
			if(dp[M+j][i] >= m){
				ans = enc(j, i);
				goto end;
			}
		}
	}
	end:;
	cout << ans << endl;
	
	return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi v(n);
	REP(i, n)cin >> v[i];
	int ans = 0;
	REP(i, n) {
		ans += 2*min(abs(v[i] - k), abs(v[i]));
	}
	cout << ans<< endl;
}


Measured memory_bytes: 256