akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define ll long long
 
const int N=1e5+5,MAX=3e7,MOD=1e9+7;

using namespace std;

int n,S;
pair<int,int>a[N];

ll memo[105][N];

ll solve(int indx,int curr){
 
     if(indx==n)return 0;

     ll &ret = memo[indx][curr];

     if(ret != -1)return memo[indx][curr];

     if(a[indx].first + curr <= S){

     	 ret = max(ret , a[indx].second + solve(indx+1,curr+a[indx].first));
     }

     ret = max(ret , solve(indx+1,curr));

     return ret;

}
int main(){
    //#ifndef ONLINE_JUDGE
      //  freopen("test.txt","r",stdin);
    //#endif
    
    scanf("%d %d",&n,&S);

    for(int i=0;i<n;i++)scanf("%d %d",&a[i].first,&a[i].second);

    memset(memo,-1,sizeof(memo));
    printf("%lld\n",solve(0,0) );
     
}

Measured memory_bytes: 82304
import math
def shell(l):
	N = len(l)
	cnt = 0
	m = int(math.log(2 * N + 1, 3))
	G = [(3 ** i - 1) // 2 for i in range(m, 0, -1)]

	for i in range(m):
		l, cnt = insert(l, G[i], cnt)

	return l, m, G, cnt

def insert(l, g, cnt):
	N = len(l)

	for i in range(g, N):
		v = l[i]
		j = i - g

		while j >= 0 and l[j] > v:
			l[j + g] = l[j]
			j -= g
			cnt += 1

		l[j + g] = v

	return l, cnt

def output(l):
	count = 0
	leng = len(l)
	for i in l:
		count += 1
		if count < leng:
			print(i, end =' ')
		else:
			print(i)




if __name__ == '__main__':
	n = int(input())
	lists = list()

	for i in range(n):
		lists.append(int(input()))

	lists, m, g, cnt = shell(lists)
	print(m)
	output(g)
	print(cnt)
	for i in lists:
		print(i)





Measured memory_bytes: 45612
x = int(input())

if 400 <= x <= 599:
    print("8")
elif 600 <= x <= 799:
    print("7")
elif 800 <= x <= 999:
    print("6")
elif 1000 <= x <= 1199:
    print("5")
elif 1200 <= x <= 1399:
    print("4")
elif 1400 <= x <= 1599:
    print("3")
elif 1600 <= x <= 1799:
    print("2")
elif 1800 <= x <= 1999:
    print("1")

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

using namespace std;

int main() {
  int arr[5];
  for (int x = 0; x < 5; x++)
    cin >> arr[x];
  int k;
  cin >> k;

  for (int x = 0; x < 5; x++) {
    for (int y = x+1; y < 5; y ++) {
      if (arr[y] - arr[x] > k) {
        cout << ":(\n";
        return 0;
      }
    }
  }
  cout << "Yay!\n";

  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        for(int i = 0;i < n;i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        long[][] memo = new long[n][3];
        int diary = -1;
        for(int i = 0;i < n;i++) {
            for(int j = 0;j < 3;j++) memo[i][j] = -1;
        }
        System.out.println(dp(n, a, b, c, n - 1, memo, diary));
    }

    private static long dp(int n, int[] a, int[] b, int[] c, int today, long[][] memo, int diary) {
        if(today == -1) return 0;
        else if(diary != -1 && memo[today][diary] != -1) return memo[today][diary];
        else {
            int yesterday = today - 1;
            long maxHappiness = Long.MIN_VALUE;
            long tmpHappiness = Long.MIN_VALUE;
            if(diary != 0) {
                int tmpDiary = 0;
                tmpHappiness = dp(n, a, b, c, yesterday, memo, tmpDiary) + a[today];
                if(maxHappiness < tmpHappiness) maxHappiness = tmpHappiness;
            }
            if(diary != 1) {
                int tmpDiary = 1;
                tmpHappiness = dp(n, a, b, c, yesterday, memo, tmpDiary) + b[today];
                if(maxHappiness < tmpHappiness) maxHappiness = tmpHappiness;
            }
            if(diary != 2) {
                int tmpDiary = 2;
                tmpHappiness = dp(n, a, b, c, yesterday, memo, tmpDiary) + c[today];
                if(maxHappiness < tmpHappiness) maxHappiness = tmpHappiness;
            }
            
            if(diary != -1) memo[today][diary] = maxHappiness;
            return maxHappiness;
        }
    }
}


Measured memory_bytes: 109728
#include<iostream>
using namespace std;
int main()
{
	int i,j,k,r,c,t;
	cin>>r>>c;
	k=r*c;
	char ch[k];
	for(i=1;i<=k;i++)
	{
		cin>>ch[i];
	}
	r=r+2;
	c=c+2;
	k=1;
	for(i=1;i<=r;i++)
	{
		for(j=1;j<=c;j++)
		{
			if(i==1||i==r||j==1||j==c)
			{
				cout<<'#';
			}
			else
			{
				cout<<ch[k];
				k++;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;
#define FIX cout << fixed << setprecision(15)

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

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 ll = long long;
using Graph = vector<vector<int>>;

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(x,y);
  if(x >= 0 && y > 0) {
    if(y > x) {
      OUT(y-x);
    } else {
      OUT(x-y+2);
    }
  } else if (y > 0 || x >= 0) {
    OUT(abs(abs(x)-abs(y))+1);
  } else {
    if(x > y) {
      OUT(x-y+2);
    } else {
      OUT(abs(y-x));
    }
  }
}

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

int solve() {
    int N, K;
    cin >> N >> K;
    vector<int> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
    }
    int c = 0;
    set<int> s;
    int ans = 1;
    s.insert(P[0]);
    for ( int i = 1; i < K; i++ ) {
        if ( P[i] < P[i-1] ) c++;
        s.insert(P[i]);
    }
    bool had_zero = (c==0);
    for ( int i = K; i < N; i++ ) {
        if ( P[i] < P[i-1] ) c++;
        if ( P[i-K+1] < P[i-K] ) c--;
        s.erase(P[i-K]);
        int mn = *s.begin();
        int mx = *s.rbegin();
        bool no = P[i-K] < mn && mx < P[i];
        s.insert(P[i]);
        if ( !no ) {
            if ( c > 0 ) {
                ans++;
            } else if ( c==0 && !had_zero ) {
                ans++;
                had_zero = true;
            }
        }
    }
    
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

int main(void) {
    int a, b;
    cin >> a >> b;
    cout << 2 * b - a << endl;
    
    return 0;
}

Measured memory_bytes: 256
/**
*    author:  souzai32
*    created: 01.08.2020 16:33:33
**/

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

int main() {

    long long int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);

    vector<long long> sum(n);
    sum.at(0)=a.at(0);
    rep(i,n-1) sum.at(i+1)=sum.at(i)+a.at(i+1);

    long long int num=1e18;
    long long int x,y;
    rep(i,n-1){
        x=sum.at(i);
        y=sum.at(n-1)-x;
        num=min(num,abs(x-y));
    }
    //cout << sum.at(n-1) << endl;
    cout << num << endl;

    

    return 0;
}

Measured memory_bytes: 5568
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  int ans = accumulate(s.begin(), s.end(), 0);
  int x = ans;
  for (int i = 0; i < n; i++) {
    if (s[i] % 10 != 0) x = min(x, s[i]);
  }
  if (ans % 10 == 0) {
    ans -= x;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n string
	fmt.Scan(&n)
	flg := 0

	for i, v := range n {
		if i != 0 && rune(v) != '9' {
			flg = 1
		}
	}
	fmt.Println(int(n[0]) - int('0') + 9*(len(n)-1) - flg)
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x.at(i);
  }
  int64_t ans = 100000000000000;
  for (int i = 0; i < N - K + 1; i++) {
    int64_t l = x.at(i);
    int64_t r = x.at(i + K - 1);
    if (r < 0) {
      ans = min(ans, abs(l));
    }
    else if (l < 0) {
      ans = min(ans, abs(min(abs(l), r) * 2) + max(abs(l), r));
    }
    else {
      ans = min(ans, r);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4060
N, x = map(int, input().split())
children = list(map(int, input().split()))
ans = 0

children = sorted(children)
for j,i in enumerate(children):
  if x < i:
    break
  elif x == i:
    ans += 1
    break
  elif j == len(children)-1:
    break
  else:
    x -= i
    ans += 1
    
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<cstdlib>
using namespace std;
const int maxn=1e5;
int N,t[maxn],x[maxn],y[maxn],lx=0,ly=0,lt=0;
bool s=1;
int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>t[i]>>x[i]>>y[i];
		if(s){
			if((t[i]-lt-abs(x[i]-lx)-abs(y[i]-ly))>=0&&(t[i]-lt-abs(x[i]-lx)-abs(y[i]-ly))%2==0){
				lx=x[i];
				ly=y[i];
				lt=t[i];
			}
			else s=0;
		}
	}
	if(s)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define ld long double
#define mp make_pair

void print(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cout<<a[i]<<' ';
    cout<<endl;
}

void get(vector<auto> &a)
{
    for (int i = 0; i<a.size(); i++) cin>>a[i];
}

const ll p = 998244353;

ll mul(ll a, ll b) {
    return (1LL * a * b) % p;
}

ll add(ll a, ll b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p; 
    return s;
}

ll po(ll a, ll  deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    ll t = po(a, deg/2);
    return mul(t, t);
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    
    int n, m;
    cin>>n>>m;
    
    vector<bitset<320>> a(n);
    
    
    
    bool t;
    
    for (int i = 0; i<n; i++)
    for (int j = 0; j<m; j++) {cin>>t; a[i][j] = t;}
    
    vector<bool> visited(n);
    
    int degbasis = 0;
    
    for (int i = 0; i<m; i++)
    {
        int idx = 0;
        while (idx<n && !(a[idx][i]==1&&!visited[idx])) idx++;
        if (idx==n) continue;
        visited[idx] = true;
        degbasis++;
        for (int j = 0; j<n; j++) if (j!=idx&&a[j][i]==1) a[j]^=a[idx];
    }
    
    //cout<<degbasis<<endl;
    
    ll total = po(2, m+n - 1) - po(2, m+n-1-degbasis);
    total%=p;
    if (total<0) total+=p;
    cout<<total;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  	ll x;
  	cin >> x;
  	ll f_h = 1000;
  	ll f_c = 5;
  	ll one = x / 500;
//   	cout << "one " << one << "\n";
  	x %= 500;
  	ll five = x / 5;
//   	cout << "five " << five << "\n";
  	ll total = (one * f_h) + (five * f_c);
  	cout << total;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX(A, B) (((A) < (B)) ? (B) : (A))
#define MIN(A, B) (((A) < (B)) ? (A) : (B))
#define ABS(A) (((A) < 0 ) ? (0 - A) : (A))

int main() {
  int p[15] = {2, 3, 5, 7, 11, 13, 17, 19, 
               23, 29, 31, 37, 41, 43, 47};
  int a[15] = {0};
  int q[5] = {73, 23, 13, 3, 1};
  int b[5] = {0};
  int N;
  scanf ("%d", &N);
  int f;
  for (int i=0; i<N; i++) {
    f = i + 1;
    for (int j=0; j<15; j++) {
      while (f != 1 && f % p[j] == 0) {
        f /= p[j];
        a[j]++;
      }
    }
  }
  for (int i=0; i<5; i++) {
    for (int j=0; j<15; j++) 
      if (a[j] > q[i])
        b[i]++;
  }
  int c = 0;
  int d = 0;
  c += b[0];
  c += b[1] * (b[4] - 1);
  c += b[2] * (b[3] - 1);
  c += b[3] * (b[3] - 1) * (b[4] - 2) / 2;
  printf("%d\n", c);
  return 0;
}


Measured memory_bytes: 128
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long LL;
 
template<class T>
    using min_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>
    using max_queue = priority_queue<T>;

template<class A, class B>
ostream& operator<<(ostream& s, pair<A, B> const& a){
  return s << "(" << get<0>(a) << ", " << get<1>(a) << ")";
}
 
 
template <size_t n, typename... T>
typename std::enable_if<(n >= sizeof...(T))>::type
    print_tuple(std::ostream&, const std::tuple<T...>&) { }
template <size_t n, typename... T>
typename std::enable_if<(n < sizeof...(T))>::type
    print_tuple(std::ostream& os, const std::tuple<T...>& tup) {
    if (n != 0) os << ", ";
    os << std::get<n>(tup);
    print_tuple<n+1>(os, tup);
}
template <typename... T>
std::ostream& operator << (std::ostream& os, const std::tuple<T...>& tup) {
    os << "(";
    print_tuple<0>(os, tup);
    return os << ")";
}
 
template<class T>
ostream& print_collection(ostream& s, T const& a){
  s << '[';
  for(auto it = begin(a); it != end(a); ++it){
    s << *it;
    if(it != prev(end(a))) s << ", ";
  }
  return s << ']';
}
template<class T, class U>
ostream& operator<<(ostream& s, map<T, U> const& a) { return print_collection(s, a); }
template<class T>
ostream& operator<<(ostream& s, set<T> const& a) { return print_collection(s, a); }
template<class T>
ostream& operator<<(ostream& s, vector<T> const& a) { return print_collection(s, a); }
 
const LL INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = acos(-1.0), eps = 1e-7;
const int max3 = 510, max4 = 20100, max5 = 201000, max6 = 2000100, inf = 0x3f3f3f3f;
const int MOD = 1007;


int main() {
    LL a, b, c, d;
    int _;
    cin >> _;
    while (_--) {
        cin >> a >> b >> c >> d;
        if (d < b) {
            cout << "No" << endl;
            continue;
        }
        if (a < b) {
            cout << "No" << endl;
            continue;
        }
        if (c >= b) {
            cout << "Yes" << endl;
            continue;
        }
        
        
        LL gd = __gcd(d, b);
        LL mii = c - a % b;
        LL need = (mii / gd) * gd;
        while (need <= c - a % b) need += gd;
        if (need > c - a % b && need < b - a % b) {
            cout << "No" << endl;
            continue;
        }
        
        LL tmp = a % b;
        bool ok = true;
        unordered_map<LL, int> mp;
        int cnt = 300000;
        while (1) {
            cnt--;
            if (cnt <= 0) {
                break;
            }
            if (tmp < b && tmp > c) {
                ok = false;
                break;
            }
            mp[tmp] = 1;
            tmp += d;
            tmp %= b;
            if (mp[tmp] == 1) break;
        }
        if (ok) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 14412
n,*a=`dd`.split.map &:to_i
l,r=[a,a.reverse].map{|a|
	s=[[0,i=-1]]
	r=a*2
	a.each{|e|
		i+=1
		s.pop while e<s[-1][0]
		r[e]=i-s[-1][1]
		s<<[e,i]
	}
	r
}
x=0
a.map{|e|x+=e*l[e]*r[e]}
p x

Measured memory_bytes: 41484
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	s := getString()

	out(s[:5] + " " + s[6:13] + " " + s[14:])
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int cnt[11][11];
int main()
{
	int N;
	cin >> N;
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		int tmp = i;
		int e = tmp % 10;
		while (tmp >= 10) {
			tmp /= 10;
		}
		int f = tmp;
		cnt[f][e]++;
	}
	for (int i = 1; i <= N; i++) {
		int tmp = i;
		int e = tmp % 10;
		while (tmp >= 10) {
			tmp /= 10;
		}
		int f = tmp;
		ans += cnt[e][f];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    int a,b;cin>>a>>b;
    if(a%b==0)cout<<0<<endl;
    else cout<<1<<endl;
    return 0;
}


Measured memory_bytes: 256
def main(str)
  n = str.length
  (palindrom?(str) && palindrom?(str[0..((n-1)/2-1)]) && palindrom?(str[(n+3/2-1)..(n-1)])) ? 'Yes' : 'No'
end

def palindrom?(str)
  n = str.length
  rule1 = (0..n/2).all? { |x| str[x] == str[n - 1 - x] }
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal("Yes", main("akasaka"))
    assert_equal("No", main("level"))
    assert_equal("No", main("atcoder"))
  end
end




Measured memory_bytes: 14384
#include <bits/stdc++.h>
using namespace std;
int main()
{
 long long  n,i,c=0;
 cin>>n;
 long double a,product=1,mx=1000000000000000000;
 vector<long double>A;
 for(i=0;i<n;i++)
 {
     cin>>a;
     A.push_back(a);
     if(a==0) c=1;
 }
 if(c==1) cout<<"0"<<endl;
 else
 {
     sort(A.begin(),A.end());
     for(i=A.size()-1;i>=0;i--)
     {
         product*=A[i];
         if(product>mx)
            break;
     }
     if(i<0) cout<<(long long int)product<<endl;
     else cout<<"-1"<<endl;
 }
return 0;
}


Measured memory_bytes: 5428
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


// #define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
	IOS;
	int a,h,a2,h2; cin>>h>>a>>h2>>a2;
	int n1=(h2-1)/a+1;
	int n2=(h-1)/a2+1;
	dbg(n1,n2);
	if(n1<=n2)
		cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3636
use std::cmp::min;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u32 = read();
    let k: u32 = read();
    println!("{}", n - k + 1);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

string f(ll n) {
  if (n == 0) return "";
  n--;
  return f(n/26) + string(1,'a'+n%26);
}

int main() {
  ll n;
  cin >> n;
  cout << f(n) << endl;
  return 0;
}

Measured memory_bytes: 3560
#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
#include <array>
#include <iterator>



using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl;
typedef pair < int, int> P;



int N, K,S[100050];
int dp[100000];//dp[i]:i回目の最大幸福度


int main() {
	cin >> N >> K;
	string s;
	cin >> s;
	ll res = 0;
	rep(i, N) {
		if (s[i] == 'L') {
			S[i] = -1;
			res++;
		}
		else {
			S[i] = 1;
		}
	}
	ll happiness = 0;
	rep(i, N) {
		if (i + S[i] < N && i + S[i] >= 0 && S[i + S[i]] == S[i]) {
			happiness++;
		}
	}
	if (res > N - res) {
		dp[0] = res;
	}
	else {
		dp[0] = N-res;
	}
	res = happiness;
	
	for (int i = 1; i < N; i++) {
		
		for (int j = i; j < N-1; j++) {
			if (S[i - 1] == S[i])break;
			if (S[i-1] != S[i] && S[j + 1] != S[j] && S[i] == S[j]) {
				res += 2;
				//reverse(S + i, S + j);
				for (int k = i; k <= j; k++) {
					S[k] *= -1;
				}
				K--;
				
				
			}
			if (K <= 0) {
				
				cout << res << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < N-1; i++) {

		if (S[0] == S[i] && S[i +1] != S[i]) {

			res++;
			//reverse(S, S + i);
			for (int k = 0; k <= i; k++) {
				S[k] *= -1;
			}
			K--;
			cout << res << endl;
			return 0;
		}

			
		
	}
	/*for (int i = N-1; i >= 1; i--) {

		if (S[N-1] == S[i] && S[i - 1] != S[i]) {

			res++;
			//reverse(S+N, S + i);
			for (int k = N-1; k >= i; k--) {
				S[k] *= -1;
			}
			K--;
		}
		if (K <= 0) {
			cout << res << endl;
			return 0;
		}
	}*/
	cout << res << endl;


}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>
#define int long long

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char c) {
	if (c == 'A') return 1;
	else if (c == 'C') return 2;
	else if (c == 'G') return 3;
	else if (c == 'T') return 4;
	else return 0;
}

int getKey(char str[]) {
	int sum = 0, p = 1;
	for (int i = 0; i < strlen(str); ++i) {
		sum += p * getChar(str[i]);
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key % M; }

int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	int key = getKey(str), h;
	for (int i = 0; ; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]) {
	int key = getKey(str), h;
	for (int i = 0; ; ++i) {
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h], str) == 0) return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

signed main() {
	int n;
	char str[L], com[9];
	for (int i = 0; i < M; ++i) H[i][0] = '\0';
	scanf("%lld", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else if (find(str)) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}
}



Measured memory_bytes: 16048
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

		int s = sc.nextInt();

		int a = s;
		int i = 2;
		int ans = 0;
		Set<Integer> set = new HashSet<>();
		set.add(a);
		while (true) {
			a = func(a);
			if (!set.add(a)) {
				ans = i;
				break;
			}
			i++;
		}
		System.out.println(ans);
		sc.close();
	}

	public static int func(int n) {
		if (n % 2 == 0) {
			return n / 2;
		}
		return 3 * n + 1;
	}
}


Measured memory_bytes: 21844
// #define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

map<ll,ll> mp;
ll a, b, c, d;
ll dfs(ll x){
    if(mp.count(x) != 0)return mp[x];
    if(x == 1)return mp[1] = d;
    if(x == 0)return mp[0] = 0;

    ll ans = INF;
    if(ans / d > x){
        chmin(ans, d * x);
    }

    if(x % 2 == 0)chmin(ans, dfs(x / 2) + a);
    else{
        chmin(ans, dfs((x + 1) / 2) + d + a);
        chmin(ans, dfs((x - 1) / 2) + d + a);
    }

    debug(x, ans);

    if(x % 3 == 0){
        chmin(ans, dfs(x / 3) + b);
    }
    else if(x % 3 == 1){
        chmin(ans, dfs((x - 1) / 3) + d + b);
        chmin(ans, dfs((x + 2) / 3) + 2 * d + b);
    }
    else{
        chmin(ans, dfs((x - 2) / 3) + 2 * d + b);
        chmin(ans, dfs((x + 1) / 3) + d + b);
    }

    debug(x, ans);
    rep(i,5){
        if(x % 5 == i && i == 0){
            chmin(ans, dfs(x / 5) + c);
            continue;
        }

        if(x % 5 == i){
            chmin(ans, dfs((x - i) / 5) + i * d + c);
            chmin(ans, dfs((x + (5 - i)) / 5) + (5 - i) * d + c);
        }

    }
    debug(x, ans);
    return mp[x] = ans;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll t; cin >> t;
    rep(_, t){
        ll n; cin >> n;
        cin >> a >> b;
        cin >> c >> d;
        cout << dfs(n) << "\n";
        mp.clear();
    }
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main(){
ll N, K;cin >> N >> K;
  vector<ll> V(N);
  
  rep(i, 0, N)cin >> V[i];
  
  rep(i, K, N){
  
  if(V[i] > V[i - K])cout << "Yes" << endl;
    
  else cout << "No" << endl;
  
  
  
  
  }

}

Measured memory_bytes: 4836
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
/*
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
namespace mp = boost::multiprecision;// 任意長整数型
using bint = mp::cpp_int;// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;// ついでに有理数型
using rat = boost::rational<bint>;
*/
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
int main(){ //srand((unsigned)time(NULL));
  while(1){
    ll H,W;
    cin >> H >> W;
    if(H == 0 && W == 0)break;
    for (int i = 0; i < H; i++) {
      if(i == 0 || i == H-1){
        for (int l = 0; l < W; l++) {
          cout << '#';
        }
      }else{
        cout << '#';
        for (int l = 0; l < W-2; l++) {
          cout << '.';
        }
        cout << '#';
      }
      cout << endl;
    }cout << endl;
  }
}



Measured memory_bytes: 3084
from itertools import product

n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))
print(sum(all(sum(i[b - 1] for b in a[1:]) % 2 == x for a, x in zip(s, p)) for i in product((0, 1), repeat=n)))

Measured memory_bytes: 9200
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, d;
    int ans = 0;

    cin >> n >> d;

    int x[100][100];

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> x[i][j];
        }
    }

    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int sum = 0;
            for (int k = 0; k < d; k++)
            {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }

            int s = sqrt(sum);

            if (s * s == sum)
            {
                ans++;
            }
        }
    }

    cout << ans << endl;
}

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

#define ioso ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define kholo freopen("input.txt","r",stdin), freopen("output.txt","w",stdout);
#define laglo cerr << "Ti : " << clock() * 1.0 / CLOCKS_PER_SEC  << endl;
#define endl '\n';
#define ll long long
ll a[200005];
int main() {
	ioso; //kholo;
	ll n; cin >>n;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	sort(a,a+n);
	ll k=0;
	for (int i = 0; i < n; ++i)
	{
		if(a[i]==a[i-1]) {
			k = 1;
		}
	}
	if(k) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
	//laglo;
}

Measured memory_bytes: 1792
#include<stdio.h>

#define R_MAX 100
#define C_MAX 100

int main(void)
{
        int r, c, array[R_MAX * C_MAX], sum_r, sum_c, sum;

        scanf("%d %d", &r, &c);

        for(int i=0; i < r * c; i++){
                scanf("%d", &array[i]);
        }

        for(int j=0; j < r; j++){
                sum_r = 0;
                for(int k=0; k < c; k++){
                        printf("%d ", array[c * j + k]);
                        sum_r += array[c * j + k];
                }
                printf("%d\n", sum_r);
    }

        for(int l=0; l < c; l++){
                sum_c = 0;
                for(int m=0; m < r; m++){
                        sum_c += array[c * m + l];
                }
                printf("%d ", sum_c);
        }

        sum = 0;

        for(int n=0; n < r * c; n++){
                sum += array[n];
        }

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

        return 0;

}


Measured memory_bytes: 2104
#include <iostream>
#include <map>

using namespace std;

int main(){
  long long int n,m,sum=0,ans=0;
  map<int, int> mp;
  cin >> n >> m;
  long long a[n];
  mp[0]=1;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
    ans+=mp[sum%m];
    mp[sum%m]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3968
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    while(true) {
      int x = sc.nextInt();
      int y = sc.nextInt();
      if(x == 0 && y == 0) {
        break;
      } else {
        System.out.println(Math.min(x, y) + " " + Math.max(x, y));
      }
    }
  }
}



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

int main(void){
    int N, M, X, Cbuf, Abuf;
    cin >> N >> M >> X;
    vector<int> MaxSkill(M, 0);
    vector<int> C;
    vector<vector<int>> A(N, vector<int>(M, 0));
    for(int i=0; i<N; i++){
        cin >> Cbuf;
        C.push_back(Cbuf);
        for(int j=0; j<M; j++){
            cin >> Abuf;
            MaxSkill[j] += Abuf;
            A[i][j] = Abuf;
        }
    }
    if(*min_element(MaxSkill.begin(), MaxSkill.end()) < X){
        cout << -1 << endl;
    }else{
        int MinPrice = 2147483647;
        for(int i=0; i<1<<N; i++){
            vector<int> Skill(M, 0);
            int PriceBuf = 0;
            for(int j=0; j<N; j++){
                if(!(i>>j&1))continue;
                PriceBuf += C[j];
                for(int k=0; k<M; k++){
                    Skill[k]+=A[j][k];
                }
            }
            if(*min_element(Skill.begin(), Skill.end()) >= X){
                MinPrice = min(PriceBuf, MinPrice);
            }
        }
        cout << MinPrice << endl;
    }
    return 0;
}

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



int main() {
	int N;
	cin >> N;
	N /= 200;
	

	cout << 10 - N << endl;
    return 0;	
							
}










Measured memory_bytes: 3620
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> pii;

int main()
{
  string str;
  int hand[26]={0,0,0,0,0,0,0,
		1,1,1,1,1,1,1,1,1,
		0,0,0,0,
		1,0,0,0,1,0};
  int i;

  while(true){
    cin>>str;
    if(str[0]=='#')break;
    int ans=0;
    rep(i,str.size()-1)
      if(hand[str[i]-'a']!=hand[str[i+1]-'a'])ans++;
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3136
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var abc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var k = int.Parse(Console.ReadLine());
            var max = abc.Max();
            var answer = abc.Sum() - max + max * (1 << k);
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,a[1010],b[1010],c[4];
	while(~scanf("%d",&n))
	{
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]);
			b[i]=a[i];
		}
		sort(b+1,b+n+1);
		int k=0;
		for(int i=1;i<=n;i++)
		{
			if(a[i]!=b[i])
			{
				c[k++]=i;
			}
		}
		if(k>2)
		printf("NO\n");
		else
		{
			if(k==0)
			printf("YES\n");
			else
			if(a[c[0]]==b[c[1]]&&a[c[1]]==b[c[0]])
			printf("YES\n");
			else
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

			int result = 0;
			if (n != 100) {
				result = ((int) Math.pow(100, d)) * n;
			} else {
				result = ((int) Math.pow(100, d) * (n + 1));
			}
			System.out.println(result);
		}
	}
}

Measured memory_bytes: 23764
let insertion_sort n v =
  let rec insert v = function
      0 -> v
    | i ->
      let j = i-1 in
      let vi,vj = v.(i),v.(j) in
      if vj <= vi then v
      else (v.(i) <- vj; v.(j) <- vi; insert v j)
  in
  let rec loop v i = if i >= n then v
    else
      let inserted = insert v i in
      for j = 1 to n do
        Printf.printf (if j=n then "%d\n" else "%d ") inserted.(j-1)
      done;
      loop inserted (i+1)
  in loop v 0

let () =
  let n = read_int () in
  let v = read_line () |> Str.split (Str.regexp " ")
          |> List.map int_of_string |> Array.of_list in
  let _ = insertion_sort n v in
  ()

Measured memory_bytes: 4152
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <tuple>
#include <algorithm>
#include <array>
using namespace std;
using ll = long long;
#define rep(i,n) for(decltype(n) i=0; i<n; ++i)
inline constexpr ll Inf = (1ULL << 62) -1;

template <class T>
void updatemax(T& a, T b) { if (b > a) a = b; }

ll pow(ll b, ll p) {
    ll r=1;
    rep(i, p) {
        r *= b;
    }
    return r;
}

int main() {
    ll ans=0;
    ll H,W,K;
    cin >> H >> W >> K;
    char m[6][6]={};
    rep(i,H) rep(j,W) {
        cin >> m[i][j];
    }
    for (int h=pow(2,H)-1; h >= 0; --h) {
        for (int w=pow(2,W)-1; w >= 0; --w) {
            ll count = 0;
            rep(i,H) rep(j,W) {
                if (((h >> i) & 1) || ((w >> j) & 1))
                    continue;
                if (m[i][j] == '#')
                    ++count;
            }
            if (count == K)
                ++ans;
        }
    }

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


Measured memory_bytes: 3320
#include<iostream>
using namespace std;
int main()
{
	int a, b, c, d,hold;
	cin >> a >> b >> c >> d;
	if (a <= c)
	{
		if (b <= d)
		{
			hold = b - c;
		}
		else
		{
			hold = d - c;
		}
	}
	else
	{
		if (b <= d)
		{
			hold = b - a;
		}
		else
		{
			hold = d - a;
		}
	}
	if (hold < 0)
	{
		hold = 0;
	}
	cout << hold;
}

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 1e5+5;
int  a[N];

int main()
{
	IOS;
	int a,b;
	cin >> a >> b;
	int cnt = 0;
	for(int i = 1; i <= 2; i++)
	{
		if(a >= b)
		{
			a--;
			cnt += a+1;
		}
		else
		{
			b--;
			cnt += b+1;
		}
	}
	cout << cnt;
	return 0;
}


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

using namespace std;

int main()
{
  char c; cin >> c;
  if (c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') {
    cout << "vowel";
  } else {
    cout << "consonant";
  }
}

Measured memory_bytes: 256
def num_divisors(n):
  res = 0
  i = 1
  while i * i <= n:
    if n % i == 0:
      res += 1
      res += 1 if i * i != n else 0
    i += 1
  return res


N = int(input())
res = 0
for n in range(1, N + 1, 2):
  if num_divisors(n) == 8:
    res += 1
print(res)

Measured memory_bytes: 38384
#include <stdio.h>
#include <stdlib.h>
int main(void){
    
    int n,m;
    scanf("%d%d",&n,&m);
    
    int a[99],b[99],c[99],d[99];
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int j=0;j<m;j++){
        scanf("%d%d",&c[j],&d[j]);
    }
    
    for(int k=0;k<n;k++){
        int min=0;
        for(int l=0;l<m;l++){
            if(abs(c[l]-a[k])+abs(d[l]-b[k])<abs(c[min]-a[k])+abs(d[min]-b[k])){
                min=l;
            }
        }
        printf("%d\n",min+1);
    }
}

Measured memory_bytes: 1712
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        m = i * 10000 + j * 5000 + (n - i - j) * 1000
        if m == y:
            print(i, j, (n - i - j))
            exit()
print(-1, -1, -1)

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

const ll mod = 1e9 + 7;
const ll MAX_N = 100010;

vector<ll> fact(MAX_N);
vector<ll> fact_inv(MAX_N);

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

ll inv(ll x, ll mod) {
  ll res = pow_mod(x, mod - 2, mod);
  return res;
}

void fact_mod(ll mod) {
  for (ll i = 0; i < MAX_N; i++) {
    if (i == 0) {
      fact[i] = 1;
      fact_inv[i] = 1;
    }
    else {
      fact[i] = (i * fact[i-1]) % mod;
      fact_inv[i] = (inv(i, mod) * fact_inv[i-1]) % mod;
    }
  }
  return;
}

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(A.begin(), A.end());
  fact_mod(mod);

  ll max_S = 0;
  ll min_S = 0;
  for (ll i = K-1; i < N; i++) {
    max_S += A[i] * fact[i] %mod * fact_inv[i-K+1] %mod * fact_inv[K-1] %mod;
  }
  for (ll i = 0; i < N-K+1; i++) {
    min_S += A[i] * fact[N-i-1] %mod * fact_inv[N-i-K] %mod * fact_inv[K-1] %mod;
  }
  ll ans = (max_S - min_S)%mod;
  if (ans < 0) ans += mod;
  cout << ans << endl;
}

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

int main(){
 int x, y, i;
 for ( i = 0; ; i++){
  cin >> x >> y;
  if ( x == 0 && y == 0 ) break;
  if ( x <= y ){
  cout << x << " " << y << endl;
  } else {
  cout << y << " " << x << endl;
  }
 }

return 0;
}

Measured memory_bytes: 3056
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

N, M, K = map(int, input().split())
friends_uf = UnionFind(N)
counts = [1] * N
for _ in range(M):
    i, j = map(lambda n: int(n) - 1, input().split())
    counts[i] += 1
    counts[j] += 1
    friends_uf.union(i, j)
blocks_graph = [[] for _ in range(N)]
for _ in range(K):
    i, j = map(lambda n: int(n) - 1, input().split())
    blocks_graph[i].append(j)
    blocks_graph[j].append(i)
for i in range(N):
    ans = friends_uf.size(i) - counts[i]
    for j in blocks_graph[i]:
        if friends_uf.same(i, j):
            ans -= 1
    print(ans, end=" ")

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

using namespace std;

int m[10];

int main() {

    for (int i = 0; i < 10; i++) {
        cin >> m[i];
    }

    sort(m, m + 10);

    cout << m[9] << endl << m[8] << endl << m[7] << endl;

    return 0;
}

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

int main(){
	int resa = 3000, resb = 3000;
	for(int i = 0; i < 3; i++){
		int a;
		cin >> a;
		resa = min(resa, a);
	}
	for(int i = 0; i < 2; i++){
		int a;
		cin >> a;
		resb = min(resb, a);
	}
	cout << resa + resb - 50 << endl;
	return 0;
}


Measured memory_bytes: 3096
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    counter = Counter(A)
    ans = 0
    for a, c in counter.items():
        if c < a:
            ans += c
        else:
            ans += c - a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18676
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL A, B;
	in >> A >> B;

	LL ans = 0;
	rep(i, 45)
	{
		LL term = (1LL << i) * 2LL;
		LL num1 = (B + 1) / term;
		LL cnt1 = num1 * (1LL << i) + ((B + 1) % term != 0 ? std::max<LL>(B % term - term / 2 + 1, 0) : 0);
		LL num2 = A / term;
		LL cnt2 = num2 * (1LL << i) + (A%term != 0 ? std::max<LL>((A - 1) % term - term / 2 + 1, 0) : 0);
		LL res = cnt1 - cnt2;
		if (res % 2 == 1) ans += (1LL << i);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
def check(string):
    if string == string[::-1]:
        return True
    else:
        return False


S = input()
n = len(S)

S1 = S[:(n-1)//2]
S2 = S[(n+1)//2:]

if check(S) and check(S1) and check(S2):
    print("Yes")
else:
    print("No")

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }

    if (a.at(0) > 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) + 2 <= a.at(i + 1)) {
            cout << -1 << endl;
            return 0;
        }
    }

    long long cnt = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a.at(i) + 1 == a.at(i + 1)) cnt++;
        else cnt += (long long)a.at(i + 1);
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>

using namespace std;

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

	vector<int> x(n, 0), y(n, 0);

	for (int i = 0; i < n; ++i)
		cin >> x[i];

	for (int i = 0; i < n; ++i)
		cin >> y[i];

	// Manhattan distance(p = 1)
	double md = 0.0;
	double p = 1.0;
	for (int i = 0; i < n; ++i)
		md += pow(abs(x[i] - y[i]), p);
	md = pow(md, 1 / p);

	// Euclidean distance(p = 2)
	double ed = 0.0;
	p = 2.0;
	for (int i = 0; i < n; ++i)
		ed += pow(abs(x[i] - y[i]), p);
	ed = pow(ed, 1 / p);

	// case of 'p = 3'
	double td = 0.0;
	p = 3.0;
	for (int i = 0; i < n; ++i)
		td += pow(abs(x[i] - y[i]), p);
	td = pow(td, 1 / p);

	// Chebyshev distance(p = ???)
	double cd = 0.0;
	for (int i = 0; i < n; ++i)
		if (abs(x[i] - y[i]) > cd)
			cd = abs(x[i] - y[i]);

	cout << setprecision(16) << md << endl;
	cout << ed << endl;
	cout << td << endl;
	cout << cd << endl;

	return 0;
}

Measured memory_bytes: 1332