akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

char d[] = { '3', '5', '7' };
str s;

inline bool ok(const str t) {
    bitset<3> b("000");
    REP(i, t.length()) {
        b[(t[i] - '0') / 2 - 1] = true;
    }
    return b.all();
}

int dfs(const int loc, const str t) {
    str n = t;
    int res = 0;
    if(loc < 0) return 0;
    REP(i, 3) {
        n = d[i] + t;
        if(stoi(n) <= stoi(s) && ok(n)) {
            res++;
        }
        res += dfs(loc - 1, n);
    }
    return res;
}

int main() {
    cin >> s;
    set<str> st;
    int ans = dfs(s.length() - 1, "");
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		X -= A;
		int Y = X / B;
		X -= Y * B;
		System.out.println(X);
	}
}

Measured memory_bytes: 21844
// 69

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long;


int main(){
    ll n, tmp, sum=0;
    cin >> n;
    tmp = n;
    vector<int> v;
    for(ll i=2; i<=sqrt(n); i++){
        int count=0;
        while(tmp % i == 0){
            count++;
            tmp /= i;
        }
        if(count != 0){
            v.push_back(count);
        }
    }
    if(tmp != 1) v.push_back(1);

    for(int n: v){
        ll i=1;
        for(; i*(i+1)/2-1<n; i++){}
        sum += i-1;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

ll ARR[15][15];

int main(int argc, char const *argv[])
{
  ll N,M,X; cin >> N >> M >> X;
  ll cnt = 0, res = 1000000000LL;
  cnt = 1 << N;
  REP(i, N) REP(j, M+1) cin >> ARR[i][j];

  vector<ll> score(15);
  ll price = 0;
  REP(k, cnt) {
    REP(kk, 15) score[kk] = 0;
    price = 0;

    REP(i, N) {
      if ((k >> i) & 1) {
        price += ARR[i][0];
        REP(j, M) score[j] += ARR[i][1+j];
      }
    }

    ll judge = true;
    REP(j, M) {
      // cout << score[j] << " ";
      judge = judge && score[j] >= X;
    }
    // cout << endl;
    if (judge) {
      res = min(res, price);
    }
  }
  if (res != 1000000000LL) {
    cout << res << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };

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

#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
        a: [usize;n-1],
    }
    let mut state = vec![0;n];
    for i in 0..n-1 {
        state[a[i]-1]+=1;
    }
    for i in 0..n{
        println!("{}", state[i]);
    }
}

Measured memory_bytes: 4324
defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.to_integer()
    |> process()
    |> IO.puts()
  end
  
  defp process(n) when n < 15, do: n * 800
  defp process(n), do: n * 800 - div(n,15) * 200
end

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

int main() {
string a;
  cin>>a;
  int i=0;
  if(a.at(0)=='R'){
    i=i+1;
    if(a.at(1)=='R'){
      i=i+1;
    }
    if(a.at(1)=='R' && a.at(2)=='R'){
      i=i+1;
    }
  }
else{
  i=0;
     if(a.at(1)=='R'){
      i=i+1;
    }
    if(a.at(2)=='R'){
      i=i+1;
    }
}
  cout<<i<<endl;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
const int mxr= 2e5+1;
vector<pair<int,int>> lef[mxr];
vector<int> righ[mxr];
int main()
{
	//ios_base::sync_with_stdio(false); 
    //cin.tie(NULL);
	int n,x;
	cin>>n;
	vector <int> v;
	int freq[n+1]={};
	for(int i=0; i<n ; i++ )
	{
		cin>>x;
		freq[x]++;
	}
	for(int i = 0; i<=n ; i++)
		if(freq[i])
			v.pb(freq[i]);
	sort(v.begin(),v.end(),greater<int>());
	int len = v.size();
	int sum[len+1]={};
	sum[len-1] = v[len-1];
	sum[len]=0;
	for(int i = len-2 ; i>=0 ; i--)
		sum[i] = v[i]+sum[i+1];
	int ans[n+1];
	cout<<endl;
	for(int i = 1; i<=n ; i++)
	{
		if(i>v.size())
		{
			ans[i]=0;
			continue;
		}
		int l = 0, r=i-1;
		while(l<r)
		{
			int mid = (l+r)/2;
			int del = i-1-mid;
			if(del*v[mid] > sum[mid+1])
			{
				l = mid+1;
			}
			else
				r=mid;

		}
		//cout<<"i = "<<i<<" r = "<<r<<"coeff : "<<(i-1-r)<<"sum : "<<sum[r]<<endl;
		if(r == i-1)
			ans[i] = sum[r];
		else
			ans[i]=  sum[r]/(i-1-r+1);

	}
	for(int i = 1; i<=n ; i++)
	{
		cout<<ans[i]<<' ';
	}

	return 0;
}

Measured memory_bytes: 14832
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int N,D,X,ans=0;
    cin>>N>>D>>X;
    REP(i,N){
        int m;cin>>m;
        int ch=1;
        int k=1;
        for(;;){
            if(k*m+1<=D)ch++;
            else break;
            k++;
        }
        ans+=ch;
    }
    cout<<ans+X<<endl;
}

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

const int MAXN = 1e5 + 21;

long long n;
bool mark[MAXN];

void f() {
 	for (long long i = 2; i < 100004; i++) {
     	if (mark[i] == true) 
      		continue;
      	for (long long j = i * i; j < 100004; j += i) 
            mark[j] = true; 
    }
}

int main() {
    f();
  cin >> n;
  for (int i = n; i < 100004; i++)
    if (!mark[i])
        return cout << i << '\n', 0;
 	return 0; 
}

Measured memory_bytes: 384
#include<algorithm>
#include<array>
#include<cmath>
#include<iostream>
#include<iomanip>
#include<iso646.h>
#include<queue>
#include<stack>
#include<string>
#include<vector>

#define FOR(counter,initial_value,condition) for(int counter = initial_value; counter < condition;counter++)

int main()
{
	std::string a, b, c;
	std::cin >> a >> b >> c;
	std::cout << (char)((int)a[0] - 32) << (char)((int)b[0] - 32) << (char)((int)c[0] - 32) << std::endl;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> v(n) ;
    int ans = 0 ;
    for(int &x : v){
        cin >> x ;
        ans ^= x ;
    }
    for(int &x : v){
        cout << (ans ^ x) << ' ' ; 
    }
    cout << endl;
    return 0; 
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;
//1秒間で処理できる for 文ループの回数は、10^8=100,000,000回程度
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}

int main(){
    //A
    /*
    int N;
    cin>>N;
    if(N/100==7||N/10%10==7||N%10==7){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
    */
   //B
   /*
   int n;cin>>n;
   ll c=0;
   rep(i,1,n+1) {
       if(i%3!=0&&i%5!=0) c+=i;
   }
   cout<<c<<endl;
   */
   //C
   int K;cin>>K;
   ll c=0;
   rep(i,1,K+1){
       rep(j,1,K+1){
           rep(l,1,K+1){
               c+=gcd(i,gcd(j,l));
           }
       }
   }
   cout<<c<<endl;
}

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

const int maxn = 1e5 + 3;

int n, k, a[maxn];

int main() {
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }
    int ans = 0x7fffffff;
    for(int i = 0; i + k <= n; ++i) {
        int l = a[i], r = a[i + k - 1];
        ans = std::min(ans, std::max({std::abs(l), std::abs(r), r - l}) + (l < 0 && r > 0 ? std::min(std::abs(l), std::abs(r)) : 0));
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
    string S, T; cin >> S >> T;
    int ls = S.length(), lt = T.length();
    int dp[ls+1][lt+1];
    for (int i=0; i<=ls; i++){
        dp[i][0] = 0;
    }
    for (int i=0; i<=lt; i++){
        dp[0][i] = 0;
    }
    for (int i=1; i<=ls; i++){
        for (int j=1; j<=lt; j++){
            if (S[i-1] == T[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int i = ls-1, j = lt-1;
    bool update;
    string ans = "";
    while (i >= 0 && j >= 0){
        if (S[i] == T[j]) {
            ans = S[i] + ans;
            i -= 1;
            j -= 1;
        }
        else {
            if (dp[i][j+1] > dp[i+1][j]){
                i -= 1;
            }
            else {
                j -= 1;
            }
        }
    }
    cout << ans << endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

const int N=405;
ll dp[N][N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<ll> sum(n+1),a(n);
    memset(dp,0x3f,sizeof(dp));
    forn(i,n){
        cin>>a[i];
        dp[i][i]=0;
    }
    partial_sum(all(a),sum.begin()+1);
    for(int len=2;len<=n;len++){
        for(int l=0;l+len-1<n;l++){
            for(int k=l;k<l+len-1;k++){
                dp[l][l+len-1]=min(dp[l][l+len-1],dp[l][k]+dp[k+1][l+len-1]+sum[l+len]-sum[l]);
            }
        }
    }
    cout<<dp[0][n-1];
    return 0;
}



Measured memory_bytes: 4916
s = list(map(int, list(input())))
n = len(s)
cnt1 = 0
cnt2 = 0
for i in range(n):
    if i%2 == 0:
        if s[i] == 0:
            cnt1 += 1
    else:
        if s[i] == 1:
            cnt1 += 1

for i in range(n):
    if i%2 == 0:
        if s[i] == 1:
            cnt2 += 1
    else:
        if s[i] == 0:
            cnt2 += 1

print(min(cnt1, cnt2))


Measured memory_bytes: 49392
#include<bits/stdc++.h>
using namespace std;
long n,m,w[1000],v[1000];
long long f[200][100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
	for(int i=1;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(j>=w[i]){
				f[i][j]=max(f[i-1][j],f[i-1][j-w[i]]+v[i]);
			}else{
				f[i][j]=f[i-1][j];
			}
		}
	}
	cout<<f[n][m];
}

Measured memory_bytes: 79360
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <vector>
using namespace std;
typedef long long LL;

LL q,tmp = 0,f,op;
string bs,s1,s2,s3;
char ch;

int main(){
	cin >> bs;
	cin >> q; s1 = ""; s2 = ""; s3 = "";
	while(q --){
		cin >> op;
		if(op == 1) tmp ^= 1;
		if(op == 2){
			cin >> f >> ch; f --;
			if((tmp ^ f) == 0) s1 += ch;
			else s2 += ch;
		}
	}
	for(LL i = s1.length() - 1;i >= 0;i --) s3 += s1[i];
	s3 += bs; s3 += s2;
	if(tmp) reverse(s3.begin(),s3.end());
	cout << s3 << endl;
	return 0;
}
//

Measured memory_bytes: 1476
//   PIGMEISTER™   //

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

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);

int main()
{
    jaldi;
    
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vp v;
    ll ap;
    sidha (i, 0, a+b+c) {
        cin >> ap;
        ll type = 1;
        if (i >= a) type = 2;
        if (i >= a+b) type = 3;
        v.pb({ap, type});
    }
    sort(bas(v));
    //for (auto i:v)cout<<i.fi<<' ';
    ll ans = 0, c1 = 0, c2 = 0, c3 = 0, i = 0;
    while (c1+c2+c3 < x+y) {
        if (v[i].se == 1 && c1 < x) {
            ++c1;
            ans += v[i].fi;
        }
        else if (v[i].se == 2 && c2 < y) {
            ++c2;
            ans += v[i].fi;
        }
        else if (v[i].se == 3) {
            ++c3;
            ans += v[i].fi;
        }
        ++i;
        //cout << ans << '*'<<v[i].fi<<'*'<<v[i].se << ' ';
    }
    cout << ans << endl;
    
    return 0;
}

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

Measured memory_bytes: 10476
//In The Name Of The God

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define F first
#define S second
#define X first.first
#define Y first .second
#define A second.first
#define B second.second
#define mp make_pair
#define pb push_back
#define pf push_front
#define P push
#define pob pop_back
#define pof pop_front
#define PO pop
#define rep(i,j,k) for(int i = j ; i <= k ; ++ i)
#define rrep(i,j,k) for(int i = j ; i>=k ; --i)
#define FR(i,j,k) for(int i = j ; i < k ; ++ i )
#define rFR(i,j,k) for(int i = j ; i > k ; -- i )
#define lb(x) x&-x
#define p2(x) (1LL<<x)
#define SZ size()
#define LB lower_bound
#define UB upper_bound
#define IT iterator
#define RIT reverse_iterator
#define E end()
#define BE begin()
#define RE rend()
#define RBE rbegin()
#define UN unsigned

typedef pair<int,int> pii;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll ;
typedef pair<int,pii> pip;
typedef pair<pii,int> ppi;
typedef pair<pii,pii> ppp;
typedef pair<int,pll> pipl;
typedef pair<pll,int> ppli ;
typedef pair<pll,pll> plpl ;
typedef pair<ll,pii> lpip;
typedef pair<pii,ll> lppi;
typedef pair<pii,pii> lppp;
typedef pair<ll,pll> lpipl;
typedef pair<pll,ll> lppli ;
typedef pair<pll,pll> lplpl ;
typedef vector<int> vi ;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii > stpi;
typedef set<pll> stpl;
typedef vi::IT vit;
typedef vl::IT vlt;
typedef vpi::IT vpit;
typedef vpl::IT vplt;
typedef sti::IT stit;
typedef stl::IT stlt;
typedef stpi::IT stpit;
typedef stpl::IT stplt;
typedef vpi::RIT rvpit;
typedef vpl::RIT rvplt;
typedef sti::RIT rstit;
typedef stl::RIT rstlt;
typedef stpi::RIT rstpit;
typedef stpl::RIT rstplt;

const int MAXN = 500000;
const int SUPERN = 5000000;
const int MAXS = 325;
const int SUPERS = 1000;
const int MD = 1e9+7;
//......Structures.......

//......Variables........
ll n,x,y,q,k,d[MAXN],p[MAXN][21],d2[MAXN],t,re;
bool vis[MAXN];
vpl ad[MAXN];
//......Funcs............
ll sum(ll a,ll b)
{
    return (a+b)%MD;
}
ll mu(ll a,ll b)
{
    return (a*b)%MD;
}
ll mn(ll a,ll b)
{
    return(a-b+MD)%MD;
}
void dfs(ll u,ll pa,ll h)
{
    d[u]=h;
    vis[u]=true;
    for(auto v:ad[u])
    {
        if(!vis[v.F])
        {
            dfs(v.F,u,v.S+h);
        }
    }
}
ll bal(ll u,ll h)
{
    rep(i,0,20)
    {
        if(h&p2(i))
        {
            u=p[u][i];
        }
    }
}
ll lca(ll u,ll v)
{
    if(d2[u]<d2[v])swap(u,v);
    u=bal(u,d2[u]-d2[v]);
    if(u==v)return v;
    rrep(i,20,0)
    {
        if(p[u][i]!=p[v][i])
        {
            u=p[u][i];v=p[v][i];
        }
    }
    return p[u][0];
}
//......Code.............
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    rep(i,1,n-1)
    {
        cin>>x>>y>>k;
        ad[x].pb({y,k});
        ad[y].pb({x,k});
    }
    cin>>q>>k;
    dfs(k,-1,0);
    rep(i,1,q)
    {
        cin>>x>>y;
        cout<<d[x]+d[y]<<endl;
    }
    return 0;
}


Measured memory_bytes: 27520
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static long Gcd(long a, long b)
		{
			if (b == 0) {
				return a;
			}

			return Gcd(b, a % b);
		}

		public static long Lcm(long a, long b)
		{
			long g = Gcd(a, b);
			return a / g * b;
		}

		public static void Exec()
		{
			long n = long.Parse(Console.ReadLine());
			var array = new long[n];

			long answer = 1;
			for (var i = 1; i <= n; ++i) {
				long time = long.Parse(Console.ReadLine());
				answer = Lcm(answer, time);
			}

			Console.WriteLine($"{answer}");

			Console.ReadKey();
		}
	}
}

Measured memory_bytes: 11220
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define Mx 1e10
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,mn=0,mx=0,x,i,t=0,j=0,k=1e10;
    	set<ll>s;
    	cin>>n;
    	ll a[n],c[n],g[n];
    	f(i,n)
    	{
    	    cin>>a[i];
    	}
        sort(a,a+n);
        mn=a[0],mx=a[n-1];
        t=(mx+mn)/2;
        for(i=-100;i<=100;i++)
        {
            t=0;
            for(j=0;j<n;j++)
            {
                x=abs(i-a[j]);
                t+=x*x;
            }
            k=min(t,k);
        }
        cout<<k<<endl;
}







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

#define st first
#define nd second
typedef long long LL;
typedef long double LLD;
typedef pair <int, int> PII;
typedef pair <LL, LL> PLL;

int main()
{       
    int maxi = 0, mini = 100;

    for (int i = 0; i < 3; ++i)
    {
        int a;
        scanf("%d", &a);
        maxi = max(maxi, a);
        mini = min(mini, a);
    }

    printf("%d", maxi - mini);
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int Q=1<<9;
int las[Q],e[Q],nn[Q],inc=0;
void ins(int x,int y)
{
	e[++inc]=y;
	nn[inc]=las[x];
	las[x]=inc;
}
int mx,mmx[Q];
void dfs(int x,int last,int dep)
{
	int num=0;
	for(int t=las[x];t;t=nn[t]){
		int y=e[t];
		if(y==last)continue;
		dfs(y,x,dep+1);
		++num;
	}
	mmx[dep]=max(mmx[dep],num);
	mx=max(mx,dep);
}
#define ll long long
int main()
{
	int n;
	int now=998244353;
	ll pi=-1;
	scanf("%d",&n);
	for(int i=1,x,y;i<n;i++)
		scanf("%d%d",&x,&y),ins(x,i+n),ins(i+n,x),ins(y,i+n),ins(i+n,y);
	n=n*2-1;
	for(int i=1;i<=n;i++){
		mx=0;
		for(int j=1;j<=n;j++)mmx[j]=0;
		dfs(i,0,1);
		int rem=mx;
		mx=(mx+1)>>1;
		if(mx<=now){
			ll tmp=1;
			for(int j=1;j<rem;j++)
				tmp*=1LL*mmx[j];
			if(mx<now||(mx==now&&tmp<pi))pi=tmp,now=mx;
		}
	}
	printf("%d %lld\n",now,pi);
	return 0;
}

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

using namespace std;

long long inf=1000000007;

long long modpow(long long n,long long p,long long mod);

int main(){
	long long n;
	cin>>n;
	long long ans=1;
	vector<string> hoge(2);
	for(long long i=0;i<2;i++) cin>>hoge.at(i);

	bool pre=false;

	for(long long i=0;i<n;i++){
		if(i==0){
			if(hoge.at(0).at(i)==hoge.at(1).at(i)){
				ans*=3;
				pre=true;
			}else{
				ans*=6;
				i++;
				pre=false;
			}
			ans%=inf;
		}else{
			if(pre){
				ans*=2;
				ans%=inf;
				if(hoge.at(0).at(i)!=hoge.at(1).at(i)){
					pre=false;
					i++;
				}
			}else{
				if(hoge.at(0).at(i)==hoge.at(1).at(i)){
					ans*=1;
					pre=true;
				}else{
					ans*=3;
					i++;
					pre=false;
				}
				ans%=inf;
			}
		}
		ans%=inf;
	}

	cout<<ans<<endl;

	return 0;
}

long long modpow(long long n,long long p,long long mod){
	if(p==0) return 1;
	if(p%2==0) return (modpow(n,p/2,mod)*modpow(n,p/2,mod))%mod;
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    int n;
    ll a[102][21];
    REP(i,102)REP(j,21) a[i][j] = 0;
    cin >> n;
    a[0][0] = 1;
    int temp;
    cin >> temp;
    a[1][temp] = 1;
    FOR(i,1,n){
	int m;
	cin >> m;
	REP(j,21){
	    if(j+m <= 20){
		a[i+1][j+m] += a[i][j];
	    }
	    if(j-m >= 0){
		a[i+1][j-m] += a[i][j];
	    }
	}
    }
    cout << a[n][0] << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

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

    int n, d, x, a;
    cin >> n >> d >> x;

    int sum = x;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        for (int i = 1; i <= d; i += a)
            ++sum;
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	if (A <= 8 && B <= 8)
	{
		cout << "Yay!" << endl;
	}
	else
	{
		cout << ":(" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        a: [usize; n],
    }

    let a_max = a.iter().max().unwrap();
    let mut first = 0;
    let mut last = *a_max;

    while last-first > 1 {
        let mid = (first + last) / 2;
        if check(mid, &a, k) {
            //println!("ok: mid {}", mid);
            last = mid;
        } else {
            //println!("ng: mid {}", mid);
            first = mid;
        }
    }

    println!("{}", last);
}

fn check(n: usize, a: &Vec<usize>, k: usize) -> bool {
    let mut count = 0;
    for na in a {
        count += (na + (n - 1)) / n - 1;
    }
    if count <= k {
        return true;
    } else {
        return false;
    }
}


Measured memory_bytes: 5336
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int s = a+b+c;

    if (s >= 22) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
// #define fast ios_base::sync_with_stdio(fasle);cin.tie(NULL)
using namespace std;

int main()
{
    // fast;/
    int d;
    cin >>d;
    int arr[3];
    cin >>arr[0]>>arr[1]>>arr[2];
    
    for(int i=2;i<=d;i++)
    {
        int temp[3];
        cin >>temp[0]>>temp[1]>>temp[2];
        temp[0] = max(temp[0]+arr[1],temp[0]+arr[2]);
        temp[1] = max(temp[1]+arr[2],temp[1]+arr[0]);
        temp[2] = max(temp[2]+arr[1],temp[2]+arr[0]);
        arr[0]=temp[0];
        arr[1]=temp[1];
        arr[2]=temp[2];
    }
    int ans = max(arr[0],max(arr[1],arr[2]));
    cout <<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b % a == 0) System.out.println(a + b);
        else System.out.println(b - a);
        
    } 
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

int PP[50]={};

int tyok(int n,int i,int M){

	if(M==0)return 1;
	if(i>=n)return 0;
	int W=tyok(n,i+1,M)||tyok(n,i+1,M-PP[i]);
	return W;
}

int main(){
	int n,M,y;
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>PP[i];
	cin>>y;
	for(int i=0;i<y;i++){
		cin>>M;
		if(tyok(n,0,M))cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
import sys
N=int(input())
if N == 1:
    print(1)
    sys.exit()
lim=10**9+7
import numpy as np
def seachPrimeNum(N):
    max_ = int(np.sqrt(N))
    seachList = [i for i in range(2,N+1)]
    primeNum = []
    while seachList[0] <= max_:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    return primeNum

ans = 1
l=seachPrimeNum(N)
#print(l)
for p in l:
    temp=0
    k=1
    while True:
        if p**k>N:
            break
        temp += N//(p**k)
        k+=1
    ans = (ans * (temp + 1)) % lim
    #print(N//p + 1)
print(ans)

Measured memory_bytes: 12424
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define pb push_back
int main(){
    int n;
    cin>>n;
    vi vec(100001);
    for(int i=0;i<n;i++){
        int t;
        cin>>t;
        vec[t]++;
    }
    int ans=0;
    for(int i=1;i<100000;i++){
        ans=max(ans,vec[i-1]+vec[i]+vec[i+1]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd
def ii(): return int(stdin.readline())
def fi(): return float(stdin.readline())
def mi(): return map(int, stdin.readline().split())
def fmi(): return map(float, stdin.readline().split())
def li(): return [x for x in mi()]
def si(): return stdin.readline()
n=ii()
print(n*n)

Measured memory_bytes: 3060
function main(input: string[]): void {
    const a = shi(input);
    const b = shi(input);
    if (9 < a || 9 < b) {
        puts(-1);
    } else {
        puts(a * b);
    }
}

// === BEGIN MODULE ===
function shi(array: string[]): number {
    return parseInt(array.shift());
}
function shf(array: string[]): number {
    return parseFloat(array.shift());
}
function puts(...message: any[]): void {
    process.stdout.write(message.join(' ') + '\n');
}
// === END   MODULE ===

import { readFileSync } from 'fs';
if (process.argv[1] == __filename) {
    const path = process.argv[2] || '/dev/stdin';
    const input = readFileSync(path, 'utf-8');
    main(input.split(/\s+/));
}

Measured memory_bytes: 9292
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int n,h,a[200010],b[200010],f[200010];
void solve()
{
    cin>>h>>n;
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=1;i<=4e4;i++)f[i]=1e18;
    int ans=1e18;
    for(int i=1;i<=4e4;i++)
    {
        for(int j=0;j<n;j++)
            if(i>=a[j])f[i]=min(f[i],f[i-a[j]]+b[j]);
        if(i>=h)ans=min(ans,f[i]);
    }
    cout<<ans;
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 2688
#include "cstdio"
long long ss;int s[100005],i,x,n;
int A(){
    int a=0,k=1;char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-') k=-1;c=getchar();
    }
    while(c>='0'&&c<='9'){
        a=a*10+c-'0';c=getchar();
    }
    return a*k;
}
int main(){
	scanf("%d%d",&n,&x);
	for(i=1;i<=n;i++)
	s[i]=A();
	for(i=1;i<=n;i++){
		if(s[i]+s[i-1]>x)ss+=s[i]+s[i-1]-x,s[i]=x-s[i-1];
	}
	printf("%lld\n",ss);
}

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

#ifdef DEBUG
    #include "debug.h"
    #define DEB
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define DEB if (false)
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

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

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

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

//*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}



signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


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

int main()
{
    int N, a, b, c, d;

    cin >> N;
    a = N/1000;
    b = N/100 -a*10;
    c = N/10 -b*10 -a*100;
    d = N -c*10 -b*100 -a*1000;
    if (a == b && b == c) cout << "Yes\n";
    else if (b == c && c == d)  cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


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

int main() {
  int h,n;
  cin>>h>>n;
  int a[n],b[n];
  for(int i=0;i<n;i++) {
    cin>>a[i]>>b[i];
  }
  int dp[1100][20090];
  for(int i=0;i<20090;i++) dp[0][i]=100000005;
  dp[0][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=h;j++){
      if(a[i]>j) dp[i+1][j]=min(dp[i][j],dp[i][0]+b[i]);
      else dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
    }
  }
  cout<<dp[n][h]<<endl;
  return 0;
}

Measured memory_bytes: 80384
n = int(input())
s = []
smallest = 1000

flag = True
for i in range(n):
    val = int(input())
    s.append(val)

    if (val % 10) > 0:
        flag = False
        if val < smallest:
            smallest = val

if flag:
    print(0)
else:
    total = sum(s)
    if (total % 10) == 0:
        print(total - smallest)
    else:
        print(total)

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

int main(){
    string s[3];
    for(int i = 0; i < 3; i++)
    {
        cin >> s[i];
    }
    
    int idx[3] = {0};
    int curr = 0;
    while(1){
        curr = s[curr][idx[curr]++] - 'a';
        if(idx[curr] >= s[curr].size()){
            cout << char('A'+curr) << endl;
            return 0;
        }
    }
    
    
    return 0;
}

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

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

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

	int a = INT_MAX,b = INT_MAX, tmp;
	for (int i = 0;i < 3;i++){
		cin >> tmp;
		a = min(tmp,a);
	}	
	for (int i = 0;i < 2;i++){
		cin >> tmp;
		b = min(tmp,b);
	}

	cout << a+b-50 << endl;

	return 0;

}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int n,k,j,i;
    cin>>n>>k;
    double ans,res=0;
    for(i=1;i<=n;i++)
    {
        ans=1.0/n;
        j=i;
      while(j<k)
      {
          j*=2;
          ans/=2;
      }
      res+=ans;
    }
    cout<<fixed<<setprecision(10)<<res<<e;
}


Measured memory_bytes: 256
import random

def calc_score(D, C, S, T):
    score = 0
    last = [0]*26
    for d in range(D):
        t = T[d] - 1
        score += S[d][t]
        last[t] = d + 1
        for i in range(26):
            score -= C[i]*(d + 1 - last[i])
    return score

def main():
    D = int(input())
    C = list(map(int, input().split()))
    S = []
    for i in range(D):
        S.append(list(map(int, input().split())))

    sorted_scores = []
    for i in range(D):
        scores = [(j, S[i][j]) for j in range(26)]
        sorted_scores.append(sorted(scores, key=lambda x: x[1], reverse=True))
    # print(sorted_scores)
    sorted_c = []
    sorted_c = [(i, C[i]) for i in range(26)]
    sorted_c.sort(key=lambda x: x[1], reverse=True)
    # print(sorted_c)
    last = [0]*26
    ans = []
    for d in range(D):
        score = -100*365*365
        t = 0
        for i in range(26):
            tmp = S[d][i]
            for j in range(26):
                if i != j:
                    tmp -= C[j]*(d + 1 - last[j])
            if tmp > score:
                score = tmp
                t = i + 1
        last[t - 1] = d + 1
        ans.append(t)
    score = calc_score(D, C, S, ans)
    for i in range(10**3):
        d = random.randint(0, D//2 - 1)
        t = random.randint(1, 13)
        org_t = ans[d]
        ans[d] = sorted_c[t][0] + 1
        s = calc_score(D, C, S, ans)
        if s <= score:
            ans[d] = org_t
        else:
            score = s
    print('\n'.join(map(str, ans)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 10544
#include <iostream>
#include <algorithm>
#include <string>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
    int n, m, i, h[100003], a, b, ans;
    bool ir[100003] = { false };

    scanf("%d%d", &n, &m);
    for (i = 0; i < n; i++) {
        scanf("%d", &h[i]);
    }
    for (i = 0; i < m; i++) {
        scanf("%d%d", &a, &b);
        if (h[a - 1] > h[b - 1]) {
            ir[b - 1] = true;
        }
        else if (h[b - 1] > h[a - 1]) {
            ir[a - 1] = true;
        }
        else {
            ir[a - 1] = ir[b - 1] = true;
        }
    }

    ans = 0;
    for (i = 0; i < n; i++) {
        if (!ir[i]) {
            ans++;
        }
    }

    printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 4316
#include<bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
using namespace std;
long long ab(long long a) {
    return a<0? -a : a;
}
long long a[100005];
int main()
{
    int n,cnt=0;
    cin >> n;
    long long sum=0;
    for(int i=1;i<=n;i++) {
       cin >> a[i];
       if(a[i]<0) cnt++;
       sum+=ab(a[i]);
    }
    if(cnt%2==0) cout << sum;
    else {
        long long mn=1e18;
        for(int i=1;i<=n;i++) mn=min(mn,ab(a[i]));
        cout << sum-(mn << 1);
    }
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

ll combination(long n, int r) {
  ll dividend = 1;
  ll divisor = 1;
  FOR(i, 1, r+1){
    dividend *= (n-i+1);
    divisor *= i;
  }
  return dividend/divisor;
}


int main(){
  int n;
  string input;
  int march[5] = {0};
  cin >> n;
  rep(i, n){
    cin >> input;
    switch (input[0]) {
      case 'M':
        march[0] += 1;
        break;
      case 'A':
        march[1] += 1;
        break;
      case 'R':
        march[2] += 1;
        break;
      case 'C':
        march[3] += 1;
        break;
      case 'H':
        march[4] += 1;
        break;
    }
  }
  ll two = 0, marchsum = 0; // 2の可能性
  rep(i, 5){
    marchsum += march[i];
  }
  ll sum = combination(marchsum, 3); // 総数
  rep(i, 5){
    if (march[i] >= 2) {
      two += (marchsum - march[i])*combination(march[i], 2);
    }
  }
  ll three = 0; // 3の可能性
  rep(i, 5){
    three += combination(max(march[i], 0), 3);
  }
  puts(sum - two - three)
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int W, a, b;
    cin >> W >> a >> b;
    if(abs(a - b) <= W) puts("0");
    else cout << abs(a - b) - W << endl;
}


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

int main() {
    int H, W;
    cin >> H >> W;

    char a[H][W];
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin >> a[i][j];
        }
    }

    // 行について探索
    int line[H];
    for (int i=0; i<H; i++) {
        int flag = 0;
        for (int j=0; j<W; j++) {
            if (a[i][j] == '#') {
                flag++;
            }
        }
        if (flag == 0) {
            line[i] = 1;
        } else {
            line[i] = 0;
        }
    }

    // 列について探索
    int column[W];
    for (int j=0; j<W; j++) {
        int flag = 0;
        for (int i=0; i<H; i++) {
            if (a[i][j] == '#') {
                flag++;
            }
        }
        if (flag == 0) {
            column[j] = 1;
        } else {
            column[j] = 0;
        }
    }

    // 出力
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (line[i] == 0 && column[j] == 0) {
                cout << a[i][j];
            }
        }
        if (line[i] == 0){
            cout << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
n=int(input())
elements= input().split()
q=int(input())
actions=[]
for i in range(q):
    actions.append(input().split())
 
dict={}
for e in elements:
    count=dict.get(e,0)
    count+=1
    dict[e]=count
 
sum=0
for key in dict.keys():
    sum+=int(key)* dict[key]

for act in actions:
    count=dict.get(act[0],0)
    sum+=(int(act[1])-int(act[0]))*count
    count+=dict.get(act[1],0)
    dict[act[1]]=count
    dict[act[0]]=0
 
    print(str(sum))

Measured memory_bytes: 54064
#include <string>
#include <iostream>
using namespace std;
 
int main () {
    string a;
    cin >> a;
    if (a == "SUN")
        cout << 7 << endl;
    else if (a == "MON")
        cout << 6 << endl;
    else if (a == "TUE")
        cout << 5 << endl;
    else if (a == "WED")
        cout << 4 << endl;
    else if (a == "THU")
        cout << 3 << endl;
    else if (a == "FRI")
        cout << 2 << endl;
    else if (a == "SAT")
        cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d,x;
	cin>>n>>d>>x;
	int sum = 0;
	int tp=n;
	while(tp--)
	{
		int a;
		cin>>a;
		int st = 1;
		int ct=0;
		int s=1;
		while(st<=d)
		{
			ct++;
			
			st = s*a + 1;
			//cout<<st<<" ";
			s++;
		}
		//cout<<"\n";
		sum+=ct;
	}
	sum+=x;
	cout<<sum<<"\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define PI  3.141592653589793

int main(void)
{
    int a, b, degC;
    double c;
    double S, L, h;
    double radC;
    double sinC, cosC;

    scanf("%d %d %d", &a, &b, &degC);
    radC = degC * PI / 180.0;

    sinC = sin(radC);
    cosC = cos(radC);

    c = sqrt(a * a + b * b - 2 * a * b * cosC);

    S = 0.5 * a * b * sinC;
    L = a + b + c;
    h = b * sinC;

    printf("%lf\n%lf\n%lf\n", S, L, h);

    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    cin>>N;
    vec sum(N+1,0);//1-indexed
    ll a;
    rep(i,N) {
        cin>>a;
        sum.at(i+1) = sum.at(i)+a;
    }
    mat dp(N,vec(N+1,0));//dp[i][j]が[i,j)のくっつけ方
    ll INF = 5e+14;
    for(int roop = N-1;roop >= 1;--roop){
        ll N1r = N+1-roop;
        rep(i,roop){
            ll mini = INF;
            ll j = i+N1r;
            ll slime = sum.at(j)-sum.at(i);
            reps(k,i+1,j){
                mini = min(mini,dp.at(i).at(k)+dp.at(k).at(j)+slime); 
            }
            dp.at(i).at(j) = mini;
        }
    }
    cout<<dp.at(0).at(N)<<endl;
}

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

int main() {
	int n,m,q;cin>>n>>m>>q;
	vector<int> l(m),r(m),ql(q),qr(q);
	for(int i=0;i<m;i++){
		cin>>l[i]>>r[i];
		l[i]--;
		r[i]--;
	}
	for(int i=0;i<q;i++){
		cin>>ql[i]>>qr[i];
		ql[i]--;
		qr[i]--;
	}
	vector<vector<int>> v(n+1,vector<int>(n+1,0));
	for(int i=0;i<m;i++){
		v[0][r[i]]++;
		v[0][n]--;
		v[l[i]+1][r[i]]--;
		v[l[i]+1][n]++;
	}
	for(int i=0;i<=n;i++){
		for(int j=1;j<=n;j++){
			v[i][j]+=v[i][j-1];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			v[i][j]+=v[i-1][j];
		}
	}
	for(int i=0;i<q;i++){
		cout<<v[ql[i]][qr[i]]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4224
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let k: usize = iterator.next().unwrap().parse().unwrap();

    let mut mk: Vec<usize> = vec![0; k];
    for i in 1..(n + 1) {
        mk[i % k] += 1;
    }

    let mut ans: usize = 0;
    for a in 0..k {
        let b = (k - a) % k;
        let c = (k - a) % k;
        if (b + c) % k != 0 {
            continue;
        }
        ans += mk[a] * mk[b] * mk[c];
    }
    return ans.to_string();
}


Measured memory_bytes: 6396