akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = sc.nextLong();
    long b = sc.nextLong();
if (a+b== 0){
    System.out.println(0);

  return;
}
    long ans = 0;
    long mod = 0;
    ans = n / (a+b);
    mod = n % (a+b);
    ans=ans * a;
    if (mod <= a) {
    	ans+=mod;
    } else{
    	ans+=a;
    }
    System.out.println(ans);
  }
}




Measured memory_bytes: 22868
n, m = map(int, input().split())
X = list(map(int, input().split()))

X =sorted(X)

dis = [X[i+1]-X[i] for i in range(len(X)-1)]
dis = sorted(dis)

ans = 0
for i in range(len(dis)-n+1):
    ans = ans + dis[i]
    
print(ans)

Measured memory_bytes: 13968
num_sunuke, num_okashi_kind = map(int, input().split())
sunuke = [0] * (num_sunuke+1)

ans = 0
for idx_okashi_kind in range(1, num_okashi_kind+1) :
    num_have_okashi = int(input())
    idx_sunuke_with_okashi = map(int,input().split())

    for i in range(1, num_have_okashi+1) :
        for j in idx_sunuke_with_okashi :
            sunuke[j] = 1

for s in sunuke :
    if s == 1 :
        ans = ans + 1

print(num_sunuke - ans)


Measured memory_bytes: 9204
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;

class UnionFind {
public:
    vector <int> par;
    vector <int> siz;

    UnionFind(int sz_): par(sz_), siz(sz_, 1LL) {
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(int sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (int i = 0; i < sz_; ++i) par[i] = i;
    }

    int root(int x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

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

    int size(int x) {
        return siz[root(x)];
    }
};

signed main() {
  int N, M; 
  cin >> N >> M;

  UnionFind uf(N);
  REP(i, M){
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }

  set<int> s;
  REP(i, N) s.insert(uf.root(i));

  cout << s.size() << endl;

  return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
long long C[505][505],dp[505][505],sum[505][505],dp2[505];
int main(){
	int n,k;
	long long m;
	cin>>n>>k>>m;
//	cout<<"haha";
	for(int i=0;i<=n+5;i++){
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++) {
			C[i][j]=C[i-1][j-1]+C[i-1][j];
			if(C[i][j]>=m) C[i][j]-=m; 
		}
	}
	for(int i=0;i<=k;i++) dp[1][i]=1;
	for(int i=k;i>=0;i--) sum[1][i]=dp[1][i]+sum[1][i+1];
	
	for(int i=2;i<=n+1;i++){
	//	cout<<"ha";
		for(int j=0;j<=k;j++){
			for(int kk=1;kk<i;kk++){
				dp[i][j]=(dp[i][j]+dp[i-kk][j]*sum[kk][j+1]%m*C[i-2][kk-1]%m)%m;
			}
		}
		for(int j=k;j>=0;j--){
			sum[i][j]=dp[i][j]+sum[i][j+1];
			if(sum[i][j]>=m) sum[i][j]-=m;
		}
	}
	dp2[1]=sum[1][1]%m;
	for(int i=2;i<=n;i++){
		dp2[i]=sum[i][1];
		for(int j=1;j<i;j++){
			dp2[i]=(dp2[i]+dp2[i-j]*sum[j][1]%m*C[i-1][j-1]%m)%m;
		}
	}
	cout<<dp2[n];
//	cout<<dp[n+1][0];
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#define rep(i,n) for (long long i=0; i < (n); ++i)
#define rep2(i,n,m) for(long long i=n;i<=m;i++)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
int main() {
 int a,b,h,m ;
 cin >>a>>b>>h>> m;
 double ji=h*30.0+m*0.5 ;
 double hun=m*6.0 ;
 double sa=ji-hun ;
 double pi= 3.141592653589793238 ;
 double ans=sqrt(a*a+b*b-2*a*b*cos(sa*pi/180)) ;
   cout << fixed<<setprecision(20) ;
   cout <<ans<<endl ;
      return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int x;
    cin >> x;

    int big = x / 500;
    int rem = (x % 500) / 5;

    print(big * 1000 + rem * 5);

    return 0;
}


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

int main() {
    int N,x;
    int a[100000];
    cin >> N >> x;
    for(int i=0; i<N; ++i) cin >> a[i];

    long long ans = 0;
    for(int i=0; i+1<N; ++i) {
        if(a[i] > x) {
            ans += a[0] - x;
            a[i] = x;
        }
        if(a[i] + a[i+1] > x) {
            int tmp = min(a[i+1], a[i] + a[i+1] - x);
            a[i+1] -= tmp;
            ans += tmp;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int maxM = 1e5+7;
const int maxV = 90010;
 
const int MOD = 1e9+7;
 
int T;
const int maxN = 1e5+8;
const ll INF = 1000000000000000010LL;
const int K = 15;
vector<pii> v[maxN];
ll dis[maxN];
int vis[maxN];
int main() {
	int n,m,p;
	scanf("%d%d%d",&n,&m,&p);
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		v[x].push_back(pii(y,z-p));
	}
	for(int i=1;i<=n;i++)
	{
		dis[i] = -INF;
	}
	dis[1] = 0;
	queue<int> Q;
	Q.push(1);
	vis[1]++;
	while(!Q.empty())
	{
		int x = Q.front();
		Q.pop();
		for(auto e:v[x])
		{
			int to = e.first;
			int w = e.second;
			ll d;
			if(dis[x] == INF)
				d = INF;
			else
				d = dis[x] + w;
			if(dis[to] < d)
			{
				dis[to] = d;
				vis[to]++;
				if(vis[to] > m)
					dis[to] = INF;
				
				Q.push(to);
			}
		}
	} 
	ll ans = max(0ll,dis[n]);
	if(ans == INF)
		ans = -1;
	cout<<ans<<endl; 
    return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a;
	cin >> n >> a;
	if(n % 500 <= a) Yes();
	else No();
	return 0;
}

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

int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B / A, C) << endl;
}
/*test
1.
2 11 4
->4
2.
3 9 5
->3
3.
100 1 10
->0

*/

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

const MOD: i64 = 1_000_000_007;

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize, k: i64,
        a: [i64; n],
    }
    let u = k * (k - 1) % MOD;
    let u = u * ((MOD + 1) / 2) % MOD;
    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            if a[i] == a[j] { continue; }
            let inv = if (i < j) && (a[i] > a[j]) {
                (u + k) % MOD
            } else {
                u
            };
            ans = (ans + inv) % MOD;
        }
    }
    puts!("{}\n", ans);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<stdio.h>
int main(){
	int c[]={4,1,4,1,2,1,2,1};
	int pos[]={0,2,6,4,7,1,5,3};
	int p[8],d=0,o,i,s,m,mp;
	while(~scanf("%d",p+d)){
		if(++d==8){
			m=0;
			for(o=0;o<8;o++){
				s=0;
				for(i=0;i<8;i++){
					d=c[(pos[o]+i)%8];
					s+=p[i]<d?p[i]:d;
				}
				if(s>=m){
					m=s;
					mp=pos[o];
				}
			}
			for(i=0;i<8;i++){
				printf("%d",c[(mp+i)%8]);
				if(i<7)
					putchar(' ');
			}
			puts("");
			d=0;
		}
	}
	return 0;
}

Measured memory_bytes: 0
fun main(args:Array<String>) {
    val (a,b,c) = readLine()!!.split(" ").map { it.toInt() }
    println(if(getAns(a,b,c)) "YES" else "NO")
}

fun getAns(a:Int, b:Int, c:Int):Boolean {
    var tmp = a
    for(i in (1..200)) {
        if(tmp % b == c) {
            return true
        }
        tmp += a
    }
    return false
}


Measured memory_bytes: 36380
import itertools
N=int(input())
S=input()
ans=S.count("R")*S.count("G")*S.count("B")
c=list(itertools.permutations(["R","B","G"],3))
for j in range(1,N):
    for i in range(N-j*2):
        if (S[i],S[i+j],S[i+j*2]) in c:
            ans-=1
print(ans)

Measured memory_bytes: 9140
#include<iostream>
#include<algorithm>

static const int N = 10000;
using namespace std;
int a[N];

int main() {
  int n;
  cin >> n;
  for (int i =0;i<n;i++){
      cin >> a[i];
  }
  int cnt=0;
  int minj = 0;
  for (int i=0;i<n;i++){
      int minj = i;
      for (int j=i+1;j<n;j++){
          if (a[j] < a[minj]){
              minj = j;
          }
      }
      if (i!=minj) {
          swap(a[i],a[minj]);
          cnt++;
      }
  }
  
  for (int i=0;i<n;i++) {
    if(i == n - 1) {
            cout << a[i] << endl;
    } else {
            cout << a[i] << " ";
    }
    }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3128
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

int divide_cnt(int val)
{
	int divide_cnt = 0;
	while (val % 100 == 0)
	{
		val /= 100;
		divide_cnt++;
	}
	return divide_cnt;
}

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

	int D, N;
	cin >> D >> N;

	int cnt = 0;
	int val = 0;
	while (cnt < N)
	{
		val++;
		if (divide_cnt(val) == D)
		{
			cnt++;
		}
	}

	cout << val;

	return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    dp = [False] * (N+10)
    dp[0] = True
    for i in range(N+1):
        if dp[i]:
            dp[i+4] = True
            dp[i+7] = True
    if dp[N]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

const int N = 2000;
ll dp[N][N];

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n;
	cin >> n;
	vpll v(n);
	for(ll i = 0; i < n; i++)
		cin >> v[i].F, v[i].S = i;
	sort(all(v));
	for(int i = 1; i <= n; i++){
		for(int j = 0; j + i <= n; j++){
			int a = j, b = j + i - 1;
			if(i == 1){
				dp[a][b] = v[0].F * abs(v[0].S - a);
				continue;
			}
			int gone = a + n - 1 - b;
			gone = n - 1 - gone;
			dp[a][b] = max(v[gone].F * abs(v[gone].S - a) + dp[a + 1][b], v[gone].F * abs(v[gone].S - b) + dp[a][b - 1]);
		}
	}
	cout << dp[0][n - 1] << endl;
}

Measured memory_bytes: 26228
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9;

int main(){
  int A[100],N;
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[i];
  double sum(0);
  for (int i(0);i<N;i++){
    sum+=(1/(double)A[i]);
  }
  cout << setprecision(9) << 1/ sum << endl;
  return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include <unordered_map>
//#include"testlib.h"
#define endl "\n"
#define all(v) v.begin(),v.end()
#define allr(s) s.rbegin(),s.rend()
#define RT(s) return cout<<s,0
#define watch(x) cout << (#x)<<" = "<<x<<endl
#define sz(s)    (int)(s.size())
#define PI acos(-1)
#define EPS 1e-8
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
int dy[] = { 1, -1, 0, 0, -1, 1, 1, -1 };
int dx[] = { 0, 0, 1, -1, 1, -1, 1, -1 };
void file() {
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
#else
	//freopen("street.in", "r", stdin);
	//freopen("out.txt", "w", stdout);
#endif
}
void fast() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
}
const int N = 1e6 + 9;
bool sieve[N];
vector<int> primes;
void generate() {
	memset(sieve, 1, sizeof sieve);
	sieve[0] = sieve[1] = 0;
	for (int i = 4; i < N; i += 2)
		sieve[i] = 0;
	for (int i = 3; i * i < N; i += 2) {
		if (!sieve[i])
			continue;
		for (int j = i * i; j < N; j += i + i) // j = i * i because i + i = 2 * i and we iterate over 2 and i + i + i = 3 * i and we iterate over 3 and so on untill i * i becase we didn't iterate over i
			sieve[j] = 0; // j += i + i because (i + i - 1) must have not i as a divisor because i is biger than half (i + i - 1)
	}
	primes.push_back(2);
	for (int i = 3; i < N; i += 2)
		if (sieve[i]) primes.push_back(i);
}
vector<pair<ll, int>> fact(ll n) { // more efficient from O(sqrt(n))
	// pair <ll, int> becase may be n is prime so it will it in long long
	if (!sieve[3])
		generate();
	if (n < 2) return vector<pair<ll, int>>();
	vector<pair<ll, int>> ret;
	for (auto it : primes) {
		if (it * (ll)it > n)
			break;
		if (n < N && sieve[n])
			break;
		int cnt = 0;
		while (n % it == 0) {
			n /= it;
			cnt++;
		}
		if (cnt)
			ret.push_back({ it, cnt });
	}
	if (n > 1)
		ret.push_back({ n, 1 });
	return ret;
}
ll solve(ll num) {
	ll start = 1, end = 1e7, mid, ans = 1;
	while (start <= end) {
		mid = (start + end) / 2;
		if (mid * (mid + 1) / 2 <= num) {
			ans = mid;
			start = mid + 1;
		}
		else
			end = mid - 1;
	}
	return ans;
}
int main() {
//	file();
	fast();
	ll n; cin >> n;
	vector<pair<ll, int>> v1 = fact(n);
	ll ans = 0;
	for (auto& it : v1) {
		ans += solve(it.second);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4868
MOD = 10 ** 9 + 7
MAX = 10 ** 5 + 1
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def CoMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def COM(n, k):
   if n < k:
       return 0
   if n < 0 or k < 0:
       return 0

   return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

N, K = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
maxtotal, mintotal = 0, 0
CoMinit()
for i in range(N):
    maxtotal += a[i] * COM(i, K - 1)

for i in range(N):
    mintotal += a[-i - 1] * COM(i, K - 1)

print((maxtotal - mintotal) % MOD)

Measured memory_bytes: 19672
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

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

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long 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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////

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

	vector<ll> T(N + 2,0), A(N + 2,0);
	repn(i, N) cin >> T[i];
	repn(i, N) cin >> A[i];

	vector<ll> tl(N + 1);
	vector<ll> al(N + 1);
	repn(i, N) {
		if (T[i] > T[i - 1]) { tl[i] = T[i]-1; }
		else { tl[i] = 0; }
		if (A[i] > A[i + 1]) { al[i] = A[i]-1; }
		else { al[i] = 0; }
	}

	mint ans = 1;

	repn(i, N) {
		ll h = min(T[i], A[i]);
		ll l = max(tl[i], al[i]);
		ll x = max(h - l, 0);
		ans *= x;
	}

	cout << ans << endl;

	system("PAUSE");
}


Measured memory_bytes: 3576
n=int(input())
a=list(map(int,input().split()))
ct1=0;ct2=0;ct4=0
for i in range(n):
  if a[i]%4==0:ct4+=1
  elif a[i]%2==0:ct2+=1
  else:ct1+=1
if ct2!=0:ct1+=1
if ct1>ct4+1:print('No')
else:print('Yes')

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

int K, N;

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

  int result = 0;
  for (int i=1; i<=N; i++) {
    bool isValid = true;
    for (int j=0; j<K; j++) {
      if (i+j > N) {
        isValid = false;
        break;
      }
    }
    if (isValid) {
      ++result;
    }
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

#define MAX 100000
#define INFTY (1 << 30)

class Edge
{
public:
  int t, w;
  Edge() {}
  Edge(int t, int w) : t(t), w(w) {}
};

vector<Edge> G[MAX];
int n, d[MAX];

bool visited[MAX];
int cnt;

void bfs(int s)
{
  for (int i = 0; i < n; i++)
  {
    d[i] = INFTY;
  }
  queue<int> Q;
  Q.push(s);
  d[s] = 0;
  int u;
  while (!Q.empty())
  {
    u = Q.front();
    Q.pop();
    for (int i = 0; i < G[u].size(); i++)
    {
      Edge e = G[u][i];
      if (d[e.t] == INFTY)
      {
        d[e.t] = d[u] + e.w;
        Q.push(e.t);
      }
    }
  }
}

void solve()
{
  bfs(0);
  int maxv = 0;
  int tgt = 0;
  for (int i = 0; i < n; i++)
  {
    if (d[i] == INFTY)
    {
      continue;
    }
    if (maxv < d[i])
    {
      maxv = d[i];
      tgt = i;
    }
  }

  bfs(tgt);
  maxv = 0;
  for (int i = 0; i < n; i++)
  {
    if (d[i] == INFTY)
    {
      continue;
    }
    maxv = max(maxv, d[i]);
  }

  cout << maxv << endl;
}

int main()
{
  int s, t, w;
  cin >> n;

  for (int i = 0; i < n - 1; i++)
  {
    cin >> s >> t >> w;
    G[s].push_back(Edge(t, w));
    G[t].push_back(Edge(s, w));
  }
  solve();

  return 0;
}


Measured memory_bytes: 9916
// ABC001C.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>

using namespace std;




int main()
{
	int n;
	long long int H,W,A,B;
	int count = 0;
	cin>>n>>H>>W;
	for(int i = 0; i < n;i++){
		cin>>A>>B;
		if(A>=H && B>=W) count++;
	}
	cout<<count<<endl;
	return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

from collections import Counter
def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n, m = rli()
    wa = [0 for _ in range(n)]
    ac = [0 for _ in range(n)]
    for i in range(m):
        p, s = rl()
        p = int(p)
        p -= 1
        if ac[p] > 0:
            continue
        if s == "WA":
            wa[p] += 1
        else:
            ac[p] = 1
    sac = sum(ac)
    swa = sum(wa[i] for i in range(len(wa)) if ac[i] > 0)
    print(sac, swa)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5008
using System;
using System.Collections.Generic;

namespace Echo
{
    class Program
    {
        static void Main(string[] args)
        {            
            var inputN = int.Parse(Console.ReadLine());
            string inputS = Console.ReadLine();

            List<char> inputString = new List<char>(inputS);
            int middlePoint = inputString.Count / 2;
            if(inputN % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }

            for(int i = 0; i < middlePoint; i++)
            {
                if(inputString[i] != inputString[middlePoint + i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()

print(ceil(N, 2)/N)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int,int> P;
typedef pair<int,P> iP;
typedef pair<P,int> Pi;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<(n);i++)
#define Fr(i,n) for(int i=0;i++<(n);)
#define ifr(i,n) for(int i=(n)-1;i>=0;i--)
#define iFr(i,n) for(int i=(n);i>0;i--)

int main(){
  int n,m,p,q,c;
  cin>>n>>m;
  map<P,vector<Pi>> v;
  fr(i,m){
    cin>>p>>q>>c;
    v[mp(p,c)].pb(mp(mp(q,c),0));
    v[mp(q,c)].pb(mp(mp(p,c),0));
    v[mp(p,0)].pb(mp(mp(p,c),1));
    v[mp(p,c)].pb(mp(mp(p,0),0));
    v[mp(q,0)].pb(mp(mp(q,c),1));
    v[mp(q,c)].pb(mp(mp(q,0),0));
  }
  priority_queue<iP,vector<iP>,greater<iP>> pq;
  map<P,bool> vis;
  pq.push(mp(0,mp(1,0)));
  while(!pq.empty()){
    iP ip=pq.top();
    pq.pop();
    int cst=ip.ft;
    P p=ip.sd;
    if(p==mp(n,0)){cout<<cst<<endl;return 0;}
    if(vis[p]) continue;
    vis[p]=1;
    fr(i,v[p].size()){
      if(vis[v[p][i].ft]) continue;
      pq.push(mp(cst+v[p][i].sd,v[p][i].ft));
    }
  }
  cout<<-1<<endl;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;


void solve(std::vector<long long> A){
    string a;
    (A[0]+A[1]+A[2]>=22)?a="bust":a="win";
    cout<<a<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())

    numss = [[0]*(10) for _ in range(10)]
    for A in range(1, N+1):
        ss = str(A)
        numss[int(ss[-1])][int(ss[0])] += 1

    ans = 0
    for A in range(1, N+1):
        ss = str(A)
        ans += numss[int(ss[0])][int(ss[-1])]

    print(ans)

solve()


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)
#define all(a) a.begin(), a.end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvb = vector<vb>;

constexpr int MOD = 1000000007;

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

    int x, y, z, k;
    cin >> x >> y >> z >> k;

    vll a(x), b(y), c(z);
    rep(i, 0, x) { cin >> a[i]; }
    rep(i, 0, y) { cin >> b[i]; }
    rep(i, 0, z) { cin >> c[i]; }

    sort(all(a), greater<ll>());
    sort(all(b), greater<ll>());
    sort(all(c), greater<ll>());

    vll abc;
    rep(i, 0, x) {
        rep(j, 0, y) {
            rep(l, 0, z) {
                if ((i + 1) * (j + 1) * (l + 1) > k) { break; }
                abc.push_back(a[i] + b[j] + c[l]);
            }
        }
    }

    sort(all(abc), greater<ll>());
    rep(i, 0, k) { cout << abc[i] << endl; }

    return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
#include <array>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;


struct Problem {

	void Solve() {
		string s, t; cin >> s >> t;
		cout << t << s << endl;
	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}
double max(double a, double b) {
	if (a < b) return b;

	return a;
}


ll N;
string S;
ll Q;
ll k[76];
ll sumD[1000005], sumM[1000005], DM[1000005], DMC[1000005];
int main() {
	cin >> N >> S >> Q;
	rep(i, Q) {
		cin >> k[i];
	}

	sumD[0] = (S[0] == 'D') ? 1 : 0;
	sumM[0] = (S[0] == 'M') ? 1 : 0;
	for(int i = 1; i < S.size(); i++){

		if (S[i] == 'D') {
			sumD[i] = sumD[i - 1] + 1;
		}
		else {
			sumD[i] = sumD[i - 1];
		}
		if (S[i] == 'M') {
			sumM[i] = sumM[i - 1] + 1;

		}
		else {
			sumM[i] = sumM[i - 1];
		}

	}

	for (int i = 1; i < S.size(); i++) {
		if (S[i] == 'M') {
			DM[i] = DM[i - 1] + sumD[i];
		}
		else {
			DM[i] = DM[i - 1];
		}
	}
	ll sum = 0, index = 0;
	for (int j = 0; j < Q; j++) {
		rep(i, N) {
			DMC[i] = 0;
		}

		for (int index = 1; index < N; index++) {
			if (S[index] == 'C' && k[j] > index) {
				DMC[index] = DMC[index - 1] + DM[index];
			}
			else if (S[index] == 'C' && k[j] <= index) {
				DMC[index] = DMC[index - 1] + DM[index] - DM[index - k[j]] - sumD[index - k[j]] * (sumM[index] - sumM[index - k[j]]);

			}
			else
				DMC[index] = DMC[index - 1];

		}

		cout << DMC[N - 1] << endl;

	}
	return 0;
}

Measured memory_bytes: 32644
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define DEBUG 1
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int K, T; cin >> K >> T;
	vector<int> a(T);
	rep(i, 0, T)cin >> a[i];
	if (T != 1)rep(i, 0, T) {
		sort(all(a));
		a[T - 1] -= a[T - 2];
		a[T - 2] = 0;
	}
	cout << max(0LL, a[T - 1] - 1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long n,m,a[1000005],b,c,d,s,i;
int main()
{
    cin >> n >> m;
    for (c=1;c<=m;c++)
    {
        cin >> a[c];s+=a[c];
    }
    if (s<=n)
    {
        cout << n-s; return 0;
    }
    cout <<-1;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define ALL(a) a.begin(), a.end()
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = 1e14;
const ll MOD = 1e9 + 7;

struct P {
    double x;
    double y;
};

void print(P p)
{
    printf("%.8lf %.8lf\n", p.x, p.y);
}

void kock(int n, P p1, P p2)
{
    if (n == 0) {
        return;
    }
    P s, t, u;
    double th = M_PI * 60.0 / 180.0;
    s.x = (2.0 * p1.x + 1.0 * p2.x) / 3.0;
    s.y = (2.0 * p1.y + 1.0 * p2.y) / 3.0;
    t.x = (1.0 * p1.x + 2.0 * p2.x) / 3.0;
    t.y = (1.0 * p1.y + 2.0 * p2.y) / 3.0;
    u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
    u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
    kock(n - 1, p1, s);
    print(s);
    kock(n - 1, s, u);
    print(u);
    kock(n - 1, u, t);
    print(t);
    kock(n - 1, t, p2);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    P a, b;
    a.x = 0, a.y = 0, b.x = 100, b.y = 0;
    print(a);
    kock(n, a, b);
    print(b);
    return 0;
}


Measured memory_bytes: 3228
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)

    # N の逆元
    # N_inv = pow(N,MOD-2,MOD)

    # nCr
    # Nの階乗 * rの階乗の逆元 * n-rの階乗の逆元
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")

    # 大きな素数
    MOD = 10**9+7
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    s = input().rstrip()
    
    print(s[0]+str(len(s)-2)+s[-1])
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
// AtCoder ABC131: D - Megalomania
// 2019.9.4 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

typedef struct { int a, b; } T;
T t[200005]; int N;

void Qsort(T *a, int l, int r) {
	int i, j, m; T t;
	
	i = l, j = r, m = a[(l+r) >> 1].b;
	while (1) {
		while (a[i].b < m) i++;
		while (m < a[j].b) j--;
		if (i >= j)	break;
		t = a[i], a[i] = a[j], a[j] = t;
		i++, j--;
	}
	if (l+1 < i) Qsort(a, l, i-1);
	if (j+1 < r) Qsort(a, j+1, r);
}

int main()
{
	int i, s;
	
	N = in(); for (i = 0; i < N; i++) t[i].a = in(), t[i].b = in();
	Qsort(t, 0, N-1);
	s = 0; for (i = 0; i < N; i++) {
		s += t[i].a;
		if (s > t[i].b) goto No;
	}
	puts("Yes"); return 0;
No: puts("No");  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll a, b, m;
  cin >> a >> b >> m;
  
  vector<int> A(a);  
  vector<int> B(b);
  rep(i, 0, a) cin >> A.at(i);
  rep(j, 0, b) cin >> B.at(j);
  
  ll ans = 10000000;
  rep(i, 0, m) {
    int x, y, c;
    cin >> x >> y >> c;
    ans = min(A.at(x-1) +B.at(y-1) -c, (int)ans);
  }
  
  sort(all(A));
  sort(all(B));
  ans = min(A.at(0)+B.at(0), (int)ans);
      
  cout << ans << "\n";

}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String args[]) { 
    	Scanner sc = new Scanner(System.in);
    	String input1 = sc.nextLine();
        String input2 = sc.nextLine();
        String input3 = sc.nextLine();
       	System.out.println(input1.substring(0,1)+input2.substring(1,2)+input3.substring(2,3));
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s >> t;
    map<char,char> m;
    intl len = s.length();
    bool flag = true;
    rep(i,len){
            if(((m.find(s[i]) != m.end())&&(m[s[i]] != t[i]))){
                flag = false;
                break;
            }
            else{
                m.insert(mp(s[i],t[i]));
            }
    }
    rep(i,len){
        if(m.find(s[i]) != m.end()){
            s[i] = m[s[i]];
        }
    }
    vector<char> v;
    for(auto i : m){
        if(find(all(v),i.second) != v.end()){
            flag = false;
        }
        else {
            v.pb(i.second);
        }
    }
    fp((s == t) && flag);
    return 0;
}

Measured memory_bytes: 776
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
int min(int x,int y)
{
	if(x<y)
		return x;
	return y;
}
int max(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
string toLower(string s)
{
	int len = s.length();
	for(int i=0;i<len;i++)
	{
		if(s[i]<91)
		{
			s[i] += 32;
		}
	}
	return s;
}
int main()
{
	//ios::sync_with_stdio(false);
    //cin.tie(0);
    //cout.tie(0);
	//cin.ignore(numeric_limits<streamsize>::max(),'\n');
	//const unsigned int M=1000000007;
	int n,k,count=0;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++)
		cin >> a[i];
	
	sort(a,a+n);
	for(int i=0;i<k;i++)
		count += a[i];
	
	cout << count;
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
  using namespace std;
  typedef long long int ll;
  #define mod 1000000007
  #define all(v)  v.begin(),v.end()
  #define pb push_back
  #define size(v)  (int) v.size()
  #define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
  ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
  ll inv(ll a){return power_mod(a,mod-2);}
  ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}

  int main()
  {
     
      int n,l;
      cin>>n>>l;
      int sum=0;
      for(int i=1;i<=n;i++)
      {
          sum+=(l+i-1);
      }
       int ans=1e9;
       int check;
      for( int i=1;i<=n;i++)
      {
          int curr = sum-(l+i-1);

          if( abs(sum-curr)<ans)
          {
              ans = abs(sum-curr);
              check= curr;

          }
      }

      cout<<check<<endl;
  }



Measured memory_bytes: 256
# AGC028
from fractions import gcd
#from math import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
S = input()
T = input()
l = lcm(N, M)
if S[0] != T[0]:
    print(-1)
    exit()
if N == 1 or M == 1:
    if N == 1:
        print(M)
    if M == 1:
        print(N)
    exit()

if N == l:
    tmp = N // M
    for i in range(tmp):
        if S[i * tmp] == T[i]:
            pass
        else:
            print(-1)
            exit()
if M == l:
    tmp = M // N
    for i in range(tmp):
        if T[i * tmp] == S[i]:
            pass
        else:
            print(-1)
            exit()

G = gcd(N, M)
if G != 1:
    for g in range(G):
        if S[g * N // G] == T[g * M // G]:
            pass
        else:
            print(-1)
            exit()
print(l)

Measured memory_bytes: 5344
n = int(input())
c = [0, 0, 0]
ans = 0
for i in range(n):
    si = input()
    ans += si.count('AB')
    if si[0] == 'B' and si[-1] == 'A':
        c[0] += 1
    elif si[0] == 'B':
        c[1] += 1
    elif si[-1] == 'A':
        c[2] += 1
ans += max(0, c[0] - 1)
if c[0] > 0 and c[1] > 0:
    ans += 1
    c[1] -= 1
if c[0] > 0 and c[2] > 0:
    ans += 1
    c[2] -= 1
ans += max(0, min(c[1:]))
print(ans)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
string S[100];
set<string> st;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N) {
        cin>>S[i];
        st.insert(S[i]);
    }

    if(st.size() == 3){
        cout<<"Three"<<endl;
    }else{
        cout<<"Four"<<endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int n,m,i,s,a;
int main()
{
    //freopen("in.txt","r",stdin);
    cin>>n>>m;
    while(m--)
    {
        cin>>a;
        s+=a;
    }
    if(n-s>=0)
        cout<<n-s;
    else
        cout<<-1;
    return 0;
}


Measured memory_bytes: 3628