akhauriyash/Code-Regression huggingface dataset:
import static java.lang.System.out;
import java.util.Scanner;
import java.util.Arrays;

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

      out.println(Math.min(A*T, B));
   }
}

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

public class Main {

	private static List<Long> getStrings(Scanner sc, long num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			long nextInt = sc.nextLong();
			stringList.add(nextInt);
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long k = sc.nextLong();
		long n = sc.nextLong();
		List<Long> as = getStrings(sc, n);
		long sum = 0;
		for (int i = 1; i < as.size(); i++) {
			sum+=as.get(i)-as.get(i-1);
		}
		long last = k-as.get(as.size()-1)+as.get(0);
		sum+=last;

		long min = Long.MAX_VALUE;
		for (int i = 1; i < as.size(); i++) {
			long j = sum - (as.get(i)-as.get(i-1));
			if (min>j){
				min = j;
			}
		}
		long p = sum-last;
		if (min>p){
			min = p;
		}
		System.out.println(min);
	}

}


Measured memory_bytes: 93812
# -*- coding: utf-8 -*-

def lower_bound(al, key):
    """
    一般に左側が満たしておらず、右側は満たしている判定基準(境目は一つ)ならlower_boundになる
    (条件を満たすもののうち、最小のインデックスを返す)
    単調にさえなっていれば、左右が逆になっていても検索には使える(ng/okも一緒に逆にする必要がある)
    """
    def isOk(a):
        # alの中でkey以上のアイテムのうち最小のインデックスを返す
        # upper_boundにする時にはa>key
        return a>=key

    ng = -1
    ok = len(al)

    while abs(ok-ng)>1:
        mid = (ok+ng)//2

        if isOk(al[mid]):
            ok = mid
        else:
            ng = mid

    return ok


a,b,q = map(int, input().split())
sl = [int(input()) for _ in range(a)]
tl = [int(input()) for _ in range(b)]
xl = [int(input()) for _ in range(q)]
# print(sl)
# print(tl)
for x in xl:
    si = lower_bound(sl,x)
    ti = lower_bound(tl,x)
    # print(x,si,ti)

    ssl = []
    if si==a:
        ssl.append(sl[-1])
    elif si==-1:
        ssl.append(sl[0])
    else:
        ssl.append(sl[si])
        if si>0:
            ssl.append(sl[si-1])
    ttl = []
    if ti==b:
        ttl.append(tl[-1])
    elif ti==-1:
        ttl.append(tl[0])
    else:
        ttl.append(tl[ti])
        if ti>0:
            ttl.append(tl[ti-1])

    res = -1
    for s in ssl:
        for t in ttl:
            if s>=x and t>=x:
                tmp = max(s-x, t-x)
            elif s<x and t<x:
                tmp = max(x-s, x-t)
            elif s>=x>=t:
                tmp = min(
                    2*(s-x)+(x-t),
                    (s-x)+2*(x-t)
                )
            else:
                tmp = min(
                    2*(x-s)+(t-x),
                    (x-s)+2*(t-x)
                )
            if res<0:
                res = tmp
            else:
                res = min(res,tmp)
    print(res)


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

const int MAX = 510000;
const int MOD = 1000000007;

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 % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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] % MOD) % MOD;
}

int main() {
    int H,W,A,B;
    cin >> H >> W >> A >> B;

    COMinit();
    long long ans = 0;
    for(int i=B; i<=W-1; ++i) {
        ans += COM(H - A - 1 + i, i) * COM(A - 1 + W - 1 - i, A - 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

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

int main(){

	int p, pt1, pt2;
	
	pt1 = 0;
	pt2 = 0;
	
	for(int i=0; i<2; i++){
		for(int j=0; j<4; j++){
			cin >> p;
			if(i == 0) pt1 += p;
			else pt2 += p;
		}
	}
	
	if(pt1 > pt2) cout << pt1 << endl;
	else if(pt1 < pt2) cout << pt2 << endl;
	else cout << pt1 << endl;

	return 0;

}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)



using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}


int main() {
    int a,b,k;
    cin >> a >> b >> k;
    if((b-a+1) <= 2*k){
        for(int i = a; i <= b; i ++){
            cout << i << endl;
        }
    }else{
        for(int i = a; i <= a+k-1; i ++){
            cout << i << endl;
        }
        for(int i = b-k+1; i <= b; i ++){
            cout << i << endl;
        }
    }

}







Measured memory_bytes: 3628
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N, K;
	long long an = 10000000000, L = 0;
	long long x[100000];
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &x[i]);
	}
	for (int i = 0; i < N - K + 1; i++) {
		L = abs(x[i]) + abs(x[i + K - 1] - x[i]);
		if (L < an) an = L;
		L = abs(x[i + K - 1]) + abs(x[i] - x[i + K - 1]);
		if (L < an) an = L;
	}
	printf("%lld",an);
	return 0;
}

Measured memory_bytes: 896
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BinaryHeap;

fn main() {
    let n: usize = read();
    let mut d: Vec<u32> = read_vec();
    d.sort_by(|a, b| a.partial_cmp(b).unwrap());
    println!("{}", d[n / 2] - d[n / 2 - 1]);
}


Measured memory_bytes: 4352
N = int(input())
dic = {}
sum = 0
for i in range(N):
    s = ''.join(sorted(str(input())))
    if s in dic:
      dic[s] += 1
    else:
      dic[s] = 1
for i in dic.values():
    if i > 1:
        sum += i*(i-1)/2
print(int(sum))

Measured memory_bytes: 17852
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int Q; cin >> Q;
    int N = 0;
    priority_queue<ll> left;
    priority_queue<ll, vector<ll>, greater<ll>> right;
    ll sumL = 0, sumR = 0, B = 0;
    while (Q--) {
        int com; cin >> com;
        if (com==1) {
            int a,b; cin >> a >> b;
            if (right.empty() || right.top() > a) {
                left.emplace(a);
                sumL += a;
            }
            else {
                right.emplace(a);
                sumR += a;
            }
            ++N;
            if (left.size() > (N+1)/2) {
                int val = left.top();
                right.emplace(val); left.pop();
                sumR += val;
                sumL -= val;
            }
            if (right.size() > N/2) {
                int val = right.top();
                left.emplace(val); right.pop();
                sumL += val;
                sumR -= val;
            }
            B += b;
        } else {
            int val = left.top();
            cout << val << " ";
            ll ans = sumR - sumL + val*(N%2);
            cout << ans+B << ln;
        }
    }
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_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())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


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

  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  pll ma,mi;
  ma.FI = mi.FI =a[0];
  REP(i, n){
    if(ma.FI<a[i])
      ma.SE=i;
    if(mi.FI>a[i])
      mi.SE=i;
    ma.FI = max(ma.FI,a[i]);
    mi.FI = min(mi.FI,a[i]);
  }


  if(mi.FI>=0){
    cout << n-1 << endl;
    REP1(i,n)
      cout << i << " " << i+1 << endl;
  }
  else if(ma.FI<=0){
    cout << n-1 << endl;
    REP1(i,n)
      cout << n-i+1 << " " << n-i << endl;
  }
  else{
    cout << 2*n-1 << endl;
    if(abs(ma.FI)>abs(mi.FI)){
      REP(i, n)
        cout << ma.SE+1 << " " << i+1 << endl;
      REP1(i,n)
        cout << i << " " << i+1 << endl;
    }
    else{
      REP(i, n)
        cout << mi.SE+1 << " " << i+1 << endl;
      REP1(i,n)
        cout << n-i+1 << " " << n-i << endl;
     }
  }


}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

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

const int H = 55, W = 55;
const int L = 1111;

string board[H];
int h,w;
string in;

bool isClear;
int walk=0;

int memo_if[L];
int memo_while[L];

int visit[H][W][4][L];

int x;
int y;
int dir;

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


void input(){
	cin>>h>>w;
	rep(i,h)cin>>board[i];
	cin>>in;
	in += "*";

	rep(i,L)memo_if[i]=memo_while[i];

	rep(i,h){
		rep(j,w){
			if(board[i][j]=='s'){
				board[i][j]='.';
				x = j;
				y = i;
				dir = 0;
			}
		}
	}
}

int sim_program(int);

bool sim_check(int st){
	char c = in[st];

	if(c=='N')return dir==0;
	if(c=='E')return dir==1;
	if(c=='S')return dir==2;
	if(c=='W')return dir==3;

	int nx = x + dx[dir];
	int ny = y + dy[dir];

	if(c=='C')return board[ny][nx]=='#';


	return true;
}

int sim_if(int st){
	bool rev = false;
	if(in[st]=='~'){
		rev = true;
		st++;
	}
	bool res = rev^sim_check(st);
	st++;

	if(res){
		int res = sim_program(st);
		if(res==-1)return res;
	}
	return 0;
}

int sim_while(int st){

	int first = st;
	while(1){

		if(visit[y][x][dir][st]==1)return -1;
		visit[y][x][dir][st] = 1;
	bool rev = false;
		if(in[st]=='~'){
			rev = true;
			st++;
		}
		bool res = rev^sim_check(st);
		st++;

		if(res){
			int res = sim_program(st);
			if(res==-1)return res;
		}else{
			break;
		}

		st = first;
	}
	return 0;
}

int sim_simple(int st){
	char c = in[st];

	int nx = x;
	int ny = y;
	if(c=='^'){
		nx = x + dx[dir];
		ny = y + dy[dir];
	}
	if(c=='v'){
		nx = x - dx[dir];
		ny = y - dy[dir];
	}
	if(board[ny][nx]=='#'){
		nx = x;
		ny = y;
	}

	x = nx;
	y = ny;


	if(c=='<')dir = (dir+3)%4;
	if(c=='>')dir = (dir+1)%4;

	//printf("aa %d   %d %d %d\n",st,x,y,dir);
	walk++;

	if(board[y][x]=='g'){
		isClear = true;
		return -1;
	}

	if(visit[y][x][dir][st]==1)return -1;
	visit[y][x][dir][st]=1;

	return 0;
}

bool isSimple(char c){
	if(c=='^')return true;
	if(c=='v')return true;
	if(c=='>')return true;
	if(c=='<')return true;
	return false;
}

int end_if(int st){
	if(memo_if[st]!=0)return memo_if[st];
	int cnt = 0;
	int pos = st;
	while(1){
		if(in[pos]=='[')cnt++;
		if(in[pos]==']')cnt--;
		if(cnt==0){
			return memo_while[st]=pos;
		}
		pos++;
	}

	return -1;
}

int end_while(int st){
	if(memo_while[st]!=0)return memo_while[st];
	int cnt = 0;
	int pos = st;
	while(1){
		if(in[pos]=='{')cnt++;
		if(in[pos]=='}')cnt--;
		if(cnt==0){
			return memo_if[st]=pos;
		}
		pos++;
	}
	return -1;
}

int sim_program(int st){

	while(1){

		if(in[st]=='*' || in[st]=='}' || in[st]==']')return 0;

		if(in[st]=='['){
			int res = sim_if(st+1);
			if(res==-1)return res;
			st = end_if(st)+1;
			continue;
		}
		if(in[st]=='{'){
			int res = sim_while(st+1);
			if(res==-1)return res;
			st = end_while(st)+1;
			continue;
		}
		if(isSimple(in[st])){
			int res = sim_simple(st);
			if(res==-1)return res;
			st++;
			continue;
		}
	}
}

int solve(){
	sim_program(0);
	if(isClear)return walk;
	return -1;
}


int main(){
	input();
	cout<<solve()<<endl;
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

void Main()
{
    LL n;cin>>n;
    VL a(n);
    VL b(n);
    REP(i,n){
        cin>>a[i];
        b[i] = a[i]-i;
    }

    LL result = 0;
    
    map<LL,LL> m;
    m[b[n-1]]++;

    for(int i=n-2;i>=0;i--){
        LL x = a[i]+i;
        x *= -1;

        result += m[x];

        m[b[i]]++;
    }

    cout<<result<<endl;


    
    return;
}

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

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

using namespace std;
typedef long long ll;
const int modd=998244353;
const int maxn=3005;
int n,s,a[maxn];
ll dp[3005][3005],sum[3005][3005];
//以i结尾，和为j的子序列的起始点下标和
inline int read() {
	char ch = getchar();
	int x = 0, f = 1;
	while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
	return x * f;
}
int main() {
	n=read(),s=read();
	for(int i=1; i<=n; i++) a[i]=read();
	for(int i=1; i<=n; i++) {
		dp[i][a[i]]+=i;
		for(int j=a[i]; j<=s; j++)
			(dp[i][j]+=sum[i-1][j-a[i]])%=modd;
		for(int j=1; j<=s; j++)
			sum[i][j]=(sum[i-1][j] +dp[i][j])%modd;
	}
	ll ans=0;
	for(int i=1; i<=n; i++)
		(ans+=dp[i][s]*(ll)(n-i+1))%=modd;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 141184
/* be name khoda */

// #define stream_enable
#define long_enable
#include <iostream>
#include <algorithm>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;

#ifdef stream_enable
#define cin sss
#endif
#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<pii> vpii;

const ll MOD = 1000000007;
const long long BIG = 1446803456761533460;
const int Big = 336860180;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).F << ", " << (x).S << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].F << ", " << (x)[i1_dap].S << ")\n"; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_dav].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

ll n;
ll ar[maxn];
map<ll, ll> pos;

void MAIN() {

    cin >> n;
    fori (i, n) cin >> ar[i], pos[ar[i]] = i;
    sort(ar, ar + n);
    ll ans = 0;
    fori (i, n) ans += (pos[ar[i]] ^ i) & 1;
    cout << ans / 2 << '\n';

}

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

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(10);
    sss << R"(
5
10
8
5
3
2
    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, x; cin >> n >> x;
  vector<int> a(n);
  for(int &c : a) {
    cin >> c;
  }
  sort(a.begin(), a.end());
  long long sum = 0;
  for(int c : a) {
    sum += c;
  }
  if(sum < x) {
    cout << n -1 << endl;
  }
  else if(sum == x) {
    cout << n << endl;
  }
  else {
    int given = 0, count = 0;
    while(given < x) {
      given += a.at(count);
      count++;
    }
    if(given == x) {
      cout << count << endl;
    }
    else {
      cout << count -1 << endl;
    }
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <unordered_set>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> S(h);
  for (int i = 0; i < h; i++) { cin >> S[i]; }


  for (int i = 0; i < w + 2; i++) { cout << "#";}
  cout << endl;
  for (int i = 0; i < h; i++) {
    cout << "#" << S[i] << "#" << endl;
  }
  for (int i = 0; i < w + 2; i++) { cout << "#";}
  cout << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a,i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if(i%3==0){
        printf(" %d",i);
        }
        else{
            a=i;
            for(j=1;j<=5;j++){
                if(a==0){
                    break;
                }
                if(a%10==3){
                    printf(" %d",i);
                    break;
                }
                a=(a-a%10)/10;
                
            }
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
int main()
{
	// freopen("AGC007-C.in", "r", stdin); 
	int n; 
	double d1, x, ans = 0; 
	scanf("%d%lf%lf", &n, &d1, &x); 
	while (n)
	{
		ans += d1 + (n - 0.5) * x; 
		d1 = ((n + 1) * d1 + 2.5 * x) / n; 
		x *= 2.0 / n + 1; 
		n--; 
	}
	printf("%.15lf\n", ans);
	return 0; 
}


Measured memory_bytes: 128
N,*C = map(int, open(0).read().split())
MOD = 10**9+7
p2 = [1]*(2*N+1)
for i in range(1,2*N+1):
  p2[i] = p2[i-1]*2%MOD
C.sort()
ans = 0
for i,c in enumerate(C):
  n = N-1-i
  ans += c*(n*p2[n-1]+p2[n])*p2[N+i]%MOD
print(ans%MOD)

Measured memory_bytes: 28324
#include<cstring>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
struct P{
  P(){};
  P(int a,int b){
    x=a,y=b;
  }
  int x,y;
  void move(int,int);
};
struct S{
  S(){};
  S(P a,P b){
    t=a;
    k=b;
  }
  P t,k;
  void move(int);
};
 
P size;
S f_pos;
vector<vector<int> > f;
bool input(){
  size=P();
  f_pos=S();
  f.clear();
  cin>>size.y>>size.x;
  if(size.x==0&&size.y==0)return false;
  cin>>f_pos.t.y>>f_pos.t.x;
  cin>>f_pos.k.y>>f_pos.k.x;
  vector<int> t;
  for(int i=0;i<size.y+2;i++){
    t.push_back(1);
  }
  f.push_back(t);
  for(int i=0;i<size.x;i++){
    vector<int> tt;
    tt.push_back(1);
    for(int j=0;j<size.y;j++){
      int tmp;
      cin>>tmp;
      tt.push_back(tmp);
    }
    tt.push_back(1);
    f.push_back(tt);
  }
  f.push_back(t);
  return true;
}
int cost[60][60][60][60];
const int vx[]={0,0,1,-1};
const int vy[]={1,-1,0,0};
void S::move(int i){
  t.move(vx[i],vy[i]);
  k.move(-vx[i],-vy[i]);
}
void P::move(int a,int b){
  if(f[x+a][y+b]!=1){
    x+=a;
    y+=b;
  }
}
int solve(){
  memset(cost,-1,sizeof(cost));
  queue<S> q;
  q.push(f_pos);
  cost[f_pos.t.x][f_pos.t.y][f_pos.k.x][f_pos.k.y]=0;
  while(!q.empty()){
    S now = q.front();q.pop();
    for(int i=0;i<4;i++){
      S tmp = now;
      tmp.move(i);
      if(cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y]!=-1)continue;
 
      cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y] = cost[now.t.x][now.t.y][now.k.x][now.k.y]+1;
      if(cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y]>=100){
        return -1;
      }else if( (tmp.t.x==tmp.k.x)&&(tmp.t.y==tmp.k.y) ){
        return cost[tmp.t.x][tmp.t.y][tmp.k.x][tmp.k.y];
      }else{
        q.push(tmp);
      }
    }
  }
  return -1;
}
int main(){
  while(input()){
    /*
    for(int i=0;i<f.size();i++){
      for(int j=0;j<f[i].size();j++){
        cout<<f[i][j];
      }cout<<endl;
    }cout<<endl;
    */
    int ans= solve();
    if(ans==-1||ans>=100){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
  }
}

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

using namespace std;

typedef long long ll;


char s[14];
int a[14],len;

int f(int n){
    return a[n]+a[n-1]*10+a[n-2]*100;
}

int main()
{
    cin>>s;
    len=0;
    for(int i=0;s[i]!='\0';i++){
        a[len++]=s[i]-'0';
    }

    int ans=900;
    for(int i=2;i<len;i++){
        ans=min(ans,abs(f(i)-753));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n*3);
  rep(i,n*3) cin >> a[i];

  vector<ll> l(n*2+1),r(n*2+1);
  priority_queue<int,vector<int>,greater<int>> lq;
  priority_queue<int> rq;
  rep(i,n*2){
    l[i+1] = l[i]+a[i];
    lq.push(a[i]);
    if(lq.size()>n) l[i+1] -= lq.top(), lq.pop();
  }
  rep(i,n*2){
    r[i+1] = r[i]+a[n*3-1-i];
    rq.push(a[n*3-1-i]);
    if(rq.size()>n) r[i+1] -= rq.top(), rq.pop();
  }
  ll ans = -1e18L;
  rep(i,n+1) ans = max(ans,l[n+i]-r[n*2-i]);
  cout << ans << endl;
}

Measured memory_bytes: 6904
import java.io.*;
import java.util.*;

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		if (S.length % 2 == 1) {
			System.out.println(NO);
			return;
		}

		for (int i = 0; i < S.length; i++) {
			if (i % 2 == 0 && S[i] != 'h') {
				System.out.println(NO);
				return;
			}

			if (i % 2 == 1 && S[i] != 'i') {
				System.out.println(NO);
				return;
			}
		}

		System.out.println(YES);
	}
}


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

using namespace std;

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

  int n;
  while(cin >> n,n){
    int suspected[n+1]={0};
    std::vector<int> owner[n+1];
    for(int i=1;i<=n;i++){
      int m;cin >>m;
      for(int j=0;j<m;j++){
        int p;cin >>p;
        owner[p].push_back(i);
      }
    }
    int k;cin >>k;
    for(int i=0;i<k;i++){
      int idx;
      cin >> idx;
      int len=owner[idx].size();
      for(int i=0;i<len;i++) suspected[owner[idx][i]]++;
    }
    int res=-1;
    bool humei=false;
    for(int i=1;i<=n;i++){
      if(suspected[i]==k){
        if(res<0)res=i;
        else humei=true;
      }
    }
    if(humei || res<0) cout << -1 << endl;
    else cout << res << endl;
  }
}

Measured memory_bytes: 3176
fun main(arr: Array<String>) {
    val (k, s) = readLine()!!.split(" ").map { it.toInt() }
    val ans = getAns(0, s, k)
    println(ans)
}

fun getAns(idx:Int, remain:Int, k:Int):Int {
    if(idx >= 2) {
        if(remain < 0) {
            return 0
        }
        if(remain <= k) {
            return 1
        }
        return 0
    }
    var ans = 0
    for(i in (0..k)) {
        if(i > remain) {
            break
        }
        ans += getAns(idx+1, remain-i, k)
    }
    return ans
}

Measured memory_bytes: 36352
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputstream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputstream);
        AtcoderB solution = new AtcoderB();
        solution.solve(1, in, out);
        out.flush();
        out.close();
    }

    static class AtcoderB {
        public void solve(int testNumber, Scanner sc, PrintWriter out) {
            int k = sc.nextInt();
            String s = sc.next();
            if (s.length() <= k)
                out.println(s);
            else
                out.print(s.substring(0, k) + "...");
        }
    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader f) {
            br = new BufferedReader(f);
        }

        public String next() {
            while (st == null || !st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 36568
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a[N],k,Max,g;
int gcd(int x,int y){ return x ? gcd(y%x,x) : y;}
int main()
{
	int i;
	scanf("%d %d",&n,&k);
	for(i=1;i<=n;i++)
		scanf("%d",&a[i]),g=gcd(g,a[i]);
	for(i=1;i<=n;i++)
		if(k%g==a[i]%g&&a[i]>=k){
			printf("POSSIBLE");
			return 0;
		  }
	printf("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 764
//i ll be the king
#include<bits/stdc++.h>
#define ll long long int
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define rep(n) for(ll i2=0;i2<n;i2++)
#define vmp(v,a,b) v.push_back(make_pair(a,b))
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define aset(a,n,k) for(ll i3=0;i3<n;i3++)a[i3]=k; 	
#define mod 1000000007
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main()
{
	sync;
	ll h,w;
	cin>>h>>w;
	char arr[h][w];
	for(ll i=0;i<h;i++)
	{
	string s;
	cin>>s;
	for(ll j=0;j<w;j++)
	arr[i][j]=s[j];
	}
	ll dp[h+1][w+1];
	for(ll i=0;i<=h;i++)
	{
		for(ll j=0;j<=w;j++)
		{
			if(i*j==0||arr[i-1][j-1]=='#')
			dp[i][j]=0;
			else if(i==1&&j==1)
			dp[i][j]=1;
			else
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		}
	}
	cout<<dp[h][w];
}

Measured memory_bytes: 9088
#include <iostream>
using namespace std;
int main(){
    int n,f=0;

    cin >> n ;

    for(int x=n; x>0; x = x/10){
        f = f + x%10;
    }

    if(n%f==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
S = input()


def can_pass(s):
    for i in range(len(s) - 1):
        if s[i] == '#' and s[i+1] == '#':
            return False
    return True


def can_pass2(s):
    for i in range(len(s) - 2):
        if s[i] == '.' and s[i+1] == '.' and s[i+2] == '.':
            return True
    return False


if B < A:
    A, B = B, A
    C, D = D, C

if C < D:
    if can_pass(S[A-1:C]) and can_pass(S[B-1:D]):
        print('Yes')
    else:
        print('No')
else:
    if can_pass2(S[B-2:D+1]):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3572
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
N=int(input())
mylist=[]
for x in range(N):
  j=int(input())
  mylist.append(j)
if a in mylist and b in mylist and c in mylist:
  print('Yes')
elif a in mylist and b in mylist and c in mylist:
  print('Yes')
elif a in mylist and e in mylist and i in mylist:
  print('Yes')
elif a in mylist and d in mylist and g in mylist:
  print('Yes')
elif d in mylist and e in mylist and f in mylist:
  print('Yes')
elif g in mylist and h in mylist and i in mylist:
  print('Yes')
elif c in mylist and e in mylist and g in mylist:
  print('Yes')
elif b in mylist and e in mylist and h in mylist:
  print('Yes')
elif c in mylist and f in mylist and i in mylist:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3064
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

N, K = input_int()

sunukes = [i+1 for i in range(N) ]

lis = []
for i in range(K):
    _ = one_int()
    temp = many_int()
    lis += temp

treats = set(sunukes)-set(lis)

print(len(treats))

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

template<typename T, typename U>
using pv=vector<pair<T,U>>;
template<typename T>
using matrix=vector<vector<T>>;
template<typename T>
using pque=priority_queue<T>;
template<typename T>
using lpque=priority_queue<T,vector<T>,greater<T>>;

using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using ilpair=pair<int,ll>;
using lipair=pair<ll,int>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;

#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define MMPRIME (1ll<<61)-1

#define len length()
#define pushb push_back
#define fi first
#define se second

#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

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

template<class T>
inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

template<class T>
inline void init(T& v) {
	for(auto &a: v) cin>>a;
}
template<class T, class U>
inline void init(vector<pair<T,U>>& v) {
	for(auto &a: v) cin>>a.first>>a.second;
}
template<class T, class N>
inline void init(T& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a;
}
template<class T, class U, class N>
inline void init(vector<pair<T,U>>& v, N n) {
	v.resize(n);
	for(auto &a: v) cin>>a.first>>a.second;
}

template<class N>
void resiz(N n) {
	//empty
}
template<class N, class T, class... U>
void resiz(N n, T&& hd, U&&... tl) {
	hd.resize(n);
	resiz(n,forward<U>(tl)...);
}

ll binpow(ll a, ll ex, ll p) {
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}


int D;
intvec C(26);
intmat S;
intvec last(26,-1);
ll score;

void input() {
	cin>>D;
	init(C);
	S.resize(D);
	for(int i=0; i<D; i++) init(S[i],26);
}

ll calc(int d, int c) {
	ll res=S[d][c];
	for(int i=0; i<26; i++) {
		res-=C[c]*(d-last[c]);
	}
	return res;
}

void solve() {
	srand(time(NULL));
	int c2;
	for(int d=0; d<D-1; d++) {
		ll temps=-LLINF;
		int c1;
		for(int c=0; c<26; c++) {
			int oldd=last[c];
			last[c]=d;
			int olddc;
			ll ttemps=calc(d,c);
			for(int pc=0; pc<26; pc++) {
				int olddd=last[pc];
				last[pc]=d+1;
				if(chmax(temps,ttemps+calc(d+1,pc))) {
					c1=c;
					c2=pc;
				}
				last[pc]=olddd;
			}
			last[c]=oldd;
		}
		score+=temps;
		last[c1]=d;
		cout<<c1+1<<endl;
	}
	cout<<c2+1<<endl;
}

int main() {
	int t=1;
	while(t) {
		input();
		solve();
		t--;
	}
}


Measured memory_bytes: 3688
import heapq

n,m=map(int,input().split())
l=[[] for i in range(m)]
s=[]
for i in range(n):
   a,b=map(int,input().split())
   if a<=m:
     l[a-1].append(b)

t=0
heapq.heapify(s)

for i in range(m):
  for j in range(len(l[i])):
    heapq.heappush(s,-l[i][j])
  if len(s)>0:
    t-=heapq.heappop(s)

print(t)


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

typedef long long ll;

const ll MOD = ((ll)1e9) + 7;

string s;

ll pw(ll x, int p) {
	ll ret = 1;
	for(; p; p>>=1) {
		if(p & 1) {
			ret *= x;
			ret %= MOD;
		}
		x *= x;
		x %= MOD;
	}
	return ret;
}

int main() {
	ios_base::sync_with_stdio(0);
	
	cin >> s;
	int n = s.size();
	
	int cnt = 0;
	ll ans = 0;
	for(int i = 0; i < n; i++) {
		if(s[i] == '1') {
			ans += (pw(3, n-i-1) * pw(2, cnt)) % MOD;
			ans %= MOD;
			cnt++;
		}
	}
	ans += pw(2, cnt);
	ans %= MOD;
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 512
S = input()
T = input()
word = [x for x in T]
for i in range(len(word)):
    a = word[0]
    word.append(a)
    word.remove(a)
    if S == ''.join(word):
        break
    else:
        pass
if S == ''.join(word):
    print('Yes')
else:
    print('No')

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

#define N ((ll)1e18)

int main(int argc, char const *argv[])
{
	double a, b;
	cin >> a >> b;
	// b = b*100;
	// ll y = (ll)b;
	// ll x = (ll)a;
	
	// x = (x*y)/100;

	// a = a - (a - (ll)a);
	cout << (((ll)a)*((ll)(b*100)))/100;
	return 0;
}

Measured memory_bytes: 3716
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll n,k,x,y;
void input(){
    cin>>n>>k>>x>>y;
}
void src(){
    cout<< (x*(min(n,k))+y*(max(n,k)-k));
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <cstdarg>
#include <set>
#include <limits>
#include <iomanip>

using namespace std;
#define INF 2e9 + 9
#define MOD 1000000007
#define ALL(v) v.begin() , v.end()
#define Int int64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T, vector<T>>;
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
#define ll(n) Int n; cin >> n;
#define LL(...) Int __VA_ARGS___; cin >> __VA_ARGS___;
#define OUT(...) cout << __VA_ARGS___;
#define RP(n, i, s) for(Int i = s ;i < n ;i++)
#define REP(n, i) for (Int i = 0; i < n; i++)
#define REPe(n, i) for (Int i = 1; i <= n; i++)
#define RPe(n, i, s) for (Int i = s; i <= n; i++)
#define upd_max(maxer, updater) if (maxer < updater) maxer = updater;

void ansYes(bool flag){
    if (flag) cout << "Yes" << endl; else  cout << "No" << endl;
}

void ansYES(bool flag){
    if (flag) cout << "YES" << endl; else  cout << "NO" << endl;
}

struct node {
    Int to;
    Int length;
};


vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    return (ret);
}

/*
vector<vector<int>> to;
vector<int> flag;
vector<int> c;


Int dfs(int from, int mae) {
    flag[from] = 1;
    Int mini = 0;
    for (auto next : to[from]) {
        if (next == mae) continue;
        if (flag[next] == 1) {
            return -1;
        } else {
            mini = min(mini, dfs(next, from));
        }
    }
    return mini;
}*/

int dx8[8] = {0, -1, -1, -1, 0, 1, 1, 1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int nanko(string s,Int n,Int i){
    Int length = min(n - i - 1,i);
    Int ans = 0;
    for (int k = i-length;k < i;k++){
        if (s.at(k) == 'R' && s.at(i +  (i - k) == 'B')) ans++;
    }
    return ans;
}

int main(){
    Int n;
    cin >> n;
    multiset<Int,greater<>> s;
    Int z;
    cin >> z;
    s.insert(z);
    REP(n - 1,i) {
        Int x;
        cin >> x;
        //cout << "Hello ";
        //cout << *s.rbegin() << " < kusa";
        if (*s.rbegin() >= x) {
            //cout << *s.rbegin() << endl;
            s.insert(x);
            //cout << "Hello 2";
        }else{
            auto it = s.upper_bound(x);
            s.erase(it);
            s.insert(x);
            //cout << "Hello 3";
        }
        /*for( auto z: s) {
            cout << z << " ";
        }
        cout << endl;*/
    }
    cout << s.size() << endl;

}

Measured memory_bytes: 4992
#include <stdio.h>

char S[1010];

int main()
{
	scanf ("%s",S);
	int a = 0, b = 0;
	for (int i=0;S[i];i++){
		if (S[i] == 'N') a |= 1;
		if (S[i] == 'S') a |= 2;
		if (S[i] == 'W') b |= 1;
		if (S[i] == 'E') b |= 2;
	}
	bool good = (a == 0 || a == 3) && (b == 0 || b == 3);
	puts(good?"Yes":"No");

	return 0;
}

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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)

ll v[101],w[101];
ll dp[101][100001];
ll N,W;
int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
       cin>>N>>W;
       loop(i,0,N-1) cin>>w[i]>>v[i];
       dp[0][0]=0;
       dp[0][w[0]]=v[0];
       loop(i,1,N-1) dp[i][0]=0;
       loop(i,1,N-1)
       {
           loop(j,1,W)
           {
               dp[i][j]=dp[i-1][j];
               if(j>=w[i])
               {
                   dp[i][j]=max(dp[i][j],v[i]+dp[i-1][j-w[i]]);
               }
           }
       }
       ll ans= -1e18;
       loop(j,0,W) ans=max(ans,dp[N-1][j]);
       cout<<ans;
    }
    return 0;
}


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

int main() {
	long long int x;
	cin >> x;
	if(x % 11 == 0){
		cout << x / 11 * 2 << endl;
		return 0;
	}
	if(x - (x / 11) * 11 > 6){
		cout << (x / 11 + 1) * 2 << endl;
		return 0;
	}
	cout << (x / 11 + 1) * 2 - 1 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(){
    int N,a[21],b[21],c[22],ans = 0,temp;
    cin >> N;
    for(int i = 1;i<=N;i++){
        cin >> a[i];
    }
    for(int i = 1;i<=N;i++){
        cin >> b[i];
        ans += b[i];
    }
    for(int i = 1;i<N;i++){
        cin >> c[i];
    }
    temp = a[1];
    for(int i = 2;i<=N;i++){
        if(a[i] == temp+1)ans += c[temp];
        temp = a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<map>
using namespace std;
#define ll long long
#define mod 1000000007;
int main(){
	string S;
    cin >> S;
    ll pat=1;
    ll A=0;
    ll AB=0;
    ll ABC=0;
    ll i;
    for (i=0;i<S.size();i++){
    	if(S[i]=='A'){
    		A=(A+pat)%mod;
    	}
    	if(S[i]=='B'){
    		AB=(AB+A)%mod;
    	}
    	if(S[i]=='C'){
    		ABC=(ABC+AB)%mod;
    	}
    	if(S[i]=='?'){
    		ABC=(3*ABC+AB)%mod;
    		AB=(3*AB+A)%mod;
    		A=(3*A+pat)%mod;
    		pat=(pat*3)%mod;
    	}
    }
    cout <<ABC;
    return 0;
}


Measured memory_bytes: 512
PROGRAM ATCODER

implicit none
integer :: a,b
character :: op

read(*,*) a,op,b

if ( op == '+' ) then
  write(*,'(i0)') a+b
else
  write(*,'(i0)') a-b
end if

contains
!!!!!! サブルーチンは↓
!!!!!!

END PROGRAM ATCODER


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <functional>
#include <algorithm>
#define rep(i,a) for(int i=0;i<(a);++i)
const int INF = 1<<30;
#define _m_ 1
struct edge{
	int from, to, cost; 
	edge () {}
	edge(int f, int t, int c){
		from=f;
		to=t;
		cost=c;
	}
};
typedef std::pair<int, int> P;

int V;
std::vector<edge> es;
int d[11];
int maxm=0;
int SP(int s){
	rep(i, maxm+1)d[i] = INF;
	d[s] = 0;
	while(_m_){
		bool update = false;
		rep(i, es.size()){
			edge e = es[i];
			if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if(!update)break;
	}
	int res = 0;
	rep(i, maxm+1){
		//if(i == s)continue;
		if(d[i] != INF)res += d[i];
	}
	
	return res;
}

int main(){
	int n;
	while(scanf("%d",&n) && n){
		es.clear();
		maxm=0;
		for(int i = 0 ; i < n; ++i){
			int a, b, c;
			scanf("%d %d %d",&a, &b, &c);
			edge ac(a,b,c);
			edge bc(b,a,c);
			es.push_back(ac);
			es.push_back(bc);
			maxm=std::max(maxm,std::max(a,b));
		}
		V = n;
		P ans=P(0, SP(0));
		
		for(int i = 0; i < maxm + 1; ++i){
			if(ans.second > SP(i)){
				ans.second = SP(i);
				ans.first = i;
			}
			//printf("OK\n");
			//printf("%d %d\n", i, SP(i));
		}
		printf("%d %d\n", ans.first, ans.second);
	}
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;
string convert(string S){
  string ret="";
  REP(S.size()){
    char tmp;
    switch (S[i])
    {
    case 'R':
      tmp=0;
      break;
    case 'G':
      tmp=1;
      break;
    default:
      tmp=2;
      break;
    }
    ret+=tmp;
  }
  return ret;
}
int another(int a,int b){
  if(a!=0&&b!=0)return 0;
  if(a!=1&&b!=1)return 1;
  if(a!=2&&b!=2)return 2;
}
void solve(long long N, std::string S){
  S=convert(S);
  ll ans=1;
  vector<ll> one_rgb(3,0),two_rgb(3,0);
  REP(3*N){
    if(two_rgb[S[i]]>0){
      ans=two_rgb[S[i]]*ans%MOD;
      --two_rgb[S[i]];
      dump(i);
      dump(ans);
      continue;
    }
    bool f=false;
    For(j,3){
      if(j==S[i])continue;
      if(one_rgb[j]>0){
        ++two_rgb[another(j,S[i])];
        dump(j);
        ans=ans*one_rgb[j]%MOD;
        --one_rgb[j];
        f=true;
        break;
      }
    }
    if(f==false){
      ++one_rgb[S[i]];
    }
    dump(i);
    dump(ans);
  }
  for (size_t i = 1; i <= N; i++)
  {
    ans=ans*i%MOD;
  }
  cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::string S;
    std::cin >> S;
    solve(N, S);
    return 0;
}


Measured memory_bytes: 1540