akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#define rep(i,o,u) for(int i = o;i < u; i++)
using namespace std;
struct node{
	node (string name,int time):name(name),time(time){}
	string name;
	int time;
};
queue <node> q;
int main(){
	int n,m;
	cin >> n >> m;
	while(n--){
		string s;int a;
		cin >> s >> a; 
		q.push(node(s,a));
	}
	int t = 0;
	while(!q.empty()){
		if(q.front().time <= m){
			t += q.front().time;
			cout << q.front().name << " " <<t << endl;
			q.pop();
		}else{
			t += m;
			node k = q.front();
			q.pop();
			q.push(node(k.name,k.time-m));
		}
	}
	return 0;
}

Measured memory_bytes: 6176
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (L, R): (i64, i64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };

    let ans = (L..std::cmp::min(L + 2019, R))
        .map(|l| {
            ((l + 1)..std::cmp::min(l + 2019, R + 1))
                .map(|r| (l * r) % 2019)
                .min()
                .unwrap()
        })
        .min()
        .unwrap();

    println!("{}", ans);
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n = 1407;
int k = 38;

//int n = 31;
//int k = 6;

//int n = 13;
//int k = 4;

int a[2000][50];
set<int> se[2000];
int cnt[2000];

int main() {
    forn(i, k) a[0][i] = i;
    int r = 1;
    forn(i, k) forn(j, k - 1) {
        a[r++][0] = i;
    }
    int from = k;
    forn(i, k - 1) {
        forn(j, k - 1) a[i + 1][j + 1] = from + j;
        forn(j, k) {
            int pos = (i * j) % (k - 1);
            forn(p, k - 1) {
                a[k + j * (k - 1) + (pos + p) % (k - 1)][i + 1] = from + p;
            }
        }
        from += k - 1;
    }
    printf("%d %d\n", n, k);
    forn(i, n) {
        forn(j, k) printf("%d ", a[i][j] + 1);
        puts("");
    }
//    forn(i, n) {
//        forn(j, k) {
//            assert(a[i][j] >= 0 && a[i][j] < n);
//            if (se[i].count(a[i][j])) {
//                cerr << "!" << endl;
//                return 0;
//            }
//            se[i].insert(a[i][j]);
//        }
//    }
//    forn(i, n) forn(j, k) ++cnt[a[i][j]];
//    forn(i, n) if (cnt[i] != k) {
//        cerr << "?" << endl;
//        return 0;
//    }
    return 0;
}


Measured memory_bytes: 896
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long h = scanner.nextInt(), w = scanner.nextInt();
        long size1, size2, size3, ans = Integer.MAX_VALUE;

        for (int i = 0; i < 2; i++) {
            for (int j = 1; j < h; j++) {
                size1 = j * w;
                size2 = (h - j) * (w / 2);
                size3 = (h - j) * (w - (w / 2));
                ans = Math.min(ans, Math.max(Math.max(size1, size2), size3) - Math.min(Math.min(size1, size2), size3));

                size2 = (h - j) / 2 * w;
                size3 = (h - j - ((h - j) / 2)) * w;
                ans = Math.min(ans, Math.max(Math.max(size1, size2), size3) - Math.min(Math.min(size1, size2), size3));
            }

            long t = w;
            w = h;
            h = t;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
s={input() for _ in range(int(input()))}
k=False
t=[input() for _ in range(int(input()))]
for i in t:
  if i in s:
    k=not k
    if k:
      print("Opened by",i)
    else:
      print("Closed by",i)
  else:
    print("Unknown",i)


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

int main(){
    string s;
    cin >> s;
    int len = s.size();
    string str = s.substr(0,1);
    for (int i = 2; i < len; i += 2){
        str += s.substr(i,1);
    }
    cout << str << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
typedef vector<int> vi; 
typedef pair<int,int> pi;
typedef long long ll;
#define F first 
#define S second 
#define PB push_back 
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)

ll h,w;

vector< vector<ll> > dp;
vector< vector<bool> > can;
vector< vector<bool> > evaluate;

ll m = 1000000007;

ll suma(ll a, ll b){
	
	return ( (a%m) + (b%m) )%m;
	
}

void see(ll x, ll y){
	
	evaluate[x][y] = true;
	
	if(x < h - 1 ){
		
		if( can[x+1][y] ){
			
			if(!evaluate[x+1][y]) see(x+1,y);
			
			dp[x][y] = suma( dp[x][y], dp[x+1][y] );
		} 
		
	}
	
	if(y < w - 1 ){
		
		if( can[x][y+1] ){
			
			if(!evaluate[x][y+1]) see(x,y+1);
			
			dp[x][y] = suma( dp[x][y], dp[x][y+1] );
		} 
		
	}
	
}

int main(){
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	cin >> h >> w;
	
	can.assign( h, vector<bool>(w, 0) );
	dp.assign( h, vector<ll>(w,0) );
	evaluate.assign( h, vector<bool>(w,0) );
	
	evaluate[h-1][w-1] = 1;
	dp[h-1][w-1] = 1;
	char c;
	
	for(ll i = 0; i < h; i++){
		
		for(ll i2 = 0; i2 < w; i2++ ){
			
			cin >> c;
			
			can[i][i2] = ( c == '.' );
			
		}
		
	}
	
	see(0,0);
	
	cout << dp[0][0] << endl;
	 	
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int D;
  cin>>D;
  vector<int> c(26);
  for(int &i:c)
    cin>>i;
  vector<vector<int>> s(D,vector<int>(26));
  for(vector<int> &v:s)
    for(int &i:v)
      cin>>i;
  vector<int> t(D);
  vector<int> A(26,0);
  int mzint=0;
  for(int i=0;i<D;i++){
    int mzi=mzint,mzin=0,k;
    for(int j=0;j<26;j++)
      mzi-=(i+1-A[j])*c[j];
    for(int j=0;j<26;j++){
      int l=mzi+s[i][j]-(i+1-A[j])*c[j];
      if(l>mzin){
        k=j;
        mzin=l;
      }
    }
    A[k]=i+1;
    mzint=mzin;
    t[i]=k+1;
  }
  int M=100000,ans=mzint;
  while(M--){
    vector<pair<int,int>> AAA={make_pair(rand()%D,rand()%26),make_pair(rand()%D,rand()%26)};
    vector<int> BBB={t[AAA[0].first],t[AAA[1].first]};
    int ans2=ans;
    for(int aaa=0;aaa<2;aaa++){
    int d=AAA[aaa].first,q=AAA[aaa].second;
    ans+=s[d][q]-s[d][t[d]-1];
    int mae=-1,ato=D;
    for(int i=d-1;i>=0;i--){
      if(t[i]==t[d]){
        mae=i;
        break;
      }
    }
    for(int i=d+1;i<D;i++){
      if(t[i]==t[d]){
        ato=i;
        break;
      }
    }
    ans-=(ato-d)*(d-mae)*c[t[d]-1];
    mae=-1,ato=D;
    for(int i=d;i>=0;i--){
      if(t[i]==q+1){
        mae=i;
        break;
      }
    }
    for(int i=d;i<D;i++){
      if(t[i]==q+1){
        ato=i;
        break;
      }
    }
    ans+=(ato-d)*(d-mae)*c[q];
    t[d]=q+1;
    }
    if(ans2>ans){
      ans=ans2;
      t[AAA[0].first]=BBB[0];
      t[AAA[1].first]=BBB[1];
    }
  }
  for(int i:t)
    cout<<i<<endl;
}

Measured memory_bytes: 3700
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

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

const int MOD = 1e9+7;
class mint {
    ll x;
public:
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    
    mint operator -() const {
        return mint(-x);
    }
    
    mint &operator +=(const mint &a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator -=(const mint &a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }

    mint &operator *=(const mint &a) {
        (x *= a.x) %= MOD;
        return *this;
    }

    mint operator +(const mint &a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint &a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator *(const mint &a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(MOD - 2);
    }

    mint &operator /=(const mint &a) {
        return (*this) *= a.inv();
    }

    mint operator /(const mint &a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream &operator<<(ostream& os, const mint &m) {
        os << m.x;
        return os;
    }
};


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

    ll N;
    string S;
    cin >> N >> S;

    ll tmp = 0;
    vec a(2*N, 0);
    Rep (i, 2*N) {
        if (S[i] == 'B' and tmp % 2 == 0 or S[i] == 'W' and tmp % 2 == 1) {
            a[i] = 1;
            tmp++;
        } else {
            a[i] = -1;
            tmp++;
        }
    }

    // // Rep (i, 2*N) {
    //     cout << a[i] << " \n"[i==2*N-1];
    // }

    mint ans(1);

    tmp = 0;
    Rep (i, 2*N) {
        if (a[i] == 1) {
            tmp++;
        } else {
            ans *= tmp;
            tmp--;
        }
    }

    if (tmp) ans *= 0;

    Rep (i, N) {
        ans *= i+1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 2196
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1e9, MOD = 1e9 + 7, MOD2 = 1e6 + 3;

string s;

int n, k;

string process (string s) {

	if (k == 1) return s;
	int l;
	for (l = 1; l <= n && s[n - l] == s.back (); l++);
	l--;
	
	ll p;

	if (k - 1 >= 13) p = n;
	else p = min ((1 << (k - 1)) * l, n);

	string t;

	for (int i = p - l; i < n; i++)
		t += s[i];

	for (int i = 0; i < p - l; i++)
		t += s.back ();

	reverse (t.begin(), t.end());

	return t;
}

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

	cin >> s;

	string best = s;

	string rev_s = s;

	reverse (rev_s.begin(), rev_s.end());

	s = s + rev_s;

	for (int i = 0; i <= s.size () / 2; i++)
	{
		//cout << s.substr (i, s.size () / 2) << ' ' << process (s.substr (i, s.size () / 2)) << endl;
		best = min (process (s.substr (i, s.size () / 2)), best);
	}

	cout << best;
}

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

using namespace std;

typedef long long ll;

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

	int N, X;
	cin >> N >> X;

	vector<int> L(N);
	rep(i, N) cin >> L[i];

	int ans = 0;
	int d = 0;
	for(int i = 0; i < N; i++){
		if(d <= X) {
			ans++;
		}else{
			break;
		}
		d += L[i];
	}

	if(d <= X) ans++;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 500005;
const int MOD = 998244353;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

namespace ModCalculator {
	inline void Inc(int &x, int y) {
		x += y; if (x >= MOD) x -= MOD;
	}
	inline void Dec(int &x, int y) {
		x -= y; if (x < 0) x += MOD;
	}
	inline int Add(int x, int y) {
		Inc(x, y); return x;
	}
	inline int Sub(int x, int y) {
		Dec(x, y); return x;
	}
	inline int Mul(int x, int y) {
		return 1LL * x * y % MOD;
	}
}
using namespace ModCalculator;

inline int ksm(int x, int k) {
	int ret = 1;
	for (; k; k >>= 1) {
		if (k & 1) ret = Mul(ret, x);
		x = Mul(x, x);
	}
	return ret;
}

int n, k;
int fac[MAXN], finv[MAXN];

inline int C(int x, int y) {
    if (x < y) return 0;
	return Mul(fac[x], Mul(finv[y], finv[x - y]));
}

void init() {
	read(n); read(k);
	fac[0] = 1;
	for (int i = 1; i <= k; ++i) {
		fac[i] = Mul(fac[i - 1], i);
	}
	finv[k] = ksm(fac[k], MOD - 2);
	for (int i = k; i >= 1; --i) {
		finv[i - 1] = Mul(finv[i], i);
	}
}

void solve() {
	if (k < n) {
        printf("0\n");
        return;
	}
	int ans = 0;
	for (int R = max((k + 1) / 2, n), B; R <= k; ++R) {
        B = k - R;
        if (R == B) --B;
        Inc(ans, C(R + B, R));
        if (R - B < n) {
            Dec(ans, C(R + B, R * 2 - n + 1));
        }
	}
	printf("%d\n", ans);
}

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



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

int main(){
    int n;
    cin >> n;
    long val[100004][3];
    long dp[100004][3];
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            cin >> val[i][j];
        }
    }
    for(int i=0;i<3;i++)
        dp[0][i]= val[0][i];

    for(int i=1;i<n;i++){
        dp[i][0]= max(dp[i-1][1],dp[i-1][2])+val[i][0];
        dp[i][1]= max(dp[i-1][0],dp[i-1][2])+val[i][1];
        dp[i][2]= max(dp[i-1][1],dp[i-1][0])+val[i][2];
    }
    cout << max(dp[n-1][0], max(dp[n-1][1],dp[n-1][2]));
    return 0;
}

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

namespace ABC140A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            Console.WriteLine(N * N * N);




            Console.ReadKey();
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int h, w; cin >> h >> w;
    char s[h][w];
    bool b[h][w];
    memset(b, 0, sizeof(b));
    rep(i,h) {
        rep(j,w) {
            char c;
            cin >> c;
            s[i][j] = c;
            if (c == '.')
                b[i][j] = 1;
        }
    }

    int nxa[4] = { 0, 1, 0, -1};
    int nya[4] = { 1, 0, -1, 0};
    rep(i,h) {
        rep(j,w) {
            if (s[i][j] == '#') {
                for(int ii = 0; ii < 4; ii++) {
                    int nx = i + nxa[ii];
                    int ny = j + nya[ii];
                    if (nx<0||nx>=h||ny<0||ny>=w)
                        continue;
                    if (s[nx][ny] == '#')
                        b[i][j] = 1;
                }
            }
        }
    }
    rep(i,h) {
        rep(j,w) {
            if (b[i][j] == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
from functools import reduce

def lcm(x, y):
  g = gcd(x, y)
  x //= g
  y //= g
  if x&y&1:
    l = x*y*g
    if l > 10**9:
      return 0
    return l
  return 0
n, m = map(int, input().split())
A = list(map(lambda x: int(x)//2, input().split()))
k = reduce(lcm, A)
if k == 0:
  print(0)
else:
  print(((m//k)+1)//2)

Measured memory_bytes: 16236
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    M=a[end]
    half=a[div(n,2)]
    for i in 1:n-1
        if abs(div(M,2)-half)>=abs(div(M,2)-a[i])
            half=a[i]
        end
    end
    println("$M $half")
end
main()

Measured memory_bytes: 121092
#include<iostream>
using namespace std;
int main(){
  int t=0,bell=0,hess=0,number[100]={0};
  while(cin >> bell){
    t++;
    number[bell]++;
  }
  for(int i=0;i<t;i++){
    if(number[i]>hess){
      hess=number[i];
    }
  }
  for(int i=0;i<t;i++){
    if(number[i]>=hess){
      cout << i << endl;
    }
  }
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if(s.back() == 's') {
        s.push_back('e');
        s.push_back('s');
    }
    else {
        s.push_back('s');
    }
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int A, B;
  cin >> A >> B;
  if(A >= 10 || B >= 10) {
    cout << -1; return 0;
  }
  cout << A * B;
  return 0;
}


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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<int> s;
    for (int i = n - 1; i >= 0; i--) {
        int idx = upper_bound(s.begin(), s.end(), a[i]) - s.begin();
        if (idx == s.size()) {
            s.push_back(a[i]);
        } else {
            s[idx] = a[i];
        }
    }
    cout << s.size() << "\n";
    return 0;
}


Measured memory_bytes: 1276
from copy import deepcopy

h, w = map(int, input().split())
c = []
for i in range(10):
    c.append(list(map(int, input().split())))

a = []
for i in range(h):
    a.append(list(map(int, input().split())))

d = deepcopy(c)

for k in range(10):
    for i in range(10):
        for j in range(10):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 0

for i in range(h):
    for j in range(w):
        if a[i][j] != -1:
            ans += d[a[i][j]][1]

print(ans)

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
#include <bitset>

using namespace std;

int main(){
    int c[3][3];

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++) cin >> c[i][j];
    }

    
    int cnt = 0;
    while(cnt < 3){
        if( (c[cnt][0] != 0 && c[cnt][1] != 0) && c[cnt][2] !=  0 ){
            c[cnt][0]--;
            c[cnt][1]--;
            c[cnt][2]--;
        }else{
            cnt++;
        }
    }


    bool flag = true;
    for(int i = 0; i < 3; i++){
        if(c[0][i] != c[1][i] || c[0][i] != c[2][i]){
            flag = false;
            break;
        }
    }

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


    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String ans = "";
        for(int i = 0; i < line.length(); i++) {
            char s = line.charAt(i);
            String str = String.valueOf(s);
            if(Character.isUpperCase(s)) {
                ans += str.toLowerCase();
            }else if(Character.isLowerCase(s)) {
                ans += str.toUpperCase();
            }else {
                ans += str;
            }
        }
        System.out.println(ans);
    }
 }


Measured memory_bytes: 31888
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  int N;
  cin>>N;
  std::vector<int> a(N*3);
  for(int i=0;i<N*3;i++)cin>>a[i];
  priority_queue<int> que;
  int mx=0;
  for(int i=0;i<N;i++){
    que.push(a[i]*(-1));
    mx-=a[i];
  }
  std::vector<int> v(N+1);
  for(int i=0;i<N;i++){
    v[i]=mx;
    que.push(a[N+i]*(-1));
    mx-=a[N+i];
    mx-=que.top();que.pop();
  }
  v[N]=mx;

  priority_queue<int> que2;
  int mx2=0;
  for(int i=0;i<N;i++){
    que2.push(a[3*N-1-i]);
    mx2+=a[3*N-1-i];
  }
  std::vector<int> v2(N+1);
  for(int i=0;i<N;i++){
    v2[i]=mx2;
    que2.push(a[2*N-1-i]);
    mx2+=a[2*N-1-i];
    mx2-=que2.top();que2.pop();
  }
  v2[N]=mx2;
  int ans=-1e18;
  for(int i=0;i<N+1;i++)ans=max(ans,-v[i]-v2[N-i]);//cout<<v[i]<<" "<<v2[N-i]<<endl;}
  cout<<ans<<endl;
}


Measured memory_bytes: 5876
n=gets.to_i
s=gets
ans=0
n.times{|l|
  a=Hash.new(0)
  for i in 0..l do
    a[s[i].ord-'a'.ord]=1
  end
  b=Hash.new(0)
  for i in l+1..n do
    b[s[i].ord-'a'.ord]=1
  end
  tans=0
  a.each{|k,v|
    tans+=1 if b[k]==1
  }
  ans=[ans,tans].max
}
p ans

Measured memory_bytes: 1916
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;
/* typedef */
typedef long long ll;
/* constant */
/* global variables */
/* function */
ll extGCD(ll a, ll b, ll& x, ll& y) {
    /*
    (q = a/b, r = a%b, d = gcd(a, b) = gcd(b, a % b))
        ax + by = d -- 1
        bx' + ry' = d -- 2
        # a = qb + r
        -> 1
        (qb + r)x + by = d
        <=>
        b(qx + y) + rx = d -- 1
        bx' + ry' = d -- 2
        x = y'
        y = x' - qx
    */
    if (b == 0) {
        // dx + 0y = d
        x = 1; y = 0;
        return a;
    }
    // x = y'
    // y = x' - qx
    ll g = extGCD(b, a%b, y, x);
    y -= (a/b) * x;
    return g;
}

/* main */
int main() {
    /*
        Given positive integers a and b,
        find the integer solution (x, y) to ax+by=gcd(a,b)
    */
    ll a, b, x, y;
    cin >> a >> b;
    extGCD(a, b, x, y);
    cout << x << ' ' << y << '\n';

}



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

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

ll ans = 0;
ll n;
void dfs(ll x, bool three, bool five, bool seven){
    if(x > n){
        return;
    }
    if(three and five and seven){
        ans++;
    }
    dfs(10*x+3, true, five, seven);
    dfs(10*x+5, three, true, seven);
    dfs(10*x+7, three, five, true);
}

int main(){
    cin>>n;
    dfs(0, false, false, false);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    var str = readLine()!!.toString()
    val q = readLine()!!.toInt()

    (0 until q).forEach { _ ->
        val command = readLine()!!.toString().split(" ")
        val operation = command[0]
        val a = command[1].toInt()
        val b = command[2].toInt()
        val s = str.slice(0 until a)
        val m = str.slice(a..b)
        val e = str.slice(b + 1 until str.length)
        when (operation) {
            "print" -> println(m)
            "reverse" -> str = s + m.reversed() + e
            "replace" -> str = s + command[3] + e
        }
    }
}


Measured memory_bytes: 33780
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n;
  cin >>n;
  int p[n];
  for(int i=0; i<n; i++) cin >>p[i];

  sort(p, p+n);
  p[n-1]=p[n-1]/2;
  int ans=0;
  for(int i=0; i<n; i++) ans+=p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int ans = 0;
  if(a == b && a != c) ans = 1;
  if(b == c && b != a) ans = 1;
  if(c == a && c != b) ans = 1;

  if(ans) Yes;
  else No;

  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))
ans, k = 0, 0
for i in range(40)[::-1]:
    b = 1 << i
    c = sum(bool(a & b) for a in A)
    if k + b <= K and c < N - c:
        k += b
        ans += b * (N - c)
    else:
        ans +=  b * c
print(ans)

Measured memory_bytes: 14620
/*
                                Bismillahi-r-Rahmani-r-Rahim
                                        RhIeyAaD
                                    IIT-7th Batch,JU
*/
#include<bits/stdc++.h>
using namespace std;

#define ll              long long int
#define MAX             2134567891
#define fr(i,n)         for(i=0;i<n;i++)
#define rep(i,n)        for(i=1;i<=n;i++)
#define rev(i,a,n)      for(i=n;i>=a;i--)
#define FOR(i,a,n)      for(i=a;i<=n;i++)
#define ALL(n)          n.begin(),n.end()
#define mem(x,n)        memset(x,n,sizeof(x))
#define TC(t)           printf("Case %lld: ",t)
#define ans(t,c)        printf("Case %lld: %lld\n",t,c)
#define SETP(n)         cout<<setprecision(n)<<fixed
#define READ            freopen("F:\\Project\\Test_Case.txt","r",stdin)
#define WRITE           freopen("F:\\Project\\Output_Test.txt","w",stdout)
#define IO              ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
#define PAIR            pair<ll,ll>
#define MP              make_pair
#define pb(a)           push_back(a)
#define ff              first
#define ss              second
#define NL              print("\n");
#define debug(a)        cout<<a<<" ";
#define hlw             printf("hlw\n");
#define NN              111
#define MOD             1000000007///10^9
#define N               1000007 ///10^6->6 zero after 1 **

ll x[N],y[N],z[N],n;
string s,S;
vector<ll>v;
//map <ll,ll> mp;

int main()
{
    //IO;
    //while(1)
    //READ;WRITE;
{
    ll a=0,b=0,c=0,d,e,f,g,i,j,k,l,m,p,q,r,u,w,t,tc,in,mod,loc,diff,val,sz,lo,hi,mid,mn=MAX,mx=0,sum=0,ans=0;
    cin>>n>>m;
    rep(i,n)
    {
        cin>>x[i];
        //mn=min(mn,x[i]);
        sum+=x[i];
    }
    sort(x+1,x+n+1,greater<int>());
    mn=x[m];
    if(4*m*mn>=sum)cout<<"Yes\n";
    else cout<<"No\n";
}
    return 0;
}

/*

*/
/// Check for constraint 0 or 1?
/// long long or double? sqrt or division will work fine??


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

int main() {
  long long n,cnt=0;
  cin >> n;
  vector<long long> a(n);
  for(long long i=0;i<n;i++){
    cin >> a.at(i);
    a.at(i) -= i+1;
  }
  sort(a.begin(),a.end());
  long long b = a.at(n/2);
  long long ans =0;
  for(long long i=0;i<n;i++){
    ans += max(a.at(i)-b,b-a.at(i));
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	retur5n a * (b / g);
}*/

int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

int main() {
	int r, D, x;
	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = r * x - D;
		cout << x << endl;
	}
}

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

int main(){
    int N;
    cin >> N;
    int p[N]={};
    int min,max =0;
    cin >> p[0];
    int flag =0;
    int memory1,memory2 = 0;
    for(int i = 1;i<N;i++){
        cin >> p[i];
        if(p[i-1]>p[i]){
            if(flag == 0){
                max = p[i-1];
                memory1 = i-1;
                flag = 1;
            }
            if(flag == 1){
                min = p[i];
                memory2 = i;
            }
            
        }

    }
    p[memory1] = min;
    p[memory2] = max;

    int count;
    for(int j =0;j<N-1;j++){
        if(p[j]>p[j+1]){
            count ++;
        }
    }

    if(count !=0){
        cout << "NO";
    }else {
        cout << "YES";
    }

}

Measured memory_bytes: 256
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

s,w=map(int,input().split())
if s<=w:
    print("unsafe")
else:
    print("safe")

Measured memory_bytes: 68268
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m, k;
    while (cin >> n >> m >> k) {
        vector<string> mat(n);
        for (auto& row: mat) {
            cin >> row;
        }
        int ans = 0, tot = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                tot += (mat[i][j] == '#');
            }
        }
        for (int i = 0; i < (1 << n); i++) {
            for (int j = 0; j < (1 << m); j++) {
                int cnt = 0;
                for (int ii = 0; ii < n; ii++) {
                    for (int jj = 0; jj < m; jj++) {
                        if ((i >> ii & 1) || (j >> jj & 1)) {
                            cnt += (mat[ii][jj] == '#');
                        }
                    }
                }
                ans += (tot - cnt == k);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Pair> rl = new ArrayList<Pair>();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            rl.add(new Pair(b, a));
        }
        Collections.sort(rl);
        int ans = 0;
        int start = 0;
        for (Pair p : rl) {
            if (p.second >= start) {
                ans++;
                start = p.first;
            }
        }
        System.out.println(ans);
    }
}
class Pair implements Comparable<Pair> {
    int first;
    int second;
    public Pair(int i, int j) {
        this.first = i;
        this.second = j;
    }
    public int compareTo(Pair p) {
        if (this.first < p.first) return -1;
        else if (this.first > p.first) return 1;
        else {
            if (this.second < p.second) return -1;
            else if (this.second > p.second) return 1;
            else return 0;
        }
    }
}

Measured memory_bytes: 87748
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

ll p(ll x){
    ll cnt=0;
    ll sum=0;
    while(x!=-1){
        sum+=cnt;
        cnt++;
        x--;
    }
    return sum;
}

int main(){
    string s; cin>>s;
    ll n=s.size();
    ll cnt1=0,cnt2=0,ans=0;
    ll j=0;
    while(s[j]=='>'){
        j++;
    }
    ans+=p(j);
    for(int i=j;i<n;i++){
        cnt1=0,cnt2=0;
        while(s[i]=='<'){
            cnt1++;
            i++;
        }
        while(s[i]=='>'){
            cnt2++;
            i++;
        }
        ans+=p(cnt1)+p(cnt2);
        ans-=min(cnt1,cnt2);
        i--;
        }
        cout<<ans<<endl;

    }

















































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

using namespace std;

int main()
{
	int time[5], loss[5], best = 0;
	
	for (int i = 0; i < 5; i++) {
		cin >> time[i];
	}
	
	for (int i = 0; i < 5; i++) {
		if (time[i] % 10) {
			loss[i] = 10 - time[i] % 10;
		}
		else {
			loss[i] = 0;
		}
	}
	
	for (int i = 4; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (loss[j] > loss[j + 1]) {
				int tmp = loss[j];
				loss[j] = loss[j + 1];
				loss[j + 1] = tmp;
				
				tmp = time[j];
				time[j] = time[j + 1];
				time[j + 1] = tmp;
			}
		}
	}
	
	for (int i = 0; i < 5; i++) {
		best += (time[i] + loss[i]);
	}
	
	best -= loss[4];
	
	cout << best << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ちゃんとユニークな配列にする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

int main() {
  int N, M;
  cin >> N >> M;
  int correct = N - M;
  int fac = (int)pow(2.0, M);
  // DEBUG(fac);
  int result = ((100 * correct) + (1900 * M)) * fac;
  cout << result << endl;
}


Measured memory_bytes: 256
import Data.Functor
import Data.List

main :: IO ()
main = do
  _ <- getLine
  as <-  map read . words <$> getLine :: IO [Int]
  putStrLn . unwords . map show . sort $ as
  print $ solve as

solve :: (Ord a) => [a] -> Int
solve as = go 0 as
  where go n (a:[]) = n
        go n (a:as) = if m < a then go (n + 1) rep
                      else go n rep
          where m = minimum as
                --rep = reverse . replaceFirst m a . reverse $ as
                rep = replaceFirst m a as

replaceFirst :: (Eq a) => a -> a -> [a] -> [a]
replaceFirst _ _ [] = []
replaceFirst a b (l:ls)
  | a == l = b:ls
  | otherwise = l:replaceFirst a b ls



Measured memory_bytes: 4092
#include<iostream>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define N 100010
class Segtree{
  public:
  ll dat[2*N];
  void init(){
    for(int i=0;i<2*N;i++)dat[i]=0;
  }
  void upd(ll i,ll val){
    i+=N; dat[i]=val;
    for(;i;i>>=1)dat[i/2]=max(dat[i],dat[i^1]);
  }
  ll qry(ll l,ll r){
    l+=N,r+=N;
    ll res=0;
    for(ll a=l,b=r;a<b;a>>=1,b>>=1){
      if(a&1)res=max(res,dat[a++]);
      if(b&1)res=max(res,dat[--b]);
    }
    return res;
  }
};Segtree seg;
ll n,a[N],b[N];
vector<P> v;
void zaats(){
  for(int i=0;i<n;i++)v.push_back(make_pair(a[i],i));
  sort(v.begin(),v.end());
  for(int i=0;i<n;i++)b[v[i].second]=i;
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  zaats();
  seg.init();
  for(int i=0;i<n;i++){
    seg.upd(b[i],seg.qry(0,b[i])+a[i]);
  }
  ll sum=0;
  for(int i=0;i<n;i++)sum+=a[i];
  cout<<sum-seg.qry(0,n)<<endl;
    return 0;
}



Measured memory_bytes: 7536
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<numeric>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  map<int, int> f;
  ll ans = 0;
  for(int i = 0; i < n; ++i){
    cin >> a[i];
    ans += f[-a[i] + i + 1];
    ++f[a[i] + i + 1];
  }

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


Measured memory_bytes: 21208
import java.util.*;

public class Main {
    final static int MOD = 1000000007;
    
    public static void main(String[] args) {
        MyScanner in = new MyScanner();
        long n = in.nextLong();
        long a = Long.MAX_VALUE;
        
        
        for (long i = 1; i * i <= n ; i++) {
            if (n % i == 0) {
                a = Math.min(a, (i + (n / i)));
            }
        }
    
        System.out.println(a-2);
        
    }
    
    static class MyScanner {
        static Scanner sc = new Scanner(System.in);
        
        String next() {
            return sc.next();
        }
        
        String nextLine() {
            return sc.nextLine();
        }
        
        int nextInt() {
            return Integer.parseInt(sc.next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        int[] nextIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextInt();
            }
            return array;
        }
        
        double[] nextDoubleArray(int n) {
            double[] array = new double[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextDouble();
            }
            return array;
        }
        
        long[] nextLongArray(int n) {
            long[] array = new long[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLong();
            }
            return array;
        }
        
        String[] nextLineArray(int n) {
            String[] array = new String[n];
            for (int i = 0; i < n; i++) {
                array[i] = nextLine();
            }
            return array;
        }
        
        int[][] nextIntMatrix(int n, int m) {
            int[][] matrix = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextInt();
                }
            }
            return matrix;
        }
        
        double[][] nextDoubleMatrix(int n, int m) {
            double[][] matrix = new double[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextDouble();
                }
            }
            return matrix;
        }
        
        long[][] nextLongMatrix(int n, int m) {
            long[][] matrix = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    matrix[i][j] = nextLong();
                }
            }
            return matrix;
        }
    }
}

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

using namespace std;

const int MaxN = 100005;
const int oo = 1e9;

int n;
int h[MaxN], dp[MaxN];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> h[i];
        dp[i] = oo;
    }
    dp[1] = 0;
    for (int i = 1; i < n; i++)
    {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }
    cout << dp[n];
    return 0;
}

Measured memory_bytes: 4404
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC085B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;

            var d = new int[N];
            for (int i = 0; i < N; i++)
            {
                d[i] = ReadInt;
            }

            int ans = d.Distinct().Count();
            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
H, W, h, w = map(int, input().split())

if h == w == 1 :
  print('No')

else :
  a = (10 ** 9 - 1) // (h * w - 1)
  ret = [[a] * W for _ in range(H)]
  for y in range(h - 1, H, h) :
    for x in range(w - 1, W, w) :
      ret[y][x] = - a * (h * w - 1) - 1

  s = 0
  for y in range(H) :
    s += sum(ret[y])
    
  if s > 0 :
    print('Yes')
    for r in ret :
      print(*r)
  else :
    print('No')

Measured memory_bytes: 49372
import collections
N=int(input())
D=list(map(int,input().split()))
l=[]
c=collections.Counter(D)
values=list(c.values())	#aのCollectionのvalue値のリスト(n_1こ、n_2こ…)
key=list(c.keys())	#先のvalue値に相当する要素のリスト(要素1,要素2,…)
p=998244353
cnt=1
for i in range(len(key)):
    l.append([key[i],values[i]])#lは[要素i,n_i]の情報を詰めたmatrix
#print(l)
if (c[0]==1)and(D[0]==0):
    for i in range(N-1):
        cnt=cnt*pow(c[i],c[i+1],p)
    print(cnt%p)
else:
    print("0")

Measured memory_bytes: 76596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=998244353;

int main(){
    int n,m;cin>>n>>m;
    string s;cin>>s;
    multiset<pair<int,int>> minimum;
    vin dp(n+1,inf),before(n+1,inf);dp[0]=0;
    rep2(i,1,min(n,m)+1){
        if(s[i]=='0'){
            dp[i]=1;
            before[i]=0;
        }
        minimum.insert(mp(dp[i],i));
    }
    int tmp;
    rep2(i,m+1,n+1){
        if(s[i]=='0'){
            tmp=(*minimum.begin()).first;
            if(tmp!=inf)tmp++;
            dp[i]=tmp;
            before[i]=(*minimum.begin()).second;
        }
        minimum.erase(minimum.find(mp(dp[i-m],i-m)));
        minimum.insert(mp(dp[i],i));
    }
    if(dp[n]==inf){
        cout<<-1<<endl;
        return 0;
    }
    stack<int> ans;
    tmp=n;
    while(tmp){
        ans.push(tmp-before[tmp]);
        tmp=before[tmp];
    }
    while(ans.size()>1){
        cout<<ans.top()<<" ";
        ans.pop();
    }
    cout<<ans.top()<<endl;
}

Measured memory_bytes: 8804
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
#include<string>
#include<iomanip>
#include<map>
#include<fstream>
#include<queue>
#include<stack>

using namespace std;

int main()
{
	int n, m, x;
	int a[101] = {};
	int res1=0,res2=0;
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		int t;
		cin >> t;
		a[t]++;
	}
	for (int i = x - 1; i >= 0; i--) {
		if (a[i])
			res1++;
	}
	for (int i = x + 1; i <= n; i++) {
		if (a[i])
			res2++;
	}
	cout << min(res1, res2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main(){
#ifdef CIN
	ifstream cin("input.txt");
	ofstream cout("output.txt");
#endif

	int a, b, c;
	int i;

	cin >> a >> b >> c;


	if (a > b)
	{
		a ^= b ^= a ^= b;
	}


	if (b > c)
	{
		b ^= c ^= b ^= c;

	}
	if (a > b)
	{
		a ^= b ^= a ^= b;
	}



	cout << a << " " << b << " " << c << endl;



	return 0;
}

Measured memory_bytes: 1164
// Author : Mahmoud Tarek

#include <bits/stdc++.h>

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define debug(x , y) cerr << #x << " = " << x << y ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n ;
vector < int > a ;

int main(){
 cin >> n ;
 a.resize( 2 * n ) ;
 forn( int , i , 0 , 2*  n ){
   cin >> a[ i ] ;
 }
 sort( all( a ) ) ;
 int ans = 0 ;
 forn( int , i , 0 , n * 2 ){
   ans += a[ i ] ;
   i++ ;
 }
 cout << ans ;
 return 0 ;
}


Measured memory_bytes: 256