akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

ll kai[200001];
ll mokai[200001];

ll mod_pow (ll x, ll y) {
    ll ret = 1;
    while (y) {
        if (y&1) ret = ret*x%MOD;
        x = x*x%MOD;
        y /= 2;
    }
    return ret;
}

void init (int _n) {
    kai[0] = 1;
    for (int i = 1; i <= _n; i++) kai[i] = kai[i-1]*i%MOD;
    for (int i = 0; i <= _n; i++) mokai[i] = mod_pow(kai[i],MOD-2);
}

ll conb (ll x, ll y) {
    ll z = x-y;
    ll ret = kai[x]*mokai[y]%MOD;
    ret = ret*mokai[z]%MOD;
    return ret;
}

ll n, a, b, c;
ll powa[100001], powb[100001];

int main() {
    cin >> n >> a >>  b >> c;
    ll A = a * mod_pow(100, MOD-2) % MOD, B = b * mod_pow(100, MOD-2) % MOD;
    ll C = 100 * mod_pow(100-c, MOD-2) % MOD;
    a = a * mod_pow(100-c, MOD-2) % MOD;
    b = b * mod_pow(100-c, MOD-2) % MOD;
    init(n*2);
    powa[0] = 1;
    powb[0] = 1;
    for (int i = 1; i <= n; i++) {
        powa[i] = powa[i-1] * a % MOD;
        powb[i] = powb[i-1] * b % MOD;
    }
    ll ans = 0;
    rep(i,n) {
        ll tmp = conb(n-1+i, i);
        tmp = tmp * powb[n] % MOD;
        tmp = tmp * powa[i] % MOD;
        //ll cnt = (n + i + mod_pow(C, MOD-2)) % MOD;
        //tmp = tmp * cnt % MOD;
        tmp = tmp * (n+i) % MOD;
        tmp = tmp * C % MOD;
        //tmp = tmp * mod_pow(B, MOD-2) % MOD;
        ans = (ans + tmp) % MOD;
    }
    rep(i,n) {
        ll tmp = conb(n-1+i, i);
        tmp = tmp * powa[n] % MOD;
        tmp = tmp * powb[i] % MOD;
        //ll cnt = (n-1 + i + mod_pow(B, MOD-2)) % MOD;
        //tmp = tmp * cnt % MOD;
        tmp = tmp * (n+i) % MOD;
        tmp = tmp * C % MOD;
        //tmp = tmp * mod_pow(A, MOD-2) % MOD;
        ans = (ans + tmp) % MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
class Fenwick:
    def __init__(self, size):
        self.arr = [0]*size
    
    def update(self, i, val):
        while i < len(self.arr): self.arr[i] += val; i |= i+1
    
    def getsum(self, i):
        res = 0
        while i >= 0: res+= self.arr[i]; i = (i&(i+1))-1
        return res

def paramin(F, l, r):
    while l <= r:
        mid = (l+r)//2
        if F(mid): ans, r = mid, mid-1
        else: l = mid+1
    return ans

from itertools import accumulate
def medleq(x):
    M = [(y<=x)*2-1 for y in L]
    MA = list(accumulate(M))
    cnt = sum(y>0 for y in MA)
    F = Fenwick(2*n+3)
    for y in MA:
        c = y+n+1
        cnt+= F.getsum(c-1)
        F.update(c, 1)
    return cnt >= target

n = int(input())
L = list(map(int,input().split()))
tot = n + n*(n-1)//2
target = tot//2 + 1
print(paramin(medleq, min(L), max(L)))

Measured memory_bytes: 121032
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <math.h>
#include <deque>
#include <queue>
#include <map>
#include <iterator>
#include <set>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e) { std::cout << e << std::endl; }
template<typename T> void view(const std::vector<T>& v) { for (const auto& e : v) { std::cout << e << " "; } std::cout << std::endl; }
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v : vv) { view(v); } }
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; }

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

const int MOD = 1e9 + 7;
const ll MAX = 200000;
ll inv[MAX], fac[MAX], finv[MAX];

void settable() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i <= MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll choose(ll n, ll k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll n, ll k) {
    ll rtn = 1;
    while (k > 0) {
        if (k & 1) rtn = rtn * n % MOD;
        n = n * n % MOD;
        k = k >> 1;
    }
    return rtn;
}

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

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

    settable();

	int n, m;
	cin >> n >> m;
    auto mp = prime_factor(m);

    mint ans = 1;
    for (auto e : mp) {
        ans *= choose(n+e.second-1, e.second);
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 4992
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String s1 = sc.nextLine();
		String s2 = sc.nextLine();
		String[] S1 = s1.split(" "); 
		String[] S2 = s2.split(" "); 
		sc.close();
		int max = 0;
		
		for(int i = 0; i < N; i++) {
			if(sum(i,S1,S2) > max) {
				max = sum(i,S1,S2);
			}
		}
		System.out.println(max);
	}
	public static int sum(int down, String[] S1, String[] S2) {
		int sum = 0;
		for( int i = 0; i <= down; i++ ) {
			sum += Integer.parseInt(S1[i]); 
		}
		for(int i = down; i < S2.length; i++){
			sum += Integer.parseInt(S2[i]);;
		}
		return sum;
	}
}

Measured memory_bytes: 22868
from collections import Counter

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

c = Counter(A)
pair = []
# print(c)
for x, cnt in c.items():
    pair += [x] * (cnt//2)

# print(pair)
pair.sort()

ans = 0
if len(pair) >= 2:
    ans = pair[-1] * pair[-2]
print(ans)

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

const int mxN = 110, mxW = 1e5 + 5;
int N, W, v[mxN], w[mxN];
ll dp[mxN][mxW];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> N >> W;
	for (int i = 1; i <= N; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = dp[i - 1][j];
			if (j < w[i]) {
				continue;
			}
			dp[i][j] = max(dp[i][j], v[i] + dp[i - 1][j - w[i]]);
		}
	}
	cout << dp[N][W];
	
	return 0;
}


Measured memory_bytes: 81728
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b; cin >> a >> b;
    vector<bool> v(5, false);
    v[a] = true;
    v[b] = true;
    repr(i, 1, 4) if (v[i] == false) {
        cout << i << endl;
        return 0;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#define int long long
using namespace std;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000

int MOD=1000000007;
int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}
signed main() {
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k%2==0)cout<<a-b<<endl;
  else cout<<b-a<<endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = n; i <= 2 * n; i++) {
    if (i % 2 != 0) {
      continue;
    } else {
      if (i % n == 0) {
        cout << i << endl;
        return 0;
      }
    }
  }
}


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

using namespace std;

// kmp ??????????????????????¨????
vector<int> makeTable(const string& s) {
    int n = s.size();
    vector<int> ret(n+1);
    ret[0] = -1;
    int j = -1;
    for (int i = 0; i < n; i++) {
        while (j >= 0 && s[i] != s[j]) j = ret[j];
        ret[i+1] = ++j;
    }
    return ret;
}

// str ????????? word ??¨?????????????????´????????????????????????
// ret ??????????????????????´? el ???, ???str[el] ????????????????????? word ??¨?????´??????????????¨?????????
vector<int> kmp(const string& str, const string& word) {
    vector<int> table = makeTable(word), ret;
    int m = 0, i = 0, n = str.size();
    while (m+i < n) {
        if (word[i] == str[m+i]) {
            if (++i == (int)(word.size())) {
                ret.push_back(m);
                m = m+i-table[i];
                i = table[i];
            }
        } else {
            m = m+i-table[i];
            if (i > 0) i = table[i];
        }
    }
    return ret;
}


int main() {
        string text, pattern;
        cin >> text >> pattern;
        vector<int> list = kmp(text, pattern);
        vector<int>::iterator it = list.begin();
        while (it != list.end()) {
                cout << *it << endl;
                it++;
        }
        return 0;
}

Measured memory_bytes: 8436
#include<bits/stdc++.h>
  using namespace std;
  int main()
  {
      string s;
      cin>>s;
      for(int i=0;i<s.length();i++)
      {
         if(s[i]!=',')
         {
             cout<<s[i];
         }
         else
         {
             cout<<" ";
         }
    }
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var sum int
	for i := 1; i <= n; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		sum += i
	}
	fmt.Println(sum)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
	ll n;
	cin>>n;
	string s[n];
	rp(i,0,n)cin>>s[i];
	sort(s,s+n);
	map<string,ll> mp;
	rp(i,0,n)mp[s[i]]++;
	ll m=0;
	for(auto i=mp.begin();i!=mp.end();i++){
		m=max(m,i->second);
	}
	for(auto i=mp.begin();i!=mp.end();i++){
		if(m==i->second)
		cout<<i->first<<endl;
	}
}


Measured memory_bytes: 26752
#include <iostream>
#include <cstdio>

using namespace std;

int x, y;

int main()
{
    scanf("%d%d", &x, &y);

    if(x + y > 16) {printf(":("); return 0;}
    if(x > 8 || y > 8) {printf(":("); return 0;}

    printf("Yay!");

    return 0;
}


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

using namespace std;

int binary_search(vector<int>& v, int istart, int iend, int value) {
  int n = v.size();

  if (istart > iend)
    return 0;

  int imid = istart + (iend - istart) / 2;
  if (v[imid] > value) {
    return binary_search(v, istart, imid - 1, value);
  } else if (v[imid] < value) {
    return binary_search(v, imid + 1, iend, value);
  } else {
    return 1;
  }
  return -1;
}

int main() {
  ios::sync_with_stdio(false);

  int n;
  cin >> n;

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

  int num_query;
  cin >> num_query;

  int query = 0;
  for (int i = 0; i < num_query; i++) {
    cin >> query;

    cout << binary_search(v, 0, n - 1, query) << endl;
  }
}



Measured memory_bytes: 3340
#abc173
n = int(input())
ln ={'AC': 0,'WA': 0,'TLE': 0,'RE': 0}  #ln[0] = AC, 1= WA, 2 =TLE, 3 =RE
for i in range(n):
    s = input()
    ln[s] += 1
for i,j in ln.items():
    print(i +' x ' + str(j))
    

Measured memory_bytes: 9040
#include<iostream>
#include<map>
#include<numeric>
#include<set>
#include<vector>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

struct union_find {
  std::vector<int> par, rank;
  
  explicit union_find(int n): par(n), rank(n,0) {
    std::iota(par.begin(), par.end(), 0);
  }
  
  int find(int x) {
    if(par[x] == 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(rank[x] < rank[y]) par[x] = y;
    else {
      par[y] = x;
      if(rank[x] == rank[y]) ++rank[x];
    }
  }
};

int main() {
  int N; std::cin >> N;
  std::set<int> sx, sy;
  std::vector<std::pair<int,int>> xy;
  for(int i = 0; i < N; ++i) {
    int x, y; std::cin >> x >> y;
    xy.emplace_back(x, y);
    sx.insert(x);
    sy.insert(y);
  }
  std::map<int,int> mx, my;
  int n = 0;
  for(auto x: sx) mx[x] = n++;
  for(auto y: sy) my[y] = n++;
  
  union_find uf(n);
  for(auto const& p: xy) uf.unite(mx[p.first], my[p.second]);
  
  std::map<int,int> cmpx, cmpy;
  for(int i = 0; i < sx.size(); ++i) ++cmpx[uf.find(i)];
  for(int i = sx.size(); i < n; ++i) ++cmpy[uf.find(i)];
  int64_t ans = -N;
  for(auto const& p: cmpx) ans += (int64_t)p.second * cmpy[p.first];
  fin(ans);
  return 0;
}


Measured memory_bytes: 11256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

#define v vector
#define ALL(x) x.begin(),x.end()
#define rALL(x) x.rbegin(),x.rend()
#define endl '\n'
#define DEBUG

template<typename T> void DBG(const char* name, T&& H) {
	cerr << name << " = " << H << ')' << endl;
}

template<typename T, typename... Args> void DBG(const char* names, T&& H, Args&&... args) {
	const char* NEXT = strchr(names+1, ',');
	cerr.write(names, NEXT-names) << " = " << H << " |";
	DBG(NEXT+1, args...);
}

#ifdef DEBUG
	#define dbg(...) cerr << __FUNCTION__ << ' ' <<__LINE__ << " : (", DBG(#__VA_ARGS__, __VA_ARGS__)
#else
	#define dbg(...)
#endif

using ll = long long;
using ld = long double;

const ll mod = 1e9 + 7;
const ld PI = acos(-1.0);
const ll maxN = 1e6+1;

void Solve() {
	vector<ll> fact(maxN, 0);
	for(ll i = 2; i <= maxN; i *= 2) {
		for(ll j = i; j <= maxN; j += i) {
			fact[j] ++;
		}
	}
	for(ll i = 1; i <= maxN; i ++) {
		fact[i] += fact[i-1];
	}
	ll n;
	cin >> n;
	vector<ll> a(n+1);
	set<ll> dif;
	for(ll i = 1; i <= n; i ++) {
		char ch;
		cin >> ch;
		a[i] = ch-'1';
		dif.insert(a[i]);
	}
	if(dif.size() == 1) {
		cout << 0 << endl;
		return;
	}
	if(dif.size() == 3) {
		for(ll i = 1; i <= n; i ++) {
			if(a[i] == 2) a[i] = 0;
		}
	}
	if(dif.size() == 2) {
		if((*dif.begin()) == 1) {
			for(ll i = 1; i <= n; i ++) {
				if(a[i] == 2) a[i] = 0;
			}
		}
	}
	ll ans = 0;
	for(ll i = 1; i <= n; i ++) {
		ll parity = fact[n-1]-fact[i-1]-fact[n-i];
		if(parity == 0) ans ^= a[i];
	}
	cout << ans << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int tt = 1;
	while(tt --) {
		Solve();
	}
	
	return 0;
}

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

using ll = long long int;
using bigint = int64_t;

#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " = " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int MOD = 1000000007;

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

void solve() {
  ll n, m;
  cin >> n >> m;
  ll ans = ((((n * (n - 1)) / 2) + ((m * (m - 1)) / 2)));
  cout << ans << endl;

}

int main() {
  IOS;
  //io_set();
  ll tt = 1;
  //cin >> tt;
  while (tt--) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 256
//090 2018/03/11
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int a , b; cin >> a >> b;
	int cnt=0;
	for(int i=a;i<=b;++i){
		int p=i/pow(10,4);int q=i%10;
		int x=(int)(i/pow(10,3))%10;int y=(i/10)%10;
		if( p==q && x==y ) ++cnt;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  	int n,d;
  	cin >> n;
  	if(n%2!=0)
    {
      	d=(n/2)+1;
    	cout << fixed << setprecision(6) << d/double(n);
    }
  	else
      	cout << 0.500000;
  	return 0;
}

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

using namespace std;

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;

	int data = 0;
	//auto correct_person_list = vector<int>(Q);
	auto nN = vector<int>(N);
	for (int i = 0; i < Q; i++) {
		cin >> data;
		//correct_person_list.at(i) = data;

		nN.at(data-1)++;
	}

	for (int j = 0; j < N; j++) {
		if (nN.at(j) <= Q - K)	cout << "No" << endl;
		else					cout << "Yes" << endl;
	}

	return 0;
}


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

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

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

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

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

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

int main() {
    int n;
    cin >> n;
    double a[n] = {};
    double sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    //cout << sum << endl;
    sum /= (double)n;
    //cout << sum << endl;;
    double sa = 99999;
    int ans = 0;
    rep(i,n){
        if(abs(sum-a[i])<sa){
            ans = i;
            sa = abs(sum-a[i]);
        }
    }


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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
using namespace std;
const int N=2e5+5;
int n,d,f[N][2];
char c[N];
int main(){
	scanf("%s",c+1);n=strlen(c+1);
	f[1][0]=1;
	f[1][1]=-N;
	f[2][0]=c[2]==c[1]?-N:2;
	f[2][1]=1;
	fo(i,3,n){
		f[i][0]=max((c[i]==c[i-1]?-N:f[i-1][0]),f[i-1][1])+1;
		f[i][1]=max(f[i-2][0],(i>=4&&c[i]==c[i-2]&&c[i-1]==c[i-3]?-N:f[i-2][1]))+1;
	}
	cout<<max(f[n][0],f[n][1]);
}

Measured memory_bytes: 2048
//#include <bits/stdc++.h>
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
#include <fstream>   // ifstream, ofstream
#include <sstream>   // istringstream
using namespace std;
using ll = long long;
const int mod = 1000000007;

ll gcd(ll a, ll b){return b ? gcd(b,a%b) : a;};//最大公約数
ll lcm(ll a, ll b){return a*b/gcd(a,b);};//最小公倍数
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
typedef pair<string,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
//ll a[100000];
//ll dom[100001];
map<string,int> memo;
string c[10] = {"a","b","c","d","e","f","g","h","i","j"};

bool sd(string s, int n, int p){
  if(memo[s]!=0) return false;
  if(s.length()==n){
    cout<<s<<endl;
    return true;
  }
  for(int i=0;i<=p;i++){
    if(i!=p) sd(s+c[i],n,p);
    else sd(s+c[i],n,p+1);
  }
  return 0; 
}
int main(){
  int n;
  cin>>n;
  if(n==1){
    cout<<"a";
  }
  else if(n==2){
    cout<<"aa"<<endl<<"ab";
  }
  else {
    sd("a",n,1);
  }
  return 0;
}

Measured memory_bytes: 17408
input_n = input()
N = int(input_n)

# S_list = [input() for i in range(N)]
check_list = ['AC', 'WA', 'TLE', 'RE']
count_list = [0, 0, 0, 0]

for i in range(N):
    flag = 0
    S = input()
    while flag<4:
        if S==check_list[flag]:
            count_list[flag] += 1
            break;
        else:
            flag += 1

print('AC  x  '+ str(count_list[0]))
print('WA  x  '+ str(count_list[1]))
print('TLE  x  '+ str(count_list[2]))
print('RE  x  '+ str(count_list[3]))

Measured memory_bytes: 9220
a, b =  map(int, input().split())
# 総口数は n(a-1)+1
# 求めたいのは n(a-1)+1 >= b を満たす最小の自然数n
# n >= (b-1)/(a-1)
# n = ((b-1)+(a-1)-1)/(a-1)
# 	= (a+b-3)//(a-1)
print((a+b-3)//(a-1))

Measured memory_bytes: 2940
def main():
  n,m,k = map(int, input().split())
  f = [1]
  p = 998244353
  for i in range(1, n):
    f.append(f[-1] * i % p)

  ans = 0
  def nCk(n,k):
    return f[n] * pow(f[n-k], p-2, p) * pow(f[k], p-2, p) % p

  for i in range(k+1):
    ans += (m * nCk(n-1, i) * pow(m-1, n-1-i, p)) % p
  print(ans % p)

if __name__ == '__main__':
  main()

Measured memory_bytes: 16848
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

vector <int> mp[maxn],a1,a2;
int n,m,V[maxn];

inline void dfs1(int u)
{
	V[u]=1; a1.pb(u);
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i]; if(V[v]) continue;
		dfs1(v); break;
	}
}

inline void dfs2(int u)
{
	V[u]=1; a2.pb(u);
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i]; if(V[v]) continue;
		dfs2(v); break;
	}
}

int main()
{
	n=read(); m=read();
	rep(i,1,m)
	{
		int u=read(),v=read();
		mp[u].pb(v); mp[v].pb(u);
	}
	dfs1(1); dfs2(1); cout<<a1.size()+a2.size()-1<<endl;
	for(int i=a1.size()-1;i>=0;i--) printf("%d ",a1[i]);
	for(int i=1;i<a2.size();i++) printf("%d ",a2[i]);
	return 0;
}

Measured memory_bytes: 31224
/**
 * Title:
 * Url:
 */
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

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

    return 0;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

void solve() {
	int a[5];
	for(int i=0;i<5;i++) in(a[i]);
	for(int i=0;i<5;i++) if(a[i] == 0) { cout<<i+1<<en; return;}
}

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


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

int main() {
  string str;
  cin >> str;
  
  if(str == "Rainy")
    cout << "Sunny" << endl;
  else if(str == "Sunny")
    cout << "Cloudy" << endl;
  else if(str == "Cloudy")
    cout << "Rainy" << endl;
  return 0;
}
  

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.util.Queue;
import java.io.BufferedReader;
import java.util.LinkedList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
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);
        DEvenRelation solver = new DEvenRelation();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEvenRelation {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<node> a[] = new ArrayList[n + 1];
            boolean ans[] = new boolean[n + 1];
            boolean visited[] = new boolean[n + 1];
            for (int i = 0; i <= n; i++) a[i] = new ArrayList<node>();
            for (int i = 0; i < n - 1; i++) {
                int u = in.nextInt();
                int v = in.nextInt();
                int w = in.nextInt();
                a[u].add(new node(u, v, w));
                a[v].add(new node(v, u, w));
            }
            Queue<Integer> q = new LinkedList<Integer>();
            q.add(1);
            while (q.size() > 0) {
                int r = q.poll();
                if (visited[r] == true) {
                    continue;
                }
                visited[r] = true;
                for (node x : a[r]) {
                    q.add(x.v);
                    if (x.w % 2 == 0) {
                        ans[x.v] = ans[r];
                    } else {
                        ans[x.v] = !ans[r];
                    }
                }
            }
            for (int i = 1; i <= n; i++) out.println(ans[i] ? 1 : 0);
        }

        class node {
            int u;
            int w;
            int v;

            node(int u, int v, int w) {
                this.u = u;
                this.v = v;
                this.w = w;
            }

        }

    }

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

    }
}



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

int main(){
  int N,Q;
  cin >> N >> Q;
  string s;
  cin >> s;

  bool aca[N];
  bool acc[N];
  fill(aca,aca+N,false);
  fill(acc,acc+N,false);
  for(int i=0;i<N-1;i++){
    if(s[i]=='A' && s[i+1] == 'C'){
      aca[i] = true;
      acc[i+1] = true;
    }
  }

  int suma[N+1];
  int sumc[N+1];
  suma[0] = 0;
  sumc[0] = 0;
  for(int i=1;i<=N;i++){
    suma[i] = suma[i-1] + aca[i-1];
    sumc[i] = sumc[i-1] + acc[i-1];
  }

  int l[Q],r[Q];
  for(int i=0;i<Q;i++){
    cin >> l[i] >> r[i];
    l[i]--;
  }
  for(int i=0;i<Q;i++){
    cout << sumc[r[i]] - suma[l[i]] << endl;
  }
  return 0;
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)

typedef long long ll;

int main() {
    int N, X, T;
    int ans;
    cin >> N >> X >> T;
    ans = (N + X - 1) / X;
    ans *= T;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3584
object Main extends App {

  val Array(w,h,x,y) = scala.io.StdIn.readLine().split(" ").map(_.toLong)

  def solve() = {
    val s = w.toDouble * h / 2
    val hasMultiWay = if(x == w.toDouble/2 && y == h.toDouble/2) 1 else 0
    s"$s $hasMultiWay"
  }


  println(solve)

}


Measured memory_bytes: 27448
import sys
input = lambda : sys.stdin.readline().strip()

from collections import deque

class Convex_Hull_Trick():
    def __init__(self):
        self.que = deque()

    @staticmethod
    def check(f1, f2, f3):
        return (f2[0] - f1[0]) * (f3[1] - f2[1]) >= (f2[1] - f1[1]) * (f3[0] - f2[0])

    @staticmethod
    def f(f1, x):
        return f1[0]*x + f1[1]

    def add_line(self, a, b):
        fi = (a, b)
        while len(self.que) >= 2 and self.check(self.que[-2], self.que[-1], fi):
            self.que.pop()
        self.que.append(fi)

    def query(self, x):
        while len(self.que) >= 2 and self.f(self.que[0], x) >= self.f(self.que[1], x):
            self.que.popleft()
        return self.f(self.que[0], x)

n,c = map(int, input().split())
h = list(map(int, input().split()))

CHT = Convex_Hull_Trick()
CHT.add_line(-2*h[0], h[0]**2)

DP = [0]*n

for i in range(1, n):
    min_cost = CHT.query(h[i])
    DP[i] = min_cost + h[i]*h[i] + c
    CHT.add_line(-2*h[i], h[i]**2+DP[i])

print(DP[-1])

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

using namespace std;

#define int long long
#define forinc(a,b,c) for(int a=b, _c=c; a<=_c; ++a)
#define fordec(a,b,c) for(int a=b, _c=c; a>=_c; --a)
#define forv(a,b) for(auto &a:b)
#define forb(a,b) for(int a=b._Find_first(); a<b.size(); a=b._Find_next(a))

#define ii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define rall(a) begin(a),end(a)
#define reset(f,x) memset(f,x,sizeof(f))
#define fasty ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define gg exit(0);

#define bit(x,i) (x>>(i-1)&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))

typedef int64_t ll;
typedef unsigned long long ull;

const int N=3005;
const int mod=998244353;
int a,b,c,d;
int f[N][N];

void add(int &x,int y){
    x=(x+y);
    if(x>=mod) x-=mod;
}
int mul(int x,int y){
    x=(1ll*x*y)%mod;
}

int32_t main(){
    fasty;
    cin>>a>>b>>c>>d;
    f[a][b]=1;
    forinc(i,a,c){
        forinc(j,b,d){
            if(i!=a || j!=b) f[i][j]=(i*f[i][j-1]%mod + j*f[i-1][j]%mod - (i-1)*(j-1)%mod*f[i-1][j-1]%mod + mod)%mod;
        }
    }
    cout<<f[c][d]<<'\n';
}


Measured memory_bytes: 73964
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        new Program().Solve();
    }

    void Solve()
    {
        Scanner cin = new Scanner();
        int p = cin.NextInt();
        int q = cin.NextInt();
        int r = cin.NextInt();

        int a = p + q;
        int b = q + r;
        int c = r + p;

        int min = Math.Min(a, Math.Min(b, c));
        Console.WriteLine(min);
 
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string Next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public char[] ArrayChar()
    {
        return Next().ToCharArray();
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextInt() + add;
        }
        return Array;
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextLong() + add;
        }
        return Array;
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = NextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int a, b;
    int[] count;
    int i, n;

    count = new int[100];
    for(;sc.hasNext();){
      for(i = 0;i < 100;i++)count[i] = 0;
      n = 0;
      for(;;){
        a = sc.nextInt();
        b = sc.nextInt();
        if(a == 0 && b == 0)break;
        count[a - 1]++; count[b - 1]++;
      }

      for(i = 0;i < 2;i++)if(count[i] % 2 == 0)n = 1;
      for(i = 2;i < 100;i++)if(count[i] % 2 != 0)n = 1;

      if(n == 1)out.println("NG");
      else out.println("OK");
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 24376
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    string w;
    cin >> w;
    if (w.length() % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    vector<int> d(26,0);
    rep(i,w.length()) {
        d[w[i]-'a']++;
    }
    rep(i,26) {
        if (d[i] % 2 == 1)
        {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
            
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

n,k = list(map(int,input().split()))
r,s,p = list(map(int,input().split()))
t = input()

#貪欲
ret = 0
cur_my_hand = []
ca = cur_my_hand.append
for i,v in enumerate(t):
    if i < k:
        if v == "r":
            ret+=p
            ca("p")
        elif v == "s":
            ret+=r
            ca("r")
        elif v == "p":
            ret+=s
            ca("s")
    else:
        if v == "r" and cur_my_hand[i-k]!="p":
            ret+=p
            ca("p")
        elif v == "s" and cur_my_hand[i-k]!="r":
            ret+=r
            ca("r")
        elif v == "p" and cur_my_hand[i-k]!="s":
            ret+=s
            ca("s")
        else:
            ca("o")
print(ret)

Measured memory_bytes: 4120
#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();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;


const int nmax=5002;
int sum[nmax][nmax];

int x[nmax],y[nmax];
vi xx,yy;

int main(void){
	int n,m;
	scanf("%d %d",&n,&m);
	rep(i,n){
		scanf("%d %d",&x[i],&y[i]);
		xx.pb(x[i]);
		yy.pb(y[i]);
	}

	sort(xx.begin(),xx.end());
	xx.erase(unique(xx.begin(),xx.end()),xx.end());

	sort(yy.begin(),yy.end());
	yy.erase(unique(yy.begin(),yy.end()),yy.end());

	rep(i,n){
		int fx=lower_bound(all((xx)),x[i])-xx.begin();
		int fy=lower_bound(all((yy)),y[i])-yy.begin();
		sum[fx+1][fy+1]++;
	}

	rep(i,xx.size())rep(j,yy.size()) sum[i+1][j+1]=(sum[i+1][j+1]+sum[i+1][j]+sum[i][j+1]-sum[i][j]);

	rep(i,m){
		int x1,x2,y1,y2;
		scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
		int lx=lower_bound(all((xx)),x1)-xx.begin();
		int rx=lower_bound(all((xx)),x2+1)-xx.begin();
		int ly=lower_bound(all((yy)),y1)-yy.begin();
		int ry=lower_bound(all((yy)),y2+1)-yy.begin();
		printf("%d\n",sum[rx][ry]-sum[lx][ry]-sum[rx][ly]+sum[lx][ly]);
	}
	return 0;
}

Measured memory_bytes: 99008
using System;
using System.Collections.Generic;
using System.Linq;

public class ABC0123_A2v4 {
    private static void OutputAnswer(string text) => Console.WriteLine(text);

    private static void Main(string[] args) {
        var inputs = ReadStringList(5);
        ConvertInputs(inputs);
    }

    private static List<string> ReadStringList(int numberOfLines) {
        var stringList = new List<string>();

        for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++) {
            stringList.Add(Console.ReadLine().Trim());
        }

        return stringList;
    }

    private static void ConvertInputs(List<string> inputs) {
        var cookingTime = inputs
            .Select(s => int.Parse(s))
            .OrderByDescending(n => (n + 9) % 10)
            .ToList();

        Solve(cookingTime);
    }

    private static void Solve(List<int> cookingTime) {
        var totalWaitingTime = 0;

        for (int i = 0; i < cookingTime.Count - 1; i++) {
            totalWaitingTime += CalculateWaitingTime(cookingTime[i]);
        }
        totalWaitingTime += cookingTime[cookingTime.Count - 1];

        OutputAnswer(totalWaitingTime.ToString());
    }

    private static int CalculateWaitingTime(int cookingTime) => cookingTime % 10 == 0 ? cookingTime : cookingTime + 10 - (cookingTime % 10);
}

Measured memory_bytes: 13396
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include <unordered_map>
#include<map>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n; ++i)
#define ALL(a) (a).begin(),(a).end()
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)

int main(){
    string s;
    cin >> s;

    string back = "";
    back += s[0];
    string front = "";
    ll ans = 1;
    for(int i = 1; i < s.size(); ++i){
        front += s[i];
        if(front != back){
            // cout << back << " & " << front << endl;
            ans++;
            back = front;
            front = "";
        }
    }
    cout << ans  << endl;
} 

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

typedef long long ll;

ll sum(ll s){
  ll ret=0;
  while(s){
  	ret+=(s%10);
    s/=10;
  }
  return ret;
}

int main(){
  ll n;
  cin>>n;
  cout<<(n%sum(n)==0?"Yes":"No")<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
from math import gcd,ceil,sqrt
from itertools import permutations as prm,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)

t=1

def sieve(MAXN): 

    spf[1] = 1
    for i in range(2, MAXN): 

        spf[i] = i 

    for i in range(4, MAXN, 2): 
        spf[i] = 2
  
    for i in range(3, ceil(sqrt(MAXN))): 

        if (spf[i] == i): 

            for j in range(i * i, MAXN, i):  

                if (spf[j] == j): 
                    spf[j] = i 
  

def fact(x): 
    ret = {}
    while (x != 1): 
        if spf[x] not in ret:
        	ret[spf[x]]=1
        else:
        	ret[spf[x]]+=1	
        x = x // spf[x] 
  
    return ret		


while t>0:
	t-=1
	n=fi()
	spf=[0]*(n+1)
	sieve(n+1)
	ans=0
	for i in range(1,n):
		r=fact(n-i)
		o=0
		p=1
		for ii in r:
			p*=(r[ii]+1)
	
		ans+=p

	print(ans)		





Measured memory_bytes: 82340
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int INF=(1e9);
int n,m,dp[1010][1<<12],ans;
int a[1010],b[1010],c[1010];
void update(int &x,int y) {
	x=min(x,y);
}
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	read(m);
	int tmp,x;
	for (int i=1;i<=m;i++) {
		read(a[i]); read(b[i]);
		tmp=0;
		for (int j=1;j<=b[i];j++) read(x),tmp+=1<<(x-1);
		c[i]=tmp;
	}
	for (int i=0;i<=m;i++)
	for (int t=0;t<(1<<n);t++) dp[i][t]=INF;
	dp[0][0]=0;
	for (int i=0;i<m;i++) {
		for (int t=0;t<(1<<n);t++) {
			update(dp[i+1][t],dp[i][t]);
			update(dp[i+1][t|c[i+1]],dp[i][t]+a[i+1]);
		}
	}
	ans=dp[m][(1<<n)-1];
	if (ans==INF) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 16256