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

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, m, c;
            {
                string[] str = Console.ReadLine().Split(' ');
                n = int.Parse(str[0]);
                m = int.Parse(str[1]);
                c = int.Parse(str[2]);
            }
            List<int> b = new List<int>();
            {
                string[] str = Console.ReadLine().Split(' ');
                foreach(string s in str) {
                    b.Add(int.Parse(s));
                }
            }

            int res = 0;
            for (int i = 0; i < n; i++)
            {
                List<int> a = new List<int>();
                {
                    string[] str = Console.ReadLine().Split(' ');
                    foreach (string s in str)
                    {
                        a.Add(int.Parse(s));
                    }
                }
                int k = 0;
                for (int j = 0; j < m; j++)
                {
                    k += a[j] * b[j];
                }
                k += c;
                if (k > 0)
                    res++;
            }
            Console.WriteLine("{0}", res);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int result;
  result = 0;
  int a;
  int b;
  cin >> a;
  cin >> b;
    for (int i = a; i < b+1; i++)
    {
        if ((i%10==i/10000)&&((i/10)%10==(i/1000)%10))
        {
            result = result + 1;
        }
        
    }
    cout << result << endl;
}

Measured memory_bytes: 3644
n = int(input())
A = [int(input()) for i in range(n)]
cnt = 0
def insertionSort(A, n, g):
    global cnt
    for i in range(g, n, 1):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v
    return A

def shellSort(A, n):
    g = 1
    m = 0
    G = []
    while g <= n:
        G.insert(0, g)
        m+= 1
        g = g*3 + 1
    for g in G:
        insertionSort(A, n, g)
    print(m)
    G_str = [str(x) for x in G]
    if G_str:
        print(' '.join(G_str))
    return A
shellSort(A, n)
print(cnt)
for i in range(n):
    print(A[i])


Measured memory_bytes: 45524
#include <stdio.h>

int main(){
    int n,k;
    scanf("%d %d", &n,&k);

    int d[k];
    int a[n];
    int i,j,tmp, cnt=0;

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

    for(i = 0; i < k; i++){
        scanf("%d", &d[i]);
        for(j = 0; j < d[i]; j++){
            scanf("%d", &tmp);
            a[tmp-1] = 1;
        }
    }
    for(i = 0; i < n; i++){
        if(a[i] == 0){
            cnt++;
        }
    }
    printf("%d", cnt);
}

Measured memory_bytes: 1732
object Main extends App {
  scala.io.StdIn.readLine
  val a = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val average = a.sum.toDouble / a.length
  def sumSquare: Int ⇒ List[Int] ⇒ Int = to ⇒ {
    def square: Int ⇒ Int = n ⇒ { n * n }
    list ⇒ {
      list.map { n ⇒ square(to - n) }.sum
    }
  }
  def min(a: Int, b: Int) = if (a < b) a else b
  println(min(sumSquare(average.ceil.toInt)(a.toList), sumSquare(average.floor.toInt)(a.toList)))
}

Measured memory_bytes: 21700
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    struct Op {
        ll B, C;
    };
    vector<Op> ops(M);
    for (ll i = 0; i < M; i++) {
        cin >> ops[i].B >> ops[i].C;
    }

    sort(A.begin(), A.end());
    sort(ops.begin(), ops.end(), [](Op& lhs, Op& rhs) {
        return lhs.C > rhs.C;
    });

    ll index = 0;
    for (const Op& op : ops) {
        for (ll i = 0; i < op.B; i++) {
            if (A[index] < op.C) {
                A[index++] = op.C;
            } else {
                break;
            }
        }
    }

    cout << accumulate(A.begin(), A.end(), (ll)0) << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var abStr = Console.ReadLine().Split(' ').ToList();
            var a = int.Parse(abStr[0]);
            var b = int.Parse(abStr[1]);
            var result = (a * b) % 2 == 0 ? "Even" : "Odd";
            Console.WriteLine(result);
        }
    }
}


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

int main() {
  vector<int> num = {1, 1, 1, 2, 1, 2, 1, 5,  2, 2, 1, 5, 1, 2, 1, 14,
                     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k = 0;
  cin >> k;
  cout << num.at(k - 1) << endl;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int a;
    cin >> a;
    set<int> st;
    REP(_,a) {
        int s; cin >> s;
        st.insert(s);
    }

    int q;
    cin >> q;
    ll sm = 0;
    REP(_,q) {
        int t; cin >> t;
        sm += st.count(t);
    }
    cout << sm << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 7792
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include<vector>
#include<iostream>
#include<set>
using namespace std;




int main() {
	int n;
	cin >> n;
	string s,t;
	cin >> s >> t;
	for(int i=0;i<n;++i){
		cout << s[i] << t[i];
	}cout << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    with open(0) as f:
        S, T = f.read().split()
    for i in reversed(range(len(S)-len(T)+1)):
        for j in reversed(range(len(T))):
            if S[i+j] == T[j] or S[i+j] == '?':
                continue
            else:
                break
        else:
            S = S[:i] + T + S[i+len(T):]
            S = S.replace('?', 'a')
            print(S)
            break
    else:
        print('UNRESTORABLE')

main()

Measured memory_bytes: 9116
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef long double ld;

int main(){
    int n,i,j,l;
    cin>>n;
    ld dp[n+1][n+1];
    ld a[n+1];
    for(i=0;i<n;i++) cin>>a[i+1];
    for(i=0;i<=n;i++){
        for(j=0;j<=n;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1.0;
    for(i=1;i<=n;i++){
        for(j=i;j>=0;j--){
            if(j>0)
            dp[j][i-j]+=dp[j-1][i-j]*a[i];
            if(i-j-1>=0)
            dp[j][i-j]+=dp[j][i-j-1]*(1.0 - a[i]);
        }
    }
    int x=n/2 + 1;
    ld ans=0;
    for(i=n;i>=x;i--){
        ans+=dp[i][n-i];
    }
    cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}


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

typedef long long ll;

ll N;
map<ll, ll> Count;

int main() {
  cin >> N;
  for (ll i = 0; i < N; ++i) {
    string s;
    cin >> s;
    for (char c = 'a'; c <= 'z'; ++c) {
      ll r = 0;
      for (char x : s)
        if (c == x) ++r;
      Count[c] = i == 0 ? r : min(Count[c], r);
    }
  }
  for (auto cn : Count) {
    char c;
    ll n;
    tie(c, n) = cn;
    for (ll i = 0; i < n; ++i) cout << c;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char buf[81];
	int sum = 0,tmp;

	while(scanf("%s",buf)!=EOF){
		tmp = 0;
		for(int i=0;buf[i] != '\0';i++){
			if(buf[i] >= 48 && buf[i] <= 57){
				tmp = 10*tmp + (buf[i] - '0');
				if(buf[i+1] == '\0'){
					sum += tmp;
				}
			}else{
				if(buf[i-1] >= 48 && buf[i-1] <= 57){
					sum += tmp;
					tmp = 0;
				}
			}
		}
	}

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

    return 0;
}



Measured memory_bytes: 2656
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

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


    
    int main(){
       int n;cin>>n;
       VEC(int,a,n);
       sort(a.begin(),a.end());
       bool f= true;
       rep(i,n-1){
           if(a[i] == a[i+1])f = false;
       }
       cout<<(f?"YES":"NO");
    }
    


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int A,B,C;
	cin>>A>>B>>C;
	if(B-A==C-B) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main(){
  long long N,K=0,A;
  cin >> N;
  A=N;
  while(A>0){
    K+=A%10;
    A=A/10;
  }if(N%K==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const lli N = 16;
vector <lli> dp;
lli pre[1 << N];
lli arr[N][N];
lli n;
void ss()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
void help(lli idx, vector <lli>& v, lli score, lli mask, lli newMask) {
	if (idx == v.size()) {
		dp[mask] = max(dp[mask], score + pre[newMask]);
		return;
	}
	help(idx + 1, v, score, mask, newMask);
	help(idx + 1, v, score, (mask ^ (1 << v[idx])), (newMask ^ (1 << v[idx])));
}
void solve() {
	lli n;
	cin >> n;
	dp.resize(1 << n, -inf);
	dp[0] = 0;
	for (lli i = 0; i < n; i++) {
		for (lli j = 0; j < n; j++) {
			cin >> arr[i][j];
		}
	}
	for (lli mask = 0; mask < (1 << n); mask++) {
		pre[mask] = 0;
		for (lli i = 0; i < n; i++) {
			if (((mask >> i) & 1)) {
				for (lli j = i + 1; j < n; j++) {
					if (((mask >> j) & 1)) {
						pre[mask] += arr[i][j];
					}
				}
			}
		}
	}
	for (lli mask = 0; mask < (1 << n); mask++) {
		vector <lli> not_taken;
		for (lli i = 0; i < n; i++) {
			if (!((mask >> i) & 1)) {
				not_taken.pb(i);
			}
		}
		help(0, not_taken, dp[mask], mask, 0);
	}
	cout << dp[(1 << n) - 1] << endl;
}
int main()
{
	ss();
	solve();
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<stdio.h>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	if (a >= 13)
		cout << b << endl;
	else if (a >= 6)
		cout << b / 2 << endl;
	else
		cout << 0 << endl;
}


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();
		sc.close();
			//105 135 165 195
			if(n>=195)System.out.println(5);
			else if(n>=189)System.out.println(4);
			else if(n>=165)System.out.println(3);
			else if(n>=135)System.out.println(2);
			else if(n>=105)System.out.println(1);
			else System.out.println(0);
	}
}


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

using namespace std;
typedef long long ll;

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

  int a, b, c;
  cin >> a >> b >> c;

  if ((a * 100 + b * 10 + c) % 4 == 0) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}


Measured memory_bytes: 3644
#include<iostream>
using namespace std;
int main()
{
	int a,n,s=0,m=10000000;
	cin>>n;
	while(n--)
	  {cin>>a;
	   if(a<=m) s++;
	   if(m>a) m=a;
	  }
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
//#include "grader.h"
#include <bits/stdc++.h>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define   mt         make_tuple
//#define   Y            imag()
//#define   X            real()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
//#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
//#define    dp(a,b)          (((conj(a))*(b)).real())
//#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
//#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     PT                    complex<double>
#define outfile freopen("out.out", "w", stdout);
#define infile  freopen("in.in", "r", stdin);
#define PI acos(-1)
typedef  long long     ll ;
typedef  unsigned long long ull;
const double eps= (1e-9);
using namespace std;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(int num, int idx) {return ((num >> idx) & 1) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(int num, int idx) {return num ^ (1<<idx);}
void FS(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}
const int N=100009;
int main()
{
    int n;
    cin>>n;

    cout<<(n-2)*180<<endl;
}



























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

int compare_int(const void *p, const void *q){
    return *(int*)p - *(int*)q;
}

int main(){
    int i,N=3;
    int a[N-1];

    for(i=0;i<N;i++){
        scanf("%d", &a[i]);
    }

    qsort(a, N, sizeof(int), compare_int);
    printf("%d\n", a[0]+a[1]);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    int H,W,K; cin >> H >> W >> K;
    vector<string> C(H);
    REP(i,H) cin >> C[i];
    int ans = 0;
    for(int r = 0; r < (1<<H); r++) {
        for(int c = 0; c < (1<<W); c++) {
            vector<string> S = C;
            for(int i = 0; i < H; i++) {
                if(r & (1<<i)) {
                    REP(j,W) S[i][j] = 'r';
                }
            }
            for(int j = 0; j < W; j++) {
                if(c & (1<<j)) {
                    REP(i,H) S[i][j] = 'r';
                }
            }
            int cnt = 0;
            REP(i,H) REP(j,W) if(S[i][j] == '#') cnt++;
            if(cnt == K) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
  
def main():
  s = input()
  ODD = ['R','U','D']
  EVEN = ['L','U','D']
  slen = len(s)
  
  for i in range(slen):
    if (i+1) % 2 == 0:#even
      #print(s[i])
      if s[i] in EVEN:
        pass
      else:
        print('No')
        exit()
    else:
      #print(s[i])
      if s[i] in ODD:
        pass
      else:
        print('No')
        exit()
  print('Yes')
  
if __name__ == '__main__':
  main()

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



int main(){
    int A,B,C,K;
    cin>>A>>B>>C>>K;
    if(A>=K){
        cout<<K<<endl;
    }
    else if(K>A+B){
        cout<<A+A-K+B<<endl;
    }
    else{
        cout<<A<<endl;
    }
    
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
#include<tuple>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef unsigned long long int ull;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=2e5;

int h,w;
vector<vector<char> > a(1000,vector<char>(1000));
vector<vector<int> > d(1000,vector<int>(1000,INF));

int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    int ans=0;
    queue<ii> que;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(a[i][j]=='#'){
                d[i][j]=0;
                que.push(make_pair(i,j));
            }
        }
    }
    while(!que.empty()){
        ii p=que.front();que.pop();
        int y=p.first,x=p.second;
        for(int i=0;i<4;i++){
            int ny=y+dy[i],nx=x+dx[i];
            if(ny>=0&&ny<h&&nx>=0&&nx<w&&d[ny][nx]>d[y][x]+1){
                d[ny][nx]=d[y][x]+1;
                que.push(make_pair(ny,nx));
                ans=max(ans,d[ny][nx]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
	string S, T;
	cin >> S >> T;
	size_t n = S.size();
	bool flag = true;

	for (int i = 0; i < n; i++)
	{
		char tmp = S[n - 1];
		for (int j = n - 1; j > 0; j--)
		{
			S[j] = S[j - 1];
		}
		S[0] = tmp;
		if (S == T)
		{
			flag = false;
		}

	}
	if (flag)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define fr(i,a,b) for(ll i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound
#define endl "\n"
using namespace std;

bool sortbysec(const pair<ll,ll> &a, 
              const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
} 

ll maxSubArraySum(ll a[], ll size) 
{ 
    ll max_so_far = INT_MIN, max_ending_here = 0; 
  
    for (ll i = 0; i < size; i++) 
    { 
        max_ending_here = max_ending_here + a[i]; 
        if (max_so_far < max_ending_here) 
            max_so_far = max_ending_here; 
  
        if (max_ending_here < 0) 
            max_ending_here = 0; 
    } 
    return max_so_far; 
} 

ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll s,w;cin>>s>>w;
    if(s>w) cout<<"safe\n";
    else cout<<"unsafe\n";
}


Measured memory_bytes: 3660
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    O = input()
    E = input()
    ans = ''
    L1 = len(O)
    L2 = len(E)
    for i in range(L2):
        ans += O[i] + E[i]
    if L1 != L2:
        ans += O[-1]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var N int
	fmt.Scan(&N)
	v := atof(nextSlice())
	sort.Float64s(v)
	for i := 0; i < N-1; i++ {
		v[i+1] = (v[i] + v[i+1]) / 2
	}
	fmt.Println(v[N-1])
}

func nextSlice() []string {
	sc.Scan()
	return strings.Split(sc.Text(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

// ---------------------------------------------------

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func larger(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func largest(a, b, c int) (lgst int) {
	if a > b {
		lgst = a
	} else {
		lgst = b
	}
	if c > lgst {
		lgst = c
	}
	return
}

func smaller(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func smallest(a, b, c int) (slst int) {
	if a < b {
		slst = a
	} else {
		slst = b
	}
	if c < slst {
		slst = c
	}
	return
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

// ---------------------------------------------------

func yesOrNo(b bool) string {
	if b {
		return "Yes"
	}
	return "No"
}

func yesorNO(b bool) string {
	if b {
		return "YES"
	}
	return "NO"
}

Measured memory_bytes: 640
s1 = input()
s2 = input()
s1len = len(s1);s2len = len(s2)
dp = [[0 for i in range(s2len+1)] for i in range(s1len+1)]
dic = [0]*3
for i in range(s1len+1):
    for j in range(s2len+1):
        if i == 0:
            dp[i][j] = j
        elif j == 0:
            dp[i][j] = i
        else:
            dic[0] = dp[i][j] = dp[i-1][j-1] if s1[i-1] == s2[j-1] else dp[i-1][j-1]+1
            dic[1] = dp[i-1][j]+1
            dic[2] = dp[i][j-1]+1
            dp[i][j] = min(dic)

print(dp[s1len][s2len])

Measured memory_bytes: 44704
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
    fastio;
    int n,i;
    cin >> n;
    long long int v[n],v1[n+1],s=0,ans=0;
    for(i=0;i<n+1;i++) cin>>v1[i];
    for(i=0;i<n;i++) cin>>v[i];
    for(i=0;i<n;i++) 
    {
        s=min(v1[i],v[i]);
        v1[i]-=s;
        v[i]-=s;
        ans+=s;
        s=min(v[i],v1[i+1]);
        v[i]-=s;
        v1[i+1]-=s;
        ans+=s;
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n,M[MAX][MAX];
void dijkstra(){
  int minv;
  int d[MAX],color[MAX];
  for(int i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    int u=-1;
    for(int i=0;i<n;i++){
      if(minv > d[i] && color[i] != BLACK){
	u=i;
      minv=d[i];
    }
  }
  if(u==-1) break;
  color[u]=BLACK;
  for(int v=0;v<n;v++){
    if(color[v] != BLACK && M[u][v] != INFTY){
      if(d[v]>d[u]+M[u][v]){
	d[v]=d[u]+M[u][v];
	color[v]=GRAY;
      }
    }
  }
  }
  for(int i=0;i<n;i++){
    cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      M[i][j] = INFTY;
    }
  }
  int k,c,u,v;
  for(int i=0;i<n;i++){
  cin >> u >> k;
  for(int j=0;j<k;j++){
  cin >> v >> c;
  M[u][v]=c;
  }
  }
  dijkstra();
  return 0;
}



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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n,m,par[maxn];

int parent(int x) {
  if (par[x]==x) return x;
  return par[x] = parent(par[x]);
}

void join(int u, int v) {
  int pu = parent(u);
  int pv = parent(v);
  if (pu == pv) {
    return;
  }
  par[pu] = pv;
}

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

  cin>>n>>m;
  for (int i=1; i<=n; i++) {
    par[i] = i;
  }
  for (int i=0; i<m; i++) {
    int x,y,z;
    cin>>x>>y>>z;
    join(x,y);
  }

  int ans = 0;
  for (int i=1; i<=n; i++) {
    if (par[i]==i) ans++;
  }
  out(ans);
  

  return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;
inline char nc() {
//	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
typedef long long ll;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 5;
const int maxlog = 20;
int n;
int f[maxn][3];
int dfn[maxn], dfc; 
int dep[maxn], parent[maxn][maxlog];
int head[maxn];
vector<int> r[maxn];
vector<int> adj[maxn];
struct edge {
	int to, nex;
	edge(int to=0,int nex=0):to(to),nex(nex){}
};
vector<edge> G;
inline void addedge(int u, int v) {
	G.push_back(edge(v, head[u])), head[u] = G.size() - 1;
	G.push_back(edge(u, head[v])), head[v] = G.size() - 1;
}
inline int add(int x) {
	return x >= mod ? x - mod : x;
}
ll power(ll x, ll y) {
	ll re = 1;
	while(y) {
		if(y & 1) re = re * x % mod;
		x = x * x % mod;
		y >>= 1;
	}
	return re;
}
void dfs(int u) {
	dfn[u] = ++dfc;
	r[dep[u]].push_back(u);
	for(int i = 1; i < maxlog; ++i) {
		parent[u][i] = parent[parent[u][i - 1]][i - 1];
	}
	for(int i = head[u]; ~i; i = G[i].nex) {
		int v = G[i].to; if(v == parent[u][0]) continue;
		dep[v] = dep[u] + 1;
		parent[v][0] = u;
		dfs(v);
	}
}
int lca(int u, int v) {
	if(dep[u] > dep[v]) swap(u, v);
	for(int i = maxlog - 1; ~i; --i) {
		if(dep[v] - dep[u] >= 1 << i) {
			v = parent[v][i];
		}
	}
	if(u == v) return u;
	for(int i = maxlog - 1; ~i; --i) {
		if(parent[u][i] != parent[v][i]) {
			u = parent[u][i];
			v = parent[v][i];
		}
	}
	return parent[u][0];
}
void dp(int u) {
	f[u][0] = 1; f[u][1] = !adj[u].size(), f[u][2] = 0;
	for(unsigned int i = 0; i < adj[u].size(); ++i) {
		int v = adj[u][i];
		dp(v);
		f[u][2] = ((ll)f[u][2] * (f[v][0] + f[v][1]) + (ll)f[u][1] * f[v][1]) % mod;
		f[u][1] = ((ll)f[u][0] * f[v][1] + (ll)f[u][1] * f[v][0]) % mod;
		f[u][0] = (ll)f[u][0] * f[v][0] % mod;
	}
	f[u][0] = add(f[u][0] + f[u][2]);
	adj[u].clear();
}
inline int cmp(const int &a, const int &b) {
	return dfn[a] < dfn[b];
}
inline void adde(int u, int v) {
	adj[u].push_back(v);
}
int sol(int x) {
	static int stk[maxn];
	sort(r[x].begin(), r[x].end(), cmp);
	int top = 0; stk[++top] = r[x][0];
	for(unsigned i = 1; i < r[x].size(); ++i) {
		int w = lca(stk[top], r[x][i]);
		while(top > 1 && dep[stk[top - 1]] > dep[w]) {
			adde(stk[top - 1], stk[top]), top--;
		}
		if(dep[stk[top]] > dep[w]) {
			adde(w, stk[top]), top--;
		}
		if(w != stk[top]) stk[++top] = w;
		stk[++top] = r[x][i];
	}
	while(top > 1) {
		adde(stk[top - 1], stk[top]), top--;
	}
	dp(stk[top]);
	return f[stk[top]][1];
}
int main() {
	read(n), n++;
	memset(head, -1, sizeof(head));
	for(int i = 2; i <= n; ++i) {
		int x; read(x), x++;
		addedge(x, i);
	}
	dfs(1);
	int an = 0;
	int x = 0;
	for(int i = 0; ; ++i) {
		if(!r[i].size()) break;
		x++;
		an = (an + power(2, n - r[i].size()) * sol(i)) % mod;
	}
	printf("%d\n", an);
	return 0;
} 

Measured memory_bytes: 45804
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main 
{
	static int n, c;
	
	static class CR implements Comparator<RecEntry>
	{

		@Override
		public int compare(RecEntry o1, RecEntry o2) {
			return o1.ready - o2.ready;
		}
	}
	
	static class CP implements Comparator<Prog>
	{

		@Override
		public int compare(Prog o1, Prog o2) 
		{
			int an = o1.s - o2.s;
			if(an == 0)an=o1.t-o2.t;
			return an;
		}
	}
	
	static class Prog
	{
		int s; //start inclusive
		int t; //finish exclusive
		boolean dead = false;
		
		public Prog(int s0, int t0)
		{
			s = s0;
			t = t0;
		}
	}
	
	static class RecEntry
	{
		int recid;
		int ready;
		
		public RecEntry(int id, int time)
		{
			recid = id;
			ready = time;
		}
	}

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		c = sc.nextInt();
		
		CP cp = new CP();
		@SuppressWarnings("unchecked")
		PriorityQueue<Prog>[] chan = new PriorityQueue[c];
		
		for(int i = 0; i < c; i++)
			chan[i] = new PriorityQueue<Prog>(cp);
		
		for(int i = 0; i < n; i++)
		{
			int s = sc.nextInt();
			int t = sc.nextInt();
			int c = sc.nextInt()-1;
			chan[c].add(new Prog(s,t));
		}
		
		int rem = n;
		
		int recs = 0;
		
		CR cr = new CR();
		PriorityQueue<RecEntry> q = new PriorityQueue<>(cr);
		
		while(rem>0)
		{
//			System.out.println("get with rem " + rem);
			//get earliest program
			Prog earliest = null;
			int earchan = -1;
			for(int i = 0; i < c; i++)
			{
//				System.out.println("channel " + i + " has " + chan[i].size());
				Prog prog = chan[i].peek();
				while(prog != null && chan[i].peek().dead)
				{ //this program is already being recorded
					chan[i].poll();
					prog = chan[i].peek();
				}
				if(prog != null)
				{
					if(earliest == null || prog.s < earliest.s)
					{
						earliest = prog;
						earchan = i;
					}
				}
			}
			rem--;
//			System.out.println("get from channel " + earchan);
			
			//assign earliest program & any of its direct continuation(s) to recorder
			//first, get earliest recorder
			RecEntry rec = q.peek();
			int recid = -1;
			if(rec == null || rec.ready > earliest.s)
			{ //new recorder
				recid = recs;
				recs++;
			}
			else 
			{
				recid = rec.recid;
				q.poll();
			}
			//assign
			int end = earliest.t;
			chan[earchan].poll();
			
			while(chan[earchan].peek() != null && chan[earchan].peek().s == end)
			{ //continuations
				Prog last = chan[earchan].poll();
				end = last.t;
				rem--;
			}
			end++; //this recorder needs time to change channel after recording this series
			q.add(new RecEntry(recid, end));
			
		}
		System.out.println(recs);
	}

}


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

const int MAXN = ( int ) 2e5;

int N, X, Y;
int C[ MAXN ], W[ MAXN ];
vector< int > c2w[ MAXN ];

int cmax[ MAXN ];
int fact[ MAXN + 1 ];
int inv_fact[ MAXN + 1 ];

int int_pow( int v, int p, int m ){
  int res = not ( v == 0 and p != 0 );
  while( p ){
    if( p & 1 ){
      res = 1LL * res * v % m;
    }
    p >>= 1;
    v = 1LL * v * v % m;
  }
  return res;
}

int unite[ MAXN ];

signed main(){
  ios::sync_with_stdio( 0 );
  {
    cin >> N >> X >> Y;
    for( int i = 0; i < N; ++i ){
      cin >> C[ i ] >> W[ i ];
      --C[ i ];
      c2w[ C[ i ] ].emplace_back( W[ i ] );
    }
    for( int i = 0; i < N; ++i ){
      sort( c2w[ i ].begin(), c2w[ i ].end() );
    }
  }
  {
    int minw = ( int ) 2e9, minwp;
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      if( minw > c2w[ i ][ 0 ] ){
        minw = c2w[ i ][ 0 ];
        minwp = i;
      }
    }
    int minw2 = ( int ) 2e9;
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      if( i == minwp ) continue;
      if( minw2 > c2w[ i ][ 0 ] ){
        minw2 = c2w[ i ][ 0 ];
      }
    }
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      {
        for( int lb = 2, ub = c2w[ i ].size(); lb <= ub; ){
          int mid = lb + ub >> 1;
          if( c2w[ i ][ 0 ] + c2w[ i ][ mid - 1 ] <= X ){
            cmax[ i ] = mid;
            lb = mid + 1;
          } else{
            ub = mid - 1;
          }
        }
      }
      {
        for( int lb = 1, ub = c2w[ i ].size(); lb <= ub; ){
          int mid = lb + ub >> 1;
          if( minw != minw2 and c2w[ i ][ 0 ] == minw ){
            if( minw2 + c2w[ i ][ mid - 1 ] <= Y ){
              unite[ i ] = mid;
              lb = mid + 1;
            } else{
              ub = mid - 1;
            }
            continue;
          }
          if( minw + c2w[ i ][ mid - 1 ] <= Y ){
            unite[ i ] = mid;
            lb = mid + 1;
          } else{
            ub = mid - 1;
          }
        }
      }
    }
  }
  {
    const int MOD = ( int ) 1e9 + 7;
    {
      for( int i = fact[ 0 ] = inv_fact[ 0 ] = 1; i <= MAXN; ++i ){
        fact[ i ] = 1LL * fact[ i - 1 ] * i % MOD;
        inv_fact[ i ] = int_pow( fact[ i ], MOD - 2, MOD );
      }
    }
    int sum = 0;
    for( int i = 0; i < N; ++i ){
      if( not unite[ i ] ) continue;
      sum += max( unite[ i ], cmax[ i ] );
    }
    int ans = fact[ sum ];
    for( int i = 0; i < N; ++i ){
      if( c2w[ i ].empty() ) continue;
      if( not unite[ i ] ) continue;
      ans = 1LL * ans * inv_fact[ max( unite[ i ], cmax[ i ] ) ] % MOD;
    }
    cout << ans << "\n";
  }
  return 0;
}


Measured memory_bytes: 13952
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod=1000000007;
int main() {
	ll i,j,k,l,m,n,t;
// 	ios_base::sync_with_stdio(false);
//     cin.tie(NULL);
	cin>>n;
	l=0;
	vector<ll> a(n+1,0);
	for(i=0;i<n-1;i++){
	    cin>>j;
	    a[j]++;
	}
	for(i=1;i<=n;i++){
	    cout<<a[i]<<'\n';
	}
	
	return 0;
}

Measured memory_bytes: 4836
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x1 - dy
y4 = y1 + dx

print(x3,y3,x4,y4)

Measured memory_bytes: 9124
import numpy as np

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

AB = np.ones([N,2])


for i in range(N):
    AB[i,0],AB[i,1] = [int(i) for i in input().split()]
    
count=0
price=0

AB_new = AB[np.argsort(AB[:,0])]

for i in range(N):

    if count<=M: 
        count+=AB_new[i,1]
        if count<=M:
            price+=AB_new[i,0]*AB_new[i,1]
        elif count>M:
            price+=AB_new[i,0]*(M-count+AB_new[i,1])
    else:
        break

        
print(int(price))

Measured memory_bytes: 16368
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1000000007;
const ll N=998244353;
ll power(ll x,ll n){ll res=1;while(n>0){if(n&1) res=res*x%MOD;x=x*x%MOD;n>>=1;}return res;}
ll modinverse(ll a){return power(a, MOD-2);}
void solve()
{
    ll n;
    cin>>n;
    vl l(n);
    forr(i, n)
    {
    	cin>>l[i];
    }
    sort(all(l));
    /*vl l2;
    map<ll, ll> mp1;
    for(ll i=0; i<n; i++)
    {
    	if(mp1.find(l[i])==mp1.end())
    		l2.pb(l[i]);
    	mp1[l[i]]++;
    }
    sort(all(l2));*/
    ll ans=0;
    forr(i, n)
    {
    	for(ll j=i+1; j<n; j++)
    	{
    		for(ll k=j+1; k<n; k++)
    		{
    			map<ll, ll> mp1;
    			mp1[l[i]]++, mp1[l[j]]++, mp1[l[k]]++;
    			if((ll)mp1.size()==3&&l[i]+l[j]>l[k])
    				ans++;
    		}
    	}
    }
    cout<<ans<<endl;
}
int main()
{
	#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll test=1;
    //cin>>test;
    while(test--)
    {
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3852
#coding:utf-8
import copy
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    n = II()
    xy = []
    for i in range(n):
        a = II()
        xy.append(XLMIIS(a))


    def f(a):
        i = 0
        while n != i  and a[i] != -1:
            i += 1
        if i == n:
            return 0

        b = copy.copy(a)
        b[i] = 1
        b_ans = 1
        mujun = 0
        q = deque([i])
        while len(q) != 0:
            qq = q.pop()
            for j in xy[qq]:
                if b[j[0]-1] == -1 and j[1] == 1:
                    q.append(j[0]-1)
                    b[j[0]-1] = 1
                    b_ans += 1
                elif b[j[0]-1] == -1 and j[1] == 0:
                    b[j[0]-1] = 0
                elif b[j[0]-1] != j[1]:
                    mujun = 1
                    break
        if mujun == 0:
            b_ans += f(b)
        else:
            b_ans = 0

        c = copy.copy(a)
        c[i] = 0
        c_ans = f(c)

        return max(b_ans, c_ans)


    print(f([-1]*n))







if __name__ == '__main__':
    main()


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define FORV(a, A) for (auto &a : A)

using namespace std;

using ll = long long;

void Main() {
  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << -1 << endl;
    return;
  }
  cout << a * b << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <map>

using LL = long long;

LL N, W;
LL w[200];
LL v[200];
std::map<std::pair<LL, LL>, LL> dp;

LL rec(LL i, LL j) {
  if (dp.find(std::make_pair(i,j)) != dp.end()) {
    return dp[std::make_pair(i,j)];
  }
  LL val;
  if (i == N) {
    val = 0;
  } else if (j < w[i]) {
    val = rec(i+1, j);
  } else {
    val = std::max(rec(i+1, j), rec(i+1, j-w[i])+v[i]);
  }
  dp[std::make_pair(i,j)] = val;
  return val;
}

int main() {
  std::cin >> N >> W;

  for (int i = 0; i < N; i++) {
    std::cin >> w[i] >> v[i];
  }

  std::cout << rec(0, W) << std::endl;

  return 0;
}

Measured memory_bytes: 6400
/*#include <functional>
#include <memory>
#include <utility>

template<typename T, typename Compare = ::std::less<T>>
class skew_heap {
    using value_type = T;
    using const_reference = const value_type &;
    using size_type = ::std::size_t;
    using value_compare = Compare;

    class node_type {
    public:
        ::std::unique_ptr<node_type> left, right;
        value_type value;

        explicit constexpr node_type(const value_type &_value = T()) : value(_value), left(nullptr), right(nullptr) {}
    };

    using pointer_type = ::std::unique_ptr<node_type>;

    pointer_type root;

    value_compare comp;

    size_type _size;

    pointer_type meld(pointer_type a, pointer_type b) {
        if (!a)return b;
        if (!b)return a;
        if (comp(a->value, b->value))a.swap(b);
        a->right = meld(::std::move(a->right), ::std::move(b));
        a->left.swap(a->right);
        return a;
    }

public:
    constexpr skew_heap() : root(nullptr), comp(), _size(1) {}

    explicit constexpr skew_heap(const value_compare &_comp) : root(nullptr), comp(_comp), _size(1) {}

    constexpr bool empty() const noexcept { return !_size; }

    constexpr size_type size() const noexcept { return _size; }

    constexpr const_reference top() const noexcept {
        return root->value;
    }

    void push(const_reference val) {
        root = meld(::std::move(root), ::std::make_unique<node_type>(val));
        ++_size;
    }

    void push(value_type &&val) {
        root = meld(::std::move(root), ::std::make_unique<node_type>(::std::move(val)));
        ++_size;
    }

    template<class... Args>
    void emplace(Args &&... args) {
        root = meld(::std::move(root), ::std::make_unique<node_type>(::std::forward<Args>(args)...));
        ++_size;
    }

    void pop() {
        root = meld(::std::move(root->right), ::std::move(root->left));
        --_size;
    }

    void meld(skew_heap &x) {
        _size += x.size();
        x._size = 0;
        root = meld(::std::move(root), ::std::move(x.root));
    }
};
*/
#include <bits/stdc++.h>

int main(){
    using namespace std;
    size_t Q;
    cin >> Q;
    //skew_heap<long, less<>> pq1;
    //skew_heap<long, greater<>> pq2;
    priority_queue<long, deque<long>, less<>> pq1;
    priority_queue<long, deque<long>, greater<>> pq2;
    long C{0};
    for(unsigned long i = 0, a, b, c; i < Q; ++i)if(cin >> c, c == 1) {
        cin >> a >> b;
        pq1.push(a);
        auto t = pq1.top();
        pq1.pop();
        C += b - a + 2 * t;
        pq2.push(t);
        if (pq1.size() < pq2.size()) {
            auto k = pq2.top();
            pq2.pop();
            C -= 2 * k;
            pq1.push(k);
        }
    }else cout << pq1.top() << " " << C + (pq1.size() != pq2.size()) * pq1.top() << endl;
    return 0;
}

Measured memory_bytes: 3712
let id x = x

let init n f =
  let rec g i ns = if i = 0 then 0 :: ns else g (i - 1) (i :: ns) in
  List.map f (g n [])

let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let s = split_string @@ Scanf.scanf "%s\n" id

let f (lst, arr) a =
  match arr with
    | [] -> failwith ""
    | x :: xs -> (a, if a = lst then (x + 1) :: xs else 1 :: x :: xs)

let ss = 
  let t = (snd @@ List.fold_left f (List.hd s, [1]) (List.tl s)) in
  let u = List.rev (if List.hd (List.rev s) = "<" then 0 :: t else t) in
  if List.hd s = ">" then 0 :: u else u

let rec g = function
  | x :: y :: xs -> 
      if x = 0 || y = 0 then x :: y :: g xs
      else if x > y then x :: (y - 1) :: g xs 
      else (x - 1) :: y :: g xs
  | _ -> []

let () = 
  ss
    |> g 
    |> List.map (fun i -> i * (i + 1) / 2) 
    |> List.fold_left (+) 0
    |> print_int;
  print_newline ()

Measured memory_bytes: 65280
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  //
  ll n, k;
  cin >> n >> k;
  vl h(n + 1, 0);
  rep(i, n) cin >> h[i + 1];
  vvl data(n + 1, vl(n + 1, 0));
  REP(x, 1, n + 1) data[x][1] = h[x];
  REP(x, 1, n + 1) {
    REP(y, 2, n - k + 1) {
      ll tmp = INF;
      REP(i, 1, x) { tmp = min(tmp, data[i][y - 1] + max(0LL, h[x] - h[i])); }
      data[x][y] = tmp;
    }
  }
  ll ans = INF;
  REP(i, 1, n + 1) { ans = min(ans, data[i][n - k]); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
W = [2 ** i for i in range(0,10)]

while True:
    try:
        n = int(input())
    except EOFError:
        break
    ans = []
    for i in range(0,10):
        if n & (1 << i):
            ans.append(W [i])
    print(' '.join(map(str,ans)))

Measured memory_bytes: 7612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

int main()
{
  int n, m;
  cin >> n >> m;
  ll h[100100];
  set<int> st;
  rep(i, n)
  {
    cin >> h[i];
    st.insert(i);
  }

  vector<vector<int>> g(1001000);
  rep(i, m)
  {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    if (h[a] > h[b])
      st.erase(b);
    else if (h[a] < h[b])
      st.erase(a);
    else
    {
      st.erase(a);
      st.erase(b);
    }
  }

  cout << st.size() << endl;
  return 0;
}

Measured memory_bytes: 32296
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++
def iii(a,b,c):
	if a==b and a!= c:
		return True
	if b==c and b!=a:
		return True
	if c==a and c!=b:
		return True
	return False
	
	
def main():
	a, b , c = IN()
	ret = 'Yes' if iii(a,b,c) else 'No'
	print(ret)
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>

using namespace std;

int main()
{
        int n,m,x;
        cin >> n >> m >> x;

        int a[m],i,j;

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

        int flagr,flagl;
        flagr=0;
        flagl=0;

        for(i=x; i<n; i++){
                for(j=0; j<m; j++){
                        if(a[j] == i)
                                flagr++;
                }
        }

        for(i=x; i>0; i--){
                for(j=0; j<m; j++){
                        if(a[j] == i)
                                flagl++;
                }
        }

        cout << min(flagr,flagl) << endl;
        return 0;
}

Measured memory_bytes: 256