akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; } value
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  map<string, int> memo;
  REP(i,n) {
    string s;
    cin >> s;
    memo[s] ++;
  }
  int maxi = 0;
  for (auto p : memo) maxi = max(maxi, p.second);
  for (auto p : memo) {
    if (p.second != maxi) continue;
    cout << p.first << endl;
  }
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 23808
Imports System.Text

Module Module1

    Sub Main()
        Dim ans As String = ""

        Dim getvaluelength As Integer


        Dim mojiretu As String = Console.ReadLine()

        Dim guusuu As Integer = CInt(mojiretu.Split(" "c)(0))
        Dim kisuu As Integer = CInt(mojiretu.Split(" "c)(1))

        ans = (((guusuu * (guusuu - 1)) / 2) + ((kisuu * (kisuu - 1)) / 2)).ToString

        Console.WriteLine(ans)
        Console.ReadKey()





    End Sub




End Module

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

int main()
{
    string S;
    cin >> S;
    int num = 0;
    int tmp = 0;
    for (int i = 0; i < S.length(); i++)
    {

        if ((S[i] == 'A') || (S[i] == 'G') || (S[i] == 'C') || (S[i] == 'T'))
        {
            tmp += 1;
            num = max(tmp, num);
        }
        else
        {
            tmp = 0;
        }
    }

    cout << num;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

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

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	REP(i, t) fact[i+1]=fact[i]*(i+1)%MOD;
	fact_inv[t]=power(fact[t], MOD-2);
	FORR(i, 0, t) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}
  
int main()
{
  ll a,b,v,w,t; cin >> a >> v >> b >> w >> t;
  ll dist, speed, sec;

  if(v <= w){cout << "NO" << endl; return 0;}
  dist = abs(a - b);
  speed = v - w;
  sec = dist / speed; if(dist % speed != 0){sec++;}
  //if(dist % speed != 0){cout << "NO" << endl; return 0;}
  if(sec > t){cout << "NO" << endl; return 0;}
  cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<LL, LL>> a(n); // <美味しさ, ネタ>
  map<LL, LL> mp;
  priority_queue<pair<LL, LL>, vector<pair<LL, LL>>, greater<pair<LL, LL>>> PQ;
  rep(i, n) cin >> a[i].second >> a[i].first;

  sort(all(a));
  reverse(all(a));

  LL sum = 0;
  for (int i = 0; i < k; i ++) {
    mp[a[i].second] ++;
    if (mp[a[i].second] > 1) PQ.push(make_pair(a[i].first, a[i].second));
    sum += a[i].first;
  }
  
  LL ans = sum + (mp.size() * mp.size());
  pair<LL, LL> t;
  for (int i = k; i < n; i ++) {
    if (!PQ.empty() && mp.find(a[i].second) == mp.end()) {
      t = PQ.top(); PQ.pop();
      mp[a[i].second] ++;
      sum -= t.first;
      sum += a[i].first;
      ans = max(ans, sum + (LL)(mp.size() * mp.size()));
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 6648
#include <iostream>

int D, N;

int main(){

  std::cin >> D >> N ;

  int h = 1;

  if(D == 2) h = 10000;
  if(D == 1) h = 100;
  if(N == 100){
    std::cout << h*100 + h<< '\n';
  }
  else  std::cout << N*h << '\n';

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

#define MAXN 200200
#define MAXE 400400

typedef pair<int, int> pii;
#define X first
#define Y second
const LL INF = (1LL << 62) | 3;
#define Debug(...) fprintf(stderr, __VA_ARGS__)

template <typename T> inline void read(T &x) {
    int ch = getchar();
    bool fg = false;
    for (x = 0; !isdigit(ch); ch = getchar()) {
        if (ch == '-') {
            fg = true;
        }
    }
    for (; isdigit(ch); ch = getchar()) {
        x = x * 10 + ch - '0';
    }
    if (fg) {
        x = -x;
    }
}

template <typename T> inline bool chkmin(T& x, const T& y) { return y < x ? (x = y, true) : false; }
template <typename T> inline bool chkmax(T& x, const T& y) { return x < y ? (x = y, true) : false; }

int a[6], n, m, k = 1000;

signed main() {
	for(int i = 1; i <= 5; i++) read(a[i]);
	for(int i = 1; i <= 5; i++) k = min(k, a[i] % 10 == 0 ? 1000 : a[i] % 10);
	for(int i = 1; i <= 5; i++) a[i] = (a[i] + 9) / 10 * 10;
	if(k == 1000) printf("%d\n", a[1] + a[2] + a[3] + a[4] +a[5]);
	else printf("%d\n", a[1] + a[2] + a[3] + a[4] +a[5] + k - 10);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll  long long
#define endl '\n'
#define pi 3.14159265
ll n,a;
vector<ll> v(51);
ll dp[51][3000][25];
ll f(ll i,ll sum,ll len)
{
    if(i==n)
        return (len*a==sum);
    if(dp[i][sum][len]!=-1)
        return dp[i][sum][len];
    dp[i][sum][len]=f(i+1,sum,len)+f(i+1,sum+v[i],len+1);
    return dp[i][sum][len];
}
int main()  
{     
    cin>>n>>a;
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++)
        cin>>v[i];
    cout<<f(0,0,0)-1;
}   

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


const int maxn = 2e5 + 5;
int ind[maxn];

int main() {
    int n;
    cin >> n;
    for (int i = 2; i<= n; ++i) {
        int x;
        cin >> x;
        ind[x]++;
    }
    for (int i = 1; i <= n; ++i) {
        cout << ind[i] << endl;
    }

}

Measured memory_bytes: 4328
import sys
input = sys.stdin.readline


def main():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    res1 = a * x + b * y
    res2 = c * max(x, y)
    res3 = c * x + max(0, y-x) * b
    res4 = c * y + max(0, x-y) * a
    print(min([res1, res2, res3, res4]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9040
#include<stdio.h>
#define ll long long
int main()
{
    ll n, m;
    while(scanf("%lld%lld", &n, &m)!=EOF)
    {
        ll ans=0;
        if(m/2>n) ans+=n+(m-2*n)/4;
        else ans+=m/2;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

int main() {
  int n, r, t;

  std::cin >> n;

  for (int i = 0; i < n; ++i) {
    std::cin >> r >> t;
    
    int j = t / 30 * 5 + r / 100;

    if (r % 100 == 0 && t % 30 == 0) {
      std::cout << j << std::endl;
    } else if (r % 100 != 0 && t % 30 == 0) {
      std::cout << j << " " << j + 1 << std::endl;
    } else if (r % 100 == 0 && t % 30 != 0) {
      std::cout << j << " " << j + 5 << std::endl;
    } else {
      std::cout << j << " " << j + 1 << " " << j + 5 << " " << j + 6 << std::endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <cstdlib>
#include <memory>
#include <queue>
#include <cassert>
#include <cmath>
#include <ctime>
#include <complex>
#include <bitset>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

#define ws ws_____________________
#define y1 y1_____________________
#define y0 y0_____________________
#define left left_________________
#define right right_______________
#define next next_________________
#define prev prev_________________
#define hash hash_________________

#define pb push_back
#define fst first
#define snd second
#define mp make_pair 
#define sz(C) ((int) (C).size())
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define ford(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define all(C) begin(C), end(C)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
typedef complex<double> cd;

#ifdef LOCAL
#define eprintf(args...) fprintf(stderr, args), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define FILE_NAME "a"

int n;

bool read() {
	if  (scanf("%d", &n) < 1) {
		return 0;
	}
	return 1;
}

void solve() {

}

int main() {
#ifdef LOCAL
	freopen(FILE_NAME ".in", "r", stdin);
	// freopen(FILE_NAME ".out", "w", stdout);
#endif

	string s;
	cin >> s;
	cout << s.substr(0, sz(s) - 8) << endl;
	return 0;
	
	while (read()) {
		solve();
	}

#ifdef LOCAL
	cerr.precision(5);
	cerr << "Time: " << fixed << (double) clock() / CLOCKS_PER_SEC << endl;
#endif
	return 0;
}


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

int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= 9; i++) for (int j = 1; j <= 9; j++) if (i * j == n) {
    cout << "Yes\n";
    return 0;
  }
  cout << "No\n";
}

Measured memory_bytes: 256
n = int(input())
flag = False
for i in range(int(n/4)+1):
    for j in range(int(n/7)+1):
        if i==0 and j==0:
            continue
        if n%((4*i)+(7*j)) == 0:
            flag = True
            break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();

    let state = (0..n).map(|_| (read(), read(), read())).collect::<Vec<(i32, i32, i32)>>();
    // 0,0 -> が最低なんステップ化だし、それ以上ならOkとする

    let mut t_ = 0;
    let mut x_ = 0;
    let mut y_ = 0;
    let mut ans = "Yes";
    for &(t, x, y) in state.iter() {

        let dt = t - t_;
        let dx = x - x_;
        let dy = y - y_;
        let dist = dx.abs() + dy.abs();

        // その場にとどまれないので、必ずステップと時間は一致
        if dist > dt || dt % 2 != dist % 2 {
            ans = "No";
            break
        }

        t_ = t;
        x_ = x;
        y_ = y;

    }

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



Measured memory_bytes: 4352
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int h, w;
  cin >> h >> w;
  vv<char> a(h, vector<char>(w));
  rep (i, h) {
    rep (j, w) {
      cin >> a[i][j];
    }
  }

  rep (isum, h+w-1) {
    int flag = 0;
    rep (jh, h) {
      int jw = isum - jh;
      if (!(0 <= jw && jw < w)) {
        continue;
      }
      if (a[jh][jw] == '#') {
        flag += 1;
      }
    }
    if (flag > 1) {
      printf("Impossible\n");
      return 0;
    }
  }
  printf("Possible\n");

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define ld long double
#define uint unsigned int
#define endl '\n'
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define eb emplace_back 
#define pll pair<long long ,long long > 
#define ppll pair < pll , pll > 
#define pd pair<int, int>
#define ppdd pair<pd, pd>
#define vd vector<int>
#define sd(x) scanf("%d",&x) 
#define sld(x) scanf("%lld",&x) 
#define deb(x) { cerr << #x << '=' << x << '\n'; }
#define tc(x) sd(x); while(x--)
#define INF 1e18 
#define eps 0.00001 
#define le length 
#define inc(il)
using namespace std;

void solve(){
    //code goes here
    int res=0;
    string s;
    cin >> s;
    for (int i = 0; i<s.size(); ++i){
        res+=s[i]-'0';
    }
    if (res%9==0) cout << "Yes";
    else cout << "No";
}

int main(){
    ios::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL); 
    solve();
    return 0;
}


Measured memory_bytes: 3660
// Author : Syed Mujtaba
// Seek knowledge from the Cradle to the Grave !!
// https://www.linkedin.com/in/syed-mujtaba

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define int             long long
#define ld              long double
#define ll              long long
#define pb              push_back
#define fi              first
#define se              second
// #define mod             1000000007  //998244353// 1e9 + 7
int mod = 1e9;
int modd = 1e9;
#define inf             1000000007 // 1e9 + 7
#define MAX             8000000000000000064LL
#define MIN            -8000000000000000064LL
#define MAXN 			10000004
#define mt 				make_tuple
#define eps             1e-6
#define endl			'\n'
#define test            int t; cin>>t; while(t--)
#define fast_io         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// #define tree            tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
// int fact[1000007]={0};
// int spf[(int)(1e7) + 20];
// bool prime[(int)((1e7) + 20)];
// int gcd(int a,int b){if(b==0)return a; return gcd(b,a%b);}
// void sp(int n){spf[1]=1;for(int i=2;i<n;i++)spf[i]=i;for(int i=4;i<n;i+=2)spf[i]=2;for(int i=3;i*i<n;i++){if(spf[i]==i){for(int j=i*i;j<n;j+=i)if(spf[j]==j)spf[j]=i;}}}
// void sieve(int n){memset(prime,true,sizeof(prime) );for(int p=2;p*p<=n;p++){if(prime[p]==true)for(int i=p*p;i<=n;i+=p)prime[i]=false;}prime[0]=false;prime[1]=false;}
// int xyp(int x,int y){int res=1;while(y>0){if(y%2==1) res=(res*x)%mod;x=(x*x)%mod;y/=2;}return res%mod;}
// int inv(int x){return xyp(x,mod - 2);}
// int inv_euclid(int a, int m = mod){int m0 = m;int y = 0, x = 1;if (m == 1)return 0;while (a > 1){int q = a / m;int t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
// void init() {fact[0]=1;fact[1]=1;for(int i=2;i<1000007;i++)fact[i]=(fact[i-1]*i)%mod;}
// int ncr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[r],mod-2)))%mod; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res;}
// int npr(int n,int r) {int res=1; res=fact[n]; res=(res*(xyp(fact[n-r],mod-2)))%mod; return res; }
// bool isp(int a){if(a == 2)return true;if(a == 1)return false;for(int x= 2; x <= sqrt(a) + 1; x++)if(a % x == 0)return false;return true;}
// int add(int a, int b){return (a%mod + b%mod + mod)%mod;}
// int sub(int a, int b){return (a%mod - b%mod + mod)%mod;}
// int mul(int a, int b){return ((a%mod)*(b%mod) + mod)%mod;}
// #define p_set tree< pair<int,int> ,  null_type ,  less<pair<int,int>> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// #define i_set tree< int ,  null_type ,  less< int > ,  rb_tree_tag ,  tree_order_statistics_node_update>
// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
// int dx[] = {1, -1, 0};
// int dy[] = {1, -1, 0};
signed main()
{
	fast_io
	ld r;
	cin >> r; 
	r *= 2.00000000000000*acos(-1);
	cout << fixed << setprecision(10) << r << endl;
}


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

bool is_exist[26];

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        if (is_exist[int(s[i] - 'a')]) {
            cout << "no" << endl;
            return 0;
        }
        is_exist[int(s[i] - 'a')] = true;
    }
    cout << "yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  string s;
  cin >> s;
  int i,n;
  int count = 0;
  long long move = 0;
  n = s.size();
  for(i = 0; i < n; i++)
  {
    if(s.at(i) == 'W')
    {
      move += i - count;
      count++;
    }
  }
  cout << move << endl;
}

Measured memory_bytes: 640
import sys
A=range(12)
m=[[0 for i in A] for j in A]
def LRUD(y,x,d):
    P=[]
    x+=d[0]
    y+=d[1]
    if 0<=x<12 and 0<=y<12 and m[y][x]==1:
        m[y][x]=c
        P=[(y,x)]
    return P
def v1(buf):
    while len(buf)>0:
        y,x=buf.pop()
        m[y][x]=c
        for e in [(-1,0),(1,0),(0,-1),(0,1)]:
            buf+=LRUD(y,x,e)
    return
def solve():
    global c
    c=2
    for i in A:
        x=m[i]
        while x.count(1)>0:
            v1([(i,x.index(1))])
            c+=1
    print c-2
    return 0

y=0
for s in sys.stdin:
    if y<12:
        x=0
        for e in map(int,list(s[:-1])):
            m[y][x]=e
            x+=1
        y+=1
    else:
        y=solve()
solve()

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

l = []

for i in range(1, n+1):
    l.append([a[i-1], i])

l.sort()

ans = []

for i in range(n):
    ans.append(l[i][1])

ans = list(map(str, ans))

print(" ".join(ans))

Measured memory_bytes: 28624
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

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 U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

ll dp[55][55][2550];
int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n,a;
    cin >> n >> a;
    vector<ll> x(n+2);
    rep(i,n) cin >> x[i];
    // i枚目まで考えた時j枚選んで総和がkになる通り
    dp[0][0][0] = 1;
    rep(i,n){
      rep(j,i+1){
        rep(k,2501){
          dp[i+1][j+1][k + x[i]] += dp[i][j][k];
          dp[i+1][j][k] += dp[i][j][k];
        }
      }
    }
    ll ans = 0;
    REP(i,1,n+1){
      ans += dp[n][i][a * i];
    }
    print(ans);
}

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

int main()
{
  	long long int n; cin >> n;
  	vector<long long int> a(n);
  	for(auto &x: a) cin >> x;
  	
  	long long int money = 1000;
  	for(int i = 0 ; i < n - 1 ; i++) {
    	long long int stocks = money/a[i];
      	money += stocks*max(a[i+1] - a[i], 0LL);
    }
  	cout << money << endl;
  	return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

/**
 * Created by wenjian on 2017/2/4.
 */
public class Main{
    public static void main(String[] args) {
        Scanner reader = new Scanner(System.in);
        int n = reader.nextInt();
        int[] a = new int[n];
        for (int i=0; i<a.length; ++i) a[i] = reader.nextInt();
        int sum = 0;
        for (int i=0; i<a.length; ++i) {
            if (a[i] % 2 == 1) ++sum;
        }
        if (sum % 2 == 0) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 33524
using System;
class Problem
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        if(str[0] != str[1] && str[1] != str[2] && str[2] != str[3])
        {
            Console.WriteLine("Good");
        }
        else { Console.WriteLine("Bad"); }
    }
}

Measured memory_bytes: 13140
#include <iostream>

using namespace std;

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  for(int i=0;i<k;i++){
    if(i&1){
      b/=2;
      a+=b;
    }
    else{
      a/=2;
      b+=a;
    }
  }
  cout<<a<<" "<<b;
}
    


Measured memory_bytes: 3632
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
using pp=pair<P,int>;
int main(){
  int n;
  cin>>n;
  V<bool> used(n,false);
  priority_queue<pp,V<pp>,greater<pp>> l,tmpl;
  priority_queue<pp> r,tmpr;
  for(int i=0;i<n;i++){
    P a;
    cin>>a.fi>>a.se;
    r.emplace(a,i);
    tmpr.emplace(a,i);
    swap(a.fi,a.se);
    l.emplace(a,i);
    tmpl.emplace(a,i);
  }
  ll ans=0,bfo=0;
  while(l.size()&&r.size()){
    while(l.size()){
        pp p=l.top();
        l.pop();
        if(used[p.se])continue;
        used[p.se]=1;
        if(p.fi.se<=bfo&&bfo<=p.fi.fi)break;
        if(p.fi.fi<=bfo&&bfo<=p.fi.se)break;
        ans+=min(abs(bfo-p.fi.fi),abs(bfo-p.fi.se));
        bfo=p.fi.fi;
        break;
    }
    while(r.size()){
        pp p=r.top();
        r.pop();
        if(used[p.se])continue;
        used[p.se]=1;
        if(p.fi.se<=bfo&&bfo<=p.fi.fi)break;
        if(p.fi.fi<=bfo&&bfo<=p.fi.se)break;
         ans+=min(abs(bfo-p.fi.fi),abs(bfo-p.fi.se));
        bfo=p.fi.fi;
        break;
    }
  }
   ans+=abs(bfo);
   ll res=0;
   while(tmpl.size()){
     l.push(tmpl.top());
     tmpl.pop();
   }
      while(tmpr.size()){
     r.push(tmpr.top());
     tmpr.pop();
   }
   bfo=0;
   used.assign(n,false);
     while(l.size()&&r.size()){
    while(r.size()){
        pp p=r.top();
        r.pop();
        if(used[p.se])continue;
        used[p.se]=1;
        if(p.fi.se<=bfo&&bfo<=p.fi.fi)break;
        if(p.fi.fi<=bfo&&bfo<=p.fi.se)break;
        res+=min(abs(bfo-p.fi.fi),abs(bfo-p.fi.se));
        bfo=p.fi.fi;
        break;
    }
    while(l.size()){
        pp p=l.top();
        l.pop();
        if(used[p.se])continue;
        used[p.se]=1;
        if(p.fi.fi<=bfo&&bfo<=p.fi.se)break;
        if(p.fi.se<=bfo&&bfo<=p.fi.fi)break;
         res+=min(abs(bfo-p.fi.fi),abs(bfo-p.fi.se));
        bfo=p.fi.fi;
        break;
    }
  }
  chmax(ans,res+abs(bfo));
   cout<<ans<<"\n";
}

Measured memory_bytes: 16500
#include <iostream>
#include <vector>
#include <string>
#include <cfenv>
#include <cmath>
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <deque>
#include <cstring>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;

  char tmp;
  vector<vector<int>> data(h, vector<int>(w));
  vector<vector<int>> L(h, vector<int>(w));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> tmp;
      if(tmp == '.') data[i][j] = 1;
      else data[i][j] = 0;
    }
  }

  for(int i=0; i<h+w-1; i++){
    for(int j=max(0,i-w+1); j<min(i+1,h); j++){
      if(data[j][i-j]==1){
        if(j==0&&(i-j)==0) L[0][0] = 0;
        else if(j==0){
          L[j][i-j] = L[j][i-j-1];

        }
        else if(i-j==0){
          L[j][i-j] = L[j-1][i-j];

        }
        else L[j][i-j] = min(L[j][i-j-1],L[j-1][i-j]);
      }
      else{
        if(j==0&&(i-j)==0){
          L[0][0] = 1;
        }
        else if(j==0){
          L[j][i-j] = L[j][i-j-1]+data[j][i-j-1];
        }
        else if(i-j==0){
          L[j][i-j] = L[j-1][i-j]+data[j-1][i-j];
        }
        else L[j][i-j] = min(L[j][i-j-1]+data[j][i-j-1],L[j-1][i-j]+data[j-1][i-j]);
      }
    }
  }

  cout << L[h-1][w-1];

  return 0;
}


Measured memory_bytes: 384
/*
 © 2020-09-26 07:00:12 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
// #include <atcoder/all>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
// using namespace atcoder;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
const lli N = 2e5 + 5;
const lli MOD = 998244353;
lli pot[N];
struct segtree{
  #define mid (l + r) / 2
  #define left(u) (u + 1)
  #define right(u) (u + ((mid - l + 1) << 1))
  struct node{
    lli s, z;
    node(lli s = 0, lli z = 0): s(s), z(z) {}
    node operator + (const node & n){
      return node((s + n.s + MOD) % MOD);
    }
  };
  vector<node> st;
  segtree(int n): st(2 * n) {}
  void push(int u, int l, int r){
    if(st[u].z){
      lli foo = (pot[l] - pot[r + 1] + MOD) % MOD;
      st[u].s = st[u].z * foo % MOD;
      if(l < r){
        st[left(u)].z = st[u].z;
        st[right(u)].z = st[u].z;
      }
      st[u].z = 0;
    }
  }
  void update(int u, int l, int r, int ll, int rr, lli dd){
    push(u, l, r);
    if(l > r or r < ll or l > rr) return;
    if(ll <= l and r <= rr){
      st[u].z += dd;
      push(u, l, r);
      return;
    }
    push(u, l, r);
    update(left(u), l, mid, ll, rr, dd);
    update(right(u), mid + 1, r, ll, rr, dd);
    st[u] = st[left(u)] + st[right(u)];
  }
};
int main(){ _
  lli n, q; cin >> n >> q;
  pot[n + 1] = 0;
  pot[n] = 1;
  for(lli i = n - 1; i >= 0; i--){
    pot[i] = pot[i + 1] * 10ll % MOD;
  }
  for(lli i = n - 1; i >= 0; i--){
    pot[i] = (pot[i] + pot[i + 1] + MOD) % MOD;
  }
  // fore(i, 0, n + 1) cout << pot[i] << ' '; cout << ENDL;
  segtree st(n);
  st.update(0, 1, n, 1, n, 1);
  while(q--){
    lli l, r, d; cin >> l >> r >> d;
    st.update(0, 1, n, l, r, d);
    cout << st.st[0].s << ENDL;
  }
  return 0;
}


Measured memory_bytes: 11136
n,Y=input().split(" ")
n=int(n)
Y=int(Y)
y=Y/1000
def counting(n,y):
    u=0
    for a in range(n+1):
        u=n-a
        for b in range(u+1):
            if 9*a+4*b-y+n==0:
                c=n-(a+b)
                a=str(a)
                b=str(b)
                c=str(c)
                l=" ".join([a,b,c])
                return (l)
                break
    else:
        return("-1 -1 -1")
print(counting(n,y))

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

int main()
{
  int h, n;
  cin >> h >> n;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    h -= tmp;
  }
  if (h <= 0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys

dishes = [int(line.strip()) for line in sys.stdin]
min1 = 10
for d in dishes:
  if 0 < d%10 < min1:
    min1 = d%10
if min1 == 0:
  min1 = 10
dishes = [((d+9)//10)*10 for d in dishes]
print(sum(dishes)-(10-min1))


Measured memory_bytes: 3060
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(ReadLine());
        int[] A = new int[N];
        int[] B = new int[N];
        for(int i = 0; i < N; i++)
        {
            int[] AB = ReadLineParseIntArray();
            A[i] = AB[0];
            B[i] = AB[1];
        }
        Array.Sort(B, A);

        int time = 0;
        for(int i = 0; i < N; i++)
        {
            time += A[i];
            if(time > B[i])
            {
                WriteLine("No");
                return;
            }
        }
        WriteLine("Yes");
    }
      static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 18784
#include<stdio.h>
//小さい順にソート
int c[100002];
void merge(int i,int j,int *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]<s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}
int main(){
  int n,i;
  scanf("%d",&n);
  int a[n+1],b[n+1],c[n+1],ab[n+1],bc[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++)
    scanf("%d",&b[i]);
  for(i=0;i<n;i++)
    scanf("%d",&c[i]);
  merge(0,n-1,a);
  merge(0,n-1,b);
  merge(0,n-1,c);
  int anum=0,cnum=0;
  for(i=0;i<n;i++){
    while(a[anum]<b[i] && anum<n)
      anum++;
    ab[i]=anum;
  }
  for(i=0;i<n;i++){
    while(b[i]>=c[cnum] && cnum<n)
      cnum++;
    bc[i]=n-cnum;
  }
  long long sum=0;
  for(i=0;i<n;i++)
    sum+=(long long)ab[i]*(long long)bc[i];
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// 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;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

int solve(int A, int B){
  if((A+B)%3 != 0) return 0;

  int step = (A+B)/3;
  if(A < step || B < step) return 0;

  return comb(step, A-step);
}

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

  cout << solve(A, B) << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007 
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int n;
	cin >> n;
	vector <int> x(n), y(n);
	int a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> x[i] >> y[i];
		a[i] = i;
	}
	double ans = 0;
	int c = 0;
	do
	{
		double res = 0;
		for (int i = 1; i < n; i++)
		{
			res += sqrt((x[a[i]] - x[a[i - 1]]) * (x[a[i]] - x[a[i - 1]]) + (y[a[i]] - y[a[i - 1]]) * (y[a[i]] - y[a[i - 1]]));
		}
		ans += res;
		c++;
	}while(next_permutation(a, a + n));
	printf("%.10lf", ans / c);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
int main(){
    int H, W, N; cin >> H >> W >> N;
    vector<int> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    
    int map[H+1][W+1];
    int c=0;
    for(int i = 0; i < H; i++){
        if(i % 2 == 0){
            for(int j = 0; j < W; j++){
                
                if(A[c] > 0){
                    map[i][j] = c+1;
                    A[c]--;
                    if(A[c]==0)c++;
                }
            }
        }
        if(i % 2 == 1){
            for(int j = W-1; j >= 0; j--){
                if(A[c] > 0){
                    map[i][j] = c+1;
                    A[c]--;
                    if(A[c]==0)c++;
                }
            }
        }
    }
    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            cout << map[i][j] << " ";
        }
        cout << endl;
    }

}

Measured memory_bytes: 384
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<queue>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;

int main() {

	long X, Y, Z, K; cin >> X >> Y >> Z >> K;
	long A[1009] , B[1009] , C[1009];
	for (int i = 0; i < X; i++) cin >> A[i];
	for (int i = 0; i < Y; i++) cin >> B[i];
	for (int i = 0; i < Z; i++) cin >> C[i];

	long AB[5000009];
	for (int i = 0; i < X; i++) for (int j = 0; j < Y; j++) AB[Y * i + j] = A[i] + B[j];

	sort(AB, AB + X * Y);

	long ABC[5000009];
	for (int i = 0; i < K; i++) for (int j = 0; j < Z; j++) ABC[Z * i + j] = AB[X * Y - 1 - i] + C[j];

	sort(ABC, ABC + K * Z);

	for (int i = 0; i < K; i++) cout << ABC[K * Z - 1 - i] << endl;
}

Measured memory_bytes: 36096
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<tuple>
#include<stdio.h>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int long long a, b;
	cin>>a>>b;
	if(a==1 || b==1)
		cout<<1<<endl;
	else
		cout<<(a*b+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
#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;
	}
};

///////////////////////////
ll N, M;

vector<vector<ll>> g;
vector<ll> col;

bool dfs(ll v) {
	for (ll w : g[v]) {
		if (col[w] == -1) {
			col[w] = (col[v] + 1) % 2;
			bool b = dfs(w);
			if (b == 0) { return 0; }
		}

		else {
			if (col[w] == col[v]) { return 0; }
		}
	}

	return 1;
}

int main() {

	cin >> N >> M;
	g.resize(N + 1);

	repn(i, M) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	col.assign(N + 1, -1);

	col[1] = 0;
	bool b = dfs(1);

	if (b == 0) {
		cout << N * (N - 1) / 2 - M;
	}
	else {
		ll nm[2] = {};
		repn(i, N) { nm[col[i]]++; }
		cout << nm[0] * nm[1] - M;
	}
	

	system("PAUSE");
}


Measured memory_bytes: 7540
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

double N,M,X;

signed main(){
	cin>>N>>M>>X;
	if(X==0){
		cout<<fixed<<setprecision(10)<<(1.0/N)*(M-1)<<endl;
		return 0;
	}
	cout<<fixed<<setprecision(10)<<(2*(N-X))/(N*N)*(M-1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int a, b, c;
	scanf("%d%d%d", &a , &b, &c);
	printf("%d", a + b + c - max(max(a, b), c));








}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			int[] result = new int[n];
			Arrays.fill(result, 0);
			IntStream.range(0, 2 * m).forEach(i -> result[scanner.nextInt() - 1]++);
			Arrays.stream(result).forEach(System.out::println);
		}
	}
}


Measured memory_bytes: 36228
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  vector<int> A{1,3,5,7,8,10,12};
  vector<int> B{4,6,9,11};
  int x,y;
  cin >> x >> y;
  if(x == 2 || y == 2){
    cout << "No" << endl;
    return 0;
  }
  bool X,Y;
  X = Y = false;
  for(int i=0; i<7; i++){
    if(x == A[i]){
      X = true;
    }
    if(y == A[i]){
      Y = true;
    }
  }
  if(X && Y){
    cout << "Yes" << endl;
    return 0;
  }else if(!X && !Y){
    cout << "Yes" << endl;
    return 0;
  }else{
    cout << "No" << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
using llong = long long;

llong n, m;
llong s, t, e;
llong l;
llong b[10005];
map<llong, llong> mp[10005];

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

    cin >> s >> t >> e;
    while (s != 0 && t != 0 && e != 0) {
        mp[s][t] = e;
        cin >> s >> t >> e;
    }

    cin >> l;
    for (int i = 0; i < l; i++) {
        for (int j = 1; j <= m; j++) {
            cin >> b[j];
        }

        for (int j = 1; j <= n; j++) {
            llong c = 0;

            for (auto x:mp[j]) {
                c += b[x.first] * x.second;
            }

            if (j > 1) cout << ' ';
            cout << c;
        }
        cout << '\n';
    }

    return 0;
}



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

int main(){
  int N;
  cin>>N;
  
  int X[N];
  for(int i=0;i<N;i++)cin>>X[i];
  int ans=10000000;
  
  for(int p=1;p<=100;p++){
    int tairyoku=0;
    for(int i=0;i<N;i++){
      tairyoku+=(X[i]-p)*(X[i]-p);
    }
    if(tairyoku<ans)ans=tairyoku;
  }
   cout<<ans<<endl; 

}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    int N;
    int K;
    long long A[100010];
    long long B[100010];
    long long CAN[30];


    cin >> N >> K;

    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }

    CAN[0] = K;
    int count = 1;
    for(int i=0;i<30;i++){
        if((K & 1<<i) == 1<<i){
            CAN[count] = (K - (1<<i)) | ((1<<i) - 1);
            count++;
        }
    }

    long long res = 0;
    long long tmp_sum = 0;
    for(int i=0;i<count;i++){
         for(int ii=0;ii<N;ii++){
            if((CAN[i] | A[ii]) == CAN[i]){
                tmp_sum += B[ii];
                /*cout << CAN[i] << ' ' << A[ii] << ' ' << B[ii] << endl;*/
            }
        }
        res = max(res, tmp_sum);
        tmp_sum = 0;
    }
    /*
    for(int ii=0;ii<N;ii++){
        if(CAN[0] == A[ii]){
            tmp_sum += B[ii];
        }
    }
    */
    res = max(tmp_sum, res);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
import sys
import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal

sys.setrecursionlimit(10000001)
INF = sys.maxsize
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    w, h, n = ns()

    max_x = -1
    min_x = INF
    max_y = -1
    min_y = INF

    for _ in range(n):
        x, y, a = ns()

        if a == 1:
            max_x = max(max_x, x)
        elif a == 2:
            min_x = min(min_x, x)
        elif a == 3:
            max_y = max(max_y, y)
        elif a == 4:
            min_y = min(min_y, y)

    if max_x == -1:
        max_x = 0
    if min_x == INF:
        min_x = w
    if max_y == -1:
        max_y = 0
    if min_y == INF:
        min_y = h

    len_x = max(0, min_x - max_x)
    len_y = max(0, min_y - max_y)

    print(len_x * len_y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10588
n, m, k = gets.chomp.split.map(&:to_i)
a = [0]
max = 0
gets.chomp.split.map(&:to_i).each do |e|
  a << a.last + e
end

b = [0]
gets.chomp.split.map(&:to_i).each do |e|
  b << b.last + e
end

b_index = b.count - 1
a.each.with_index do |ae, ai|
  remain_k = k - ae
  break if remain_k < 0

  b_index.downto(0) do |bi|
    b_index = bi
    break if remain_k - b[bi] >= 0
  end
  max = [max, ai + b_index].max
end

p max

Measured memory_bytes: 50904