akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)

stack<int> s;
int a,b;

void op() {
	a = s.top();
	s.pop();
	b = s.top();
	s.pop();
}

int main() {
	string w;
	while (cin >> w) {
		if(w == "+") {
			op();
			s.push(a + b);
		} else if (w == "-") {
			op();
			s.push(b - a);
		} else if (w == "*") {
			op();
			s.push(b * a);
		} else {
			s.push(atoi(w.c_str()));
		}
	}
	cout << s.top() << endl;
	return 0;
}

Measured memory_bytes: 3176
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

/*　入力方法
１、簡単に書く
fmt.Scan
2,たくさん読む()
bufio.Scanner
(テキストを1行ずつ読み込む。fileからscannerを生成し、scan()が末尾に達してfalseを返すまで読み込む。Text()を呼ぶことで文字列として取り出すことができる)
3,長い行を読む
bufio.ReadLine
4, スペース区切りのデータを読み込む
sc.Split(bufio.ScanWords)
#########バッファの最大読み込みの数を変更するには
sc.Buffer(buf,MaxBuf)#MAXBUFのところにサイズをしていする
*/

/* 書き込み
１、接頭辞F（前）
書き込み先を指定できる
2,接頭辞S(前)
出力ではなくフォーマットした結果を文字列で返す
3,接頭辞 f（後ろ）
フォーマット（文字列型など）を指定することができる
４、接頭辞 ln（後ろ）
オペランドの間に半角スペースが入り、文字列の最後に開業が追加

・interface{}型
どのような型がくるかわからないときに演算はできないが全ての型を受ける
new(T)
任意の型

*/
/*
フォーマット文字列
%c 1文字を出力　　　%d　　整数を10進む
%s 文字列を出力

指定子	対応する型	説明	使用例
%c	char	１文字を出力する
%s	char *	文字列を出力する
%d	int, short	整数を10進で出力する
%u	unsigned int, unsigned short	符号なし整数を10進で出力する
%o	int, short,unsigned int, unsigned short	整数を8進で出力する
%x	int, short,unsigned int, unsigned short	整数を16進で出力する
%f	float	実数を出力する
%e	float	実数を指数表示で出力する
%g	float	実数を最適な形式で出力する
%ld	long	倍精度整数を10進で出力する
%lu	unsigned long	符号なし倍精度整数を10進で出力する
%lo	long, unsigned long	倍精度整数を8進で出力する
%lx	long, unsigned long	倍精度整数を16進で出力する
%lf	double	倍精度実数を出力する
*/
/*
文字
*/
const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()

}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

/*strings.Splitで入力したものを分ける*/
func Scanner() []string {
	var s string
	if sc.Scan() {
		s = sc.Text()
	}
	slice := strings.Split(s, " ")
	return slice

}

/*"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""*/
func main() {
	tArr := Scanner()
	for i := 0; i < 3; i++ {
		fmt.Print(string(strings.ToUpper(tArr[i])[0]))
	}
	fmt.Println()

}

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

typedef pair<int,int> P;

bool compare(P A, P B){
  
  int y1 = A.first, x1 = A.second;
  int y2 = B.first, x2 = B.second;
  
  return y1 * x2 < x1 * y2;
}

int h, w;
string s[605];

int check(int y, int x){
  
  char a = s[y][x], b = s[y+1][x], c = s[y+1][x+1], d = s[y][x+1];
  
  if( a == '.' && b == '#' && c == '.' && d == '.' ) return 1;
  
  if( a == '.' && b == '.' && c == '.' && d == '#' ) return -1;
  
  if( a == '#' && b == '.' && c == '#' && d == '#' ) return 1;
  
  if( a == '#' && b == '#' && c == '#' && d == '.' ) return -1;
  
  return 0;
}

vector<P> point;

int main(){
  
  cin>>h>>w;
  
  for(int i=0;i<=h+1;i++) s[i] = string( w + 2, '.' );
  
  for(int i=h;i>=1;i--){
    for(int j=1;j<=w;j++) cin>>s[i][j];
  }
    
  for(int i=0;i<=h;i++){
    
    for(int j=0;j<=w;j++){
      
      int r = check( i, j );
      
      if( !r ) continue;
      
      point.push_back(P( i, j ));
      
    }
    
  }
  
  sort( point.begin(), point.end(), compare );
  
  int ans = 1, x = 1, idx = 0, len = (int)point.size();
  
  while( idx < len ){
    
    while( idx < len && compare( point[idx], point[idx+1] ) == false ){
    
      x += check( point[idx].first, point[idx].second );
      
      idx++;
      
    }

    x += check( point[idx].first, point[idx].second );
      
    idx++;
    
    ans = max( ans, x );
    
  }
  
  cout<<ans<<endl;
  
  return 0;
}



Measured memory_bytes: 4176
#include <bits/stdc++.h>
using namespace std;
#define INF 1e9+7
typedef long long int ll;
const int maxn = 100000;
ll mod = INF;

ll fac[maxn+1];
ll rfac[maxn+1];

//最小二乗法
ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll a=pow(x,y/2);
        return (a*a)%mod;
    }else{
        ll a=pow(x,(y-1)/2);
        return a*a%mod*x%mod;
    }
}


int main(){
    ll ans=0;
    ll n;
    ll k;
    ll a[maxn+1];
    ll sum[maxn+1]={0};

    cin >> n>>k;
    for(int i=1;i<=n;i++){
        cin >> a[i];
    }

    sort(a+1,a+n+1);
    sum[1]=a[1];
    for(int i=2;i<=n;i++){
        sum[i]=sum[i-1]+a[i];
    }
    
    fac[0]=fac[1]=rfac[0]=rfac[1]=1;

    for(ll i=1;i<=maxn;i++){
        fac[i]=fac[i-1]*i%mod;
    }

    //逆元を求める
    rfac[maxn]=pow(fac[maxn],mod-2);
    
    for(ll i=maxn;i>=1;i--){
        rfac[i-1]=rfac[i]*i%mod;
    }
    
    if(k==1){
        ans=0;
    }else{
        
        for(ll K=k;K<=n;K++){
            
            ll S=sum[n]-sum[K-1]-sum[n-K+1];
            while(S<0)S+=mod;
            S=S%mod;
            ll nCk=fac[K-2]*rfac[k-2]%mod*rfac[K-k]%mod;
            ans=(ans+S*nCk%mod)%mod;
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 6724
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
int n,p[11],a[11]={0,1,2,4,7,12,20,29,38,52,73};
ll g[11][11],M;
int main()
{
	scanf("%d",&n);
	for(int i=2;i<=n;++i)
	{
		for(int j=1;j<i;++j)g[i][j]=g[j][i]=(M+1)*a[j];
		if(i==n)break;
		for(int j=1;j<=i;++j)p[j]=j;
		do
		{
			ll s=0;
			for(int j=1;j<i;++j)s+=g[p[j]][p[j+1]];
			M=max(M,s);
		}while(next_permutation(&p[1],&p[i+1]));
	}
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=n;++j)
			printf("%lld ",g[i][j]);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define pb push_back
#define ll long long int
# define pll pair<ll,ll>
# define pii pair<int,int>
# define fio ios_base::sync_with_stdio(false); cin.tie(NULL)
int main()
{   ll n,k;
    ll a[200009];
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    ll money=1000;
    ll stocks=0;
    a[n+1]=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i+1]>a[i])
        {
            stocks+=money/a[i];
            money=money%a[i];
        }
        else  if(a[i]>a[i+1])
        {
            money+=stocks*a[i];
            stocks=0;
        }
    }
    cout<<money;
}


Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N,M;
  cin>>N>>M;
  priority_queue<int, vector<int>, greater<int> > q;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    int A;
    cin>>A;
    q.push(A);
  }
  vector<pair<int,int> >  card(M);
  for (int i = 0; i < M; i++)
  {
    cin>>card[i].second >> card[i].first;
  }
  sort(ALL(card), greater<pair<int,int> >());

  int index = 0;
  int COUNT = 0;
  while(true)
  {
    int C = card[index].first;
    int TOP = q.top();
    // DEBUG(TOP);
    if(TOP >= C)break;
    else
    {
      q.pop();
      q.push(C);
    }
    
    COUNT++;
    if(index ==M-1 && COUNT == card[index].second)
    {
      break;
    }

    if(COUNT == card[index].second)
    {
      COUNT = 0;
      index++;
    }
    
  }

  int ANS = 0;
  while(!q.empty())
  {
    ANS += q.top();
    q.pop();
  }
  cout<<ANS<<endl;

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


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

#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
#define ANS(ans) cout << (ans) << endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;
typedef pair<int, int> P;

// repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, n) for (long long i = 0; i < (n); ++i)

int main() {
  char ch;
  cin>>ch;
  ANS(char(ch + 1));
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = []
n.times do
  a << gets.chomp.to_i
end
ans = 0
n.times do |i|
  ans += a[i] / 2
  if a[i] % 2 == 1 && i != n - 1 && a[i + 1] != 0 then
    ans += 1
    a[i + 1] -= 1
  end
end
puts ans


Measured memory_bytes: 2684
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI = 3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM =
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<ll>A(2), B(2);
	cin >> A[0] >> A[1];
	cin >> B[0] >> B[1];
	ll ans = LLONG_MIN;
	for (ll i = 0; i < 2; i++)
	{
		for (ll j = 0; j < 2; j++)
		{
			ans = max(ans, A[i] * B[j]);
		}
	}
	cout << ans << endl;
	return 0;
}


//252908XL

/*
comments:-

*/


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

typedef long long ll;
typedef pair<int, int> P;

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second

/*-------------------------------------------------*/




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

  sort(all(L));

  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      for(int k = j + 1; k < n; k++){
        if(L[k] < L[i] + L[j] &&
           L[i] != L[j] &&
           L[j] != L[k] &&
           L[k] != L[i] )
          ans++;
      }
    }
  }
  cout << ans << endl;
return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

set<ll> base_minus2(ll N){
    set<ll> S;
    if(N == 0){
        return S;
    }
    if(N > 0){
        ll c = 0;
        while(pow(4, c+1) - 1 < 3 * N){
            c++;
        }
        S.insert(2*c);
        set<ll> T = base_minus2(N - pow(4, c));
        set<ll> U;
        for(auto p : S){
            U.insert(p);
        }
        for(auto p : T){
            U.insert(p);
        }
        return U;
    }
    ll c = 0;
    while(2*(pow(4, c+1) - 1) < -3 * N){
        c++;
    }
    S.insert(2*c+1);
    set<ll> T = base_minus2(N + 2 * pow(4, c));
    set<ll> U;
    for(auto p : S){
        U.insert(p);
    }
    for(auto p : T){
        U.insert(p);
    }
    return U;
}

int main()
{
    ll N;
    cin >> N;
    if(N == 0){
        cout << 0 << endl;
        return 0;
    }
    ll c = 0;
    if(N > 0){
        while(pow(4, c+1) - 1 < 3 * N){
            c++;
        }
        c = 2 * c + 1;
    }
    else{
        while(2*(pow(4, c+1) - 1) < -3 * N){
            c++;
        }
        c = 2 * c + 2;
    }
    set<ll> S = base_minus2(N);
    string ans;
    rep(i, c){
        if(S.count(c-i-1)){
            ans += "1";
        }
        else{
            ans += "0";
        }
    }
    cout << ans << endl;
}

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

long long gcd(long long a,long long b)
{
    long long c;
    while(b > 0)
    {
        c = a % b;
        a = b;
        b = c;
    }
    return a;
}

int main()
{
    long long sum = 0;
    long long n = 200;
    scanf("%lld", &n);
    for(long long i = 1; i <= n; i++)
        for(long long j = 1; j <= n; j++)
            for(long long k = 1; k <= n; k++)
            {
                sum += gcd(gcd(i, j), k);
            }
    printf("%lld", sum);
    return 0;
}


Measured memory_bytes: 3844
N,m = map(int,input().split())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])

A = sorted(A)
money = 0
for n in range(N):
    if m > A[n][1]:
        m -= A[n][1]
        money += A[n][1] * A[n][0]
    elif m <= A[n][1]:
        money += m * A[n][0]
        break

print(money)


Measured memory_bytes: 20840
x,y = map(int,raw_input().split())
if x==y:
    print x
else:
    if y>x:
        tmp = x
        x = y
        y = tmp
    i=2
    ans = 1
    al = []
    while i*i<=x:
        if x % i ==0:
            if y % i==0:
                al.append(i)
                x = x/i
                y = y/i
                continue
        i+=1
    if len(al)!=0:
        for j in al:
            ans *= j
    print ans

Measured memory_bytes: 6432
import sys
def input():
    return sys.stdin.readline()[:-1]
n=int(input())
abc=[list(map(int,input().split())) for i in range(n)]
happy=[[0,0,0] for i in range(n)]
happy[0]=abc[0]
# print(happy)
for i in range(n-1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            happy[i+1][k]=max(happy[i+1][k],happy[i][j]+abc[i+1][k])
    # print(happy)
print(max(happy[-1]))

Measured memory_bytes: 72156
-- noch nicht fertig

import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sort, group)
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  let
    sieve :: Int -> [(Int, Bool)] -> VU.Vector Bool
    sieve m = VU.accum (flip const) (VU.replicate m True) . map (flip (,) False) . concatMap f
      where
        f :: (Int, Bool) -> [Int]
        f (k, True) = map (k *) [2..(pred m `div` k)]
        f (k, _)    = map (k *) [1..(pred m `div` k)]
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    v = sieve (succ $ 10 ^ 6) . map ((,) <$> head <*> (== 1) . length) . group . sort $ as :: VU.Vector Bool
  print . length . filter (v VU.!) $ as

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 53064
import scala.annotation.tailrec

object Main extends App {

  import scala.io.StdIn._

  solve
  @tailrec
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    val numbers = Array.tabulate(n){_ ⇒ readLine.trim.toInt}
    var count = 0
    for (limit ← (1 until n).reverse) {
      for (i ← 0 until limit){
        if (numbers(i) > numbers(i + 1)){
          count += 1
          val temp = numbers(i)
          numbers(i) = numbers(i + 1)
          numbers(i + 1) = temp
        }
      }
    }
    println(count)
    solve
  }
  implicit class Extension[T](value :T){
    @inline
    def let[A](@inline func: T ⇒ A): A = func(value)
    @inline
    def also(@inline func: T ⇒ Unit): T = {func(value); value}
  }
}


Measured memory_bytes: 44068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, R = 0;
  cin >> N;
 
  for (int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    R += (B - A) + 1;
  }
  cout << R;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	unsigned long long N;
	vector<unsigned long long> P;
	cin >> N;
	int i;
	for (i = 0; i < 5; i++) {
		unsigned long long p;
		cin >> p;
		P.push_back(p);
	}
	sort(P.begin(), P.end());
	if (N % P.at(0) == 0) {
		cout << 4 + N / P.at(0);
	}
	else {
		cout << 5 + N / P.at(0);
	}
}

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

double e_value(int i){
    if(i==1){
        return 1.0;
    }else{
        double tmp;
        tmp = i * (1+i) / 2; 
        return tmp / i;
    }

}

int main(){
    int N,K;
    cin >> N >> K;
    int p[N];
    double p_value[N];
    double result=0.0,result_tmp = 0.0;

    for(int i=0;i<N;i++){
        cin >> p[i];
        p_value[i] = e_value(p[i]);
        //cout << "pv " << p_value[i] << endl;
    }

    for(int index=0;index<N-K+1;index++){
        if(index==0){
            for(int i=index;i<index+K;i++){
                result_tmp += p_value[i];
            }
        }else{
            result_tmp = result_tmp - p_value[index-1] + p_value[index+K-1];
        }

        if(result<result_tmp){
            result = result_tmp;
        }
        //cout << result_tmp << endl;
    }

    cout << fixed << setprecision(12) << result << endl;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	final int MAX_N = 100000000;
	boolean[] primes;
	void eratosthenes() {
		primes = new boolean[MAX_N + 1];

		primes[2] = true;
		for (int i = 3; i <= MAX_N; i += 2)
			primes[i] = true;

		for (int i = 3; i <= Math.sqrt(MAX_N); i += 2) {
			if (!primes[i]) continue;
			for (int j = i * 2; j <= MAX_N; j += i)
				primes[j] = false;
		}
	}
	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int ans = 0;
		for (int i = 0; i < n; i++) {
			int v = scan.nextInt();
			ans += primes[v] ? 1 : 0;
		}
		System.out.println(ans);
	}
	public static void main(String[] args) {
		Main main = new Main();
		main.eratosthenes();
		main.run();
	}
}



Measured memory_bytes: 140192
#include<iostream>
using namespace std;
int main(){
	string a;
	int n;
	cin>>n>>a;
	int k=0;
	for(int i=0;i<n;i++)
		if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
			k++;
	cout<<k<<"\n";
	return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var array = Console.ReadLine().Split().Select(_ => int.Parse(_)).ToArray();

            var maxCount = 0;
            var count = 0;
            for (int i = 0; i < N - 1; i += count == 0 ? 1 : count)
            {
                count = 0;
                for (int j = i; j < N - 1; j++)
                {
                    if (array[j] < array[j + 1])
                        break;

                    count++;
                }

                if (count > maxCount)
                    maxCount = count;
            }

            Console.WriteLine(maxCount);
        }
    }
}


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

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define plll pair<pll,pll>
#define pdd pair<long double,long double>
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<ll,vector<ll>,greater<ll> >pq;
priority_queue<ll,vector<ll>,greater<ll> >pq1;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,c,l,r,s,q;
    ll n,t,k;
    cin>>n;
    ll ans=n/2;
    if(n%2==0)
        ans--;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,a[3],MAX=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    MAX = max(MAX,a[i]);
  }
  for(int i=1;i<=MAX;i++){
    bool dotti=true;
    for(int j=0;j<n;j++){
      if(a[j] % i != 0) dotti = false;
    }
    if(dotti == true) cout << i << endl;
  }
}


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

using namespace std;

int main()
{
    long long N;
    cin >> N;
    long long ans = 1e18;
    for (long long i = 1;i <= sqrt(N+1);i++) {
        if(N%i == 0){
            long long j = 0;
            j = N/i;
              if((i-1)+(j-1)< ans){
                    ans = (i-1)+(j-1);
                }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  int64_t D, G;
  cin >> D >> G;
  vector<int64_t> P(D), C(D);
  for(int64_t i=0; i<D; i++){
    cin >> P.at(i) >> C.at(i);
  }
  int64_t Ans=10000;
  for(int64_t i=0; i<(int64_t)pow(2, D); i++){
    int64_t subAns=0;
    vector<int64_t> V(D, 0);
    int64_t k=i;
    for(int64_t j=0; j<D; j++){
      if(k%2==1){
        V.at(j)=1;
      }
      k/=2;
    }
    int64_t Sum=0;
    int64_t L=0;
    for(int64_t j=0; j<D; j++){
      L+=V.at(j)*P.at(j);
      Sum+=V.at(j)*(100*(1+j)*P.at(j)+C.at(j));
    }
    if(Sum>=G){
      subAns=L;
    }
    else{
      for(int64_t j=D-1; j>=0; j--){
        if(V.at(j)==0){
          if(Sum+100*(1+j)*(P.at(j)-1)<G){
            goto finish;
          }
          else{
            L+=(G-Sum-1)/(100*(1+j))+1;
            subAns=L;
            break;
          }
        }
      }
    }
    Ans=min(subAns, Ans);
finish: L=0;
  }
  cout << Ans << endl;
}


Measured memory_bytes: 4068
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    string s;
    cin >> N >> s;
    
    vector<char> t(N);
    vector<char> animal = {'S', 'W'};
    rep(i, 2) rep(j, 2) {
        t[0] = animal[i];
        t[1] = animal[j];
        REP(k, N - 1) {
            if (t[k] == 'S') {
                if (s[k] == 'o') t[k + 1] = t[k - 1];
                else t[k + 1] = 'S' + 'W' - t[k - 1];
            } else {
                if (s[k] == 'x') t[k + 1] = t[k - 1];
                else t[k + 1] = 'S' + 'W' - t[k - 1];
            }
        }
        bool judge = true;
        if (t[0] == 'S') {
            if (s[0] == 'o' ^ t[1] == t[N - 1]) judge = false;
        } else {
            if (s[0] == 'x' ^ t[1] == t[N - 1]) judge = false;
        }
        if (t[N - 1] == 'S') {
            if (s[N - 1] == 'o' ^ t[0] == t[N - 2]) judge = false;
        } else {
            if (s[N - 1] == 'x' ^ t[0] == t[N - 2]) judge = false;
        }
        if (judge) {
            rep(i, N) cout << t[i];
            cout << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

enum MOD = (10 ^^ 9) + 7;

void main()
{
    long N = lread();
    auto A = aryread();
    long[long] D;
    foreach (a; A)
    {
        D[a] = (a in D) ? D[a] + 1 : 1;
        D[a + 1] = (a + 1 in D) ? D[a + 1] + 1 : 1;
        D[a - 1] = (a - 1 in D) ? D[a - 1] + 1 : 1;
    }
    auto K = D.keys;
    auto V = D.values;
    zip(V, K).sort!"b<a"();
    long x = K.front;
    A.map!(a => abs(x - a) <= 1).sum().writeln();
}


Measured memory_bytes: 10812
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ar array
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)
 
using namespace __gnu_pbds;
using namespace std;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > iil;
typedef pair<ll,int> li;
typedef pair<int,int> ii;
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;

inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
}
ll pMod(ll x,ll n,ll mod)
{ ll r=1;
  while(n>0)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
    n%=mod;
  }
  return r;
 
}
 
//think recursively also;
const int mxn=3000;
int n;
db p[mxn+1];
db dp[mxn+1][mxn+1];
void solve()
{ 
  cin>>n;
  for(int i=1;i<=n;i++)
    cin>>p[i];
  dp[0][0]=1.0;

  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<=i;j++)
    {  
       if(j==0)
        {dp[i][j]=dp[i-1][j]*(1.0-p[i]);
          continue;
        }
       dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1.0-p[i]);
    }
  }
  // for(int i=1;i<=n;i++)
  // {
  //   for(int j=0;j<=i;j++){

  //     cout<<dp[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }
  db ans=0;
  for(int j=(n+1)/2;j<=n;j++)
  {
    ans+=dp[n][j];
  }
  cout<<setprecision(10)<<ans;
}
int main()
{
  fast();
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {//cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}

Measured memory_bytes: 49964
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	vector<int> a(3);
	for (int i = 0; i < 3; i++) cin >> a[i];
	sort(a.begin(), a.end());
	cout << a[2] * 10 + a[1] + a[0] << endl;
	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 data[] = new int[n];
		for(int i = 0;i < n;i++) data[i] = sc.nextInt();
		int min , max,ans;
		min = max =data[0];
		for(int i = 1;i < n;i++) {
			if(max < data[i])max = data[i];
			if(min > data[i])min = data[i];
		}
		ans = max - min;
		System.out.println(ans);
	}

}


Measured memory_bytes: 21972
#include<cstdio>
int main(){
    int as=0,bs=0,ins;
    for(int i=0;i<4;i++){
        scanf("%d",&ins);
        as+=ins;
    }
    for(int i=0;i<4;i++){
        scanf("%d",&ins);
        bs+=ins;
    }
    printf("%d\n",as>bs?as:bs);
}

Measured memory_bytes: 0
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        Long k = Long.parseLong(sc.nextLine());

        long ans = solve(s, k);
        System.out.println(ans);
    }

    static long solve(String s, long k) {
        // 全部同じ文字の場合は置き換える数 * K回
        if (isAllSameChar(s)) {
            return s.length() * k / 2;
        }

        // 異なる文字が1つでもある場合
        List<Long> ranlength = new ArrayList<>();
        long ranl = 1;

        // 元文字列で何回置き換える必要があるか計算する
        // ex) issii -> 122 = 2回
        for (int i = 1; i <= s.length(); i++) {
            if (i == s.length()) {
                ranlength.add(ranl);
                break;
            }
            if (s.charAt(i) == s.charAt(i - 1)) {
                ranl++;
            } else {
                ranlength.add(ranl);
                ranl = 1;
            }
        }

        // 先頭と最後が同じ文字の場合、置き換える数が変わる
        long ans = 0;
        if (isSameFirstAndLastChar(s)) {
            // @formatter:off
            /**
             * 最初と最後が同じ文字の場合、Kの回数次第で連結部が変わる
             * ただし、中間部分は数列の繰り返しになる
             * issii
             * 12       2
             *
             * issiiissii
             * 12 32    2
             *
             * issiiissiiissii
             * 12 32 32 2
             *
             * K=3のissiiissiiissiiの場合...
             * ①最初と最後の部分は元々のランレングス圧縮したリストの各値を/2した合計
             * 12       2
             * -> (1/2 + 2/2 + 2/2)
             * -> 2 回数
             *
             * ②真ん中部分(ex K=3)は同じ値が連続するので、元リストの先頭を置換して計算
             *    32 32
             * -> (3/2 + 2/2 + 3/2 + 2/2)
             * -> 4 回数
             *
             * ①②を合算して6回が答えになる
             */
            // @formatter:on
            // 置換前の状態は全部足してOK
            for (int i = 0; i < ranlength.size(); i++) {
                ans += ranlength.get(i) / 2;
            }

            // 最初の値を最後の値との合算値に置き換える
            ranlength.set(0, ranlength.get(0) + ranlength.get(ranlength.size() - 1));

            // 中間の部分の計算。0番目～length-1番目までを加算
            long tmp = 0;
            for (int i = 0; i < ranlength.size() - 1; i++) {
                tmp += ranlength.get(i) / 2;
            }

            // 中間部分をK-1回分加算する。置換前の要素で1回足しているので、-1.
            ans += tmp * (k - 1);

        } else {

            // 元の文字列を何回置き換えるか計算し、それをK倍したのが答え
            // ex) abbc 3 ->(121 = 1回) * 3 = 3回
            for (int i = 0; i < ranlength.size(); i++) {
                ans += ranlength.get(i) / 2;
            }
            ans *= k;
        }

        return ans;
    }

    private static boolean isAllSameChar(String s) {
        char bef = s.charAt(0);
        for (int i = 0; i < s.length(); i++) {
            if (bef != s.charAt(i)) {
                return false;
            }
        }
        return true;
    }

    private static boolean isSameFirstAndLastChar(String s) {
        return s.charAt(0) == s.charAt(s.length() - 1);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long lld;
typedef long double llu;
int main()
{
    std::ios::sync_with_stdio(false);
    lld t = 1;
    // cin >> t;
    while(t--) {
        lld n;
        cin >> n;
        multiset<llu> ms;
        for(lld i = 0; i < n; i++) {
            lld x;
            cin >> x;
            ms.insert(x * 1.0);
        }

        for(lld i = 0; i < n - 1; i++) {
            auto id1 = ms.begin();
            llu avg = *id1;
            id1++;
            avg += *id1;
            llu newVal = avg * 1.0 / 2;
            auto it1 = ms.begin();
            auto it2 = ms.begin();
            it2++;
            ms.erase(it1);
            ms.erase(it2);
            ms.insert(newVal * 1.0);
        }
        cout << fixed << setprecision(10);
        cout << *(ms.begin()) << "\n";
    }
}

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

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> c(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> c.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < (1<<H); i++) {
    for(int j = 0; j < (1<<W); j++) {
      int cnt = 0;
      for(int k = 0; k < H; k++) {
        for(int l = 0; l < W; l++) {
          if(c.at(k).at(l) == '#' && (1&i>>k) == 0 && (1&j>>l) == 0) {
            cnt++;
          }
        }
      }
      if(cnt == K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<iostream>
#include<queue>
#include<vector>
#include<cstdlib>
#include<cstdio>
using namespace std;

int main(){
    char N[3];
    int flag = 0;
    cin >> N;
    for(int i =0;i<3;i++){
        if(N[i] == '7'){
            flag=1;
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }else
    {
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 3636
s = input()
t = input()

ns = len(s)
nt = len(t)

ans = nt

for i in range(ns - nt + 1):
  d = 0
  for j in range(nt):
    if t[j] != s[i+j]:
      d += 1
  ans = min(ans, d)
print(ans)

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

using namespace std;

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

	int n;
	while(cin>>n,n){
		int w,h;cin>>w>>h;
		vector< vector<int> > field(501,vector<int>(501,0));
		for(int i=0;i<n;i++){
			int x,y;cin>>x>>y;
			field[x][y]=1;
		}
		int s,t;cin>>s>>t;
		int res=0;
		for(int i=1;i<=w-s+1;i++){
			for(int j=1;j<=h-t+1;j++){
				int tmp=0;
				for(int k=0;k<s;k++){
					for(int l=0;l<t;l++){
						if(field[i+k][j+l]) tmp++;
					}
				}
				res=max(res,tmp);
			}
		}
		cout<<res<<endl;
	}
}

Measured memory_bytes: 3892
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        double x = in.doubleNext();
        double y = in.doubleNext();
        double hour = in.doubleNext();
        double mins = in.doubleNext();
        hour += (mins) / 60;

        double hourAngle = (hour * 360) / 12;
        double minAngle = (mins * 360) / 60;

        double angle = Math.abs(hourAngle - minAngle);
        out.println(Math.sqrt(x * x + y * y - 2 * x * y * Math.cos(Math.toRadians(angle))));

        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




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

int main(){
	int s;
	cin >> s;
	int a[500000], b;
	for(int i=0; i<500000; i++){
		a[i] = 0;
	}
	b = s;
	for(int i=0; i<500000; i++){
		if(i == 0){
			a[b] = 1;
		}else{
			if(b % 2 == 0){
				b = b/2;
			}else{
				b = 3*b + 1;
			}
			a[b]++;
			if(a[b] == 2){
				cout << i+1 << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
#define INF 0x7FFFFFFF
#define mod 1000000007
typedef long long ll;
////////////////////////////////////////////////////////////

int main(){
	string s;
	cin >> s;
	map<char,int> m;
	rep(i,0,s.size())
		m[s[i]]++;
	
	if( !m['N'] && m['S'] )
		No;
	else if( m['N'] && !m['S'] )
		No;
	else if( m['W'] && !m['E'] )
		No;
	else if( !m['W'] && m['E'] )
		No;
	else
		Yes;

	ret 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)
result = nil
n.times do |i|
  break if i == array.length - 1
  r = array[0..i].inject(:+) - array[(i + 1)..(-1)].inject(:+)
  r = - r if r < 0
  if result == nil || r < result
    result = r
  end
end
puts result

Measured memory_bytes: 1788
import java.util.*;

public class Main {
    int n;
    int[] ps;
    int[] xs;
    ArrayList<ArrayList<Integer>> graph;
    PriorityQueue<Node> queue;
    int[] ys;
    private final static int INF = 1 << 29;

    public static void main(String[] args) {
        Main m = new Main();
        m.read();
        m.solve();
    }

    private void read() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        ps = new int[n];
        xs = new int[n];
        graph = new ArrayList<>(n);
        for (int i = 0; i < n; i++)
            graph.add(new ArrayList<>());
        for (int i = 1; i < n; i++)
            ps[i] = sc.nextInt() - 1;
        for (int i = 0; i < n; i++)
            xs[i] = sc.nextInt();
        createGraph();
    }

    private void createGraph() {
        for (int i = 1; i < n; i++) {
            graph.get(ps[i]).add(i);
        }
        queue = new PriorityQueue<>((n1, n2) -> Integer.compare(n2.dist, n1.dist));
        Queue<Node> q = new LinkedList<>();
        q.add(new Node(0, 0));
        while (!q.isEmpty()) {
            Node n = q.poll();
            for (int i: graph.get(n.id)) {
                q.add(new Node(i, n.dist+1));
            }
            queue.add(n);
        }
    }

    private void solve() {
        ys = new int[n];
        boolean flg = false;
        while (!queue.isEmpty()) {
            Node n = queue.poll();
            int min = dp(n.id);
            if (min == INF ) {
                flg = true;
                break;
            }
            ys[n.id] = min;
        }
        if (flg) {
            System.out.println("IMPOSSIBLE");
        }
        else {
            System.out.println("POSSIBLE");
        }
    }

    private int dp(int trg) {
        ArrayList<Integer> ls = graph.get(trg);
        if (ls.size() == 0)
            return 0;
        int[][] dp = new int[ls.size()+1][xs[trg]+1];
        for (int i = 0; i < dp.length; i++)
            Arrays.fill(dp[i], INF);
        dp[0][0] = 0;
//        for (int i: ls)
//            dp[0][0] += xs[i];
        for (int i = 1; i < dp.length; i++) {
            int n = ls.get(i-1);
            for (int j = xs[trg]; j >= 0; j--) {
                if (j + xs[n] <= xs[trg]) {
                    dp[i][j+xs[n]] = Math.min(dp[i][j+xs[n]],
                                        dp[i-1][j] + ys[n]);
                }
                if (j + ys[n] <= xs[trg]) {
                    dp[i][j + ys[n]] = Math.min(dp[i][j + ys[n]],
                                            dp[i-1][j] + xs[n]);
                }
            }
        }
        int ret = INF;
        for (int i = 0; i < dp[dp.length-1].length; i++) {
            ret = Math.min(ret, dp[dp.length-1][i]);
        }
        return ret;
    }

    private class Node {
        int id;
        int dist;
        Node(int node, int d) {
            id = node;
            dist = d;
        }

        @Override
        public String toString() {
            return String.format("%d: %d", id, dist);
        }
    }
}


Measured memory_bytes: 35332
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 1000000
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back

typedef long long ll;
typedef double db;

using namespace std;

int main()
{
    io;
    //freopen("in.txt" , "r" , stdin);
    //freopen("out.txt" , "w" , stdout);

    ///Let the showdown begin

    int s,t,v;
    cin >> s >> t >> v;

    db d = ceil((db)s/t);
    if(d <= v)
        cout << "Yes" << nl;
    else
        cout << "No" << nl;

    ///Happily DONE
    return 0;
}


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	static int[][] bingo = new int[3][3];

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

		String a = sc.next();
		String b = sc.next();

		int num = Integer.parseInt(a + b);

		int root = (int) Math.sqrt(num);

		if (Math.pow(root, 2) == num) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22612
from collections import deque

n, m, k = map(int,input().split())

friend_sum = [[] for i in range(n)]
block = []
block_sum = [[] for i in range(n)]

for i in range(m):
    a, b = map(int,input().split())
    if a > b:
        a, b = b, a
    friend_sum[a-1].append(b-1)
    friend_sum[b-1].append(a-1)

for i in range(k):
    a, b = map(int,input().split())
    block.append([a, b])
    block_sum[a-1].append(b-1)
    block_sum[b-1].append(a-1)

label = 0
g_label = [0 for i in range(n)]
g_list = [0 for i in range(n)]

for i in range(n):
    if g_label[i] == 0:
        label += 1
        g_label[i] = label
        g_list[label-1] += 1
        q = deque([])
        q.append(i)
        while len(q) != 0:
            num = q.popleft()
            for j in range(len(friend_sum[num])):
                if g_label[friend_sum[num][j]] == 0:
                    g_label[friend_sum[num][j]] = label
                    g_list[label-1] += 1
                    q.append(friend_sum[num][j])

ans = 0

for i in range(n):
    ans = g_list[g_label[i]-1] - len(friend_sum[i]) - 1
    for j in range(len(block_sum[i])):
        if g_label[i] == g_label[block_sum[i][j]]:
            ans -= 1
    print(ans, end=' ')

print()


Measured memory_bytes: 59516
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=3005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
int L[MAXN],R[MAXN],n,m,pos[MAXN],pos1[MAXN];
char ch[MAXN];
int f[MAXN][MAXN];
void wr(int msk,int L)
{
	for(int i=1;i<=L;i++)putchar(msk&(1<<(i-1))?'1':'0');puts("");
}
int main()
{
	n=read();m=read();int total=0,total0=0;
	scanf("%s",ch+1);
	for(int i=1;i<=n;i++)
	{
		if(ch[i]=='1')pos[++total]=i;
		else pos1[++total0]=i;
	}
	for(int i=1;i<=n;i++)L[i]=R[i]=i;
	for(int i=1;i<=m;i++)
	{
		int l=read(),r=read();
		for(int j=l;j<=r;j++)chkmin(L[j],l),chkmax(R[j],r);
	}
	f[0][0]=1;
	for(int i=0;i<n;i++)for(int j=0;j<=i&&j<=total;j++)if(f[i][j])
	{
		if(i+1-j<=total0&&L[pos1[i+1-j]]<=i+1)ad(f[i+1][j],f[i][j]);
		if(j+1<=total&&L[pos[j+1]]<=i+1)ad(f[i+1][j+1],f[i][j]);
	}pr2(f[n][total]);
//	LL S=0;
//	for(int i=0;i<(1<<n);i++)if(__builtin_popcount(i)==total)
//	{
//		bool flag=true;
//		for(int j=1,t1=0,t2=0;j<=n;j++)
//		{
//			if(i&(1<<(j-1)))++t1,flag&=(L[pos[t1]]<=j);
//			else ++t2,flag&=(L[pos1[t2]]<=j);
//		}
//		if(!flag)continue;
//		wr(i,n);S+=flag;
//	}pr2(S);
	return 0;
}



Measured memory_bytes: 33920
#include<stdio.h>
int main(void){
    int a=0,b=0,t=0,i=0,N=0;
    long long c = 0;
    for(scanf("%d",&N);N--;i++){
        scanf("%d",&t);
        if(!i||a>=t)a=t;
        if(!i||b<=t)b=t;
        c+=t;
    }
    printf("%d %d %lld\n",a,b,c);
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#define PRINTP(p)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#p<<" = ("<<(p.first)<<", "<<(p.second)<<")"<<endl;
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTP(p)
#define PRINTI(a,i)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M1, M2, D1, D2;
    cin >> M1 >> D1 >> M2 >> D2;
    cout << (M1 != M2) << endl;
    return 0;
}



Measured memory_bytes: 256