akhauriyash/Code-Regression huggingface dataset:
/**
 *    author:  tourist
 *    created: 30.09.2017 15:08:32       
**/
#include <bits/stdc++.h>

using namespace std;

const int N = 1234567;

template <typename T>
class fenwick {
  public:
  vector<T> fenw;
  int n;

  fenwick(int n) : n (n) {
    fenw.resize(n);
  }

  void modify(int x, T v) {
    while (x < n) {
      fenw[x] += v;
      x |= (x + 1);
    }
  }

  T get(int x) {
    T v{};
    while (x >= 0) {
      v += fenw[x];
      x = (x & (x + 1)) - 1;
    }
    return v;
  }
};

int a[N], b[N], c[N];
pair<double, int> e[N];
int id[N];

inline bool cmp(int i, int j) {
  return (a[i] * b[j] > a[j] * b[i]);
}

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  for (int rot = 0; rot < 2; rot++) {
    for (int i = 0; i < n; i++) {
      if (b[i] < 0) {
        a[i] *= -1;
        b[i] *= -1;
        c[i] *= -1;
      }
      id[i] = i;
    }
    sort(id, id + n, cmp);
    double low = -1e9, high = 1e9;
    for (int it = 0; it < 80; it++) {
      double mid = 0.5 * (low + high);
      for (int i = 0; i < n; i++) {
        e[i] = make_pair((c[id[i]] - mid * a[id[i]]) / b[id[i]], i);
      }
      sort(e, e + n);
      fenwick<int> f(n);
      long long inv = 0;
      for (int i = 0; i < n; i++) {
        inv += f.get(e[i].second);
        f.modify(e[i].second, 1);
      }
      long long need = ((long long) n * (n - 1) / 2 + 1) / 2;
      if (inv >= need) {
        high = mid;
      } else {
        low = mid;
      }
    }
    double ans = 0.5 * (low + high);
    printf("%.17f", ans);
    if (rot == 0) {
      printf(" ");
    } else {
      printf("\n");
    }
    for (int i = 0; i < n; i++) {
      swap(a[i], b[i]);
    }
  }
  return 0;
}


Measured memory_bytes: 8832
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-05 17:42:39
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int n, W; cin >> n >> W;
  vector<int64> w(n), v(n);
  vector<pair<int64, int64>> w0, w1, w2, w3;
  for (int i = 0; i < n; ++i) {
    cin >> w[i] >> v[i];
    if (w[i] == w[0]) {
      w0.emplace_back(v[i], w[i]);
    } else if (w[i] == w[0] + 1) {
      w1.emplace_back(v[i], w[i]);
    } else if (w[i] == w[0] + 2) {
      w2.emplace_back(v[i], w[i]);
    } else {
      w3.emplace_back(v[i], w[i]);
    }
  }

  sort(w0.rbegin(), w0.rend());
  sort(w1.rbegin(), w1.rend());
  sort(w2.rbegin(), w2.rend());
  sort(w3.rbegin(), w3.rend());

  int64 ans = 0;

  for (int i = 0; i <= n; ++i) {
    for (int j = i; j <= n; ++j) {
      for (int k = j; k <= n; ++k) {
        for (int l = k; l <= n; ++l) {
          int64 n0 = i, n1 = j - i, n2 = k - j, n3 = l - k;
          //cerr << n0 << " " << n1 << " " << n2 << " " << n3 << '\n';
          int64 sum0 = 0, sum1 = 0, sum2 = 0, sum3 = 0;
          for (int m = 0; m < min(n0, static_cast<int64>(w0.size())); ++m) {
            sum0 += w0[m].first;
          }
          for (int m = 0; m < min(n1, static_cast<int64>(w1.size())); ++m) {
            sum1 += w1[m].first;
          }
          for (int m = 0; m < min(n2, static_cast<int64>(w2.size())); ++m) {
            sum2 += w2[m].first;
          }
          for (int m = 0; m < min(n3, static_cast<int64>(w3.size())); ++m) {
            sum3 += w3[m].first;
          }
          if (w[0] * n0 + (w[0] + 1) * n1 + (w[0] + 2) * n2 + (w[0] + 3) * n3 <= W){
            ans = max(ans, sum0 + sum1 + sum2 + sum3);
          }
        }
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200005;
int a[N],s[N],n;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i>=1;i--)
		s[a[i]]++;
	for(int i=1;i<=n;i++)
		printf("%d\n",s[i]);
	return 0;
}

Measured memory_bytes: 5428
import java.util.*;
import java.io.*;
import java.lang.*;
class Main {
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        long n = ob.nextLong(),k=ob.nextLong();
        if(k>n){
            System.out.println(Math.min(k-n,n));
        }
        else{
            System.out.println(Math.min(n%k,k-(n%k)));
        }



    }
}

Measured memory_bytes: 21204
#include<stdio.h>

int main()
{
    double a, b, c, d, e, f, x, y;
    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f) != EOF){
        x = (e * c - b * f) / (e * a - b * d);
        y = (d * c - a * f) / (d * b - a * e);
        printf("%0.3lf %0.3lf\n",x+0.0001,y+0.0001);
    }   
    return 0;
}

Measured memory_bytes: 656
def main():
    N = int(input())
    A = list(map(int, input().split()))
    BubbleSort(A, N)
    

def BubbleSort(A, N):
    count = 0
    for i in range(N):
        for j in range(N-1,i,-1):
            if A[j] < A[j-1]:
                A[j], A[j-1] = A[j-1], A[j]
                count += 1
    print(*A)
    print(count)

main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
// aya_seは起床のプロ
using namespace std;

//@ebi's definition

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n - 1)); i >= (int)(a); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;

struct Edge
{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w) {}
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<ll>>;

// xxpoxx's definition
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define RES(a, n) (a).resize(n)
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L << 60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/

// aya_se's definition
vl fac, finv, inv;
void COMinit(ll N)
{
    fac.resize(N);
    finv.resize(N);
    inv.resize(N);
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < N; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
ll COM(ll n, ll k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll modinv(ll a, ll m)
{
    ll b = m, u = 1, v = 0;
    while (b)
    {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

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

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

int main()
{
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int now = 0;
    int n = s.size();
    int ans = 0;
    rep(i, 0, n)
    {
        if (now < (s[i] - 'A'))
        {
            now = s[i] - 'A';
        }
        else
        {
            ans++;
            now = s[i] - 'A';
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3228
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)

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

ll const INF = 1LL << 60;
ll const MAX_N = 100000;
ll const MOD = 1000000007;

// 桁DPの遷移
// - 2進数の計算

// N=63435 について、
// dp[3][true]  : 634○○未満となる数(00000 - 63399)についての暫定の答え
// dp[3][false] : 634○○ となる数(63400 ~ 63429)についての暫定の答え

// dp[i][true] から dp[i+1][true]にのみ遷移
// (i桁目まででNより小さいなら、i+1桁目をどのように選んでもNより小さい）
// dp[i][false] から dp[i+1][true]へ遷移
// (i桁目までNと同じで、 i+1桁目はNより小さい数の時)
// dp[i][false] から dp[i+1][false]へ遷移
// (i桁目までNと同じで、 i+1桁目もNと同じ数の時)

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    const int MAX_BIT = 45;
    ll dp[MAX_BIT + 1][2];

    rep(i, MAX_BIT + 1) rep(j, 2) dp[i][j] = -1;

    dp[MAX_BIT][0] = 0;

    for (int d = MAX_BIT - 1; d >= 0; d--) {
        ll mask = 1LL << d;
        ll num = 0;

        rep(i, N) {
            if (A[i] & mask) num++;
        }

        // cout << "dp[" << d + 1 << "][0]: " << dp[d + 1][0] << ", "
        //      << "dp[" << d + 1 << "][1]: " << dp[d + 1][1] << endl;
        // cout << "- mask: " << mask << endl;
        // cout << "- 0:" << N - num << ", 1:" << num << endl;
        // cout << "- mask * num: " << mask * num << endl;
        // cout << "- mask * (N - num): " << mask * (N - num) << endl;

        if (dp[d + 1][1] >= 0) {
            chmax(dp[d][1], dp[d + 1][1] + mask * max(num, N - num));
        }

        if (dp[d + 1][0] >= 0) {
            if (K & mask) {
                chmax(dp[d][1], dp[d + 1][0] + mask * num);
                chmax(dp[d][0], dp[d + 1][0] + mask * (N - num));
            } else {
                chmax(dp[d][0], dp[d + 1][0] + mask * num);
            }
        }
    }

    // rep(i, MAX_BIT + 1) {
    //     rep(j, 2) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << max(dp[0][0], dp[0][1]) << endl;

    return 0;
}


Measured memory_bytes: 4008
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int m = max(a, b);
	m = max(m, c);
	int sum = (a + b + c) - m;

	for (int i = 0; i < k; i++) {
		m *= 2;
	}
	cout << sum + m << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll val[2][3];
int main()
{
	ll n;
	cin >> n;
	for (ll i = 0; i <= 1; i++)
		for (ll j = 0; j <= 2; j++)
			cin >> val[i][j];
	ll res = n;
	for (ll i = 0; i <= 2; i++)
		for (ll j = i + 1; j <= 2; j++)
			for (ll c1 = 0; c1 <= n; c1++)
				for (ll c2 = 0; c2 <= n; c2++)
				{
					if (c1 * val[0][i] + c2 * val[0][j] > n) break;
					ll cur = n + c1 * (val[1][i] - val[0][i]) + c2 * (val[1][j] - val[0][j]);
					res = max(res, cur);
					for (ll k = 0; k <= 2; k++)
					{
						ll tmp = cur + (val[0][k] - val[1][k]) * (cur / val[1][k]);
						res = max(res, tmp);
					}
				}
	for (ll i = 0; i <= 2; i++)
	{
		ll cur = n + (n / val[0][i]) * (val[1][i] - val[0][i]);
		res = max(res, cur);
		for (ll j = 0; j <= 2; j++)
			for (ll k = 0; k <= 2; k++)
			{
				if (j == k || j == i || k == i) continue;
				for (ll x = 0; x <= cur; x++)
				{
					if (x * val[1][j] > cur) break;
					ll tmp = cur + x * (val[0][j] - val[1][j]);
					res = max(res, tmp);
					tmp += ((cur - x * val[1][j]) / val[1][k]) * (val[0][k] - val[1][k]);
					res = max(res, tmp);
				}
			}
	}
	for (ll j = 0; j <= 2; j++)
		for (ll k = 0; k <= 2; k++)
			for (ll l = 0; l <= 2; l++)
			{
				if (j == k || j == l || k == l) continue;
				for (ll c1 = 0; c1 <= n; c1++)
				{
					if (c1 * val[1][j] > n) break;
					ll cur = n + c1 * (val[0][j] - val[1][j]);
					res = max(res, cur);
					for (ll c2 = 0; c2 <= n; c2++)
					{
						if (c1 * val[1][j] + c2 * val[1][k] > n) break;
						ll tmp = cur + c2 * (val[0][k] - val[1][k]);
						res = max(res, tmp);
						tmp += (n - c1 * val[1][j] - c2 * val[1][k]) / val[1][l] * (val[0][l] - val[1][l]);
						res = max(res, tmp);
					}
				}
			}
	for (int i = 0; i <= 2; i++)
		swap(val[0][i], val[1][i]);
	for (ll j = 0; j <= 2; j++)
		for (ll k = 0; k <= 2; k++)
			for (ll l = 0; l <= 2; l++)
			{
				if (j == k || j == l || k == l) continue;
				for (ll c1 = 0; c1 <= n; c1++)
				{
					if (c1 * val[1][j] > n) break;
					ll cur = n + c1 * (val[0][j] - val[1][j]);
					res = max(res, cur);
					for (ll c2 = 0; c2 <= n; c2++)
					{
						if (c1 * val[1][j] + c2 * val[1][k] > n) break;
						ll tmp = cur + c2 * (val[0][k] - val[1][k]);
						res = max(res, tmp);
						tmp += (n - c1 * val[1][j] - c2 * val[1][k]) / val[1][l] * (val[0][l] - val[1][l]);
						res = max(res, tmp);
					}
				}
			}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S, T; cin >> S >> T;
  int ans = 0, N = S.length();
  for(int i = 0; i < N; i++){
    if(S[i] != T[i]) ans += 1;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int M1, D1, M2, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    
    if (D2 == D1 + 1){
                cout << 0 << endl;
    } else {
                cout << 1 << endl;
    }
            
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 200005
int n,m,ans;
int p[maxn];
int pos[maxn];
int cnt[maxn];
void add(int x,int val) {
    if(x<=0) return ;
    cnt[x] += val;
    if(cnt[x]==0 && val==-1) ans--;
    if(cnt[x]==1 && val==1) ans++;
}
main() {
    int i,x,val;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++) pos[i] = i+1;
    ans = 0;
    for(i=1;i<=n;i++) scanf("%d",&p[i]), add(--pos[p[i]],1);
    while(m--) {
        scanf("%d%d",&x,&val);
        add(pos[p[x]]++,-1);
        p[x] = val;
        add(--pos[p[x]],1);
        printf("%d\n",n-ans);
    }
}


Measured memory_bytes: 3840
n,q = map(int,input().split())
my_list = [input().split() for s in range(n)]
count = 0
while my_list != []:
    a = my_list.pop(0)
    n1 = a[0]
    n2 = int(a[1])
    if n2 > q:
        n2 -= q
        count += q
        my_list.append([n1,n2])
    else:
        count += n2
        print(n1,count)


Measured memory_bytes: 16856
#include <bits/stdc++.h>
#include<cmath>
using namespace std;
 
int main() {
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {

	string a, b;
	cin >> a >> b;
	int t = 0;
	a += b;
	while (a.size()) {
		t *= 10;
		t += a[0] - '0';
		a.erase(0, 1);

	}
	int x=sqrt((double)t);
	if (x*x == t)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int n;
int v[100000];

void init()
{
}

void solve()
{
    map<int, int> mo, me;
    int i = 0;
    while(true){
        if(2*i < n) me[v[2*i]]++;
        else break;
        if(2*i+1 < n) mo[v[2*i+1]]++;
        else break;
        i++;
    }
    int maxo = 0, maxo2=0, maxe = 0, maxe2=0;
    int maxov = 0, maxov2=0, maxev = 0, maxev2=0;
    for(auto it = me.begin(); it != me.end(); it++){
        if(maxe < it->se){
            maxe2 = maxe;
            maxev2 = maxev;
            maxe = it->se;
            maxev = it->fi;
        }
        else if(maxe2 < it->se){
            maxe2 = it->se;
            maxev2 = it->fi;
        }
    }
    for(auto it = mo.begin(); it != mo.end(); it++){
        if(maxo < it->se){
            maxo2 = maxo;
            maxov2 = maxov;
            maxo = it->se;
            maxov = it->fi;
        }
        else if(maxo2 < it->se){
            maxo2 = it->se;
            maxov2 = it->fi;
        }
    }
    if(maxov != maxev) cout << n - maxe - maxo << endl;
    else{
        if(maxo2 < maxe2) cout << n - maxe2 - maxo << endl;
        else cout << n - maxe - maxo2 << endl;
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    REP(i, n) cin >> v[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 5376
package main

import "fmt"

func main() {

  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  if (a > b) {
      a, b = b, a
  }
  if (b > c) {
      b, c = c, b
  }
  if (a > b) {
     a, b = b,a
  }
  fmt.Println(a, b, c)
}


Measured memory_bytes: 1156
import math

N = int(input())
n = int(math.sqrt(N))

def f_ab(a, b):
    if len(str(a)) >= len(str(b)):
        return len(str(a))
    else:
        return len(str(b))

ans = float('inf')
for a in range(1, n+1):
    if N % a == 0:
        b = N // a
        ans = min(ans, f_ab(a, b))
print(ans)

Measured memory_bytes: 39024
n = int(input())
tmp = 0
num_list = []
for i in range(1,10**9):
    if tmp < 10**9:
        tmp += i
        num_list.append(tmp)
    else:
        break
for i in range(len(num_list)):
    if num_list[i] >= n:
        print(i+1)
        break

Measured memory_bytes: 4888
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int n, m, c;
  cin >> n >> m >> c;
  vector<int > b(m, 0);
  REP(i, m )cin >> b[i];
  int ans = 0;
  int tmp;
  int sum;
  REP(i, n){
    sum = 0;
    REP(j, m){
      cin >> tmp;
      sum += tmp*b[j];
    }
    if(sum + c > 0){
      ans ++;
    }
  }
  cout << ans << endl;

}


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

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

    vector<lint> a(n);
    for(auto& elem : a)  cin >> elem;

    map<lint,lint> mp;
    for(lint i=0; i<n; i++) {
        mp[a[i]]++;
    }

    lint ans = 0;
    for(auto& e : mp)  ans += (e.second)*(e.second-1)/2;

    for(lint i=0; i<n; i++) {
        cout << ans - (mp[a[i]]-1) << endl;
    }
}

Measured memory_bytes: 11904
#include<stdio.h>
int main(){
  long long n,q,l,r,m,x,s,t,i,a[100010],b[100010]={};
  long long c[100010]={};
  scanf("%lld %lld",&n,&q);
  for(i=0;i<n;i++)scanf("%lld",&a[i]);
  a[n]=1e9;
  for(i=0;i<n;i++)c[i+1]=c[i]+a[i];
  for(i=0;i<n;i++)b[i+1]=b[i]+((n%2==i%2)?0:a[i]);
  //for(i=0;i<=n;i++)printf("%d ",b[i]);printf("\n");
  while(q--){
    l=0;
    r=n;
    scanf("%lld",&x);
    if(x>=a[n-1]){
      printf("%lld\n",b[n]);
      continue;
    }
    while(r-l-1){//printf("l%d %d\n",l,r);
      m=(l+r)/2;//printf("%d\n",a[m]);
      t=n-m-1;
      s=m-t+1;//printf("%d %d %d %d\n",s,t,a[s],a[m]);
      if(s<0)l=m;
      else if(a[m+1]<=x)l=m;
      else if(s==0)l=m;
      else if(a[s-1]>=x)r=m;
      else if(x-a[s-1]<=a[m]-x)r=m;
      else if(x-a[s]>a[m+1]-x)l=m;
      else l=m;//printf("l%d %d\n",l,r);
    }//printf("%d\n",l);
    t=n-l-1;
    s=l-t+1;
    if(s<0)s=0;
    printf("%lld\n",b[s]+c[n]-c[l+1]);
  }
  return 0;
}
    


Measured memory_bytes: 3968
/* by Natsu Kinmoe */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define loop(i,n) for(int i=0;i<(n);i++)
#define cont(i,n) for(int i=1;i<=(n);i++)
#define circ(i,a,b) for(int i=(a);i<=(b);i++)
#define range(i,a,b,c) for(int i=(a);((c)>0?i<=(b):i>=(b));i+=(c))
#define foreach(it,v) for(__typeof((v).begin()) it=(v).begin(),_e_D_=(v).end();it!=_e_D_;it++)
#define y0 y0O0OO00OO0OO0OO0OOO00OO0OO0O0O000OO0
#define y1 y1II11II11III11I1III11II111IIII1II1I1
#define pub push_back
#define pob pop_back
#define mak make_pair

typedef long long ll;
typedef long double lf;
const int Inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3fll;
/* Source code starts here */

int n,k;
int x[66],y[66],c[66];
lf ds[66];

lf dist(lf x,lf y){
	return sqrtl(x*x+y*y);
}

int main(){
	scanf("%d%d",&n,&k);
	cont(i,n)scanf("%d%d%d",x+i,y+i,c+i);
	if(k==1)return 0&puts("0.0000000000");
	lf l=0,r=1000000;
	loop(tms,150){
		lf m=(l+r)/2;bool can=0;
		cont(i,n)ds[i]=m/c[i];
		cont(j,n)cont(i,j){
			lf dis=dist(x[i]-x[j],y[i]-y[j]);
			lf xi,yi;
			if(dis>=ds[i]+ds[j])continue;
			if(ds[i]>ds[j]+dis)xi=dis,yi=0;
			else if(ds[j]>ds[i]+dis)xi=0,yi=0;
			else{
				xi=(ds[i]*ds[i]-ds[j]*ds[j]+dis*dis)/(2*dis);
				yi=sqrt(ds[i]*ds[i]-xi*xi);
			}
			lf xx=(x[j]-x[i])/dis,yy=(y[j]-y[i])/dis;
			range(tm,-1,1,2){
				lf nx=xi*xx+yi*yy*tm+x[i];
				lf ny=xi*yy-yi*xx*tm+y[i];
				int cnt=0;
				cont(i,n)if(dist(x[i]-nx,y[i]-ny)<=ds[i]+1e-10)cnt++;
				if(cnt>=k)can=1;
			}
		}
		if(can)r=m;
		else l=m;
	}
	printf("%.10Lf\n",l);
	return 0;
}

Measured memory_bytes: 3816
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL H,W,M;
//i行目を横に見た時の、爆破地点の合計をrow[i]とおく
vector<LL> row;
//i列目を縦に見た時の、爆破地点の合計をcolumn[i]とおく
vector<LL> column;
//爆破地点(h,w)を格納
set<pair<LL,LL>> bombed;
//bombedに(h,w)が格納されているかを調べる関数　あればtrueを返す
bool has_h_w(LL h,LL w){
    auto iter = bombed.find(pair<LL,LL>(h,w));
    return (iter!=bombed.end());
}

LL ans = 0;

void solve(){
    //h行目を横に見た時の、爆破地点の合計がjのとき
    //row_num[j]はhを要素に持つ
    map<LL,vector<LL>> row_num;
    for(int h=1;h<=H;h++) row_num[row[h]].push_back(h);

    //w列目を横に見た時の、爆破地点の合計がjのとき
    //column_num[j]はwを要素に持つ
    map<LL,vector<LL>> column_num;
    for(int w=1;w<=W;w++) column_num[column[w]].push_back(w);

    auto bomber = [&](){
        auto row_iter=(--row_num.end());
        auto column_iter=(--column_num.end());
        LL row_numof_bomb = row_iter->first;
        LL column_numof_bomb = column_iter->first;
        vector<LL> row_index = row_iter->second;
        vector<LL> column_index = column_iter->second;
        for(int i=0;i<row_index.size();i++){
            LL h = row_index[i];
            for(int j=0;j<column_index.size();j++){
                LL w = column_index[j];
                if(has_h_w(h,w)){
                    ans = row_numof_bomb + column_numof_bomb - 1LL;
                }else{
                    ans = row_numof_bomb + column_numof_bomb;
                    return;
                }
            }
        }
    };
    bomber();
}

int main(){
    cin >> H >> W >> M;
    row = vector<LL>(H+1,0);
    column = vector<LL>(W+1,0);
    for(int i=0;i<M;i++){
        LL h,w;
        cin >> h >> w;
        row[h]++;
        column[w]++;
        bombed.insert(pair<LL,LL>(h,w));
    }

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35620
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>
#include <unordered_map>
#include <vector>

using namespace std;

int sumab(int a, int b) {
	int sum = 0;
	while (a > 0) {
		sum += a % 10;
		a /= 10;
	}
	while (b > 0) {
		sum += b % 10;
		b /= 10;
	}
	return sum;
}

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

	int lowestSum = sumab(1, N-1);
	for (int i = 2; i < N / 2; i++) {
		int currentSum = sumab(i, N - i);
		if (currentSum < lowestSum) {
			lowestSum = currentSum;
		}
	}
	cout << lowestSum;
}


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

using P = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<P> sch(N);
  for (int i{}; i < N; ++i) {
    int X, L;
    cin >> X >> L;
    sch[i].second = X - L;
    sch[i].first = X + L;
  }
  sort(sch.begin(), sch.end());

  int ans{};

  int end{sch[0].second};
  for (const auto& r : sch) {
    if (end > r.second)
      continue;
    end = r.first;
    ++ans;
  }

  cout << ans << endl;
}


Measured memory_bytes: 1024
n = int(input())
t = 0
x = 0
y = 0
for _ in range(n):
    tt, xt, yt = map(int, input().split())
    tt -= t
    m = abs(xt - x) + abs(yt - y)
    if m > tt:
        print('No')
        exit()
    elif m < tt:
        if m%2 != tt%2:
            print('No')
            exit()
    t += tt
    x = xt
    y = yt
print('Yes')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	string S,T;

	cin >> S >> T;

	printf("%s%s\n",T.c_str(),S.c_str());

	return 0;
}


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

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

bool used[4];
int a[4], v[4], e[3];

int tp[5][7] = {
  {0, 0, 1, 0, 0, 1, 1},
  {0, 0, 0, 1, 0, 1, 1},
  {0, 0, 0, 0, 1, 1, 1},
  {0, 0, 1, 0, 1, 0, 1},
  {0, 0, 0, 1, 1, 0, 1}
};

bool calc() {
  rep(i, 5) {
    stack<int> sta;
    int cv = 0, ce = 0;
    rep(j, 7) {
      if(tp[i][j]) {
        int e2 = sta.top(); sta.pop();
        int e1 = sta.top(); sta.pop();
        int r;
        switch(e[ce++]) {
          case 0: r = e1 + e2; break;
          case 1: r = e1 - e2; break;
          case 2: r = e1 * e2; break;
        }
        sta.push(r);
      }else {
        sta.push(v[cv++]);
      }
    }
    if(sta.top()==10) {
      stack<string> sts;
      string s;
      cv = ce = 0;
      rep(j, 7) {
        if(tp[i][j]) {
          string s2 = sts.top(); sts.pop();
          string s1 = sts.top(); sts.pop();
          string r;
          switch(e[ce++]) {
            case 0: r = s1 + "+" + s2; break;
            case 1: r = s1 + "-" + s2; break;
            case 2: r = s1 + "*" + s2; break;
          }
          r = "(" + r + ")";
          sts.push(r);
        }else {
          stringstream ss;
          ss << v[cv++];
          sts.push(ss.str());
        }
      }
      cout << sts.top() << endl;
      return true;
    }
  }
  return false;
}

bool e_dfs(int c) {
  if(c==3) {
    return calc();
  }else {
    rep(i, 3) {
      e[c] = i;
      if(e_dfs(c+1)) return true;
    }
  }
  return false;
}

bool v_dfs(int c) {
  if(c==4) {
    return e_dfs(0);
  }else {
    rep(i, 4) {
      if(!used[i]) {
        used[i] = true;
        v[c] = a[i];
        bool r = v_dfs(c+1);
        used[i] = false;
        if(r) return true;
      }
    }
  }
  return false;
}

int main() {
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] && a[0]) {
    if(!v_dfs(0)) cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
     ll n,k;
     cin >> n >>k;
     ll m = n/k;
     ll a= n-k*m;
     ll b= a-k;
     cout << min (a,abs(b)) <<endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> res(N, 1);
  for (int i = 0; i < M; ++i) {
    int d; cin >> d;
    for (int j = 0; j < d; ++j) {
      int a; cin >> a; --a;
      res[a] = 0;
    }
  }
  int cnt = 0;
  for (int i = 0; i < N; ++i) if (res[i]) ++cnt;
  cout << cnt << endl;
}


Measured memory_bytes: 3620
package main

import (
	"fmt"
	"strings"
)

func main() {
	var a,b,c string
	fmt.Scan(&a,&b,&c)

	as := strings.Split(a,"")
	bs := strings.Split(b,"")
	cs := strings.Split(c,"")

	fmt.Println(as[0] + bs[1] + cs[2])
}

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

using namespace std;

const int MAXN = 1e5 + 10;
long long h[MAXN];
long long dp[MAXN];

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

    dp[n] = 0;
    dp[n-1] = abs(h[n] - h[n-1]);

    for (int i = n-2; i >= 1; i--)
        dp[i] = min(dp[i+2] + abs(h[i] - h[i+2]), 
                    dp[i+1] + abs(h[i] - h[i+1]));

    cout << dp[1];
    return 0;
}

Measured memory_bytes: 1792
C = []
for i in range(3):
	C.append([int(i) for i in input().split()])

D_h = [[C[idx][jdx+1]-C[idx][jdx] for idx in range(3)] for jdx in range(2)]
D_v = [[C[idx+1][jdx]-C[idx][jdx] for idx in range(2)] for jdx in range(3)]

for idx in range(2):
	if D_h[idx][0] != D_h[idx][1]:
		print("No")
		exit(0)
	elif D_h[idx][0] != D_h[idx][2]:
		print("No")
		exit(0)

for idx in range(2):
	if D_v[0][idx] != D_v[1][idx]:
		print("No")
		exit(0)
	elif D_v[0][idx] != D_v[2][idx]:
		print("No")
		exit(0)

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ss substr
typedef long long ll ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;
typedef map<ll,ll> mapi ;
typedef map<string,string> maps ;


int main()
{
  //freopen("lifeguards.out", "w", stdout) ;
  //freopen("lifeguards.in", "r", stdin) ;
  ios_base::sync_with_stdio(0) ;
  cin.tie(NULL) ;
  cout.tie(NULL) ;
 
 //int t ; cin >> t ; while(t--){} 
 
 ll n ; cin >> n ;
 ll r = sqrt(n) + 1 ; 
 for ( ll i = r ; i >= 1 ; i-- )
 {
   if ( n % i == 0 )
   {
     cout << ( i - 1 ) + ( n/i - 1 ) ;
     return 0 ;
   }
 }

}

Measured memory_bytes: 256
use std::cmp::*;

fn main() {
  let (n, k): (usize, u32) = get::tuple();
  let abs: Vec<(u32, u64)> = get::tuples(n);
  
  let bs = (0..32).rev().map(|i| (1u32 << i) & k).filter(|&x| x != 0).collect::<Vec<_>>();
  
  let mut ans = 0;
  for i in 0 .. bs.len()+1 {
    let mask = if i==bs.len() {0} else {bs[i] - 1} | (0..i).map(|d|bs[d]).sum::<u32>();
    let sum = abs.iter().map(|&(a,b)|if a|mask==mask {b} else {0}).sum::<u64>();
    ans = max(ans, sum)
  }

  println!("{}", ans)
}

#[allow(dead_code)]
mod get {
  use std::io::*;
  use std::str::*;

  pub fn val<T: FromStr>() -> T {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().parse::<T>().ok().unwrap()
  }

  pub fn vals<T: FromStr>(n: usize) -> Vec<T> {
    let mut vec: Vec<T> = vec![];
    for _ in 0 .. n {
      vec.push(val());
    }
    vec
  }

  pub fn tuple<T1: FromStr, T2: FromStr>() -> (T1, T2) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    (x, y)
  }

  pub fn tuples<T1: FromStr, T2: FromStr>(n: usize) -> Vec<(T1, T2)> {
    let mut vec: Vec<(T1, T2)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple());
    }
    vec
  }

  pub fn tuple3<T1: FromStr, T2: FromStr, T3: FromStr>() -> (T1, T2, T3) {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    let mut it = buf.trim_right().split_whitespace();
    let x = it.next().unwrap().parse::<T1>().ok().unwrap();
    let y = it.next().unwrap().parse::<T2>().ok().unwrap();
    let z = it.next().unwrap().parse::<T3>().ok().unwrap();
    (x, y, z)
  }

  pub fn tuple3s<T1: FromStr, T2: FromStr, T3: FromStr>(n: usize) -> Vec<(T1, T2, T3)> {
    let mut vec: Vec<(T1, T2, T3)> = vec![];
    for _ in 0 .. n {
      vec.push(tuple3());
    }
    vec
  }

  pub fn list<T: FromStr>() -> Vec<T> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().split_whitespace().map(|t| t.parse::<T>().ok().unwrap()).collect()
  }

  pub fn lists<T: FromStr>(h: usize) -> Vec<Vec<T>> {
    let mut mat: Vec<Vec<T>> = vec![];
    for _ in 0 .. h {
      mat.push(list());
    }
    mat
  }

  pub fn chars() -> Vec<char> {
    let mut buf = String::new();
    let s = stdin();
    s.lock().read_line(&mut buf).ok();
    buf.trim_right().chars().collect()
  }
}


Measured memory_bytes: 6524
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a,b,i,c=0;
		while (stdIn.hasNext()) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c=a+b;
			for(i=0;0<c;i++){
				c=c/10;
			}
			System.out.println(i);
	}
	}
}

Measured memory_bytes: 20424
N,A,B = map(int,input().split())
S = input().strip()
cntA = 0
cntB = 0
for i in range(N):
    x = S[i]
    if x=="a" and cntA<A+B:
        print("Yes")
        cntA += 1
    elif x=="b" and cntA<A+B and cntB<B:
        print("Yes")
        cntA += 1
        cntB += 1
    else:
        print("No")

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

int main(){
  int w,a,b;
  cin >> w >> a >> b;
  int ans ;
  
  if(b >= a+w) cout << b - (a+w) << endl;
  else if(a >= b+w) cout << a - (b+w) << endl;
  else cout << 0 << endl;
}


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

int main() {
  int N,A,B,C,D;
  string S;
  cin >> N >> A >> B >> C >> D >> S;
  A--;
  B--;
  C--;
  D--;
  vector<bool> ma(N,false);
  
  for (int i=0; i<N; i++) {
    if (S[i] == '.') {
      ma[i] = true;
    }
  }
  if (C > D) {
    for (int i=B; i<=D; i++) {
      if (ma[i-1] && ma[i] && ma[i+1]) {
        break;
      }
      if (i == D) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  
  for (int i=A+1; i<C-2; i++) {
    if (!(ma[i] || ma[i+1])) {
      cout << "No" << endl;
      return 0;
    }
  }
  for (int i=B+1; i<D-2; i++) {
    if (!(ma[i] || ma[i+1])) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int a[55];
    a[0]=a[1]=1;
    rep(i,50)a[i+2]=a[i+1]+a[i];
    int n;cin>>n;
    cout<<a[n]<<endl;
    return 0;
}


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

int cnt = 0;

bool func_prime(int i, int N)
{
	if (i % 5 == 1)
	{
		cout << i;
		cnt++;
		if (cnt == N)
		{
			return true;
		}
		cout << " ";
	}
	return false;
}
int main()
{
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	int N;
	scanf("%d", &N);

	vector<bool> is_prime(55555 + 1, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int i;
	for (i = 2; i * i <= 55555; i++)
	{
		if (is_prime[i])
		{
			if (func_prime(i, N))
			{
				return 0;
			}

			for (int j = 2; j * i <= 55555; j++)
			{
				is_prime[i * j] = false;
			}
		}
	}
	// cout << " check prime done \n";
	while (i <= 55555)
	{
		if (is_prime[i] && func_prime(i, N))
		{
			return 0;
		}
		i++;
	}
	cout << "failed";
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){ 
    int a,b,c,d=0;
    cin >> a >> b >> c;
    if(a!=b){ d++; }
    if(b!=c){ d++; }
    if(a!=c){ d++; }  
    if(d==0) {d++;}
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
t = [list(map(int, input().split())) for i in range(n)]

t.sort(key=lambda x: (x[1], x[0]))

now = 0
for i in range(n):
    now += t[i][0]
    if now > t[i][1]:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 90328
#include<bits/stdc++.h>
using namespace std;
#define clz(n) __builtin_clz(n)
typedef long long ll;
const int mod=924844033;
const int w_=5;
const int N=(1<<20)+1;
inline int ksm(ll a,int b,int c=1){for(;b;b/=2,a=a*a%mod)if(b&1)c=c*a%mod;return c;}
int jc[N],jc2[N];

void Init(){
	jc[0]=1;
	for(int i=1;i<N;i++)jc[i]=(ll)jc[i-1]*i%mod;
	jc2[N-1]=ksm(jc[N-1],mod-2);
	for(int i=N-1;i;i--)jc2[i-1]=(ll)jc2[i]*i%mod;
}

int n_,lgn_;
int rev_[N],omg_[N];
void FFT_init(int n){
    lgn_=32-clz(n-1);n_=1<<lgn_;
    rev_[0]=0;omg_[0]=1;
    ll d=ksm(w_,441<<(21-lgn_));
    for(int i=1;i<n_;i++){
        omg_[i]=omg_[i-1]*d%mod;
        rev_[i]=rev_[i/2]>>1|(i&1)<<(lgn_-1);
    }
}

ll ww[N];
void FFT(int*a,int fg=0){
    for(int i=0;i<n_;i++)if(rev_[i]<i)swap(a[i],a[rev_[i]]);
    int s,t;
    for(int i=0;i<lgn_;i++){
        t=1<<i;
        for(int j=0;j<1<<i;++j)ww[j]=omg_[j<<(lgn_-i-1)];
        for(int j=0;j<n_;j+=t<<1){
            int*at=a+j,*bt=a+j+t;
            for(int k=0;k<t;++k){
                s=ww[k]*bt[k]%mod;
                bt[k]=at[k]-s;bt[k]+=bt[k]>>31&mod;
				at[k]+=s-mod;at[k]+=at[k]>>31&mod;
            }
        }
    }
    if(fg){
        reverse(a+1,a+n_);
        ll iv=ksm(n_,mod-2);
        for(int i=0;i<n_;++i)a[i]=a[i]*iv%mod;
    }
}

int C(int n,int k){
	if(k<0)return 0;
	if(n<0){
		int res=C(k-n-1,k);
		if(k&1)return (mod-res)%mod;
		else return res;
	}
	if(n<k)return 0;
	return (ll)jc[n]*jc2[k]%mod*jc2[n-k]%mod;
}
int n,f[N],a[N],sz[N],fa[N];
vector<int>g[N];
void dfs(int x){
	sz[x]=1;
	for(int i:g[x])if(i!=fa[x]){
		fa[i]=x;dfs(i);
		f[sz[i]]++;sz[x]+=sz[i];
	}
	f[n-sz[x]]++;
}


int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;Init();
	for(int i=1;i<n;++i){
		int x,y;cin>>x>>y;
		g[x].push_back(y);g[y].push_back(x);
	}
	dfs(1);
	for(int i=0;i<=n;++i)f[i]=(ll)f[i]*jc[i]%mod;
	for(int i=0;i<=n;++i)a[i]=jc2[i];
	reverse(a,a+n+1);
	FFT_init(2*n+1);
	FFT(f);FFT(a);
	for(int i=0;i<n_;++i)f[i]=(ll)f[i]*a[i]%mod;
	FFT(f,1);
	for(int i=1;i<=n;++i){
		int ret=(ll)C(n,i)*n%mod,res=(ll)f[i+n]*jc2[i]%mod;
		ret=(ret-res+mod)%mod;
		cout<<ret<<'\n';
	}
	return 0;
}


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

using namespace std;
#define BUF (1000)
#define ll long long 

int n;

int main(void){
	cin >> n;
	int n_=n;
	int ans = 0;
	while(n>10){
		int a=n%10;
		ans+=a;
		n/=10;
	}

	ans+=n;

//	cout << ans;
	if(n_%ans==0){
		cout << "Yes";
	}else cout << "No";

	return 0;
}


Measured memory_bytes: 256
//Atcoder 177B
#include <bits/stdc++.h>
#define endl "\n"

using namespace std;

int main(){
	string s,t;
	cin >> s >> t;
	int max=0;
	for(int i=0;i<s.length()-t.length()+1;i++){
		int temp=i;
		int count=0;
		for(int j=0;j<t.length();j++){
			if(s[i]==t[j]){
				count++;
			}
			i++;
		}
		if(count>max) max=count;
		i=temp;
	}
	cout << t.length()-max << endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)
#define rep2(i, a, b) for(int i=a; i<=(int)(b); ++i)
#define all(v) v.begin(),v.end()
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, p;
  string s;
  cin >> n >> p;
  cin >> s;

  ll ans = 0;
  if (p == 2 || p == 5) {
    rep(i, n) {
      if ((s[i]-'0') % p == 0) ans += (i+1);
    }
    cout << ans << endl;
    return 0;
  }
  reverse(all(s));
  int ten = 1, a = 0;
  vector<int> cnt(p);
  rep(i, n) {
    ++cnt[a];
    a += ten * (s[i] - '0');
    a %= p;
    ten = ten * 10 % p;
    ans += cnt[a];
  }
  cout << ans << endl;
}

Measured memory_bytes: 720
#include <stdio.h>

int main() {
	int N = 0;
	int R = 0;

	scanf("%d %d", &N, &R);

	if(N >= 10) {
		printf("%d\n", R);
	} else {
		printf("%d\n", R + 100*(10-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();
        int[] d = new int[N];
        //d[0] = sc.nextInt();
        int sum = 0;

        for(int i=0; i<=N-1; i++){
            d[i] = sc.nextInt();
            for(int j=0; j<i; j++){
                sum = sum + d[i] * d[j];
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21076
import java.util.*;

public class Main{

	public static void main(String args[]){
      
      Scanner sc=new Scanner(System.in);
      
      String S=sc.next();
      
      if(S.contains("a") && S.contains("b") && S.contains("c")){
      	System.out.println("Yes");
      }else{
      	System.out.println("No");	
      }
      
    }
}

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

typedef long long           ll;
typedef unsigned long long  ull;


#define srev                reverse(s.begin(),s.end())
#define sortstr             sort(s.begin(), s.end());
#define gtl(x)              getline(cin, (x))
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define PI                  acos(-1)
#define Precision(a) 		cout << fixed << setprecision(a)
#define FasterIO()     		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

int main()
{
    int k, a, b, x;
    cin >> k;
    cin >> a >> b;
    x=(b/k)*k;
    if(a<=x) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
using namespace std;
int m, n, ans = 0, temp;
int a[15][10005];
void dfs(int d)
{
	int up;
	if (d == m)
	{
		temp = 0;
		for (int j = 0; j < n; j++)
		{
			up = 0;
			for (int i = 0; i < m; i++)
				if (a[i][j])
					up++;
			temp += max(up, m - up);
		}
		ans = max(ans, temp);
		return;
	}
	dfs(d + 1);
	for (int j = 0; j < n; j++)
		if (a[d][j])
			a[d][j] = 0;
		else
			a[d][j] = 1;
	dfs(d + 1);
}
int main(void)
{
	while (cin >> m >> n)
	{
		if (!m)
			break;
		for (int i = 0; i < m; i++)
			for (int j = 0; j < n; j++)
				cin >> a[i][j];
		dfs(1);
		cout << ans << endl;
	}
	
}

Measured memory_bytes: 3448
n = int(input())
s = input()

lcount = 0
rcount = 0

count = 0
for i in range(n):
  if s[i] == ')':
    count += 1
  else:
    count -= 1
  lcount = max(lcount,count)

count = 0
for i in reversed(range(n)):
  if s[i] == '(':
    count += 1
  else:
    count -= 1
  rcount = max(rcount,count)
  
print('('*lcount+s+')'*rcount)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
struct edge { int s, t, c; };
bool compare(const edge& e1, const edge& e2) {
	return e1.c < e2.c;
}
int V, E, par[10009]; edge e[100009];
int root(int x) {
	if(par[x] == x) return x;
	return par[x] = root(par[x]);
}
void unite(int x, int y) {
	x = root(x);
	y = root(y);
	par[x] = y;
}
bool same(int x, int y) {
	return root(x) == root(y);
}
int main() {
	scanf("%d%d", &V, &E);
	for(int i = 0; i < E; i++) scanf("%d%d%d", &e[i].s, &e[i].t, &e[i].c);
	sort(e, e + E, compare);
	int ret = 0;
	for(int i = 0; i < V; i++) par[i] = i;
	for(int i = 0; i < E; i++) {
		if(!same(e[i].s, e[i].t)) {
			ret += e[i].c;
			unite(e[i].s, e[i].t);
		}
	}
	printf("%d\n", ret);
	return 0;
}



Measured memory_bytes: 4412