akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n, m; cin >> n >> m;
    vector<ll> a(n);
    vector<bool> vec(n, false);
    for (int i = 0; i < m; ++i) {
        int p; string s;
        cin >> p >> s;
        --p;
        if(vec[p]) continue;
        if(s == "AC"){
            vec[p] = true;
        }
        else{
            ++a[p];
        }
    }
    ll ans1 = 0;
    for (int j = 0; j < n; ++j) {
        if(vec[j]) ans1++;
    }
    ll ans2 = 0;
    for (int k = 0; k < n; ++k) {
        if(vec[k]) ans2 += a[k];
    }
    cout << ans1 << ' ' << ans2 << endl;

}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll, greater<ll> > mp;
    rep(i,n)cin>>a[i];
    rep(i,n)mp[a[i]]++;
    ll ra=0,rb=0;
    for(auto x:mp){
        ll tmp=x.second;
        if(ra!=0&&rb!=0)break;
        if(ra==0)tmp-=2;
        if(ra==0&&tmp>=0){
            ra=x.first;
        }
        if(rb==0)tmp-=2;
        if(rb==0&&tmp>=0)rb=x.first;
    } 
    cout << (ra*rb) << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i <= b; i++)


int main() {
	string s;
	int N;
	int a;
	int b;
	
	cin >> N >> a >> b;
	cin >> s;
	int passed = 0;
	int out_passed = 0;
	for(int i= 0; i < N; i++){
		if(s[i] == 'c'){
			cout << "No" << "\n";
		}
		else if(s[i] == 'a' && passed < a+b){
			cout << "Yes" << "\n";
			++passed;
		}
		else if(s[i] == 'b' && passed < a+b && out_passed < b){
			cout << "Yes" << "\n";
			++passed;
			++out_passed;
		}
		else
			cout << "No" << "\n";
	}
}


Measured memory_bytes: 896
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


class Combination {
public:
	Array fact;//n！
	Array inv;//n!の逆元
	ll mod;
	Combination(ll n, ll _mod) {
		mod = _mod;
		fact.resize(n + 1);
		fact[0] = 1;
		REP(i, n) {
			fact[i + 1] = (fact[i] * (i + 1LL)) % mod;
		}
		inv.resize(n + 1);
		inv[n] = mod_inv(fact[n]);
		for (int i = n; i > 0; i--) {
			inv[i - 1] = inv[i] * i % mod;
		}
	}
	//modの逆元
	ll mod_inv(ll x) {
		ll n = mod - 2;
		ll res = 1LL;
		while (n > 0) {
			if (n & 1) res = res * x % mod;
			x = x * x % mod;
			n >>= 1;
		}
		return res;
	}
	ll nCr(ll n, ll r) {
		return ((fact[n] * inv[r] % mod) * inv[n - r]) % mod;
	}
	ll nPr(ll n, ll r) {
		return (fact[n] * inv[n - r]) % mod;
	}
	ll nHr(ll n, ll r) {
		//重複組み合わせ：n種類のものからr個取り出す組み合わせ
		return nCr(r + n - 1, r);
	}
};

Combination com(1e6 + 10, MOD);

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

	ll h, w, a, b;
	cin >> h >> w >> a >> b;
	
	ll ans = 0;
	ll pre = 0;
	for (ll x = b+1; x <= w; x++) {
		ll y = h - a;
		//cout << x << " " << y<< " "<<ans<<" "<<pre << endl;

		ll now = com.nHr(x, y-1);
		ll sum = (now - pre+MOD)%MOD;
		pre = now;
		(sum *= com.nHr(w - x + 1, h - y))%=MOD;
		ans += sum;
		ans %= MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int d(int x, int y) {
  return abs(x - y);
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, x, y; cin >> n >> x >> y;
  vector<int> ans(n + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int dis = j - i;
      dis = min(dis, d(i, x) + d(x, j));
      dis = min(dis, d(i, y) + d(y, j));
      dis = min(dis, d(i, x) + 1 + d(y, j));
      dis = min(dis, d(i, y) + 1 + d(x, j));
      ans[dis]++;
    }
  }

  for (int k = 1; k < n; k++) {
    cout << ans[k] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define SZ(i) int(i.size())
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#endif

const int MAXN = 1000006;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, a[MAXN];
ll pre[MAXN], suf[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;
    REP (i, n*3) {
        cin >> a[i];
    }

    {
        // build prefix as big as possible
        priority_queue<int, vector<int>, greater<int> > pq;
        ll sum = 0;
        REP (i, n*3) {
            pq.emplace(a[i]);
            sum += a[i];
            if (SZ(pq) > n) {
                sum -= pq.top();
                pq.pop();
            }

            if (SZ(pq) == n) {
                pre[i] = sum;
            } else {
                pre[i] = -INF;
            }
        }
    }

    {
        // build prefix as small as possible
        priority_queue<int, vector<int>, less<int> > pq;
        ll sum = 0;
        for (int i=n*3-1; i>=0; i--) {
            pq.emplace(a[i]);
            sum += a[i];
            if (SZ(pq) > n) {
                sum -= pq.top();
                pq.pop();
            }

            if (SZ(pq) == n) {
                suf[i] = sum;
            } else {
                suf[i] = INF;
            }
        }
    }

    ll ans = -INF;
    REP (i, 3*n-1) {
        ans = max(ans, pre[i] - suf[i+1]);
    }

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


Measured memory_bytes: 13432
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

struct Combination {
	vector<int64_t> _fact, _rfact, _inv;
	int64_t MOD;

	Combination(size_t sz, int64_t mod) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1), MOD(mod) {
		_fact[0] = _rfact[sz] = _inv[0] = 1;
		for (int i = 1; i <= sz; ++i) {
			_fact[i] = _fact[i - 1] * i % MOD;
		}
		_rfact[sz] = inverse(_fact[sz]);
		for (int i = sz - 1; i >= 0; --i) {
			_rfact[i] = _rfact[i + 1] * (i + 1) % MOD;
		}
		for (int i = 1; i <= sz; ++i) {
			_inv[i] = _rfact[i] * _fact[i - 1] % MOD;
		}
	}

	inline int64_t fact(int k) const { return _fact[k]; }
	inline int64_t rfact(int k) const { return _rfact[k]; }
	inline int64_t inv(int k) const { return _inv[k]; }

	int64_t inverse(int64_t x) const { return pow(x, MOD - 2); }
	int64_t pow(int64_t x, int64_t n) const {
		int64_t ret = 1;
		while (n > 0) {
			if (n & 1) { (ret *= x) %= MOD; }
			(x *= x) %= MOD;
			n >>= 1;
		}
		return ret;
	}

	int64_t P(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(n - r) % MOD;
	}
	int64_t C(int n, int r) const {
		if (r < 0 || n < r) { return 0; }
		return fact(n) * rfact(r) % MOD * rfact(n - r) % MOD;
	}
	int64_t H(int n, int r) const {
		if (n < 0 || r < 0) { return 0; }
		return r == 0 ? 1 : C(n + r - 1, r);
	}
};

int main() {
	constexpr Int MOD = 1e9 + 7;
	Int N, M;
	cin >> N >> M;

	Combination cb(M, MOD);
	Int ans = 0;
	for (int i = 0; i <= N; ++i) {
		Int add = cb.C(N, i) * cb.P(M, i) % MOD * cb.P(M-i, N-i) % MOD * cb.P(M-i, N-i) % MOD;
		if (i % 2) { add = -add; }
		(ans += add + MOD) %= MOD;
	}
	cout << (ans + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 14872
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  sort(ALL(A));
  vector<ll> sum(N + 1);
  sum[0] = 0;
  REP(i, N) sum[i + 1] = sum[i] + A[i];
  int ng = 0;
  REP(i, N - 1) {
    if (2 * sum[i + 1] < A[i + 1]) ng = i + 1;
  }
  cout << N - ng << endl;
  return 0;
}

Measured memory_bytes: 1408
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s,a[10000005];
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)
	{
		k=n/i;
		s+=k*(k+1)/2*i;
	}
	cout<<s;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

typedef long long ll;
typedef pair<int, int> P;
typedef complex<double> C;

const int INF = 99999999;
const int MAX_N = 100000;

int N;
int a[MAX_N];

void input() {
    scanf("%d", &N);
    REP(i, N) {
        scanf("%d", &a[i]);
    }
}

void solve() {
    int t1 = 0, t2 = 0, t3 = 0;
    int cnt = 1;
    int mx = 0;
    FOR(i, 1, N) {
        if (a[i] == a[i - 1]) {
            t3 = t2;
            t2 = t1;
            t1 = cnt;
            cnt = 0;
            mx = max(mx, t1 + t2 + t3);
        }
        cnt++;
    }
    t3 = t2;
    t2 = t1;
    t1 = cnt;
    cnt = 0;
    mx = max(mx, t1 + t2 + t3);
    printf("%d\n", mx);
}

int main() {
    input();
    solve();
    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  int N;
  cin >> N;
  vector<int> a(N);
  vector<int> cnt((int)1e+5);
  rep(i, N) {
    cin >> a[i];
    cnt[a[i]]++;
  }

  int ans = 0;
  rep(i, (int)1e+5 - 1) {
    int temp = cnt[i - 1] + cnt[i] + cnt[i + 1];
    chmax(ans, temp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace tmnfipc2020
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_tmnfipc2020B();
            Console.Out.Flush();
        }

        public static void solve_tmnfipc2020B()
        {
            int[] av = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int[] bw = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            int t = Convert.ToInt32(Console.ReadLine());

            //vx = wx + |a - b|
            int d = Math.Abs(av[0] - bw[0]);
            int x = av[1] - bw[1];
            if (x <= 0)
            {
                Console.WriteLine("NO");
            }
            else
            {
                if ((double)d / x <= t)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }

        public static void solve_tmnfipc2020A()
        {
            Console.WriteLine(Console.ReadLine().Substring(0, 3));
        }
    }
}

Measured memory_bytes: 28548
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "hi\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string s(1,x); return s;}
const int MOD = 1e9 + 7;
template <typename T> void maxself(T& a, T b) {
	a = max(a, b);
}
template <typename T> void minself(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
int32_t main() {
	IAMSPEED
	// set testing to 0 when submitting to judge
	int m,k; cin >> m >> k;
	if(m==0) {
		if(k!=0) return cout << -1, 0;
		return cout<< "0 0", 0;
	} else if(m==1) {
		if(k!=0)return cout << -1, 0;
		return cout <<"0 0 1 1", 0;
	}
	int len = 1<<m;
	if(k>len-1)return cout << -1, 0;
	deque<int> dq;
	//int len = 1<<m;
	FOR(i,0,len-1) {
		if(i!=k)dq.pb(i);
	}
	deque<int> nq = dq;
	reverse(all(nq));
	dq.pb(k);
	for(auto i : nq)dq.pb(i);
	dq.pb(k);
	for(auto i : dq)cout << i << ' ';
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    int N;
    int centh = 0;
    int[][] xyh = new int[100][];
    private static Scanner sc;
    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            N = sc.nextInt();
            for (int i = 0; i < N; i++) {
                xyh[i] = new int[3];
                xyh[i][0] = sc.nextInt();
                xyh[i][1] = sc.nextInt();
                xyh[i][2] = sc.nextInt();
            }

            for (int x = 0; x <= 100; x++) {
                for (int y = 0; y <= 100; y++) {
                    Boolean b = check(x, y);
                    if (b) {
                        System.out.println(String.format("%d %d %d", x, y, centh));
                    }
                }
            }


        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private Boolean check (int x, int y) {
        for (int i = 0; i < N; i++) {
            if (xyh[i][2] > 0) {
                centh = xyh[i][2] + Math.abs(x-xyh[i][0]) + Math.abs(y-xyh[i][1]);
                break;
            }
        }
        int tmph;
        for (int i = 0; i < N; i++) {
            tmph = Math.max(centh-Math.abs(x-xyh[i][0])-Math.abs(y-xyh[i][1]), 0);
            if (tmph != xyh[i][2]) return false;
        }
        return true;
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

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

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define all(v) v.begin() , v.end()
#define ceil(a, b) (a + b - 1) / b
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll inf = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << ' ';
    out << nl;
    return out;
}

bool isPrime (ll n)
{
    if (n < 4)
        return true;
    if (n % 2 == 0)
        return false;
    ll i = 3;
    while (i * i <= n)
    {
        if (n % i == 0)
            return false;
        i += 2;
    }
    return true;
}

vvl adj(1e5 + 1);
vb visited (1e5 + 1, 0);
vll dp(1e5 + 1, 0);

void visit(ll vertex)
{
    visited[vertex] = 1;
    for (ll child : adj[vertex])
    {
        if (!visited[child])
            visit (child);
        dp[vertex] = max (dp[vertex], dp[child] + 1);
    }
}

void solve ()
{
    ll n, m;
    cin >> n >> m;
    for (ll i = 0; i < m; ++i)
    {
        ll x, y;
        cin >> x >> y;
        adj[x].emplace_back(y);
    }
    for (ll i = 1; i <= n; ++i)
    {
        if (!visited[i])
            visit(i);
    }
    ll ans = 0;
    for (ll i = 1; i <= n; ++i)
        ans = max (ans, dp[i]);
    cout << ans << nl;
}

int main()
{
    IOS
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11984
#include <iostream>
#include <set>
#include <map> 
#include <queue>
#include <math.h>
#include <string.h>
#include <vector>
#include <algorithm>
using namespace std; 

typedef long long ll; 
const int up=1000005; 

int main(){
	int a,b; cin>>a>>b; 
	cout<<a*b-a-b+1; 
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <set>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
const ll INF = 1<<30;
const ll MOD = (ll)1e9 + 7;
const ll MAX_N = (ll)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(ll i = 0; i < (ll) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

bool init_check(const string& s, const string& t)
{
    set<char> st;
    for(ll i = 0; i < s.size(); i++)
    {
        st.insert(s[i]);
    }
    for(ll i = 0; i < t.size(); i++)
    {
        if(st.count(t[i]) == 0) return true;
    }
    return false;
}

inline ll calc(const ll&pos, const vector<ll>& v)
{
    return *upper_bound(v.begin(), v.end(), pos);
}

void solve()
{
    string s, t; cin >> s >> t;
    if(init_check(s, t))
    {
        cout << -1 << endl;
        return;
    }

    map<char, vector<ll>> mp;
    ll n = (ll)s.size();
    s = s + s;
    for(ll i = 0; i < s.size(); i++)
    {
        mp[s[i]].push_back(i);
    }

    ll ans = 0;
    ll pre = -1;
    for(ll i = 0; i < t.size(); i++)
    {
        ll index = calc(pre, mp[t[i]]);
        if(index >= n)
        {
            index -= n;
            ans += n;
        }
        ans += index - pre;
        pre = index;
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 2916
S = input()
snx = S.replace('x', '')
ls = len(S)
if ls == 1 or len(snx) == 0:
    print(0)
    exit(0)
l = 0
r = ls-1

ans = 0
while l < r:
    lxc = 0
    while S[l] == 'x':
        l += 1
        lxc += 1
    rxc = 0
    while S[r] == 'x':
        r -= 1
        rxc += 1
    ans += abs(lxc-rxc)

    if S[l] == S[r]:
        l += 1
        r -= 1
    else:
        print(-1)
        break
else:
    print(ans)

Measured memory_bytes: 73264
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = 1000000007;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;


	void doIt() {
		int N = sc.nextInt();
		int act[][] = new int[N + 1][3];
		int dp[][] = new int[N + 1][3];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 3; j++) {
				act[i][j] = sc.nextInt();
			}
		}
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < 3; j++) {
				for(int k = 0; k < 3; k++) {
					if(j == k)continue;
					dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + act[i][j]);
				}
			}
		}
		int max = MAX + 1;
		for(int i = 0; i < 3; i++) {
			max = Math.max(max, dp[N][i]);
		}
		System.out.println(max);
	}
	int diff(int a, int b) {
		return Math.abs(a - b);
	}




	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main() {
  int coinCount;
  int payment;

  int zan;
  
  cin >> payment;
  cin >> coinCount;
  
  zan = payment % 500;
  
  if (coinCount - zan >= 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}



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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll N;
vector<ll> A;
int main(int argc, char **argv)
{
	cin >> N;
	A.resize(N);
	REP(i, N) cin >> A[i];

	deque<ll> que;
	REP(i, N)
	{
		ll t = A[i];
		ll idx = lower_bound(ALL(que), t) - que.begin();
		if (idx == 0) que.push_front(t);
		else que[idx-1] = t;
	}

	std::cout << que.size() << std::endl;
}


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

const int MOD = 1000000007;

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


int main(){
  long long int n,k,i,j,kari,kotae=0;
  n=3;
  cin>>k;
  long long int a[k+1];
  for(i=0;i<=k;i++){
    a[i]=0;
  }
  for(i=k;i>=1;i--){
    j=k/i;
    if(j==1){
      a[i]=1;
    }else{
      kari=modpow(j,n);
      for(;j>=2;j--){
        kari=(kari+MOD-a[i*j])%MOD;
      }
      a[i]=kari;
    }
    kotae=(kotae+a[i]*i)%MOD;
  }
  cout<<kotae;
}
  


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

#define int long long

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define mp make_pair

using namespace std;

using ll = long long;
using ld = long double;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;

const int INF = 1e9;
const int MOD = 1e9+7;

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

int N, Q;
vvi G;
vi counter;
vi ans;

void dfs(int n, int sum)
{
    sum += counter[n];
    ans[n] = sum;
    for(auto c : G[n])
    {
        if(ans[c] == -1) dfs(c, sum);
    }
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, Q; cin >> N >> Q;
    G.resize(N+1);
    counter.resize(N+1, 0);
    ans.resize(N+1, -1);
    REP(i, N-1)
    {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    REP(i, Q)
    {
        int p, x; cin >> p >> x;
        counter[p] += x;
    }

    dfs(1, 0);
    REPS(i, N) cout << ans[i] << " ";
    cout << endl;
}

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

int main() {
	int k;cin>>k;
	int a,b;cin>>a>>b;
	int f=0;
	for(int i=a;i<=b;i++)
	{
	    if(i%k==0)
	    {
	        cout<<"OK"<<endl;
	        f=1;
	        break;
	    }
	    
	}
	if(f==0)    cout<<"NG"<<endl;
	return 0;
}

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

const int limit=50;
int a[limit], b[limit];
int n,m;

bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
    visited[v]=true;

    for(int v2=0; v2<n; v2++){
        if(graph[v][v2]==false) continue;
        if(visited[v2]==true) continue;
        dfs(v2); 
    }
}

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

    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }

    int ans=0;

    for(int i=0; i<m; i++){
        graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;

        for(int j=0; j<n; j++) visited[j]=false;
        dfs(0);

        bool bridge=false;
        for(int j=0; j<n; j++){
            if(visited[j]==false) bridge=true;
        }
        if(bridge) ans++;

        graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m;
ll ans;
struct P
{
    ll x,y;
}pnt1[256],pnt2[256];

int cmp1(P a,P b)
{
    return a.x<b.x;
}

int cmp2(P a,P b)
{
    return a.y<b.y;
}
int vis[256];

void judge(ll lx,ll rx)
{
    ll y[256];
    int u=0,d=0;
    for(int i=0;i<n;++i)
        if(pnt2[i].x>=lx&&pnt2[i].x<=rx){
            y[u++]=pnt2[i].y;
            if(u-d==m){
                ans=min(ans,(y[u-1]-y[d])*(rx-lx));
                ++d;
            }
        }
}

int main()
{
    while(~scanf("%d%d",&n,&m)){

        for(int i=0;i<n;++i){
            scanf("%lld%lld",&pnt1[i].x,&pnt1[i].y);
            pnt2[i]=pnt1[i];
        }
        sort(pnt1,pnt1+n,cmp1);
        sort(pnt2,pnt2+n,cmp2);
        ans=1;
        for (int i=0; i<62; i++)  ans *= 2;
        int l,r;
        for(int i=0;i<n;++i)
            for(int j=i;j<n;++j)
                judge(pnt1[i].x,pnt1[j].x);
        printf("%lld\n",ans);
    }
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        long[][] k = {{1,1,1},{1,1,-1},{1,-1,1},{-1,1,1},{-1,-1,1},{-1,1,-1},{1,-1,-1},{-1,-1,-1}};
        long[] x = new long[n];
        long[] y = new long[n];
        long[] z = new long[n];
        long[][] sum = new long[8][n];
        for(int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
            y[i] = sc.nextLong();
            z[i] = sc.nextLong();
            for(int v = 0; v < 8; v++) {
                sum[v][i] = x[i]*k[v][0]+y[i]*k[v][1]+z[i]*k[v][2];
            }
        }
        long ans = 0;
        for(int v = 0; v < 8; v++){
            Arrays.sort(sum[v]);
            long ans1 = 0, ans2 = 0;
            for (int i = 0, c = n - 1; i < m; i++, c--) {
                ans1 += sum[v][i];
                ans2 += sum[v][c];
            }
            ans = Math.max(ans, Math.max(Math.abs(ans1), Math.abs(ans2)));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26608
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  ll n; cin >> n;
  vll A(5);
  rep(i,5) cin >> A[i];
  rep(i,4) {
    if (A[i] < A[i+1]) A[i+1] = A[i];
  } 
  ll ans = 4 + (n-1)/A[4] + 1;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 3720
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  int N; cin >> N;
  vector<int> H(N);
  rep(i,N) cin >> H[i];
  int temp = 0; int ans = 0;
  rep(i,N-1){
    if (H[i] >= H[i+1]) temp += 1;
    else temp = 0;
    if (ans < temp) ans = temp;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstring>
#define rg register
#define LL long long
using namespace std;
const int MAXN=5000;
int N,H,W;

template <typename T> inline void in(T &a) {
	T ch = getchar(), f = 1;
	for(a = 0; !isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
	for( ; isdigit(ch); ch = getchar()) a = (a << 3) + (a << 1) + ch - '0';
	a *= f;
}

template <typename T> inline void print(T x) {
	if(x < 0) putchar('-'), x = -x;
	if(x > 9) print(x / 10);
	putchar(x % 10 + '0');
}

int main(){
	in(N),in(H),in(W);
	
	print((N-H+1)*(N-W+1)),puts("");
	
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    MOD = 10 ** 9 + 7
    note = [{} for _ in range(n+1)]

    def ok(last4):
        for i in range(4):
            t = list(last4)
            if i >= 1:
                t[i-1], t[i] = t[i], t[i-1]
            if ''.join(t).count('AGC') >= 1:
                return False
        return True

    def dfs(cur, last3):
        if last3 in note[cur]:
            return note[cur][last3]
        if cur == n:
            return 1
        ret = 0
        for c in 'ACGT':
            if ok(last3 + c):
                ret += dfs(cur + 1, last3[1:] + c)
                ret %= MOD
        note[cur][last3] = ret
        return ret

    print(dfs(0, 'TTT'))


main()


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

int main() {
  long H, W;
  cin >> H >> W;

  if (H % 3 == 0 || W % 3 == 0) {
    cout << 0 << endl;
    return 0;
  }

  long mind = H;
  mind = min(mind, W);

  long h1 = H / 2;
  long h2 = H - h1;
  for (long i = 1; i <= W; i++) {
    long mx = max(i * H, max((W - i) * h1, (W - i) * h2));
    long mn = min(i * H, min((W - i) * h1, (W - i) * h2));
    if (mx - mn < mind) {
      mind = mx - mn;
    }
  }

  long w1 = W / 2;
  long w2 = W - w1;
  for (long i = 1; i <= H; i++) {
    long mx = max(i * W, max((H - i) * w1, (H - i) * w2));
    long mn = min(i * W, min((H - i) * w1, (H - i) * w2));
    if (mx - mn < mind) {
      mind = mx - mn;
    }
  }

  cout << mind << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int N;
	scanf("%d",&N);
	char sakoda[N+100];
		scanf("%s",sakoda);
	
	int answer = 0;
	int count = 0;
	for(int i=N-1; i >= 1; i-- ){
		if(sakoda[i] == 'R'){
			int flag = 0;
			for(int j=count; j<i ; j++ ){
				if(sakoda[j] == 'W' ){
					sakoda[j] = 'R';
					sakoda[i] = 'W';
					count = j;
					answer++;
					flag = 1;
					break;
				}
			}
			if(flag == 0){
				printf("%d",answer);
				return 0;
			}
		}
	}
	printf("%d",answer);
}




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

ans = 1
w_set = set()
previous_word = ''
for i in range(N):
    w = str(input())
    if i != 0:
        if previous_word[-1] == w[0]:
            pass
        else:
            ans = 0
            break
    if w in w_set:
        ans = 0
        break
    previous_word = w
    w_set.add(w)

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define Maxn 300010

int h, w, m, p[Maxn], q[Maxn], p_, q_, Row_m, Col_m, Row[Maxn], Col[Maxn];
map<long long, int> Rem;
vector<int> Erow, Ecol;

int main()
{
	scanf("%d%d%d", &h, &w, &m);
	for (int i=1; i<=m; i++)
	{ 	
		scanf("%d%d", &p[i], &q[i]);
		Rem[(long long)p[i]*w+q[i]]=1;
		Row[p[i]]++, Col[q[i]]++;
		if (Row[p[i]] > Row_m) Row_m = Row[p[i]], p_ = p[i];
		if (Col[q[i]] > Col_m) Col_m = Col[q[i]], q_ = q[i];
	}
	int Res = Row_m + Col_m;
	if (!Rem[(long long)p_*w+q_]) { printf("%d\n", Res); return 0; }
	for (int i=1; i<=h; i++)
		if (Row[i] == Row_m) Erow.push_back(i);
	for (int i=1; i<=w; i++)
		if (Col[i] == Col_m) Ecol.push_back(i);
	for (auto i:Erow)
		for (auto j:Ecol)
			if (!Rem[(long long)i*w+j]) { printf("%d\n", Res); return 0; }
	printf("%d\n", Res-1);
}

Measured memory_bytes: 30760
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    static int f(int n)
    {
        int count = 0;
        for (int x = 1; x <= 100; ++x)
        {
            for (int y = 1; y <= 100; ++y)
            {
                double d = (x + y) * (x + y) - 4 * (x * x + y * y + x * y - n);
                if (d >= 0)
                {
                    int z = (int)(-(x + y) + Math.Sqrt(d)) / 2;
                    if (z > 0 && x * x + y * y + z * z + x * y + y * z + z * x == n) { ++count; }
                }
            }
        }
        return count;
    }

    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        for (int i = 1; i <= N; ++i)
        {
            Console.WriteLine(f(i));
        }
    }
}


Measured memory_bytes: 17576
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

int N, M;
string S, T;

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

int main(){
	cin >> N >> M;
	cin >> S >> T;
	if(S[0] != T[0]){
		cout << -1 << endl;
		return 0;
	}
	ll lcm = (ll)N / (ll)gcd(N, M) * (ll)M;
	int div1 = N / gcd(N, M), div2 = M / gcd(N, M);
	bool flag1 = true, flag2 = true;
	for(int i = 0; i < N - 1; i++){
		if(S[i] != S[i + 1]) flag1 = false;
	}
	for(int i = 0; i < M - 1; i++){
		if(T[i] != T[i + 1]) flag2 = false;
	}
	if(flag1 && flag2){
		cout << lcm << endl;
		return 0;
	}else if(flag1 || flag2){
		cout << (ll)N * (ll)M << endl;
		return 0;
	}
	for(int i = 0; i < gcd(N, M); i++){
		if(S[i * div1] != T[i * div2]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << lcm << endl;
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;using ll=long long;typedef vector<ll> vl;typedef pair<ll, ll> pll;
typedef set<ll> sl;typedef map<ll,ll> mll;typedef vector<pll> vll;
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define endl '\n'
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
//----------------------------------------------//

int main()
{
    int ts=1;//cin>>ts;
    for(int tss=1;tss<=ts;tss++)
    {
        ll x;
        cin>>x;
        if(x==0) cout<<1<<endl;
        else if(x==1) cout<<0<<endl;

        return 0;
    }
}
//
//
//
//
//
//
///Struggle goes here....


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string s;
   cin >> s;
   int cost = 700;
   for(int i = 0 ; i < 3; i++){
      if(s[i] == 'o'){
         cost += 100;
      }
   }
   cout << cost << endl;

   return 0;
}

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

int main()
{
  uint64_t n, p;
  cin >> n >> p;
  map<uint64_t, uint64_t> m;
  for (uint64_t i = 2; i * i <= p; i++) {
    while (p % i == 0) {
      m[i]++;
      p /= i;
    }
  }
  if (p > 1) {
    m[p] = 1;
  }
  uint64_t ans = 1;
  for (auto&& e : m) {
    if (e.second >= n) {
      for (uint64_t i = 0; i < e.second / n; i++) {
	ans *= e.first;
      }
    }
  }
  cout << ans << endl;
}


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

M = sum(A)

for i in range(N):
    K = min(A[i], B[i])
    A[i] -= K
    A[i+1] -= B[i] - K
    A[i+1] = max(0, A[i+1])
    
print(M - sum(A))

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

void count( int* a, int b, int e, int k )
{
    int cnt = 0;
    for( int i = b; i <= e - 1; i++ )
        if( a[i] == k )
            cnt++;

    cout << cnt << endl;
}

int main()
{
    int n, q;
    int b,e,k;

    cin >> n;

    int a[n];

    for( int i = 0; i < n; i++ )
        cin >> a[i];

    cin >> q;

    for( int i = 0; i < q; i++ )
    {
        cin >> b >> e >> k;
        count( a, b, e , k );
    }
    return 0;
}


Measured memory_bytes: 3064
package main

import "fmt"

func main() {
	var H1, M1, H2, M2, K int
	fmt.Scan(&H1, &M1, &H2, &M2, &K)
	h := H2 - H1
	m := M2 - M1
	diff := 60*h + m
	if diff <= K {
		fmt.Println(0)
	} else {
		ans := diff - K
		fmt.Println(ans)
	}
}


Measured memory_bytes: 1752
# -*- coding: utf-8 -*-

cnt = int(input())
num_list = list(map(int, input().split()))

ans = 0
while True:
    for i in range(cnt):
        # 各数値に対して偶数か判定、奇数があればそこで終了
        if num_list[i] % 2 != 0:
            print(ans)
            exit()
        # 偶数なら操作を行う
        num_list[i] /= 2
    # 全ての数値で操作が完了したら+1
    ans += 1

Measured memory_bytes: 2940
main = putStr . unlines . map show . sovle . map (read::String->Double) . words =<< getLine
  where
    sovle [a,b,theta] = [s, l, h]
      where
        t=theta/180.0*pi
        h=b*sin t
        s=0.5*a*h
        c=sqrt (a*a+b*b-2.0*a*b*cos t)
        l=a+b+c


Measured memory_bytes: 4144
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    map<int, ll> mp;
    rep(i, N) { mp[A[i]]++; }
    ll res = 0;
    for(auto x : mp) {
        res += (x.second * (x.second - 1)) / 2;
    }
    rep(i, N) {
        int a = A[i];
        ll tmp = res;
        if(mp[a] == 1) {
            cout << res << endl;
            continue;
        }
        tmp -= (mp[a] * (mp[a] - 1)) / 2;
        tmp += ((mp[a] - 1) * (mp[a] - 2)) / 2;
        cout << tmp << endl;
    }
    return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double PI=3.14159265358979323846;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    double a, b, x;
    cin >> a >> b >> x;
    double ans;
    if(pow(a, 2)*b  < 2*x){
        ans = 2*(b - x / pow(a, 2))/a;
        ans = atan(ans);
    }
    else{
        ans = a*pow(b, 2)/(2*x);
        ans = atan(ans);
    }

    ans = ans * 180 / PI;
    
    printf("%.9lf", ans);
    return 0;
}

Measured memory_bytes: 256
program main
    implicit none
    integer(4):: i
    character(3), parameter:: week(7) = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
    character(3):: input_week
    read*, input_week

    do i = 1, 7
        if (week(i) == input_week) then
            print*, 8-i
        end if
    end do


end program main

Measured memory_bytes: 256
# Your code here!
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

def partition(a)
  length = a.size
  r = length-1
  i = -1
  (0...length).each do |j|
    if a[j] <= a[r]
      i+=1
      # puts "#{a[j]}と#{a[i]}交換"
      if j==r
        a[j] = "[#{a[j]}]"
      end
      a[j], a[i] = a[i], a[j]
    else
      # puts "#{a[r]}<#{a[j]} とくになにもしない"
      next
    end
  end
  return a
end

puts partition(a).map(&:to_s).join(' ')


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

int main(){
  long long x; cin >> x;
  if(x%11==0){
    cout << x/11*2 << endl;
  }else if(x%11<=6){
    cout << x/11*2+1 << endl;
  }else{
    cout << x/11*2+2 << endl;
  }
}

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

class dice{
	public:
	int d[6];
	void roll(char in){//4 2 1 6 5 3
		int direc[4][6]={
			{1,5,2,3,0,4},//n
			{3,1,0,5,4,2},//e
			{4,0,2,3,5,1},//s
			{2,1,5,0,4,3}//w
		};
		int news;
		int temp_d[6];
		if(in =='N')news = 0;
		if(in =='E')news = 1;
		if(in =='S')news = 2;
		if(in =='W')news = 3;
		for(int i = 0;i < 6;i++)
			temp_d[i] = d[direc[news][i]];
		for(int i = 0;i < 6;i++)
			d[i] = temp_d[i];
	}
	void print(void){
		for(int i = 0;i < 6; i++){
			cout << d[i];
			if(i==6-1)cout << endl;
			else cout << " ";
		}
	}
};

int main(){
	dice d1;
	char str[101];
	for(int i = 0;i < 6; i++)
		cin >> d1.d[i];
	cin >> str;
	for(int i = 0; str[i] != '\0'; i++)
		d1.roll(str[i]);
	cout << d1.d[0] << endl;
    return 0;
}

Measured memory_bytes: 1164
N,M,Q=map(int,input().split())
G=[input() for i in range(N)]
node=[[0]*(M+1)]
edge_x=[[0]*M]
edge_y=[[0]*(M+1)]
for i in range(1,N+1):
  n,e_x,e_y=[0],[0],[0]
  for j in range(1,M+1):
    if G[i-1][j-1]=="1":
      n.append(n[-1]+node[i-1][j]-node[i-1][j-1]+1)
    else:
      n.append(n[-1]+node[i-1][j]-node[i-1][j-1])
    if j<M:
      if G[i-1][j-1]=="1" and G[i-1][j]=="1":
        e_x.append(e_x[-1]+edge_x[i-1][j]-edge_x[i-1][j-1]+1)
      else:
        e_x.append(e_x[-1]+edge_x[i-1][j]-edge_x[i-1][j-1])
    if i<N:
      if G[i-1][j-1]=="1" and G[i][j-1]=="1":
        e_y.append(e_y[-1]+edge_y[i-1][j]-edge_y[i-1][j-1]+1)
      else:
        e_y.append(e_y[-1]+edge_y[i-1][j]-edge_y[i-1][j-1])
  
  node.append(n)
  edge_x.append(e_x)
  if i<N:
    edge_y.append(e_y)

for q in range(Q):
  x1,y1,x2,y2=map(int,input().split())
  n=node[x2][y2]-node[x1-1][y2]-node[x2][y1-1]+node[x1-1][y1-1]
  e_y=edge_y[x2-1][y2]-edge_y[x1-1][y2]-edge_y[x2-1][y1-1]+edge_y[x1-1][y1-1]
  e_x=edge_x[x2][y2-1]-edge_x[x1-1][y2-1]-edge_x[x2][y1-1]+edge_x[x1-1][y1-1]
  e=e_x+e_y
  print(n-e)

Measured memory_bytes: 164228