akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class A_167_Registration
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();
            string r = Console.ReadLine();
            

            if (s == r.Substring(0, r.Length - 1))
            {
                string result = "Yes";
                Console.WriteLine(result);
            }
            else
            {
                string result = "No";
                Console.WriteLine(result);
            }

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 25820
#include "bits/stdc++.h"

using namespace std;

void Main() {
    string s;
    cin >> s;

    string ans = "";
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'B') {
            if (ans.size() > 0) {
                ans = ans.substr(0, ans.size() - 1);
            }
        }
        else {
            ans += s[i];
        }
    }

    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using ll = long long int;
using ul = unsigned long long int;
const ll LL_MAX (1LL<<60);
const ll MOD (1000000007);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    rep(i,0,n) cin >> c[i];
    
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll cnt(0);
    for (ll i=0; i<n; ++i)
    {
        ll ai = lower_bound(a.begin(), a.end(), b[i]) - begin(a);
        ll ci = n - (upper_bound(c.begin(), c.end(), b[i]) - begin(c));
        cnt += ai * ci;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 2560
[n, m] = map(int, input().split())
a = [list(map(int, input().split())) for i in range(n)]
b = [int(input()) for i in range(m)]

d = [sum([a[i][j]*b[j] for j in range(m)]) for i in range(n)]
for i in range(n):
    print(d[i])

Measured memory_bytes: 7908
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long A, B, C;
    scan(A, B, C);
    long x = 2 * (A + B);
    if (x < C)
    {
        writeln("Yes");
        return;
    }
    writeln((cast(real)(A + B) + 2 * sqrt(cast(real)(A * B)) < (cast(real) C)) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int H,W,h,w,cnt=0;
    scanf("%d %d",&H,&W);
    scanf("%d %d",&h,&w);
    cnt=(H-h)*(W-w);
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cstdlib>
#include <climits>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <string>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

namespace bit {
template <typename Tp>
int log2p1(Tp n) {
  if (n == 0) return 0;
  return (CHAR_BIT * sizeof(long long)) - __builtin_clzll(n);
}

template <typename Tp>
Tp ceil2(Tp n) {
  if (n == 0) return 1;
  return Tp{1} << log2p1(n-1);
}

template <typename Tp>
int ctz(Tp n) {
  return __builtin_ctzll(n);
}
}  // bit::

namespace detail {
template <typename Tp, size_t N>
std::vector<Tp> make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N == 1), Tp const&>::type x
) {
  return std::vector<Tp>(sizes[0], x);
}
template <typename Tp, size_t N>
auto make_vector(
    std::vector<size_t>& sizes,
    typename std::enable_if<(N > 1), Tp const&>::type x
) {
  size_t size = sizes[N-1];
  sizes.pop_back();
  return std::vector<decltype(make_vector<Tp, N-1>(sizes, x))>(
      size, make_vector<Tp, N-1>(sizes, x)
  );
}
}  // detail::

template <typename Tp, size_t N>
auto make_vector(size_t const(&sizes)[N], Tp const& x) {
  std::vector<size_t> s(N);
  for (size_t i = 0; i < N; ++i) s[i] = sizes[N-i-1];
  return detail::make_vector<Tp, N>(s, x);
}

int main() {
  size_t h, w;
  scanf("%zu %zu", &h, &w);

  auto a = make_vector<intmax_t>({h, w}, 0_jd);
  auto b = a;
  for (auto& ai: a)
    for (auto& aij: ai) scanf("%jd", &aij);
  for (auto& bi: b)
    for (auto& bij: bi) scanf("%jd", &bij);

  auto d = a;
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j)
      d[i][j] = std::abs(a[i][j]-b[i][j]);

  size_t kmax = 80*80;
  auto dp = make_vector<bool>({h, w, kmax+1}, false);
  dp[0][0][d[0][0]] = true;
  for (size_t i = 0; i < h; ++i)
    for (size_t j = 0; j < w; ++j) {
      for (size_t k = 0; k <= kmax; ++k) {
        size_t k0 = k-d[i][j];
        k0 = std::min(k0, -k0);
        size_t k1 = k+d[i][j];
        k1 = std::min(k1, -k1);

        if (i-1 < h) {
          if (k0 <= kmax && dp[i-1][j][k0]) dp[i][j][k] = true;
          if (k1 <= kmax && dp[i-1][j][k1]) dp[i][j][k] = true;
        }
        if (j-1 < w) {
          if (k0 <= kmax && dp[i][j-1][k0]) dp[i][j][k] = true;
          if (k1 <= kmax && dp[i][j-1][k1]) dp[i][j][k] = true;
        }
      }
    }

  for (size_t k = 0; k <= kmax; ++k)
    if (dp[h-1][w-1][k]) return !printf("%zu\n", k);
}


Measured memory_bytes: 5760
#include <string>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
typedef long long ll;
const int mod=1000000007;
#define lol(i,n) for(int i=0;i<n;i++)

using namespace std;

int n,q,s[100010],t[50010];
//binary search;
int binarysearch(int key){
    int left=0;
    int right=n;
    int mid;
    while(left<right){
        mid=(left+right)/2;
        if(key==s[mid])return 1;
        else if(key>s[mid])left=mid+1;
        else right=mid;
    }
    return 0;
}
int main(){
    cin >> n ;
    lol(i,n)cin >> s[i];
    cin >> q;
    int ans=0,x;
    lol(i,q){
        cin >> x;
        if(binarysearch(x))ans++;
    }
    cout << ans << endl;
    }



Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,m,n) for(ll i = (m); i < (n); i++)
#define all(v) v.begin(), v.end()
#define print(x) cout << (x) << endl
//宣言
int N,M,A,ans;

int main() {
    cin >> N >> M;
    ans = N;

    rep(i,M){
        cin >> A;
        ans -= A;
    }
    cout << max(-1,ans) << endl;
    return 0;
}


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

int gcd(int a, int b);

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

    for(int i=0; i<n; i++) cin>>m[i];

    int ans=gcd(m[0],m[1]);

    for(int i=1; i<n-1; i++)ans = gcd(m[i],ans);
    

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

int gcd(int a,int b){
    int r;
    while(r = a%b){
        a=b;
        b=r;
    }

    return b;
}

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

int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;
    int score = 0;
    int max = 0;

    for(int i = 0; i < N; i++){
        if(S.at(i) == 'I'){
            score++;
            if(max < score){
                max = score;
            }
        }else{
            score--;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    for (size_t i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for (size_t i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    ll ans = 0;
    for (size_t i = 0; i < n; i++)
    {
        if (a[i] < b[i])
        {
            ans += a[i];
            if (a[i + 1] < b[i] - a[i])
            {
                ans += a[i + 1];
                a[i + 1] = 0;
            }
            else
            {
                ans += b[i] - a[i];
                a[i + 1] -= b[i] - a[i];
            }
        }
        else
        {
            ans += b[i];
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) (a).begin(),(a).end()
#define SORT(a) sort(all(a))
using ll = long long;
constexpr ll INF = 10000000000;
constexpr ll MOD = 1000000007;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	long long g = gcd(a, b);
	return a / g * b;
}

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

	string a, b, c; cin >> a >> b >> c;

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] == b[i] && b[i] == c[i])cnt += 0;
		else if (a[i] == b[i] || b[i] == c[i] || a[i] == c[i])cnt++;
		else if (a[i] != b[i] && b[i] != c[i] && a[i] != c[i])cnt += 2;
	}
	cout << cnt;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc126/tasks/abc126_b
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
    int text;
    cin >> text;
    int a = text / 100;
    int b = text % 100;
    if (a >= 1 && a <= 12 && b >= 1 && b <= 12)
        cout << "AMBIGUOUS" << endl;
    else if (a >= 1 && a <= 12)
        cout << "MMYY" << endl;
    else if (b >= 1 && b <= 12)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    return 0;
}

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

using ll = long long;
#define int ll

void min_self(int& a,int b)
{
	a = min(a,b);
}

void max_self(int& a,int b)
{
	a = max(a,b);
}

const int INF = 1e18L + 5;

int32_t main()
{
	int n,W;
	scanf("%lld%lld",&n,&W);
	vector<int> weight(n),value(n);
	for(int i=0;i<n;i++)
	{
		scanf("%lld%lld",&weight[i],&value[i]);
	}
	int sum_value = 0;
	for(int x : value)
	{
		sum_value += x;
	}
	vector<int> dp(sum_value+1,INF);
	dp[0] = 0;
	for(int item=0;item<n;item++)
	{
		for(int value_already=sum_value-value[item];value_already>=0;value_already--)
		{
			min_self(dp[value_already + value[item]],dp[value_already] + weight[item]);
		}
	}
	int answer = 0;
	for(int i=0;i<=sum_value;i++)
	{
		if(dp[i]<=W)
		{
			max_self(answer,i);
		}
	}
	printf("%lld\n",answer);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  int k = 0;
  rep(i, 3) {
    if (s.at(i) == s.at(i+1)){
      cout << "Bad" << endl;
      k++;
      break;
    }
  }
  if (k == 0) {
    cout << "Good" << endl;
  }
}


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

	int n, k; cin >> n >> k;

	ll res = 0;
	res = pow(n / k, 3);
	if (k % 2 == 0) {
		int div = (n + k / 2) / k;
		res += pow(div, 3);
	}
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)

struct task {
  int duration, deadline;
};

int main () {
  int N;
  cin >> N;
  vector<task> T(N);
  rep(i,N) cin >> T[i].duration >> T[i].deadline;

  sort(T.begin(), T.end(), [](const task&a, const task&b) {
      return a.deadline < b.deadline;
    });

  int t = 0;
  rep(i,N) {
    t += T[i].duration;
    if(t > T[i].deadline) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int table[101][101]={0};
    int r,c,i,j,R,C,Atotal=0;
    /*入力部*/
    scanf("%d %d",&r,&c);
    for(i = 0;i < r;i++){
        for(j = 0;j < c;j++){
            scanf("%d",&table[i][j]);
        }
    }
    /*出力部*/
    //printf("\n");デバッグ
    for(i = 0;i < r;i++){
        R = 0;
        for(j = 0;j < c;j++){
            printf("%d ",table[i][j]);
            R += table[i][j];
        }
        printf("%d\n",R);
    }

    for(i = 0;i < c;i++){
        R = 0;
        for(j = 0;j < r;j++){
            //printf("table:%d\n",table[j][i]);デバッグ
            R += table[j][i];
        }
        printf("%d ",R);
        Atotal += R;
    }
    printf("%d\n",Atotal);
    return 0;
}



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

int main(){
    for(ll n, m, k; cin >> n >> m >> k, n;){
        ll dp[n+1][n*m+1];
        for(ll i = 0; i <= n; i++){
            for(ll j = 0; j <= n * m; j++)dp[i][j] = 0;
        }
        dp[0][0] = 1;
        for(ll i = 0; i < n; i++){
            for(ll j = 0; j < n * m; j++){
                if(dp[i][j] == 0)continue;
                for(ll k = 1; k <= m; k++){
                    dp[i+1][j+k] += dp[i][j];
                }
            }
        }
        double a = 0, b = 0;
        for(ll i = 0; i <= n * m; i++){
            a += max(1LL, i - k) * dp[n][i];
            b += dp[n][i];
        }
        printf("%.9f\n", a / b);
    }
    return 0;
}



Measured memory_bytes: 3268
#include <stdio.h>

int	main(void)
{
  int a = 0;
 
  scanf("%d", &a);
  
  if ( a % 2 == 0)
    printf("%d\n", (a / 2));
  else
    printf("%d\n", ((a / 2) + 1));
 
  return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

const ll INF = 1LL << 61;

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    cout << char(toupper(a[0])) << char(toupper(b[0])) << char(toupper(c[0])) << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;



int main(){
	int n;
	cin >> n;
	int sum = 0;
	int i;
	for (i = 1;sum<n; i++) {
		sum += i;
	}
	cout << i-1 << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())
alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
buf = ''
for i in range(len(S)) :
    buf += alpha[(alpha.index(S[i]) + N) % 26]
print(buf)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using namespace atcoder;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
    int n;
    cin >> n;
    VI x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    VI xtoi(n);
    rep(i, n) xtoi[x[i]] = i;
    dsu d(n);
    VI ord(n);
    rep(i, n) ord[i] = i;
    sort(all(ord), [&](int i, int j){return y[i] < y[j];});
    set<int> s;
    rep(z, n) {
        int i = ord[z];
        int xi = x[i];
        auto it = s.lower_bound(xi);
        if (it != s.begin()) {
            int lm = *s.begin();
            auto itt = s.begin();
            itt++;
            for(; itt != it;) {
                auto nxtit = itt;
                nxtit++;
                d.merge(xtoi[lm], xtoi[*itt]);
                s.erase(itt);
                itt = nxtit;
            }
            d.merge(xtoi[lm], xtoi[xi]);
        } else {
            s.insert(xi);
        }
    }
    rep(i, n) cout << d.size(i) << endl;
}


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

using namespace std;
int dp[234567];

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(dp, 1000000, sizeof(dp));
  int N;
  cin >> N;
  int h[N+2];
  for(int i=1; i<=N; ++i)
    cin >> h[i];
  dp[1] = 0;
  dp[2] = abs(h[2]-h[1]);
  for(int i=3; i<=N; ++i)
  dp[i] = min(dp[i-1] + abs(h[i-1]-h[i]), dp[i-2] + abs(h[i-2]-h[i]));
  cout << dp[N] << "\n";
  return 0;
}
//.#..##.#.##.
//4 -


Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <cstring>

int n;
long long dp[31];

int main(){
    while(scanf("%d", &n), n){
        memset(dp, 0, sizeof(dp));
        
        dp[0] = 1;
        for(int j = 0; j <= n; ++j){
            for(int i = 1; i <= 3; ++i){
                if(j + i <= n)
                    dp[j + i] += dp[j];
            }
        }
        
        std::cout << dp[n] / 3650 + (dp[n] % 3650 != 0) << std::endl;
    }
    
    return 0;
}

Measured memory_bytes: 1212
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>


using namespace std;


int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		char a[1024], b[1024];
		scanf(" %s %s", a, b);
		if (strlen(a) > 80 || strlen(b) > 80)
		{
			puts("overflow");
			continue;
		}
		int aa[80], bb[80];
		memset(aa, 0, sizeof(aa));
		memset(bb, 0, sizeof(bb));
		for (int j = 0; j < strlen(a); ++j)
			aa[j] = a[strlen(a)-j-1] - '0';
		for (int j = 0; j < strlen(b); ++j)
			bb[j] = b[strlen(b)-j-1] - '0';

		int sum[81];
		memset(sum, 0, sizeof(sum));
		for (int j = 0; j < 80; ++j)
		{
			sum[j] += aa[j]+bb[j];
			sum[j+1] = sum[j]/10;
			sum[j] %= 10;
		}
		if (sum[80])
			puts("overflow");
		else
		{
			int d;
			for (d = 80; sum[d] == 0 && d > 0; --d)
				;
			for (; d >= 0; --d)
				printf("%d", sum[d]);
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for (int i = 0;;) {
			i++;
			int j = sc.nextInt();
			if (j == 0) {
				break;
			}
			System.out.printf("Case %d: %d\n", i, j);
		}
		sc.close();
	}
}

Measured memory_bytes: 66448
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val W, H = ni()
    val P = na(W)
    val Q = na(H)

    val A = Array.ofDim[(Int, Int)](W + H)
    rep(W)(i => A(i) = (P(i), 0))
    rep(H)(i => A(i + W) = (Q(i), 1))
    Sorting.quickSort(A)(Ordering.by(_._1))

    var ans = 0L
    val c = Array[Long](H + 1, W + 1)
    rep(A.length) { i =>
      val (v, x) = A(i)
      ans += c(x) * v
      c(x ^ 1) -= 1
    }

    out.println(ans)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;


int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N, M;
    cin >> N >> M;
    priority_queue<int> a;
    for(int i = 0 ; i < N; ++i){
        int tmp; cin >> tmp;
        a.push(tmp);
    }

    for(int i = 0; i < M; ++i){
        int tmp = a.top(); a.pop();
        tmp /= 2;
        a.push(tmp);
    }
    ll ans = 0;
    while(!a.empty()){
        ll tmp = a.top(); a.pop();
        ans += tmp;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

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


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

    ll N, M;
    cin >> N >> M;
    vec A(N), B(M);
    Rep (i, N) {
        cin >> A[i];
    }
    Rep (i, M) {
        cin >> B[i];
    }

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    ll a = N-1;
    ll b = M-1;

    // Rep (i, N) cout << A[i] << " \n"[i==N-1];
    // Rep (i, M) cout << B[i] << " \n"[i==M-1];

    mint ans(1);

    for (ll now = N*M; now > 0; now--) {
        // cout << "now:" << now << " " << a << " " << A[a] << " " << b << " " << B[b] << "\n";
        if (a >= 0 and A[a] == now and b >= 0 and B[b] == now) {
            a--; b--;
        } else if (a >= 0 and A[a] == now) {
            ans *= max((ll)0, M-1-b);
            a--;
        } else if (b >= 0 and B[b] == now) {
            ans *= max((ll)0, N-1-a);
            b--;
        } else {
            ans *= max((ll)0, (M-1-b)*(N-1-a)-N*M+now);
        }
        // chmax(a, (ll)0);
        // chmax(b, (ll)0);
        // cout << "now:" << now << " " << ans << endl;
    }

    cout << ans << endl;
}

// 129 147 151 158 167 168 169 175 176 178 179 180 181 182
// 150 159 167 169 173 175 176 177 178 179 180 181 182

Measured memory_bytes: 256
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(<=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)
}

private struct PriorityQueue<T: Comparable> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[child], _data[right]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[pos], data[parent]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

main()



Measured memory_bytes: 16976
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<int,bool> P;
typedef complex<double> CP;
typedef long long ll;

int main(){
	bool f=false;
	int id;
	double w,h;
	char t;
	while(cin>>id>>t>>w>>t>>h){
		if(25<=w/h/h){
			f=true;
			cout<<id<<endl;
		}
	}
	if(!f) cout<<"該当なし"<<endl;
	return 0;
}

Measured memory_bytes: 1232
#include<map>
#include<set>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<vector>
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define lc (x<<1)
#define rc (x<<1|1)
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define ll long long
#define pi pair<int,int>
using namespace std;
const int N=1010,M=3*N,size=1<<20,mod=998244353,inf=1.1e9;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	x=0; int f=1; char c=gc;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c))x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x<0) putchar('-'),x=-x;
	if(x>9) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {qw(x); putchar(' ');}
template<class o> void pr2(o x) {qw(x); puts("");}

//math
ll gcd(ll x,ll y) {return !x?y:gcd(y%x,x);}
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}
ll power(ll a,ll b=mod-2) {
	ll c=1;
	while(b) {
		if(b&1) c=c*a%mod;
		b /= 2; a=a*a%mod;
	}
	return c;
}

int n,m,a[N],b[N],c[N],d[N],e[N],f[N],x[M],xc,y[M],yc;
int getx(int t) {return lower_bound(x+1,x+xc+1,t)-x;}
int gety(int t) {return lower_bound(y+1,y+yc+1,t)-y;}

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

pi q[M*M]; int l=1,r;
bool V[M][M];
int z[M][M];
void add(int x,int y) {q[++r]=mk(x,y); V[x][y]=1;}

int main() {
	qr(n); qr(m);
	for(int i=1;i<=n;i++) {
		qr(a[i]); qr(b[i]); qr(c[i]);
		x[++xc]=a[i];
		x[++xc]=b[i];
		y[++yc]=c[i];
	}
	for(int i=1;i<=m;i++) {
		qr(d[i]); qr(e[i]); qr(f[i]);
		x[++xc]=d[i];
		y[++yc]=e[i];
		y[++yc]=f[i];
	}
	x[++xc]=-inf;
	x[++xc]=0;
	x[++xc]=inf;
	y[++yc]=-inf;
	y[++yc]=0;
	y[++yc]=inf;
	sort(x+1,x+xc+1); xc=unique(x+1,x+xc+1)-(x+1);
	sort(y+1,y+yc+1); yc=unique(y+1,y+yc+1)-(y+1);
	for(int i=1;i<=n;i++) {
		int u=getx(a[i]),v=getx(b[i]),w=gety(c[i]);
		for(int j=u;j<v;j++)
			z[j][w-1]|=1<<2,
			z[j][w]|=1<<3;
	}
	for(int i=1;i<=m;i++) {
		int u=getx(d[i]),v=gety(e[i]),w=gety(f[i]);
		for(int j=v;j<w;j++)
			z[u][j]|=1<<1,
			z[u-1][j]|=1<<0;
	}
	int sx=getx(0),sy=gety(0);
	for(int i=-1;i<=0;i++) for(int j=-1;j<=0;j++) add(sx+i,sy+j);
	while(l<=r) {
		pi now=q[l++];
		int u=now.fi,v=now.se;
		for(int t=0;t<4;t++) if((~z[u][v])>>t&1) {
			int tx=u+dx[t],ty=v+dy[t];
			if(tx&&tx<xc&&ty&&ty<yc&&!V[tx][ty]) 
				add(tx,ty);
		}
	}
	for(int i=1;i<yc;i++)
		if(V[1][i]||V[xc-1][i]) return puts("INF"),0;
	for(int j=1;j<xc;j++)
		if(V[j][1]||V[j][yc-1]) return puts("INF"),0;
	ll ans=0;
	for(int i=1;i<xc;i++)
		for(int j=1;j<yc;j++) if(V[i][j])
			ans+=(ll)(x[i+1]-x[i])*(y[j+1]-y[j]);
	pr2(ans);
	return 0;
}/*
2 2
-2 3 2
-3 5 -7
-1 -8 5
2 -9 7

*/



Measured memory_bytes: 115912
n = int(input())
link = [[] for _ in range(n)]
for i in range(n-1):
    tmp = list(map(int,input().split()))
    link[tmp[0]-1].append(tmp[1]-1)
    link[tmp[1]-1].append(tmp[0]-1)

from collections import deque
Q = deque()
Q.append(0)
visited=[-1]*n
visited[0]=1
prev=[-1]*n

while Q:
    now = Q.popleft()
    for nxt in link[now]:
        if visited[nxt]!=-1:
            continue
        visited[nxt]=1
        Q.append(nxt)
        prev[nxt]=now

rt=[n-1]
now=n-1
while prev[now]!=-1:
    now=prev[now]
    rt.append(now)
rt.reverse()
cut= -(-len(rt)//2)
f_node=rt[cut-1]
s_node=rt[cut]

Q = deque()
Q.append([0,0]) # 0 is f, 1 if s
visited=[-1]*n
visited[0]=0

while Q:
    now,fs = Q.popleft()
    for nxt in link[now]:
        nxt_fs=fs
        if now==f_node and nxt==s_node:
            nxt_fs=1
        if visited[nxt]!=-1:
            continue
        visited[nxt]=nxt_fs
        Q.append([nxt,nxt_fs])
s_score = sum(visited)
f_score = n-s_score
if s_score >= f_score:
    print("Snuke")
else:
    print("Fennec")

Measured memory_bytes: 68256
from math import factorial
def cmb(n,r):
    if n-r<0:
        return 0
    else:
        return factorial(n) // factorial(r) // factorial(n - r)
        

n,p,*a=map(int,open(0).read().split())

odd=sum(i%2 for i in a)
even=n-odd


x=sum(cmb(even,i)for i in range(even+1))
y=sum(cmb(odd,i)for i in range(p,odd+1,2))
print(x*y)



Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
#define ms(a, x) memset(a, x, sizeof(a))
#define fore(i, a, n) for (long long i = a; i < n; i++)
#define ford(i, a, n) for (long long i = n - 1; i >= a; i--)
#define si(a) scanf("%d", &a)
#define sl(a) scanf("%lld", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)
#define debug(a) cout << a << endl
#define pr(a) printf("%d ",a)
#define endl '\n'
#define pi acos(-1.0)
#define tr t[root]
#define lson t[root << 1]
#define rson t[root << 1 | 1]
#define IO ios::sync_with_stdio(false), cin.tie(0)
#define ull unsigned long long
const double eps = 1e-8;
inline int sgn(const double &x) { return x < -eps ? -1 : x > eps; }
typedef long long ll;
const int inf=0x3f3f3f3f;
const int MAXN = 3e3+10;
const int mode=1e9+7;
int N;
double p[MAXN];
double dp[MAXN][MAXN];
int main()
{
	IO;
	cin>>N;
	for(int i=1;i<=N;++i)
	{
		cin>>p[i];
	}
	dp[1][0]=1-p[1];
	dp[1][1]=p[1];
	for(int i=2;i<=N;++i)
	for(int j=0;j<=i;++j)
	dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
	int ans;
	ans=N/2+1;
	long double P=0;
	for(int j=ans;j<=N;++j)
	P+=dp[N][j];
	cout<<fixed<<setprecision(10)<<P<<endl;
 } 


Measured memory_bytes: 69120
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <queue>
using namespace  std;
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
struct Edge{
    int from, to, cost;
    Edge(int f, int t, int c){
        from = f;
        to = t;
        cost = c; 
    }
};
bool operator< (const Edge& e1, const Edge& e2){
    return e1.cost < e2.cost;
}
bool operator> (const Edge& e1, const Edge& e2){
    return e1.cost > e2.cost;
}
int makeMST(vector<vector<int>> &G, vector<vector<int>> &H){
    int N = G.size();
    int res = 0;
    int v = 0;
    priority_queue<Edge, vector<Edge>, greater<Edge> > pq;
    vector<int> visited(N, 0);
    visited[0] = 1;
    for(int i=0; i<N; i++) if(G[v][i]!=-1) pq.push(Edge(0, i, G[v][i]));
    int numv = 1;
    while(pq.size() and numv!=N){
        Edge e = pq.top(); pq.pop();
        if(visited[e.to]) continue;
        res += e.cost;
        visited[e.to] = 1;
        H[e.from][e.to] = e.cost;
        H[e.to][e.from] = e.cost;
        for(int i=0; i<N;i++){
            if(G[e.to][i]!=-1 and !visited[i]) pq.push(Edge(e.to, i, G[e.to][i]));
        }
        numv++;
    }
    return res;
}

signed main(){
    int N; cin>>N;
    vector<vector<int>> G(N, vector<int>(N));
    vector<vector<int>> H(N, vector<int>(N, -1));
    for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++){
            cin>>G[i][j];
        }
    }
    cout << makeMST(G, H) << endl;
    return 0;
}


Measured memory_bytes: 3244
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
 string s;
  int k;
  cin >> k >> s;
  int n=s.size();
  if(n<=k) cout << s << endl;
  else if(n>k){
  rep(i,k){
    cout << s.at(i) ;
  }
  cout << "..." << endl;
  }
      
}

Measured memory_bytes: 3632
#include<stdio.h>
    #include<string.h>
    int main()
    {
    	char c,s[105],t[105];
    	int i,j,n,k;
    	k=0;
    	scanf("%s",&s);
    	scanf("%s",&t);
    	n=strlen(s);
    	for(i=0;i<n;i++)
    	{
    		if(strcmp(s,t)==0)
    		{
    			k=1;break;	
    		}
    		c=s[n-1];
    		for(j=n-2;j>=0;j--)
    		s[j+1]=s[j];
    		s[0]=c;
    	}
    	if(k==0)
    	printf("No\n");
    	else
    	printf("Yes\n");
    	return 0;
    }

Measured memory_bytes: 128
using System;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            var n = int.Parse(Console.ReadLine());
            var tmp = n;

            Console.Write(n + ":");

            while(tmp % 2 == 0){
                tmp /= 2;
                Console.Write(" " + 2);
            }

            for(var i = 3; i * i <= n; i += 2){
                while(tmp % i == 0){
                    tmp /= i;
                    Console.Write(" " + i);
                }
            }

            if(tmp > 1) Console.Write(" " + tmp);
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9092
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; ++i) cin >> h[i];

  vector<int> dp(N, numeric_limits<int>::max());
  dp[0] = 0;
  for (int i = 0; i < N; ++i) {
    if (i >= 1) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
    if (i >= 2) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
  }
  cout << dp[N - 1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <limits.h>
#include <math.h>

int main() {
	int n, x, max = INT_MIN, min = INT_MAX;
	std::cin >> n;
	while (n != 0 && std::cin >> x) {
		n--; 
		if (min == INT_MAX)
			min = x;
		else {
			x - min > max ? max = x - min : 0;
			x < min ? min = x : 0;
		}
	}
	std::cout << max << "\n";
	return 0;
}



Measured memory_bytes: 3104
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
  return int(input())
def readInts():
  return list(map(int, input().split()))
def readChar():
  return input()
def readChars():
  return input().split()
def factorization(n):
  res = []
  if n%2==0:
    res.append(2)
  for i in range(3,math.floor(n//2)+1,2):
    if n%i==0:
      c = 0
      for j in res:
        if i%j==0:
          c=1
      if c==0:
        res.append(i)
  if len(res)==0:
    res = [n]
  return res
def fact2(n):
  p = factorization(n)
  res = []
  for i in p:
    c=0
    z=n
    while 1:
      if z%i==0:
        c+=1
        z/=i
      else:
        break
    res.append([i,c])
  return res
def fact(n):#階乗
  ans = 1
  m=n
  for _i in range(n-1):
    ans*=m
    m-=1
  return ans
def comb(n,r):#コンビネーション
  if n<r:
    return 0
  l = min(r,n-r)
  m=n
  u=1
  for _i in range(l):
    u*=m
    m-=1
  return u//fact(l)
def combmod(n,r,mod):
  return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
  r=copyQueue(q)
  ans=[0]*r.qsize()
  for i in range(r.qsize()-1,-1,-1):
    ans[i] = r.get()
  print(ans)
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1]*n

  def find(self, x): # root
    if self.parents[x]<0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x = self.find(x)
    y = self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y = y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -1*self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x): # much time
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
  x = 1
  zero = "0"*n
  ans = []
  ans.append([0]*n)
  for i in range(2**n-1):
    ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
    x+=1
  return ans;
def arrsSum(a1,a2):
  for i in range(len(a1)):
    a1[i]+=a2[i]
  return a1
def maxValue(a,b,v):
  v2 = v
  for i in range(v2,-1,-1):
    for j in range(v2//a+1): #j:aの個数
      k = i-a*j
      if k%b==0:
        return i
  return -1
def copyQueue(q):
  nq = queue.Queue()
  n = q.qsize()
  for i in range(n):
    x = q.get()
    q.put(x)
    nq.put(x)
  return nq
def get_sieve_of_eratosthenes(n):
  data = [2]
  #data = [0,0,0]
  for i in range(3,n+1,2):
    data.append(i)
    data.append(0)
  for i in range(len(data)):
    interval = data[i]
    if interval!=0:
      for j in range(i+interval,n-1,interval):
        data[j] = 0
  ans = [x for x in data if x!=0]
  #ans = data[:]
  return ans


a,b = readInts()

#print(a+b)
print(a*b)

Measured memory_bytes: 9476
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);

string s;

int main(void) {
	cin >> s;
	string ret = "Yes";
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') {
				ret = "No";
				break;
			}
		}
		else {
			if (s[i] == 'R') {
				ret = "No";
				break;

			}
		}
	}
	cout << ret << endl;
	return 0;

}

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

const ll mod=1000000007;

int main() {
  ll a,b,n;
  cin >> a >> b >> n;
  if(n>=b-1)n=b-1;
  cout<<(a*n/b)-a*(n/b)<<endl;
}

Measured memory_bytes: 3616
a, b, c = map(int, input().split())
L = []
for i in range(1, b+1):
  L.append(a*i%b)
L2 = list(set(L))
for i in range(len(L2)):
  for k in range(len(L2)):
    if L2[i]+L2[k] == c:
      print("YES")
      quit()
print("NO")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cctype>
using namespace std;

#define rep(i,n) for(int (i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

char buf[1030];

inline bool ok(char c) {
  return c != ',' && c != ' ' && c != '.' ;
}

int main() {
  while (fgets(buf, 1024, stdin)) {
    const int N = strlen(buf);
    size_t itr = 0, cnt = 0;
    bool printed = false;
    if (ok(buf[0])) {
      cnt = 1;
    } else {
      itr = 1;
    }
    for (int i = 1; i < N; ++i) {
      if (ok(buf[i])) {
        if (cnt == 0) itr = i;
        ++cnt;
      } else {
        if (cnt > 2 && cnt < 7) {
          if (printed) putchar(' ');
          //putchar('[');
          for (int j = itr; j < i; ++j) putchar(buf[j]);
          //putchar(']');
          printed = true;
        }
        itr = i;
        cnt = 0;
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 0
use proconio::{fastout, input};

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

    let mut t = 0;
    while w + 1 > t {
        print!("#");
        t += 1;
    }
    println!("#");
    for a_iter in a.iter() {
        println!("#{}#", a_iter);
    }
    let mut u = 0;
    while w + 1 > u {
        print!("#");
        u += 1;
    }
    println!("#");
}


Measured memory_bytes: 2172
#include "bits/stdc++.h"

using namespace std;

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    int t1 = h1 * 60 + m1;
    int t2 = h2 * 60 + m2;

    if (t2 < t1) t2 += (24 * 60);
    t2 -= k;
    cout << t2 - t1 << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <complex>
#include <unordered_map>
#include <bitset>
#include <ctime>
#include <cassert>
#include <random>

#define sz(a) (int)((a).size())

using namespace std;

mt19937 rnd(239);

typedef long long ll;
typedef long double ld;

int solve()
{
    ios::sync_with_stdio(0);
    int n;
    if (!(cin >> n))
    {
        return 1;
    }
    ll d, x;
    cin >> d >> x;
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        x += (d + a - 1) / a;
    }
    cout << x << endl;
    return 0;
}

int32_t main()
{
    #ifdef ONPC
        freopen("in.txt", "r", stdin);
    #endif
    int T = 100;
    //cin >> T;
    for (int i = 1; i <= T; i++)
    {
        #ifdef ONPC
            cerr << "Test #" << i << ":\n";
        #endif
        if (solve())
            break;
        #ifdef ONPC
            cerr << "_______________________________________________" << endl;
        #endif
    }
    #ifdef ONPC
        cerr << endl << "finished in " << clock() * 1000LL / CLOCKS_PER_SEC << " ms" << endl;
    #endif
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n,r;
	int ans=0;
	cin >>n>>r;
	
	cout<<((n >=10)?(r):r+(100*(10-n)))<<endl;
}

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

MAX_DIGIT = 40

dp = [[-1, -1] for _ in range(MAX_DIGIT+1)]
dp[0][0] = 0
for i in range(MAX_DIGIT):
    mask = 1 << (MAX_DIGIT - i - 1)
    cnt_1 = 0
    for v in a:
        if v & mask:
            cnt_1 += 1
    cnt_0 = n - cnt_1

    cost_0 = mask * cnt_1
    cost_1 = mask * cnt_0

    if dp[i][1] != -1:
        dp[i+1][1] = max(dp[i+1][1], dp[i][1] + max(cost_0, cost_1))

    if k & mask:
        dp[i+1][1] = max(dp[i+1][1], dp[i][0] + cost_0)

    if k & mask:
        dp[i+1][0] = max(dp[i+1][0], dp[i][0] + cost_1)
    else:
        dp[i+1][0] = max(dp[i+1][0], dp[i][0] + cost_0)

print(max(dp[MAX_DIGIT][0], dp[MAX_DIGIT][1]))

Measured memory_bytes: 68696
from itertools import accumulate

N = int(input())
W = [int(i) for i in input().split()]

W = list(accumulate(W))

ans = 10**9
for i in range(1,N):
    p = W[i]
    q = W[-1] - W[i]
    ans = min(ans,abs(p-q))

print(ans)


Measured memory_bytes: 3060