akhauriyash/Code-Regression huggingface dataset:
import sys
from time import time
from random import randint

def func(s, x):
    last = [0] * 26
    score = 0
    for i, v in enumerate(x, 1):
        last[v] = i
        c = 0
        for j in range(26):
            c += s[j] * (i - last[j])
        score += s[i * 26 + v] - c
    return score

def main():
    start = time()
    d, *s = map(int, sys.stdin.buffer.read().split())
    x = ([*range(26)] * 15)[:d]
    M = func(s, x)
    while time() - start < 1.8:
        y = x.copy()
        if randint(0, 1):
            y[randint(0, d - 1)] = randint(0, 25)
        elif randint(0, 1):
            i=randint(0, d - 16)
            j=randint(i + 1, i + 15)
            y[i], y[j] = y[j], y[i]
        else:
            i = randint(0, d - 15)
            j = randint(i + 1, i + 7)
            k = randint(j + 1, j + 7)
            if randint(0, 1):
                y[i], y[j], y[k] = y[j], y[k], y[i]
            else:
                y[i], y[j], y[k] = y[k], y[i], y[j]
        t = func(s, y)
        if t > M:
            M = t
            x = y
    for t in x:
        print(t + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 93768
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,a,b; cin >> n >> a >> b; if(a>b) swap(a,b); //a<b
    if((b-a)%2==0){out((b-a)/2); return 0;}
    else {
        int ans1 = max(a,b)-1;
        int ans2 = n-min(a,b);
        int ans3 = (n-b)+(n-(a+n-b)-1)/2+1;
        int ans4 = (a-1)+(b-a-1)/2+1;
        out(min({ans1,ans2,ans3,ans4}));
    }

    return 0;
}

Measured memory_bytes: 256
#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>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
  int n;
  vector<int> f, primes;
  Sieve(int n=1):n(n), f(n+1) {
    f[0] = f[1] = -1;
    for (ll i = 2; i <= n; ++i) {
      if (f[i]) continue;
      primes.push_back(i);
      f[i] = i;
      for (ll j = i*i; j <= n; j += i) {
        if (!f[j]) f[j] = i;
      }
    }
  }
  bool isPrime(int x) { return f[x] == x;}
  vector<int> factorList(int x) {
    vector<int> res;
    while (x != 1) {
      res.push_back(f[x]);
      x /= f[x];
    }
    return res;
  }
  vector<P> factor(int x) {
    vector<int> fl = factorList(x);
    if (fl.size() == 0) return {};
    vector<P> res(1, P(fl[0], 0));
    for (int p : fl) {
      if (res.back().first == p) {
        res.back().second++;
      } else {
        res.emplace_back(p, 1);
      }
    }
    return res;
  }
  vector<pair<ll,int>> factor(ll x) {
    vector<pair<ll,int>> res;
    for (int p : primes) {
      int y = 0;
      while (x%p == 0) x /= p, ++y;
      if (y != 0) res.emplace_back(p,y);
    }
    if (x != 1) res.emplace_back(x,1);
    return res;
  }
};

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

  Sieve s(1000005);
  auto fs = s.factor(n);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 7820
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;

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

int main(){
    int N,sum,num;
    int W[100];
    cin >> N >> sum;
    W[0] = sum;
    for(int i=1;i<N;i++){
        cin >> num;
        sum += num;
        W[i] = sum;
    }
    int curr = sum - W[0];
    for(int i=0;i<N;i++){
        if(curr < abs(sum - W[i]*2)) break;
        curr = abs(sum - W[i]*2);

    }
    cout << curr;
}

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

bool agari(int num[]){
  for(int head = 1;head<10;head++){
    if(num[head]>=2){
      int hands[12] = {0};
      for(int i = 1;i<10;i++)
	hands[i] = num[i];
      hands[head]-=2;
      bool agari = true;
      for(int i=0;i<10;i++)
	while(hands[i]%3)
	  for(int j=0;j<3;j++){
	    hands[i+j]--;
	    if(hands[i+j]<0)
	      agari = false;
	  }
      if(agari)
	return true;
    }
  }
  return false;
}

int main(){
  long long hand;
  while(cin>>hand){
    int num[10] = {0};
    for(;hand>0;hand/=10){
      num[hand%10]++;
    }
    bool tenpai = false;
    for(int i=1;i<10;i++){
      if (num[i]<4){
	num[i]++;
	if(agari(num)){
	  if(tenpai)
	    cout<<" ";
	  cout<<i;
	  tenpai = true;
	}
	num[i]--;
      }
    }
    if(!tenpai)
      cout<<0;
    cout<<endl;
  }
  return 0;
}

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

int N, x1, y1, x2, y2, X, Y;

bool CanReceive(int x, int y, int _X = X, int _Y = Y)
{
    return x == _X || y == _Y || x + y == _X + _Y || x - y == _X - _Y;
}

int main()
{
    cin >> N;
    
    for(int i = 0; i < N; ++i)
    {
        cin >> x1 >> y1 >> x2 >> y2 >> X >> Y;
        
        if((x1 == X && y1 == Y) || (x2 == X && y2 == Y))
            cout << 0 << endl;
        else if(CanReceive(x1, y1) && CanReceive(x2, y2))
            cout << 1 << endl;
        else if(CanReceive(x1, y1) || CanReceive(x2, y2))
            cout << 2 << endl;
        else if(CanReceive(x1, y1, x2, y2) ||
            CanReceive(x1, y2) || CanReceive(x2, y1) ||
            CanReceive(x1, y2 + x1 - x2) || CanReceive(x1, y2 - x1 + x2) ||
            CanReceive(x2, y1 + x1 - x2) || CanReceive(x2, y1 - x1 + x2) ||
            CanReceive(x1 + y1 - y2, y2) || CanReceive(x1 - y1 + y2, y2) ||
            CanReceive(x2 + y1 - y2, y1) || CanReceive(x2 - y1 + y2, y1) ||
            (!((x1 + y1 - x2 - y2) & 1) &&
            (CanReceive((x1 + x2 - y1 + y2) / 2, (x2 - x1 + y1 + y2) / 2) ||
            CanReceive((x1 + x2 + y1 - y2) / 2, (x1 - x2 + y1 + y2) / 2))))
            cout << 3 << endl;
        else
            cout << 4 << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
#include <iomanip>
#include <queue>
#include <cmath>
#include <math.h>
#include <string>
#include <cmath>
#include <bitset>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;
#define min(a, b) ((a) < (b) ? (a) : (b))

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

	int K, S;
	cin >> K >> S;
	long res = 0;
	for (int i = 0; i <= K; i++) {
		for (int j = 0; j <= K; j++) {
			if (S - i - j <= K && i + j <= S) {
				++res;
			}
		}
	}

	cout << res << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

func (p *problem) solve() {
	t := p.NextInts()
	N, L := t[0], t[1]
	var first, last int
	sum := 0
	for i := 1; i <= N; i++ {
		tmp := L + i - 1
		if i == 1 {
			first = tmp
		}
		sum += tmp
		last = tmp
	}
	if first > 0 {
		sum -= first
	} else if last < 0 {
		sum -= last
	}
	p.PrintInt(sum)
}

var (
	debug  bool
	output string
)

func main() {
	flag.BoolVar(&debug, "debug", false, "Print debug logs")
	flag.BoolVar(&debug, "d", false, "Print debug logs")
	flag.StringVar(&output, "output", "stdout", "Specify output target (Default: stdout)")
	flag.StringVar(&output, "o", "stdout", "Specify output target (Default: stdout)")
	flag.Parse()

	if debug {
		out := os.Stdout
		if output != "stdout" {
			logfile, err := os.OpenFile(output, os.O_CREATE|os.O_WRONLY, 0666)
			if err != nil {
				panic(err)
			}
			defer logfile.Close()
			out = logfile
		}
		log.SetOutput(out)
	} else {
		log.SetOutput(ioutil.Discard)
	}

	p := problem{
		in:  bufio.NewReader(os.Stdin),
		out: bufio.NewWriter(os.Stdout),
	}
	p.solve()

	if err := p.out.Flush(); err != nil {
		panic(err)
	}
}

type problem struct {
	in  *bufio.Reader
	out *bufio.Writer
}

func (p *problem) PrintInt(d int) {
	p.Printf("%d\n", d)
}

func (p *problem) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, format, a...); err != nil {
		panic(err)
	}
}

func (p *problem) Printfln(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(p.out, fmt.Sprintf("%v\n", format), a...); err != nil {
		panic(err)
	}
}

func (p *problem) NextInt() int {
	return stoi(p.Next())
}

func (p *problem) NextInts() []int {
	line := p.NextSSLine()
	ds := make([]int, len(line))
	for i, s := range line {
		ds[i] = stoi(s)
	}
	return ds
}

func (p *problem) NextSSLine() []string {
	return strings.Split(p.Next(), " ")
}

// Next reads line and return string.
func (p *problem) Next() string {
	var b []byte
	for {
		l, pre, err := p.in.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}


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

#define DeltaCube23 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define minimum(a) *min_element(a.begin(), a.end())
#define maximum(a) *max_element(a.begin(), a.end())
#define MOD 1000000007
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i >= (b); i--)

typedef long long int lli;

using namespace std;

const int mx=2e6+5;

int main()
{
    DeltaCube23
	int t=1;
	//cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    string s;
	    cin>>s;
	    int w=0,r=0;
	    forf(i,0,n)
	    if(s[i]=='W')
	    w++;
	    int e=n-w;
	    forf(i,e,n)
	    if(s[i]=='W')
	    r++;
	    cout<<min(e,w-r);
	}
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll n, m;
ll a[305][305];
bool v[305];
ll b[305];
ll cnt[305];
ll ans = 4e18;

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < n; i++)
    {
        for(ll j = 0; j < m; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    for(ll i = 0; i < m; i++)
    {
        ll mx = 0, mi = 0;
        for(ll j = 1; j <= m; j++)
        {
            cnt[j] = 0;
        }
        for(ll j = 0; j < n; j++)
        {
            cnt[a[j][b[j]]]++;
            if(mx < cnt[a[j][b[j]]]) mx = cnt[a[j][b[j]]], mi = a[j][b[j]];
        }
        ans = min(ans, mx);
        v[mi] = true;
        for(ll j = 0; j < n; j++)
        {
            while(v[a[j][b[j]]]) b[j]++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;
    ll A[100000];
    for(int i=0;i<N;i++)
        cin >> A[i];
    
    ll ans = 0, sum = 0;
    for(int i=0;i<N;i++){
        if(A[i] != 0){
            sum += A[i];
        }else{
            ans += sum/2;
            sum = 0;
        }
    }
    ans += sum/2;
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer> d = new ArrayList<Integer>(k);

		for (int i = 0; i < k; i++) {
			d.add(sc.nextInt());
		}

		for (Integer i = n; i < 100000; i++) {
			int flag = 0;
			int len = String.valueOf(i).length();
			int dgt = (int) Math.pow(10, len - 1);

			int tmp = i;
			for (int j = 1; j <= len; j++) {
				if (d.contains(tmp / dgt)) {
					flag = 1;
					break;
				}
				tmp %= dgt;
				dgt /= 10;
			}

			if (flag == 0) {
				System.out.print(i);
				break;
			}
		}

	}
}

Measured memory_bytes: 27860
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}

int n,m;ll w, h;
vector<ll> d(10, 0);
//vector<vector<bool>> f;
map<pair<ll, ll>,bool> f;

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int cou(ll x, ll y){
	int c = 0;
	if(f[pair<ll,ll>(x,y)])c++;
	rep(i, 8){
		if(f[pair<ll,ll>(x+dx8[i],y+dy8[i])])c++;
	}
	return c;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	cin>>h>>w>>n;
	
	d[0] = (w-2)*(h-2);
	rep(i, n){
		ll a, b;
		cin>>a>>b;a--;b--;
		rep(j, 8){
			ll nx = a+(ll)dx8[j];
			ll ny = b+(ll)dy8[j];
			if(0 < nx && nx < h-1 && 0 < ny && ny < w-1){
				int c = cou(nx, ny);
				d[c]--;
				d[c+1]++;
				//debug("%d %d %d\n",nx,ny,c);
			}else{
				//debug("%d %d xx\n",nx,ny);
			}
		}
		if(0 < a && a < h-1 && 0 < b && b < w-1){
			int c = cou(a, b);
			d[c]--;
			d[c+1]++;
			//debug("%d %d %d\n",a,b,c);
		}

		f[pair<ll,ll>(a,b)] = true;
	}
	rep(i, 10){
		cout << d[i]<< endl;
	}
	return 0;
}


Measured memory_bytes: 156544
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  int res1 = 1, res2 = 1;

  if(abs(n-m) >= 2) return cout << 0 << '\n',0;

  reps(i,n){
    (res1 *= i) %= mod1;
  }

  reps(i,m){
    (res2 *= i) %= mod1;
  }

  if(n == m){
    cout << (res1 * res2) * 2 % mod1 << '\n';
  }else{
    cout << res1 * res2 % mod1 << '\n';
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n, i, input;
    scanf("%d", &n);
    //int l[n];
    int max = -1000000, min = 1000000;
    long int sum = 0;
    for (i = 0; i < n; i++){
        scanf("%d", &input);

        //printf("(%d): ", i);
        //printf("%d, ", input);
//    }
//}

//    }
//   for (i = 1; i < n;i++){
        if (max < input)
        {
            max = input;
        }
        if (input < min)
        {
            min = input;
        }
        sum = sum + input;
    }
    printf("%d %d %ld\n", min, max, sum);
    return 0;
}
//28 999997 5019101515


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
 
#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";
 
// #pragma GCC optimize ("O3")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #define _CRT_SECURE_NO_WARNINGS
 
// #ifndef ONLINE_JUDGE
// #define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
// template <typename Arg1>
// void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
// template <typename Arg1, typename... Args>
// void __f(const char* names, Arg1&& arg1, Args&&... args){
// 	const char* comma = strchr(names + 1, ',');
// 	cerr.write(names, comma - names) << " : " << arg1 << "  ";
// 	__f(comma + 1, args...);}
// #else
// #define debug(...)
// #endif
 
// template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
// template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
// template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}
 
const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 1e5 + 5;
 
int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}
 
int modinv(int a){return takemod(pow(takemod(a), mod-2,mod));}

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

	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("output.txt","w",stdout);
	// 	freopen("error.txt","w",stderr);
	// #endif

	time_t t1, t2;
	t1 = clock();

	string s;
	string t;
	cin >> s >> t;
	int arr[s.length()][t.length()];

	for(int i=0; i<s.length(); i++){
		for(int j=0; j<t.length(); j++){
			if(i==0 && j==0){
				if (s[i]==t[j]) arr[i][j]=1;
				else arr[i][j]=0;
			}
			else if(i==0){
				if (s[i]==t[j]) arr[i][j]=1;
				else arr[i][j]=arr[i][j-1];
			}
			else if(j==0){
				if(s[i]==t[j]) arr[i][j]=1;
				else arr[i][j]=arr[i-1][j];
			}
			else{
				if(s[i]==t[j]) arr[i][j]=arr[i-1][j-1]+1;
				else arr[i][j]=max(arr[i-1][j], arr[i][j-1]);
			}
		}
	}
	int i1=s.length()-1, j1=t.length()-1;
	// cout<<i1<<" "<<j1<<endl;
	string ans="";

	while (i1>=0 && j1>=0) {
		// cout<<i1<<" "<<j1<<endl;
		if (s[i1]==t[j1]){
			ans+=s[i1];
			i1--;
			j1--;
		}
		else{
			if (i1==0) j1--;
			else if (j1==0) i1--;
			else if(arr[i1-1][j1]>arr[i1][j1-1]) i1--;
			else j1--;
		}
	}
	
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	return 0;
}



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

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;

  for(int i=0;i<tx-sx;i++) {
    cout << 'R';
  }
  for(int i=0;i<ty-sy;i++){
    cout << 'U';
  }
  for(int i=0;i<tx-sx;i++){
    cout << 'L';
  }
  for(int i=0;i<ty-sy;i++) {
    cout << 'D';
  }
  cout << 'D';
  for(int i=0;i<tx-sx+1;i++) {
    cout << 'R';
  }
  for(int i=0;i<ty-sy+1;i++) {
    cout << 'U';
  }
  cout << 'L';
  cout << 'U';
  for(int i=0;i<tx-sx+1;i++) {
    cout << 'L';
  }
  for(int i=0;i<ty-sy+1;i++) {
    cout << 'D';
  }
  cout << 'R' << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,K,d,A;
int s[102]={0};
int main(){
  cin>>N>>K;
  for(int k=0;k<K;k++){
    cin>>d;
    for(int j=0;j<d;j++){
      cin>>A;
      s[A]+=1;
    }
  }
  int sum=0;
  for(int i=1;i<=N;i++){
    if(s[i]==0)sum++;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <cmath>
#include <limits>
#define REP(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;

template <class T> struct StarrySkyTreeMin {

    int N;
    vector<T> node_acc, node_min;
    const T INF = numeric_limits<T>::max() / 2;
  
    StarrySkyTreeMin (int n) {
        N = 2 << (int)log2(n);
        node_acc.resize(N*2,0);
        node_min.resize(N*2,0); 
    }

    void add(int l, int r, T val) {
        _add(l,r,val,0,0,N);
    }
    
    T get_min(int l, int r) {
        T ret = _get_min(l,r,0,0,N);
        return (ret == INF) ? 0 : ret;
    }

    void _add(int a, int b, T x, int k, int l, int r) {
        if (r <= a || b <= l) return;
        if (a <= l && r <= b) {
            node_acc[k] += x;
            return;
        }
        _add(a,b,x,k*2+1,l,(l+r)/2);
        _add(a,b,x,k*2+2,(l+r)/2,r);
        T l_val = node_min[k*2+1] + node_acc[k*2+1];
        T r_val = node_min[k*2+2] + node_acc[k*2+2];
        node_min[k] = min(l_val,r_val);
    }

    T _get_min(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return (node_min[k] + node_acc[k]);
        T l_val = _get_min(a,b,k*2+1,l,(l+r)/2);
        T r_val = _get_min(a,b,k*2+2,(l+r)/2,r);
        return (min(l_val,r_val) + node_acc[k]);
    }

};

int main() {
    
    StarrySkyTreeMin<long long> inst(100010);

    int n,q; cin >> n >> q;
    REP(i,q) {
        int com; cin >> com;
        if(com == 0) {
            long long s,t,x; cin >> s >> t >> x;
            inst.add(s,t+1,x);
        } else {   
            int a; cin >> a;
            cout << inst.get_min(a,a+1) << endl;
        }
    }    

    return 0;
}

Measured memory_bytes: 6976
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int h = sc.nextInt();
    int n = sc.nextInt();
    sc.nextLine();
    int[] x = new int[n];
    int[] y = new int[n];
    int[] a = new int[n];

    for (int i = 0; i < n; ++i) {
      x[i] = sc.nextInt();
      y[i] = sc.nextInt();
      a[i] = sc.nextInt();
      sc.nextLine();
    }

    int d = 0, u = h, r = 0, l = w;
    for (int i = 0; i < n; ++i) {
      switch (a[i]) {
        case 1:
          r = (r < x[i] ? x[i] : r);
          break;
        case 2:
          l = (l > x[i] ? x[i] : l);
          break;
        case 3:
          d = (d < y[i] ? y[i] : d);
          break;
        case 4:
          u = (u > y[i] ? y[i] : u);
          break;
      }
      if (r >= l || d >= u) {
        System.out.println("0");
        return;
      }
    }
    System.out.println((l - r) * (u - d));
  }
}


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

int main() {
  int n; ll k; cin >>n>>k;
  vector<int> A(n);
  vector<int> cnt(n);
  vector<int> t = {0};
  vector<int> old(n,-1);
  rep(i,n) {
    cin>>A[i];
    A[i]--;
  }
  int v = 0;
  old[v] = 0;
  rep(i,n+1) {
    v = A[v];
    if (old[v] != -1) break;
    old[v] = t.size();
    t.push_back(v);
  }
  int p = old[v];
  if (k<p) cout << t[k]+1 << endl;
  else {
    int d = t.size() - p;
    int m = (k - p) % d;
    cout << t[p+m]+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 6672
from itertools import product

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

bulb = {}
for i in range(1, m+1):
    k_s = list(map(int, input().split()))
    bulb[i] = k_s[1:]

p = list(map(int, input().split()))

count = 0
for item in product([0, 1], repeat=n):
    on = [ind+1 for ind, status in enumerate(item) if status]
    for k, v in bulb.items():
        if p[k-1] != len(set(v).intersection(set(on))) % 2:
            break
    else:
        count += 1

print(count)



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

int main() {
	int n, x, m[110];
  	int sum = 0;
  	int min = 1500;
	cin >> n >> x;
  	int piece = n;
	for (int i = 0;i < n;i++) {
	    cin >> m[i];
	    sum = sum + m[i];
	    if (m[i] < min) min = m[i];
	}
	while (sum <= x) {
	    sum = sum + min;
	    piece++;
	}
	cout << piece - 1;
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    ll H, W;
    cin >> H >> W;
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }

    vector<Vl> ans(H, Vl(W));
    int now = 0;
    for (ll h = 0; h < H; h++) {
        if (h & 1) {
            for (ll w = W - 1; w >= 0; w--) {
                ans[h][w] = now + 1;
                --A[now];
                if (A[now] == 0) ++now;
            }
        }
        else {
            for (ll w = 0; w < W; w++) {
                ans[h][w] = now + 1;
                --A[now];
                if (A[now] == 0) ++now;
            }
        }
    }

    for (ll h = 0; h < H; h++) {
        for (ll w = 0; w < W - 1; w++) {
            cout << ans[h][w] << " ";
        }
        cout << ans[h][W - 1] << "\n";
    }

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char s[105];
    cin >> s;
    int lg=strlen(s),cnt=0,j;
    if (lg%2==0) j=1;
    else j=0;
    for (int i=lg/2;i<lg;i++)
    {
        if (s[i]!=s[i-j]) cnt++;
        j+=2;
    }
    cout << cnt;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
char c;
int h,w,i,j;
int a[105],b[105];
char s[105][105];
int main(){

 cin>>h>>w;
 for(int i=1;i<=h;i++)
   for(int j=1;j<=w;j++)
     
 {
   cin>>s[i][j];
   if(s[i][j]=='#')a[i]=1,b[j]=1;
 }

  
  for(int i=1;i<=h;i++)
 {
 	if(a[i]==1)
 {  for(int j=1;j<=w;j++)
 		
     
 {
  if(b[j]==1) cout<<s[i][j]; 
   
 }
 cout<<endl;
   }  
   }
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
};

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
//abc178_b.cpp
//Sun Sep 13 20:42:10 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007
#define rep(i,n) for (int i=0;i<(n);++i)

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

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;

	ll ans = -2e18;
	ans = max(ans,b*d);
	ans = max(ans,a*d);
	ans = max(ans,a*c);
	ans = max(ans,b*c);


	cout << ans << endl;
//	printf("%.4f\n",ans);
}


Measured memory_bytes: 3632
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

while True:
    S, tp = raw_input().split()
    if tp == 'X':
        break
    if tp == 'L':
        if '_' in S:
            ls = S.split('_')
            S = ''
            for s in ls:
                S += chr(ord('A') + ord(s[0]) - ord('a')) + s[1:]
        if 0 <= ord(S[0]) - ord('A') < 26:
            S = chr(ord('a') + ord(S[0]) - ord('A')) + S[1:]
    if tp == 'U':
        if '_' in S:
            ls = S.split('_')
            S = ''
            for s in ls:
                S += chr(ord('A') + ord(s[0]) - ord('a')) + s[1:]
        if 0 <= ord(S[0]) - ord('a') < 26:
            S = chr(ord('A') + ord(S[0]) - ord('a')) + S[1:]
    if tp == 'D':
        for i in range(26):
            S = S.replace(chr(ord('A') + i), '_' + chr(ord('a') + i))
        if S[0] == '_':
            S = S[1:]
    print S


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0;i<s.size();i++){
        if (s[i]=='+'){
            ans ++;
        }
        else {
            ans --;
        }
    }cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr<<endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
double dp[3000][3000];

signed main(void)
{ios
	int n;
	cin>>n;
	double p[n+1];
	rep(i,1,n+1)
	cin>>p[i];
	dp[1][1]=p[1];
	dp[1][0]=1-p[1];
	rep(i,2,n+1)
	{
		rep(j,0,i+1)
		{
			dp[i][j]=p[i]*dp[i-1][j-1]+(1-p[i])*dp[i-1][j];
		}
	}
	double ans=0;
	rep(j,(n+1)/2,n+1)
	{
		ans+=dp[n][j];
	}
	cout<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 68992
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll nPr(int n,int r){ll i,result=1;rep(i,r){result*=(ll)(n-i);}return result;}
ll nCr(int n,int r){ll i,result=1;if(n<r) return 0;rep(i,min(r,n-r)){result*=(ll)(n-i);result/=(ll)(i+1);}return result;}
#define nHr(n,r) nCr((int)((n)+(r)+1),(int)(r))
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1};
int dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(const void *a, const void *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(const void *a, const void *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(const void* left, const void* right) {return strcmp((char *)left,(char *)right);}
int downchar(const void* left, const void* right) {return strcmp((char *)right,(char *)left);}
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1){
            res *= a; if(mod>=1) res %= mod;
        }
        a *= a; if(mod>=1) a %= mod;
        n >>= 1;
    }
    return res;
}
const int MAX=510000;
#define MOD 998244353
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD2;
        inv[i] = MOD2 - inv[MOD2%i] * (MOD2 / i) % MOD2;
        finv[i] = finv[i - 1] * inv[i] % MOD2;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD2) % MOD2;
}
void initialize(){
    COMinit();
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,tmp;
  int a[LIMIT2]={0};
  char s[LIMIT1];
  
  scanf("%lld %lld %lld",&n,&m,&k);
  rep(i,k+1){
    tmp = COM(n-1,i);
    tmp = (tmp * m % MOD2) * modpow(m-1,n-i-1,MOD2);
    if(tmp<0) tmp+=MOD2;
    tmp %= MOD2;
    result += tmp;
    if(result<0) result+=MOD2;
    result %= MOD2;
  }
  printf("%lld",result);
  return 0;
}



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

void swap(int &x, int &y){
	int t = x;
	x = y;
	y = t;
	return;
}

void sort(int &n, int &m){
	if(n > m) swap(n, m);
	return;
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	sort(a, b);
	sort(b, c);
	sort(a, b);
	cout << a << " " << b << " " << c <<endl;
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

struct point {
    ll x, y;
};

int main(){
    int n, K;
    cin >> n >> K;
    
    vector<ll> x(n), y(n);
    vector<point> v(n);

    rep(i, n){
        cin >> x[i] >> y[i];
        v[i] = {x[i], y[i]};
    }

    sort(all(x));
    sort(all(y));

    
    ll ans = (x[n-1]-x[0]) * (y[n-1]-y[0]);

    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=0; k<n; k++){
                for(int l=k+1; l<n; l++){
                    int cnt = 0;
                    rep(idx, n){
                        ll xi = v[idx].x;
                        ll yi = v[idx].y;
                        if(x[i]<=xi && xi<=x[j] && y[k]<=yi && yi<=y[l]) cnt++;
                    }
                    ll s = abs(x[j] - x[i]) * abs(y[l] - y[k]);
                    if(cnt >= K) ans = min(ans, s);
                }
            }
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 256
s = gets.chomp
t = gets.chomp
max_count = 0

(s.size - t.size + 1).times do |i|
  count = 0
  s[i...(t.size + i)].chars.each_with_index do |x, j|
    if t[j] == x
      count += 1
    end
    max_count = [count, max_count].max
  end
end

puts t.size - max_count


Measured memory_bytes: 14340
public class Main {

	//自分が書いたコード
	public static void main(String[] a) {
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i+"x"+j+"="+(i*j));
			}
		}
	}

}


Measured memory_bytes: 24116
import java.util.Scanner;
class Main{
    public static void main(String arg[]){
        Scanner scn=new Scanner(System.in);
        int[] num=new int[3];
        int min=10;
        int max=0;
        for(int i=0;i<3;i++){
            num[i]=scn.nextInt();
            if(min>num[i]){
                min=num[i];
            }
            if(num[i]>max){
                max=num[i];
            }
        }
        int[] answer = new int[3];
        int[] check ={0,0};
        for(int i=0;i<3;i++){
            if(max==num[i]&&check[0]==0){
                answer[0]=num[i];
                check[0]++;
            }else if(min==num[i]&&check[1]==0){
                answer[2]=num[i];
                check[1]++;
            }else{
                answer[1]=num[i];
            }
        }
        String buf=String.valueOf(answer[0])+String.valueOf(answer[1]);
        System.out.println(Integer.parseInt(buf)+answer[2]);
    }
}

Measured memory_bytes: 21844
#include <stdio.h>

int* init_card(int* card, int len) {
  int i;
  for(i=0;i<len;i++) card[len-i-1]=i+1;
  return card;
}

void cut_card(int* card, int p, int c) {
  int diff_card[50], i;

  for(i=0;i<c;    i++) diff_card[i]   = card[p-1+i];
  for(i=0;i<p;    i++) diff_card[i+c] = card[i];
  for(i=0;i<p+c-1;i++) card[i] = diff_card[i];
}

int main() {
  int n,r,card[50];
  
  while(1) {
    scanf("%d %d", &n, &r);
    if(n==0) break;

    init_card(card, n);

    int i,p,c;
    for(i=0;i<r;i++) {
      scanf("%d %d", &p, &c);
      cut_card(card, p, c);
    }
    
    printf("%d\n", card[0]);
  }

  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;

int main(){
    int n,m;cin>>n>>m;
    vector<P> s;
    rep(i,n){
        int a,b;cin>>a>>b;
        s.push_back({a,b});
    }
    sort(been(s));
    ll ans =0,i =0,nw=0;
    while(nw<m){
        ll v =s[i].first,c= s[i].second;
        if(nw+c>m){
            ans += (m-nw)*v;
            nw = m;
        }
        else{
            ans+=c*v;
            nw+=c;
        }
        i++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int ans;
int main()
{
    int a,b,c,n;
    cin>>a>>b>>c>>n;
    for (int i=0;i<=a;i++)
    {
        for(int j=0;j<=b;j++)
        {
            if(n-i*500-j*100>=0&&n-i*500-j*100<=c*50)
            {
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main (void) {
    int N, K;
    cin >> N >> K;

    double ans = 0;
    double tmp_ans;
    int score;
    for ( int first_score=1; first_score<=N; first_score++ ) {
        score = first_score;
        tmp_ans = (double) 1 / N;
        while ( score < K ) {
            tmp_ans /= 2;
            score *= 2;
        }
        ans += tmp_ans;
    }

    printf("%.10lf\n", ans);
    return 0;
}


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

const int N = 1e5 + 7, INF = 0x3f3f3f3f;

int arr[N], dp[N];

int main() {
        int n, k; cin >> n >> k;
        for(int i = 1; i <= n; i++) {
                cin >> arr[i];
        }
        memset(dp, 0x3f, sizeof dp);
        dp[1] = 0;
        for(int i = 2; i <= n; i++) {
                for(int j = 1; j <= k && i - j > 0; j++) {
                        dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
                }
        }
        cout << dp[n] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

const int MOD = 1e9 + 7;

int add(int a, int b) {
	return (a + b) % MOD;
}

int mul(int a, int b) {
	return (a * b) % MOD;
}

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

    string str1;
    cin >> str1;

    for(int i=0; i<3; i++){
        if(str1[i] == '7'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <set>

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

    std::set<int> diameters;
    for (int i = 0; i < N; i ++) {
        int d;
        std::cin >> d;
        diameters.insert(d);
    }
    std::cout << diameters.size() << std::endl;
}


Measured memory_bytes: 256
/*input
3
10 2 5
6 3 4
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int x[maxn],y[maxn];
int main(){
	IOS;
	int n;
	cin>>n;
	ll ans=0;
	REP(i,n) cin>>x[i];
	REP(i,n) cin>>y[i];
	REP(i,n){
		ans+=max(x[i]-y[i],0);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	res := 0
	for i := 0; i < n; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if tmp >= k {
			res++
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 5504
import java.util.*;

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

    int s = sc.nextInt();
    int w = sc.nextInt();
    String ans = "safe";

    if(s <= w){
      ans = "unsafe";
    }

    System.out.println(ans);
  }
}


Measured memory_bytes: 35736
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
using namespace std;
int main(){
    int n,cost=INT_MAX,comp=0,ans;
    bool f = true;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i] +=100;
    }
    sort(a,a+n);
    int k=1;
    while(k<n){
        if(a[k]!=a[k-1]){
            f=false;
            break;
        }
        k++;
    }
    if(f){
        cout << "0" << endl;
        return 0;
    }
    ans = a[n-1];
    for(int i=0;i < ans;i++){
        comp = 0;
        for(int j=0;j<n;j++){
            comp+=pow(a[j]-i,2);
        }
        if(comp < cost)cost = comp;
    }
    cout << cost << endl;

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: usize = sc.read();
    let v:Vec<i32> = (0..n).map(|_| sc.read()).collect();
    for (i,v) in v.into_iter().rev().enumerate() {
        print!("{}{}", v, if i==n-1 { '\n'} else {' '});
    }

}


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

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

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

int main(void){

    int n;
    cin >> n;
    vector<int> x(n);
    roop(i, n) cin >> x[i];

    vector<int> y = x;
    sort(y.begin(), y.end());
    int border = y[n/2];

    roop(i, n){
        if(x[i] < border) cout << y[n/2] << endl;
        else cout << y[n/2-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<(a!=c)<<endl;
}

Measured memory_bytes: 256