akhauriyash/Code-Regression huggingface dataset:
// AtCoder Beginners Contest 165
// D - Floor Function

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    unsigned long A, B, N, i,m, value0, value1;

    cin >> A >> B >> N;

    if (A < 1 && 1000000 < A)  {
        cout << "Aは条件を満たしていません!\n";
        return 0;
    }

    if (B < 1 && 1000000000000 < B)  {
        cout << "Bは条件を満たしていません!\n";
        return 0;
    }

    if (N < 1 && 1000000000000 < N)  {
        cout << "Nは条件を満たしていません!\n";
        return 0;
    }
    
    /*
    m = 1;
    value0 = floor(A*m/B) - A*floor(m/B);
    for (i = 2; i <= B-1; i++) {
	value1 = floor(A*i/B) - A*floor(i/B);
	if (value1 > value0) {
	    value0 = value1;
	}
    }
    */
    if (B-1 < N)
        value0 = floor(A*(B-1)/B) - A*floor((B-1)/B);
    else
        value0 = floor(A*N/B) - A*floor(N/B);
    cout << value0 << '\n';
}


Measured memory_bytes: 3636
fun main(args: Array<String>){
  val values = readLine()!!.split(" ")
  val a = Integer.parseInt(values[0])
  val b = Integer.parseInt(values[1])
  val t = Integer.parseInt(values[2])
  val result = ((t.toDouble() + 0.5) / a.toDouble()).toInt() * b
  println(result)
}

Measured memory_bytes: 37872
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,ans=0;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=1;i<n-1;i++)
    {
        if((a[i-1]>a[i]&&a[i]>a[i+1])||(a[i-1]<a[i]&&a[i]<a[i+1])) ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 3564
const main = (input) => {
  input = input.trim().split('\n')
  const [N, D] = input[0].split(' ').map(Number)
  const [, ...points] = input

  let ans = 0

  for (let v of points) {
    const [x, y] = v.split(' ').map(Number)

    if (Math.sqrt(x**2 + y**2) <= D) ans++
  }

  return console.log(ans)
}

process.env.MYTEST ? test() : main(require('fs').readFileSync('/dev/stdin', 'utf8'))

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

int main() {
  int N;
  cin >> N;
  
  vector<int> rice(N);
  for (int i = 0; i < N; i++) {
  	cin >> rice.at(i);
  }
  
  int n = 0;
  
  for (int i = 0; i < N; i++) {
  	if (rice.at(i) == 0){
    	continue;
    }
    else {
    	for (int j = 0; j < N; j++){
        	if (i == j) {
            	continue;
            }
          	else if (rice.at(j) == rice.at(i)) {
            	rice.at(j) = 0;
              	n++;
            }
        }
    }
  }
  
  cout << N -n;
  
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。
int main() {
    int X;
    cin >> X;
    for(int i = 2; i < X; i++){
        if(X % i == 0){
            X++;
            i = 1;
        }
    }
    cout << X << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // This will work only for g++ compiler.

#define for0(i, n) for (int i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (int i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (int i = (ll)(n); i >= 1; --i) // reverse 1 based
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end() //Forward traversal
#define rall(x) (x).rbegin, (x).rend() //reverse traversal
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) ll((a).size())
#define mod 1000000007
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

void fast()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
bool prime[1000001];
void sieve()
{
  memset(prime, true, sizeof(prime));
  prime[1]=false;
  for (int p=2; p*p<=1000000; p++)
  {
    if (prime[p] == true)
    {
        for (int i=p*p; i<=1000000; i += p)
                prime[i] = false;
    }
  }
}
void solve()
{
  ll a,b,c; 
  cin >> a >> b >> c; 
  if(c>=min(a,b) && c<=max(a,b))cout << "Yes" << endl; 
  else cout << "No" << endl;
 }
int main()
{
  fast();
  /*ll t;
  cin >> t;
  while(t--)*/
  solve();

return 0;
}


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

using ll = long long;
const ll p = 1000000007;

ll power(ll x, ll y,ll p){
    ll res = 1;    
  
    x = x % p;  
  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
  
        y = y>>1; 
        x = (x*x) % p;  
    }  
    return (res%p);  
} 

ll modInverse(ll n,ll p){
	return power(n,p-2,p);
}
ll nCr(ll n, ll k)  {  
    ll ans = 1;   
    if(k<0 || k>n){
    	return 0;
    }
    k = min(k,n-k);
    for (ll i = 1; i <= k; ++i){  
        ans = ((ans*modInverse(i,p))%p * (n+1-i))%p;
    }  
  
    return ans;  
} 

int main(){
	ll n,a,b;
	cin >> n >> a >> b;

	ll sum = power(2,n,p)-1;
	//cout << (binomialCoeff(n,a))%m << " " << (binomialCoeff(n,b))%m << "\n";
	sum = ((sum - (nCr(n,a))-nCr(n,b))%p + p)%p;

	cout << (sum%p) << "\n";
	return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#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 PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  rep(i,n){
    rep(j,n-i){
      string tmp=s;
      tmp.erase(i,j);
      if(tmp=="keyence"){
        cout<<"YES"<<endl;
        return 0;
      }
    }
  }
  if(s=="keyence"){
    cout<<"YES"<<endl;
    return 0;
  }
  cout<<"NO"<<endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  map<char,int> m;
  rep(i,N) {
    m[S[i]]++;
  }
  set<char> ignore;
  for (auto i = m.begin(); i != m.end(); i++) {
    if (i->second == 1) {
      ignore.insert(i->first);
    }
  }
  for (auto x : ignore) m.erase(x);
  int cur = 0;
  set<char> m2;
  int ma = 0;
  rep(i, N) {
    char c = S[i];
    if (ignore.count(c) > 0) continue;
    m2.insert(c);
    m[c]--;
    if (m[c] == 0) {
      m.erase(c);
      m2.erase(c);
    }
    ma = max(ma, (int)m2.size());
  }
  cout << ma << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <functional>
#include <typeinfo>
#include <utility>
#include <tuple>
#include <queue>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define all(vec) (vec).begin(), (vec).end()
#define yn(formula) (formula) ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(formula) (formula) ? (cout << "YES" << endl) : (cout << "NO" << endl)

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;

constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1ll << 59;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };

/*<ここから>***********************************************************/


int main()
{
	int N;
	cin >> N;
	vi a(N);
	rep(i, N) cin >> a[i];

	vpii ans;
	int ma = 0, mi = 0;
	rep(i, N) {
		if (a[ma] < a[i]) ma = i;
		if (a[mi] > a[i]) mi = i;
	}

	bool minus;
	if (a[mi] < 0) {
		if (a[ma] > 0) {
			if (-a[mi] < a[ma]) {
				rep(i, N) {
					ans.push_back(make_pair(ma, i));
					a[i] += a[ma];
				}
				minus = false;
			}
			else {
				rep(i, N) {
					ans.push_back(make_pair(mi, i));
					a[i] += a[mi];
				}
				minus = true;
			}
		}
		else {
			minus = true;
		}
	}
	else {
		minus = false;
	}


	int ptr = 0;
	if (!minus) {
		while (ptr < N - 1) {
			if (a[ptr] > a[ptr + 1]) {
				a[ptr + 1] += a[ptr];
				ans.push_back(make_pair(ptr, ptr + 1));
			}
			else ptr++;
		}
	}
	else {
		ptr = N - 1;
		while (ptr > 0) {
			if (a[ptr - 1] > a[ptr]) {
				a[ptr - 1] += a[ptr];
				ans.push_back(make_pair(ptr, ptr - 1));
			}
			else ptr--;
		}
	}

	cout << ans.size() << endl;
	rep(i, ans.size()) {
		cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2020 Bjarni Dagur Thor Karason

#include <bits/stdc++.h>

using namespace std;

#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); i++)
#define MP make_pair
#define PB push_back
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
#define INF 1000000000
#define PI 3.14159265359

int n, k;
vi stones;
int memo[100010];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    memset(memo, -1, sizeof(memo));
    cin >> n >> k;
    stones.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> stones[i];
    }
    memo[0] = 0;
    for (int i = 1; i < n; i++) {
        memo[i] = memo[i - 1] + abs(stones[i - 1] - stones[i]);
        for (int j = 2; j <= k; j++) {
            if (i - j >= 0) {
                memo[i] = min(memo[i], memo[i - j] + abs(stones[i - j] - stones[i]));
            }
            else break;
        }
    }
    cout << memo[n - 1] << endl;

    return 0;
}

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

long int GCD(long int a,long int b){
    if(b == 0)return a;
    return GCD(b,a%b);
}

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

    int a,b;
    cin >> a;

    for(int i = 0;i < n - 1; ++i){
        cin >> b;
        a = GCD(a,b);
    }

    cout << a << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <string>
#include <cmath>
#include <set>
#include <cmath>
using namespace std;


vector<vector<long long>> dp;
vector<long long> a;

const long long mod = 1e+9 + 7;

void solve()
{
	int n, K;
	cin >> n >> K;

	a.resize(n);

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

	dp.assign(2, vector<long long>(K + 1, 0));

	int cnt = 0;
	for (int i = 0; i < n; i++)
	{
		cnt += a[i];
		for (int k = 0; k <= min(cnt, K); k++)
		{
			if (i == 0)
			{
				dp[i & 1][k] = 1;
			}
			else
			{
				int l = max(0, (int)(k - a[i]));
				int r = k;

				

				dp[i & 1][k] = dp[(i + 1) & 1][r];
				
				if(l > 0)
					dp[i & 1][k] = (mod + dp[i & 1][k] - dp[(i + 1) & 1][l - 1]) % mod;

				dp[i & 1][k] %= mod;
			}

			

		}

		for (int k = 1; i < n - 1 && k <= min(K, cnt + (int) a[i + 1]); k++)
		{
			dp[i & 1][k] += dp[i & 1][k - 1];
			dp[i & 1][k] %= mod;
		}
	}

	cout << dp[(n - 1) & 1][K] % mod;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("file.in", "r", stdin);//freopen("file.out", "w", stdout);

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

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define lcm(a, b) ((a) * (b) / gcd((a), b))
#define all(x) x.begin(), x.end()
#define rep(i, x, n) for (ll i = x; i < n; i++)
#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)
#define endl '\n'

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;

template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

const ld PI = acos(-1);

ld solve(ld a, ld b, ld x) {
    return a * a * b / 2.0 <= x ? atan(2 * (a * a * b - x) / (a * a * a)) : PI/2 - atan(2 * x / (a * b * b));
}

signed main()
{
//	freopen("TEXT.inp", "r", stdin); freopen("TEXT.out", "w", stdout);
	fastio();

	ld a, b, x; cin >> a >> b >> x;
	cout << setprecision(10) << fixed << solve(a, b, x) * 180.0 / PI;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ramen = 700;
		char[] ary = sc.next().toCharArray();
		for (char c : ary) {
			if(c == 'o') ramen += 100;
		}
		System.out.println(ramen);
	}
}



Measured memory_bytes: 22868
//abc161_e.cpp
//Sat Apr  4 20:34:51 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	int n,k,c;
	cin >> n >> k >> c;
	string s;
	cin >> s;

	int l[k];
	int r[k];

	int num = 0;
	for (int i=0;i<s.length();i++){
		if (s[i]=='o'){
			l[num] = i;
			i+=c;
			num++;
		}
		if (num>=k){
			break;
		}
	}

	num = k-1;
	for (int i=s.length()-1;i>=0;i--){
		if (s[i]=='o'){
			r[num] = i;
			i-=c;
			num--;
		}
		if (num<0){
			break;
		}
	}

	for (int i=0;i<k;i++){
		if (l[i]==r[i]){
			cout << l[i]+1 << endl;
		}
	}

}

Measured memory_bytes: 3332
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll ans=0,n,k,r,s,p; cin>>n>>k>>r>>s>>p;
  string t; cin>>t;
bool rr=false,ss=false,pp=false;
  for(ll j=0;j<k;j++){
  ll i=j;
  char pre='a';
    while(i<n){
  if(t[i]=='r'){
   if(pre!='r'){ans+=p; pre='r';}
    else  pre='a';
        }
    else if(t[i]=='s'){
         if(pre!='s')  {ans+=r;pre='s';}
      else  pre='a';
                      }
    else if(t[i]=='p'){
      if(pre!='p'){ans+=s;pre='p';}
      else  pre='a';
        
  } 
    i+=k;
  }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i < (b); ++i)
#define F2(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i > (b); --i)
#define dF2(i, a, b) for (int i = (a); i >= (b); --i)
#define maxn 110
using namespace std;
typedef long long LL;
struct Point {
    int x,y,type;
    bool operator < (const Point& p) const { return x < p.x; }
}a[maxn<<1];
set<int> st;
int main() {
    int n;
    scanf("%d", &n);
    F(i, 0, n) scanf("%d%d", &a[i].x, &a[i].y), a[i].type=0;
    F(i, 0, n) scanf("%d%d", &a[n+i], &a[n+i].y), a[n+i].type=1;
    sort(a, a+(n<<1));
    int ans=0;
    F(i, 0, n<<1) {
        if (a[i].type) {
            auto it = st.lower_bound(a[i].y);
            if (it==st.begin()) continue;
            else st.erase(--it), ++ans;
        }
        else {
            st.insert(a[i].y);
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
typedef long long ll;
using ll = long long;
using vi = vector<int>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    int h, w;
    cin >> h >> w;
    string board[50];

    REP(i, h) cin >> board[i];

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

    REP(i, h) {
        REP(j, w) {
            if(board[i][j] == '#') continue;
            
            int num = 0;
            REP(k, 8) {
                const int ni = i + dx[k];
                if(ni < 0 or ni >= h) continue;
                const int nj = j + dy[k];
                if(nj < 0 or nj >= w) continue;

                if(board[ni][nj] == '#') num++;
            }
            board[i][j] = char(num + '0');
        }
    }
    REP(i, h) cout << board[i] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    char c;
    cin >>c;
    if(c=='A')
    {
        cout << 'T';
    }
    if(c=='T')
    {
        cout << 'A';
    }
    if(c=='G')
    {
        cout << 'C';
    }
    if(c=='C')
    {
        cout << 'G';
    }
    return 0;
}
    

Measured memory_bytes: 256
N,M=map(int,input().split())
s = [tuple(map(int,input().split())) for _ in range(N)]
c = [tuple(map(int,input().split())) for _ in range(M)]

def calc_dict(p1,p2):
  return abs(p1[0]-p2[0])+abs(p1[1]-p2[1])

for i in range(N):
  dist = list(map(lambda x:calc_dict(s[i],x),c))
  print(dist.index(min(dist))+1)

Measured memory_bytes: 9112
#include <bits/stdc++.h>
using namespace std;
int main() {
	char n[1000001];
	cin>>n;
	int l=strlen(n);
	int sum=0;
	for (int i=0;i<l;i++)
		if (n[i]=='1') sum++;
	cout<<sum;	
	
	return 0;
}

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

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

  vector<string> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
  }

  string res = "Three";
  for(int i=0;i<N;i++){
    if(vec.at(i)=="Y"){
      res = "Four";
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int a, b, c, k;
main() {
  file("threesum");
  ios;
  cin >> a >> b >> c >> k;
int   ans = min(a, k);
  k -= min(a, k);
  k -= min(k, b);
  ans -= min(k, c);
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    if (a=="H"&&b=="H"){
        cout<<"H"<<endl;
    }else if (a=="H"&&b=="D"){
        cout<<"D"<<endl;
    }else if (a=="D"&&b=="H"){
        cout<<"D"<<endl;
    }else if(a=="D"&&b=="D"){
        cout<<"H"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int x, y, a, b, c; cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    ll sum = 0;
    priority_queue<ll, vector<ll>, greater<ll>> k;
    rep(i,x) k.push(p[i]), sum += p[i];
    rep(i,y) k.push(q[i]), sum += q[i];

    rep(i,c) {
        if (k.top() > r[i]) break;
        else {
            sum -= k.top();
            k.pop();
            sum += r[i];
            k.push(r[i]);
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4724
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long k = sc.nextLong();
        a -= k;
        if(a < 0) {
            b += a;
            a = 0;
        }
        if(b < 0) {
            b = 0;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 38788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(i=0;i<n;i++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1; rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define fact(n) nPr((int)(n),(int)(n))
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
    
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  double tmp;
  
  scanf("%lld",&n);
  rep(i,n) scanf("%d",&a[i]);
  
  qsort(a,n,sizeof(int),upint);
  
  tmp = (a[0]+a[1])/2.0;
  for(i=2;i<n;i++){
    tmp = (tmp+a[i])/2.0;
  }
  printf("%g",tmp);
  return 0;
}



Measured memory_bytes: 2176
n = input()
one = int(n[-1])


if one == 0 or one == 1 or one == 6 or one == 8:
    print('pon')
elif one == 2 or one == 4 or one == 5 or one == 7 or one == 9:
    print('hon')
else:
    print('bon')

Measured memory_bytes: 9176
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int money = Integer.parseInt(sc.nextLine());
      	int work = money;
      	int i = 0;
      
      	while (work >= 500){
        	work = work - 500;
          	i++;
        }
      	
      	int j = 0;
      	while(work >= 5){
        	work = work - 5;
          	j++;
        }
      	
      	System.out.println(i*1000 + j * 5);
	}
}

Measured memory_bytes: 23252
use io::*;
use std::cmp::max;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let ps: Vec<usize> = (0..n).map(|_| sc.next()).collect();

    let mut qs: Vec<(usize, usize)> = ps.into_iter().zip(0..n).collect();
    qs.sort();

    let mut prev = qs[0].1;
    let mut cur_len = 1;
    let mut max_len = 1;
    for i in 1..n {
        if prev <= qs[i].1 {
            cur_len += 1;
            max_len = max(max_len, cur_len);
        } else {
            cur_len = 1;
        }
        prev = qs[i].1;
    }

    println!("{}", n - max_len);

    // println!("{}", n - LongestIncreasingSubsequenceLength(&ps));
}

// fn CeilIndex(v: &[usize], mut l: i32, mut r: i32, key: usize) -> usize {
//     while r - l > 1 {
//         let m = l + (r - l) / 2;
//         if v[m as usize] >= key {
//             r = m;
//         } else {
//             l = m;
//         }
//     }

//     r as usize
// }

// fn LongestIncreasingSubsequenceLength(v: &[usize]) -> usize {
//     if v.len() == 0 {
//         return 0;
//     }

//     let mut tail = vec![0; v.len()];
//     let mut length = 1; // always points empty slot in tail

//     tail[0] = v[0];
//     for i in 1..v.len() {
//         if v[i] < tail[0] {
//             // new smallest value
//             tail[0] = v[i];
//         } else if v[i] > tail[length - 1] {
//             // v[i] extends largest subsequence
//             tail[length] = v[i];
//             length += 1;
//         } else {
//             // v[i] will become end candidate of an existing subsequence or
//             // Throw away larger elements in all LIS, to make room for upcoming grater elements than v[i]
//             // (and also, v[i] would have already appeared in one of LIS, identify the location and replace it)
//             let ix = CeilIndex(&tail, -1, length as i32 - 1, v[i]);
//             tail[ix] = v[i];
//         }
//     }

//     length
// }

//-----

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


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

 
int main(){
	int a;
	string s;
	cin>>a>>s;
	if(a>=3200){
		cout<<s<<endl;
	}
	
	else{
		cout<<"red"<<endl;
	}
	return 0;
	
}

 

Measured memory_bytes: 256
x = int(input())
def prime_checker(i): #素数かどうか判定
    import sys
    if i == 1:
        return
    else:
        for j in range(2,(int(i**0.5))+1):
            if i % j == 0:
                return
        else:
            print(x)
            sys.exit()
while True:
    prime_checker(x)
    x += 1
    


Measured memory_bytes: 3060
main(i){float a,b,c,d,e,f,g,h;while(~scanf("%f %f %f %f %f %f %f %f",&a,&b,&c,&d,&e,&f,&g,&h))printf(!(a>g||a>h||c<e||d<f)?"YES\n":"NO\n");exit(0);}

Measured memory_bytes: 612
class Element:
	val = 0
	parent = None
	height = 0
	size = 1
	def __init__(self, val, parent=None, height=0, size=1):
		self.val = val
		if parent is None:
			self.parent = self
		else:
			self.parent = parent
		self.height = height
		self.size = size

class UnionFindTree:
	elemnts = []

	def __init__(self, n):
		self.elemnts = [Element(val=i) for i in range(n)]

	def root(self, x:int) -> Element:
		if self.elemnts[x].parent is self.elemnts[x]:
			return self.elemnts[x]
		return self.root(self.elemnts[x].parent.val)

	def same(self, x:int, y:int) -> bool:
		rx = self.root(x)
		ry = self.root(y)
		return rx is ry

	def unite(self, x:int, y:int):
		rx = self.root(x)
		ry = self.root(y)
		if rx == ry:
			return
		if rx.height < ry.height:
			rx.parent = ry
			ry.size += ry.height
		else:
			ry.parent = rx
			rx.size += ry.size
			if rx.height == ry.height:
				rx.height += 1

def main():
	N, M = map(int, input().split())
	uionfind = UnionFindTree(N)
	for i in range(M):
		u, v, z = map(int, input().split())
		uionfind.unite(u-1, v-1)
	ans_set = set()

	ans = 0
	for i in range(N):
		this_root = uionfind.root(i).val
		if not this_root in ans_set:
			ans += 1
			ans_set.add(this_root)
	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 39148
#include <stdio.h>          // printf(), scanf()

#define MAX_N 200000
#define min(a, b) ((a) < (b) ? a : b)
#define max(a, b) ((a) > (b) ? a : b)

int
main(int argc, char** argv)
{
	int r[MAX_N];
	int n, i;

	int maxv = -1000000000;
	int minv = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
		scanf("%d", &r[i]);

	minv = r[0];
	for (i = 1; i < n; ++i)
	{
		maxv = max(maxv, r[i] - minv);
		minv = min(minv, r[i]);
	}

	printf("%d\n", maxv);
	return 0;
}

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

int main(){
  string s,t;
  cin >> s;
  cin >> t;
  int res=0;
  rep(i,s.size()) if(s[i]!=t[i]) res++;
  cout << res;
  return 0;
}

Measured memory_bytes: 3852
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,n,m;
	cin>>n>>m;
	ll temp=m-2*n;
	if(temp%2==0) {
		temp/=2;
		ll temp1=n-temp;
		if(temp>=0 && temp1>=0) cout<<"Yes\n";
		else cout<<"No\n";
	}
	else {
		cout<<"No\n";
	}
}

int main() {
    speedup;
    ll i=0,t;
    t=1;
    //cin>>t;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;
typedef char CHAR;
typedef unsigned char UCHAR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int INT;
typedef unsigned int UINT;
typedef long long LLONG;
typedef unsigned long long ULLONG;

#define LengthOf(x)    (sizeof(x) / sizeof(x[0]))

#if 1
//No.4
int main()
{
	LLONG A, B, N;
	cin >> A >> B >> N;

	LLONG x = (B - 1 > N) ? N : B - 1;
	LLONG ret = (A * x) / B - A * (x/B);
	cout << ret;
	return 0;
}
#endif

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

public class Main {
    public static void main(String[] args) {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        try {
            String input = in.readLine();

            int S = Integer.parseInt(input);
            int s = S % 60;
            int m = S % (60 * 60) / 60;
            int h = S / (60 * 60);

            System.out.println(String.format("%d:%d:%d", h, m, s));
        } catch (IOException ex) {
            // no op
        }
    }
}


Measured memory_bytes: 24704
package main

import "fmt"

func main() {
  var N, M, sum int
  fmt.Scan(&N, &M)
  
  A := make([]int, N)
  for i := range A {
    fmt.Scan(&A[i])
    sum += A[i]
  }
  
  th := float64(sum)/float64(M)/4
  var count int
  for i := range A {
    if float64(A[i]) >= th {
      count++
    }
  }

  if count>=M {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}
  

Measured memory_bytes: 512
from math import factorial as f
x,y=map(int,input().split())
if(x<2):
    a=0
else:
    a=f(x)//(f(x-2)*2)
if(y<2):
    b=0
else:    
    b=f(y)//(f(y-2)*2)
print(a+b)


Measured memory_bytes: 38256
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
#include<functional>
#include<deque>
#include<list>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int a[10][10],h,w,k,i,j;
  cin >> h >> w >> k;
  scanf("\n");
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      char s;
      scanf("%c",&s);
      if(s=='.'){
        a[i][j]=0;
      }
      else{
        a[i][j]=1;
      }
    }
    scanf("\n");
  }
  int ans=0;
  for(int tmp=0;tmp<(1<<h);tmp++){
    bitset<7> x(tmp);
    for(int tmp1=0;tmp1<(1<<w);tmp1++){
      bitset<7> y(tmp1);
      int b[10][10];
      for(i=0;i<h;i++){
        for(j=0;j<w;j++){
          b[i][j]=a[i][j];
        }
      }
      for(i=0;i<h;i++){
        if(x[i]==1){
          for(j=0;j<w;j++){
            b[i][j]=0;
          }
        }
      }
      for(i=0;i<w;i++){
        if(y[i]==1){
          for(j=0;j<h;j++){
            b[j][i]=0;
          }
        }
      }
      int sum=0;
      for(i=0;i<h;i++){
        for(j=0;j<w;j++){
          if(b[i][j]==1){
            sum++;
          }
        }
      }
      if(sum==k){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

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

int cmp(int a,int b){
	return a>b;
}
int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1; i<=n; i++){
		a[i]=0;
	}
	for(int i=1; i<=n; i++){
		int t;
		cin>>t;
		a[t]++;
	}
	sort(a+1,a+n+1,cmp);
	int x=0;
	for(int i=k+1; i<=n; i++){
		x+=a[i];
	}
	cout<<x<<endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	string s, ans;
	cin >> s;
	int n = s.length();
	string res=to_string(n - 2);
	ans = s[0] + res + s[n - 1];
	cout << ans << endl;
	return 0;
}


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

int mod = 1000000007;
int64_t large = 9223372036854775807;
double PI = 3.141592653589793;

int main()
{
    int N, tmp;
    cin >> N;
    unordered_map<int, int> hist;
    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        hist[tmp - 1]++;
    }
    int ans = 0;
    for (auto x:hist)
    {
        int good = x.first + 1, count = x.second;
        if (good < count)
            ans += count - good;
        if (good > count)
            ans += count;
    }
    cout << ans;
}

Measured memory_bytes: 4260
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a , b) << endl;
  return 0;
}

Measured memory_bytes: 256
s=[1 if x =="1" else 0 for x in input()]
ans1,ans2=0,0
for i in range(len(s)):
    if i%2==0:
        if s[i]==1:
            ans1+=1
        else:
            ans2+=1
    else:
        if s[i]==0:
            ans1+=1
        else:
            ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 45424
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;
bool seen[101];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x,n,tmp,ans1,ans2;
    cin>>x>>n;
    for(int i=0;i<n&&cin>>tmp;i++)
        seen[tmp]=1;
    for(int i=x;i<200;i++)
        if(!seen[i]){ans1=i;break;}
    for(int i=x;i>=0;i--)
        if(!seen[i]){ans2=i;break;}
    cout<<(ans1-x<x-ans2?ans1:ans2);
    return 0;
}


Measured memory_bytes: 3624
import itertools
import collections

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
        table[i] *= i
    return table

N = int(input())
#N=10**7
#print(prime_factor(N,prime_factor_table(N)))
ans = 0
print(sum(num_divisors_table(N)))

    #num_divisors_table(N)



Measured memory_bytes: 146596
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n,a[100000],cnt[100000];
int main(){
    scanf("%d",&n);
    memset((cnt),0,sizeof(cnt));
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        cnt[a[i]]++;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int cur=cnt[a[i]];
        if(a[i]-1>=0)cur+=cnt[a[i]-1];
        if(a[i]+1<n)cur+=cnt[a[i]+1];
        ans=max(ans,cur);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

template<typename Monoid,typename F>
class SegmentTree{
private:
//    using F = function<Monoid(Monoid,Monoid)>;
    int sz;
    vector<Monoid> seg;
    const F op;//演算
    const Monoid e;//単位元
public:
    SegmentTree(int n,const F op,const Monoid &e):op(op),e(e){
        sz = 1;
        while(sz<n) sz <<= 1;
        seg.assign(2*sz,e);
    }
    //代入
    void set(int k, const Monoid &x){
        seg[k+sz] = x;
    }
    //前計算(?)
    void build(){
        for(int i=sz-1;i>0;i--){
            seg[i] = op(seg[2*i],seg[2*i+1]);
        }
    }
    void update(int k,const Monoid &x){
        k += sz;
        seg[k] += x;
        while(k>>=1){
            seg[k] = op(seg[2*k],seg[2*k+1]);
        }
    }
    Monoid query(int l,int r){
        Monoid L = e,R = e;
        for(l+=sz,r+=sz;l<r;l>>=1,r>>=1){
            if(l&1) L = op(L,seg[l++]);
            if(r&1) R = op(seg[--r],R);
        }
        return op(L,R);
    }
    Monoid operator[](const int &k)const{
        return seg[k+sz];
    }
    template<typename C>
    int find_subtree(int a,const C &check,Monoid &M,bool type) {
        while(a<sz) {
            Monoid nxt = type ? op(seg[2*a+type],M) : op(M,seg[2*a+type]);
            if(check(nxt)) a = 2*a+type;
            else M = nxt, a = 2*a+1-type;
        }
        return a - sz;
    }

    template<typename C>
    int find_first(int a,const C &check) {
        Monoid L = e;
        if(a <= 0) {
            if(check(op(L,seg[1]))) return find_subtree(1,check,L,false);
            return -1;
        }
        int b = sz;
        for(a+=sz,b+=sz;a<b;a>>=1,b>>=1) {
            if(a&1) {
                Monoid nxt = op(L,seg[a]);
                if(check(nxt)) return find_subtree(a,check,L,false);
                L = nxt;
                ++a;
            }
        }
        return -1;
    }

    template<typename C>
    int find_last(int b,const C &check) {
        Monoid R = e;
        if(b >= sz) {
            if(check(op(seg[1], R))) return find_subtree(1, check, R, true);
            return -1;
        }
        int a = sz;
        for(b+=sz; a<b; a>>=1,b>>=1) {
            if(b&1) {
                Monoid nxt = op(seg[--b],R);
                if(check(nxt)) return find_subtree(b,check,R,true);
                R = nxt;
            }
        }
        return -1;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q;
    cin >> N >> Q;
    auto add = [](int a,int b){return a+b;};
    SegmentTree<int,decltype(add)> 
    seg(N,add,0);
    for(int i=0;i<Q;i++){
        int c,x,y;
        cin >> c >> x >> y;
        if(c==0) seg.update(x,y);
        else cout << seg.query(x,y+1) << endl;
    }
}


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

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	int A = 0;
	int B = 0;
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0) {
			A += a[i];
		}
		else {
			B += a[i];
		}
	}
	int ans = A - B;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

const int N = 50+5;
int adj[N][N] = {};
int flag[N] = {};

void dfs(int vertex) {
    int i;

    if (flag[vertex]) return;

    flag[vertex] = 1;

    for (i=0; i<N; ++i) {
        if(adj[vertex][i]) dfs(i);
    }
}

int main() {
    using namespace std;
    int n, m;
    int i, a, b;
    int j, count = 0;
    int k;

    cin >> n >> m;
    for (i=0; i<m; ++i) {
        cin >> a >> b;
        adj[a-1][b-1] = 1;
        adj[b-1][a-1] = 1;
    }

    for (i=0; i<n; ++i) {
        for (j=i; j<n; ++j) {
            if (adj[i][j]) {
                adj[i][j] = 0;
                adj[j][i] = 0;

                dfs(0);
                for (k=0; k<n; ++k) {
                    if (!flag[k]) break;
                }
                if (k < n) ++count;

                for (k=0; k<N; ++k) flag[k] = 0;
                adj[i][j] = 1;
                adj[j][i] = 1;
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 2e18

using namespace std;

llint Q;
llint sx, sy, tx, ty;
vector<llint> SX, SY, TX, TY;
llint beki[35];

vector<llint> get(llint x)
{
	vector<llint> ret;
	for(int i = 0; i < 30; i++){
		ret.push_back(x%3);
		x /= 3;
	}
	reverse(ret.begin(), ret.end());
	return ret;
}

llint dist(llint sx, llint sy, llint tx, llint ty)
{
	return abs(sx-tx) + abs(sy-ty);
}

llint trip(llint sx, llint sy, llint tx, llint ty, llint level)
{
	llint ret = inf;
	llint size = beki[29-level];
	
	llint px = tx/size*size, py = ty/size*size;
	ret = min(ret, dist(sx, sy, px-1, py-1) + dist(px-1, py-1, tx, ty));
	ret = min(ret, dist(sx, sy, px+size, py-1) + dist(px+size, py-1, tx, ty));
	ret = min(ret, dist(sx, sy, px-1, py+size) + dist(px-1, py+size, tx, ty));
	ret = min(ret, dist(sx, sy, px+size, py+size) + dist(px+size, py+size, tx, ty));
	return ret;
}

llint calc(llint sx, llint sy, llint tx, llint ty)
{
	if(sy > ty) swap(sy, ty);
	SX = get(sx), SY = get(sy);
	TX = get(tx), TY = get(ty);
	
	llint diff = 30; bool flag = false;
	for(int i = 0; i < 30; i++){
		if(flag){
			if(SY[i] == 2 && TY[i] == 0) continue;
			else{
				diff = i;
				break;
			}
		}
		if(SY[i] != TY[i]){
			if(!flag && TY[i] - SY[i] == 1){
				flag = true;
				continue;
			}
			diff = i;
			break;
		}
	}
	
	llint level = -1;
	for(int i = 0; i < 30; i++){
		if(SX[i] != TX[i]) return -1;
		if(SX[i] == 1){
			if(diff <= i){
				level = i;
				break;
			}
		}
	}
	if(level == -1) return -1;
	
	return trip(sx, sy, tx, ty, level);
}

int main(void)
{
	beki[0] = 1;
	for(int i = 1; i <= 30; i++) beki[i] = beki[i-1] * 3;
	
	cin >> Q;
	for(int q = 0; q < Q; q++){
		cin >> sx >> sy >> tx >> ty;
		sx--, sy--, tx--, ty--;
		
		llint ret = calc(sx, sy, tx, ty);
		if(ret != -1){
			cout << ret << endl;
			continue;
		}
		swap(sx, sy), swap(tx, ty);
		
		ret = calc(sx, sy, tx, ty);
		if(ret != -1){
			cout << ret << endl;
			continue;
		}
		
		cout << dist(sx, sy, tx, ty) << endl;
	}
}

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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	if(30 <= x){
		cout << "Yes";
	}
	else{
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int N = 101010;
int main(){
	int a,b,i;
	string s1,s2;
	cin>>s1;
	cin>>s2;
	s1=s1+s2;
	
	a=0;
	for(i=0;i<s1.length();i++){
		a=a*10+s1[i]-'0';
	}
	bool t=false;
	for(i=1;i<=10000;i++){
		if(i*i==a)t=true;
	}
	if(t)cout<<"Yes";
	else cout<<"No";
	return 0;
}  

Measured memory_bytes: 256