akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define INF 1000000009
const ll INFll=1ll*INF*INF;
#define MOD 998244353
#define MODE 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define rep(i,n) for (ll i = 0; i < n; i++)
#define rev(i,n) for (ll i = n-1; i >= 0; i--)
#define REP(i,a,b) for (ll i = a; i < b; i++)
#define REV(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vl vector<ll>
#define pll pair<ll,ll>
#define sz(a) (ll)a.size()
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->f<<' '<<it->s << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
ll gcd(ll a,ll b)  {return (b==0)? a:gcd(b,a%b);}

ll bpow(ll a, ll b, ll m) {
  a %= m;
  ll res = 1;
  while (b > 0) {
    if (b & 1)res = res * a % m;
    a = a * a % m;
    b >>= 1;
}
return res;
}


void solve() {
	ll n, w;
	cin >> n >> w;
	vl V(n);
	vl W(n);
	rep(i, n){
		cin >> W[i] >> V[i];
	}
	vector<vl>dp(n);
	rep(i, n){
		dp[i].resize(w+1);
		rep(j, w+1){
			if(i == 0){
				if(j < W[i])dp[i][j] = 0;
				else dp[i][j] = V[i];
			}
			else{
				dp[i][j] = dp[i-1][j];
				if(j > W[i])dp[i][j] = max(V[i] + dp[i-1][j-W[i]], dp[i][j]);
			}
		}
	}
	cout << dp[n-1][w] << endl;
}

// DONT GET TLE FOR NOT USING FASTIO (--__--)

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


Measured memory_bytes: 81592
#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 maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int a,b,k;
    cin >> a >> b >> k;

    rep(i,k){
        if(i%2==0){
            a -= a%2;
            a /= 2;
            b += a;
        }else{
            b -= b%2;
            b /= 2;
            a += b;
        }
    }
    cout << a << ' ' << b << endl;
    return 0;
}
 
 


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

using namespace std;

long long power(long long a, long long n){
    long long mod = 1000000007;
    long long res = 1;
    if(n == 0){
        return 1;
    }else if (n % 2 == 0){
        return (power(a * a % mod, n / 2)) % mod;
    }else{
        return (a * power(a * a % mod, n / 2)) % mod;
    }
    
}

long long nCr(long long n, long long r){
    long long ans = 1, mod = 1000000007;

    for (int i = 0; i < r; i++){
        ans = ans *  (n - i) % mod;
        ans = ans * power(i+1, mod-2) % mod;
    }
    return ans;
}

long long ans(long long  N, long long K, long long count){

    if (2 * count - 1 > N || K < count){
        return 0;
    }else{
        long long resB = K - count ;
        long long resA = (N - K) - (count - 1);

        return ((nCr(resB+count-1, count-1)% 1000000007) * (nCr(resA+count, count)) % 1000000007) % 1000000007;

    }
}


int main(){

    long long N, K; cin >> N >> K;



    for (long long i = 1; i <= K; i++){
        cout << ans(N, K, i) << endl;
    }


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0; i<n; i++)
        cin>>h[i];
    sort(h,h+n);
    ll ans=0;
    for(int i=0; i<n-k; i++)
    {
        ans+=h[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int a,b;
    cin >> a >> b;
    int count = b - a + 1;
    int out = 0;
    if(a % 2 != 0){
        count--;
        out = out ^ a;
    }
    if (b % 2 == 0){
        count--;
        out = out ^ b;
    }
    if((count / 2)% 2 == 1){
        out = out ^ 1;
    }
    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
# B 087 

A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt=0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500 * i + 100 * j + 50 *k == X:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
def calc_distance(x, y) #x, y???????´???°2??????1?¬??????????
  require 'bigdecimal'
  distance = ((y[0] - x[0])**2 + (y[1] - x[1])**2) ** 0.5
  distance_approximately = BigDecimal(distance.to_s).floor(8).to_f
  return distance_approximately #P1??¨P2????????¢
end

input_values = gets.chomp.split.map(&:to_f)
x = [input_values[0], input_values[1]]
y = [input_values[2], input_values[3]]
puts calc_distance(x, y)

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

struct uf {
private:
	vector<int> par, ran;
public:
	void init(int n) {
		par.resize(n, 0);
		ran.resize(n, 0);
		rep(i, n) {
			par[i] = i;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x), y = find(y);
		if (x == y)return;
		if (ran[x] < ran[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (ran[x] == ran[y])ran[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int n, h, w;
const int mn = 100000;
vector<P> cx[mn], cy[mn];
uf u;
int x[40000], y[40000];
bool used[40000];
int main() {
	cin >> n >> h >> w; u.init(n);
	bool exi = false;
	rep(i, n) {
		cin >> x[i] >> y[i]; x[i]--; y[i]--;
		if (x[i] == 0 || y[i] == 0 || x[i] == h - 1 || y[i] == w - 1)exi = true;
		cx[x[i]].push_back({ y[i],i });
		cy[y[i]].push_back({ x[i],i });
	}
	rep(i, h)sort(cx[i].begin(), cx[i].end());
	rep(i, w)sort(cy[i].begin(), cy[i].end());
	rep(i, n) {
		int id = upper_bound(cx[x[i]].begin(), cx[x[i]].end(), P{ y[i],i }) - cx[x[i]].begin();
		if (id < cx[x[i]].size()) {
			int to = cx[x[i]][id].second;
			u.unite(i, to);
		}
		id -= 2;
		if (id >=0) {
			int to = cx[x[i]][id].second;
			u.unite(i, to);
		}
		id = upper_bound(cy[y[i]].begin(), cy[y[i]].end(), P{ x[i],i }) - cy[y[i]].begin();
		if (id < cy[y[i]].size()) {
			int to = cy[y[i]][id].second;
			u.unite(i, to);
		}
		id -= 2;
		if (id >= 0) {
			int to = cy[y[i]][id].second;
			u.unite(i, to);
		}
	}
	int cnt = 0;
	rep(i, n) {
		int p = u.find(i);
		if (used[p])continue;
		used[p] = true; cnt++;
	}
	int ans = n - cnt;
	if (cnt > 1) {
		ans += 2 * cnt - 1;
		if (exi)ans--;
	}
	cout << ans << endl;
	//stop
	return 0;
}



Measured memory_bytes: 10204
#include<bits/stdc++.h>
 
using namespace std;
 
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007
 
int main()
{
    boost
    int n;
    ll k;
    cin >> n >> k;
    
    vector<ll> a(n), f(n);
    loop(z, a) cin >> z;
    loop(z, f) cin >> z;
    
    sort(a.B, a.E);
    sort(f.B, f.E);
    
    vector<ll> af(n);
    for(int i = 0; i < n; i++) af[i] = a[i]*f[n - i - 1];
    
    ll max_ = *max_element(af.B, af.E);
    
    ll l = 0;
    ll r = max_;
    
    while(l < r)
    {
    	ll mid = (l + r) / 2;
    	
    	ll req = 0;
    	for(int i = 0; i < n; i++)
    	{
    		if(af[i] <= mid) continue;
    		req += ceil((af[i] - mid + 0.0) / f[n - i - 1]);
    	}
    	if(req > k)
    		l = mid + 1;
    	else
    		r = mid;
    }
    
    cout << r << nl;
    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
using namespace std;
long long p[700000], j[700000];
int main(void) {
	while (1) {
		for (long long i = 0; i < 700000; i++) {
			p[i] = j[i] = 0;
		}
		long long n, l, max, s;
		max = 0;
		l = 0;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (long long i = 0; i < n; i++) {
			cin >> p[i];
			l = l + p[i];
		}
		for (long long i = 0; i < n - 1; i++) {
			cin >> j[i];
		}
		sort(p, p + n);
		sort(j, j + n - 1);
		for (long long i = 0; i < n - 1; i++) {
			s = l*(n - i);
			if (max < s) {
				max = s;
			}
			l = l + j[n - 2 - i];
		}
		if (max < l) {
			max = l;
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 14068
//https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_e
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};

constexpr int mod = 998244353;
int R,C;
int A[312][312];
LL pow_mod(LL a,LL n,int M=mod){
    LL res=1;
    a%=M;
    while(n){
        if(n&1)
            res=(res*a)%M;
        a=(a*a)%M;
        n>>=1;
    }
    return res;
}
int get_rank(){
    int ret = 0;
    for(int c:range(C)){
        int id=-1;
        for(int i:range(ret,R)){
            if(A[i][c]==1){
                id=i;
            }
        }
        if(id==-1)continue;
        for(int j:range(C)){
            swap(A[ret][j],A[id][j]);
        }
        ret++;
        for(int i:range(ret,R)){
            if(A[i][c]==1)for(int j:range(C)){
                A[i][j] = A[i][j] xor A[ret-1][j];
            }
        }
    }
    return ret;
}
int main(){
    cin>>R>>C;
    for(int i:range(R))for(int j:range(C)){
        cin>>A[i][j];
    }
    LL ret=pow_mod(2,R+C-1)-pow_mod(2,R+C-1-get_rank())+mod;
    cout<<ret%mod<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
    long long h, w, ans = 1e10;
    cin >> h >> w;
    if(h%3 == 0 || w%3 == 0){
        ans = 0;
    }
    ans = min(ans, h);
    ans = min(ans, w);
    for(int i=1;i<h;i++){
        long long s, t, u;
        s = i * (w / 2);
        t = i * (w - w / 2);
        u = (h - i) * w;
        ans = min(ans, max(u, t) - min(u, s));
    }
    for(int i=1;i<w;i++){
        long long s, t, u;
        s = i * (h / 2);
        t = i * (h - h / 2);
        u = (w - i) * h;
        ans = min(ans, max(u, t) - min(u, s));
    }
    cout << ans << endl;
    
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<int> V(1e5);
  for (int i = 0; i < N; i++) {
    V.at(A.at(i))++;
  }
  int ans = 0;
  for (int i = 0; i + 2 < 1e5; i++) {
    ans = max(ans, V.at(i) + V.at(i + 1) + V.at(i + 2));
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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;
}

bool dp[81][81][13000];
//vector<vector<vector<bool>>> dp(81, vector<vector<bool>>(81, vector<bool>(13010,false)));
vector<vector<int>> A,B,C;

int main() {
  int H,W; cin >> H >> W;
  A.resize(H, vector<int>(W)); B.resize(H, vector<int>(W)); C.resize(H, vector<int>(W));
  rep(i,H) {
    rep(j,W) cin >> A[i][j];
  }

  rep(i,H) {
    rep(j,W) cin >> B[i][j];
  }

  rep(i,H) {
    rep(j,W) C[i][j] = abs(A[i][j] - B[i][j]);
  }

  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      for (int k = 0; k < 13000; k++) {
        if (i == 1 && j == 1) {
          dp[1][1][C[0][0]] = true;
          break;
        }
        if (dp[i][j-1][k]) {
          dp[i][j][k+C[i-1][j-1]] = true;
          dp[i][j][abs(k - C[i-1][j-1])] = true;
        } 
        if (dp[i-1][j][k]) {
          dp[i][j][k+C[i-1][j-1]] = true;
          dp[i][j][abs(k - C[i-1][j-1])] = true;
        }
      }
    }
  }
  int ans;
  for (int i = 0; i < 13000; i++) {
    if (dp[H][W][i]) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
}

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

using namespace std;

int main() {
    int y, m, d;
    char i, j;
    cin >> y >> i >> m >> j >> d;
    
    if (m <= 4){
        cout << "Heisei" << endl;
    }

    else{
        cout << "TBD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
ll gcd(ll x, ll y){
  if(y==0)return x;
  else return gcd(y,x%y);
}
int main() {
  ll n,k;
  cin >> n >> k;
  ll sum=0;
  if(k==0){
    sum=n*n;
    cout << sum << endl;
    return 0;
  }
  
  for(ll b=k+1;b<=n;b++){
    ll a=k;
    while(a<=n){
      if(a+b-k-1<=n){
        sum+=b-k;
        a+=b;
      }
      else{
        sum+=n-a+1;
        break;
      }
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#pragma region

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

#pragma endregion


int main() {
    int n;
    cin >> n;
    
    ll sum_e = 0;
    rep(i, n - 1) {
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        sum_e += u * (n - v + 1);
    }
    
    ll sum_v = 0;
    repr(len, 1, n + 1) {
        sum_v += ll(n - len + 1) * len;
    }
    
    cout << sum_v - sum_e << endl;
}

Measured memory_bytes: 3600
#include <math.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;

using ll = long long;
typedef pair<ll, ll> P_ll;
typedef pair<int, int> P;

const ll INF_ll = 1e17;
const int INF = 1e8;

int main() {
  ll D, T, S;
  cin >> D >> T >> S;
  ll L = T * S;
  if (L < D) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

  
    public static void main(String[] args) {
        String x;
        Scanner n =new Scanner(System.in);
        x=n.next();
        if(x.equals("Sunny"))
            System.out.print("Cloudy");
        else if(x.equals("Cloudy"))
            System.out.print("Rainy");
        else if(x.equals("Rainy"))
            System.out.print("Sunny");
    }
    
}

Measured memory_bytes: 21328
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define rv(s) reverse(s.begin(),s.end());
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  ll mod=1e9+7;
  
  ll n,k;cin>>n>>k;
  vi a(n);
  rep(i,n)cin>>a[i];
  
  ll x=0;
  rep(i,n){
    irep(j,i+1,n){
      if(a[i]>a[j])x++;
    }
  }
  
  ll y=0;
  rep(i,n){
    rep(j,n){
      if(a[i]>a[j])y++;
    }
  }
  
  ll c=(k*(k-1)/2LL);c%=mod;
  ll ans=(x*k+c*y)%mod;
  cout(ans);
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int t = sc.nextInt();
        for (int i = 1; i <= t; i++) {
            long a = sc.nextLong(); long b = sc.nextLong(); long c = sc.nextLong(); long d = sc.nextLong();
            if (a < b || d < b) {
                out.println("No");
                continue;
            }
            long gcd = gcd(b, d);
            long init = a % gcd;
            long max = b - gcd + init;
            if (c >= max) out.println("Yes"); else out.println("No");
        }
        out.close();
    }

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


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            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;
        }


    }

}

Measured memory_bytes: 33392
# coding=utf-8
input = input().split()
stack = []

for i in input:
    if i == '+':
        stack.append(stack.pop() + stack.pop())
    elif i == '-':
        stack.append(- stack.pop() + stack.pop())
    elif i == '*':
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(i))

print(stack[0])

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

int main() {
    int A,B,C,K;
    cin >> A >> B >> C >> K;

    int cnt=0;

    while (A >= B) {
        B*=2;
        cnt++;
        if (cnt > K) {
            cout << "No" << endl;
            return 0;
        }
    }

    while (B >= C) {
        C*=2;
        cnt++;
        if (cnt > K) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3628
/*
* Author: Anmol Choudhary
*/
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int ll
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
													 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1e9+7;
const ll maxn = 1000005;
const ll mm = 1e+18;
void solve()
{
    int n,x;
    cin>>n>>x;
    cout<<min(n%x,x-n%x);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  val n = in.readInt
  val h = in.readLine.split(" ").map(_.toInt)
  val fs = 0 +: h

  def calc(pre:Int, idx:Int):Int = {
    if(!(idx < n) || (pre > 0 && fs(idx+1) == 0)) fs.sum
    else {
      val nx = fs(idx+1)
      if(fs(idx+1) > 0) fs(idx+1) -= 1
      calc(nx, idx+1)
    }
  }
  def rec(acc:Int, cnt:Int):Int = {
    if(acc == 0) cnt
    else {
      rec(calc(0,0),cnt+1)
    }
  }

  val ans = rec(fs.sum,0)
  println(ans)
  // (1 to 5).foreach(i => {calc(0,0);println(fs.mkString(" "))})
}

Measured memory_bytes: 30236
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
using namespace std;
const int _N = (int)1e5 + 5;
const long long MOD = (long long)1e9 + 7;

string s;
int k;

int main() {
	cin >> s >> k;
	int n = s.size();
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') continue;
		int need = (int)(s[i] - 'a');
		int x = 26 - need;
		if (k >= x) {
			s[i] = 'a';
			k -= x;
		}
	}
	k = k % 26;
	int plus = (int)(s[n-1] - 'a');
	plus = (plus + k) % 26;
	s[n-1] = (char)(plus + 'a');
	cout << s << endl;
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
inline bool isprime(ll num)
{if(num==2||num==3)return true;
if(num%6!=1&&num%6!=5)return false;
for(int i=5;1ll*i*i<=num;i+=6){if(num%i==0||num%(i+2)==0)return false;}
return true;}
const int mod = 1e9+7;
inline ll mul(ll a,ll b,ll c){return (a*b-(ll)((ld)a*b/c)*c+c)%c;}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll g = exgcd(b,a%b,y,x);y-=a/b*x;return g;}
inline ll quick_pow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll quick_pow(ll a,ll b){ll res=1;while(b){if(b&1)res=mul(res,a,mod);a=mul(a,a,mod);b>>=1;}return res;}
inline ll inv(ll x){return quick_pow(x,mod-2);}
inline ll inv(ll x,ll mod){return quick_pow(x,mod-2,mod);}
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
	ll n;
	scanf("%lld",&n);
	if(n==2)return 0*printf("1\n");
	ll m=n-1;
	int ans = 2;
	for(int i=2;1ll*i*i<=n;i++){
	if(n%i==0){
		ll temp=n;
		while(temp%i==0)temp/=i;
		ans+=(temp%i==1);
	}
	}
	for(int i=2;1ll*i*i<=m;i++){
	if(m%i==0){
		if(1ll*i*i!=m)ans+=2;
		else ans+=1;
	}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;
ll N;
vector<ll> children[100500];
vector<ll> paths[100500];
vector<ll> a, b;
ll p[100500];
ll ans = 0;
ll SIZE[100500];
void dfs1(int now) {
    SIZE[now] = 1;
    for(auto to : paths[now]) {
        if(to == p[now]) continue;
        children[now].push_back(to);
        p[to] = now;
        dfs1(to);
        SIZE[now] += SIZE[to];
    }
}

void dfs2(int now) {
    ll timer = 0;
    for(auto to : children[now]) {
        dfs2(to);
        chmax(timer, -a[to]);
    }
    ans += timer;
    if(p[now] != -1) {
        a[p[now]] += timer;
        a[now] -= timer;
    }
    for(auto to : children[now]) {
        a[to] += timer;
        a[now] -= timer;
    }
    for(auto to : children[now]) {
        //cerr << now << " " << to << " " << a[to] << endl;
        ans += SIZE[to] * a[to];
        a[now] += a[to];
        a[to] = 0;
    }
    //cerr << now << " " << timer << " " << a[now] << endl;
}

int main() {
    cin >> N;
    for(int i = 0; i < N - 1; i++) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        paths[u].push_back(v);
        paths[v].push_back(u);
    }
    a.resize(N);
    b.resize(N);
    for(int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> b[i];
        a[i] = a[i] - b[i];
    }
    p[0] = -1;
    dfs1(0);
    dfs2(0);
    cout << ans << endl;
    return 0;
}


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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int solve(vector<int> & A, int a, int b, int idx) {
  if (idx == A.size())
    return abs(a - b);
  return min(solve(A, a + A[idx], b, idx + 1), solve(A, a, b + A[idx], idx + 1));
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N;
  while (cin >> N, N) {
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    cout << solve(A, 0, 0, 0) << endl;
  }
  return 0;
}

Measured memory_bytes: 3112
# K <= 5なので、5まで

s = input()
K = int(input())

substr = set()
for i in range(len(s)):
    for j in range(1,6):
        if i + j <= len(s):
            substr.add(s[i:i+j])
substrlist = list(substr)
substrlist.sort()
print(substrlist[K-1])

Measured memory_bytes: 4464
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		while(true){
			int x=sc.nextInt();
			int y=sc.nextInt();
			if(x==0 && y==0){
				break;
			}
			if(x>y){
				int temp=x;
				x=y;
				y=temp;
			}
			System.out.println(x+" "+y);
		}
	}

}



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

int main(){
    int H,W;
    cin>> H >> W;
    char s[H][W];
    for (int i=0;i<H; ++i){
        for (int j=0; j<W; ++j){
             cin>>s[i][j];
        }
    }
    bool X = true;
    for (int i=0;i<H; ++i){
        for (int j=0; j<W; ++j){
             if (s[i][j]=='#'){
                if (s[i-1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.' && s[i+1][j]=='.') X=false;
            }
        }
    }
    if (X) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;
using LLI = long long int;

int main(void) {
	LLI N, dis, dis_t;
	bool res = true;
	cin >> N;
	vector<LLI>time(N + 1);
	vector<LLI>pos_x(N + 1);
	vector<LLI>pos_y(N + 1);
	for (int i = 0; i < N; i++) {
		cin >> time[i + 1] >> pos_x[i + 1] >> pos_y[i + 1];
	}
	for (int i = 0; i < N; i++) {
		dis = abs(pos_x[i] - pos_x[i + 1]) + abs(pos_y[i] - pos_y[i + 1]);
		dis_t = time[i + 1] - time[i];
		if (dis > dis_t) {
			res = false;
		}
		if (dis % 2 != dis_t % 2) {
			res = false;
		}
	}
	if (res) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 2560
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

w,a,b = iim()

if abs(a-b) <= w:
    print(0)
else:
    print(abs(a-b)-w)

Measured memory_bytes: 3064
#include<iostream>
#include<iostream>
#include<string>
#include<sstream>
#include<vector>
#include<algorithm>
#include<math.h>
#include"boost/algorithm/string.hpp"

using namespace std;


int main(){


	/*Q2*/

	/*Q3*/

	/*Q2*/

	int h[20];
	int n;
	int count = 0;
	int max = 0;

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

		if (max <= h[i]){
			count++;
			max = h[i];
		}

	}

	cout << count << endl;
	return 0;


	/*Q1*/
	/*
	int a, b;
	cin >> a >> b;

	if (a == b){
	cout << a + b;
	}
	else{
	if (a < b){
	cout << b * 2 - 1;
	}
	else{
	cout <<  a * 2 - 1;
	}
	}

	return 0;
	*/
}

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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    ll p= 100, tar, y=0;

    cin>> tar;

    while(p< tar)
    {
        p+= (p/100);
        y++;
    }

    cout<< y<< '\n';

    return 0;
}




Measured memory_bytes: 3672
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int n,k,l[50],ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>l[i];
	}
	sort(l,l+n);
	for(int i=n-k;i<n;i++){
		ans+=l[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main() {
    int N;
    cin >> N;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L[i];
    sort(all(L));
    ll sum = 0;
    for(int i = 0; i < N - 2; i++){
        for(int j = i + 1; j < N - 1; j++){
            for(int k = j + 1; k < N; k++){
                if(L[i] + L[j] > L[k]) sum++;
                else break;
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(),M = sc.nextInt();
		char[][] arrayA = new char[N][N];
		char[][] arrayB = new char[M][M];
		int[] flg = new int[N-M+1];
		int sum=0;
		String buff;

		for(int i=0;i<N;i++) {
			buff = sc.next();
			for(int j=0;j<N;j++) {
				arrayA[i][j] = buff.charAt(j);
			}
		}
		for(int i=0;i<M;i++) {
			buff = sc.next();
			for(int j=0;j<M;j++) {
				arrayB[i][j] = buff.charAt(j);
			}
		}
		for(int i=0;i<N-M+1;i++) {
			if(sample(N,M,arrayA,arrayB,i)==0) {
				System.out.println("Yes");
				System.exit(0);
			}
		}

		System.out.println("No");




	}
	public static int sample(int N,int M,char[][] arrayA,char[][] arrayB,int k) {
		int res=0;
		for(int i=0;i<N-M+1;i++) {
			for(int j=0;j<M;j++) {
				for(int l=0;l<M;l++) {
					if(arrayA[j+k][l+i]!=arrayB[j][l]) {
						res = 1;
						break;
					}
				}
			}
			if(res == 0) {
				return 0;
			}
			res = 0;
		}
		return 1;
	}

}


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2e5 + 5;

int n;
ll x[maxn], y[maxn];

int main(){
	scanf("%d", &n);
	FOR(i, 0, n){
		ll x_, y_;
		scanf("%lld%lld", &x_, &y_);
		x[i] = x_ + y_;
		y[i] = x_ - y_;
	}
	sort(x, x + n);
	sort(y, y + n);
	printf("%lld\n", max(x[n - 1] - x[0], y[n - 1] - y[0]));
	return 0;
}


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

int main(){
    int N,K,Q;
    cin>>N>>K>>Q;
    vector<int>A(Q);
    vector<int>B(N);
    for(int i=0;i<N;i++){
        B[i]=0;
    }
    for(int i=0;i<Q;i++){
        cin>>A[i];
        B[A[i]-1]++;
    }
    for(int i=0;i<N;i++){
        if(K-Q+B[i]>0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 1408
<?php
    fscanf(STDIN,"%d %d",$n,$m);
$p_s = array();
	for($i=0;$i<$m;$i++){
    	$p_s[] = explode(" ", trim(fgets(STDIN)));
    }

$pena=0;
$corect=0;
$memo = array();
$increct = array();

$realpena=0;
    foreach($p_s as $p){
        if(empty($memo[$p[0]]) && $p[1] == 'WA'){
          //$pena++;
          $increct[$p[0]]++;
        }
      if(empty($memo[$p[0]]) && $p[1]=='AC'){
          $corect++;
          $memo[$p[0]]++;
          $realpena+=$increct[$p[0]];
        }
     
    }


  echo $corect." ".$realpena."\n";

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

int main(int argc, const char * argv[]) {
    int N, M;
    int i, j;
    int *aM;
    int hole = 0;
    long long int *caseNum;
    
    scanf("%d",&N);
    scanf("%d",&M);
    aM = (int *)calloc(M, sizeof(int));
    caseNum = (long long int *)calloc(N, sizeof(long long int));
    
    for(i=0; i<M; i++){
        scanf("%d",&aM[i]);
    }
    
    caseNum[0] = 1;
    caseNum[1] = 2;
    for (j=0; j<M; j++) {
        if(aM[j] == 1){
            caseNum[0] = 0;
            caseNum[1] = 1;
            hole++;
        }
        if(aM[j] == 2){
            caseNum[1] = 0;
            hole++;
            break;
        }
        if(aM[j] > 2){break;}
    }
    
    for(i=2; i<N; i++){
        if(aM[hole] == i+1){
            caseNum[i] = 0;
            hole++;
        }else{
            caseNum[i] = (caseNum[i-1] + caseNum[i-2]) % 1000000007;
        }
    }
    
    printf("%lld\n", caseNum[N-1]);
    
    free(aM);
    free(caseNum);
    return 0;
}


Measured memory_bytes: 1280
x=io.read("*n")
local range
for i=0,1000000000 do
    if i*i*i*i*i-(i-1)*(i-1)*(i-1)*(i-1)*(i-1)>=1000000000 then
        range=i
        break
    end
end

for i=-range,range do
    for j=-range,range do
        if i*i*i*i*i-j*j*j*j*j==x then
            print(i.." "..j)
            return
        end
    end
end

Measured memory_bytes: 2788
import math
a,b,C=map(int,input().split())
S=a*b*math.sin(math.radians(C))/2
print(S)
c=math.sqrt(pow(a,2)+pow(b,2)-2*a*b*math.cos(math.radians(C)))
L=a+b+c
print(L)
h=2*S/a
print(h)


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> val;
    for(int i = 0;i<n;i++)
    {
        int x;
        cin>>x;
        val.push_back(x);
    }
    sort(val.begin(),val.end());
    long long sum = 0;
    sum += val[val.size()-1];
    int left = n-2;
    for(int i = val.size()-2;i>=0;i--)
    {
        if(left >= 2)
        {
            sum = sum + 2*val[i];
            left -= 2;
        }
        else if(left == 1)
        {
            sum += val[i];
            left--;
            break;
        }
        else
        {
            break;
        }

    }

    cout<<sum;

    return 0;
}

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

		int n = sc.nextInt();
		int k = sc.nextInt();
		int a[] = new int[10000];
		boolean  data[] = new boolean[n+1];
		int count =0;

		for (int i = 0;i<k ;i++ ) {
			  int d = sc.nextInt();
			for (int j = 0 ;j<d ;j++ ) {
				a[j] = sc.nextInt();
				  data[a[j]]=true;
			}
		}

		for (int i = 0;i<n+1 ;i++ ) {
			if (data[i]==false) {
				count++;
			}
		}

		System.out.println(count-1);
	}
}


Measured memory_bytes: 46216
n, m, Q = map(int,input().split())
lr = [[0 for i in range(n+1)] for j in range(n+1)]
for i in range(m):
    l,r = map(int,input().split())
    lr[l][r] += 1

# 二次元累積和(indexに注意)
s = [[0 for i in range(n+1)] for j in range(n+1)]
# s[x][y]:=[0,x-1]×[0,y-1]の長方形区間の総和
for i in range(n):
    for j in range(n):
        s[i+1][j+1] = s[i+1][j] + s[i][j+1] -s[i][j] + lr[i+1][j+1]

for i in range(Q):
    p,q = map(int,input().split())
    ans = s[q][q] - s[q][p-1] - s[p-1][q] + s[p-1][p-1] 
    print(ans)

# 72

Measured memory_bytes: 15588
from collections import*
def cont(n):
  res=0
  n-=1
  for i in c:
    if i>=n:res+=1
  return res
def fact_p(n):
  m=n
  i=2
  a=[]
  while n>1:
    if i>m**.5:
      a+=[n]
      break
    if n%i==0:
      n//=i
      a+=[i]
    else:i+=1  
  return a
n=int(input())
a=[]
for i in range(1,n+1):
  a+=fact_p(i)
c=list(Counter(a).values())
print(cont(75)+cont(25)*(cont(3)-1)+cont(15)*(cont(5)-1)+cont(5)*(cont(5)-1)*(cont(3)-2)//2)

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

typedef struct {
    int x;
    int y;
} coodinate;

int main(void){
    int N,M; cin >> N >> M;
    coodinate students[N];
    coodinate points[M];

    for(int i=0; i<N; i++){
        cin >> students[i].x >> students[i].y;
    }
    for(int i=0; i<M; i++){
        cin >> points[i].x >> points[i].y;
    }

    for(int i=0; i<N; i++){
        int min=pow(10,9);
        int id=0;
        for(int j=0; j<M; j++){
            int distance=abs(students[i].x-points[j].x)+abs(students[i].y-points[j].y);
            if(distance<min){
                min=distance;
                id=j+1;
            }
        }
        cout << id << endl;
    }

    return 0;
}

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

static const int MAX = 10000;
static const int INFTY = (1<<20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> >adj[MAX];

void dijkstra(){
  priority_queue<pair<int, int> >PQ;
  int color[MAX];
  int d[MAX];
  for(int i = 0; i < n;i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while( !PQ.empty() ){
    pair<int,int> f = PQ.top();
    PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if( d[u] < f.first * (-1)) continue;

    for(int j = 0;j < adj[u].size(); j++){
      int v = adj[u][j].first;
      if(color[v] == BLACK)continue;
      if(d[v] > d[u] + adj[u][j].second){
        d[v] = d[u] + adj[u][j].second;
        PQ.push(make_pair(d[v] * (-1),v));
        color[v] = GRAY;
      }
    }
  }

  for(int i = 0;i < n;i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i] ) << endl;
  }
}

int main(){
  int k,u,v,c;

  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v >> c;
      adj[u].push_back(make_pair(v,c));
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 8076