akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int N;
	int V[20], C[20];
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> V[i];
	}
	
	for (int i = 0; i < N; ++i)
	{
		cin >> C[i];
	}

	int mx = pow(2,N);
	int nowV,nowC,nowI;
	int ans = 0;
	int A[N];
	for (int i = 0; i < mx; ++i)
	{
		nowV = 0;
		nowC = 0;
		nowI = i;
		for (int j = 0; j < N; ++j)
		{
			if (nowI % 2 == 1)
			{
				nowV += V[j];
				nowC += C[j];
			}
			nowI /= 2; 
		}
		ans = max(ans,nowV-nowC);

	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  int a, b;
  vector<int> ans;
  vector<int> count;
  while(cin >> a >> b, a, b){
    int cnt = 0;
    for(int i = a; i <= b; i++){
      if(i % 4 == 0){
        if(i % 100 != 0 || i % 400 == 0){
          ans.push_back(i);
          cnt++;
        }
      }
    }
    count.push_back(cnt);
  }
  int l = 0, k = 0;
  for(int i = 0; i < ans.size(); i++){
    if(count[k] == 0){
      cout << "NA" << endl;
      i--;
    }else{
      cout << ans[i] << endl;
      l++;
    }
    if(l == count[k] && i != ans.size() - 1){
      cout << endl;
      k++;
      l = 0;
    }
  }
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
using namespace std;
int main(){
  int64_t N,x;
  cin>>N>>x;
  vector<int64_t> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  int64_t b=0;
  for(int i=0;i<N;i++){
    b+=a.at(i);
    }
  if(b>=x){
  int count=0;
  int64_t acount=0;
  sort(a.begin(),a.end());
  for(int i=0;i<N;i++){
    acount+=a.at(i);
    if(acount>x){
      acount-=a.at(i);
      break;
    }
    count++;
  }
  cout<<count;
  }
  if(b<x){
    cout<<N-1;
  }
}

Measured memory_bytes: 256
fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let h: i64 = sc.read();
    let n: usize = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let sum = a.iter().fold(0, |sum, a| sum + a);
    let result = if sum >= h { "Yes" } else { "No" };
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 8572
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
mod = 10**9+7
n, m = map(int, input().split())
broken = {int(input()) for _ in range(m)}

dp = [0]*(n+1)
dp[0] = 1
for i in range(n+1):
    for j in (1, 2):
        nex = i+j
        if nex <= n and not nex in broken:
            dp[nex] += dp[i]
            dp[nex] %= mod
print(dp[-1])


Measured memory_bytes: 11884
//be name khoda
#include<bits/stdc++.h>

typedef long long ll;
typedef long double ld;

using namespace std;

const ll INF = 1e18;
const ll maxn = 110;
const ll K = 1e6+10;
const ll mod = 1e9+7;

ll n , m , k;
ll a[maxn];
ll pre[maxn][K];
ll dp[maxn][K];

int main()
{
    cin>> n >> k;
    for(ll i = 1; i <= n; i++) cin>> a[i];

    for(ll i = 1; i <= n; i++)
    {
        for(ll j = 0; j <= k; j++)
        {
            if(i == 1){
                dp[i][j] = (a[i] >= j);
                continue;
            }
            if(j == 0){
                dp[i][j] = 1;
                continue;
            }

            dp[i][j] = ((pre[i-1][j] - pre[i-1][j-a[i]-1]) % mod + mod) % mod;
        }
        for(ll j = 0; j <= k; j++)
            pre[i][j] = (pre[i][j-1] + dp[i][j]) % mod;
    }

    cout<< (dp[n][k] + mod) % mod;
}










Measured memory_bytes: 569600
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    int all = H * W;
    all -= h * W;
    all -= w * H;
    all += h * w;
    cout << all;
    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    int N; cin >> N;
    if(N % 10 == 3) {
        cout << "bon" << endl;
    }else if(N % 10 == 0 || N % 10 == 1 ||N % 10 == 6 ||N % 10 == 8) {
        cout << "pon" << endl;
    }else {
        cout << "hon" << endl;
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
// 217
// 44

using namespace std;

const int MAXN = 300;

char str[MAXN + 1];

int dp[MAXN + 1][MAXN + 1][MAXN + 1];

int main() {
    //ifstream cin("A.in");
    //ofstream cout("A.out");
    int i, j, n, k;
    ios::sync_with_stdio(false);
    cin >> str + 1;
    cin >> k;
    n = strlen(str + 1);
    for(i = 1; i <= n; i++) {
        for(j = 0; j <= k; j++) {
            dp[i][i][j] = 1;
        }
    }
    for(i = 1; i < n; i++) {
        if(str[i] == str[i + 1]) {
            dp[i][i + 1][0] = 1;
        }
        else {
            dp[i][i + 1][1] = 1;
        }
        for(j = 1; j <= k; j++) {
            dp[i][i + 1][j] = max(dp[i][i + 1][j], dp[i][i + 1][j - 1]);
        }
    }
    for(int len = 1; len < n; len++) {
        for(int l = 1; l + len <= n; l++) {
            int r = l + len;
            for(i = 0; i <= k; i++) {
                dp[l][r][i] = max(dp[l][r - 1][i], dp[l + 1][r][i]);
                if(i >= (str[l] != str[r])) {
                    dp[l][r][i] = max(dp[l][r][i], dp[l + 1][r - 1][i - (str[l] != str[r])] + 2);
                }
            }
            for(i = 1; i <= k; i++) {
                dp[l][r][i] = max(dp[l][r][i], dp[l][r][i - 1]);
            }
        }
    }
    cout << dp[1][n][k];
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 106496
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		int a[]=new int[10],i=0;
		while(i<10)a[i++]=s.nextInt();
		Arrays.sort(a);
		while(i>7)System.out.println(a[--i]);
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int  n, k;
  cin >> n >> k;

  int cnt = 0;

  rep(i, n) rep(j, k) {
    int d1 = (j+1)%10;
    int d2 = (j+1)/10;
    if (d1>=2&&d2>=2&&d1*d2==i+1) {
      cnt++;
    } 
  }

  cout << cnt << endl;

}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,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);}
/*
 <url:https://atcoder.jp/contests/abc126/tasks/abc126_f>
 問題文============================================================
 =================================================================
 解説=============================================================
 Kを除く[0,2^M)の全てのxorがKになれば K 0 1 … 2^M-2 2^M-1 K 2^M-1 2^M-2 … 1 0 の形で作れる
 K = 0の時は
 0 0 1 1 2 2 ...
 でいい
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll M,K; cin >> M >> K;
    ll Max = 1LL<<M;
    if(Max <= K) return vector<ll>{-1};
    ll N = 1LL<<(M+1);
    res.resize(N);
    if(K == 0){
        for(ll i = 0; i < N;i+=2){
            res[i] = res[i+1] = i/2;
        }
    }else{
        res[0] = K;
        res[N/2] = K;
        
        ll XOR = 0;
        for(ll n = 0; n < Max; n++){
            if(n == K) continue;
            XOR ^= n;
        }
        if(XOR != K) return vector<ll>{-1};
        ll cnt = 0;
        for(ll n = 0; n < Max; n++){
            if(n == K) continue;
            res[cnt+1]  = res[N-1-cnt] = n;
            cnt++;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<vector<ll>>() << endl;
    return 0;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin>>a.at(i);
  vector<int> b(n,0);
  for(int i=n;i>0;i--){
    int c=2*i;
    int s=a.at(i-1);
    while(c<=n){
      s+=b.at(c-1);
      c+=i;
    }
    b.at(i-1)=s%2;
  }
  vector<int> e;
  for(int i=0;i<n;i++)
    if(b.at(i)==1)
      e.push_back(i+1);
  cout<<e.size()<<endl;
  for(int i=0;i<e.size();i++)
    cout<<e.at(i)<<(i<e.size()-1?" ":"");
  cout<<endl;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;


// modint
// 1000000007 で割ったあまりに関する四則演算を直感的に行える
template<int MODULO> struct Fp {
    long long val;

    constexpr Fp(long long v = 0) noexcept : val(v % MODULO) {
        if (val < 0) v += MODULO;
    }
    constexpr Fp operator - () const noexcept {
        return val ? MODULO - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MODULO) val -= MODULO;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MODULO;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MODULO, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MODULO;
        if (val < 0) val += MODULO;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
};

template<int MODULO> constexpr ostream& operator <<
(ostream &os, const Fp<MODULO>& x) noexcept {
    return os << x.val;
}
template<int MODULO> constexpr istream& operator >>
(istream &is, Fp<MODULO>& x) noexcept {
    return is >> x.val;
}

template<int MODULO> constexpr Fp<MODULO> modpow
(const Fp<MODULO> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
}


// 二項係数ライブラリ
template<int MODULO> struct BiCoef {
    vector<Fp<MODULO> > fac, inv, finv;
    constexpr BiCoef(int n) noexcept : fac(n, 1), inv(n, 1), finv(n, 1) {
        for(int i = 2; i < n; i++){
            fac[i] = fac[i-1] * i;
            inv[i] = -inv[MODULO%i] * (MODULO/i);
            finv[i] = finv[i-1] * inv[i];
        }
    }
    constexpr Fp<MODULO> com(int n, int k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fac[n] * finv[k] * finv[n-k];
    }
};



// ここから解答
const int MAX = 201010;
const int MOD = 1000000007;
using mint = Fp<MOD>; // mod 計算を直感的に

int main() {
    BiCoef<MOD> bc(MAX); // 二項係数計算の前処理

    long long N, K;
    cin >> N >> K;
    cout << bc.com(N-1, K-1) << endl;
}



Measured memory_bytes: 7416
#include<iostream>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
ll n,len=1;
string s="";

void solve(ll now,ll x,ll leng){
	if(now<x){
		for(int i=0;i<leng;i++){
			s+=char('a'+now%26);
			now/=26;
		}
		return ;
	}
	now-=x;x*=26;leng++;return solve(now,x,leng);
}

signed main(){
	cin>>n;
/*	while(n){
		n--;
		s+=char('a'+n%26);
		n/=26;
	}*/
/*	while(n>pow(26,len)){
		n-=pow(26,len);
		len++;
	}n--;
	for(int i=0;i<len;i++){
		s+=char('a'+n%26);
		n/=26;
	}*/
/*	n--;ll p=26,d=1;
	while(n>=p){
		n-=p;
		d++;
		p*=26;
	} 
	while(d--){
		s+=char('a'+n%26);
		n/=26;
	}*/
	n--;
	solve(n,26,1);
	reverse(s.begin(),s.end());
	cout<<s<<endl;
}

Measured memory_bytes: 3604
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define sz(x)             (int)x.size()
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        (a*(b/gcd(a,b)))
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
#define watch(x)         cout << #x << " = " << x << endl
#define trace(x)         cerr << #x << " = " << x << endl
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){
    
	int a; cin>>a;
	if(a >= 30) cout<<"Yes";
	else cout<<"No";
	
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  long countpl=0,countmi=0;
  long a[100100],b[100100],c[100100];
  //bool hugou=true;//符号が+の時trueとする
  for(int i=0;i<n;i++){
    cin >> a[i];
  }

  //a[0]の符号だけで判断するのは愚の骨頂！！！！

  /*b[0]=a[0]
  if(b[0]==0){
    counter++;
    b[0]++;
    hugou=true;
  }
  if(b[0]<0){
    hugou=false;
  }
  */
  for(int i=0;i<n;i++){

  //1 -1 1 -1
    if(i>0){
      b[i]=b[i-1]+a[i];
    }
    if(i==0){
      b[i]=a[i];
    }
    //  cout << "sum["<<i+1<<"]=" <<  b[i] << endl;
    if(i%2==0){
      if(b[i]<1){
        countpl+=1-b[i];
        b[i]=1;
      }
    }else{
      if(b[i]>-1){
        countpl+=b[i]-(-1);
        b[i]=-1;
      }
    }
    //-1 1 -1 1
    if(i>0){
      c[i]=c[i-1]+a[i];
    }
    if(i==0){
      c[i]=a[i];
    }
    //  cout<<"sum["<<i<<"]="  << b[i] << endl;
    if(i%2==0){
      if(c[i]>-1){
        countmi+=c[i]-(-1);
        c[i]=-1;
      }
    }else{
      if(c[i]<1){
        countmi+=1-c[i];
        c[i]=1;
      }
    }
  }
  cout << min(countpl,countmi) << endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int N;
    cin >> N;
    ll dp[4][4][4] = {};
    ll dp2[4][4][4] = {};
    rep(i, 4)
    {
        rep(j, 4)
            rep(k, 4) dp[i][j][k] = 1;
    }
    dp[0][1][2] = 0;
    dp[0][2][1] = 0;
    dp[1][0][2] = 0;
    rep(i, N - 3)
    {
        rep(i, 4)
        {
            rep(j, 4)
            {
                rep(k, 4)
                {
                    rep(l, 4)
                    {
                        dp2[j][k][l] += dp[i][j][k];
                    }
                }
            }
        }
        rep(i, 4)
        {
            dp2[i][1][2] -= dp[0][i][1];
            dp2[1][i][2] -= dp[0][1][i];
        }
        dp2[1][1][2] += dp[0][1][1];
        dp2[0][1][2] = 0;
        dp2[0][2][1] = 0;
        dp2[1][0][2] = 0;
        rep(i, 4)
        {
            rep(j, 4)
            {
                rep(k, 4)
                {
                    dp[i][j][k] = dp2[i][j][k] % mod;
                    dp2[i][j][k] = 0;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, 4)
    {
        rep(j, 4) rep(k, 4) ans += dp[i][j][k] % mod;
    }
    cout << ans % mod << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)
#define INF 1000000000

int main() {
	int e;
	while (cin >> e, e) {
		int m = INF;
		for (int y = 0; y*y <= e; y++) {
			for (int z = 0; z*z*z <= e; z++) {
				int x = e - y*y - z*z*z;
				if (x < 0) continue;
				m = min(m, x + y + z);
			}
		}

		cout << m << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p) / CLOCKS_PER_SEC << endl;
}

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<int>v(n);
  for (int i = 0; i < n; i++)
    cin >> v[i];
  int sum = accumulate(v.begin(), v.end(), 0LL);
  sum = ceil(sum * 1.0 / (4 * m));
  int res = 0;
  for (auto &x : v)
    res += x >= sum;
  cout << (res >= m ? "Yes" : "No") << endl;
  time();
  return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t

const int MOD = 1e9+7;
 
int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    string s;
    cin>>n;
    cin>>s;

    int ans=0;
    for(int i=0;i<n-2;i++) {
    	if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
    	{
    		ans++;
    		i++;
    	}
    }

    cout<<ans;


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define F first
#define S second
int main(){

    ll N ;
    cin >>N ;
    if(N==1)
        cout<<"2\n";
    else if(N%2==0)
        cout<<N<<endl;
    else
        cout<<2*N<<endl;
    return 0 ;

}


Measured memory_bytes: 256
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b && b < c) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 26240
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int t=1;
	while(t--){
		int n,m;
		cin>>n>>m;
		int a[n];
		std::vector<int> dp(m+1,0);
		dp[0]=0;
		for(int i=0;i<n;i++){
			cin>>a[i];
			dp[a[i]]=1;
		}
		for(int i=0;i<=m;i++){
			for(int j=0;j<n;j++){
				if(i-a[j]>=0){
					if(!dp[i-a[j]]){
						dp[i]=1;
					}
					else if(dp[i]!=1)
						dp[i]=0;
				}
			}
		}
		if(dp[m])
			cout<<"First";
		else
			cout<<"Second";
		cout<<endl;
	}
		return 0;
}
	


Measured memory_bytes: 640
n,a,b=map(int,input().split())
if (b-a)%2==0:
    print((b-a)//2);exit()
a-=1;b-=1
# print(min(b,n-1-a))
ans1=0; ans2=0
ans1+= a
aa=0 ; bb=b-a 
ans1+= (bb//2+1)

ans2=n-1-b 
b=n-1
a+=ans2
ans2+= (b-a)//2+1

print(min(ans1,ans2))

Measured memory_bytes: 61860
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int a, b, h, m; cin >> a >> b >> h >> m;
	double al1 = (h + (double) m / 60) / 12 * 2 * M_PI;
	double al2 = (double)m / 60 * 2 * M_PI;
	double al = al1 - al2 + 2*M_PI;
	if(al > 2*M_PI)al -= 2*M_PI;
	double ans = sqrt(a*a + b * b - 2* a * b * cos(al));
	cout << setprecision(12) << ans << endl;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k, x;
    cin >> k >> x;
    if(k*500 >= x){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long*)a>*(long long *)b){
        return 1;
    }
    return -1;
}

int main()
{   int i,a[21]={0},b[21]={0},k=0,n,m,x,y,c,d;
    scanf("%d%d%d",&n,&m,&c);
    for(i=0;i<m;i++){
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++){
        for(int j=0;j<m;j++){
            int tmp;
            scanf("%d",&tmp);
            a[i]+=tmp*b[j];
            if(j==m-1){
                a[i]+=c;
                if(a[i]>0){
                    k++;
                }
            }
        }
    }
    printf("%d",k);
    
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
       if(a==1||a==3||a==5||a==7||a==8||a==10||a==12)
       {
           if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)
            printf("Yes\n");
            else
                printf("No\n");
       }
       if(a==4||a==6||a==9||a==11)
       {
           if(b==4||b==6||b==9||b==11)
            printf("Yes\n");
            else
            printf("No\n");
       }
       if(a==2)
       {
           if(b==2)
            printf("Yes\n");
           else
            printf("No\n");
       }
    }

}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int n; ll k;
ll a[1 << 17];
int c[40];
ll dfs(int i, bool b,ll cur) {
	if (i < 0)return 0;
	ll z = (ll)1 << i;
	ll res = 0;
	if (b) {
		res = max(c[i], n - c[i]);
		res *= z;
		res += dfs(i - 1, true,k);
	}
	else {
		if (z > cur) {
			res = c[i] * z;
			res += dfs(i - 1, false,cur);
		}
		else {
			//0の場合
			ll a0 = c[i] * z + dfs(i - 1, true,cur);
			//1の場合
			ll a1 = (n - c[i])*z + dfs(i - 1, false, cur - z);
			res = max(a0, a1);
		}
	}
	return res;
}
int main(){
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
		per(j, 40) {
			ll x = (ll)1 << j;
			if (a[i] & x)c[j]++;
		}
	}
	cout << dfs(39, false, k) << endl;
	//stop
	return 0;
}


Measured memory_bytes: 1024
import math
import sys

s = input()
acgt = ['A', 'C', 'G', 'T']
ans, cnt = 0, 0
for c in s:
    if c in acgt:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 3060
main :: IO ()
main = do
  [a, b] <- map read . words <$> getLine
  print $ solve a b

solve :: Int -> Int -> Int
solve a b = n + 1 where
  n = length . primeFactorsSet $ gcd a b

primeFactorsSet :: Int -> [Int]
primeFactorsSet n = go n 2 []
  where
    go m i xs
      | i * i >= m = if m == 1 then xs else m:xs
      | q == 0     = go r (i + 1) (i:xs)
      | otherwise  = go m (i + 1) xs
      where
        (p, q) = divMod m i
        r = until (\a -> a `mod` i /= 0) (\a -> a `div` i) p


Measured memory_bytes: 508
#include <stdio.h>

#define MAX 100


void bubbleSort(int *A , int N){
  int j;
  int temp;
  int flag;
  int num = 0;

  flag = 1;

  while(flag){
    flag = 0;
    for( j = N-1 ; j > 0 ; j--){
      if(A[j] < A[j-1]){
        temp = A[j];
        A[j] = A[j-1];
        A[j-1] = temp;
        flag = 1;
        num++;
      }
    }
  }
  for(j = 0 ; j < N ; j++){
    printf("%d", A[j]);
    if(j != N-1) printf(" ");
  }
  printf("\n");
  printf("%d\n", num);

  return;
}

int main(void){

  int N;
  int A[MAX];
  int i;

  scanf("%d",&N);

  for(i = 0 ; i < N ; i++){
    scanf("%d",&A[i]);
  }

  bubbleSort(A, N);


  return 0;
}

Measured memory_bytes: 604
#if 0
50分
Bellman_Fordで無限をlong longの最大値にしたことで、overflow対策が
必要になったことは事前に気づくことができたが、Dijkstraで閉路があると
無限ループになることが盲点だった。
#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
using ll = long long;
ll ll_max = numeric_limits<ll>::max();
ll ll_min = numeric_limits<ll>::min();
int int_max = numeric_limits<int>::max();
int int_min = numeric_limits<int>::min();

int V, E, r, s, t, d;
// vector<pair<pair<int, int>, int> > edges1;
pair<vector<int>, vector<int> > edges2[100000];
int D[100000];
int checked[100000] = {};

// void Bellman_Ford() {
//     rep(v, V) D[v] = int_max;
//     D[r] = 0;
//     rep(v, V - 1) {
//         bool updated = false;
//         for (auto edge : edges1) {
//             s = edge.first.first;
//             t = edge.first.second;
//             d = edge.second;
//             // overflow対策
//             if (min(D[t], D[s] + d) > 0) {
//                 updated = true;
//                 D[t] = min(D[t], D[s] + d);
//             }
//         }
//         if (!updated) return;
//     }
// }

void Dijkstra() {
    rep(v, V) D[v] = int_max;
    D[r] = 0;
    // vector<int> fixed;
    priority_queue<pair<int, int> > Q;
    Q.push(make_pair(0, r));
    while (Q.size() != 0) {
        pair<int, int> top = Q.top();
        Q.pop();
        // すでに確定済み頂点なら飛ばす。
        if (checked[top.second] == 1) 
            continue;
        rep(i, edges2[top.second].first.size()) {
            int t = edges2[top.second].first[i];
            int d = edges2[top.second].second[i];
            D[t] = min(D[t], d - top.first);
            // 距離をマイナスで与えて、近いものから取り出すようにする。
            Q.push(make_pair(-D[t], t));
        }
        checked[top.second] = 1;
    }
}

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

    cin >> V >> E >> r;
    rep(e, E) {
        cin >> s >> t >> d;
        // edges1.push_back(make_pair(make_pair(s, t), d));
        edges2[s].first.push_back(t);
        edges2[s].second.push_back(d);
    }
    // cout << "input done" << endl;
    // Bellman_Ford();
    Dijkstra();
    rep(v, V) {
        if (D[v] == int_max) cout << "INF" << endl;
        else cout  << D[v] << endl;
    }

    return 0;
}


Measured memory_bytes: 17500
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <vector>



int main()
{
    std::ios_base::sync_with_stdio(0);
    std::vector<int> result;
    std::vector<int> B;
    std::vector<int> BS = {0};
    int64_t n;
    std::cin >> n;
    std::map<int, int> M;
    for (int i=0;i<n;++i)
    {
        int a;
        std::cin >> a;
        M[a]++;
    }
    for (auto it : M) B.push_back(it.second);
    std::sort(B.begin(), B.end(), std::greater<int>());
    for (int i=0;i<B.size();++i) BS.push_back(BS.back() + B[i]);

    int last = -1;
    int buff = 0;
    int div = n;
    for (int i=1;i<=n;++i)
    {
        auto it = std::upper_bound(B.begin(), B.end(), div, std::greater<int>());
        int j = std::distance(B.begin(), it);
        int k = (div == 0 ? i : (j + (BS.back()-BS[j]) / div));
        if (k >= i || div == 0) std::cout << div << "\n";
        else { --div; --i; }
    }

    return 0;
}

Measured memory_bytes: 18032
#include<iostream>
#include<algorithm>
#include<cstdint>

int const MAXN = 2e5;

int64_t const INF = 1e18+1;

int64_t pos[MAXN];
int64_t neg[MAXN];

int npos, nneg, nzer, N;
int64_t K;

int64_t countLE(int64_t v) {
  int64_t res = 0;
  //if(v >= 0) {
    //res = (int64_t)nzer*(N-nzer) + (int64_t)nzer*(nzer-1)/2; // count of zeroes
    //res += (int64_t)npos*nneg; // count of negatives
    //if(v == 0) return res;
    // count positive and <=v
    int i = 0;
    for(int p = npos-1; p > 0; --p) {
      if(i > p) i = p;
      while(i < p && pos[i]*pos[p] <= v) ++i;
      res += i;
    }
    i = nneg-1;
    for(int p = 0; p < nneg-1; ++p) {
      if(i < p) i = p;
      while(i > p && neg[i]*neg[p] <= v) --i;
      res += nneg-1 - i;
    }
  //} else {
  {
    // count negative and <= v
    int64_t i = 0;
    for(int p = 0; p < npos; ++p) {
      while(i < nneg && neg[i]*pos[p] <= v) ++i;
      res += i;
    }
  }
  return res;
}

int main() {
  std::cin >> N >> K;
  npos = nneg = nzer = 0;
  for(int i = 0; i < N; ++i) {
    int64_t A; std::cin >> A;
    if(A < 0) neg[nneg++] = A;
    else /*if(A >= 0)*/ pos[npos++] = A;
    /*else ++nzer;*/
  }
  std::sort(pos, pos+npos);
  std::sort(neg, neg+nneg);
  int64_t vL = INF, vH = -INF;
  /*if(nzer > 0) vL = vH = 0;
  if(npos > 0) {
    if(npos > 1) vH = std::max(vH, pos[npos-1]*pos[npos-2]);
    if(nneg > 0) vL = std::min(vL, pos[npos-1]*neg[0]);
  } else if(nneg > 1) {
    vH = std::max(vH, neg[0]*neg[1]);
    vL = std::max(vL, neg[0]*neg[1]);
  }
  --vL; // countLE(vL) == 0, countLE(vH) == N(N-1)/2
  */
  vL = -INF; vH = INF;
  while(vL < vH) {
    int64_t vM = vL + (vH-vL)/2;
    if(countLE(vM) < K) vL = vM+1;
    else vH = vM;
 }
 std::cout << vL << std::endl;
 return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if(k>=n)
    {
        cout<<s;
    }
    else
    {
        for(int i=0;i<k;i++)
        cout<<s[i];
        cout<<"...";
    }
}

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

int main(){
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll res=0;
	ll b[n],w[n];
	memset(b,0,sizeof(b));
	memset(w,0,sizeof(w));
	ll bj=0,wj=0;
	for(ll i=0;i<n;i++){
		if(s[i]=='.')wj++;
		if(s[i]=='#')bj++;
	}
	res = min(bj,wj);
	ll cnt = wj;
	//res= cnt;
	for(ll i=0;i<n;i++){
		if(s[i]=='#'){
			cnt++;
		}else{
			cnt--;
		}
		res = min(cnt,res);
	}

	cout<<res<<endl;
}


Measured memory_bytes: 3716
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        ArrayList<String> ans = new ArrayList<String>();
        while(sc.hasNext()){
            double[] a = {sc.nextDouble(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble(),sc.nextDouble()};
            ans.add(String.format("%.3f %.3f",getX(a),getY(a)));
        }
        for(int i = 0,size = ans.size();i < size;i++){
            System.out.println(ans.get(i));
        }
    }
    static double getX(double[] v){
        double x1 = v[0] * Math.abs(v[4]);
        double c1 = v[2] * Math.abs(v[4]);
        double x2 = v[3] * Math.abs(v[1]);
        double c2 = v[5] * Math.abs(v[1]);
        if((v[1] >= 0) == (v[4] >= 0)){
            x2 *= -1;
            c2 *= -1;
        }
        return (c1 + c2) / (x1 + x2);
    }
    static double getY(double[] v){
        double y1 = v[1] * Math.abs(v[3]);
        double c1 = v[2] * Math.abs(v[3]);
        double y2 = v[4] * Math.abs(v[0]);
        double c2 = v[5] * Math.abs(v[0]);
        if((v[0] >= 0) == (v[3] >= 0)){
            y2 *= -1;
            c2 *= -1;
        }
        return (c1 + c2) / (y1 + y2);
    }
}

Measured memory_bytes: 28136
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,tot,e[500001],nt[500001],hd[500001],g[500001];
void build(int x,int y){
	tot++;
	e[tot]=y;
	nt[tot]=hd[x];hd[x]=tot;
}
void dfs(int x,int fa){
	int i;
	for(i=hd[x];i;i=nt[i]){
		if(e[i]==fa)continue;
		dfs(e[i],x);
	}
	if(!g[x]){
		if(g[fa]){
			puts("First");
			exit(0);
		}
		g[x]=g[fa]=1;
	}
}
int main(){
	int i,x,y;
	g[0]=1;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d",&x,&y);
		build(x,y);build(y,x);
	}
	dfs(1,0);
	puts("Second");
}

Measured memory_bytes: 5376
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char a, b, c; cin >> a >> b >> c;
    if (a == c) cout << "Yes" << endl;
    else cout << "No" << endl;
}



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

int main(){
	int n , q;
	int S[10000], T[500];
	int count = 0;
	
	cin >> n;
	for (int i = 0; i < n; i++){
		scanf("%d", &S[i]);
	}
	
	cin >> q;
	for (int i = 0; i < q; i++){
		scanf("%d", &T[i]);
	}
	
	for(int j = 0; j < q;  j++){
		int i = 0;
		while (S[i] != T[j] && i < n -1) i++;
		if(i < n - 1) count ++;
	}
	
	cout << count << endl;
	
	return 0;
}

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

int N;
int table[20][20];
int dp[100000];

int main()
{
	while(cin >> N, N){
		for(int stage = 0; stage < N; stage++) {
			for(int item = 0; item <= N ; item++) {
				cin >> table[stage][item];
			}
		}
		
		for(int bit = 0; bit <= (1<<N); bit++) {
			dp[bit] = 2000000;
		}dp[0] = 0;
		
		for(int nowBit = 0; nowBit < (1<<N); nowBit++) {
			if(dp[nowBit] == 2000000) { continue; }
			
			for(int next = 0; next < N; next++) {
				if((nowBit & (1<<next)) != 0) { continue; }
				
				int minCost = table[next][0];
				for(int item = 0; item < N; item++) {
					if((nowBit & (1<<item)) != 0) {
						minCost = min(minCost, table[next][item+1]);
					}
				}
				
				int nextBit = (nowBit | (1<<next));
				dp[nextBit] = min(dp[nextBit], dp[nowBit] + minCost);
			}
		}
		
		cout << dp[(1<<N)-1] << endl ;
	}
	
	return 0;
}

Measured memory_bytes: 1424
#include <stdio.h>

int gcd(int a,int b,int c);
int gcd2(int i, int j);


int main(void){
    
    int K;
    scanf("%d", &K);

    int sum = 0;

    for(int a=1;a<=K;a++){
        for(int b=1;b<=K;b++){
            for(int c=1;c<=K;c++){
                sum += gcd(a,b,c);

            }
        }
    }

    printf("%d",sum);

    return 0;
}

int gcd(int a,int b,int c){

    int x;

    int a2 = gcd2(a,b);

    x = gcd2(a2,c);

    return x;
}

int gcd2(int i, int j){

    int temp, ans,ans2;

    if(i<j){
        temp = i;
        i=j;
        j = temp;
    }

    ans = i%j;
    // for(;;){
    //     ans2 = j % ans;
    //     if(ans2 ==0){
    //         y =  j/ans;
    //         break;
    //     }
    //     j=ans;
    //     ans = ans2;      
    // }
    while(ans!=0){
        i =j;
        j =ans;
        ans = i%j;
    }
    

    return j;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) c[i] = i+1;
  
  int res = 0, cnt = 0;
  do
  {
    if(c == a) res += cnt;
    if(c == b) res -= cnt;
    cnt++;
  }while(next_permutation(c.begin(), c.end()));
  
  cout << abs(res) << endl;
  
  return 0;
}

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

a = s.split('0').map(&:length)
b = s.split('1').map(&:length)
a.delete(0)
b.delete(0)

c = []
c << 0 if s[0] == '0'
while !a.empty? || !b.empty? do
  if s[0] == '1'
    c << a.shift unless a.empty?
    c << b.shift unless b.empty?
  else
    c << b.shift unless b.empty?
    c << a.shift unless a.empty?
  end
end
c << 0 if c.size % 2 == 0

r = [0]
c.size.times do |i|
  r[i + 1] = r[i] + c[i]
end

ans = 0
add = 2 * k + 1
0.step(by: 2, to: c.size - 1) do |i|
  left = i
  right = [(i + add), c.size].min
  tmp = r[right] - r[left]

  ans = [tmp, ans].max
end

puts ans

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

using namespace std;

int main()
{

    int n,d;
    cin>>n>>d;
    vector<vector<int>> vec;
    int x;
    vector<int> v;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
          {
             cin>>x;
             v.push_back(x);
          }
          vec.push_back(v);
          v.clear();
    }

int temp=0,diff=0,value,cnt=0;

    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {

            for(int k=0;k<d;k++)
            {
                temp=vec[i][k] - vec[j][k];
                diff+=temp*temp;

            }
           value=sqrt(diff);
            if(value*value == diff)cnt++;
            diff=0;
        }
    }

    cout<<cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, cnt1, cnt2;
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) 
	{
		int x;
		scanf("%d", &x);
		if(x % 4 == 0) ++cnt1;
		else if(x % 2 != 0) ++cnt2;
	}
	if((cnt2 == cnt1 + 1 && cnt2 + cnt1 < n) || (cnt2 > cnt1 + 1)) puts("No");
	else puts("Yes");
	return 0;
}

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

using namespace std;

int main(void){
    string a;
    int i=0,j=0,max=0;
    cin >> a;
    for(i=0;a[i];i++){
        if(a[i]=='R')
            j++;
        else{
            if (max<j)
                max = j;
            j=0;
        }
    }
    if (max<j)
        max = j;
    cout << max;
    return 0;
}

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

vector<vector<ll>> permutation(vector<ll> v) {
  vector<vector<ll>> perms;
  do {
    perms.push_back(v);
  } while (next_permutation(v.begin(), v.end()));

  return perms;
}

int toInt(vector<ll> v) {
  ll result = 0, base = 1;
  while (v.size() != 0) {
    result += v[v.size()-1] * base;
    base *= 10;
    v.pop_back();
  }

  return result;
}

int main() {
  int N;
  cin >> N;
  vector<ll> perms(N);
  rep(i, N) perms[i] = i+1;
  vector<vector<ll>> all_perms = permutation(perms);

  vector<ll> P(N), Q(N);
  rep(i, N) cin >> P[i];
  ll p = toInt(P);
  rep(i, N) cin >> Q[i];
  ll q = toInt(Q);

  ll a, b;
  for (int i = 0; i < all_perms.size(); i++) {
    ll inPerm = toInt(all_perms[i]);
    if (inPerm == p) a = i;
    if (inPerm == q) b = i;
  }

  cout << abs(a - b) << endl;
  return 0;
}


Measured memory_bytes: 4404
import java.util.*;

public class Main {
    public static int N;
    public static int[] arr;
    
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        
        while (in.hasNextInt()) {
            N = in.nextInt();
            
            arr = new int[N];
            boolean[] visited = new boolean[N];
            
            for (int i = 0; i < N; i++) {
                arr[i] = in.nextInt();
            }
            
            boolean found = false;
            for (int i = 0; i < N && !found; i++) {
                visited[i] = true;
                found = found || recursive(0, arr[i] % 10, visited, 1)
                    || recursive(0, arr[i] / 10, visited, 1);
                visited[i] = false;
            }
            
            if (found) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
    
    public static boolean recursive(int pos, int n, boolean[] visited, int len) {
        if (len == N) return true;
        if (pos == N) return false;
        
        boolean ret = false;
        int a = arr[pos] % 10;
        int b = arr[pos] / 10;
        int newNum = a == n ? b : a;
        
        if (visited[pos]) return recursive(pos+1, n, visited, len);
        if (a != n && b != n) return recursive(pos+1, n, visited, len);
        
        visited[pos] = true;
        ret = ret || recursive(0, newNum, visited, len+1);
        visited[pos] = false;
        ret = ret || recursive(pos+1, n, visited, len);
        
        return ret;
    }
}



Measured memory_bytes: 27924
import java.util.Scanner;
     
    class Main{
    	public static void main(String[] args) {
    		Scanner sc=new Scanner(System.in);
    		int a=sc.nextInt();
    		if(a==3 || a==5 || a==7) {
    			System.out.println("YES");
    		}
    		else {
    			System.out.println("NO");
    		}
    	}
    }

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>

int h, w, d, ax[90005], ay[90005], q, l[100005], r[100005];
long long data[90005];
int main() {
	std::cin >> h >> w >> d;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j) {
			int a;
			std::cin >> a;
			ax[a] = i;
			ay[a] = j;
		}
	for (int i = d + 1; i <= h * w; ++i)
		data[i] = data[i - d] + std::abs(ax[i] - ax[i - d]) + std::abs(ay[i] - ay[i - d]);
	std::cin >> q;
	for (int i = 0; i < q; ++i)
		std::cin >> l[i] >> r[i];
	for (int i = 0; i < q; ++i)
		std::cout << data[r[i]] - data[l[i]] << std::endl;
	return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
const int N=2e5+4;
int n,cnt[N];
inline int read() {
	int x=0;char c=getchar();
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x;
}
int main() {
	n=read();
	for (register int i=1;i<n;++i) {
		int b=read();
		++cnt[b];
	}
	for (register int i=1;i<=n;++i)
		printf("%d\n",cnt[i]);
	return 0;
}

Measured memory_bytes: 4368
#include<iostream>
using namespace std;
int main(){
  
  int money[9],all,sum;

  
  while(1){

    cin >>all;
    
    if(all == 0)break;

    sum=0;
    
    for(int i=0 ; i < 9 ; i++){
      cin >>money[i];
      sum+=money[i];
    }
    
    cout <<all-sum<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160