akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <iostream>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

ll vs[55];
int n;

ll go(void) { // 手順通りやる
  ll maxi = 0;
  int idx = -1;
  REP(i, n) {
    if(vs[i] > maxi) {
      maxi = vs[i];
      idx = i;
    }
  }
  vs[idx] -= n;
  REP(i, n) {
    if(i != idx) {
      ++vs[i];
    }
  }
  return 1;
}

ll go2(void) { // 最大の箇所から、n+1手でn+1減らす、というのを十分小さくなるまで一気にやる
  ll maxi = 0;
  int idx = -1;
  REP(i, n) {
    if(vs[i] > maxi) {
      maxi = vs[i];
      idx = i;
    }
  }
  ll cnt = vs[idx] / (n+1);
  ll res = cnt * (n+1);
  vs[idx] -= cnt * (n+1);
  return res;
}

bool toContinue1(void) { // 全ての箇所がn-1以下なら終わる
  REP(i, n) {
    if(vs[i] > n-1) {
      return true;
    }
  }
  return false;
}

bool toContinue2(void) { // 全ての箇所がn-1以上になるまでやる
  REP(i, n) {
    if(vs[i] < n-1) {
      return true;
    }
  }
  return false;
}

bool toContinue3(void) { // 全ての箇所がn以下になるまでやる
  REP(i, n) {
    if(vs[i] > n) {
      return true;
    }
  }
  return false;
}

int main(void) {
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }

  ll res = 0;
  while(toContinue1()) { // 全ての箇所がn-1以下になるまでやる
    if(toContinue2()) { // 「全ての箇所がn-1以上である」でない
      // cerr << "> a" << endl;
      res += go();
    } else if(toContinue3()){ // 「全ての箇所がn以下である」でない
      // cerr << "> b" << endl;
      res += go2();
    } else {
      // cerr << "> c" << endl;
      res += go();
    }
  }

  printf("%lld\n", res);
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int L;
    cin >> L;
    double S, D, OneThird;
    
    OneThird = 1.0/3;

    if(L%3 == 0){
        S = L/3;
    } else if(L%3 == 1){
        S = (L-1)/3 + OneThird;
    } else if(L%3 == 2){
        S = (L-2)/3 + 2*OneThird;
    }

    D = S*S*S;

    cout << setprecision(12) << D << endl;
} 

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

int main()
{
    long int N;
    long int A,B;
    long int S=0;
    long int Y=0;
    long int T=0;
    scanf("%ld %ld %ld",&N,&A,&B);


        S=N/(A+B);
        Y=N%(A+B);
        if(Y>A)
            T=(S*A)+A;
        else
            T=(S*A)+Y;

    printf("%ld",T);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
using namespace std;
const int tINF = (int)INT_MAX;
const long long lINF = (long long)LLONG_MAX;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef DEBUG
			assert(freopen("inp", "r", stdin));
			assert(freopen("out", "w",stdout));
	#else
			#define cerr if(false)cerr
	#endif
    int n, k;
    cin >> n >> k;
    vector <double> pr(1001);
    double sum123 = 0;
    for(int i = 1; i <= 1000; ++i){
        sum123 += i;
        pr[i] = sum123 / (double)i;
    }
    vector <double> ar(n);
    for(auto &i : ar)
        cin >> i;
    for(int i = 0; i < n; ++i){
        ar[i] = pr[(int) ar[i]];
  //      cout << ar[i] << '\n';
    }
    double mx = 0;
    double sum = 0;
    for(int i = 0; i < k; ++i){
        sum += ar[i];
    }
        mx = max(mx,sum);
       int  pos  =0 ;
    for(int i = k - 1; i < n - 1; ++i){
        sum -= ar[pos];
        sum += ar[i + 1];
        mx = max(mx,sum);
        ++pos;
    }
    cout << fixed << setprecision(9) << mx << '\n';
    cerr << "Time execute: " << (double)clock() / (double)CLOCKS_PER_SEC 
    << " sec" << endl;
}

Measured memory_bytes: 1792
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include<string>

using namespace std;

int state[100005];
int penal[100005];


int main()
{
	int n, m;
	int num;
	string s;
	cin >> n >> m;
	int score = 0;
	int pena = 0;
	for (int i = 0; i < m; i++) {
		cin >> num >> s;

		if (state[num] == 0) {
			if (s == "AC") {
				score++;
				state[num] = 1;
				pena += penal[num];
			}
			else {
				penal[num]++;
			}
		}
	

	}
	cout << score <<" "<< pena << endl;;

	return 0;


}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string a, b, c;

  cin >> a >> b >> c;

  char turn = 'a';
  while (true) {
    switch (turn) {
      case 'a':
        if (a.empty()) {
          cout << 'A' << endl;
          return 0;
        } else {
          turn = a[0];
          a = a.substr(1);
        }
        break;
      case 'b':
        if (b.empty()) {
          cout << 'B' << endl;
          return 0;
        } else {
          turn = b[0];
          b = b.substr(1);
        }
        break;
      case 'c':
        if (c.empty()) {
          cout << 'C' << endl;
          return 0;
        } else {
          turn = c[0];
          c = c.substr(1);
        }
        break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
import numpy as np

N,K = [int(i) for i in input().split(" ")]
ans = np.zeros(N)
for i in range(K):
    d = int(input())
    ar = [int(i) for i in input().split(" ")]
    for l in range(d):
        ans[ar[l]-1] += 1

print(np.count_nonzero(ans == 0))

Measured memory_bytes: 27148
#include <stdio.h>

int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);

    if(1<=a,b<=1000000000){  
    d=a/b;
    r=a%b;
    f=1.0*a/b;
    printf("%d %d %8lf\n",d,r,f);
    }    
    return 0;
}


Measured memory_bytes: 2072
#include<stdio.h>
int max(int a,int b){
  if(a+b>=a-b&&a+b>=a*b)
    return a+b;
  else if(a-b>=a+b&&a-b>=a*b)
    return a-b;
  else
    return a*b;
}
int main(){
  int a,b;
  scanf("%d %d", &a,&b);
  printf("%d",max(a,b));
  return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    int a, b, k;
    cin >> a >> b >> k;

    int cur = a;
    for (; cur <= b && cur <= a + k - 1; ++cur) {
        cout << cur << endl;
    }
    cur = max(cur, b - k + 1);
    for (; cur <= b; ++cur) {
        cout << cur << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
inline int read(){
    int x = 0; char c = getchar();
    while (!isdigit(c)) c = getchar();
    while (isdigit(c)) x = x * 10 + c - '0',c = getchar();
    return x;
}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int P = 1e9 + 7,N = 500050;
int n,fac[N],inv[N];
int x[N];
int f[N];
long long ans,now;
int main(){
	int i;
	read(n);
	for (i = 1; i <= n; ++i) read(x[i]);
	for (fac[0] = i = 1; i <= n; ++i) fac[i] = 1ll*fac[i-1]*i%P;
	for (inv[0] = inv[1] = 1,i = 2; i <= n; ++i) inv[i] = 1ll*inv[P%i]*(P-P/i)%P;
	for (i = 1; i <= n; ++i){
		int prob; prob = inv[i];
		f[i] = 1ll*prob*(f[i-1]+1) % P;
		f[i] += 1ll*(P+1-prob)*f[i-1] % P;
		f[i] %= P;
	}
	ans = 0;
	for (i = 1; i <= n-1; ++i){
		int dist = x[i+1] - x[i];
	//	cout << 1ll*dist * f[i] << endl;
		ans = (ans + 1ll*dist*f[i]%P)%P;
	} 
	cout << 1ll*fac[n-1]*ans%P << endl;
    return 0;
}


Measured memory_bytes: 4992
class SegTree:
    
    def __init__(self, A, intv, initialize = True):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        if initialize:
            self.data = [intv]*(self.N0-1) + A + [intv]*(self.N0 - self.N + 1)
            for i in range(self.N0-2, -1, -1):
                self.data[i] = min(self.data[2*i+1], self.data[2*i+2]) 
        else:
            self.data = [intv]*(2*self.N0)
    
    def segf(self, a, b):
        return min(a, b)
    
    def update(self, k, x):
        k += self.N0-1
        self.data[k] = x
        while k >= 0 :
            k = (k-1)//2
            self.data[k] = min(self.data[2*k+1], self.data[2*k+2])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = min(s, self.data[R-1])
            if L & 1:
                
                s = min(s, self.data[L-1])
                L += 1
            L >>= 1
            R >>= 1
        return s

import sys
N, Q = map(int, input().split())
T = SegTree([0]*N, 2**31-1, False)
for _ in range(Q):
    qt, x, y = map(int, sys.stdin.readline().split())
    if qt:
        print(T.query(x, y+1))
    else:
        T.update(x, y)


Measured memory_bytes: 9436
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) sum += s[i] - '0';
	if (sum % 9 == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace std;
namespace mp = boost::multiprecision;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    mp::cpp_dec_float_100 a, b, c;
    cin >> a >> b >> c;

    if (sqrt(a) + sqrt(b) < sqrt(c))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 384
package main

import (
	"fmt"
)

func main() {
	var s string
	var si, ei int = -1, -1
	fmt.Scan(&s)

	for i :=0; i<len(s); i++ {
		sc := string(s[i])
		if si < 0 && sc == "A" {
			si = i
		}
		if sc == "Z" {
			ei = i
		}
	}

	fmt.Println(ei - si + 1)
}

Measured memory_bytes: 1920
a, b, c, k = map(int, input().split())

ans = 0
if a - k >= 0:
    ans = k
else:
    ans += a
    k -= a
    if b - k < 0:
        k -= b

        if c - k >= 0:
            ans -= k
        else:
            ans -= c

print(ans)

Measured memory_bytes: 61804
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)
	{
		 Scanner sc=new Scanner(System.in);
		 int i=sc.nextInt();
		 int j=sc.nextInt();
		 int arr[]=new int[j];
		 List li1=new ArrayList();
		 if(j==0)
		 {
			 System.out.println(i);
			 System.exit(0);
		 }
		 for(int k=0;k<j;k++)
		 {
			 arr[k]=sc.nextInt();
			 li1.add(arr[k]);
		 }
		 if(!li1.contains(i))
		 {
			 System.out.println(i);
			 System.exit(0);
		 }
		
		 for(int k=0;k<=j;k++)
		 {
			if((li1.contains(i+k))&&(li1.contains(i-k)))
			 { 
				 continue;
			 }
           
			 if(!li1.contains(i-k))
			 {
				 System.out.println(i-k);
                 break;
				 
			 }
			 if(!li1.contains(i+k))
			 {
				 System.out.println(i+k);
                 break;
				 
			 }	 
		 }
		 
		 
	}
 
}

Measured memory_bytes: 36024
#include<bits/stdc++.h>
using namespace std;
string z;
int M,A,R,C,H;
int main(){
    while(cin>>z){
        switch(z[0]){
            case 'M':M++;break;
            case 'A':A++;break;
            case 'R':R++;break;
            case 'C':C++;break;
            case 'H':H++;break;
        }
    }
    //a=(M*A*R)+(M*A*C)+(M*A*H)+(M*R*C)+(M*R*H)+(M*C*H)+(A*R*C)+(A*R*H)+(A*C*H)+(R*C*H);
    //式変形
    long long int x=C+H,y=A+R,v=A*R,t=C*H;
    cout<<v*(M+x)+t*(M+y)+(M*x*y)<<endl;
}


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

int main() {

double x1,x2,y1,y2;
double x,y,z;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

x = (x2-x1) * (x2-x1);
y = (y2-y1) * (y2-y1);

printf("%.11lf",sqrt(x+y));


return 0;

}



Measured memory_bytes: 2096
#include <iostream>
#include <vector>

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

	std::vector<int> s(n);
	for (auto&& e : s)
		std::cin >> e;

	int ans = 0;

	int q;
	std::cin >> q;

	for (int i = 0; i < q; ++i) {
		int t;
		std::cin >> t;

		for (auto&& e : s) {
			if (e == t) {
				++ans;
				break;
			}
		}
	}

	std::cout << ans << std::endl;
}


Measured memory_bytes: 3088
/***
 **   A S M Atikur Rahman
 **   Update: 17-12-2019
***/

//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<cstring>
#include<time.h>
#include<limits.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<utility>
#include<iterator>
#include<algorithm>
#include<cassert>
#include<iomanip> ///setprecision


#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sci(x) scanf("%d%*c", &(x))
#define scll(x) scanf("%lld%*c", &(x))
#define scd(x) scanf("%lf%*c", &(x))
#define scstr(x) scanf("%s", x)
#define pfi(x) printf("%d", (x))
#define pfll(x) printf("%lld", (x))
#define pfd(x) printf("%f", (x))
#define pfstr(x) printf("%s", (x))
#define ps printf(" ")
#define pn printf("\n")
#define pfdot printf("..")

#define For(a,n) for(int i=(a); i<(n); i++)
#define rFor(n,a) for(int i=n-1; i>=0; i--)
#define trav(a,x) for (auto& a : x)
#define Mset(ara, val) memset(ara, val, sizeof(ara))

#define mkp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound

#define pi  (2*acos(0))


using namespace std;

using ll=long long;
using pii= pair<int,int>;
using pll= pair<long long, long long>;
using pcc= pair<char, char>;
using pdd= pair<double, double>;

#define V(a) vector<a>
using vi= vector<int>;
using vs= vector<string>;
using vll= vector<ll>;
using vpii= vector<pii>;
using vc= vector<char>;
using vd= vector<double>;

//ll POW(ll a,ll b){if(b==0)return 1;ll x=POW(a,b/2);x=(x*x);if(b&1)x=(x*a);return x;}




int main( int argc, char *argv[] )
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stout);

    ll n,m,ans;
    cin>>n>>m;
    ans=(n*(n-1))/2;
    ans+=(m*(m-1))/2;
    pfll(ans),pn;




    return 0;
}
























Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int a,b,c,d;
  int x,y;
  scanf("%d",&a);
  scanf("%d",&b); 
  scanf("%d",&c); 
  scanf("%d",&d);
 
  x=a/d;
  y=c/b;

  if((a%d)!=0){
    x=x+1;
  }  
  if((c%b)!=0){
    y=y+1;
  }
  if(x<y){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
  return 0;
}


Measured memory_bytes: 1616
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    L, R, d = map(int, input().split())
    l = list(range(L, R+1))
    cnt =0
    for i in l:
        if i%d==0:
            cnt += 1
    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
import numpy as np
h,w=input().split()
h,w=int(h),int(w)
x3=[]
for i in range(h):
    x1=input()
    if x1 !=  w*".":
        x3.append(list(x1))

x3=np.array(x3).T.tolist()
x4=[]
for i in range(w):
    if x3[i] != ["." for i in range(len(x3[i]))]:
        x4.append(x3[i])

x4=np.array(x4).T.tolist()
for i in range(len(x4)):
    for j in range(len(x4[0])):
        print(x4[i][j],end="")
    print()


Measured memory_bytes: 14024
N, W = map(int, input().split())
v = [0]*N
w = [0]*N
for i in range(N):
    v[i], w[i] = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if w[i]>j:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i])

print(dp[N][W])


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll x, y; cin >> x >> y;
    
    rep(i, 100){
        rep(j, 100){
            if(2*i + 4*j == y && i+j == x){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3624
const collatz = (n) => {
  if (n % 2 === 0) {
    n /= 2
  } else {
    n = 3 * n + 1
  }

  return n
}

const main = stdin => {
  const input = stdin.trim().split('\n')
  const s = parseInt(input[0])

  if (s === 1 || s === 2 || s === 4) {
    console.log(4)
    return
  }

  let tmp = s
  let first = 0
  let second = 0
  for (let i = 1; ; i++) {
    if (tmp === 4 && first === 0) {
      first = i
    } else if (tmp === 4 && first !== 0) {
      second = i
      break
    }
    tmp = collatz(tmp)
  }

  console.log(second)
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29580
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")


def main():
    sys.setrecursionlimit(2147483647)
    INF = float("inf")
    IINF = 10 ** 18
    MOD = 998244353

    N, M = list(map(int, sys.stdin.readline().split()))

    def get_factorials(max, mod=None):
        """
        階乗 0!, 1!, 2!, ..., max!
        :param int max:
        :param int mod:
        :return:
        """
        ret = [1]
        n = 1
        if mod:
            for i in range(1, max + 1):
                n *= i
                n %= mod
                ret.append(n)
        else:
            for i in range(1, max + 1):
                n *= i
                ret.append(n)
        return ret

    def mod_invs(max, mod):
        """
        逆元のリスト 0 から max まで
        :param max:
        :param mod:
        :return:
        """
        invs = [1] * (max + 1)
        for x in range(2, max + 1):
            invs[x] = (-(mod // x) * invs[mod % x]) % mod
        return invs

    factorials = np.array(get_factorials(M * 3 // 2 + N, MOD), dtype=int)
    finvs = np.ones(M * 3 // 2 + N + 1, dtype=int)
    p = 1
    for i, inv in enumerate(mod_invs(M * 3 // 2 + N, MOD)):
        p = p * inv % MOD
        finvs[i] = p

    def ncr(n, r, mod=None):
        """
        scipy.misc.comb または scipy.special.comb と同じ
        組み合わせの数 nCr
        :param int n:
        :param int r:
        :param int mod: 3 以上の素数であること
        :rtype: int
        """
        ret = factorials[n] * finvs[r] % MOD * finvs[n - r] % mod
        ret[n < r] = 0
        return ret

    # (1) 合計が M*3 で、奇数の数が M 以下である数列の数
    odds = np.arange(M % 2, M + 1, 2)
    halves = (M * 3 - odds) // 2

    oc1 = ncr(N, odds, MOD)
    oc2 = ncr(N - 1, odds, MOD)

    # 合計が halfs の数列を 2 倍して、odds 個選んで 1 を足す
    c1 = ncr(halves + N - 1, N - 1, MOD) * oc1 % MOD

    # (2) max が M*2 より大きく、奇数の数が M 以下である数列の数
    # => 合計が M で、1 要素目が 0 より大きい、奇数が M 以下である数列の数 * N
    # 1 要素目に M*2 を足せば (2) になる
    halves = (M - odds) // 2
    # a. 合計が M で奇数が M 以下
    c2a = ncr(halves + N - 1, N - 1, MOD) * oc1 % MOD
    # c2a = c1
    # b. 1 要素目が 0 である数列の数
    c2b = ncr(halves + N - 2, N - 2, MOD) * oc2 % MOD

    c2 = (c2a - c2b) * N % MOD
    print((c1 - c2).sum() % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 108516
#include <stdio.h>
#include <stdlib.h>
#define WHITE 0
#define BLACK 1
#define GLAY -1
#define N 100
#define INFTY 200000

int n;
int a[N][N];

int prim();

int main(){
  int i, j;

  scanf("%d", &n);
  if(n < 1 || 100 < n) exit(1);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      scanf("%d", &a[i][j]);
      if(a[i][j] != -1 && (a[i][j] < 0 || 2000 < a[i][j])) exit(2);
    }
  }

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

  return 0;
}

int prim(){
  int i, u, v;
  int mincost, sum=0;
  int d[N], p[N], color[N];

  for(i=0; i<n; i++){
    color[i]=WHITE;
    d[i]=INFTY;
  }

  d[0]=0;
  p[0]=-1;

  while(1){
    mincost=INFTY;
    for(i=0; i<n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost=d[i];
	u=i;
      }
    }

    if(mincost == INFTY) break;

    color[u]=BLACK;

    for(v=0; v<n; v++){
      if(color[v] != BLACK && a[u][v] != -1){
	if(a[u][v] < d[v]){
	  d[v]=a[u][v];
	  p[v]=u;
	  color[v]=GLAY;
	}
      }
    }
  }

  for(i=0; i<n; i++){
    sum=sum+d[i];
  }

  return sum;
}

    



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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  string s;
  string t;
  cin >> s >> t;
  int i;
  int ans = 0;
  rep(i,s.size())
  {
    if(s[i] != t[i]) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3920
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rep(i,x) for(int i=0;i<(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

struct SegTree { // ??????min,max
	int n;
	vector<int> Max;
	vector<int> Min;

	void init(int n_)
	{
		n = 1;
		while (n < n_) n *= 2;

		Max.resize(2 * n);
		Min.resize(2 * n);

		for (int i = 0; i < 2 * n - 1; ++i) {
			Max[i] = -inf;
			Min[i] = inf;
		}
	}

	void min_update(int idx, int val)
	{
		idx += n - 1;
		Min[idx] = val;

		while (idx > 0) {
			idx = (idx - 1) / 2;
			Min[idx] = min(Min[idx * 2 + 1], Min[idx * 2 + 2]);
		}
	}

	void max_update(int idx, int val)
	{
		idx += n - 1;
		Max[idx] = val;

		while (idx > 0) {
			idx = (idx - 1) / 2;
			Max[idx] = max(Max[idx * 2 + 1], Max[idx * 2 + 2]);
		}
	}

	int get_min(int a, int b, int k = 0, int l = 0, int r = -1) // [a, b)???min
	{
		if (r == -1) r = n;

		if (r <= a || b <= l) return inf;

		if (a <= l && r <= b) return Min[k];

		int vl = get_min(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_min(a, b, k * 2 + 2, (l + r) / 2, r);

		return min(vl, vr);
	}

	int get_max(int a, int b, int k = 0, int l = 0, int r = -1) // [a, b)???max
	{
		if (r == -1) r = n;

		if (r <= a || b <= l) return -inf;

		if (a <= l && r <= b) return Max[k];

		int vl = get_max(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = get_max(a, b, k * 2 + 2, (l + r) / 2, r);

		return max(vl, vr);
	}
};

int X[200020], Y[200020];

signed main()
{
	int N, d; scanf("%d%d", &N, &d);

	SegTree x_seg, y_seg;

	x_seg.init(N), y_seg.init(N);

	vpii hoge;

	rep(i, N) {
		int x, y, b; scanf("%d%d%d", &x, &y, &b);
		X[i] = x, Y[i] = y;

		hoge.PB(pii(b, i));
	}

	sort(all(hoge));

	rep(i, N) {
		x_seg.min_update(i, X[hoge[i].scd]);
		x_seg.max_update(i, X[hoge[i].scd]);

		y_seg.min_update(i, Y[hoge[i].scd]);
		y_seg.max_update(i, Y[hoge[i].scd]);
	}

	ll ans = -inf;

	rep(i, N) {
		if (i > 0 && hoge[i].fst == hoge[i - 1].fst) continue;

		int b = hoge[i].fst;

		int idx = upper_bound(all(hoge), pii(b + d, inf)) - hoge.begin();

		int min_x = x_seg.get_min(i, idx);
		int max_x = x_seg.get_max(i, idx);

		int min_y = y_seg.get_min(i, idx);
		int max_y = y_seg.get_max(i, idx);

		ans = max(ans, 1ll * (max_x - min_x) * (max_y - min_y));
	}

	printf("%lld\n", ans);
}

Measured memory_bytes: 12440
#include "bits/stdc++.h" // 1
using namespace std; // 2
#define INF 0x3f3f3f3f    //3
#undef INF // 4
long long A, B, C, X, Y; // 5
long long solve(){   //6
    return -1;} // 7
long long a, b, c, x, y; // 1
void solve2(){ // 2
    long long num=0;    //3
    long min_ = std::min(x, y); // 4
    c = min(2 * c, a + b); // 5
    } //6
int main() { // 7
    cin>>a>>b>>C>>X>>y; // 1
    #define INF 1000000007 // 2
    long long sum=0LL;    //3
    A = a; B = b; c = C; x = X; Y = y; // 4
    long ans = min({A * X + B * Y, max(X, Y) * 2 * C, min(X, Y) * 2 * C + abs(X - Y) * (X > Y ? A : B)}); // 5
    long long q = solve();solve2();   //6 
    #undef INF   // 7
    cout<<ans*q*solve(); // 1
    cout << endl; // 2
    int dx[8]={0,0,-1,1,1,1,-1,-1};    //3
    return 0;}

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

using namespace std;

const int N = 500500;

struct Summer {
  int v[N];

  void add(int pos, int k) {
    for (; pos < N; pos += pos & (-pos)) {
      v[pos] += k;
    }
  }

  int sum(int pos) {
    int res = 0;
    for (; pos; pos &= pos - 1) res += v[pos];
    return res;
  }
};

char s[N];


Summer su[26];

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

  int n; cin >> n >> (s + 1);
  int q; cin >> q;

  int t, ind, l, r;
  char c;
  for (int i = 1; i <= n; ++i) su[s[i] - 'a'].add(i, 1);
  while (q--) {
    cin >> t;
    if (t == 1) {
      cin >> ind >> c;
      while (c == ' ') cin >> c;

      if (s[ind] != c) {
        su[s[ind] - 'a'].add(ind, -1);
        su[c - 'a'].add(ind, 1);
        s[ind] = c;
      }
    } else {
      cin >> l >> r;
      int res = 0;
      for (int i = 0; i < 26; ++i) {
        if (su[i].sum(r) != su[i].sum(l-1)) {
          ++res;
        }
      }
      cout << res << '\n';
    }
  }
}


Measured memory_bytes: 51584
#pragma GCC Optimize("Ofast")
#pragma GCC Optimize "trapv"
#define _GLIBCXX_DEBUG

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

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

ll a[100005],dp[100005],n,k;

ll ans(ll i){
	if(i==n-1)
		return 0;
	if(i>=n)
		return INT_MAX;
	if(dp[i]!=-1)
		return dp[i];
	ll solution=INT_MAX;
	for(ll j=1;j<=k;j++){
		if(i+j<n)
		solution=min(solution,abs(a[i]-a[i+j])+ans(i+j));
	}
	return dp[i]=solution;
}

void solve(){
	memset(dp,-1,sizeof(dp));
	cin >> n >> k;
	for(ll i=0;i<n;i++)		cin >> a[i];
	cout << ans(0) << endl;
}

int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif	
	FAST
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	solve();
	ret 0;
}

Measured memory_bytes: 12912
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int h = stdin.nextInt();
        int w = stdin.nextInt();
        int a = stdin.nextInt();
        int b = stdin.nextInt();
        
        long ans = 0;
        for (int i = 0; i < h - a; i++) {
            ans += (c(b - 1 + i,b - 1) * c(w - 1 - b + h - 1 - i, w - 1 - b)) % mod;
            ans %= mod;
        }
        
        System.out.println(ans);
    }
    
    private static List<BigInteger> fcts = new ArrayList<>();
    private static List<BigInteger> invs = new ArrayList<>();
    private static BigInteger m = BigInteger.valueOf(1000000007);
    private static long mod = m.longValue();
    
    public static long c(int n, int k) {
        if (fcts.isEmpty()) {
            fcts.add(BigInteger.ONE);
            invs.add(BigInteger.ONE);
        }
        
        for (int i = fcts.size(); i <= n; i++) {
            BigInteger x = BigInteger.valueOf(i);
            BigInteger fct = fcts.get(i - 1);
            BigInteger inv = invs.get(i - 1);
            fcts.add(fct.multiply(x).mod(m));
            invs.add(inv.multiply(x.modInverse(m)).mod(m));
        }
        
        return (fcts.get(n).multiply(invs.get(k).multiply(invs.get(n - k)))).mod(m).longValue();
    }
}

Measured memory_bytes: 126620
#include<bits/stdc++.h>
#define rep(i,n) 				for(int i=0; i<(n); ++i)
#define all(c) 					(c).begin(),(c).end()
#define sortall(x)              sort(all(x))
#define tr(c,i) 				for( typeof( (c).begin() ) i = (c).begin();  i != (c).end(); ++i)
#define pb 						push_back
#define sz(a) 					int((a).size())
#define mp                      make_pair
#define ll                      long long
#define F                       first
#define S                       second
#define PI                      3.1415926535897932384626
// Input macros
#define s(n)                    scanf("%d",&n)
#define sc(n)                   scanf("%c",&n)
#define sl(n)                   scanf("%lld",&n)
#define sf(n)                   scanf("%lf",&n)
#define ss(n)                   scanf("%s",n)

// Others
#define test(t) 				int t; cin>>t; while(t--)
#define endl 					"\n"

using namespace std;

typedef pair<int, int> 			pii;
typedef pair<ll, ll> 	        pll;
typedef vector<int> 			vi;
typedef vector<ll>              vl;

// const int mod = 1000000007;
// const int INF = 1e9+5;

int main(){
	
     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

     string s, t;
     cin >> s >> t;
     
     int l1 = s.length();
     int l2 = t.length();
     
     vector< vector<int> > dp(l1+1, vector<int>(l2+1,0));
     
     for( int i=1 ; i<=l1 ; i++ ){
		 for(int j=1 ; j<=l2 ; j++){
			 if(s[i-1] == t[j-1]){
				 dp[i][j] = dp[i-1][j-1] + 1;
			 }else{
				 dp[i][j] = max( dp[i-1][j], dp[i][j-1] );
			 }
		 }
	 }
	 
	 //for( int i=0 ; i<=l1 ; i++ ){
		 //for(int j=0 ; j<=l2 ; j++){
			 //cout<<dp[i][j]<<" ";
		 //}
		 //cout<<endl;
	 //}
	 
	 string answer = "";
	 
	 ll i=l1; ll j=l2;
	 
	 while(i>0 && j>0){
		 
		 if (s[i-1] == t[j-1]){ 
			  answer += s[i-1]; 
			  i--; j--;
		 } 
		 else if (dp[i-1][j] > dp[i][j-1]) 
			 i--; 
		 else
			 j--; 
			 
	 }
	 
	 reverse(all(answer));
	 cout<<answer<<endl;

     return 0;

}


Measured memory_bytes: 38476
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long s1=10000;
    long long s2=5000;
    long long s3=1000;
    int n,y;
    cin>>n>>y;
    for(int i=0; i<=2000; i++)
    {
        for(int j=0; j<=2000; j++)
        {
            long long val=i*s1+j*s2;
            long long left=y-val;
            int k=0;
            if(left%s3==0 && left>=0)
            {
                k=left/s3;
                left=left-s3*k;
            }
            if(i+j+k==n && left==0)
            {
                //cout<<val<<" "<<left<<endl;
                cout<<i<<" "<<j<<" "<<k<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        if(s=="ABC")
            cout<<"ARC";
        else
            cout<<"ABC";
    }
}

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

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define F first
#define S second
#define pb push_back
#define sz(a) ((int)(a).size())

using namespace std;

typedef vector<int> vi;
                                                  	
int main(){       
	int n;
	scanf("%d",&n);
	cout << (n * (n + 1)/2) << endl;	
	
	return 0;
}







Measured memory_bytes: 256
import itertools

h,w,k = map(int,input().split())
ab = []
for _ in range(h):
    s=list(input())
    ab.append(s)

tate = []
yoko = []
 
for i in range(h):
    tate.append(i)

for i in range(w):
    yoko.append(i)

ans = 0

for i in range(h+1):
    for j in range(w+1):
        for v in itertools.combinations(tate, i):
            for vv in itertools.combinations(yoko, j):
                memo = 0
                for tt in range(h):
                    if tt in v:
                        continue
                    for yy in range(w):
                        if yy in vv:
                            continue
                        if ab[tt][yy] == '#':
                            memo += 1
                if memo == k:
                    ans += 1
print(ans)

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

int main() {
	while(true){
		int n,x,pattern=0;
		cin>>n>>x;
		if(n==0&&x==0)break;
		else{
			for(int i=1;i<=n;i++){
				for(int j=i+1;j<=n;j++){
					for(int k=j+1;k<=n;k++){
						if(i+j+k==x){
								pattern++;
						}
					}
				}
			}
			cout<<pattern<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var t = Console.ReadLine();
		long wa = 0;
		for(int i = 0; i < t.Length; i++)
		{
			if(t[i] != s[i])
				wa++;
		}
		Console.WriteLine(wa);
	}

	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}

Measured memory_bytes: 27456
#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;
const long long MOD =1000000000+7;
void solve(int a) { cout << (a ? "APPROVED" : "DENIED") << endl; }
int main(){
    int n;
    cin >>n;
    int a=0;
    bool ans = true;
    for(int i=0;i<n;i++){
        cin >>a;
        if(a%2==0){
            if(a%3==0 or  a%5==0){

            }else{
                ans=false;
            }
        }
    }
   
    solve(ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor a.k.a. OakenSh1eld
 *
 * */
int mod = 1000000007;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int h, w; cin>>h>>w;
	vector<string> grid(h);
	vector<vector<int>> dp(h, vector<int> (w, 0));
	dp[0][0] = 1;
	for(int i=0; i<h; ++i) cin>>grid[i];
	for(int i=0; i<h; ++i) for (int j=0; j<w; ++j) if(grid[i][j] != '#'){
		if(i) dp[i][j]+=dp[i-1][j];
		if(j) dp[i][j] += dp[i][j-1];
		dp[i][j]%=mod;
	}
	cout<<dp[h-1][w-1];
	return 0;
}


Measured memory_bytes: 5248
import sys

def f(k):
  global N,h,update
  if k==N:
    return -1
  if h[k]==0:
    return k
  else:
    h[k]-=1
    update=True
    f(k+1)


update=False
N=int(input())
h=list(map(int,input().split(" ")))
r=0
s=0

try:
  while True:
    if h[s]!=0:
      break
    s+=1
except Exception:
  print(0)
  sys.exit(0)

while True:
  f(s)
  if update:
    r+=1
    while s!=N-1 and h[s]==0:
      s+=1
    update=False
  else:
    break

print(r)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 1000000009
using P = pair<int,int>;

int main() {
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  bool flag = false;
  string standard = "";
  rep(i,h){
    if(i<b){
      rep(j,w){
        if(j<a){
          cout << '0';
        }
        else{
          cout << '1';
        }
      }
      cout << endl;
    }
    else{
      rep(j,w){
        if(j<a){
          cout << '1';
        }
        else{
          cout << '0';
        }
      }
      cout << endl;
    }
  } 
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;
int main() {
	int N;
	scanf("%d", &N);
	int *a = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", a + i);
	}
	int cnt = 0;
	for (int i = 1; i < N; i++) {
		if (a[i - 1] == a[i]) {
			cnt++;
			i++;
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 256
x, k, d = map(int, input().split())
if x < 0:
    x = -x

if k * d <= x:
    print(x - k * d)
else:
    steps, x = divmod(x, d)
    k -= steps
    k %= 2
    if k == 0:
        print(x)
    else:
        print(abs(x - d))


Measured memory_bytes: 61772
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        HashMap<Integer, Integer> countMap = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int key = sc.nextInt();
            countMap.put(key, countMap.getOrDefault(key, 0) + 1);
        }

        long ans = 0l;
        for (Entry<Integer, Integer> e : countMap.entrySet()) {
            if (e.getValue() < e.getKey()) {
                ans += e.getValue();
            } else if (e.getValue() > e.getKey()) {
                ans += e.getValue() - e.getKey();
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 60400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		if (x <= y) {
			if (x >= 0 && y >= 0) {
				System.out.println(Math.abs(y - x));
				System.err.println(1);
			} else if (x <= 0 && y <= 0) {
				System.out.println(Math.abs(y - x));
				System.err.println(2);
			} else {
				System.out.println(Math.abs(y + x) + 1);
				System.err.println(3);
			}
		} else {
			if (x > 0 && y > 0) {
				System.out.println(Math.abs(x - y) + 2);
				System.err.println(4);
			} else if (x < 0 && y < 0) {
				System.out.println(Math.abs(x - y) + 2);
				System.err.println(5);
			} else {
				System.out.println(Math.abs(x + y) + 1);
				System.err.println(6);
			}
		}
	}
}


Measured memory_bytes: 9804
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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

int dp[105][4][4][4] = {};

signed main(void) {
    int n;
    cin >> n;
    rep(a,4)rep(b,4)rep(c,4){
        if(a == 1 && b == 2 && c == 3)continue;
        if(a == 2 && b == 1 && c == 3)continue;
        if(a == 1 && b == 3 && c == 2)continue;
        dp[0][a][b][c] = 1;
    }
    rep(i,n-3)rep(a,4)rep(b,4)rep(c,4)rep(d,4){
        if(b == 1 && c == 2 && d == 3)continue;
        if(b == 2 && c == 1 && d == 3)continue;
        if(b == 1 && c == 3 && d == 2)continue;
        if(a == 1 && c == 2 && d == 3)continue;
        if(a == 1 && b == 2 && d == 3)continue;
        (dp[i+1][b][c][d] += dp[i][a][b][c]) %= MOD;
    }
    int ans = 0;
    rep(a,4)rep(b,4)rep(c,4)(ans += dp[n-3][a][b][c]) %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
/*	MASTER HAS FAILED MORE TIMES
	THAN BEGINNER HAS EVER TRIED
*/

#include <bits/stdc++.h>

using namespace std;

#define endl             '\n'
#define all(a)           a.begin(), a.end()
#define mem(a, n)        memset(a, n, sizeof(a))
#define Unique(n)        (n).erase(unique(all(n)), (n).end())
#define NumofDigits(n)   ((long long)log10(n)+1)
#define repeat(i, a, n)  for(int i=a; i<n; i++)
#define isPowerOfTwo(n)  (n && !(n & (n - 1)))

typedef long long ll;
typedef long double ld;

int sieve(int n);
unsigned long long pow(long long base, long long power);
long long gcd(long long a, long long b){ return a%b ? gcd(b, a%b) : b; }
long long lcm(long long a, long long b){ return a*b/gcd(a, b); }

void quicken(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
void file(){
#ifdef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif /*ONLINE_JUDGE*/
}

set<int> s;
bool ok(int d){
    string str = to_string(d);
    repeat(i, 0, str.size())
        if(s.find(str[i]-'0') != s.end()) return false;
    return true;
}

int main(){
    quicken();

    int n, k, d; cin >> n >> k;
    repeat(i, 0, k) cin >> d, s.insert(d);

    repeat(i, n, n*100)
        if(ok(i)) return cout << i, 0;
    cout << 0;

    return 0;
}

unsigned long long pow(long long base, long long power){  /// mod?
    if(power==0)
        return 1;
    if(power==1)
        return base;

    unsigned long long ans = pow(base, power/2); /// mod?
    ans *= ans; /// ((ans%mod)*(ans%mod))%mod;

    if(power&1)
        return ans*base; /// ((ans%mod)*(base%mod))%mod;
    return ans;
}

int sieve(int n){
    int c = 0;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = isPrime[1] = 0;

    for(long long i=2; i*i<=n; i++)
        if(isPrime[i])
            for(long long j=i*2; j<=n; j+=i)
                isPrime[j] = 0;
    repeat(i, 0, n+1)
    if(isPrime[i])
        c++;
    return c; /// primeCount [1:n]
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Data
{
public:
    int x, y, index;
    char d;
    bool isWhite;
    bool operator<(const Data& d) const{
        return make_pair(x + y, x) < make_pair(d.x + d.y, d.x);
    }
};

void solve(int h, int w, const vector<Data>& v, vector<int>& dist)
{
    vector<vector<Data> > v2(2);
    if(v[0].isWhite){
        for(unsigned i=0; i<v.size(); ++i)
            v2[v[i].x%2].push_back(v[i]);
    }
    else{
        for(unsigned i=0; i<v.size(); ++i){
            int j = (v[i].x + ((v[i].d == 'S') ? 1 : 0)) % 2;
            v2[j].push_back(v[i]);
        }
    }

    for(int i=0; i<2; ++i){
        int n = v2[i].size();

        vector<pair<int, int> > p;
        for(int j=0; j<n; ++j){
            if(v2[i][j].d == 'S')
                p.push_back(make_pair(h+1, v2[i][j].x));
        }
        for(int j=0; j<n; ++j){
            if(v2[i][j].d == 'E')
                p.push_back(make_pair(v2[i][j].y, w+1));
        }

        for(int j=0; j<n; ++j){
            int y = p[j].first;
            int x = p[j].second;
            dist[v2[i][j].index] = (y - v2[i][j].y) + (x - v2[i][j].x);
        }
    }
}

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

    vector<Data> v(n);
    for(int i=0; i<n; ++i){
        cin >> v[i].x >> v[i].y >> v[i].d;
        v[i].isWhite = ((v[i].x + v[i].y) % 2 == 0);
        v[i].index = i;
    }
    sort(v.begin(), v.end());

    vector<int> dist(n);
    vector<Data> v2;
    for(int i=0; i<n; ++i){
        v2.push_back(v[i]);
        if(i == n - 1 || v[i].y + v[i].x != v[i+1].y + v[i+1].x){
            solve(h, w, v2, dist);
            v2.clear();
        }
    }

    vector<pair<int, int> > ans(n);
    for(int i=0; i<n; ++i)
        ans[i] = make_pair(dist[i], i+1);
    sort(ans.begin(), ans.end());
    for(int i=0; i<n; ++i)
        cout << ans[i].second << endl;

    return 0;
}

Measured memory_bytes: 16700
fun main(args: Array<String>) {
    val (H, N) = listOfInt()
    val A = listOfInt()
    val sum = A.sum()
    println(if (sum >= H) "Yes" else "No")
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 52744
N,X,Y = map(int, input().split())
count = [0]*(N-1)
c=0
for i in range(0,N):
    for j in range(i+1,N):
        if abs(i-j) >= abs(X-i-1)+1+abs(Y-j-1):
            count[abs(X-i-1)+1+abs(Y-j-1)-1] +=1
        else:
            count[abs(i-j)-1] += 1
for i in range(N-1):
    print(count[i])

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int main(){
	ll n;
	ll i;
	cin >> n;
	i=0;
	while((i+1)*(i+1)<=n) i++;
	cout << i*i;

	return 0;
}

Measured memory_bytes: 256