akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 2e5+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;
ll bin_pow(ll base,ll deg)
{
    if (deg==0)
        return 1;
    ll t=bin_pow(base,deg/2);
    if (deg&1)
        return (((t*t)%mod1)*base)%mod1;
    else
        return (t*t)%mod1;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef LOCAL
    freopen("a.in","r",stdin);
#endif
    ll n;
    cin>>n;
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    ll fact[MAXN];
    ll f=1;
    for (ll i=0;i<MAXN;i++)
        fact[i]=f,f*=(i+1),f%=mod1;
    ans=bin_pow(2,n);
    ll aa=1; //
    for (ll i=n;i>n-a;i--)
        aa*=i,aa%=mod1;
    aa*=bin_pow(fact[a],mod1-2);
    aa%=mod1;
    ans-=aa;
    ans%=mod1;
    ans+=mod1;
    ans%=mod1;
    ll bb=1;
    for (ll i=n;i>n-b;i--)
        bb*=i,bb%=mod1;
    bb*=bin_pow(fact[b],mod1-2);
    bb%=mod1;
    ans-=bb;
    ans%=mod1;
    ans+=mod1;
    ans%=mod1;
    ans--;
    if (ans<0)
        ans+=mod1;
    cout<<ans;




}

Measured memory_bytes: 1792
#include <iostream>
#include <set>
#include <iterator>
#include <algorithm>

int main() {
    long long n, c, k, t, ret = 0;
    std::cin >> n >> c >> k;
    std::multiset<long long> s;
    for (auto i = 0ll; i < n; i++) {
        std::cin >> t;
        s.insert(t);
    }

    while (!s.empty()) {
        auto t = *s.begin();
        auto cit = s.lower_bound(t + k + 1);
        auto count = std::distance(s.begin(), cit);
        auto b = std::max(count / c, 1ll);
        ret += b;
        for (auto i = 0; i < (count >= c ? b * c : count); i++) if (!s.empty()) s.erase(s.begin());
    }

    std::cout << ret << std::endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define flb(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define mp make_pair
#define pb push_back
#define inf (long long)(1e18+1e15)
typedef pair<int,int> ii;
typedef vector <int> vi;
typedef vector <pair<int,int> > vii;
typedef vector <vector <int> > vvi;

int main()
{
    float r;
    cin>>r;
    float pi=3.1415926536;
    float ans=2*pi*r;
    printf("%f",ans);
}


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

int main() {
    int A, B;
    cin >> A;
    cin >> B;
    if(A<=8&& B<=8){
        cout << "Yay!" << endl;
        return 0;
    }

    cout << ":(" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>

using namespace std;

int main()
{
 int a, b;
 int d, r;
 double f;
 scanf("%d %d", &a, &b);

 d = a / b;
 r = a % b;
 f = (double)a / b;
 cout << d << " " << r << " ";
 cout << fixed << setprecision(5) << f << endl;
}


Measured memory_bytes: 3316
#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>
using namespace std;

#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)

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int s = 0;
    rep(i, n) {
        cin >> a[i];
        s += a[i];
    }
    int cnt = 0;
    rep(i, n) if (s <= a[i] * 4 * m) cnt++;
    cout << (m <= cnt ? "Yes" : "No") << endl;
}

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

int par[10001], d[10001];
void init(int n){
	for(int i = 0;i < n;i++){
		par[i] = i;
		d[i] = 0;
	}
}

int find(int x){
	if(x == par[x])return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x);
	y = find(y);
	if(x == y)return ;
	if(d[x] < d[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(d[x] == d[y])d[x]++;
	}
}

bool same(int x, int y){
	return find(x) == find(y);
}

int main(){
	int n, q, c, x, y;
	scanf("%d%d", &n, &q);
	init(n);
	
	for(int i = 0;i < q;i++){
		scanf("%d%d%d", &c, &x, &y);
		if(!c){
			unite(x, y);
		}else{
			printf("%d\n", same(x, y));
		}
	}
	return 0;
}


Measured memory_bytes: 3288
n = int(input())

num = [int(input()) for _ in range(5)]

index = 0
mi = num[0]
for i in range(5):
    if num[i] < mi:
        index = i
        mi = num[i]

if n % mi == 0:
    print(n // mi + 4)
else:
    print(n // mi + 5)

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n;
  int pa, pb;
  int sa = 0, sb = 0;
  int i;
  for(;;){
    scanf("%d",&n);
    if(n==0) break;
    sa = 0; sb = 0;
    for(i=0;i<n;i++){
      scanf("%d %d",&pa,&pb);
      if(pa > pb) sa += pa+pb;
      else if(pa < pb) sb += pa+pb;
      else sa += pa, sb += pb;
    }
    printf("%d %d\n", sa, sb);
  }
  return 0;
}

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

int func(int x) {
    int cnt = 0;
    while (x >= 2) {
        if (x % 2 == 0) {
            cnt++;
            x /= 2;
        } else {
            break;
        }
    }
    return cnt;
}

int main() {
    int N; cin >> N;
    ll a[N];
    int ans = 0;
    rep(i, N){
        cin >> a[i];
        ans += func(a[i]);
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const long double PI = 3.14159265359;
const int MAX_N = 100010;


int dp[110][100010];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, W; cin >> n >> W;
	VE w(n), v(n); rep(i, n)cin >> w[i] >> v[i];
	rep(i, 100010)dp[0][i] = INF;
	dp[0][0] = 0;
	rep(i, n) {
		for (int j = 0; j <= 100010; j++) {
			if (j < v[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	int ans = 0;
	rep(i, 100010) {
		if (dp[n][i] <= W)chmax(ans, i);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int a,b,c;	cin>>a>>b>>c;
	if(a!=b && b!=c && a!=c)cout<<"No"<<endl;
	else if(a==b && b==c)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

	return 0;
}


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

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        // abc 113 C
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] list = new int[m][3];

        for (int i = 0; i < m; i++) {
            // 県
            list[i][0] = sc.nextInt();
            // 年
            list[i][1] = sc.nextInt();
            // 出力順
            list[i][2] = i;
        }

        Arrays.sort(list, Comparator.comparingInt(a -> a[1]));

        String[] ans = new String[m];
        int[] count = new int[n];

        for (int i = 0; i < m; i++) {
            int[] t = list[i];
            count[t[0] - 1]++;
            ans[t[2]] = String.format("%06d%06d", t[0], count[t[0] - 1]);
        }

        for (String v: ans
             ) {
            System.out.println(v);
        }
    }
}

Measured memory_bytes: 155992
import sys
import math

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()


def inverse(x, mod):
    return pow(x, mod - 2, mod)


def factorize(x):
    count = {}
    i = 2
    while i * i <= x:
        while x % i == 0:
            x //= i
            count[i] = count.get(i, 0) + 1
        i += 1
    if x > 1:
        count[x] = count.get(x, 0) + 1
    return count


N = int(input())
A = list(map(int, input().split()))

A = list(map(factorize, A))

lcm = {}
for i in A:
    for factor, count in i.items():
        lcm[factor] = max(lcm.get(factor, 0), count)

MOD = 1000000007

lcm_int = 1
for factor, count in lcm.items():
    lcm_int *= pow(factor, count, MOD)
    lcm_int %= MOD

ans = 0
for i in A:
    B = lcm_int
    for factor, count in i.items():
        B *= inverse(pow(factor, count, MOD), MOD)
        B % MOD
    ans = (ans + B) % MOD
print(ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INF = 2147483647;
const long long LINF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
	int N; cin >> N;
    VI x1(N), y1(N), x2(N), y2(N); REP(i,N) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
    vector<ll> wx, wy;
    REP(i,N){
        wx.push_back(x1[i]); wx.push_back(x2[i]);
        wy.push_back(y1[i]); wy.push_back(y2[i]);
    }
    SORT(wx); wx.erase(unique(ALL(wx)), wx.end());
    SORT(wy); wy.erase(unique(ALL(wy)), wy.end());

    VVI fld(wx.size()+1, VI(wy.size()+1,0));
    REP(i,N){
        int p1 = LB(wx, x1[i]), p2 = LB(wx, x2[i]);
        int p3 = LB(wy, y1[i]), p4 = LB(wy, y2[i]);
        fld[p1][p3]++; fld[p1][p4]--; fld[p2][p3]--; fld[p2][p4]++;
    }
    REP(i,wx.size())REP(j,wy.size()) fld[i+1][j] += fld[i][j];
    REP(i,wx.size())REP(j,wy.size()) fld[i][j+1] += fld[i][j];
    ll ans = 0;
    REP(i,wx.size()-1)REP(j,wy.size()-1){
        if(fld[i][j]) ans += (wx[i+1]-wx[i])*(wy[j+1]-wy[j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 65624
n, y = map(int, input().split())

for i in range(n, -1, -1):
    for j in range(n-i, -1, -1):
        if i *10000 + j * 5000 + (n-i-j) * 1000 == y:
            print(str(i) + ' ' + str(j) + ' ' + str(n-i-j))
            exit(0)

print("-1 -1 -1")

Measured memory_bytes: 3060
import math
N = int(input())
if N == 0:
  print(0)
  quit()
p = int(math.log2(abs(N))) + 1
ans = [0] * (p + 10)
now = 0
for i in range(p + 10):
  x = N % (2 ** (i + 1))
  y = (now + ((-1) ** i) * (2 ** i) ) % (2 ** (i + 1))
  if (y == x) or (y + 2 ** (i + 1) == x):
    now += ((-1) ** i) * (2 ** i)
    ans[i] = 1
  if now == N:
    break
  #print(now, ans, x, y)

#print("n", now, ans, x, y)
p = 0
for i in range(1, len(ans) + 1):
  if p == 0:
    if ans[-i] != 0:
      p = 1
      print(ans[-i], end = "")
  else:
    print(ans[-i], end = "")

print("")



Measured memory_bytes: 9284
#include <cstdio>
#include <algorithm>
 
using namespace std;
 
int main() {
    int a[5], k;
    scanf("%d%d%d%d%d%d", a, a + 1, a + 2, a + 3, a + 4, &k);
    sort(a, a + 5);
    puts(a[4] - a[0] <= k ? "Yay!" : ":(");
    return 0;
}

Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))

ans = []
a.sort()
low = a[0]
high = a[-1]
for i in a[1:-1]:
    if i>0:
        ans.append([low,i])
        low = low - i
    else:
        ans.append([high,i])
        high = high - i

ans.append([high,low])
print(high-low)
for x,y in ans:
    print('{0} {1}'.format(x,y))

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

int main() {
  int x, y, z ,a;
  cin >> x >> y >> z >>a;

  if(x+y > z+a)
    cout << "Left" << endl;
  else if(x+y == z+a)
    cout << "Balanced" << endl;
  else if(x+y < z+a)
    cout << "Right" << endl;
      
}

Measured memory_bytes: 256
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 998244353
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========     //\\       //||     ||====//||
//      ||        //  \\        ||     ||   // ||
//      ||       //====\\       ||     ||  //  ||
//      ||      //      \\      ||     || //   ||
//  ========== //        \\  ========  ||//====|| 
//  code

void solve(){
    int n,i,j,k,l,p;
    cin >> n;
    vector< vector<int> > dp(n, vector<int>(3, -1)), a(n, vector<int>(3));
    for(i = 0; i < n; i++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }

    dp[0] = a[0];
    for(i = 1; i < n; i++){
        dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = a[i][2] + max(dp[i - 1][1], dp[i - 1][0]);
    }

    cout << *max_element(all(dp[n - 1])) << endc;
}

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


Measured memory_bytes: 14216
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {

	int D, T, S;

	cin >> D >> T >> S;

	if(T*S >= D) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3596
import java.io.*;
import java.math.BigDecimal;
import java.text.Bidi;
import java.util.StringTokenizer;

public class Main {
    
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task task = new Task();
        task.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long a = in.nextLong();
            long b = in.nextLong();
            long c = in.nextLong();

            if (c - a - b > 0 && 4 * a * b < (c - a - b) * (c - a - b)) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

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

    }

}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(s) cout << s << endl;
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    string n; cin>>n;
    if(n[0]=='9'||n[1]=='9') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(i=0;i<n;i++)
using namespace std;
int main() {
    string a, b, c;
    cin >> a >> b >> c;
    string ans = a.substr(0, 1);
    ans += b.substr(0, 1);
    ans += c.substr(0, 1);
    int i;
    rep(i, ans.size()) {
        ans[i] -= 32;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*************************************************************************
    > File Name: DD.cpp
    > Author: HandsomeHow
    > Mail: handsomehowyxh@gmail.com 
    > Created Time: 2017/7/11 13:15:17
 ************************************************************************/

#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define cl(a) memset((a),0,sizeof(a))
#ifdef HandsomeHow
#define dbg(x) cerr << #x << " = " << x << endl
#else
#define dbg(x)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
const int inf=0x3f3f3f3f;
const double eps=1e-8;
const int mod=1000000007;
const double pi=acos(-1.0);
inline void gn(long long&x){
    int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');c=='-'?(sg=-1,x=0):(x=c-'0');
    while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
ll gcd(ll a,ll b){return a? gcd(b%a,a):b;}
ll powmod(ll a,ll x,ll mod){ll t=1ll;while(x){if(x&1)t=t*a%mod;a=a*a%mod;x>>=1;}return t;}
// (づ°ω°)づe★------------------------------------------------
const int maxn = 4444;
char s[maxn], t[maxn];
int cnts[33], cntt[33];
int len1, len2;
ll md[] = { 1000000009,1000000007 };
ll key[] = { 1000000007,19260817 };
pii hh(int *a){
    ll ret[2];
    rep(i,0,25){
        rep(j,0,1){
            ret[j]=(ret[j]*key[j]+a[i])%md[j];
        }
    }
    return mp((int)ret[0],(int)ret[1]);
}
set<pii>has;
bool check(int len){
    has.clear();
    cl(cnts);cl(cntt);
    rep(i,1,len){ cnts[s[i]-'a']++; }
    int ls=1,rs=len;
    while(rs<=len1){
        has.insert(hh(cnts));
        cnts[s[ls]-'a']--;ls++;
        rs++;if(rs>len1)break;
        cnts[s[rs]-'a']++;
    }
    rep(i,1,len){ cntt[t[i]-'a']++; }
    int lt=1,rt=len;
    while(rt<=len2){
        pii now = hh(cntt);
        if(has.count(now)){
            return true;
        }
        cntt[t[lt]-'a']--; lt++;
        rt++;if(rt>len2)break;
        cntt[t[rt]-'a']++;
    }
    return false;
}
int main(){
#ifdef HandsomeHow
    freopen("data.in","r",stdin);
    //freopen("data.out","w",stdout);
#endif
    scanf("%s%s",s+1,t+1);
    len1 = strlen(s+1);
    len2 = strlen(t+1);
    int l = 0, r = min(len1,len2);
    per(i,r,1){
        if(check(i)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 3376
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<utility>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> P;
typedef unsigned long long int ull;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;
const int MAXE=100000;
const int MAXV=10000;
const ll INF=2e9;

struct UnionFindTree{
    vector<int> par,rank;
    UnionFindTree(int n):par(n),rank(n,0){
        for(int i=0;i<n;i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[rx]<rank[ry]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

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

int popcount(int x){
    int res=0;
    while(x>0){
        if(x&1) res++;
        x>>=1;
    }
    return res;
}

int f(int x){
    if(x==0) return 1;
    return f(x%popcount(x))+1;
}

vector<int> prime_factor(int n){
    vector<int> res(n+1,0);
    for(int i=2;i<=n;i++){
        int m=i;
        for(int j=2;j*j<=m;j++){
            if(m%j==0){
                while(m%j==0){
                    res[j]++;
                    m/=j;
                }
            }
        }
        if(m!=1) res[m]++;
    }
    return res;
}

int main(){
    int n;cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    if(n%2==1){
        ll res1=0,res2=0;
        for(int i=0;i<n/2;i++){
            res1-=a[i]*2;
        }
        res1+=a[n/2]+a[n/2+1];
        for(int i=n/2+2;i<n;i++){
            res1+=a[i]*2;
        }
        for(int i=0;i<n/2-1;i++){
            res2-=a[i]*2;
        }
        res2-=(a[n/2-1]+a[n/2]);
        for(int i=n/2+1;i<n;i++){
            res2+=a[i]*2;
        }
        ans=max(res1,res2);
    }
    else{
        for(int i=0;i<n/2-1;i++){
            ans-=a[i]*2;
        }
        ans-=a[n/2-1];
        ans+=a[n/2];
        for(int i=n/2+1;i<n;i++){
            ans+=a[i]*2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main () {
	long long A;
	long long B;
	long long T;
	cin >> A;
	cin >> B;
	cin >> T;
    
    
    if ( T >= A ) {
    	cout << ((T/A)*B) <<endl;
    } 
    else {
    	cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define p 101
#define mod 131
#define ABC (('A'-'A'+1)*p*p+('B'-'A'+1)*p+('C'-'A'+1))%mod
using namespace std;
string a;
int n;

void INPUT(){
	cin>>n;
	cin>>a;
}
void SOLVE(){
	int ans=0;
	for(int i=2;i<n;i++)
		if(((a[i-2]-'A'+1)*p*p+(a[i-1]-'A'+1)*p+(a[i]-'A'+1))%mod==ABC)ans++;
	cout<<ans<<endl;
}
int main(){
	INPUT();
	SOLVE();
	return 0;
}

Measured memory_bytes: 256
// Given an array of integers of size ‘n’.
// Our aim is to calculate the maximum sum of ‘k’
// consecutive elements in the array.

/*{{{*/
#include<bits/stdc++.h>
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(), (X).end()
#define rep(I, A, B) for (int I = (A); I <= (B); ++I)
#define repr(I, A, B) for (int I = (A); I >= (B); --I)
#define fors(I, S) for (int I = 0; S[I]; ++I)
#define get_pos(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define mp make_pair
#define pb emplace_back
#define ms0(X) memset((X), 0, sizeof((X)))
#define ms1(X) memset((X), -1, sizeof((X)))
#define len(X) strlen(X)
#define in insert
#define cn count
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef set<int> si;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T, class U> void _W(const pair<T, U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
#define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
#define DEBUG(...)
#endif
int MOD = 1e9 + 7;
/*}}}*/

const int SIZE = 1e6 + 10;
int aa[SIZE];

void solve() {
	int n, m;
	R(n, m);
	pii an;
	rep(i, 0, m - 1) {
		int x;
		string s;
		R(x, s);
		if (s == "WA") {
			if (aa[x] <= 0)aa[x]--;
		} else {
			if (aa[x] <= 0) {
				an.F++, an.S -= aa[x];
				aa[x] = 1;
			}
		}
	}
	W(an);
}

int main() {

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

#define MULTITEST 0
#if MULTITEST
	CASET {
		solve();
	}
#else
	solve();
#endif
	return 0;
}


Measured memory_bytes: 4172
#include<iostream>
using namespace std;int h,w,m=0,D[1401][1401]={},f,i=0;main(){for(cin>>h>>w;i<h*w;i++)cin>>f,m=max(m,D[i/w+1][i%w+1]=(min(D[i/w][i%w],min(D[i/w+1][i%w],D[i/w][i%w+1]))+1)*(!f));cout<<m*m<<endl;}


Measured memory_bytes: 10740
N, L = list(map(int, input().split()))

buff = []
for i in range(N):
    buff.append((L + i+1 - 1, i))


buff = sorted(buff, key=lambda x: abs(x[0]))

ans = 0
for i in range(len(buff)):
    if i > 0:
        ans += buff[i][0]
print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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 long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    cout << max(0, min(b, d) - max(a, c)) << endl;
}

Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define ull unsigned long long
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int INF = 1001001001;
const int MOD=1e9+7;

int main(){
	int n;
	cin>>n;
	int w[n];
	int sum = 0;
	rep(i,n)
    {
		cin>>w[i];
		sum += w[i];
	}
	int ans = sum;
	int tmp = 0;
	rep(j,n)
    {
		tmp += w[j];
		ans = min(ans,(abs(2*tmp - sum)));
	}
	cout<<ans<<endl;
}


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

using namespace std;

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

#define INF INT_MAX;
#define F first
#define S second

ll n,m;
ll w[105];
ll v[105];
ll dp[105][100005];

int main(){
  scanf("%lld %lld",&n,&m);
  for(int i=1;i<=n;i++){
    scanf("%lld %lld",&w[i],&v[i]);
  }

  for(int i=1;i<=n;i++){
    for(int j=1;j<=m;j++){
      if(w[i]<=j){
	dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }else{
	dp[i][j]=dp[i-1][j];
      }
    }
  }

  printf("%lld\n",dp[n][m]);
  
  return 0;
}


Measured memory_bytes: 79360
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = IntStream.range(0, n).map(i -> scanner.nextInt()).toArray();
			int max = 0, count = 0;
			for (int i = 0; i < n; i++) {
				if (a[i] >= max) {
					max = a[i];
					count++;
				}
			}
			System.out.println(count);
		}
	}
}


Measured memory_bytes: 35760
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        h: usize, w: usize,
    }

    if h == 1 || w == 1 {
        println!("1");
    } else {
        println!("{}", ((h * w) as f64 / 2.0).ceil() as usize);
    }
}


Measured memory_bytes: 2648
N = int(input())
S = input()

NR = [-1 for _ in range(N)]
NG = [-1 for _ in range(N)]
NB = [-1 for _ in range(N)]

R_pos = []
G_pos = []
B_pos = []

r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == 'R':
        r += 1
        R_pos.append(i)
    elif S[i] == 'G':
        g += 1
        G_pos.append(i)
    else:
        b += 1
        B_pos.append(i)

    NR[i] = r
    NG[i] = g
    NB[i] = b

ans = 0
for i_ in R_pos:
    for j_ in G_pos:
        if i_ <= j_:
            i = i_
            j = j_
        else:
            i = j_
            j = i_

        ans += NB[N - 1] - NB[j]
        if j + (j - i) < N:
            ans -= NB[j + (j - i)] - NB[j + (j - i) - 1]

    for j_ in B_pos:
        if i_ <= j_:
            i = i_
            j = j_
        else:
            i = j_
            j = i_

        ans += NG[N - 1] - NG[j]
        if j + (j - i) < N:
            ans -= NG[j + (j - i)] - NG[j + (j - i) - 1]

for i_ in G_pos:
    for j_ in B_pos:
        if i_ <= j_:
            i = i_
            j = j_
        else:
            i = j_
            j = i_

        ans += NR[N - 1] - NR[j]
        if j + (j - i) < N:
            ans -= NR[j + (j - i)] - NR[j + (j - i) - 1]

print(ans)


Measured memory_bytes: 69112
#include <iostream>
#include <string>
#include <algorithm>
#define rep(i,b) for(int i=0;i<b;i++)
using namespace std;
int d[200][200];
int const inf=1<<28;
int main(){
    int n;
    cin>>n;
    rep(i,n+1)rep(j,n+1)d[i][j]=inf;
    rep(i,n+1)d[i][i]=0;
    string s[100];
    bool b[1000];
    rep(i,n){
        cin>>s[i];
        if(s[i]=="goto"){
            cin>>s[i];
            s[i].back()=':';
            b[i]=true;
        }else b[i]=false;
    }
    rep(i,n){
        if(b[i]){
            d[i][i+1]=1;
            rep(j,n){
                if(!b[j] && s[i]==s[j]){
                    d[i][j]=0;
                    break;
                }
            }
        }else d[i][i+1]=0;
    }

    rep(i,n+1)rep(j,n+1)rep(k,n+1){
        d[j][k]=min(d[j][k],d[j][i]+d[i][k]);
    }
    cout<<d[0][n]<<endl;
}

Measured memory_bytes: 1296
import java.util.Scanner;

class Main {
	public static void main(String[] $) {
		Scanner sc = new Scanner(System.in);
		long x=sc.nextLong();
		for(int i=1;i<=x;i++) {
			if(i*(i+1)/2>=x) {
				System.out.println(i);
				break;
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w, K; cin >> h >> w >> K;
  vector<string> s(h); rep(i, h) cin >> s[i];
  int ans = inf;
  rep(i, 1<<(h-1)) {
    map<int, int> mp;
    int cur = 0;
    rep(j, h-1) {
      mp[j] = cur;
      if((i>>j)&1) cur++;
    }
    mp[h-1] = cur;
    int n = cur+1;
    vector<int> cnt(n);
    int tmp = 0;
    bool ok = true;
    rep(j, w) rep(k, h) {
      if(s[k][j] == '1') {
        if(++cnt[mp[k]] > K) {
          tmp++;
          cnt = vector<int>(n);
          rep(k, h) {
            if(s[k][j] == '1') {
              if(++cnt[mp[k]] > K) {
                ok = false;
                j = w;
              }
            }
          }
          break;
        }
      }
    }
    if(!ok) continue;
    ans = min(ans, tmp+n-1);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 3644
#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)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string s;
    cin>>s;
    int n=s.size();
    if(n==1){
        cout<<0<<endl;
        return 0;
    }
    string ls,rs;
    int l=0,r=n-1,cnt=0;
    while(1){
        if(s[l]==s[r]){
            ls+=s[l];rs+=s[r];
            ++l,--r;
        }
        else if(s[l]=='x'){
            ls+='x';rs+='x';
            ++l;++cnt;
        }
        else if(s[r]=='x'){
            ls+='x';rs+='x';
            --r;++cnt;
        }
        else{
            cout<<-1<<endl;
            return 0;
        }
        if(l>=r) break;
    }
    if(ls==rs) cout<<cnt<<endl;
    else cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 768
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

use std::rc::Rc;
use std::cell::RefCell;

struct UnionFind {
    par: Rc<RefCell<Vec<usize>>>
}

impl UnionFind {
    fn new(n: usize) -> Self {
        let uf = UnionFind{ par: Rc::new(RefCell::new(vec![0; n])) };
        for i in 0..n {
            uf.par.borrow_mut()[i] = i;
        }
        uf
    }

    fn root(&self, x: usize) -> usize {
        let t = self.par.borrow()[x];
        if  t == x {
            x
        } else {
            self.par.borrow_mut()[x] = self.root(t);
            self.par.borrow()[x]
        }
    }

    fn same(&self, x: usize, y: usize) -> bool {
        self.root(x) == self.root(y)
    }

    fn unite(&self, mut x: usize, mut y: usize) {
        x = self.root(x);
        y = self.root(y);
        if x == y{ return }

        self.par.borrow_mut()[x] = y;
    }
}

fn solve(ps: Vec<usize>, xys: Vec<(usize, usize)>) -> usize {
    use std::collections::HashSet;

    let n = ps.len();
    let mut hs = HashSet::new();
    let uf = UnionFind::new(100001);

    for (x, y) in xys {
        uf.unite(x,y);
    }

    for i in  0..n {
        if ps[i] == i+1 {
            hs.insert(ps[i]);
        }

        if uf.root(ps[i]) == uf.root(i+1) {
            hs.insert(ps[i]);
        }
    }

    hs.len()
}

fn main() {
    let (_n, m) = parse_line!(usize, usize);

    let ps = parse_vec!(usize);

    let xys = (0..m).map(|_| parse_line!(usize, usize)).collect();

    println!("{}", solve(ps, xys));
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![5,3,1,4,2], vec![(1,3), (5,4)]), 2);
    assert_eq!(solve(vec![3,2,1], vec![(1,2), (2,3)]), 3);
    assert_eq!(solve(vec![5, 3, 6, 8, 7, 10, 9, 1, 2, 4], vec![(3,1), (4,1), (5,9), (2,5), (6,5), (3,5), (8,9), (7,9)]), 8);

}


Measured memory_bytes: 8944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  int ans = 0;
  for(int i=1; i<=N; i++){
    int now = i;
    if(now%2==0) continue;
    int cnt = 0;
    for(int j=1;j<=now;j++){
      if(now%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,m; cin >> n >> m;
    vector<vector<ll>> graph(n);
    rep(i,m) {
        ll a,b;cin >> a >> b;
        a--;b--;
        graph[a].emplace_back(b);
        graph[b].emplace_back(a);
    }

    queue<ll> que;
    vector<ll> color(n,INF);
    vector<ll> cnt(2);
    que.emplace(0);
    color[0] = 0;
    cnt[0]++;
    bool bin = true;
    while(!que.empty()) {
        auto p = que.front();que.pop();
        for(auto to : graph[p]){
            if(color[to] == color[p]){
                bin = false;
                break;
            }
            if(color[to] == INF){
                color[to] = color[p] ^ 1;
                cnt[color[to]]++;
                que.emplace(to);
            }
        }
    }

    if(bin){
        cout << cnt[0] * cnt[1] - m << endl;
    }
    else{
        cout << (n * (n-1) / 2) - m << endl;
    }

}

Measured memory_bytes: 7168
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs.shift());
const adj = inputs.map((s) => s.split(' ').map(Number));

class Node {
  constructor(id, list) {
    this.id = id;
    this.list = list || [];
  }
  toString() {
    return [this.id, this.depth !== undefined ? this.depth : -1].join(' ');
  }
}

class Graph {
  constructor() {
    this.queue = [];
    this.map = new Map();
  }
  get(id) {
    return this.map.get(id);
  }
  set(id, list) {
    this.map.set(id, new Node(id, list));
  }
  bfs() {
    const root = graph.map.get(1);
    root.depth = 0;
    this.queue.push(root);
    while(this.queue.length) {
      const node = this.queue.shift();
      node.list.forEach(id => {
        const child = graph.map.get(id);
        if (child.depth !== undefined) {
          return;
        }
        child.depth = node.depth + 1;
        this.queue.push(child);
      })
    }
  }
  print() {
    for (let i = 1; i <= this.map.size; i++) {
      const node = this.map.get(i);
      console.log(node.toString());
    }
  }
}

const graph = new Graph();
adj.forEach(([id, k, ...ck]) => {
  graph.set(id, ck);
});
graph.bfs();
graph.print();



Measured memory_bytes: 16408
# -*- coding: utf-8 -*-
def two_pointers(ary, l, r, split, ary_func, comb_func, comp_func):
    '''
    This function is supposed to be repeatedly called so that 'split' keeps
    renewing, under an assumption that 'split' increases monotonously.
    ('l' and 'r' just specify the region to be searched in 'ary')
    '''

    left = ary_func(ary, l, split)
    right = ary_func(ary, split, r)
    val = comb_func(left, right)

    for i in range(split + 1, r):
        tmp_left = ary_func(ary, l, i)
        tmp_right = ary_func(ary, i, r)
        tmp_val = comb_func(tmp_left, tmp_right)

        if comp_func(val, tmp_val):
            return i - 1, val, left, right
        else:
            left = tmp_left
            right = tmp_right
            val = tmp_val

    else:
        return r - 1, val, left, right


if __name__ == '__main__':
    '''
    an example of using this function
    At-Coder ABC 102 - D
    '''

    from operator import add
    from itertools import accumulate

    n = int(input())
    a = [int(_) for _ in input().split()]
    cul_ary = [0] + list(accumulate(a, add))

    l_split = 1
    r_split = 3
    griefs = []
    for i in range(2, n - 1):
        # left
        l_split, l_diff, p, q = two_pointers(cul_ary,
                                             0,
                                             i,
                                             l_split,
                                             lambda ary, l, r: ary[r] - ary[l],
                                             lambda left, right: abs(left - right),
                                             lambda val1, val2: True if val1 < val2 else False)

        # right
        r_split, r_diff, r, s = two_pointers(cul_ary,
                                             i,
                                             n,
                                             r_split,
                                             lambda ary, l, r: ary[r] - ary[l],
                                             lambda left, right: abs(left - right),
                                             lambda val1, val2: True if val1 < val2 else False)

        griefs.append(max(p, q, r, s) - min(p, q, r, s))

    print(min(griefs))


Measured memory_bytes: 28820
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n; cin>>n;
  int z1=-2000000000,z2=2000000000,w1=z1,w2=z2;
  for(int i=0; i<n; ++i){
    int x,y; cin>>x>>y;
    z1=max(z1,x+y);
    z2=min(z2,x+y);
    w1=max(w1,x-y);
    w2=min(w2,x-y);
  }
  cout<<max(z1-z2,w1-w2);
  return 0;
}


Measured memory_bytes: 3608
n, x = map(int, input().split())
a = list(map(int, input().split()))
if a[0] > x:
    pre = x
    num = a[0] - x
else:
    pre = a[0]
    num = 0

for i in range(1, n):
    if a[i] + pre > x:
        num += a[i] + pre - x
        pre = a[i] - (a[i] + pre - x)
    else:
        pre = a[i]

print(num)

Measured memory_bytes: 14052
/*  ex3_3
    Graku   */
#include <stdio.h>
#include <math.h>

int main(void) {
    int num, base_size; //declaration
    scanf("%d %d", &num, &base_size);

    /*
    write num in base_size base, and divide num by base_size.
    this operation mean remove ones place.
    */
    int count = 0; //initialized
    do {
        count++;
    } while (num /= base_size);

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


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;


int main() {
	int q;
	cin >> q;
	long long a, b, m, ret;
	for (int i = 0; i < q; i++) {
		cin >> a >> b;
		if (a == b) {
			cout << 2 * (a - 1) << endl;
		}
		else {
			m = ceil(sqrt(a*b)) - 1;
			ret = 2 * m - 1;
			if (m*(m + 1) >= a * b && min(a,b) <= m) ret--;
			cout << ret << endl;
		}
	}


	return 0;
}


Measured memory_bytes: 256