akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		ArrayList<Integer> list = new ArrayList<>();
		boolean type = (arr[0] == '1');
		boolean first = type;
		int count = 1;
		for (int i = 1; i < n; i++) {
		    if (type == (arr[i] == '1')) {
		        count++;
		    } else {
		        list.add(count);
		        type ^= true;
		        count = 1;
		    }
		}
		list.add(count);
		int length = list.size();
		int[] sums = new int[length + 1];
		for (int i = 0; i < length; i++) {
		    sums[i + 1] = sums[i] + list.get(i);
		}
		int max = 0;
		int left;
		int right;
		if (!first) {
		    max = sums[Math.min(length, k * 2)];
		    left = 2;
		    right = Math.min(length, left + k * 2);
		} else {
		    left = 1;
		    right = Math.min(length, left + k * 2);
		}
		while (left <= right) {
		    max = Math.max(max, sums[right] - sums[left - 1]);
		    left += 2;
		    right = Math.min(length, right + 2);
		}
		System.out.println(max);
    }
}



Measured memory_bytes: 26576
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
  
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

   int s,w;
   cin>>s>>w;
   if(w>=s)
   cout<<"unsafe"<<endl;
   else
   {
       cout<<"safe"<<endl;
   }
   

    return 0 ;

}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include<string>
using namespace std;
const int maxn = 1000007;
int a[maxn];
int n,m,h;
int main()
{
    cin>>n>>m>>h;
    int sum = 0;
    cin>>sum;
    sum/=50;
    int ans = 0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=m;j++)
        {
            for(int k=0;k<=h;k++)
            {
                int now = i*10+j*2+k;
                if(now==sum)ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong N, M;
  vector<llong> A;

  cin >> N >> M;
  A.resize(M);
  llong sum = 0;
  for (auto &in: A) {
    cin >> in;
    sum += in;
  }

  if (sum > N) {
    cout << -1 << endl;
  }
  else {
    cout << N - sum << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
n = int(input())
comments = []

for i in range(1, n+1):
  comment = []
  for _ in range(int(input())):
    comment.append(list(map(int, input().split())))
  comments.append(comment)
  
check_lists = []
ans = 0

for j in range(2**n):
  check_list = []
  index_list = []
  for k in range(n):
    if j & 1<<k:
      index_list.append(k)
      for comment_i in comments[k]:
        check_list.append(comment_i)
  
  case_result = True
  
  for check_list_i in check_list:
    ind, flg = check_list_i
    
    if ind-1 in index_list and flg==0:
      case_result = False
      break
    if ind-1 not in index_list and flg==1:
      case_result = False
      break
  
  if case_result:
    ans = max(ans, len(index_list))
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main()
{
	long long int x, y, count = 0;
	cin >> x >> y;
	while (x <= y) {
		x *= 2;
		count++;
	}
	cout << count << endl;
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int A,B;
  cin>>A>>B;
  cout<<A*B<<endl;
  return 0;
}


Measured memory_bytes: 3652
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        
    int cnt = 0;

	int  i1 = 0 ,i2 = 0, i3 = 0;
	long L1 = 0, L2 = 0, L3 = 0;
	char ch;
	String str = "";
		

//  String s1 = sc.next();
//  char[] c1 = s1.toCharArray();

    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int c = Integer.parseInt(sc.next());
//  int[] test  = new int[W];
/*  while(true){
        test[cnt] = Integer.parseInt(sc.next());
        o++;
        if(cnt==N)break;
    }
*/
    str = "No";
    if( a+b == c  ) str ="Yes";
    if( b+c == a  ) str ="Yes";
    if( a+c == b  ) str ="Yes";

        System.out.print(str);
        System.out.println();
	}
        
}

Measured memory_bytes: 9676
def main():
    from builtins import int, map, list, print, min
    import sys, math
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    A, B, H, M = input_number_list()

    minute = H * 60 + M
    hd = minute / 2 % 360
    md = M * 6 % 360
    sa = min(abs(hd - md), abs(md - hd))
    ans = (A ** 2) + (B ** 2) - (2 * A * B * math.cos(math.radians(sa)))
    ans = ans ** 0.5
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll S,W;
    cin >> S >> W;
    if(S <= W){
        cout << "unsafe" <<endl;
    }else{
        cout << "safe" << endl;
    }
}

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

using namespace std;
using namespace __gnu_cxx;


#define f first
#define s second
#define sz size()
#define em empty()
#define pb push_back
#define pf push_front
#define mem(a,b,s) for(int i=0 ; i<=s ; ++i) a[i]=b;
#define mem2(a,r,c,b) for(int i=0 ; i<=r ; ++i)    for(int j=0 ; j<=c ; ++j)    a[i][j]=b;
#define all(a) a.begin(),a.end()
#define rall(a)	a.rbegin(),a.rend()
#define mp make_pair
#define in insert
#define sc(x) scanf("%d",&x)
#define scl(a)	scanf("%lld",&a)
#define sc2(a,b)	scanf("%d%d",&a,&b)
#define rep(x,a,b)	for(int x=a ; x<=b ; ++x)
#define irep(x,a,b)	for(int x=a ; x>=b ; --x)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef set<int> si;
typedef set<pair<int,int> > sii;
typedef map<int,int>	mii;
typedef pair<int,char>	ic;
typedef pair<int,string> is;
typedef long double ld;
typedef priority_queue<ii> pqii;
typedef priority_queue<int>pqi;

const double pi=3.14159265358979323846264338327950288419716939937510582097494459;
const double EPS = 1e-12;
const int MAXN=1e5+10;
const ll MOD=1e9+7;
const int oo=2e9+10;
const ll OO=1e18;

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

int x;
vi v;

int main()
{
////	ios_base::sync_with_stdio(false);
////	cin.tie();
////	cout.tie();
//#ifndef ONLINE_JUDGE
//	freopen("In.txt","r",stdin);
////	freopen("Out.txt","w",stdout);
//#else
////	freopen("battery.in","r",stdin);
////	freopen("output.txt","w",stdout);
//#endif

	rep(i,1,3)	scanf("%d",&x),v.pb(x);
	sort(all(v));
	x=1;
	rep(i,0,1)	x*=v[i];
	x/=2;
	printf("%d\n",x);
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	int pn = 1;
	if (*ci == '-') {
		pn = -pn;
		ci++;
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return pn * tmp;
}

ll A[200001];
void pakuri_sort(int N, ll A[]) {
	const int b = 9;
	ll tmp[200001];
	rep(k, 6) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	rep1(i, N) {
		A[i] = getint() + A[i - 1];
	}

	pakuri_sort(N + 1, A);

	ll kotae = 0;
	ll mae = 1e18;
	int kazu = 0;
	rep(i, N + 1) {
		if (mae != A[i]) {
			mae = A[i];
			kazu = 0;
		}
		kotae += kazu++;
	}

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 6476
let scan_int () = Scanf.scanf " %d" (fun x -> x)
let print_int n = Printf.printf "%d\n" n

let rec solve i n ans =
  if i * i > n then ans
  else
    if n mod i = 0 then solve (i+1) n (min ans (i + (n/i) - 2))
    else solve (i+1) n ans

let init_val = int_of_float 1e12

let () =
  let n = scan_int() in
  print_int (solve 1 n init_val)

Measured memory_bytes: 2432
import sys
input = sys.stdin.readline
from collections import defaultdict
N = int(input())
S = input().strip()
Q = int(input())
K = list(map(int,input().split()))

'''
import random
import string
S = "".join(random.choices(string.ascii_uppercase, k=10**6))
Q =75 
K = [random.randint(1,10**6) for i in range(Q)]
'''

for k in K:
    ans = 0
    m = [0] * 3
    for i,s in enumerate(S):
        if i >= k:
            pre = S[i-k]
            if pre == 'D':
                m[0] -= 1 # m['D'] -= 1
                m[2] -= m[1] # m['DM'] -= m['M']
            elif pre == 'M':
                m[1] -= 1 # m['M'] -= 1
        if s == 'D':
            m[0] += 1 # m['D'] += 1
        if s == 'M': 
            m[2] += m[0] # m['DM'] += m['D']
            m[1] += 1# m['M'] += 1
        if s == 'C':
            ans += m[2] # ans += m['DM']
        #print(s,m)
    print(ans)



Measured memory_bytes: 76344
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(a[i] % 2 == 0)
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                cout<<"DENIED"<<endl;
                return 0;
            }
    }
    cout<<"APPROVED"<<endl;
    return 0;
}


Measured memory_bytes: 256
using System;
class program
{
  static void Main()
  {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    
    // データ型をintに変換
    int first = int.Parse(input[0]);
    int second = int.Parse(input[1]);
    
    // 2つの整数を順に並べた数
    // second が1桁、2桁、3桁（100）で異なる
   int number = 0;
    if ( second <= 9 )
    {
      number = (first * 10) + second;
    }
    else if (second <= 99 )
    {
      number = (first * 100) + second;
    }
    else
    {
      number = (first * 1000) + second;
    }
    
    
    // 自然数iを宣言
    int i = 0;
    int check = 0;
    
    // for文で2乗したらnumberと等しくなる値を探す
    for ( i=1; i<=number; i++)
    {
      // もし見つかったらYesの表示、Yesを伝えるためのcheckに1を代入
      if ( i*i == number )
      {
        Console.WriteLine("Yes");
        check = 1;
      }
    }
    // もしcheckに何も代入されず0のままだったら
    if (check ==0)
    {
      // Noの表示
      Console.WriteLine("No");
    }
  }
}

Measured memory_bytes: 11092
#解説を見て
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N -K):
    if A[i] <A[i+K]:
        print("Yes")
    else:
        print("No")

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

int main() {
  long D;
  cin >> D;
  
  //減点量の入力
  long c[27];
  for(int i=1; i<26+1; i++){
    cin >> c[i];
  }
  
  //加点量の入力
  long s[D+1][26+1];
  for(int i=1; i<D+1; i++){
  for(int j=1; j<26+1; j++){
    cin >> s[i][j];
  }}
  
  //開催日程の入力
  long t[D+1];
  for(int i=1; i<D+1; i++){
    cin >> t[i];
  }
  
  //過去の最終開催日を保持する配列
  long past[26+1] = {0};
  
  //日々の処理
  long ans=0;
  
  for(int day=1; day<D+1; day++){
    
    //仮の満足度を保持する配列
    long tempPoint[26+1] = {0};
    for(int tt=1; tt<26+1; tt++){

      //満足度の加点計算
      tempPoint[tt] += s[day][tt];

      //満足度の減点計算
      for(int num=1; num<26+1; num++){
        tempPoint[tt] -= ( c[num] * (day - past[num]) );
      }
    }
    
    //それぞれの選択に対する満足度の変化量を表示
    //for(int i=1; i<26+1; i++){
    //  cout << i << " : " << tempPoint[i] << endl;
    //}
    
    //仮の満足度から一番高い満足度の選択を出力
    int choice=1;
    for(int i=1; i<26+1; i++){
      if(tempPoint[choice] < tempPoint[i]) choice = i;
    }
    //cout << "choice " << choice << endl;
    cout << choice << endl;
  }

  return 0;
}


Measured memory_bytes: 3756
N = int(input())
A = list(map(int,input().split()))
x = A[0]
y = sum(A[1:])
ans = float('inf')
if N == 2:
    print(abs(A[0]-A[1]))
    exit()
for i in range(1,N-1):
    x += A[i]
    y -= A[i]
    ans = min(ans, abs(x-y))
print(ans)


Measured memory_bytes: 24812
#![allow(non_snake_case)]

use std::io;
use std::io::prelude::*;

fn read_multi_line(){
    let sin = io::stdin();
    let mut l_iter = sin.lock().lines();

    let word: String = l_iter.next().unwrap().unwrap().to_lowercase();

    let mut cnt = 0;
    for l in l_iter {
        let line = l.unwrap();
        if line == "END_OF_TEXT" {
            break;
        }
        for w in line.split_whitespace() {
            if w.to_lowercase() == word {
                cnt += 1;
            }
        }
    }
    println!("{}", cnt);
}

/// 遅くてTLE
fn _too_slow(){
    let sin = io::stdin();
    let mut word = String::new();
    sin.read_line(&mut word).ok();
    word = word.to_lowercase().replace("\n", "");
    let mut cnt = 0;

    loop {
        let mut line = String::new();
        sin.read_line(&mut line).unwrap();
        if line == "END_OF_TEXT" {
            break;
        } else {
            for w in line.split_whitespace() {
                if w.to_lowercase() == word {
                    cnt += 1;
                }
            }
        }
    }

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

fn main() {
    read_multi_line();
}



Measured memory_bytes: 5056
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
    int x, a, b, sum, calc;
    scanf("%d%d%d", &x, &a, &b);
    
    sum = x - a;
    calc = sum / b;
    
    printf("%d\n", sum - b * calc);
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <string.h>
using namespace std;

const int MAX_N=100,MAX_U=10000;
int n,u,w,v;
int dp[101][10001];
	
int main(){
	cin >> n >> u;
	
	memset(dp,0,sizeof(dp));
	
	for(int i=0;i<n;i++){
		cin >> v >> w;
		for(int j=0;j<=u;j++){
			if(j>=w) dp[i+1][j] = max(dp[i][j], dp[i][j-w]+v);
			else dp[i+1][j]=dp[i][j];
		}
	}
	
	cout << dp[n][u] << endl;
	return 0;
}

Measured memory_bytes: 7044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> X(n), Y(n), P(n);
  rep(i, n) cin >> X[i] >> Y[i] >> P[i];
  vector<vector<ll>> xmin(1<<n, vector<ll>(n)), ymin(1<<n, vector<ll>(n));
  rep(i, 1<<n) {
    rep(j, n) {
      xmin[i][j] = abs(X[j]);
      ymin[i][j] = abs(Y[j]);
    }
    rep(k, n) {
      if((i>>k)&1) {
        rep(j, n) {
          xmin[i][j] = min(abs(X[j]-X[k]), xmin[i][j]);
          ymin[i][j] = min(abs(Y[j]-Y[k]), ymin[i][j]);
        }
      }
    }
  }
  vector<ll> ans(n+1, longinf);
  auto dfs = [&](auto dfs, int i, ll xb, ll yb) -> void {
    if(i == n) {
      ll cost = 0;
      rep(j, n) cost += P[j] * min(xmin[xb][j], ymin[yb][j]);
      int cnt = __builtin_popcount(xb) + __builtin_popcount(yb);
      if(cnt > n) return;
      ans[cnt] = min(cost, ans[cnt]);
      return;
    }
    dfs(dfs, i+1, xb, yb);
    dfs(dfs, i+1, xb|(1<<i), yb);
    dfs(dfs, i+1, xb, yb|(1<<i));
  };
  dfs(dfs, 0, 0, 0);

  /* dummy */
  vector<ll> pw(n+1);
  pw[0] = 1;
  rep(i, n) pw[i+1] = pw[i] * 3;
  rep(i, pw[n]) {
    ll x = 0, y = 0;
    rep(j, n) {
      if(i/pw[j]%3 == 1) {
        x |= 1<<j;
      } else if(i/pw[j]%3 == 2) {
        y |= 1<<j;
      }
    }
    ll cur = 0;
    rep(j, n) cur += P[j] * min(xmin[x][j], ymin[y][j]);
    int cnt = __builtin_popcount(x) + __builtin_popcount(y);
    if(cnt > n) continue;
  }
  /* dummy */

  rep(i, n+1) cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 12976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

ll dp[51][5001];
int main(int argc, char const *argv[]) {
    int N,A;
    cin>>N>>A;
    vector<int> x(N),y(N);
    REP(i,N) {
        cin>>x[i];
        y[i]=x[i]-A;
    }
    FOR(i,0,N) {
        dp[i][2501+y[i]]++;
        REP(j,5002) {
            dp[i+1][j]+=dp[i][j];
            if(0<=j+y[i+1] && j+y[i+1]<5002) dp[i+1][j+y[i+1]]+=dp[i][j];
        }
    }
    cout<<dp[N-1][2501]<<endl;
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m, x;
    cin >> n >> m >> x;
    int a[m+1];
    for(int i=0;i<m;i++) cin >> a[i];
    int left=0, right=0;
    for(int i=0;i<m;i++){
        if(a[i]<x) left++;
        else right++;
    }
    cout << min(left, right);
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
l = [None]*N
for i in range(N):
    l[i] = list(map(int, input().split()))
l.sort()

prek = l[0][0]
prea = l[0][1]
cnt = N

for i in range(1,N):
    k,a = l[i]
    pre_reach = prek+prea
    now_reach_m = k-a
    now_reach_p = k+a
    #前の範囲が今回Xのマイナス側の範囲と被ると問題
    if pre_reach>now_reach_m:
        #前の範囲が今回の範囲よりplusに長ければ前のアームを消す
        if pre_reach>now_reach_p:
            cnt -= 1
            prek = k
            prea = a
        else:
            cnt -= 1
    else:
        prek = k
        prea = a
print(cnt)

Measured memory_bytes: 27872
n = int(input())
apple = list(map(int, input().split()))
a = 0
count = 0
while a == 0:
    for i, j in zip(apple, range(n)):
        if i%2==0:
            count += 1
            apple[j] = int(i/2)
        else:
            a = 1
            break
print(int(count/n))

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

int main(){
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];

    sort(a.begin(), a.end());

    int ans = a[2] * 10 + a[1] + a[0];

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 200005

struct MOD_INT{

  MOD_INT(ll arg_value){
	  value = arg_value;
	  value %= MOD;
  }
  MOD_INT operator-() const{
	  return MOD_INT(-value);
  }
  MOD_INT& operator+=(const MOD_INT arg){
    if ((value += arg.value) >= MOD){
    	value -= MOD;
    }
    return *this;
  }
  MOD_INT& operator-=(const MOD_INT arg){
    if ((value += MOD-arg.value) >= MOD){
    	value -= MOD;
    }
    return *this;
  }
  MOD_INT& operator*=(const MOD_INT arg){
	  (value *= arg.value) %= MOD;
	  return *this;
  }
  MOD_INT operator+(const MOD_INT arg) const{
	  return MOD_INT(*this) += arg;
  }
  MOD_INT operator-(const MOD_INT arg) const{
	  return MOD_INT(*this) -= arg;
  }
  MOD_INT operator*(const MOD_INT arg) const{
	  return MOD_INT(*this) *= arg;
  }
  ll value;
};

ll N,K;
ll A[SIZE];

int main(){

	scanf("%lld %lld",&N,&K);

	vector<ll> PLUS,NEG;

	for(ll i = 0; i < N; i++){

		scanf("%lld",&A[i]);

		if(A[i] < 0){

			NEG.push_back(A[i]);
		}else{

			PLUS.push_back(A[i]);
		}
	}

	ll num_NEG = NEG.size();
	ll num_PLUS = PLUS.size();

	bool FLG = false;

	if(num_PLUS > 0){

		if(N == K){

			FLG = (num_NEG%2 == 0);

		}else{

			FLG = true;
		}

	}else{ //num_PLUS == 0

		FLG = (K%2 == 0);
	}

	MOD_INT ans = 1;

	if(!FLG){ //答えが負になる

		for(int i = 0; i < N; i++){

			A[i] = abs(A[i]);
		}
		sort(A,A+N);

		for(int i = 0; i < K; i++){

			ans *= A[i];
		}
		ans *= -1;

	}else{

		sort(PLUS.begin(),PLUS.end());
		sort(NEG.rbegin(),NEG.rend());

		if(K%2 == 1){

			ans *= PLUS.back();
			PLUS.pop_back();
		}
		vector<ll> work;

		while(PLUS.size() >= 2){

			ll tmp = PLUS.back();
			PLUS.pop_back();
			tmp *= PLUS.back();
			PLUS.pop_back();
			work.push_back(tmp);
		}

		while(NEG.size() >= 2){

			ll tmp = NEG.back();
			NEG.pop_back();
			tmp *= NEG.back();
			NEG.pop_back();
			work.push_back(tmp);
		}
		sort(work.rbegin(),work.rend());

		for(ll i = 0; i < K/2; i++){

			ans *= work[i];
		}
	}

	printf("%lld\n",(ans.value+MOD)%MOD);

	return 0;
}


Measured memory_bytes: 8204
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools as fts
import itertools as its
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: str):
    return [NO, YES][sum(int(c) for c in N) % 9 == 0]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    print(f'{solve(N)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 76220
import math

a, b, h, m = map(int, input().split())

theta_h = 30*h + 0.5*m
theta_m = 6*m

theta = abs(theta_h - theta_m)

ans = math.sqrt(a**2 + b**2 -2*a*b*math.cos(math.radians(theta)))

print(ans)

Measured memory_bytes: 9500
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

int _(int x) {
  return x + 500;
}

struct point {
  int x;
  int y;
  int d;
  point(int x, int y, int d)
    : x(x), y(y), d(d) {
  }
};

void solve() {
  int t, n;
  while (cin >> t >> n, t) {
    vvi m(1000, vi(1000, false));
    while (n--) {
      int x, y;
      cin >> x >> y;
      m[_(x)][_(y)] = true;
    }
    int sx, sy;
    cin >> sx >> sy;
    queue<point> q;
    q.push(point(sx, sy, 0));
    int c = 0;
    while (q.size()) {
      point p = q.front();
      q.pop();
      if (p.d > t || m[_(p.x)][_(p.y)]) continue;
      c++;
      m[_(p.x)][_(p.y)] = true;
      int dx[] = {1, 1, 0, -1, -1, 0}, dy[] = {1, 0, -1, -1, 0, 1};
      rep(i, 6) q.push(point(p.x + dx[i], p.y + dy[i], p.d + 1));
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 10724
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn min (a: &i64, b: &i64)-> i64{
    if *a <= 0i64 {*b}
    else if *b <= 0i64  {*a}
    else if *a < *b {*a}
    else {*b}
}

fn max (a: &i64, b:&i64) -> i64{
    if *a < *b {*b} else {*a}
}

fn abs (a: &i64, b: &i64) -> i64{
    if *a - *b <= 0 {*b - *a} else {*a - *b}
}

fn main(){
    input!{
        y: i32
    }
    let s = match (y / 100, y % 100){
        (1...12, 1...12) => "AMBIGUOUS",
        (1...12, _) => "MMYY",
        (_, 1...12) => "YYMM",
        _ => "NA"
    };
    println!("{}", s);
}


Measured memory_bytes: 2160
#include <bits/stdc++.h>
using namespace std;
// Macros for easier access
#define ll long long
#define endl '\n'
#define F first
#define S second
#define umap unordered_map
#define uset unordered_set
#define test ll cases; cin>>cases; for(ll testCase = 1; testCase <= cases; testCase++)
#define fill(name, val) memset(name, val, sizeof(name));
#define mop(a, op, b)    (a%mod op b%mod)%mod
#define precise fixed<<setprecision(50)
#define vll vector<ll>
#define vvll vector<vll>
#define pll pair<ll, ll>
#define get(a, n)    for(ll it = 0; it < n; it++)    cin>>a[it];
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug(x) cerr << #x << " : " << (x) << endl
// Constants
#define MX 100001
#define mod 1000000007LL
#define inf 1000000000000000000LL
void init(){
	boost;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

// i, k => (i-1) (k, k-1, k-2, ..., k-ai)
// i, k-1 => (i-1) (k-1, k-2, ..., k-ai, k-ai-1)

// (i, k) = (i, k-1) - dp[i-1][k-ai-1] + dp[i-1][k]

int main(){
	init();
	ll n, k;	cin>>n>>k;
	ll a[n];	get(a, n);
	ll dp[n+1][k+1];	dp[0][0] = 1;
	for(ll i = 1; i <= k; i++)	dp[0][i] = 0;
	for(ll i = 1; i <= n; i++){
		dp[i][0] = 1;
		for(ll j = 1; j <= k; j++){
			dp[i][j] = mop(dp[i][j-1], +, dp[i-1][j]);
			if(j >= a[i-1] + 1)
				dp[i][j] = (dp[i][j] + mod - dp[i-1][j-a[i-1]-1])%mod;
		}
	}
	// for(ll i = 0; i <= n; i++){
	// 	for(ll j = 0; j <= k; j++)	cout<<dp[i][j]<<' ';
	// 	cout<<endl;
	// }
	cout<<dp[n][k];
}

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

int main(){
  int N,K;
  cin >> N >> K;
  string S;
  cin >>S;
  S = S + 'E';
  vector<int> C(N,0);
  int CI=0;
  for(int i=0;i<N;i++){
    char x=S.at(i);
    for(int j=1;j<2*N;j++){
      if(S.at(i+j) != x){
        C.at(CI) = j;
        CI ++;
        i=i+j-1;
        break;
      }
    }
  }
  ll sum=0;
  ll ans=0;
  K = min(N,2*K+1);
  for(int i=0;i<K;i++){
    sum+=C.at(i);
    C.at(i)=0;
  }
  C.at(K-1)=sum;
  for(int i=0;i<N;i++){
    ans += max(C.at(i)-1,0);
  }
  cout << ans << endl;
}

Measured memory_bytes: 892
using System;
using System.Linq;

class C
{
    static void Main()
    {
        Console.ReadLine();
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

        for (var i = a.Length - 2; i >= 0; i--)
        {
            if (a[i] > a[i + 1] + 1)
            {
                Console.WriteLine("No");
                return;
            }
            else if (a[i] == a[i + 1] + 1)
            {
                a[i]--;
            }
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 28124
from heapq import*
(N, M), *t = [map(int, s.split()) for s in open(0)]
q, z = [], 0
v = [[] for _ in [None] * 10**5]
for a, b in t:
    v[a - 1] += b,
for i in v[:M]:
    for j in i:
        heappush(q, -j)
    if q:
        z += -heappop(q)
print(z)

Measured memory_bytes: 62404
x,n = map(int, input().split())
if n == 0:
  print(x)
  exit()
p = list(map(int, input().split()))

a = 0
for i in range(x-1, -10**9, -1):
  if i not in p:
    a = i
    break
b = 0
for i in range(x, 10**9):
  if i not in p:
    b = i
    break

if abs(x-a) <= abs(x-b):
  print(a)
else:
  print(b)

Measured memory_bytes: 9208
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	readInt := func() int {
		sc.Scan()
		ans, _ := strconv.Atoi(sc.Text())
		return ans
	}
	a := readInt() // 1
	b := readInt() // 2
	c := readInt() // 10
	x := readInt() / 50

	var count int
	for i := 0; i <= a; i++ {
		tmpi := i * 10
		for j := 0; j <= b; j++ {
			tmpj := tmpi + j*2
			for k := 0; k <= c; k++ {
				tmpk := tmpj + k
				if tmpk == x {
					count++
				}
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];

vector<int> cnt;

void dfs(int v) {
    if (visited[v]) return;
    visited[v] = true;
    cnt[v/V]++;
    for(int u: to[v]) dfs(u);
}

int main(){
    int n;
    cin >> n;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        y += V;
        to[x].push_back(y);
        to[y].push_back(x);
    }

    ll ans = 0;
    rep(i, V*2) {
        if (visited[i]) continue;
        cnt = vector<int>(2);
        dfs(i);
        ans += (ll)cnt[0]*cnt[1];
    }
    ans -= n;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10240
while 1:
	try:
		ls = raw_input().split()
		dic = {}

		for word in ls:
			dic[word] = dic.get(word,0) + 1

		max1 = sorted(dic.items(), key=lambda x:x[1], reverse=True)

		max2 = ""
		for i in ls:
			if len(max2) < len(i):
				max2 = i

		print max1[0][0] + " " + max2
	except:
		exit()

Measured memory_bytes: 4216
# -*- coding: utf-8 -*-
from itertools import combinations

s = input()
n = len(s)

def gen():
    l = []
    for i in range(n):
        l.append(s[i])
        l.append("")
    return l

res = 0
for r in range(n):
    for p in combinations(range(n-1),r):
        e = gen()
        for i in p:
            e[2*i+1] = "+"
        res += eval("".join(e))

print(res)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] a) {
		Scanner s = new Scanner(System.in);
		String text = s.nextLine();
		int [] counts = new int[26];
		char[] cs = text.toCharArray();
		for (char c : cs) {
			counts[c - 'a']++;
		}
		for (int count : counts) {
			if(count % 2 == 1) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>
#include<deque>
#include<list>


using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;



int main() {
	int x, y;
	cin >> x >> y;
	


	int cnt = 0;
	
	if (x < 0 && abs(x) < abs(y)) {
		cnt++;
		x = -x;
	}

	if (x > 0 && abs(x) > abs(y)) {
		cnt++;
		x = -x;
	}

	cnt += abs(abs(x) - abs(y));
	x += abs(abs(x) - abs(y));
	if ((1LL *x) * y < 0) {
		cnt++;
		x -= x;
	}

	cout << cnt << endl;


}



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

using namespace std;

typedef long long ll;
typedef pair<ll,ll> pii;
typedef long double ld;
typedef pair<ld, ld> pdd;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll N = (ll)2e5 + 9;
const ll MOD = (ll)1e9 + 7;
const ll inf = (ll)1e15;
vector<pii> T[N];
vector<ll> Q[N];
vector<ll> R[N];
ll dis[N];
ll drv[N];
ll u[N];
ll v[N];
ll w[N];
ll cc[N];
ll dd[N];
ll deg[N];
bool had[N];

void add(ll &a, ll b){  
  a += b;
  if(a >= MOD) a -= MOD;
  else if(a < 0) a += MOD;
}

bool llersect(ll li, ll ri, ll lp, ll rp){
  if(rp <= li || lp >= ri) return false;
  return true;
}

int main(){
  fastIO;
  ll n, m, s, t;
  cin >> n >> m >> s >> t;
  for(ll i = 0 ; i < m ; i ++ ){
    cin >> u[i] >> v[i] >> w[i];
    T[u[i]].push_back(mp(v[i],w[i]));
    T[v[i]].push_back(mp(u[i],w[i]));
  }
  for(ll i = 1; i <= n; i ++ )
    dis[i] = inf;
  priority_queue<pii,vector<pii>,greater<pii>> pq;
  pq.push(mp(0,s));
  dis[s] = 0;
  ll node;
  ll dr;
  while(!pq.empty()){
    node = pq.top().se;
    dr = pq.top().fi;
    pq.pop();
    if(dr != dis[node]) continue;
    for(auto x : T[node]){
      if(dr + x.se < dis[x.fi]){
        dis[x.fi] = dr + x.se;
        pq.push(mp(dis[x.fi], x.fi));
      }
    }
  }
  queue<ll> rv;
  rv.push(t);
  had[t] = true;
  while(!rv.empty()){
    node = rv.front();
    rv.pop();
    for(auto x : T[node]){
      if(dis[x.fi] + x.se == dis[node]){
        deg[node] ++ ;
        Q[x.fi].push_back(node);
        R[node].push_back(x.fi);
        if(had[x.fi] == false){
          had[x.fi] = true;
          rv.push(x.fi);
        }
      }
    }
  }
  rv.push(s);
  cc[s] = 1;
  while(!rv.empty()){
    node = rv.front();
    rv.pop();
    for(auto x : Q[node]){
      if(had[x]){
        cc[x] = (cc[x] + cc[node]) % MOD;
        deg[x] -- ;
        if(deg[x] == 0) 
          rv.push(x);
      }
    }
  }
  ll ans = (cc[t] * 1ll * cc[t]) % MOD;
  rv.push(t);
  dd[t] = 1;
  for(ll i = 1; i <= n; i ++ ) deg[i] = 0;
  for(ll i = 1; i <= n; i ++ ){
    for(auto x : R[i]) deg[x] ++ ;
  }
  while(!rv.empty()){
    node = rv.front();
    rv.pop();
    for(auto x : R[node]){
      if(had[x]){
        dd[x] = (dd[x] + dd[node]) % MOD;
        deg[x] -- ;
        if(deg[x] == 0)
          rv.push(x);
      }
    }
  }
  ll ff = dis[t];
  ll uy;
  for(ll i = 1; i <= n; i ++ ){
    if(had[i] && dis[i] * 2ll == ff){
      uy = (cc[i] * 1ll * dd[i]) % MOD;
      uy = (uy * 1ll * uy) % MOD;
      add(ans, -uy);
    }
  }
  ll li, ri;
  ll lq, rq;
  for(ll i = 0 ; i < m ; i ++ ){
    if(dis[u[i]] > dis[v[i]]) swap(u[i], v[i]);
    if(dis[v[i]] != dis[u[i]] + w[i]) continue; // irrelevent
    li = dis[u[i]];
    ri = dis[v[i]];
    lq = ff - dis[v[i]];
    rq = lq + w[i];
    if(llersect(li,ri,lq,rq)){
      uy = (dd[v[i]] * 1ll * cc[u[i]]) % MOD;
      uy = (uy * 1ll * uy) % MOD;
      add(ans, -uy);
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 43000
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.Reader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;
import java.util.StringTokenizer;

/**
 * The Java template file for AtCoder online judge.
 */
public class Main {

  private static FastScanner scanner;
  private static PrintWriter printer;

  public static void solve() {
    int n = scanner.nextInt();
    int[] slimes = new int[n];
    for (int i = 0; i < n; i++) {
      slimes[i] = scanner.nextInt();
    }
    long result = recur(slimes, 0, n - 1, new Long[n][n]);
    printer.println(result);
  }

  private static long recur(int[] slimes, int low, int high, Long[][] cache) {
    if (low >= high) {
      return 0L;
    }
    if (cache[low][high] != null) {
      return cache[low][high];
    }
    long sum = 0;
    for (int i = low; i <= high; i++) {
      sum += slimes[i];
    }
    long result = Long.MAX_VALUE;
    for (int i = low; i <= high - 1; i++) {
      long next = recur(slimes, low, i, cache) + recur(slimes, i + 1, high, cache) + sum;
      result = Math.min(result, next);
    }
    cache[low][high] = result;
    return cache[low][high];
  }

  public static void main(String[] args) {
    scanner = new FastScanner();
    printer = new PrintWriter(System.out);
    solve();
    printer.flush();
  }

  private static class FastScanner {
    BufferedReader br;
    StringTokenizer st;

    public FastScanner(Reader in) {
      br = new BufferedReader(in);
    }

    public FastScanner() {
      this(new InputStreamReader(System.in));
    }

    public String next() {
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public String nextLine() {
      String str = "";
      try {
        str = br.readLine();
      } catch (IOException e) {
        e.printStackTrace();
      }
      return str;
    }

    public int[] readIntArray(int size) {
      int[] ret = new int[size];
      for (int i = 0; i < size; i++) {
        ret[i] = nextInt();
      }
      return ret;
    }
  }
}


Measured memory_bytes: 27184
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    
    ll N,M;
    ll fact1[maxn+1]={0},fact2[maxn+1]={0};
    string S,T;
    
    cin >> N>>M;
    cin >> S>>T;
    
    ll subM=M,subN=N;
    ll lcm=1;
    
    for(int i=2;i<=max(M,N);i++){
        while(subN%i==0||subM%i==0){
            lcm*=i;
            if(subN%i==0)subN/=i;
            if(subM%i==0)subM/=i;
        }
    }
    
    ll n=lcm/M,m=lcm/N;
    
    rep(i,lcm/m/n){
        if(S[n*i]!=T[m*i]){
            cout << -1<<endl;
            return 0;
        }
    }
    
    cout << lcm<<endl;
    
    return 0;
}


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

int main() {
  string s;
  cin>>s;
  sort(s.begin(), s.end());
  if (s[0] != s[1]) {
    cout<<"No"<<endl;
    return 0;
  }
  if (s[2] != s[3]) {
    cout<<"No"<<endl;
    return 0;
  }
  if (s[1] == s[2]) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
int MOD = 1e9+7;
using ll = long long;
using namespace std;
int main(){
    string s;
    cin >> s;
    bool h=false;
    if(s[0]=='B'){
        h=true;
    }
    int c=0;
    for(int i=1;i<s.size();i++){
        if(h&&s[i]=='W'){
            c++;
            h=false;
        }
        if(!h&&s[i]=='B'){
            c++;
            h=true;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = n; i < 1000; ++i) {
        int tmp = i;
        int s = tmp % 10;
        tmp /= 10;
        bool zorome = true;
        while (tmp > 0) {
            if (tmp % 10 != s) {
                zorome = false;
            }
            tmp /= 10;
        }
        if (zorome) {
            cout << i;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

//#define _DEBUG_ 3
void run() {
	int n; cin >> n;

	long long int ans = 1;
	int mod = 1000000000 + 7;

	for (int i = 1; i <= n; i++) {
		ans = (ans * i) % mod;
	}

	cout << ans << endl;
}

int main() {
#ifdef _DEBUG_
	using std::chrono::system_clock;
	using std::chrono::duration_cast;
	system_clock::time_point  start, end;
	std::ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
	for (int i = 0; i < _DEBUG_; i++) {
		cout << "-------------------------- (cnt:" << i << ")" << endl;
		start = system_clock::now();
		run();
		end = system_clock::now();
		int elapsed = duration_cast<std::chrono::milliseconds>(end - start).count();
		cout << "-------------------------- (time:" << elapsed << "ms)" << endl << endl;
}
#else
	run();
#endif
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in); 

        int N = sc.nextInt();
        int K = sc.nextInt();
        sc.close();
        long count_1 = 0;
        long count_2 = 0;
            if(K%2 == 1){
                if(N < K){
                    System.out.println(0);
                } else {
                    for(int i = K; i <= N; i = i + K){
                        count_1++;
                    }
                    System.out.println((long)Math.pow(count_1, 3));
                }
            } else{
                if(N >= (K/2)){
                    for(int i = K/2; i <= N; i = i + K){
                        count_1++;
                    }
                }
                if(N >= K){
                    for(int i = K; i <= N; i = i+K){
                        count_2++;
                    }
                }
                System.out.println((long)(Math.pow(count_1, 3)+Math.pow(count_2, 3)));
            }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//}

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int dp[1010][1010];
int bingo[3][3];
bool flag[3][3];
int I[100][20];

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	ll ans = 0;
	rep(i, n) {
		while (a[i] % 2 == 0) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	string S, T;
	cin >> S >> T;
	int length = 0;
	for(int i = 0; i <= S.size() - T.size(); i++) {
		int tmp = 0;
		for(int j = 0; j < T.size(); j++) {
			if(S[i + j] == T[j]) tmp++;
		}
		length = max(length, tmp);
	}

	cout << T.size() - length;
	return 0;
}


Measured memory_bytes: 3620
from collections import Counter

n, m = map(int, input().split())
graph = []
for _ in range(m):
    graph.extend([int(i) for i in input().split()])
    
cnt = Counter(graph)
ans = 'YES'
for i in cnt.values():
    if i % 2 != 0:
        ans = 'NO'
        break
print(ans)    

Measured memory_bytes: 94592