akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
   	 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
   	 static int a_dist[];
//	 static int mod = 998244353;
	 public static void main(String[] args) {
	        Scanner sc = new Scanner(System.in);
	        long K = sc.nextLong();
	        
	        long ans=0;
	        for(int i=1;i<=K;i++) {
	        	for(int j=1;j<=K;j++) {
	        		for(int k=1;k<=K;k++) {
	        			long tmp=GCD(i,j);
	        			tmp=GCD(tmp,k);
	        			ans=ans+tmp;
	        		}
	        	}
	        }
	        
	    	System.out.println(ans);
	        
	        	        	        
	 }
	 
	  static long GCD(long a,long b) {
		  long tmp;
		  long r;
		  if(a<b) {
			  tmp = a;
			  a = b;
			  b = tmp;				  
		  }
		  
		  r = a % b;
		  while(r!=0) {
			  a=b;
			  b=r;
			  r=a%b;
		  }
		  
		  return b;
	  }
}

Measured memory_bytes: 35792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

int main(void) {
	long long x, i, j, ans = 0;
	cin >> x;
	for (i = 0; ans < x; i++) {
		ans += i;
	}
	cout << i - 1 << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

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

    int a, b;
    cin >> a >> b;
    int ans = a * b;
    if (ans % 2 == 0) {
        cout << "Even" << "\n";
    } else {
        cout << "Odd" << "\n";
    }


}















Measured memory_bytes: 3628
def examA():
    S = SI()
    ans = "No"
    if "a" in S and "b" in S and "c" in S:
        ans = "Yes"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examA()


Measured memory_bytes: 38384
import java.util.Scanner;


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

		double v, t, y;
		int n;

		while(sc.hasNext()){
			v = sc.nextDouble();
			t = v / 9.8;
			y = 4.9 * t * t;

			n = (int)Math.ceil((y + 5) / 5);

			System.out.println(n);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  if (S == "RRR"){
    cout << 3 << endl;
  }else if (S == "RRS"){
    cout << 2 << endl;
  }else if (S == "SRR"){
    cout << 2 << endl;
  }else if (S == "SRS"){
    cout << 1 << endl;
  }else if (S == "RSR"){
    cout << 1 << endl;
  }else if (S == "RSS"){
    cout << 1 << endl;
  }else if (S == "SSR"){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
}

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

int main()
{
	long long int n,i, j,k, res, r = 0, g = 0, b = 0;
	cin >> n;
	string s;
	cin >> s;
	for (i = 0; i < n; i++)
	{
		if (s[i] == 'R')
			r++;
		else if (s[i] =='G') g++;
		else b++;
	}
	res = r*b*g;
	int x=(int)'R' + (int)'G' + (int)'B';
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			k = 2*j - i;
			if(k<n&&((int)s[i] + (int)s[j]+(int)s[k])== x)
			      res--;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#define N 100000
#define Q 100000
int lineSearch(int a,int b);
int S[N];

int main(){
  int i,n,q,T[Q],a=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&S[i]);
   scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    a+=lineSearch(T[i],n);
  }

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

  return 0;
}

int lineSearch(int a,int b){
  int i=0;
  S[b]=a;
  while(S[i]!=a){
    i++;
    if(i==b)return 0;   
  }
  return 1;
}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

template<typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n,0);
  rep(i,n) cin >> a[i];

  set<int> s(all(a));
  if(s.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 10368
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*

fun bsCondOpCl(N: Long, L: Long, R: Long): Long {
    fun isCondition(m: Long): Boolean {
        if ((1+m)*m/2 < N) return false
        return true
    }
    var l = L; var r = R
    while (l+1 < r) {
        val m = (l + r) / 2
        if (isCondition(m)) {
            r = m
        } else {
            l = m
        }
    }
    return r
}

fun solve() {
    val N = rd.readLong()
    
    var i = bsCondOpCl(N, 0, N)
    var sum = (1+i)*i/2

    if (N == sum) {
        println((1..i).joinToString("\n"))
        return
    }

    val ans = (1..i).toList().filter { it != sum-N }
    println(ans.joinToString("\n"))
}


//val rd = debug.Reader("etc", "cf16-final", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!! }
    catch (e: Exception) { throw e }
    finally { rd.close() }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
    val readListIntCol: (Int) -> List<Int> = { N -> (0 until N).map { readInt() } }
    val readListLongCol: (Int) -> List<Long> = { N -> (0 until N).map { readLong() } }
    val close: () -> Unit = { br.close() }
    protected fun finalize() { close() }
}


Measured memory_bytes: 37756
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int max=0;
  int tsk=1;
  for(int i = 0;i<=N;++i){
    int res=0;
    int kari=i;
    while(true){
        if(kari!=0){
            if(kari%2==0) ++res;
            else break;
        }
        else{
            break;
        }
        kari /= 2;
    }
    if(max < res){
      max = res;
      tsk=i;
    }
  }
  cout << tsk << endl;
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A + B >= C) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORTASC(c) sort((c).begin(),(c).end())
#define SORTDESC(c,t) sort((c).begin(),(c).end(), std::greater<t>());
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double PI  = acos(-1.0);

using ll = long long;
using namespace std;

int main() {
    ll n;
    vector<ll> v;

    cin >> n;

    FOR(i, 1, 10){
        FOR(j, 1 ,10){
            v.PB(i*j);
        }
    }

    REP(i, v.size()){
        if(v[i]==n){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int prime[1000001];

void eratosthenes(void) {
    int i, j;
    prime[0] = 1;
    prime[1] = 1;
    for(i = 2; i < 1000001; i++ ) {
        for(j = 2; j * i < 1000001; j++ ) {
            prime[i * j] = 1;
        }
    }
}

int main(void) {
    int i, n, count = 0; 
    eratosthenes();
    while(scanf("%d",&n), n != 0) {
        count = 0;
        for(i = 2; i <= n / 2; i++ ) {
            if(!prime[i]) {
                if(!prime[n - i]) {
                    count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

Measured memory_bytes: 4504
n,x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
if A[0] > x:
        ans += A[0] - x
        A[0] = x
for i in range(n-1):
    if A[i] + A[i+1] > x:
        ans += A[i] + A[i+1] - x
        A[i+1] -= A[i] + A[i+1] - x
print(ans)

Measured memory_bytes: 14540
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
    char tmp = a.charAt(0);
    int ans = tmp;
    if(ans >= 97){
      System.out.println("a");
    }else System.out.println("A");
	}
}


Measured memory_bytes: 35652
#include <bits/stdc++.h>
typedef long long ll;
#define MX 100005
#define PB push_back
ll MOD = 1e9 + 7;
using namespace std;
ll dp[101][MX];
ll cum[101][MX];
int main() {
	int n, k;
	cin >> n >> k;
	for (int i = 0; i <= k; ++i)
		cum[0][i] = 1;
	int a;
	int sum = 0;
	vector <int> vec(n);
	/*for (int &x : vec)
	     cin >> x;
	 sort(vec.begin(), vec.end());*/
	for (int i = 1; i <= n; ++i) {
		cin >> a;
		//a = vec[i - 1];
		sum += a;
		for (int j = 0; j <= k; ++j) {
			if (j <= sum) {
				int b = j - a;
				if (b <= 0)
					dp[i][j] = cum[i - 1][j];
				else
					dp[i][j] = (cum[i - 1][j] - cum[i - 1][b - 1]) % MOD;
				if(dp[i][j] < 0)
					dp[i][j] += MOD;
			}
			cum[i][j] = dp[i][j];
			if (j > 0)
				cum[i][j] = (cum[i][j] % MOD + cum[i][j - 1] % MOD) % MOD;
		}
	}
	/*if (sum < k)
		cout << 0 << endl;
	else if(sum == k)
		cout << 1 << endl;
	else*/
	cout << dp[n][k] << endl;
}

Measured memory_bytes: 158080
import java.util.Scanner;
import java.lang.Math;

public class Main {

    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < n; i++) {
            w[i] = sc.nextInt();
        }
        int s1 = 0;
        int s2 = 0;
        int min = 100;
        for (int i = 0; i < n; i++) {
            s1 += w[i];
            if (i == 0) {
                for (int t = i+1; t < n; t++) {
                    s2 += w[t];
                }
            } else {
                s2 -= w[i];
            }
            int sum = s2 - s1;
            if (sum < 0) {
                sum = -sum;
            }
            if (sum < min) {
                min = sum;
            }
        }
        System.out.println(min);
    }

}


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

bool comp(string s, string t) {
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] != t[i])
		{
			return false;
		}
	}
	return true;
}

int main() {
	string s, t;
	cin >> s >> t;

	if (comp(s, t)) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main()
{
    int n,i,a[50005];
    while(1)
    {
        cin>>n;
        if(n<2) break;
        int average=0,total=0;
        for(i=0;i<n;i++)
            {
                cin>>a[i];
                total=total+a[i];
            }
         average=total/n;
         int numbers=0;
         for(i=0;i<n;i++)
         {
             if(a[i]<=average)
             numbers++;
         }
         cout<<numbers<<endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define REP(i,a,b) for(ll i=a;i<b;i++)
using namespace std;
typedef long long ll;
std::vector<int> adj[200005];
ll arr[200005];
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

int main(int argc, char const *argv[])
{
	   FAST();

	ll n,x,k;
	cin>>n>>x>>k;
ll count;
if(n%x==0)
count=n/x;
else
count=(n/x)+1;


cout<<(count)*k;







	return 0;
}

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

int main(){
 int n, k;
 cin >> n >> k;
 vector<int> d(n);
 rep(i,k){
 	int m;
 	cin >> m;
 	rep(j,m){
 		int a;
 		cin >> a;
 		d[a-1] = 1;
 	}
 }
 int ans =0;
 rep(i,n) if (d[i] == 0) ans++;
 cout << ans << endl;
 return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e7+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll n;
ll a[100100];
ll t;
map<ll, ll> mii;

int main(){
	bool f = 0;
	ll MAX= -1, MIN = 1000000100;
	ll buf[2];
	cin >> n >> t;
	REP(i, n){
		cin >> a[i];
		if (i != 0){
			if (a[i] > a[i - 1]){
				f = 1;
				buf[0] = a[i];
			}
			else{
				if (f)mii[buf[0] - MIN]++;
				buf[0] = a[i];
				buf[1] = a[i];
				MIN = min(a[i], MIN);
				f = 0;
			}
		}
		else{
			buf[0] = a[i];
			buf[1] = a[i];
			MIN = a[i];
		}
	}
	if (f)mii[buf[0]- MIN]++;
	ll num = -1;
	for (P p : mii){
		num = p.first;
	}
	cout << mii[num] << endl;
}

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

int main(){
	int a, b, ab, digits[200], cnt=0, i;
	while(cin>>a>>b){
		digits[cnt]=1;
		ab = a+b;
		while(ab/=10){
			digits[cnt]++;
		}
		cnt++;
	}
	for(i=0;i<cnt;i++){
		cout<<digits[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin >> n;
    int bit;
    long long temp;

   for(long long i=3;i<=n;i++){
       temp = i;
       bit = 0;
       while(1){
           if(temp%10==3){
               bit=1;
               break;
           }
           temp = temp/10;
           if(temp==0){
               break;
           }
       }
       if(i%3==0||bit==1){
           cout << " " << i;
       }

   }
    cout << endl;
    return 0;

}


Measured memory_bytes: 3092
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

ll N , K ;
ll nodes[112345];
map<ll, vector<ll> > tree;
map<ll, bool> used;

void cal(ll node, ll less_color){
    nodes[node] = less_color;
    
    if(less_color < 2) less_color ++;
    else less_color = 2;
    
    ll cnt = 0;
    rep(i, tree[node].size()){
        if(used[tree[node][i]] == true) continue;
        
        used[tree[node][i]] = true;
        cal(tree[node][i], less_color + cnt );
        cnt ++;
        
    }
    
}


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

    cin >> N >> K ;
    
    rep(i, N-1){
        ll a, b ;
        cin >> a >> b;
        a--;b--;
        tree[a].pb(b);
        tree[b].pb(a);
    }
    
    used[0] = true;
    cal(0,0);
    
    ll ans = 1;
//    cerr << "----------" << endl;
    rep(i, N){
//        cerr << nodes[i] << endl;
        ans *= (K-nodes[i]);
        ans %= MOD;
    }
//    cerr << "----------" << endl;
    
    cout << ans << endl;
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

int main(){

  int a,b;

  cin >> a >> b;

  if(a % 3 == 0||b % 3 == 0 || (a+b) % 3 == 0){
    cout << "Possible" << endl;
  }
  else
    cout << "Impossible" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    vector<int> A(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
    }
    ll Q;
    cin >> Q;
    ll sum = 0;
    rep(i,N) sum += A[i];
    rep(i,Q){
        ll B,C;
        cin >> B >> C;
        ll kosu = mp[B];
        sum = sum - B*kosu + C*kosu;
        mp[B]=0;
        mp[C]+=kosu;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 9432
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            //整数A Bの入力
            int A, B, max;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]); 

            //最大値maxを求める
            max = A + B;

            if (max < A - B)
				max = A - B;
            if (max < A * B)
				max = A * B;
            

			
                           

            //最大値を出力(表示)
            Console.WriteLine(max);
            //入力
            Console.ReadKey();




        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

ll mod = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    ans += modpow(10, n, mod);
    ans %= mod;
    ans -= 2 * modpow(9, n, mod);
    ans %= mod;
    ans += modpow(8, n, mod);
    ans %= mod;
    ans += mod;
    ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
fun main(args:Array<String>) {
    val N = readLine()!!.toInt()
    val W = readLine()!!.split(" ").map(String::toInt)
    val weight = W
    var left = 0
    var right = weight.fold(0) {sum,ele -> sum + ele}
    var acc = right - left
    for (w in weight) {
        left += w
        right -= w
        val diff =  if (right - left < 0 ) {
            left - right
        } else {
            right - left
        }
        acc = if (acc > diff) {diff} else {acc} 
    }
    
    acc.run(::println)
}
 

Measured memory_bytes: 37924
#include<stdio.h>
#include<math.h>
 
int main(void){
    double pi,a,b,c,s,l,h,rad,x;
    scanf("%lf %lf %lf",&a,&b,&c);
    pi=acos(-1);
    rad=(c/(double)180)*pi;
    s=a*b*sin(rad)*0.5;
    x=sqrt(a*a+b*b-(double)2*a*b*cos(rad));
    l=a+b+x;
    h=(double)2*(s/a);
    printf("%f\n%f\n%f\n",s,l,h);
return 0;
}

Measured memory_bytes: 648
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
a = line[0] * 1
b = line[1] * 1 
k = line[2] * 1

_dividers = function(n) {
  var arr = []
  for (var i = 1; i*i <= n; i++) {
     if (n % i === 0) {
       arr.push(i)
       if ( i != n / i) {
         arr.push(n / i)
       }
     }
  }
  return arr.sort((a, b) => b - a)
}

a_d = _dividers(a)
b_d = _dividers(b)

arr = []
c = a_d.filter((x) => b_d.indexOf(x) >= 0)

console.log(c[k-1])

Measured memory_bytes: 7372
/*
连通块数量啊哥！
C = V - E + F
网格图常见套路
*/
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
using namespace std;

const int N = 2e3 + 10;
int n, m, Q;
int v[N][N], e[N][N], row[N][N], col[N][N], mp[N][N];
char g[N][N];

int main() {
    cin >> n >> m >> Q;
    rep(i, 1, n) {
        scanf("%s", g[i] + 1);
        rep(j, 1, m) {
            mp[i][j] = g[i][j] - '0';
            v[i][j] = v[i - 1][j] + v[i][j - 1] - v[i - 1][j - 1] + mp[i][j];
            e[i][j] = e[i - 1][j] + e[i][j - 1] - e[i - 1][j - 1] + (mp[i][j] && mp[i - 1][j]) + (mp[i][j] && mp[i][j - 1]);
            row[i][j] = row[i][j - 1] + (mp[i][j] && mp[i - 1][j]);
            col[i][j] = col[i - 1][j] + (mp[i][j] && mp[i][j - 1]);
        }
    }
    while (Q--) {
        int x0, y0, x2, y2; scanf("%d%d%d%d", &x0, &y0, &x2, &y2);
        int u = v[x2][y2] - v[x0 - 1][y2] - v[x2][y0 - 1] + v[x0 - 1][y0 - 1];
        int v = e[x2][y2] - e[x0 - 1][y2] - e[x2][y0 - 1] + e[x0 - 1][y0 - 1] - (row[x0][y2] - row[x0][y0 - 1]) - (col[x2][y0] - col[x0 - 1][y0]);
        printf("%d\n", u - v);
    }
    return 0;
}


Measured memory_bytes: 86296
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF 999999999
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int a[100005];
/**********************************************/

int main(){
    cin >> n;
    REP(i, n){
        cin >> a[i];
    }

    map<int, int> mp;

    REP(i, n){
        mp[a[i]]++;
        mp[a[i]+1]++;
        mp[a[i]-1]++;
    }
    
    int ans = 0;
    for(auto x: mp){
        ans = max(ans, x.second);
    }

    cout << ans << endl;
}


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

		long mod = (long)Math.pow(10,9)+7;
		
		if((2*X-Y)%3!=0) {
			System.out.println(0);
			return;
		}
		if((2*Y-X)%3!=0) {
			System.out.println(0);
			return;
		}
		
		long L = Math.max(X,Y);
		long S = Math.min(X,Y);
		if(L>S*2) {
			System.out.println(0);
			return;
		}
		
		
		long m = (2*X-Y)/3;
		long n = (2*Y-X)/3;
		
		
		//n+mCn を計算したい。
		FermatCombination com = new FermatCombination(n+m, mod);
		long ans = com.combine(n+m, n);
		System.out.println(ans);
		
	}
}

//フェルマーの小定理を用いた組み合わせ計算
class FermatCombination {
		
		long[] factrial;
		long[] inverse;
		long MOD;
		
		FermatCombination(long size, long mod) {
			
			this.factrial = new long[(int) size + 1];
			this.inverse = new long[(int) size + 1];
			this.MOD = mod;
			
			this.factrial[0] = 1;
			this.inverse[0] = 1;
			
			for (int i = 1; i <= size; i++) {
				factrial[i] = factrial[i - 1] * i % MOD;
				inverse[i] = pow(factrial[i], (int) MOD - 2) % MOD; //フェルマーの小定理
			}
		}
		
		long combine(long n, long k) {
			// nCk = n! / (k! * (n-k)!) 
			return factrial[(int) n] * inverse[(int) k] % MOD * inverse[(int)n - (int)k] % MOD;
		}
		
		long pow(long x, int n) {
			long ans = 1;
			while (n > 0) {
				if ((n & 1) == 1) {
					ans = ans * x % MOD;
				}
				x = x * x % MOD;
				n >>= 1;
			}
			return ans;
		}
	
}

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



int main() {
    int N;
    cin >> N;
    int a = 0, b = 0, c = 0, d = 0;
    string s;

    for (int i = 0; i < N; i++) {
        cin >> s;
        if (s == "AC") a++;
        if (s == "WA") b++;
        if (s == "TLE") c++;
        if (s == "RE") d++;
    }

    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(){
	long long int N, sum = 0;
	scanf("%lld", &N);
	for (int i=1 ; i<=N ; i++){
		if (i%3 == 0 || i%5 == 0 ){
			continue;
		}
		else {
			sum+=i;
		}
	}
	printf("%lld", sum);
	
	return 0;
}

Measured memory_bytes: 1684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int r;
  r = (N % 100) % 10; 
  if(r==3) cout << "bon" << endl;
  else if(r==0 || r==1 || r==6 || r==8) cout << "pon" << endl;
  else cout << "hon" << endl;
  return 0;
}

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

int main() {
    int N,K,ans;
    cin >> N >> K;
  	long long h[110000] = {0};
    for(int i = 0; i < N; ++i) cin >> h[i];
    ans = 0;
    long long p[N-K+1] = {0};
    sort(h,h+N);
    for(int i =0; i<N-K+1; ++i){
            p[i] = h[i+K-1] - h[i];
        }

    sort(p,p+N-K+1);
    cout << p[0] << endl;
}


Measured memory_bytes: 1920
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = a * b;
		
		if(a >= 10 || b >= 10) {
			System.out.println(-1);
		}
		else {
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	long long int f[4];
	
	f[0]=a*c;
	f[1]=a*d;
	f[2]=b*c;
	f[3]=b*d;
	sort(f,f+4);
	cout<<f[3]<<"\n";
	
}


Measured memory_bytes: 3660
// by adiforluls
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST         ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll           long long
#define ld           long double
#define pb           push_back
#define mp           make_pair
#define pii          pair<int,int>
#define mii          map<int,int>
#define vi           vector<int>
#define vll          vector<long long>
#define all(a)       (a).begin(),(a).end()
#define clz(a)       __builtin_clz(a) // count leading zeroes
#define ctz(a)       __builtin_ctz(a) // count trailing zeroes
#define popc(a)      __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define lul          1000000007
#define rep(i,a,b)   for(int i=a;i<b;i++)
#define rfor(i,a,b)  for(int i=a; i>=b; i--)
#define SIZE         1000005
#define F            first
#define S            second
#define mod          998244353
 
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " = " << arg1<<" |";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define endl         '\n'
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;

vi a[26];
void solve()
{
    string s,t; cin>>s>>t;
    int n = s.size();
    rep(i,0,n)
    {
        a[s[i]-'a'].pb(i);
    }
    ll ans = 0, prev=-1;
    rep(i,0,(int)t.size())
    {
        if(a[t[i]-'a'].size() == 0) {cout<<-1; return;}
        int l = 0, r = a[t[i]-'a'].size()-1, check=-1;
        while(l<=r)
        {
            int mid = l + (r-l)/2;
            if(a[t[i]-'a'][mid]>prev)
            {
                check = a[t[i]-'a'][mid];
                r = mid-1;
            }
            else l = mid+1;
        }
        if(check == -1)
        {
            ans+=n;
            prev = a[t[i]-'a'][0];
        }
        else{
            prev = check;
        }
    }
    prev++;
    ans+=prev;
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    while(t--){
       solve();
    }
    return 0;
}

Measured memory_bytes: 1228
from collections import defaultdict

n = int(input())

result = defaultdict(int)

for x in range(1, 101):
	for y in range(1, 101):
		for z in range(1, 101):
			result[x*x + y*y + z*z + x*y + y*z + z*x] += 1
				
for i in range(1, n + 1):
	print(result[i])

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

int main() {
  int n,ans = 0;
  string s;
  cin >> n >> s;
  for(int i = 1;i < n;i++){
    vector<bool>x(26,false);
    vector<bool>y(26,false);
    for(int j = 0;j < n;j++){
      if(j < i) x[s[j]-'a'] = true;
      else y[s[j]-'a'] = true;
    }
    int sum = 0;
    for(int j = 0;j < 26;j++) if(x[j]&&y[j]) sum++;
    ans = max(ans,sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args){
		sc=new Scanner(System.in);
		Dice2 dice=new Dice2();
		for(int i=0;i<6;i++){
			dice.set(sc.nextInt(),i);
		}
		int q=sc.nextInt();
		for(int i=0;i<q;i++){
			int u=sc.nextInt();
			int f=sc.nextInt();
			dice.find(u, f);
			System.out.println(dice.get(3));
		}
	}

}
class Dice2 {
	private int d[]=new int[6];
	void set(int a,int i){
			d[i]=a;
	}
	int get(int i){
		return d[i-1];
	}
	void roll(String s){
		for(int i=0;i<s.length();i++){
			int temp=d[0];
			switch(s.charAt(i)) {
			case 'N':
				d[0]=d[1];
				d[1]=d[5];
				d[5]=d[4];
				d[4]=temp;
				break;
			case 'S':
				d[0]=d[4];
				d[4]=d[5];
				d[5]=d[1];
				d[1]=temp;
				break;
			case 'E':
				d[0]=d[3];
				d[3]=d[5];
				d[5]=d[2];
				d[2]=temp;
				break;
			case 'W':
				d[0]=d[2];
				d[2]=d[5];
				d[5]=d[3];
				d[3]=temp;
				break;
			}
		}
	}
	void find(int u,int f){
		for(int i=0;i<4;i++){
			if(d[1]==f)break;
			roll("N");
		}
		if(d[1]!=f){
			roll("E");
			for(int i=0;i<4;i++){
				if(d[1]==f)break;
				roll("N");
			}
		}
		for(int i=0;i<4;i++){
			if(d[0]==u)break;
			roll("E");
		}
	}
}

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

int main() {
  string s; cin >> s;
  int a = 0, b = 0;
  for (int i = 0; i < 3; i ++) {
    if (s[i] == 'A') a ++;
    else b ++;
  }

  if (a && b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s, p, r = map(int, input().split())
t = input()
output = []
ans = 0
for i in range(n):
    if i < k:
        if t[i] == "r":
            ans += r
            output.append("r")
        if t[i] == "p":
            ans += p
            output.append("p")
        if t[i] == "s":
            ans += s
            output.append("s")
    else:
        if t[i] == output[i-k]:
            output.append(1)
        else:
            if t[i] == "r":
                ans += r
                output.append("r")
            if t[i] == "p":
                ans += p
                output.append("p")
            if t[i] == "s":
                ans += s
                output.append("s")

print(ans)

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std; 
typedef long long ll; 
const int N = 1e5+5;

int p[N];

int main()
{	
	int n,x;
	ll ans = 0;
	scanf("%d",&n);
	memset(p,0,sizeof(p));
	for(int i = 1;i <= n;++i){
		scanf("%d",&x);
		ans += x;
		p[x]++;
	}
	
	int q,u,v;
	scanf("%d",&q);
	while(q--){
		scanf("%d%d",&u,&v);
		if(!p[u]) printf("%lld\n",ans);
		else{
			ans -= (ll)p[u]*(ll)u;
			ans += (ll)p[u]*(ll)v;
			p[v] += p[u];
			p[u] = 0;
			printf("%lld\n",ans);
		}
	}
	return 0;
}


Measured memory_bytes: 4200
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
class permut{
  constructor(ary){
    var n=ary.length;
    this.array=ary;
    this.id=Array(n).fill().map((a,i)=>i);
    this.id2=Array(n).fill().map((a,i)=>i);
    this.moved=Array(n).fill(0);
    this.left=Array(n).fill(true);
    this.done=false;
  }
  static swap(self,i){
    var u=self.id2[i],v=self.id2[i-1],t=self.id[u];
    self.id2[i]=self.id2[i-1],self.id2[i-1]=u;
    self.id[u]=self.id[v],self.id[v]=t;
  }
  next(){
    if(this.done)return;
    var n=this.array.length,res=Array(n);
    for(var i=0;i<n;i++)res[i]=this.array[this.id2[i]];
    while(i--){
      if(this.moved[i]<i){
        this.moved[i]++;
        var m=this.left[i]?this.id[i]:this.id[i]+1;
        permut.swap(this,m);
        return res;
      }
      this.moved[i]=0,this.left[i]=!this.left[i];
    }
    this.done=true;
    return res;
  }
}

console.log(main());
function main(){
  var n = o.a();
  var x = o.m(n);
  var per = new permut(Array(n).fill().map((a,i)=>i));
  var s;
  var ans = 0, sum = 0;
  while((s = per.next()) !== undefined){
    sum++;
    for(var i = 1; i < n; i++){
      var x1 = x[s[i-1]][0], y1 = x[s[i-1]][1];
      var x2 = x[s[i]][0], y2 = x[s[i]][1];
      var dx = x1 - x2, dy = y1 - y2;
      ans += Math.sqrt(dx*dx+dy*dy)
    }
  }
  return ans/sum;
}

Measured memory_bytes: 10188
/* _  */ 

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <sstream> //stringstream
#include <cstring> // getline
#include <cmath>
#include <unordered_set>
#include <limits>
#include <unordered_map>


#define go(i,init ,n) for(int  i=init ;i<n ;i++) 
#define X first 
#define Y second
#define ll long long 
#define ALL arr.begin() ,arr.end()
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define FI freopen("input.txt", "r", stdin);
#define FO freopen("output.txt", "w", stdout);
#define OO 1000000000000
#define oo 1e9
#define N 200100

using namespace std;


ll int MOD = 1e9 + 7;
ll int memo[100005];
ll int prime[1000000];
ll int fac[N], ifac[N];
ll int inv[N];
vector<ll int>primes;

ll int gcd(ll int a, ll int b){ if (b == 0) return a; return gcd(b, a%b); }
bool IsPrime(ll int x){ if (x == 1) return false; for (ll int i = 2; i*i <= x; i++){ if (x%i == 0) return false; } return true; }
void seive(ll int n){ prime[0] = prime[1] = 1; for (ll int i = 2; i*i <= n; i++) if (!prime[i]){ for (ll int j = i*i; j <= n; j += i) prime[j] = 1;} }
bool sortMa7boub(const pair<int, int> &a, const pair<int, int> &b) { if (a.first == b.first) return (a.second < b.second); return(a.first >b.first); }
bool IsVowel(char c){ return(c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o'||c=='y' || c == 'A' || c == 'E' || c == 'I' || c == 'U' || c == 'O'||c=='Y'); }
bool IsEqual(string s1, string s2){ if (s1.length() != s2.length())return 0; go(i, 0, s1.length()) if (s1[i] != s2[i])return 0; return 1; }
ll int  powMod(ll int  base, ll int  pw) { ll int ret = 1; while (pw) { if (pw & 1) ret = (ret * base) % MOD; base = (base * base) % MOD; pw >>= 1; }return ret; }

/*should use makeFact before useing C or P */
void makeFact(){ fac[0] = ifac[0] = 1; for (ll int i = 1; i<N; i++) { fac[i] = (fac[i - 1] * i) % MOD; ifac[i] = powMod (fac[i], MOD - 2); } }
inline void Init(){ inv[1] = 1; for (int i = 2; i < N; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;}
ll int  C(ll int  a, ll int  b) { if (a < b) return 0; return (((fac[a] * ifac[b]) % MOD) * ifac[a - b]) % MOD; }
ll int P(ll int a, ll int b){ if (a < b) return 0; return(fac[a] * ifac[a - b]) % MOD; }


int a = -1;

string AL = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vector<ll int>vec; ll int n, m;

bool isValid(int i) { return i >= 0 && i < n; }

ll int mini(int indx )
{
	
	ll int &ret = memo[indx];

	if (indx == n-1)
		return 0;
	
	if (~ret)
		return ret;

	ll int a = OO, b = OO;

		a = mini(indx + 1) + abs(vec[indx] - vec[indx + 1]);

	if (isValid(indx+2))
		b = mini(indx + 2) + abs(vec[indx] - vec[indx + 2]);

	return ret =  min(a, b);
}

int main()
{
	IO;
	/*freopen("txt.in", "r", stdin);
	freopen("txt.out","w",stdout);*/
	
	cin >> n;
	vec.resize(n);
	go(i, 0, n)
		cin >> vec[i];

	
	memset(memo, -1, sizeof memo);
	ll int ans = mini(0);

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



Measured memory_bytes: 6528
S = input()
binary = '111'
for i in range(2**(len(S)-1)):
  binary = str(format(i,'b')).zfill(3)
  if int(S[0])+int(S[1])*(-1)**(int(binary[0]))+int(S[2])*(-1)**(int(binary[1]))+int(S[3])*(-1)**(int(binary[2]))==7:  
    break
B = binary.replace('0','+').replace('1','-')
print(S[0]+B[0]+S[1]+B[1]+S[2]+B[2]+S[3]+'=7')

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 303;
const Int INF = 1e18;
Int dp[MAX][MAX][MAX];
signed main(){
  Int n,k;
  cin>>n>>k;
  vector<Int> hs(n);
  for(Int i=0;i<n;i++) cin>>hs[i];

  for(Int i=0;i<MAX;i++)
    for(Int j=0;j<MAX;j++)
      for(Int l=0;l<MAX;l++)
        dp[i][j][l]=INF;

  for(Int i=0;i<n;i++){
    dp[i][i][i]=hs[i];
    for(Int j=0;j+1<MAX;j++){
      for(Int l=0;l<i;l++){
        chmin(dp[i][j+0][i],dp[i-1][j][l]+max<Int>(hs[i]-hs[l],0));
        chmin(dp[i][j+1][l],dp[i-1][j][l]);
      }
    }
  }

  Int ans=(k==n?0:INF);
  for(Int j=0;j<=k;j++)
    for(Int l=0;l<n;l++)
      chmin(ans,dp[n-1][j][l]);

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


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

int main(){
	int H, N;
	cin >> H >> N;
	int A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
		H -= A[i];
	}
	if(H > 0)cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3996
N = int(input())
XY_list = [[] for _ in range(N)]
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        XY_list[i].append([person - 1, state])
ans = 0
for i in range(1 << N):
    bool = True
    for j in range(N):
        if (i >> j) & 1 == 1:
            for person, state in XY_list[j]:
                if (i >> person) & 1 != state:
                    bool = False
                    break

    if bool:
        ans = max(ans, bin(i)[2:].count("1"))
print(ans)


Measured memory_bytes: 74260
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
const int IINF = INT_MAX;
using ll = long long;
using P = pair<int,int>;
#define INF 100000000

const double pai = 3.141592653589793238;
int main(){
    int n; cin >> n;
    string s; cin >> s; 
	int ans = 1;
    rep(i,n-1){
    	if(s[i] == s[i+1]) continue;
    	ans++;
    }
     cout << ans << endl;
    return 0;	
}

Measured memory_bytes: 512
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

from collections import Counter

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    a, b = LI()
    a_s = prime_factorize(a)
    b_s = prime_factorize(b)
    a_keys = set(Counter(a_s).keys())
    b_keys = set(Counter(b_s).keys())
    print(str(1 + len(a_keys & b_keys)))

if __name__ == '__main__':
    main()



Measured memory_bytes: 3316
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
//#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string S;
	cin >> S;
	int num = 0;
	rep(i, S.size())if (S[i] == 'o')num++;
	cout << 700 + 100 * num;
}

Measured memory_bytes: 256
import os, sys, re, math

(N, M) = [int(n) for n in input().split()]
favorites = [n + 1 for n in range(M)]
for i in range(N):
    d = [int(n) for n in input().split()]
    favorites = list(filter(lambda x: x in d[1:], favorites))

print (len(favorites))


Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

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

		int k, s, ans = 0;
		k = sc.nextInt();
		s = sc.nextInt();
		sc.close();

		for (int i = 0; i <= k; ++i) {
			for (int j = 0; j <= k; ++j) {
				int tmp = s - i - j;
				if (tmp >= 0 && tmp <= k)
					ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21204
# 53
import math
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def f(a, b):
    return max(len(str(a)), len(str(b)))


n = I()
divs = make_divisors(n)
divs = [elem for elem in divs if elem <= math.sqrt(n)]
ans = f(divs[0], n // divs[0])
for i in divs:
    ans = min(ans, f(i, n // i))
print(ans)


Measured memory_bytes: 9252
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

int main() {
    int n; cin >> n;
    map<int, int> cnt;
    while (n--) {
        int a; cin >> a;
        cnt[a]++;
    }
    priority_queue<int> pq;
    for (auto &p: cnt) {
        for (int i = 0; i < p.second / 2; i++) pq.emplace(p.first);
    }
    if (pq.size() < 2) return !(cout << 0 << endl);
    int x = pq.top(); pq.pop();
    int y = pq.top(); pq.pop();
    cout << 1LL * x * y << endl;
    return 0;
}


Measured memory_bytes: 4992
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let a: Vec<i32> = s.by_ref().take(n).map(|a| a.parse().unwrap()).collect();
	let mut edges = vec![vec![]; n];
	for _ in 0..n - 1 {
		let a = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let b = s.next().unwrap().parse::<usize>().unwrap() - 1;
		edges[a].push(b);
		edges[b].push(a);
	}
	let mut ans = vec![0; n];
	let mut dp = vec![std::i32::MAX; n];
	let graph = Graph { edges, a };
	graph.dfs(&mut ans, &mut dp, 0, std::usize::MAX, 0);
	use std::io::Write;
	let out = std::io::stdout();
	let mut out = out.lock();
	for ans in ans {
		writeln!(out, "{}", ans).unwrap();
	}
}

struct Graph {
	edges: Vec<Vec<usize>>,
	a: Vec<i32>,
}

impl Graph {
	pub fn dfs(&self, ans: &mut [i32], dp: &mut [i32], v: usize, last: usize, depth: usize) {
		let i = dp[..depth].lower_bound(&self.a[v]);
		ans[v] = std::cmp::max(i as i32 + 1, *ans.get(last).unwrap_or(&0));
		let l = dp[i];
		dp[i] = self.a[v];
		for &to in self.edges[v].iter() {
			if to != last {
				self.dfs(ans, dp, to, v, depth + 1);
			}
		}
		dp[i] = l;
	}
}

pub trait BinarySearch<'a, T: 'a> {
	fn lower_bound(&self, x: &T) -> usize;
}

impl<'a, T: 'a + Ord> BinarySearch<'a, T> for [T] {
	fn lower_bound(&self, x: &T) -> usize {
		let mut first = 0;
		let mut len = self.len() - first;
		while len > 0 {
			let half = len >> 1;
			let mid = first + half;
			use std::cmp::Ordering;
			match self[mid].cmp(x) {
				Ordering::Less => {
					first = mid + 1;
					len = len - half - 1;
				}
				Ordering::Equal | Ordering::Greater => {
					len = half;
				}
			}
		}
		first
	}
}


Measured memory_bytes: 41568
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
using Int = long long;
bool solve(string& s)
{
    if (s[0] == s[s.size()-1]) {
        return (s.size() - 1) % 2;
    } else {
        return s.size() % 2;
    }
}
int main()
{
    string s; cin >> s;
    cout << (solve(s) ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 512