akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  int m1, m2, d1, d2;
  cin >> m1 >> d1 >> m2 >> d2;

  if (d2 == 1) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

int day(int y, int m)
{
	return (y%3==0||m%2!=0)?20:19;
}

int millennium(int ey, int em, int ed)
{
	int cnt = 0;
	for (int y = 1; y <= ey; y++) {
		for (int m = 1; m <= 10; m++) {
			for (int d = 1; d <= day(y, m); d++) {
				if (y == ey && m == em && d == ed)
					return cnt;
				cnt++;
			}
		}
	}
}

int main(void)
{
	int n;	
	cin >> n;
	rep(t, n) {
		int y, m, d;
		cin >> y >> m >> d;
		cout << millennium(1000, 1, 1)-millennium(y, m, d) << endl;
	}
	return 0;
}

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int turn = 0;
  while (a > 0 && c > 0) {
    if (turn & 1) a -= d;
    else c -= b;
    
    ++turn;
  }

  if (a > 0) cout << "Yes\n";
  else cout << "No\n";

  return (0);
}

Measured memory_bytes: 3596
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int number = 0;
    for (int i = 1; i <= N; i++) {
      int j = i;
      int total = 0;
      total += (j % 10);
      while ((j / 10) != 0) {
        j /= 10;
        total += (j % 10);
      }
    
      if (total >= A && total <= B) {
        number += i;
      }
    }
    System.out.println(number);
  }
}

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

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

#define RFOR(i, b, a) for(int(i)=(b); (i)>=(a); (i)--)
#define RREP(i, n) FOR((i), (n), 0)

#define pb push_back
#define mp make_pair 

using namespace std;

const int INF=INT_MAX/4;
const int MOD=1000000007;
const double EPS=1e-14;

const bool debug_flag=true;

void debug(string str){
	if(debug_flag){
		cout<<str<<endl;
	}
}

void debugs(string str){
	if(debug_flag){
		cout<<str;
	}
}

long n, a, b, c, d;

bool check(int m){
	return m*c-(n-1-m)*d<=b-a && b-a<=m*d-(n-1-m)*c;
}

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout.precision(10);


	cin>>n>>a>>b>>c>>d;

	for(int i=0; i<n-1; ++i){
		if(check(i)){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO"<<endl;

	return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
// #define mp make_pair
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'
// #define int ll
vector<ll> ft(1, 1LL);

/*======================================================================*/


void solve(){
    string s;
    cin >> s;
    cout  << (s=="ABC"?"ARC":"ABC");
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	ll ans=0;
	ll N,A;
	ll prev=0;
	cin>>N;
	rep(i,0,N){
		cin>>A;
		if(prev){
			if(A<prev){
				ans+=prev-A;
				A=prev;
			}
		}
		prev=A;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

#include <vector>
using namespace std;

int main() {
	double a, b;
	cin >> a >> b;

	if (a>b) {
		cout << "GREATER" << endl;
	}
	else if(a==b){
		cout << "EQUAL" << endl;
	}
	else {
		cout << "LESS" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

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

int main() {
  ll h, w, n;
  cin >> h >> w >> n;
  vector<ll> a(n), b(n);
  set<P> st, done;
  REP(i, n) {
    cin >> a[i] >> b[i];
    a[i]--, b[i]--;
    st.insert(P(b[i], a[i]));
  }

  map<ll, ll> ans;
  REP(i, n) {
    REP(j, 9) {
      ll cx = b[i] + dx[j], cy = a[i] + dy[j];
      if (!(0 <= cx && cx < w && 0 <= cy && cy < h)) continue;
      if (done.count(P(cx, cy)) == 1) continue;

      ll cnt = 0;
      REP(k, 9) {
        ll nx = cx + dx[k], ny = cy + dy[k];
        if (!(0 <= nx && nx < w && 0 <= ny && ny < h)) break;
        if (st.count(P(nx, ny)) == 1) cnt++;
        if (k == 8) {
          done.insert(P(cx, cy));
          ans[cnt]++;
        }
      }
    }
  }

  ll sum = 0;
  FOR(i, 1, 10) { sum += ans[i]; }
  cout << (h - 2) * (w - 2) - sum << endl;
  FOR(i, 1, 10) { cout << ans[i] << endl; }

  return 0;
}

Measured memory_bytes: 64256
def dp_solver(tmp):
    l=len(tmp)
    rev=tmp[::-1]+"0"
    dp=[[float("inf") for _ in range(2)] for _ in range(l+2)]
    dp[0][0]=0
    for i in range(l+1):
        for j in range(2):
            num=int(rev[i])
            num+=j
            if num<10:
                dp[i+1][0]=min(dp[i+1][0],dp[i][j]+num)
            if num>0:
                dp[i+1][1]=min(dp[i+1][1],dp[i][j]+(10-num))

    #import numpy as np
    #dp=np.array(dp)
    return(dp[l+1])

s=input()
ans=dp_solver(s)
print(ans[0])

Measured memory_bytes: 208192
#include<bits/stdc++.h>
using namespace std;
#define Set(a,b) memset(a,b,sizeof(a))
template<class T>inline void init(T&x){
	x=0;char ch=getchar();bool t=0;
	for(;ch>'9'||ch<'0';ch=getchar()) if(ch=='-') t=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch-48);
	if(t) x=-x;return;
}typedef long long ll;
int main()
{
	int a,b,c;
	init(a),init(b),init(c);
	cout<<min(a+b,min(a+c,b+c))<<endl;
	return 0;
}


Measured memory_bytes: 256
list = input().rstrip().split()
N = int(list[0])
K = int(list[1])
list2 = input().rstrip().split()
a = []
for i in range(N):
    a = a + [int(list2[i])]
a.sort()
sum = 0
for i in range(K):
    sum = sum + a[N-1-i]
print(sum)

Measured memory_bytes: 3064
# ABC145 - Virtual
# A
# B
# C
import itertools

def fact(n,mod):
    ret=1
    for i in range(2,n+1):
        ret=(ret*i)%mod
    return ret

N=int(input())
X=[tuple(map(int,input().split())) for _ in range(N)]
ans=0
for p in itertools.permutations(X):
    # print(p)
    sx,sy=p[0]
    for x,y in p:
        ans+=((sx-x)**2+(sy-y)**2)**0.5
        sx,sy=x,y
    # print(ans)
ans/=fact(N,10**9+7)
print(ans)
    

    
# D
# E

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a + b == 15){cout << '+' << endl;}
    else if(a * b == 15){cout << '*' << endl;}
    else{cout << 'x' << endl;}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define EPS 0.0000000001
#define INF 1000000000
#define MOD 1000000007
typedef long long ll;

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


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

;
int main(){
  string alice,bob,charles;
  cin>>alice>>bob>>charles;
  int i=0,j=0,k=0,jugador=0;
  char ganador;
  while(i<=alice.size() && j<=bob.size() && k<=charles.size()){
    if(jugador==0){
      if(alice[i]=='a'){
        jugador=0;     
      }else if(alice[i]=='b'){
        jugador=1;
      }else if(alice[i]=='c'){
        jugador=2;
      }
      
      if(i==alice.size()){
        ganador='A';
        break;
      }i++;

    }

    if(jugador==1){
      if(bob[j]=='a'){
        jugador=0;
      }else if(bob[j]=='b'){
        jugador=1;
      }else if(bob[j]=='c'){
        jugador=2;
      }
      
       if(j==bob.size()){
        ganador='B';
        break;
      }j++;
    }

        if(jugador==2){
      if(charles[k]=='a'){
        jugador=0;
      }else if(charles[k]=='b'){
        jugador=1;
      }else if(charles[k]=='c'){
        jugador=2;
      }
      
       if(k==charles.size()){
        ganador='C';
        break;
      }k++;
    }
  }
    cout<<ganador<<endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a;
    for(int i=0;i<h;i++){
        a.push_back(vector<char>());
        string s;
        cin>>s;
        for(int j=0;j<w;j++){
            a[i].push_back(s[j]);
        }
    }
    vector<bool> hb(h),wb(w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                hb[i]=true;
                wb[j]=true;
            }
        }
    }
    for(int i=0;i<h;i++){
        if(!hb[i])continue;
        for(int j=0;j<w;j++){
            if(!wb[j])continue;
            cout<<(a[i][j]);
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long llong;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   for (int i = 1; i < 10; i++) {
      for (int j = 1; j < 10; j++) {
         if (i * j == n) {
            printf("Yes\n");
            return 0;
         }
      }
   }
   printf("No\n");
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl
typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;

bool hantei(vector<vector<char>> x, int i, int j)
{
	if (x[i][j] == '#')
		if (x[i + 1][j] == '#' || x[i - 1][j] == '#' || x[i][j + 1] == '#' || x[i][j - 1] == '#')
			return true;
		else
			return false;
	else
		return true;
}

int main()
{
	int h, w; cin >> h >> w;
	vector<string> x(h);
	rep(i, h)
		cin >> x[i];
	rep(i, h)
		cout << x[i] << endl << x[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll n;
  cin >> n;
  
  cout << (n + 110)/111 * 111 << endl;

  return 0;
}


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

void trace(int A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i > 0 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int count = 0;

void doMS(int A[], int head, int len)
{
    if (len < 2)
        return;
    int toplen = len / 2;
    int botlen = len - toplen;
    int tophead = head;
    int bothead = tophead + toplen;
    doMS(A, tophead, toplen);
    doMS(A, bothead, botlen);
    // merge top and bottom
    int res[len];
    int i = tophead;
    int j = bothead;
    int res_i = 0;
    while (i < tophead + toplen || j < bothead + botlen)
    {
        if (i >= tophead + toplen)
        {
            memcpy(res + res_i, A + j, sizeof(int) * (bothead + botlen - j));
            count += bothead + botlen - j;
            break;
        }
        if (j >= bothead + botlen)
        {
            memcpy(res + res_i, A + i, sizeof(int) * (tophead + toplen - i));
            count += tophead + toplen - i;
            break;
        }
        res[res_i++] = A[i] > A[j] ? A[j++] : A[i++];
        count++;
    }
    memcpy(A + head, res, sizeof(int) * len);
}

int main(){
    int n, i, j, key, temp;
    int *A;
    //extern count;
    scanf("%d", &n);
    A = malloc(sizeof(int) * n);

    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    
    doMS(A, 0, n);
    trace(A, n);
    printf("%d\n", count);

    return 0;
}

/* 
8 5 9 2 6 3 7 1 10 4
*/

Measured memory_bytes: 5724
N = int(input())
a = [0] * N
b = [0] * N
c = [0] * N

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

# print(a)
# print(b)
# print(c)
S = [[0 for j in range(3)] for i in range(N)]
S[0][0] = a[0]
S[0][1] = b[0]
S[0][2] = c[0]

for i in range(1, N):
    S[i][0] = max(S[i - 1][1], S[i - 1][2]) + a[i]
    S[i][1] = max(S[i - 1][0], S[i - 1][2]) + b[i]
    S[i][2] = max(S[i - 1][0], S[i - 1][1]) + c[i]

# print(S)
print(max(S[N - 1]))


Measured memory_bytes: 40476
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i = 0; i < (n); ++i)
typedef long long ll;


int main(void) {
  ll n;
  cin >> n;
  bool flag = false;
  ll a, b;
  ll root = sqrt(n);
  for(ll i = root; i > 0; --i) {
    ll amari = n % i;
    if(amari == 0) {
      flag = true;
      a = i;
      b = n / i;
      break;
    }
  }

  cout << a + b - 2 << endl;

  return 0;
}

Measured memory_bytes: 256
N=int(input())

spf=[1 for _ in range(N+1)]

for i in range(2,N+1):
    n=i
    if spf[i]!=1:
        continue
    while n<=N:
        if spf[n]==1:
            spf[n]=i
        n+=i

ans=0
for j in range(1,N):
    d={}
    t=j
    res=1
    while t>1:
        if spf[t] in d:
            d[spf[t]]+=1
        else:
            d[spf[t]]=1
        t//=spf[t]
    for D in d:
        res*=d[D]+1
    ans+=res
print(ans)


Measured memory_bytes: 141896
import Data.Char

main = interact $ unlines . map unreliable_message . groupAt 2 . tail . lines

unreliable_message [ms,str] = foldr relay_rev str ms
 where
  relay_rev 'J' s = last s : init s
  relay_rev 'C' s = tail s ++ [head s]
  relay_rev 'E' s = if odd (length s) then xs2 ++ [x] ++ xs1 else xxs ++ xs1
   where (xs1,xxs@(x:xs2)) = splitAt (div (length s) 2) s
  relay_rev 'A' s = reverse s
  relay_rev 'P' s = map (\c -> if c=='0' then '9' else if isDigit c then pred c else c) s
  relay_rev 'M' s = map (\c -> if c=='9' then '0' else if isDigit c then succ c else c) s

groupAt n xs
 | null xs = []
 | otherwise = take n xs : groupAt n (drop n xs)

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

using namespace std;

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

  uint64_t x;
  cin >> x;

  uint64_t pos = 0;
  for (uint64_t i = 1; i <= x; ++i) {
    pos += i;
    if (x <= pos) {
      cout << i << "\n";
      break;
    }
  }
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)

h = {}

gets.split.map(&:to_i).each do |i|
  h[i] = (h[i] || 0) + 1
end

ary = h.to_a.sort_by {|a| a[1] }

res = 0

(0...(ary.size-k)).each do |i|
  res += ary[i][1]
end

puts res

Measured memory_bytes: 43904
class Dice
    attr_reader :top, :front, :right, :left, :back, :bottom

    def initialize(top, front, right, left, back, bottom)
        @top, @front, @right, @left, @back, @bottom \
            = top, front, right, left, back, bottom
    end

    def south
        @top, @front, @bottom, @back \
            = @back, @top, @front, @bottom
    end

    def north
        @top, @front, @bottom, @back \
            = @front, @bottom, @back, @top
    end

    def east
        @top, @right, @bottom, @left \
            = @left, @top, @right, @bottom
    end

    def west
        @top, @right, @bottom, @left \
            = @right, @bottom, @left, @top
    end

    def spin
        @front, @right, @back, @left \
            = @right, @back, @left, @front
    end
end

dice = Dice.new(*(gets.chomp.split.map(&:to_i)))

data = gets.chomp.to_i

data.times do
    tp, fr = gets.chomp.split.map(&:to_i)

    if dice.right == tp
        dice.west
    elsif dice.left == tp
        dice.east
    else
        until dice.top == tp
            dice.south
        end
    end

    until dice.front == fr
        dice.spin
    end

    puts dice.right
end

Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  vector<bitset<10>> f(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 10; j++) {
      bool b;
      cin >> b;

      f[i][j] = b;
    }
  }

  int p[n + 10][20];
  memset(p, 0, sizeof(p));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= 10; j++) {
      cin >> p[i][j];
    }
  }

  ll ans = -(1<<31);
  for (int i = 1; i < (1 << 10); i++) {
    bitset<10> b(i);

    ll v = 0;
    for (int x = 0; x < n; x++) {
      int count = 0;

      for (int y = 0; y < 10; y++) {
        if (b[y] && f[x][y]) {
          count++;
        }
      }

      v += p[x][count];
    }

    if (v >= ans) {
      ans = v;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split(" "))
grid = list()
for _ in range(H):
    l = list()
    for c in input():
        if c == ".":
            l.append(True)
        else:
            l.append(None)
    grid.append(l)


def get_neighbors(x, y):
    neighbors = ((x-1, y), (x+1, y), (x, y-1), (x, y+1))
    result = list()
    for neighbor in neighbors:
        x, y = neighbor
        if 0 <= x <= W-1 and 0 <= y <= H-1:
            result.append((x, y))
    return result


current_x = 0
current_y = 0
distance = 0
queue = list()
grid[0][0] = 0
queue.append((current_x, current_y, distance+1))
while True:
    if not queue:
        break
    current_x, current_y, distance = queue.pop(0)
    if current_y == H - 1 and current_x == W - 1:
        break
    for neighbor in get_neighbors(current_x, current_y):
        x, y = neighbor
        if grid[y][x] is not None:
            if grid[y][x] is True:
                grid[y][x] = distance
                queue.append((x, y, distance+1))


if grid[H-1][W-1] is None or grid[H-1][W-1] is True:
    print(-1)
else:
    test = [l.count(None) for l in grid]
    num_black = sum(l.count(None) for l in grid)
    print(H*W - num_black - grid[H-1][W-1] - 1)


Measured memory_bytes: 3064
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

n, m = map(int, input().split())
data = getSomeInputListInt(m)

datatmp = sorted(data, key=lambda x:int(x[1]))
dataSorted = sorted(datatmp, key=lambda x:x[0])

tmpCheck = -1
tmpNum = 0

for i in range(m):
    if dataSorted[i][0]==tmpCheck:
        tmpNum += 1
    else:
        tmpNum = 1
    dataSorted[i].append(tmpNum)
    tmpCheck = dataSorted[i][0]


for i in range(m):
    tmp = str(data[i][0])
    for j in range(6-len(tmp)):
        tmp = '0'+tmp

    tmp2 = str(data[i][2])
    for j in range(6-len(tmp2)):
        tmp2 = '0'+tmp2

    print(tmp+tmp2)




Measured memory_bytes: 37880
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m,v,p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  auto check = [&](ll M) -> bool {
    bool ok=false;
    bool sub=true;
    ll s=0;
    //a[M]で条件満たすの?
    FOR(i,M+1,n-p+1){
      if(a[M]+m-a[i]>=0){
        s +=(a[M]+m-a[i]);
      }
      else
        sub=false;
    }
    if((M+1)*m+s>=m*(v-p+1)){
      ok=true;
    }
    return ok && sub;
  };
  
  ll ok = n - 1, ng = -1;
  while(abs(ok - ng) > 1){
    ll cen = (ok + ng) / 2;
    (check(cen) ? ok : ng) = cen;
  }
  
  cout << n - ok << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
#define int ll
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n;
    cin >> n;

    vector<int> a(n+2, 0);
    rep(i, n) {
        cin >> a[i];
    }
    vector<int> cumsum(n+2, 0);

    REP(i, 0, n) {
        cumsum[i+1] = (cumsum[i] + a[i])%mod;
    }
    int res =0;
    rep(i, n-1) {
        res += ((cumsum[n] - cumsum[i+1]+mod) % mod)*a[i]%mod;
        res = res % mod;
    }

    cout << res << "\n";
}

Measured memory_bytes: 6364
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define endl "\n"


int main() {
    #ifndef ONLINE_JUDGE
	freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
/*
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>


typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
*/

using namespace std;

int main()
{
    double a,b,c,C;
    cin >> a>>b>>C;
    C *= M_PI / 180;
    c = sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(C));

    cout << fixed << setprecision(8) << a * b * sin(C) / 2<<endl;
    cout << fixed << setprecision(8) << a + b + c<<endl;
    cout << fixed << setprecision(8) << b * sin(C)<<endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
//#define endl "\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vi vector<ll>
#define pb push_back
#define F first
#define S second
#define all(v) (v).begin(),(v).end()
#define pii pair<ll,ll>
#define vii vector<pii>
#define MOD 1000000007LL
#define calc_fact(n) tgamma(n+1)

ll binpow(ll a, ll b)
{
    if(b==0)return 1;
    ll res=binpow(a, b/2);
    res = (res*res)%MOD;
    if(b%2){
        res = (res*a)%MOD;
    }
    return res;
}
ll inv(ll n)
{
    return binpow(n, MOD-2);
} 
bool compare(const pair<ll,ll>&i,const pair<ll,ll>&j)
{
    if(i.F!=j.F)
    return i.F<j.F;             //sort the first element of vector pair in ascending order
    else
    return i.S>j.S;            //sort the second element of vector pair in descending order
}
vi v;
void sieve(ll n)     // number upto which prime number we want
{
    vector<bool> PRIME(n+1,true);
    PRIME[0]=false;PRIME[1]=false;
    for(ll p=2;p*p<=n;p++)
    {
        if(PRIME[p]==true)
        {
            for(ll i=p*p;i<=n;i+=p)
            {
                PRIME[i]=false;    // mark multiples of number as composite
            }
        }
    }
         // PRIME[i]==true then prime number
    for(ll i=2;i<PRIME.size();i++)
    {
        if(PRIME[i])
        v.pb(i);
    }
}



signed main()
{
    FIO;
    ll a;
    vi v;
    for(ll i=0;i<5;i++)
    {
        cin>>a;
        v.pb(a);
    }
    cout<<find(all(v),0)-v.begin()+1;
}

Measured memory_bytes: 3648
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

static vector<int32_t> xs;

int32_t main()
{
  int32_t N, K;
  cin >> N;
  cin >> K;

  for (int32_t i = 0; i < N; i++) {
    int32_t x;
    cin >> x;
    xs.push_back(x);
  }

  int64_t distance = 0;
  for (uint32_t i = 0; i < xs.size(); i++) {
    int32_t x = xs[i];
    distance += 2 * min(abs(K - x), abs(x));
  }

  cout << distance << endl;

  return 0;
}


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

using namespace std;

int N;
string S;

vector<int> nW, nB;

int R = 1 << 30;

int main()
{
  cin >> N >> S;
  nW.resize(N + 1);
  nB.resize(N + 1);
  nW[0] = 0;
  for (int i = 0; i < N; ++i)
  {
    nW[i + 1] = nW[i] + (S[i] == '#');
  }
  nB[N] = 0;
  for (int i = N - 1; i >= 0; --i)
  {
    nB[i] = nB[i + 1] + (S[i] == '.');
  }
  for (int i = 0; i <= N; ++i)
  {
    R = min(R, nW[i] + nB[i]);
  }
  cout << R << endl;
  return 0;
}


Measured memory_bytes: 2180
#include<cstdio>

long long n;
long long m = 1e9 + 7;

int main()
{
	scanf("%lld",&n);
	long long ans = 1;
	for(long long i = 1;i <= n; i++){
		ans *= i % m;
		ans = ans % m;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int a,b,c,n,s;
int main()
{
    cin >> a >> b >> c >> n;
    for (int i=0;i<=a;i++)
    {
    	for (int j=0;j<=b;j++)
    	{
    		if ((n-i*500-j*100>=0)&&(n-i*500-j*100<=c*50))
    		{
    			s++;
			}  
		} 
	}
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector< ll > vi;
#define INF  10000000000000000
#define all(c) c.begin(),c.end()
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main()
{
    ios
    int t=1;
    //cin>>t;
    while(t--)
    {
	int n;cin>>n;
	vi v;
	priority_queue<ll> b;
	priority_queue<ll,vector<ll>,greater<ll> > a;
	ll sum=0,l[3*n],r[3*n];
	rep(i,0,3*n)
	{
		ll x;
		cin>>x;
		v.pb(x);
	}
	rep(i,0,3*n)
	{
		a.push(v[i]);
		sum+=v[i];
		if(a.size()<n)
			l[i]=-INF;
		if(a.size()>n)
		{
			//cout<<a.top();
			sum-=a.top();
			a.pop();
		}
		if(a.size()==n)
		{	
			l[i]=sum;
			//cout<<sum<<" ";
		}
	}
	sum=0;
	for(ll i=3*n-1;i>=0;i--)
	{
		b.push(v[i]);
		sum+=v[i];
		if(b.size()<n)
			r[i]=INF;
		if(b.size()>n)
		{
			sum-=b.top();
			b.pop();
		}
		if(b.size()==n)
			r[i]=sum;
	}
	ll ans=-INF;
	rep(i,n-1,2*n)
	{
		ans=max(ans,l[i]-r[i+1]);
		//cout<<l[i]-r[i+1]<<" ";
	}
	cout<<ans;
		
	}
    return 0;
}

Measured memory_bytes: 11628
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, i;
  cin >> N >> i;
  cout << N+1-i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);


int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n + x - 1) / x * t;
	cout << ans << en;


	return 0;
}




Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);    
  
  int N; cin >> N;
  
  ll data[N][2];
  F0R(i, N) {
    F0R(j, 2) cin >> data[i][j];
  }
  
  ll ans = 0;
  
  F0R(xP, 2) {
    F0R(yP, 2) {
      ll xC = xP; if (xC == 0) xC = -1;
      ll yC = yP; if (yP == 0) yC = -1;
      
      vpl oldPoints;
      oldPoints.pb({0, 0});
      
      F0R(i, N) {
        vpl newPoints;
        F0R(j, sz(oldPoints)) {
          newPoints.pb(oldPoints[j]);
          newPoints.pb(mp(oldPoints[j].f+data[i][0]*xC, oldPoints[j].s+data[i][1]*yC));
        }
        sort(all(newPoints));
        reverse(all(newPoints));
        oldPoints.clear();
        
        F0R(x, sz(newPoints)) {
          int k = sz(oldPoints)-1;
          if (sz(oldPoints) == 0 || oldPoints[k].f < newPoints[x].f || oldPoints[k].s < newPoints[x].s) {
            oldPoints.pb(newPoints[x]);
          }
        }
      }
      
      F0R(i, sz(oldPoints)) {
        ans = max(ans, oldPoints[i].f*oldPoints[i].f+oldPoints[i].s*oldPoints[i].s);
      }
    }
  }
  
  
  cout << setprecision(30) << sqrtl((ld) ans) << endl;
  
  return 0;
}

Measured memory_bytes: 10004
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    ll now = 1000;
    for(int i = 0; i + 1 < N; i++) {
        if(A[i+1] > A[i]) {
            ll num = now / A[i];
            now %= A[i];
            now += A[i+1] * num;
        }
    }
    cout << now << endl;
    return 0;
}


Measured memory_bytes: 3672
sentence = input()
N = int(sentence)
sentence = input()
p_str = sentence.split()
p_list = []
previous = -1
need_move = []
for i, p in enumerate(p_str):
    present = int(p)
    p_list.append(present)
    if previous > present:
        need_move.append(i)
        need_move.append(i-1)
    previous = present
ans_ok = "YES"
ans_no = "NO"
# 昇順ならyes
if not need_move:
    print(ans_ok)
    exit()
if len(need_move) > 4:
    print(ans_no)
    exit()
while len(need_move) > 1:
    move_index = need_move.pop(0)
    for move_index_2 in need_move:
        # 入れ替えてみて昇順か確かめる
        before_number = p_list[move_index]
        after_number = p_list[move_index_2]
        p_list[move_index] = after_number
        p_list[move_index_2] = before_number
        ok = True
        pre = -1
        for p in p_list:
            if p < pre:
                ok = False
                break
            pre = p
        # ok
        if ok:
            print(ans_ok)
            exit()
        p_list[move_index] = before_number
        p_list[move_index_2] = after_number
print(ans_no)




Measured memory_bytes: 3064
n = int(input())
ct = 0
max_ct = 0
now = 0
max_num = 1
for i in range(1, n+1):
    now = i
    while (i % 2 == 0):
        i = i / 2
        ct += 1
    if max_ct < ct:
        max_ct = ct
        max_num = now
    ct = 0

print(max_num)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<list>
#include<iterator>
#include<cstdlib>
#include<ctime>
#include<stdio.h>
#define _CRT_SECURE_NO_WARNINGS
#define __USE_MINGW_ANSI_STDIO
#define Fast ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
#define ll long long
#define ff float
#define oo bool
#define ii int
#define ch char
#define dd double
#define ld long double
#define ss string
#define pb push_back
#define all(c) c.begin(), c.end()
#define loop(i,m,n) for(ll i=m;i<n;i++)
#define for1(i,m,n) for(ll i=m;i>=n;i--)
#define for2(i,m,n) for(ll i=m;i<=n;i++)
using namespace std;
//ld pi = 3.14159265359;
//const ll mod = 1e9 + 7;
/*
 you can ^_^ (•‿•)

( إن الله وملائكته يصلون على النبي يا أيها الذين آمنوا صلوا عليه وسلموا تسليما )
*/
ii main()
{
	//cout << fixed << setprecision(1);
	Fast;
	ss s; cin >> s;
	sort(all(s));
	if (s[0] == 'a' && s[1] == 'b' && s[2] == 'c')
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}
/*
  //freopen(".in","r",stdin);
  //freopen(".out","w",stdout);

  scanf("%",&);
  printf("%",);
*/

Measured memory_bytes: 256
N, K = map(int, raw_input().split())

if K<=(N-1)*(N-2)/2:
  E = []
  for i in range(N-1):
    for j in range(i):
      E += [(j, i)]
  E = E[:(N-1)*(N-2)/2-K]
  for i in range(N-1):
    E += [(i, N-1)]
  print len(E)
  for e in E:
    print e[0]+1, e[1]+1
else:
  print "-1"


Measured memory_bytes: 2948
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> A(n);
        rep(i, n){
        cin >> A[i];
    }
    sort(A.begin(),A.end());
    reverse(A.begin(), A.end());
    ll a,b; a = 0; b = 0;
    for(ll i = 0; i < n; i += 2){
        a += A[i];
    }
    for(ll i = 1; i < n; i += 2){
        b += A[i];
    }
    cout << a - b << endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
ll mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,sum;
ll x[100005],y[100005];
 
int main(){
    cin>>n; 
	if(n<=999){
		p("ABC");
	}else{
		p("ABD");
	}
    return 0;
}

Measured memory_bytes: 4992
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)

using namespace std;
typedef long long ll;
const int MAX_N = 100;
const int MAX_W = 1000000000;
static const int INF = 1<<29;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    // 追加２, 以降 cin の入力元が 'input.txt' になる
    //提出時に消す！！

    int N,D;
    cin >> N >> D;
    int C[11][11];
    rep(i,N){
        rep(j,D){
            cin >>C[i][j];
        }
    }

    float ans=0;
    int counter=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            rep(k,D){
                ans += (C[i][k]-C[j][k])*(C[i][k]-C[j][k]);
            }
            float x=sqrt(ans);
            if(x==int(x)) counter++;
            ans=0;
            }
        }
    cout << counter << endl;

    return 0;

}

Measured memory_bytes: 256
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
// #pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
// char buf[1<<20],*p1=buf,*p2=buf;
// #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//
int n,a[mn],b[mn];
ll k,ans,l,r,mid;
inline bool ch(ll x){
	ll ans=0;
	FOR(i,1,n)if(1ll*a[i]*b[n-i+1]>x){
		ans+=a[i]-(x/b[n-i+1]);
		if(ans>k)return 0;
	}
	return (bool)(ans<=k);
}
signed main(){
#ifdef LOCAL_LIGEN
	freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	n=read();k=read();
	FOR(i,1,n)a[i]=read();
	FOR(i,1,n)b[i]=read();
	sort(a+1,a+1+n);sort(b+1,b+1+n);
	l=0,r=(ll)(1e12)+5;
	while(l+1<r){
		mid=(l+r)>>1;
		if(ch(mid))r=mid;else l=mid;
	}
	if(!ch(l))l=r;
	writeln(l);
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}


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

using namespace std;

using Int = long long;

map<char, set<Int>> gather_indices_by_color(const string &s) {
    map<char, set<Int>> ans{{'R', {}}, {'G', {}}, {'B', {}}};

    for (Int i = 0; i != s.size(); ++i) {
        ans[s[i]].insert(i);
    }

    return ans;
}

vector<tuple<char, char, char>> all_triples() {
    vector<tuple<char, char, char>> ans;
    vector<char> curr{'B', 'G', 'R'};

    do {
        ans.emplace_back(curr[0], curr[1], curr[2]);
    } while (next_permutation(curr.begin(), curr.end()));

    return ans;
}

Int count_isooffsets(const map<char, set<Int>> &indices_by_color) {
    Int ans = 0;

    for (const auto [c1, c2, c3] : all_triples()) {
        for (auto i : indices_by_color.at(c1)) {
            for (
                auto itk = indices_by_color.at(c3).upper_bound(i); 
                itk != indices_by_color.at(c3).cend();
                ++itk
            ) {
                const auto k = *itk;
                if ((k - i) % 2) continue;
                if (indices_by_color.at(c2).count(i + (k - i) / 2)) ++ans;
            }
        } 
    }

    return ans;
}

int main() {
    Int n;
    string s;
    cin >> n >> s;

    const auto indices_by_color = gather_indices_by_color(s);

    const Int ans = accumulate(
        indices_by_color.cbegin(), 
        indices_by_color.cend(), 
        1LL, 
        [](const Int memo, const auto p) { return memo * p.second.size(); }
    ) - count_isooffsets(indices_by_color);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3836
N = int(input())
B = [int(x) for x in input().split()]
A = []

for i in range(N):
    if i == 0:
        A.append(B[i])
    elif i == N-1:
        A.append(B[i-1])
    else:
        A.append(min(B[i-1],B[i]))

print(sum(A))


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if sum(a) < sum(b):
  print(-1)
  exit()
  
c = [x-y for x,y in zip(a,b)]
p = [z for z in c if z > 0]
m = [z for z in c if z < 0]

f = sum(m)
l = len(m)
for k in sorted(p, reverse=True):
  if f >= 0:
    break
  f += k
  l += 1
print(l)

Measured memory_bytes: 18356