akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, e) for (int i = (s); i < (int)(e); ++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const long long MOD = 998244353;

/**
 * http://hos.ac/slides/20140319_bit.pdf
 */
class BinaryIndexedTree {
 private:
  vector<ll> bit;
  ull size;

 public:
  explicit BinaryIndexedTree(ull size) : bit(size + 1, 0), size(size) {}

  /**
   * @param i
   * @param value
   */
  void add(ull i, ll value) {
    for (ull x = i; x < size; x |= x + 1) {
      bit[x] += value;
    }
  }

  /**
   * [0, i) の合計
   * @param i
   */
  ll sum(ull i) {
    ll ret = 0;
    for (ll x = i - 1; x >= 0; x = (x & (x + 1)) - 1) {
      ret += bit[x];
    }
    return ret;
  }
};

/**
 * values を 1 以上の整数に圧縮したベクタを生成する
 * @tparam T
 * @param values
 */
template<typename T>
vector<ll> compress(vector<T> &values) {
  vector<ll> ret(values.size());
  vector<pair<T, ull>> V(values.size());

  rep (i, values.size()) {
    V[i] = make_pair(values[i], i);
  }
  sort(V.begin(), V.end());

  ll cnt = 1;
  T prev = V[0].first;
  for (const auto &vi : V) {
    T v;
    ll i;
    tie(v, i) = vi;

    if (prev != v) cnt++;
    ret[i] = cnt;
    prev = v;
  }
  return ret;
}

/**
 * x ** y % mod
 * @param x
 * @param y
 * @param mod
 */
ll mod_pow(ll x, ll y, ll mod) {
  ll ret = 1;
  while (y > 0) {
    if (y & 1) {
      ret = ret * x % mod;
    }
    x = x * x % mod;
    y >>= 1;
  }
  return ret;
}

int main() {
  ifstream ifs;
  if (getenv("LOCAL") != nullptr) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N;
  cin >> N;
  vector<tuple<ll, ll>> XY;
  rep (i, N) {
    ll x, y;
    cin >> x >> y;
    XY.emplace_back(x, y);
  }

  sort(XY.begin(), XY.end());
  vector<ll> Y;
  for (const auto &xy : XY) {
    ll _, y;
    tie(_, y) = xy;
    Y.push_back(y);
  }
  Y = compress(Y);

  vector<ll> LL;
  vector<ll> LG;
  vector<ll> GL;
  vector<ll> GG;
  BinaryIndexedTree bit = BinaryIndexedTree(N + 1);
  rep (i, N) {
    ll lls = bit.sum(Y[i]);
    ll lgs = i - lls;
    ll gls = Y[i] - 1 - lls;
    ll ggs = N - Y[i] - lgs;
    LL.push_back(lls);
    LG.push_back(lgs);
    GL.push_back(gls);
    GG.push_back(ggs);
    bit.add(Y[i], 1);
  }

  vector<ll> pow2(N);
  ll p = 1;
  rep (i, N) {
    pow2[i] = p;
    p = p * 2 % MOD;
  }

  ll ans = 0;
  rep (i, N) {
    // この点を使う
    ll r = pow2[N - 1];
    // この点を使わない
    ll a = (pow2[LL[i]] - 1) * (pow2[GG[i]] - 1) % MOD * pow2[N - LL[i] - GG[i] - 1] % MOD;
    ll b = (pow2[LG[i]] - 1) * (pow2[GL[i]] - 1) % MOD * pow2[N - LG[i] - GL[i] - 1] % MOD;
    ll c = (pow2[LL[i]] - 1) * (pow2[GG[i]] - 1) % MOD * (pow2[LG[i]] - 1) % MOD * (pow2[GL[i]] - 1) % MOD;
    ans += r + a + b - c + MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 18804
import heapq

x, y, z, k = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(3)]
for i in range(3):
    ls[i].sort(reverse=True)
q = [(-sum([ls[i][0] for i in range(3)]), 0, 0, 0)]
res = []
used = [(0, 0, 0)]
while len(res) < k:
    s, i, j, l = heapq.heappop(q)
    res.append(-s)
    if i + 1 < x and (i + 1, j, l) not in used:
        heapq.heappush(q, (-(ls[0][i + 1] + ls[1][j] + ls[2][l]), i + 1, j, l))
        used.append((i + 1, j, l))
    if j + 1 < y and (i, j + 1, l) not in used:
        heapq.heappush(q, (-(ls[0][i] + ls[1][j + 1] + ls[2][l]), i, j + 1, l))
        used.append((i, j + 1, l))
    if l + 1 < z and (i, j, l + 1) not in used:
        heapq.heappush(q, (-(ls[0][i] + ls[1][j] + ls[2][l + 1]), i, j, l + 1))
        used.append((i, j, l + 1))
print(*res, sep='\n')

Measured memory_bytes: 4716
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> l(n);
    REP(i,n)cin >> l[i];
    sort(ALL(l));
    reverse(ALL(l));
    int answer=0;
    REP(i,k){
        answer+=l[i];
    }
    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 256
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = do
  { _  <- getInts
  ; xs <- getInts
  ; putInts (reverse xs)
  }

--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn .  unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""



Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

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;
}
template<class T>inline int cmp(vector<T>&v,T &a){
	return lower_bound(all(v),a)-v.begin();
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,A[200005];
signed main(){
	cin>>N;
	int xo=0;
	rep(i,N){
		cin>>A[i];
		if(i)xo^=A[i];
	}
	rep(i,N){
		cout<<xo<<" ";
		xo^=A[i];xo^=A[i+1];
	}
	cout<<"\n";
}


Measured memory_bytes: 5044
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long A = scan.nextLong();
        long B = scan.nextLong();
        long K = scan.nextLong();
        for (int i = 0; i < K; i++) {
            if (i % 2 == 0) {
                if (A % 2 == 1) {
                    A -= 1;
                }
                A /= 2;
                B += A;
            } else {
                if (B % 2 == 1) {
                    B -= 1;
                }
                B /= 2;
                A += B;
            }
        }
        System.out.printf("%d %d\n", A, B);
    }
}


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

int main(){
	int ret[2];
	cin >> ret[0] >> ret[1];

	int x,y,z;
	x = max(ret[0],ret[1]);
	y = min(ret[0],ret[1]);

	while(x % y){
		z = x % y;
		x = y;
		y = z;
	}
	cout << y << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  string s,t="2019/04/30";
  cin>>s;
  if(s<=t)cout<<"Heisei"<<endl;
  else cout<<"TBD"<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		int[] point = new int[n];
		for(int i = 0; i < n; i++) {
			point[i] = k;
		}
		for(int i = 0; i < q; i++) {
			int a = sc.nextInt();
			point[a-1] += 1;
		}
		for(int i = 0; i < n; i++) {
			if(point[i]-q <= 0)System.out.println("No");
			else System.out.println("Yes");
		}
		sc.close();
	}

}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;
const int MAX=100001;
const ll INF=(1LL<<50);

struct path{
    ll x;
    ll y;
    int num;
};

bool comx(path a,path b){
    if(a.x==b.x) return a.y<b.y;
    else return a.x<b.x;
}

bool comy(path a,path b){
    if(a.y==b.y) return a.x<b.x;
    else return a.y<b.y;
}

vector<pair<ll,int>> T[MAX];
int state[MAX],N;
priority_queue<pair<ll,int>> Q;

ll prim(){
    for(int i=0;i<N;i++){
        state[i]=0;
    }
    for(int i=0;i<T[0].size();i++){
        Q.push(make_pair(-T[0][i].first,T[0][i].second));
    }
    state[0]=1;
    int cnt=1;
    ll ans=0;
    while(Q.size()){
        int a=Q.top().second;
        if(state[a]==0){
            ans+=(-Q.top().first);
            cnt++;
            state[a]=1;
        Q.pop();
        for(int i=0;i<T[a].size();i++){
            int b=T[a][i].second;
            if(state[b]==0){
                Q.push(make_pair(-T[a][i].first,T[a][i].second));
            }
        }
        }
        else Q.pop();
        if(cnt==N) break;
    }
    return ans;
}

int main(){
    
    cin>>N;
    vector<path> S(N);
    for(int i=0;i<N;i++){
        cin>>S[i].x>>S[i].y;
        S[i].num=i;
    }
    
    sort(all(S),comx);
    for(int i=0;i<N-1;i++){
        T[S[i].num].push_back(make_pair(S[i+1].x-S[i].x,S[i+1].num));
        T[S[i+1].num].push_back(make_pair(S[i+1].x-S[i].x,S[i].num));
    }
    sort(all(S),comy);
    for(int i=0;i<N-1;i++){
        T[S[i].num].push_back(make_pair(S[i+1].y-S[i].y,S[i+1].num));
        T[S[i+1].num].push_back(make_pair(S[i+1].y-S[i].y,S[i].num));
    }
    
    cout<<prim()<<endl;
    
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> ps(n);
    for (int& p : ps) {
        cin >> p;
    }
    set<int> current_numbers(ps.begin(), ps.begin()+k);
    int count = 1;
    for (int i = k; i < n; ++i) {
        current_numbers.insert(ps[i]);
        int lo = *current_numbers.begin(), hi = *current_numbers.rbegin();
        count += lo != ps[i-k] || hi != ps[i];
        current_numbers.erase(ps[i-k]);
    }
    int sorted_stretches = 0;
    int current_stretch = 1;
    for (int i = 1; i < n; ++i) {
        if (ps[i] > ps[i-1]) {
            ++current_stretch;
        } else {
            current_stretch = 1;
        }
        sorted_stretches += current_stretch == k;
    }
    cout << count - max(sorted_stretches-1, 0) << endl;
    return 0;
}


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

int main()
{
	int k;
	string s;
	cin >> k >> s;
	int length = s.size();
	if (length <= k) {
		cout << s << "\n";
	}
	else {
		cout << s.substr(0, k) << "...\n";
	}
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){
    int a, b;
    scanf("%d%d",&a,&b);
    if(a>b){
        printf("%d\n",a-1);
    }else{
        printf("%d\n",a);
    }
    return 0;
}

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

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

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

int main() {
  long long N, M; cin >> N >> M;
  string S, T; cin >> S >> T;
  long long L = lcm(N, M);
  long long G = gcd(N, M);
  bool can = true;
  for (int i = 0; i < G; i++) {
    if (S.at((N/G) * i) != T.at((M/G) * i)) can = false;
  }
  if (can) cout << L << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int n;

    scanf("%d",&n);

    int i;
    int count=0;
    for(i=1;i<=n;i++){
        if(1<=i&&i<10){
            count++;
        }
        else if(99<i&&i<1000){
            count++;
        }
        else if(9999<i&&i<100000){
            count++;
        }
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define pll pair <lli,lli>
#define vll vector <lli>
#define vpll vector <pll>
#define f first
#define s second
#define pb push_back
#define priq priority_queue
#define unm unordered_map
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld double
#define eb emplace_back
const long double pi = 3.1415926535898;
const lli mod=1e9+7;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=2*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k;
    cin>>n>>k;
    lli a[n+1];
    for (int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    lli dp[2*k+2];
    mem(dp,0);
    for (int i=0;i<=a[1];i++)
    {
        dp[i]=1;
    }
    lli pre[2*k+2];
    pre[0]=dp[0];
    for (int i=1;i<=k;i++)
    {
        pre[i]=pre[i-1]+dp[i];
    }
    lli sum=a[1];
    for (int i=2;i<=n;i++)
    {
        sum+=a[i];
        for (int j=0;j<=min(sum,k);j++)
        {
            if (j-a[i]-1<0)
            {
                dp[j]=pre[j]%mod;
            }
            else
            {
                dp[j]=(pre[j]-pre[j-a[i]-1])%mod;
            }
        }
        pre[0]=dp[0];
        for (int j=1;j<=k;j++)
        {
            pre[j]=pre[j-1]+dp[j];
        }
    }
    cout<<dp[k];
    return 0;
}

Measured memory_bytes: 5968
#include<bits/stdc++.h>
using namespace std;
#define forn(i, n)             for(int i = 0; i < n; i ++)
#define forn1(i, n)            for(int i = 1; i <= n; i ++)
#define pb push_back
#define ll long long int
#define fi first
#define se second
#define ii  pair<long long int, long long int>
#define vi  vector <long long int>
#define vii vector <pair <long long int, long long int > >
#define all(cont)  cont.begin(), cont.end()
#define EPS 1e-9
#define MOD 1000000007
#define range 
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
int main(){

    //freopen("input.txt","r",stdin);
    IOS;
    clock_t clk = clock();
    ll t; cin >> t;
    cout<<t*t*t<<endl;



    cerr << endl << setprecision(10) << fixed << (double)(clock() - clk) / CLOCKS_PER_SEC;
    return 0;
}


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    

int main() {    
    int n, m;
    cin >> n >> m;
    vector<int> l(m), r(m);
    for(int i=0; i<m; i++) {
        cin >> l[i] >> r[i];
    }
    int left = 0; 
    int right = n;
    for(int i=0; i<m; i++) {
        int cl = l[i];
        int cr = r[i];
        if(cl > left) {
            left = cl;
        }
        if(cr < right) {
            right = cr;
        } 
    }
    int ans = ((right - left) >=0)? right - left + 1 : 0;
    cout << ans << endl;
    
    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n, m;
int t[15][15];
vector<int> v[15];

void vrotate(int r, int c, int size, int angle) {
	if(angle == 0 || angle == 360) return;

	memset(t, 0, sizeof(t));

	rep(i, angle/90) {
		int col = c;
		for(int i = r + size - 1; i >= r; i--, col++) {
			REP(j, c, c + size) {
				t[r+j-c][col] = v[i][j];
			}
		}

		REP(i, r, r + size) {
			REP(j, c, c + size) {
				v[i][j] = t[i][j];
			}
		}
	}
}

void reversal(int r, int c, int size) {
	REP(i, r, min(n, r + size)) {
		REP(j, c, min(n, c + size)) {
			v[i][j] = !v[i][j];
		}
	}
}

void leftshift(int r) {
	int t = v[r][0];
	rep(i, n) {
		v[r][i] = v[r][i+1];
	}
	v[r][n-1] = t;
	// rotate(v[r].begin(),v[r].begin()+1,v[r].end());
}

void rightshift(int r) {
	int t = v[r][n-1];
	for(int i = n-1; i >= 1; i--) {
		v[r][i] = v[r][i-1];
	}
	v[r][0] = t;
	// rotate(v[r].rbegin(),v[r].rbegin()+1,v[r].rend());
}

int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
bool used[15][15];

bool can(int y, int x) {
	if(0 <= y && y < n && 0 <= x && x < n) return true;
	return false;
}

void islandreversal(int r, int c) {
	queue<P> que;
	que.push(mp(r, c));

	memset(used, 0, sizeof(used));
	used[r][c] = true;
	int t = v[r][c];
	while(que.size()) {
		P p = que.front(); que.pop();
		int y = p.first;
		int x = p.second;

		if(v[y][x] == t) {
			v[y][x] = !v[y][x];
		}

		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];

			if(can(ny, nx) && !used[ny][nx] && v[ny][nx] == t) {
				que.push(mp(ny, nx));
				used[ny][nx] = true;
			}
		}
	}
}

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

	memset(v, 0, sizeof(v));
	rep(i, n) {
		v[i].resize(n);
		rep(j, n) cin >> v[i][j];
	}

	rep(i, m) {
		int o;
		cin >> o;

		int r, c, size, angle;

		if(o == 0) { // rotate
			cin >> r >> c >> size >> angle;
			r--; c--;

			vrotate(r, c, size, angle);
		} else if(o == 1) { // reversal
			cin >> r >> c >> size;
			r--; c--;

			reversal(r, c, size);
		} else if(o == 2) { // left shift
			cin >> r;
			r--;

			leftshift(r);
		} else if(o == 3) { // right shift
			cin >> r;
			r--;
			rightshift(r);
		} else if(o == 4) { // Island reversal
			cin >> r >> c;
			r--; c--;
			islandreversal(r, c);
		}

		// rep(j, n) {
		// 	rep(k, n) {
		// 		cout << v[j][k] << " ";
		// 	}
		// 	cout << endl;
		// }
	}

	rep(i, n) {
		rep(j, n) {
			cout << v[i][j];

			if(j == n-1) cout << endl;
			else cout << " ";
		}
	}

	return 0;
}

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

int main() {
    long long N;
    cin >> N;

    long long div1 = N, div2 = N;
    for (long long i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            if (i != N / i) {
                if (i + N / i < div1 + div2) {
                    div1 = i;
                    div2 = N / i;
                }
            } else {
                if (i + i < div1 + div2) {
                    div1 = i;
                    div2 = i;
                }
            }
        }
    }

    cout << div1 + div2 - 2 << endl;
    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))

L = []
for i in range(N):
    if A[i] % 2 == 1:
        L.append("A")
    elif A[i] % 2 == 0 and A[i] % 3 == 0:
        L.append('A')
    elif A[i] % 2 == 0 and A[i] % 5 == 0:
        L.append('A')
    else:
        L.append('D')
if set(L) == {'A'}:
    print('APPROVED')
else:
    print('DENIED')

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
ll x[3], k;
vvl a(3);

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin >> x[0] >> x[1] >> x[2] >> k;
  a[0].resize(x[0]);
  a[1].resize(x[1]);
  a[2].resize(x[2]);
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < x[i]; j++)
      cin >> a[i][j];
  for (int i = 0; i < 3; i++)
    sort(a[i].begin(), a[i].end());
  vector<ll> ns;
  for (int i = 0; i < x[0]; i++)
    for (int j = 0; j < x[1]; j++)
      ns.push_back(a[0][i] + a[1][j]);
  sort(ns.begin(), ns.end());
  reverse(ns.begin(), ns.end());
  vector<ll> ans;
  for (int i = 0; i < k && i < ns.size(); i++) {
    for (int j = x[2] - 1; j >= 0; j--) {
      ans.push_back(ns[i] + a[2][j]);
    }
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < k; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 42984
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#define INT_MAX 999999999
#define ll long long int
#define mod 1000000007
using namespace std;
int main()
{
    ll n, k;
    cin>>n>>k;
    vector<ll> a(n);
    for(int i = 0; i< n; i++)
        {
            int t;
            cin>>t;
            a[i] = t;
        }
    sort(a.begin(), a.end());
    vector<bool> dp(k+1);
    dp[0] = 0;
    for(int i = 1; i<=k; i++)
    {
        dp[i] = 0;
        for(int j = 0 ; j< n; j++)
        {
            if(i-a[j]>=0)
            {
                if(dp[i-a[j]]==0)
                {
                    dp[i] = 1;
                    break;
                }
            }
            else
            {
                break;
            }
        }
    }
    if(dp[k]==1)
    {
        cout<<"First"<<endl;
    }
    else
    {
        cout<<"Second"<<endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <map>

int main(){
  char b;
  std::cin >> b;
  
  std::map<char,char> m = 
  {
    {'A','T'},
    {'T','A'},
    {'C','G'},
    {'G','C'},
  };
    std::cout << m[b] << std::endl;
}

Measured memory_bytes: 888
N = int(input())
abc = []
for i in range(N):
    abc.append(list(map(int,input().split())))
A = [0 for i in range(N)]
B = [0 for i in range(N)]
C = [0 for i in range(N)]
j = 0
for j in range(N):
    if j == 0:
        A[0] = abc[0][0]
        B[0] = abc[0][1]
        C[0] = abc[0][2]
    else:
        A[j] = max(B[j-1]+abc[j][0],C[j-1]+abc[j][0])
        B[j] = max(C[j-1]+abc[j][1],A[j-1]+abc[j][1])
        C[j] = max(A[j-1]+abc[j][2],B[j-1]+abc[j][2])
print(max(A[N-1],B[N-1],C[N-1]))

Measured memory_bytes: 42588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

//const long long INF = 1LL << 60;
const int INF = 1001001001 * 2;

const int MAX_V = 110;
const int MAX_E = 9910;
int d[MAX_V][MAX_V];
int V, E;

void warshall_floyd(){
  rep(k, V){
    rep(i, V) if(d[i][k] != INF){
      rep(j, V) if(d[k][j] != INF){
        chmin(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
  cin >> V >> E;

  rep(i, V) rep(j, V){
    if(i == j) d[i][j] = 0;
    else d[i][j] = INF;
  }
  rep(i, E){
    int s, t, c;
    cin >> s >> t >> c;
    d[s][t] = c;
  }

  warshall_floyd();

  rep(i, V){
    if(d[i][i] < 0){
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
  }

  rep(i, V){
    rep(j, V){
      if(j) cout << " ";
      if(d[i][j] == INF) cout << "INF"; 
      else cout << d[i][j];
    }
    cout << endl;
  }
 
  return 0;
}





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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

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

    if(s[0]==s[1] || s[1]==s[2] || s[2] == s[3]){
        pl("Bad")
    } else {
        pl("Good")
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 0; i < N; i++) {
            list.add(sc.nextInt());
        }

        sc.close();

        int ans = 0;
        int active = 0;

        for (int i = 0; i < N; i++) {
            int tmp = list.get(i);
            if (active < tmp) {
                ans += tmp - active;
            }
            active = tmp;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23252
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool b = true;
  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]) b = false;
  }
  if(b) cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define Max 			1e6
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define ppb				pop_back
#define pf				push_front
#define ppf				pop_front
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define v 				vector
#define mii             map<ll,ll>
#define umap			unordered_map
#define pq              priority_queue<ll>
#define pqm             priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            ll x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define sp 				' '
#define pi 				3.14159265359
#define intmax 			INT32_MAX
#define intmin			INT32_MIN
#define conti           continue
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
ll d8[8][2] = {{ -1, -1}, { -1, 0}, { -1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
ll d4[4][2] = {{ -1, 0}, {0, -1}, {0, 1}, {1, 0}};
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
/* ordered set:
tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
member functions :
1. order_of_key(k) : number of elements strictly lesser than k
2. find_by_order(k) : k-th element in the set
*/
void IO()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}
void fastIO()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}




int main()
{
	fastIO();
	IO();
	ll n, d;
	cin >> n >> d;
	ll c = 0;
	d = d * d;
	ll x, y;
	ll temp;
	for (ll i = 0; i < n; i++)
	{
		cin >> x >> y;
		temp = x * x + y * y;
		if (temp <= d)
		{
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

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

int main() {
  string s,p;
  cin >> s >> p;
  int N=s.size();
  int n=p.size();
  for (int i=0; i<N; i++) {
      string A=s.substr(i,n);
      if (n>N-i) A+=s.substr(0,n-N+i);
      if (A==p) {
          cout << "Yes" << endl;break;
      }
      if (i==N-1) cout << "No" << endl;
  }
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int H,W;
char G[1000][1000];
int D[1000][1000];
pair<int,int> X;
deque<pair<pair<int,int>,int>> Q;

int main() {
 scanf("%d%d",&H,&W);
 { int x,y; scanf("%d%d",&y,&x); Q.push_back({{x-1,y-1},0}); }
 { int x,y; scanf("%d%d",&y,&x); X={x-1,y-1}; }
 rep(y,H) rep(x,W) scanf(" %c",&G[x][y]);
 rep(y,H) rep(x,W) D[x][y]=-1;
 int ans=-1;
 while(Q.size()){
  int x=Q.front().first.first;
  int y=Q.front().first.second;
  int d=Q.front().second; Q.pop_front();
  if(x<0 || y<0 || x>=W || y>=H) continue;
  if(G[x][y]=='#') continue;
  if(X==make_pair(x,y)){ ans=d; break; }
  if(D[x][y]!=-1) continue;
  D[x][y]=d;
  for(int dx=-2; dx<=2; dx++){
   for(int dy=-2; dy<=2; dy++){
   if(abs(dx)+abs(dy)==1) Q.push_front({{x+dx,y+dy},d});
   else Q.push_back({{x+dx,y+dy},d+1});
  }}
 }
 printf("%d\n",ans);
 return 0;
}

Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    ll ans = 0;
    for(int b = k+1; b <= n; b++)
    {
    	int range = b-k;
    	int xmin = (n-(k))/b;
    	int xmax = (n-(b-1))/b;
    	// printf("%d %d\n",xmin,xmax );
    	if(xmin==xmax)
    	{
	    	ans += range*(xmax+1);
    	}
    	else
    	{
	    	ans += range*(xmax+1);
    		// int l = k;
    		// int r = b-1;
    		// int m=0;
    		// while(l<=r)
    		// {
    		// 	m = l+(r-l)/2;
    		// 	if(b*xmin+m == n)
    		// 	{
    		// 		l = m;
    		// 		break;
    		// 	}
    		// 	else if(b*xmin+m < n)
    		// 		l = m+1;
    		// 	else
    		// 		r = m-1;
    		// }
    		// printf("ans bs%lld %d\n",ans,n%b );
    		// if(k)
    		ans+=max({0,(n%b)-k+1});
    	}
    	if(k==0)
    	{
    		ans-=1;
    		
    	}
    // printf("b==%d\n",b );	
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int mn=INT_MAX;

int f(int a[],int n,int i,int c){
    
    int cst[n];
    cst[0]=0;
    cst[1]=abs(a[1]-a[0]);
    
    for(int i=2;i<n;i++){
        int m;
        int u=abs(a[i]-a[i-1])+cst[i-1];
        int v=abs(a[i]-a[i-2])+cst[i-2];
        m=min(u,v);
        cst[i]=m;
    }
   // for(int i=0;i<n;i++)cout<<cst[i]<<" ";
    
    return cst[n-1];
}

int main() {
	   int n;cin>>n;
	   int a[n],i;
	   for(int i=0;i<n;i++)cin>>a[i];
	   
	   mn=f(a,n,0,0); 
	cout<<mn<<endl;
	return 0;
}


Measured memory_bytes: 4412
import math
N = int(input())
price = list(map(int,input().split()))
price.append(0)
stock = 0
money = 1000
for i in range(N):
    if price[i] <= price[i+1]:
        times = math.floor(money/price[i])
        money -= price[i]*times
        stock += times
    else:
        money += price[i]*stock
        stock =0
print(money)

Measured memory_bytes: 9192
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
 
public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			int[] array = new int[3];
			for(int i = 0; i < 3; i++) {
				array[i] = sc.nextInt();
			}
			Arrays.sort(array);
			
			System.out.println(Math.abs(array[0] - array[1]) + Math.abs(array[1] - array[2]));
		}
	}
 
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22740
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;


void main() {
    string s = readln.chomp;

    writeln(s.startsWith("YAKI") ? "Yes" : "No");
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        List<Integer> list = new ArrayList<>();
        while(sc.hasNext()){
          list.add(sc.nextInt());
        }

        Collections.sort(list);
        String ans = "";
        if (list.get(2) == list.get(0) + list.get(1)) {
            ans = "Yes";
        } else {
            ans = "No";
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    vector<vector<int>> c(3,vector<int>(3));
    rep(i,3)rep(j,3)cin >> c[i][j];
    vector<int> a(3);
    int a1Max = *max_element(ALL(c[0]));    
    for(int i=0;i<=a1Max;i++){
        vector<int> b(3);
        b[0] = c[0][0] - i;
        b[1] = c[0][1] - i;
        b[2] = c[0][2] - i;
        a[0] = i;
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        rep(j,3)rep(k,3){
            if(a[j]+b[k] != c[j][k]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    long h, n;
    cin >> h >> n;
    vector<long> a(n), b(n);
    for(int i=0; i<n; i++)
        cin >> a[i] >> b[i];

    vector<long> dp(2e4, 1e9);
    dp[0] = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<=2e4; j++)
            if(j - a[i] >= 0)
                dp[j] = min(dp[j], dp[j-a[i]] + b[i]);
    }

    long r = 1e9;
    for(int i=h; i<2e4; i++)
        r = min(r, dp[i]);
    cout << r << endl;
}


Measured memory_bytes: 384
import numpy as np
import itertools
N,M=[int(i) for i in input().split(" ")]
k_dict={}
for i in range(M):
    _in=[int(j)-1 for j in input().split(" ")]
    k=_in[0]
    s=_in[1::]
    k_dict[i]=s



p=np.asarray([int(i) for i in input().split(" ")])

def _switch(pattern):
    lamps=np.zeros(M)
    for i,pat in enumerate(pattern):
        if pat==0:
            continue
        for key in k_dict:
            if i in k_dict[key]:
                lamps[key]+=1



    return np.sum(lamps%2 == p)==M


retval=0
for i in itertools.product([0,1], repeat=N):
    retval+=_switch(i)
print(retval)


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int count=1;
  
  for(int i=1;i<N;++i){
    if(S.at(i-1)==S.at(i)){
      continue;
    }
    else{
      ++count;
    }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 512
defmodule Main do
  def main do
    use Bitwise
    [w,h,k]=IO.gets("") |> String.split() |> Enum.map(&String.to_integer(&1))

    m=IO.stream(:stdio, :line) 
    |> Enum.take(w)
    |> Enum.map(&String.trim(&1))

    count=
    Enum.map(Enum.to_list(0..(1 <<< h)-1), fn x -> 
      Enum.map(Enum.to_list(0..(1 <<< w)-1), fn y ->
        brack=
        Enum.map(Enum.to_list(0..(h-1)), fn i -> 
          Enum.map(Enum.to_list(0..(w-1)), fn j ->
            ((((x>>>i)&&&1)==0)&&((y>>>j)&&&1)==0)&&check(m, i,j)
            end
          )
          end
        )
        |>List.flatten()
        |>Enum.count(fn x-> x==true end)
        brack==k
        end
      )
      end
    )
    |>List.flatten()
    |>Enum.count(fn x-> x==true end)

    IO.puts(count)
  end

  def check(m,i,j) do
    e=elem(List.pop_at(m, j),0)
    |> String.at(i)
    e=="#"
  end
 
end


Measured memory_bytes: 31248
import java.util.*;
import java.math.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(sc.hasNext()){

        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();
        double d = sc.nextDouble();
        double e = sc.nextDouble();
        double f = sc.nextDouble();

        double x = ((double)(int)(((c*e-b*f)*1000)/(a*e-b*d)))/1000;
        double y = ((double)(int)(((c*d-a*f)*1000)/(b*d-a*e)))/1000;
//        BigDecimal x_answer = x.setScale(3, BigDecimal.ROUND_HALF_UP);
//        BigDecimal y_answer = y.setScale(3, BigDecimal.ROUND_HALF_UP);

        System.out.printf("%.3f ",x);
        System.out.printf("%.3f\n",y);

    }

    }
}

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

using namespace std;

int main() {
  string s, p;
  cin >> s >> p;

  if (p.length() <= s.length()) {
    for (size_t i = 0; i < s.length(); ++i) {
      size_t j;
      for (j = 0; j < p.length(); ++j) {
        if (s[(i + j) % s.length()] != p[j]) break;
      }
      if (j == p.length()) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3208
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
# list(map(int, input().split()))

N = int(input())

x = 26
d = 1
while N > x:
    N -= x
    x *= 26
    d += 1
N -= 1
ans = ''
for i in range(d):
    ans += chr(ord('a') + N % 26)
    N //= 26

print(ans[::-1])

Measured memory_bytes: 9312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int n;
int a[105];
int s;
int m=1000000000;
int ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s+=a[i];
    }
    for(int i=0;i<n;i++){
        if(abs(s-a[i]*n)<m){
            ans=i;
            m=abs(s-a[i]*n);
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 3648
import java.util.*;

// ABC 50-C
// http://abc050.contest.atcoder.jp/tasks/arc066_a

public class Main {
	
	static int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int[] freq = new int[n];
		for (int i = 0; i < n; i++) {
			freq[in.nextInt()]++;
		}
		
		boolean isValid = true;
		
		if (n % 2 == 1) {
			if (freq[0] != 1) {
				isValid = false;
			}
			for (int i = 2; i < n; i += 2) {
				if (freq[i] != 2) {
					isValid = false;
					break;
				}
			}
		} else {
			for (int i = 1; i < n; i += 2) {
				if (freq[i] != 2) {
					isValid = false;
					break;
				}
			}
		}
		
		long answer = 1;
		if (isValid) {
			for (int i = 0; i < n / 2; i++) {
				answer *= 2;
				answer %= MOD;
			}
		} else {
			answer = 0;
		}
		System.out.println(answer);
		
	}
}

Measured memory_bytes: 49976
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
int main() {
	int N, W; cin >> N >> W;
	vi dp(W + 1, 0);
	int v, w;
	rep(i, 0, N) {
		cin >> v >> w;
		rrep(j, W, w - 1) chmax(dp[j], dp[j - w] + v);
	}
	P(dp[W]);
	return 0;
}

Measured memory_bytes: 3200
// AOJ 2028: Gather on the Clock
// 2017.11.03 bal4u@uu

#include <stdio.h>
#include <string.h>

int a[102];
int dp[102][102];

int main()
{
	int t, n, i, j, k, v, ans;
	
	scanf("%d", &t); while (t--) {
		scanf("%d", &n);
		for (i = 0; i < n; i++) scanf("%d", a+i);
		memset(dp, 0, sizeof(dp));

		for (k = 1; k < n; k++) for (i = 0; i < n; i++) for (j = 0; j < k; j++) {
			int x = i+j+1;
			if (x >= n) x -= n;
			v = a[x] - a[i]; if (v < 0) v = -v;
			v += dp[x][k-j-1] + dp[i][j];
			if (v > dp[i][k]) dp[i][k] = v;
		}

		for (ans = 0, i = 0; i < n; i++) if (dp[i][n-1] > ans) ans = dp[i][n-1];
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1892
N = int(input())
A = sorted([int(_) for _ in input().split()])
#B[i]回の操作をすると全項N-1以下になる
#A[i]-N*B[i]+sum(B)-B[i]<=N-1 が全iで成り立つ
#B[i]=0-(-(a+x+1-N))//(N+1)

def check(x):
    b = [0 - (-(a + x + 1 - N)) // (N + 1) for a in A]
    return sum(b) == x

p = max(0, sum(A) - (N - 1) * N)
while True:
    q = check(p)
    if q:
        break
    p += 1
print(p)


Measured memory_bytes: 9032
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>

int main() {
	int n;
	std::cin >> n;
	std::string a, s;
	std::vector<std::string> str;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		str.emplace_back(a);
	}
	for (int i = 'a'; i <= 'z'; i++) {
		int cmin = 1000;
		for (int j = 0; j < n; j++) {
			int calphabet = 0;
			for (int o = 0; o < str[j].size(); o++) {
				if (str[j][o] == i) {
					calphabet++;
				}
			}
			if (calphabet <= cmin) {
				cmin = calphabet;
			}
		}
		for (int j = 0; j < cmin; j++) {
			s += i;
		}
	}
	std::cout << s << std::endl;
}

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

int main() {
	int Xa,Xb,Xc,Xd,Ya,Yb,Yc,Yd;
	cin >> Xa >> Ya >> Xb >> Yb;
	Xc=Xb+(Ya-Yb);
	Yc=Yb-(Xa-Xb);
	Xd=Xc+(Xa-Xb);
	Yd=Yc+(Ya-Yb);
	cout << Xc << " ";
	cout << Yc << " ";
	cout << Xd << " ";
	cout << Yd << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void YN(bool ans){
    if(ans)cout<<"YES"<<endl;
    else cout <<"NO"<<endl;
    return;
}
int main(){
    string S;
    cin>>S;
    bool ans = false;
    if(S == "KIHBR")ans = true;
    if(S == "AKIHBR")ans = true;
    if(S == "KIHABR")ans = true;
    if(S == "KIHBAR")ans = true;
    if(S == "KIHBRA")ans = true;
    if(S == "AKIHABR")ans = true;
    if(S == "AKIHBAR")ans = true;
    if(S == "AKIHBRA")ans = true;
    if(S == "KIHABAR")ans = true;
    if(S == "KIHABRA")ans = true;
    if(S == "KIHBARA")ans = true;
    if(S == "AKIHABAR")ans = true;
    if(S == "AKIHABRA")ans = true;
    if(S == "AKIHBARA")ans = true;
    if(S == "KIHABARA")ans = true;
    if(S == "AKIHABARA")ans = true;

    YN(ans);
    return 0;
}

Measured memory_bytes: 256