akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
  int N;
  cin >> N;
  int ans = 0;
  for(int n = 1; n <= N; n += 2) {
    int cnt = 0;
    for(int p = 1; p * p <= n; p++) {
      if(0 == n % p) {
        if(p * p == n) {
          cnt++;
        } else {
          cnt += 2;
        }
      }
    }
    if(8 == cnt) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] a = new long[N];
	        long ave =0;
	        for (int i=0 ; i<N; i++) {
	            a[i] = Long.parseLong(sc.next())-(i+1);
	        }
	        Arrays.sort(a);
	        
	        long ans=Long.MAX_VALUE;
	        for(int i=Math.max(N/2-1, 0);i<Math.min(N/2+2, N);i++) {
	        	long t = a[i];
	        	long tmp=0;
	        	for(int j=0;j<N;j++) {
		        	tmp=tmp+Math.abs(a[j]-t);	        		
	        	}
	        	ans=Math.min(ans,tmp);
	        }
	        System.out.println(ans);
	        
	    }
	}

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

using namespace std;

int q;
long long x, y;
map<long long, int> m;
int main( ) {
	scanf("%d", &q);
	while (q --) {
		scanf("%lld %lld", &x, &y);
		if (x > y) swap(x, y);
		long long tmp = 1LL * x * y - 1;

		int l = 1, r = (int )1e9;
		while (l <= r) {
			int mid = (l + r) >> 1;
			if (1LL * mid * mid < tmp) l = mid + 1;
			else r = mid - 1;
		}
		printf("%lld\n", min(x - 1, tmp / (y + 1)) + min(1LL * r, tmp / (x + 1)) + max((tmp / (r + 1)) - x, 0LL));
		//printf("fuck %lld %lld\n", min(tmp / (y + 1), x - 1), min(tmp / (x + 1), y - 1));
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;



int main(){
    int n;
    cin >> n;
    int a;
    if(n%2==0) out(n);
    else out(2*n);
}

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

int main(){
  int s;
  cin>>s;
  set<int> a;
  a.insert(s);
  int i=2;
  while(true){
    if(s%2==0){
      s=s/2;
    }
    else{
      s=s*3+1;
    }
    if(a.count(s)){
      break;
    }
    else{
      a.insert(s);
      i++;
    }
  }
  cout<<i<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using p = pair<int, int>;

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  if (K <= A + B) cout << min(K, A) <<endl;
  else{
    cout << A - (K - A - B) << endl;
  }
}

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

ans_list = [0] * N

wa = sum(A)
A = list(map(lambda x:x * 2, A))
tmp = 0
for i in range(0, N-1, 2):
    tmp += A[i]
ans_list[-1] = wa - tmp
for i in range(N-2, -1, -1):
    ans_list[i] = A[i] - ans_list[i+1]

print(" ".join(map(str, ans_list)))


Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]" << endl; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


ll dp[1010][10010];
int main() {
    ll H, N;
    cin >> H >> N;
    vector<ll> A(N), B(N);
    rep(i,N)cin >> A[i] >> B[i];
    rep(i,N+1)rep(j,H+1)dp[i][j] = INFLL;
    dp[0][0] = 0;
    rep(i,N){
        rep(j,H+1){
            ll next = min(H, j + A[i]);
            chmin(dp[i][next], dp[i][j]+B[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }
    // rep(i,N+1){
    //     rep(j,H+1){
    //         if(dp[i][j] == INFLL)cerr << -1 << " ";
    //         else cerr << dp[i][j] << " ";
    //     }
    //     cerr << endl;
    // }
    cout << dp[N][H] << endl;
}


Measured memory_bytes: 81944
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int solve(int N, int K, string S) {
	int same = 0;
	int group = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] == S[i - 1])same++;
		else group++;
	}
	return same + min(group - 1, 2 * K);
}

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

	int N,K;
	cin >> N >> K;
	string S;
	cin >> S;
	puts(solve(N, K, S));
	
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main implements Runnable {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Thread(null, new Main(), "", 128 * 1024 * 1024).start();
    }

    public void run() {
        int n = sc.nextInt(), t = sc.nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int c = sc.nextInt();
            int tt = sc.nextInt();
            if (tt <= t) {
                min = Math.min(c, min);
            }
        }
        if (min == Integer.MAX_VALUE) {
            System.out.println("TLE");
        } else {
            System.out.println(min);
        }
    }
}

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

int main() {
	
	int n; cin >> n;
	if (n == 2) {
		int o, e; cin >> o >> e;
		if (o == e) cout << 1 << endl;
		else cout << 0 << endl;
		return 0;
	}
	const int p = n / 2;
	const int z = 100001;
	vector<int> o_num(z, 0), e_num(z, 0);
	for (int i = 0; i < n; i++) {
		int v; cin >> v;
		if (i % 2 == 0) o_num[v]++;
		else e_num[v]++;
	}
	int o_firstCnt = 0;
	int o_secondCnt = 0;
	int o_firstCntValue = 0;	
	int e_firstCntValue = 0;
	int e_firstCnt = 0;
	int	e_secondCnt = 0;
	for (int i = 0; i < z; i++) {
		if (o_firstCnt <= o_num[i]) {
			o_firstCntValue = i;
			o_firstCnt = o_num[i];
		}
		if (e_firstCnt <= e_num[i]) {
			e_firstCntValue = i;
			e_firstCnt = e_num[i];
		}
	}
	sort(o_num.rbegin(), o_num.rend());
	sort(e_num.rbegin(), e_num.rend());
	o_firstCnt = o_num[0];
	o_secondCnt = o_num[1];
	e_firstCnt = e_num[0];
	e_secondCnt = e_num[1];
	int ans;
	if (o_firstCntValue != e_firstCntValue) {
		ans = n - o_firstCnt - e_firstCnt;
	}
	else { // o_firstCntValue == e_firstCntValue
		ans = min(n - o_secondCnt - e_firstCnt, n - o_firstCnt - e_secondCnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4032
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)


def 関数(liste):
    for index,val in enumerate(liste):
        if val == 0:
            return index + 1

def çözmek():
    x_liste = list(map(int, sys.stdin.readline().split()))

    res = []
    res.append(関数(x_liste))
    print(*res, sep="\n")

if __name__ == "__main__":
    çözmek()


Measured memory_bytes: 9196
///スマホコーディング
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
const int inf=1e9;
int main(){
  int a,b;cin>>a>>b;
  int s=a+b;
  int x=(s+2-1)/2;
  cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 100;

static int cnt = 0;

void trace(int *a, int n) {
    for (int i = 0; i < n-1; i++) {
        cout << a[i] << " ";
    }
    cout << a[n-1] << endl;
}

void selectionSort(int *a, int n) {
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (a[minj] > a[j]) {
                minj = j;
            }
        }
        if (i != minj) {
            cnt++;
            int tmp = a[i];
            a[i] = a[minj];
            a[minj] = tmp;
        }
    }
}

int main() {    
    int a[MAX], n;

    cin >> n;
    
    for (int i = 0; i < n; i++) cin >> a[i];
    
    selectionSort(a, n);
    trace(a, n);
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 3064
H, W = map(int, input().split())
a = []
for i in range(H):
    tmp = list(input())
    if "#" in tmp:
        a.append(tmp)

w_check = [True] * W
for i in range(len(a)):
    for j in range(W):
        if a[i][j] == "#":
            w_check[j] = False

ans = [[] for i in range(len(a))]
for i in range(len(a)):
    for j in range(W):
        if not w_check[j]:
            ans[i].append(a[i][j])

for i in ans:
    output = ""
    for j in i:
        output += j
    print(output)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a) * b << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    Long K = sc.nextLong();
    char ans = '1';
    int count = 0;
    for(int i=0; i<K; i++){
      if(S.charAt(i) != '1'){
        ans = S.charAt(i);
        break;
      }
    }
    System.out.println(ans);
  }

  public static int gcd(int a, int b){
    if(b == 0) return a;
    return gcd(b, a%b);
  }
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

ll H;

int main() {
    cin >> H;
    ll ans = 0;
    ll coeff = 1;
    while (H) {
        ans += coeff;
        H >>= 1;
        coeff <<= 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, a[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> a[i];

	int tot = 0;
	rep(i, 0, N) tot ^= a[i];
	
	rep(i, 0, N) {
		if(i) printf(" ");
		printf("%d", tot ^ a[i]);
	}
	printf("\n");
}







Measured memory_bytes: 4492
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll 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] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////

int main() {
	ll n, d; cin >> n >> d;
	int ans = 0;
	REP(i, n) {
		ll x, y;
		cin >> x >> y;
		if (d*d >= x * x + y * y)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct UnionFind{
  Int n,num;
  vector<Int> r,p;
  UnionFind(){}
  UnionFind(Int sz):n(sz),num(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
    num--;
  }
  Int size(Int x){
    return r[find(x)];
  }
  Int count() const{
    return num;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,r;
  cin>>n>>r;
  vector<Int> ps(n);
  for(Int i=0;i<n;i++) cin>>ps[i],ps[i]--;

  UnionFind uf(n);
  for(Int i=0;i<n;i++) uf.unite(i,ps[i]);

  vector<Int> vs;
  for(Int i=0;i<n;i++)
    if(uf.find(i)==i) vs.emplace_back(uf.size(i));

  const Int BS = 600;
  vector<Int> cnt(BS,0);
  for(Int v:vs)
    if(v<BS) cnt[v]++;

  vector<Int> dp(n+1,0);
  dp[0]=1;
  for(Int w=1;w<BS;w++){
    vector<Int> nx(n+1,-1);
    for(Int i=0;i<=n;i++){
      if(dp[i]) chmax(nx[i],cnt[w]);
      if(nx[i]>0&&i+w<=n) chmax(nx[i+w],nx[i]-1);
    }
    for(Int i=0;i<=n;i++) dp[i]=nx[i]>=0;
  }

  for(Int v:vs){
    if(v<BS) continue;
    for(Int i=n;i>=0;i--)
      if(i+v<=n) dp[i+v]|=dp[i];
  }

  cout<<(dp[r]?"Yes":"No")<<endl;
  return 0;
}



Measured memory_bytes: 16944
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll a,b,c,i,j,misplaced=0;
    cin>>a>>b>>c;
    if(a-b<=0)
        cout<<c<<endl;
    else
        cout<<max(0*1ll,c-(a-b))<<endl;
    return 0;
}





Measured memory_bytes: 3612
while True:
	a,op,b = input().split()
	a = int(a)
	b = int(b)

	if op == "?":
		break

	if op == "+":
		print(a+b)
	if op == "-":
		print(a-b)
	if op == "*":
		print(a*b)
	if op == "/":
		print(a//b)



Measured memory_bytes: 5596
n = int(input())
s = list(map(int, input().split()))
q = int(input())
t = list(map(int, input().split()))

count = 0

for i in t:
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if s[mid] == i:
            count += 1
            break
        elif i < s[mid]:
            right = mid
        else:
            left = mid + 1
print(count)


Measured memory_bytes: 16708
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n;
const int Maxn=1e5+5;
int h[Maxn],dp[Maxn];

int main(){
	cin>>n;
	rep(i,n){
		cin>>h[i];
	}
	memset(dp,INF,sizeof(dp));
	dp[0]=0;
	rep(i,n){
		if(i+1<n){
			chkmin(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
		}
		if(i+2<n){
			chkmin(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

template<typename T, typename Q>
istream &operator>>(istream &is, pair<T, Q> &p) {
	return is >> p.first >> p.second;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
	for (auto &x : v) is >> x;
	return is;
}                                                                  

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<string> a(n); cin >> a;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		sort(a[i].begin(), a[i].end());
		m[a[i]]++;
	}
	long long ans = 0;
	for (auto p : m) {
		ans += p.second * (long long) (p.second - 1) / 2;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 14196
#include<iostream>
#include<cmath>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#define P pair<long long, long long>


using namespace std;
const long long int MOD=1e9+7;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

long long fact[200009], inv_fact[200009];

void make_fact(){
  fact[0] = 1, inv_fact[0] = 1;
  for(int i=1;i<200001;i++){
    fact[i] = (fact[i-1]*i)%MOD;
    inv_fact[i] = modinv(fact[i], MOD);
  }
}

int main(){
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans=0;
  make_fact();
  ans += (modpow(2, n, MOD) - 1 + MOD) % MOD;
  long long sub=1;
  for(int i=0;i<a;i++){
    sub = (sub*(n-i))%MOD;
  }
  sub = (sub * inv_fact[a]) %MOD;
  ans = (ans - sub +MOD) %MOD;
  sub=1;
  for(int i=0;i<b;i++){
    sub = (sub*(n-i))%MOD;
  }
  sub = (sub * inv_fact[b]) %MOD;
  ans = (ans - sub +MOD) %MOD;
  cout << ans << endl;
}


Measured memory_bytes: 3328
H, W, K = map(int, input().split(' '))
ls, rst = [], 0
for i in range(H):
    ls.append(input())

for i in range(1 << H):
    for j in range(1 << W):
        cnt = 0
        for s in range(H):
            if i >> s & 1:
                continue
            for t in range(W):
                if j >> t & 1:
                    continue
                if ls[s][t] == '#':
                    cnt += 1
        if cnt == K:
            rst += 1
print(rst)

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

typedef long long ll;
typedef long double Double;
#define rep(i,n) for(int i = 0; i < (int)(n) ; i++)

// chmax, chmin
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;
}


void solve(long long N, std::vector<long long> A){
    long long ans = 1e18;
    long long sum = 0;
    for(int i = 0 ; i < A.size() ; i++){
        sum += A[i];
    }

    long long x = 0;
    for(int i = 0 ; i < A.size() ; i++){
        x += A[i];
        ans = min(ans, abs(sum - 2 * x));
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}



Measured memory_bytes: 1792
n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
counter = 0
for i in range(n):
    s = i + 2
    for j in range(i+1,n):        
        while (s < n and l[i] + l[j] > l[s]):
            s += 1
        counter += s-j-1
print(counter)

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int n,a[1000005];
priority_queue<int>q,p,pp,qq;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=(1<<n);i++)
	{
		scanf("%d",&a[i]);
		q.push(a[i]);
	}
	p.push(q.top());
	q.pop();
	for(int i=1;i<=n;i++)
	{
		while(!q.empty()&&!p.empty())
		{
			if(q.top()<p.top())
			{
				pp.push(p.top());
				pp.push(q.top());
				q.pop();
				p.pop();
			}
			else qq.push(q.top()),q.pop();
		}
		if(!p.empty())
		{
			printf("No\n");
			return 0;
		}
		while(!pp.empty())
		{
			p.push(pp.top());
			pp.pop();
		}
		while(!qq.empty())
		{
			q.push(qq.top());
			qq.pop();
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 6016
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

n,m=MI()
sws=[]
for i in range(m):
    sws.append(list(map(int,input().split())))
#print(sws)
ps=LI()
ans=0
for i in range(2**n):
    count=0
    for j in range(m):
        sm=0
        for k in range(1,len(sws[j])):
            sm+= (i>>(sws[j][k]-1)) %2
        #print(sm)
        if sm%2==ps[j]:
            count+=1
    if count==m:
        ans+=1
print(ans)


Measured memory_bytes: 41456
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main ()
{
   ll n,a;
   cin>>n>>a;
   ll ans=n/a;
   if(n%a)
    ans++;
   cout<<ans<<endl;
}
/* pray for me
All is well
*/


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long num = sc.nextLong();
		int len = (int) 1e7;
		long numOrg = num;
		boolean[] hurui = new boolean[len];
		Arrays.fill(hurui, true);
		hurui[0] = false;
		hurui[1] = false;
		for (int i = 2; i < len; i++) {
			if (!hurui[i]) {
				continue;
			} else {
				for (int j = i * 2; j < len; j += i) {
					hurui[j] = false;
				}
			}
		}
		long count = 0l;
		int index = 2;
		int[] used = new int[len];
		while (num > 1 && index < len - 1) {
			if (num % index == 0) {
				num /= index;
				used[index]++;
			} else {
				while (index < len - 1 && !hurui[++index]) {
				}
			}
		}
		index = 2;
		while (index < len) {
			int indexTmp = 1;
			while (used[index] >= indexTmp) {
				used[index] -= indexTmp;
				++count;
				++indexTmp;
			}
			++index;
		}
		int tmp = (int) Math.sqrt(numOrg) + 10;
		boolean flag = true;
		for (int i = 2; i <= tmp; i++) {
			if (numOrg % i == 0) {
				flag = false;
				break;
			}
		}
		if (flag && numOrg > 1) {
			++count;
		}
		if (num != numOrg && num > 1) {
			tmp = (int) Math.sqrt(num) + 10;
			flag = true;
			for (int i = 2; i <= tmp; i++) {
				if (num % i == 0) {
					flag = false;
					break;
				}
			}
			if (flag) {
				++count;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 85628
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>
using namespace std;

typedef long long ll;
// 領域は2000まで
static const int MAX = 2000;

size_t compress(vector<int> &xs,map<int,int> &x){
    sort(xs.begin(),xs.end());
    xs.erase(unique(xs.begin(),xs.end()),xs.end());
    for(int i = 0;i < xs.size();++i){
        x[xs[i]] = i;
    }
    return xs.size();
}

int main(){
    int n;
    scanf("%d",&n);
    int x1[MAX],x2[MAX],y1[MAX],y2[MAX];
    static int field[MAX * 2][MAX * 2] = {};
    vector<int> xs,ys;
    map<int,int> x,y;

    for(int i = 0;i < n;++i){
        scanf("%d %d %d %d",x1 + i,y1 + i,x2 + i,y2 + i);
        xs.push_back(x1[i]);
        xs.push_back(x2[i]);
        ys.push_back(y1[i]);
        ys.push_back(y2[i]);
    }
    
    size_t w = compress(xs,x);
    size_t h = compress(ys,y);

    for(int i = 0;i < n;++i){
        int xx1 = x[x1[i]], xx2 = x[x2[i]], yy1 = y[y1[i]], yy2 = y[y2[i]];
        field[xx1][yy1]++;
        field[xx2][yy2]++;
        field[xx1][yy2]--;
        field[xx2][yy1]--;
    }
    for(int i = 1;i < w;++i){
        for(int j = 0;j < h;++j){
            field[i][j] += field[i - 1][j];
        }
    }
    for(int i = 1;i < h;++i){
        for(int j = 0;j < w;++j){
            field[j][i] += field[j][i - 1];
        }
    }
    
    ll ans = 0;
    for(int i = 0;i < w;++i){
        for(int j = 0;j < h;++j){
            ll dx = xs[i + 1] -xs[i], dy = ys[j + 1] - ys[j];
            if(field[i][j] > 0){
                ans += dx * dy;
            }
        }
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 65624
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();

        if(a >= 13){
            System.out.println(b);
        }else if (a >= 6){
            System.out.println(b/2);
        }else{
            System.out.println(0);
        }
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 100005;
int N, Q;
int A[MAX_N];
int X[MAX_N];

int sumAOdd[MAX_N], sumAEven[MAX_N];
int sumA[MAX_N];

using II = pair<int, int>;

int checkRange(int rr, int xq)
{
  int k = A[rr] - xq;
  int kk = xq - k;
  int ret = lower_bound(A,A+N,kk) - A;
  return ret;
}

bool check(int midr, int xq)
{
  int ll = checkRange(midr, xq);
  // cerr << ll << " " << midr << " " <<xq << endl;
  return (midr - ll) >= N-midr-1 && midr > ll;
}

int solve(int xq) 
{
  int l = -1, r = N;
  // cerr << l << " " << r << endl;
  while(r-l>1) {
    int mid = (l+r)/2;
    if(check(mid, xq)) {
      // cerr << mid << ", OK" << endl;
      r = mid;
    } else {
      // cerr << mid << ", NG" << endl;
      l = mid;
    }
  }

  l = r;
  
  int ret = sumA[N] - sumA[l];
  int ll = max(checkRange(l, xq), l - (N-l));
  // cerr << l << " " << N-l << " " << l-(N-l) << endl;
  // cerr << "*** " << ll << " " << l << " " << ret << endl;

  if(ll > 0) {
    if((l-ll)%2 == (N-l)%2) { //Aから
      // cerr << "A" << endl;
      if((ll-1)%2 == 0) {
        ret += sumAEven[ll];
      } else {
        ret += sumAOdd[ll];
      }
    } else { //Bから
    // cerr << "B" << endl;
      if((ll-1)%2 == 0) {
        ret += sumAOdd[ll];
      } else {
        ret += sumAEven[ll];
      }
    }
  }

  return ret;
}

signed main()
{
  cin >> N >> Q;
  REP(n,N) {
    cin >> A[n];
    if(n%2 == 0) {
      sumAOdd[n+1] = sumAOdd[n];
      sumAEven[n+1] = sumAEven[n] + A[n];
    } else {
      sumAEven[n+1] = sumAEven[n];
      sumAOdd[n+1] = sumAOdd[n] + A[n];
    }
    sumA[n+1] = sumA[n] + A[n];
  }

  vector<int> ans;

  REP(q,Q) {
    cin >> X[q];
    ans.push_back(solve(X[q]));
  }

  for(int a : ans) {
    cout << a << endl;
  }

  return 0;
}

Measured memory_bytes: 6516
#include <iostream>
using namespace std;
  
int F[105][105];
int xg,yg,w,h;
  
  
void DFS(int Y,int X,int c){
  if(Y < 1 || X < 1)
    return;
  if(F[Y][X] != c || Y > w || X > h){
    return;
  }
  
  F[Y][X] = -1;
  DFS(Y+1,X  ,c);
  DFS(Y-1  ,X,c);
  DFS(Y,X+1  ,c);
  DFS(Y  ,X-1,c);
}
  
  
int main(){
  int xs,ys,n;
  while(1){
    cin >> w >> h;
    if(w == 0 && h == 0)
      break;
for(int i=0; i<105; i++){
      for(int j=0; j<105; j++){
        F[i][j] = 0;
      }
    }
      
    cin >> xs >> ys >> xg >> yg >> n;
  
  
    for(int i=0;i<n;i++){
      int c,d,x,y;
      cin >> c >> d >> x >> y;

      if(d == 0){
        for(int j=0;j<4;j++){
          F[x+j][y] = c;
          F[x+j][y+1] = c;
        }
      } else {
        for(int j=0;j<4;j++){
          F[x][y+j] = c;
          F[x+1][y+j] = c;
        }
      }
    }
  DFS(xs,ys,F[xs][ys]);
  
  if(F[xg][yg] == -1){
    cout << "OK" << endl;
  } else {
    cout << "NG" <<endl;
  }
  }
}


Measured memory_bytes: 3112
s = input()

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    ll N, K;
    cin >> N >> K;
    ll sum = 0;
    rep2(i, K, N+1){
        ll l = i*(i-1)/2;
        ll r = (2*N-i+1)*i/2;
        sum += r-l+1;
        sum %= MOD;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	static int a,b,c,N;
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			a=cin.nextInt();
			b=cin.nextInt();
			c=cin.nextInt();
			if(a+b+c==0){
				break;
			}
			N=cin.nextInt();
			int[] normal=new int[a+b+c+1];
			int[] ans=new int[a+b+c+1];
			int[][] d = new int[N][4];
			for(int i = 0;i<N;i++){
				for(int j = 0;j<4;j++){
					d[i][j]=cin.nextInt();
				}
				if(d[i][3]==1){
					normal[d[i][0]]=ans[d[i][0]]=1;
					normal[d[i][1]]=ans[d[i][1]]=1;
					normal[d[i][2]]=ans[d[i][2]]=1;
				}
			}
			for(int i =0;i<N;i++){
				if(normal[d[i][0]]+normal[d[i][1]]+normal[d[i][2]]==2){
					for(int j = 0;j<3;j++){
						if(normal[d[i][j]]==0){
							ans[d[i][j]]=2;
						}
					}
				}
			}
			for(int i = 1;i<normal.length;i++){
				if(ans[i]==0){
					System.out.println(2);
				}
				else if(ans[i]==2){
					System.out.println(0);
				}
				else{
					System.out.println(1);
				}
			}
		}
	}
}

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

int main(){
    string s; cin >> s;
    vector<int> alp(26, 0);
    for (char c: s){
        alp.at(c-'a')++;
    }
    bool judge=true;
    for (int count: alp){
        if (count!=0 && count%2!=0){
            judge=false;
            break;
        }
    }
    if (judge) cout << "Yes"<< endl;
    else cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cassert>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
static int C[20][3] = {{5,4,1},{6,0,2},{7,1,3},{8,2,4},{9,3,0},{0,11,10},{1,12,11},{2,13,12},{3,14,13},{4,10,14},{15,9,5},{16,5,6},{17,6,7},{18,7,8},{19,8,9},{10,16,19},{11,17,15},{12,18,16},{13,19,17},{14,15,18}};
static const int dx[3] = {0, -1, 1};
static const int dy[3] = {1, 0, 0};

static const int MAX = 305;
static const int SHIFT = 150;

class State{
public:
  int x, y, b, r, c;
  State(){}
  State(int x, int y, int b, int r):x(x), y(y), b(b), r(r){ c = 0;}
};

State getNext(State u, int r){
  int nx = dx[r];
  int ny = dy[r];
  
  if ( (u.x + u.y)%2  ){ nx *= (-1); ny *= (-1); }
  nx += u.x;
  ny += u.y;

  int bt[3], nt[3];

  rep(i, 3) bt[i] = C[u.b][i];
  rotate(bt, bt + u.r, bt + 3);
  int nb = bt[r]; // next bottom

  rep(i, 3) nt[i] = C[nb][i];
  int nr = -1; // next rotate
  rep(i, 3){
    if ( u.b == nt[r] ){ nr = i; break; }
    rotate(nt, nt+1, nt+3);
  }

  return State(nx, ny, nb, nr);
}

bool vis[MAX][MAX][20][3];

int bfs(int gx, int gy, int gb){
  queue<State> Q;
  rep(i, MAX)rep(j, MAX) rep(k,20) rep(l,3) vis[i][j][k][l] = false;

  Q.push(State(SHIFT, SHIFT, 0, 0));
  vis[SHIFT][SHIFT][0][0] = true;
  State u, v;

  while(1){
    u = Q.front(); Q.pop();
    if ( u.x == gx && u.y == gy && u.b == gb ) return u.c;
    rep(r, 3){
      v = getNext(u, r);
      if ( !vis[v.x][v.y][v.b][v.r] ){
	vis[v.x][v.y][v.b][v.r] = true;
	v.c = u.c + 1;
	Q.push(v);
      }
    }
  }
}

main(){
  int gx, gy, gb;
  while(1){
    cin >> gx >> gy >> gb;
    if ( gx == 0 && gy == 0 && gb == 0 ) break;
    gx += SHIFT;
    gy += SHIFT;
    cout << bfs(gx, gy, gb) << endl;
  }
}

Measured memory_bytes: 6996
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,s,c=0,m=1;
  cin>>n;
  vector<int> p(n,0);
  for(int i=0;i<n;i++){
    cin>>s;
    p.at(i)=s;
  }
  while(m!=2){
    if(c>n){
      cout<<-1;
      break;
    }
    else{
      m=p.at(m-1);
      c++;
    }
  }
  if(c<=n)
    cout<<c;
}


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

const int maxn=1e5+10;
int n,a[maxn<<1],l,r,b[maxn<<1],c[maxn<<1];

bool judge(int k){
	for(int i=1;i<2*n;++i)
		if(a[i]<=k)
			b[i]=0;
		else
			b[i]=1;
	memset(c,-1,sizeof(c));
	for(int i=2;i<2*n;++i)
		if(b[i]==b[i-1])
			c[i]=c[i-1]=b[i];
	for(int i=0;i<n;++i){
		if(c[n-i]!=-1)
			return c[n-i];
		if(c[n+i]!=-1)
			return c[n+i];
	}
	return b[n]^(n-1&1);
}

int main(){
	cin>>n;
	for(int i=1;i<2*n;++i)
		cin>>a[i];
	l=1;r=2*n-1;
	while(l<r){
		int mid=l+r>>1;
		if(judge(mid))
			l=mid+1;
		else
			r=mid;
	}
	cout<<l<<endl;
	return 0;
}

Measured memory_bytes: 2560
for e in iter(input,'0 0 0'):
 d=[2]*-~sum(map(int,e.split()))
 f=[]
 for _ in[0]*int(input()):
  s,t,u,v=map(int,input().split())
  if v:d[s]=d[t]=d[u]=1
  else:f+=[(s,t,u)]
 for s,t,u in f:
  if d[t]*d[u]==1:d[s]=0
  if d[u]*d[s]==1:d[t]=0
  if d[s]*d[t]==1:d[u]=0
 for x in d[1:]:print(x)


Measured memory_bytes: 5720
N = int(input())
P=list(map(int,input().split()))

a=1
for i in range(N):
  if(P[i]==0):
    a=0
    break
if a!=0:
  for i in range(N):
    a*=P[i]
    if(a>1000000000000000000):
      a=-1
      break
print(a)

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

using namespace std;
     
int main(){
    int N,X,sum=0,ans=0;
    cin >> N >> X;
    vector<int> m(N);
    for(int i=0;i<N;i++){
        cin >> m.at(i);
    }

    for(int i=0;i<N;i++){
        sum += m.at(i);
    }

    int left = X - sum;
    int i=0;
    while(left >= *min_element(m.begin(),m.end())*i){
            ans = i;
            i++;
    }
    cout << N + ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
ll read()
{
	ll tmp=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
	return tmp*f;
}
using namespace std;
char s[1010];
int main()
{
	ll a=read(),b=read(),i;
	scanf("%s",s);
	int flag=1;
	for(i=0;i<a;i++)if(s[i]<'0'||'9'<s[i])flag=0;
	if(s[a]!='-')flag=0;
	for(i=a+1;i<=a+b;i++)if(s[i]<'0'||'9'<s[i])flag=0;
	if(flag)printf("Yes\n");else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*; 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String [] s = new String[n];
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
		}
		int m = sc.nextInt();
		String [] t = new String[m];
		for(int i = 0; i < m; i++) {
			t[i] = sc.next();
		}
		int point = 0;
		for(int i = 0; i < n; i++) {
			int plus = 0;
			int minus = 0;
			for(int j= 0; j < n; j++) {
				if(s[i].equals(s[j])) {
					plus ++;
				}
			}
			for(int k = 0; k < m; k++) {
				if(s[i].equals(t[k])) {
					minus ++;
				}
			}
			if(point < plus - minus) {
				point = plus - minus;
			}
		}
		System.out.println(point);

	}

}


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

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

using namespace std;

int main() {
    long long r,d,x;
    scanf("%lld %lld %lld", &r, &d, &x);

    for (int i = 0; i < 10; ++i) {
        x = x * r - d;
        printf("%lld\n", x);
    }
    return 0;
}


Measured memory_bytes: 256
S = list(input())
ans = "None"
alphabets = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

for item in alphabets:
    if not item in S:
        ans = item
        break

print(ans)


Measured memory_bytes: 3956
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        res = N-R*r-G*g
        if res < 0:
            continue
        else:
            if res%B == 0:
                ans += 1
print(ans)


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

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
typedef vector<vi> vvi;
const int MOD = 1e9 + 7;

#define fastIO \
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define pb push_back
#define ff first
#define ss second
#define mp make_pair 

#ifdef DIV_DEBUG
#define cerr(...) __cerr(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __cerr(const char *name, Arg1 &&arg1) {
    cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __cerr(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *sep = strchr(names + 1, ',');
    cerr.write(names, sep - names) << " = " << arg1 << " |";
    __cerr(sep + 1, args...);
}
#else
#define cerr(...) 
#endif


int main() {
    fastIO;
    string s;
    cin >> s;
    int n = s.length();
    if (s[n - 1] == 's')    s += "es";
    else    s += 's';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

struct SCC {
    int n;
    vector<vector<int>> G, R, T;
    vector<bool> used;
    vector<int> vs, cmp;

    SCC(int n) : n(n), G(n), R(n), used(n), cmp(n) {}

    int operator[](int k) {
        return cmp[k];
    };

    void add_edge(int from, int to) {
        G[from].emplace_back(to);
        R[to].emplace_back(from);
    }

    void dfs(int v) {
        used[v] = true;
        for (int u : G[v]) {
            if (!used[u]) dfs(u);
        }
        vs.emplace_back(v);
    }

    void rdfs(int v, int k) {
        used[v] = true;
        cmp[v] = k;
        for (int u : R[v]) {
            if (!used[u]) rdfs(u, k);
        }
    }

    int build() {
        for (int v = 0; v < n; v++) {
            if (!used[v]) dfs(v);
        }
        fill(used.begin(), used.end(), false);
        int k = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (!used[vs[i]]) {
                rdfs(vs[i], k);
                k++;
            }
        }
        T.resize(k, vector<int>());
        for (int v = 0; v < n; v++) {
            for (int u : G[v]) {
                if (cmp[v] != cmp[u]) T[cmp[v]].emplace_back(cmp[u]);
            }
        }
        for (int i = 0; i < k; i++) {
            sort(T[i].begin(), T[i].end());
            T[i].erase(unique(T[i].begin(), T[i].end()), T[i].end());
        }
        return k;
    }
};

/*
    To.size() == V
   であればトポロジカルソートができた、そうでなければできなかったと判定できる
*/
vector<int> Tsort(vector<vector<int>>& G) {
    vector<int> To;
    int V = G.size();
    stack<int> st;
    int indeg[V] = {};
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < (int)G[i].size(); j++) {
            indeg[G[i][j]]++;
        }
    }
    for (int i = 0; i < V; i++) {
        if (indeg[i] == 0) {
            st.push(i);
        }
    }
    // vector<int> dp(V);
    while (!st.empty()) {
        int u = st.top();
        st.pop();
        To.push_back(u);
        for (int i = 0; i < (int)G[u].size(); i++) {
            indeg[G[u][i]]--;
            // dp[G[u][i]] = max(dp[G[u][i]], dp[u] + 1);
            // ans = max(ans, dp[G[u][i]]);
            if (indeg[G[u][i]] == 0) {
                st.push(G[u][i]);
            }
        }
    }
    return To;
}

signed main() {
    int n, m;
    cin >> n >> m;
    SCC scc(n);
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    int k = scc.build();
    cout << k << endl;
    vector<int> vec[k];
    rep(v, n) {
        vec[scc[v]].emplace_back(v);
    }
    auto G = scc.T;
    for (auto v : vec) {
        cout << v.size();
        for (int u : v) {
            cout << " " << u;
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 122824
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A[] = $a[0];
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->A[] = $a[0];
  }
}
printf("%d\n",(($key->A[0]+$key->A[1])*$key->A[2])/2);


Measured memory_bytes: 4344
N=int(input())
Dinner=[[int(i) for i in input().split()] for i in range(N)]
C=[Dinner[i][0]+Dinner[i][1] for i in range(N)]
C.sort(reverse=True)
ans=0
for i in range(N):
  if i%2==0:
    ans+=C[i]
  ans-=Dinner[i][1]
print(ans)


Measured memory_bytes: 67288