akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;

#define int long long
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, M, A, B;

signed main() {
    cin >> N >> M >> A >> B;
    if (N * M < 2 * (A + B)) {
        cout << "NO" << endl;
        return 0;
    }
    int a = max(0LL, (A - M * (N % 2) / 2)),
        b = max(0LL, (B - N * (M % 2) / 2));
    if (((N % 2 == 0 || M % 2 == 0) &&
         (N / 2) * (M / 2) < a / 2 + b / 2 + a % 2 + b % 2) ||
        (N % 2 == 1 && M % 2 == 1) &&
            (N / 2) * (M / 2) < (a + b) / 2 + (a + b) % 2) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    char ans[1000][1000];
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            ans[i][j] = '.';
        }
    }
    if (N % 2 == 1) {
        for (int i = 0; i < M - M % 2 && A > 0; i += 2) {
            ans[N - 1][i] = '<';
            ans[N - 1][i + 1] = '>';
            A--;
        }
    }
    if (M % 2 == 1) {
        for (int i = 0; i < N - N % 2 && B > 0; i += 2) {
            ans[i][M - 1] = '^';
            ans[i + 1][M - 1] = 'v';
            B--;
        }
    }
    for (int i = 0; i < N - N % 2; i += 2) {
        for (int j = 0; j < M - M % 2; j += 2) {
            if (N % 2 == 1 && M % 2 == 1) {
                if (A > 1) {
                    ans[i][j] = '<';
                    ans[i][j + 1] = '>';
                    ans[i + 1][j] = '<';
                    ans[i + 1][j + 1] = '>';
                    A -= 2;
                } else if (B > 1) {
                    ans[i][j] = '^';
                    ans[i + 1][j] = 'v';
                    ans[i][j + 1] = '^';
                    ans[i + 1][j + 1] = 'v';
                    B -= 2;
                }
            } else {
                if (A > 0) {
                    ans[i][j] = '<';
                    ans[i][j + 1] = '>';
                    A--;
                    if (A > 0) {
                        ans[i + 1][j] = '<';
                        ans[i + 1][j + 1] = '>';
                        A--;
                    }
                } else if (B > 0) {
                    ans[i][j] = '^';
                    ans[i + 1][j] = 'v';
                    B--;
                    if (B > 0) {
                        ans[i][j + 1] = '^';
                        ans[i + 1][j + 1] = 'v';
                        B--;
                    }
                }
            }
        }
    }
    if (A == 1 && B == 1) {
        ans[N - 3][M - 3] = '<';
        ans[N - 3][M - 2] = '>';
        ans[N - 2][M - 3] = '^';
        ans[N - 1][M - 3] = 'v';
        ans[N - 1][M - 2] = '<';
        ans[N - 1][M - 1] = '>';
    } else if (A == 1) {
        ans[N - 3][M - 3] = '<';
        ans[N - 3][M - 2] = '>';
    } else if (B == 1) {
        ans[N - 3][M - 3] = '^';
        ans[N - 2][M - 3] = 'v';
    }
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
import itertools
a = 0
b = 0
cnt = 1
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=sorted(p)
for i in itertools.permutations(r, n):
    if list(i) == p:
        a += cnt
    if list(i) == q:
        b += cnt
    if a!=0 and b!=0:
        break
    else:
        cnt += 1
    
print(abs(a-b))

Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], n, k;
long long qian[N], quj[N], sum[N], ans;
int main() {
    scanf ("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
    	scanf("%d",&a[i]);
		sum[i] = sum[i - 1] + a[i];
		qian[i] = qian[i - 1] + max(a[i], 0);
	}
    quj[n + 1] = 0;
    for (int i = n; i >= 1; i--)
		quj[i] = quj[i + 1] + max(a[i], 0);
    ans = 0;
    for (int i = 0; i <= n - k; i++)
        ans = max(ans, qian[i] + quj[i + k + 1] + max(sum[i + k] - sum[i], 0ll));
    printf ("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n;
  cin >> n;

  int ans = (n + 1) / 2;

  cout << ans << endl;

  return 0;
}


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

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

    int flag = 0;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(N == i*j){
                flag = 1;
            }
        }
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No"  << endl;
    }  
}

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

int main(){
    int X,A,B;
    cin>>X>>A>>B;
    if(A>=B){
        cout<<"delicious"<<endl;
    }else if(A+X>=B){
        cout<<"safe"<<endl;
    }else{
        cout<<"dangerous"<<endl;
    }
}

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

int main() {
	int n;
	cin>>n;
	vector<int>c;
	vector<int>d;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		c.push_back(a);
		d.push_back(a);
	}
	sort(c.begin(),c.end());
	int front,rear;
	front = c[n/2-1];
	rear = c[n/2];
	for(int i=0;i<n;i++){
		if(d[i]<=front){
			cout<<rear;
		}
		else{
			cout<<front;
		}
		cout <<endl;
	}
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h1,m1,h2,m2,k,limit=0;
	cin>>h1>>m1>>h2>>m2>>k;
	limit=(h2-h1)*60+m2-m1-k;
	cout<<limit;
	return 0;
} 

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

int a, b, c, d, e, f;

signed main() {
	cin >> a >> b >> c >> d >> e >> f;
	
	double max_noudo = -1;
	int max_w, max_s;
	for (int i = 0; i <= 30; i++) {
		for (int j = 0; j <= 30; j++) {
			int w = 100 * a * i + 100 * b * j;
			if (w > f) continue;
			int smax = min(e * w / 100, f - w);
			
			for (int k = 0; k <= 3000; k++) {
				if (c * k > smax) continue;
				
				int s = smax - (smax - c * k) % d;
				
				if (max_noudo < 100.0 * s / (w + s)) {
					max_noudo = 100.0 * s / (w + s);
					max_w = w;
					max_s = s;
				}
			}
		}
	}
	
	cout << max_w + max_s << " " << max_s << endl;
	return 0;
}

Measured memory_bytes: 888
import bisect,collections,copy,heapq,itertools,math,string
import sys
def I():
    #1 line 1 int
     return int(sys.stdin.readline().rstrip())
def LI():
    #1 line n int
     return list(map(int,sys.stdin.readline().rstrip().split()))
def S():
    #1 line 1 string
     return sys.stdin.readline().rstrip()
def LS():
    #1 line n strings
     return list(sys.stdin.readline().rstrip().split())

R=I()
G=I()

x=2*G-R
print(x)

Measured memory_bytes: 10028
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}



int main(){
  string S;cin>>S;
  if(S=="AAA" || S=="BBB")cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 127
//C - Prison
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

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

    int lmax=0;
    int rmin=100000;
    REP(i, m) {
        int l,r;
        cin >> l >> r;
        lmax=max(lmax, l);
        rmin=min(rmin, r);
    }
    int ans=rmin-lmax+1;
    if (ans<0) ans=0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
using namespace std;

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

    vector<int> a(n);
    vector<int> f(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    for (int i = 0; i < n; i++){
        cin >> f[i];
    }
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());

    long long sum,m,t = 1e12, r = -1;
    while (r+1 < t){
        m = (t+r)/2;
        sum = 0;
        for (int i = 0; i < n; i++){
            sum += max(0ll, a[i]-m/f[i]);
        }
        if (sum <= k){
            t = m;
        }else{r = m;}
    }
    cout << r+1;
    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {

    val (n, m) = readLine()!!.split(" ").map { it.toLong() }

    var A = readLine()!!.split(" ").map { it.toLong() }.toMutableList()

    // Cj 以下　で　下から Bj 枚を Cj に書き換える

    // A は  10^5 配列 で 10^5 回 上記の操作を行う -> 毎回要素を全探索は出来ない

    // 単純に全部の要素を追加した上で，ソートをしてみる
    // 追加は一気にできるとして，最後配列のソートが nlogn <= 10^8 ならば行ける
    //  Bj < 10^5 で 置き換えが 10^5 回発生するから，最悪ケースでは要素数が 10^5 + 10^5 x 10^5 になって計算時間がダメそうだが？？

    // やってみる -> やはり TLE （想定通りで良かった？？)
    // 入れ替え候補の選び方が肝
    // map を作成し，入れ替える値と，その枚数をもつ -> ソート，-> 値が大きい map から順に，N枚になるまで取得する

    val candidates = mutableListOf<Pair<Long, Long>>()
    for (i in 0 until m) {
        val (b, c) = readLine()!!.split(" ").map { it.toLong() }
        candidates.add(Pair(b, c))
    }
    
    val candidatesSorted = candidates.sortedByDescending { it.second }
    
    var count = 0L
    var candSelected = mutableListOf<Long>()
    for (c in candidatesSorted){
        
        candSelected.addAll(LongArray(c.first.toInt()) {c.second}.toList())
        count += c.first
        
        if (count > n) {
            candSelected = candSelected.subList(0, n.toInt())
            break
        }
    }
    
    
    // 元の列と，変換候補 N 個 を結合して，ソートした上で上位N 個を取得，総和
    A.addAll(candSelected)
    
    println(A.sortedDescending().toList().subList(0, n.toInt()).sum())
}

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

vecveci dp(3010,veci(3010,0));

int main() {
    string S,T;
    cin >> S >> T;
    int n = S.size();
    int m = T.size();

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < m; j++) {
            if(S[i] == T[j])  {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else dp[i+1][j+1] = max(dp[i+1][j],dp[i][j+1]);
        }
    }

    string ans = "";

    while(n > 0 && m > 0) {
        if(dp[n][m] == dp[n-1][m]) n--;
        else if(dp[n][m] == dp[n][m-1]) m--;
        else {
            n--;
            m--;
            ans += S[n];
        }
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

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


int main() {
    int N, M;
    cin >> N >> M;
    vector<int> nums(N + 1, -1);
    for (int i = 0; i < M; i++) {
        int s, c;
        cin >> s >> c;
        if (nums[s] != -1 && nums[s] != c) {
            cout << -1 << endl;
            return 0;
        }
        nums[s] = c;
    }

    if (nums[1] == 0 && N != 1) {
        cout << -1 << endl;
        return 0;
    }

    for (int i = 1; i <= N; i++) {
        if (nums[i] == -1) {
            if (i == 1 && N != 1) {
                cout << 1;
            } else {
                cout << 0;
            }
        } else {
            cout << nums[i];
        }
    }

    cout << endl;
    return 0;
}

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

int main(){
  int num;
  long max, min, sum;
  
  cin >> num;
  
  int temp;
  cin >> temp;
  max = temp;
  min = temp;
  sum = temp;
  for(int i = 1; i < num; i++) {
    cin >> temp;
    if(max < temp) {
      max = temp;
    }
    if(min > temp) {
      min = temp;
    }
    sum += temp;
  }
  cout << min << " " << max << " " << sum << endl;
  
  return 0;
}

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

int main() {
    string s; cin >> s;
    int n = s.size();
    string t = "";
    char l = 'T';
    for(char c : s){
        if(l == 'S' && c == 'T'){
            t.pop_back();
            l = t[t.size()-1];
        }
        else{
            t.push_back(c);
            l = c;
        }
    }
    int ans = t.size();
    cout << ans << endl;
}


Measured memory_bytes: 776
//Author: Pakhomovee 
#include <iostream> 
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <deque>
#include <assert.h>

using namespace std;
using namespace std::chrono;

void solve()
{
	int x, n;
	cin >> x >> n;
	set<int> s;
	for (int i = 0; i < n; ++i)
	{
		int y;
		cin >> y;
		s.insert(y);
	}
	for (int delta = 0; ; delta++)
	{
		if (!s.count(x - delta))
		{
			cout << x - delta;
			return;
		}
		if (!s.count(x + delta))
		{
			cout << x + delta;
			return;
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	auto start = system_clock::now();

	solve();

	auto end = system_clock::now();
	cerr << "Time: " << duration_cast<milliseconds> (end - start).count() << "ms" << endl;
}

Measured memory_bytes: 3664
s = input()

f = int(s[:2])
b = int(s[2:])

if f>12:
    if b>0 and b<13:
        print("YYMM")
    else:
        print("NA")

elif f>0 and f<13:
    if b>0 and b<13:
        print("AMBIGUOUS")
    else:
        print("MMYY")

else:
    if b>0 and b<13:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
def solve(i, m, a, n)
  return true if m == 0
  return false if i >= n
  res = solve(i+1, m, a, n) || solve(i+1, m - a[i], a, n)
  return res
end

n = gets.to_i
a = gets.chomp.split(' ').map(&:to_i)
q = gets.to_i
m = gets.chomp.split(' ').map(&:to_i)

q.times do |i|
  puts solve(0, m[i], a.select{|j| j <= m[i]}, a.select{|j| j <= m[i]}.size) ? 'yes' : 'no'
end

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repA(i, a, n) for(int i = a; i <= (n); ++i)
#define repD(i, a, n) for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a) memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int mod = 998244353;
const int maxn = 3019;
ll dp[maxn][maxn];
int a,b,c,d; 

ll fp(ll a, ll b){
	ll ans = 1;
	while(b){
		if(b&1) ans = (ans*a)%mod;
		a = (a*a)%mod;
		b /= 2;
	}
	return ans;
}

ll solve(int n, int m){
	if(dp[n][m] != -1){
		return dp[n][m];
	}
	if(n == a && m == b){
		return 1;
	}
	if(n == a){
		return fp(a,m-b);
	}
	if(m == b){
		return fp(b,n-a);
	}
	ll t1 = (m*solve(n-1,m))%mod;
	ll t2 = (n*solve(n,m-1))%mod;
	ll t3 = ((n-1)*(m-1))%mod;
	t3 = (t3*solve(n-1,m-1))%mod;
	dp[n][m] = (t1 + t2)%mod;
	dp[n][m] = (dp[n][m] - t3 + mod)%mod;
	return dp[n][m];
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	cin >> a >> b >> c >> d;
	rep(i,c+1) rep(j,d+1) dp[i][j] = -1;
	cout << solve(c,d) << '\n';
	return 0;
}



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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> a(N);
    REP(i, N) cin >> a[i];

    // dp[i] = 石が i 個のときに太郎くんが勝つかどうか
    vector<bool> dp(K+1, false);
    FOR(i, 1, K+1){
        bool check = false;
        REP(j, N){
            if(i >= a[j] and !dp[i-a[j]]){
                check = true;
                break;
            }
        }
        if(check) dp[i] = true;
    }

    if(dp[K]) cout << "First" << endl;
    else cout << "Second" << endl;

    return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

bool isAllVisit(const vector<bool>& visit) {
    for (auto&& v : visit) {
        if (!v)return false;
    }
    return true;
}

int solve(int v, const vector<vector<int>>& graph, vector<bool> visit) {
    if (visit[v])return 0;
    visit[v] = true;
    if (isAllVisit(visit))return 1;
    int cnt = 0;
    for (auto&& g : graph[v]) {
        cnt += solve(g, graph, visit);
    }
    return cnt;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    ll X;
    cin >> X;

    ll ans = round_up(X, 11LL) * 2;
    if (1 <= X % 11LL && X % 11LL <= 6)ans--;

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

Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(width, height, w, h, x, y) = readLine.trim.split(' ').map(_.toInt)
  val daunats = Section(-height / 2, height / 2, width / 2, -width / 2)
  val ate = Section(y - h / 2, y + h / 2, x + w / 2, x - w / 2)
  daunats.intersection(ate) match {
    case None ⇒ println(1)
    case Some(s@Section(b,u,r,l)) ⇒
      println((r + l).toDouble / (b + u).toDouble)
  }
  case class Section(bottom: Int, up: Int, right: Int, left: Int){
    def verticalRange: Range = Range(bottom, up)
    def horizontalRange: Range = Range(left, right)
    def intersection(that: Section): Option[Section] = {
      verticalRange.intersection(that.verticalRange).flatMap{vRange ⇒
        horizontalRange.intersection(that.horizontalRange).map{hRange ⇒ Section(hRange.from, hRange.to, vRange.to, vRange.from)}
      }
    }
  }
  case class Range(from: Int, to: Int){
    def intersection(that: Range): Option[Range] = {
      if (to < that.from || from > that.to) None
      else Some(Range(math.max(from, that.from), math.min(to, that.to)))
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44416
// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ████━████   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━

// Author        : WhyWhy
// Created Time  : 2017年04月20日 星期四 20时29分20秒
// File Name     : E.cpp

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>

using namespace std;

char s[100005];
int sum[2][100005];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);

	for(int i=0;i<2;++i) {
		scanf("%s",s+1);
		sum[i][0]=0;
		for(int j=1;s[j];++j) sum[i][j]=sum[i][j-1]+(s[j]=='B');
	}

	int T,a,b,c,d;
	scanf("%d",&T);

	while(T--) {
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int x=x=b-a+1+sum[0][b]-sum[0][a-1];
		int y=y=d-c+1+sum[1][d]-sum[1][c-1];
		if(x%3==y%3) puts("YES");
		else puts("NO");
	}

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }
 
const int mod=1e9+7;
 
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  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 c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
 
    return true;
}
 
map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}
 
void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}
 
int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int a,b,h;cin>>a>>b>>h;
  int ans=(a+b)*h/2;
  cout(ans);
  return 0;
}

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

using namespace std;

long long N, s, res;
int a[100002];

int main(){
	cin >> N;
	a[0] = a[N+1] = 0;
	for(int i = 1; i <= N; ++i) cin >> a[i];
	for(int i = 0; i <= N; ++i) s += abs(a[i] - a[i+1]);
	for(int i = 1; i <= N; ++i){
		res = s + abs(a[i-1] - a[i+1]) - (abs(a[i-1] - a[i]) + abs(a[i] - a[i+1]));
		cout << res << endl;
	}
}

Measured memory_bytes: 1664
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int lst[Max], ls[Max];
int n;

int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &lst[i]);
	}
	sort(lst + 1, lst + 1 + n,greater<int>());
	ll sum = 0;
	for (int i = 1; i <= n; i++)
	{
		if (i % 2 != 0)sum += lst[i];
		else sum -= lst[i];
	}
	cout << sum;
}

Measured memory_bytes: 3224
#include <iostream>
#include <string>

constexpr int MAX = 100000;

std::string S, T;
int q;

int main(){

	std::cin >> S >> T >> q;
	
	int scsum[MAX + 1] = {}, tcsum[MAX + 1] = {};
	for(int i = 0; i < S.length(); ++i){
		if(S[i] == 'A'){
			scsum[i + 1] = 1 + scsum[i];
		}
		else{
			scsum[i + 1] = 2 + scsum[i];
		}
	}
	for(int i = 0; i < T.length(); ++i){
		if(T[i] == 'A'){
			tcsum[i + 1] = 1 + tcsum[i];
		}
		else{
			tcsum[i + 1] = 2 + tcsum[i];
		}
	}
	for(int i = 0; i < q; ++i){
		int a, b, c, d;
		std::cin >> a >> b >> c >> d;

		if((scsum[b] - scsum[a - 1]) % 3 == (tcsum[d] - tcsum[c - 1]) % 3){
			std::cout << "YES" << std::endl;
		}
		else{
			std::cout << "NO" << std::endl;
		}
	}

	return 0;
}


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

int main(){
    int X, N;
    cin >> X >> N;
    set<int> num;
    for (int i = 0; i <= 101; i++) {
        num.insert(i);
    }
    int p;
    for (int i = 0; i < N; i++) {
        cin >> p;
        num.erase(p);
    }
    int abs_min = 100;
    int min_num = 0;
    for (auto elem : num) {
        if (abs(elem - X) < abs_min) {
            abs_min = abs(elem - X);
            min_num = elem;
        }
    }
    cout << min_num << endl;  
}

Measured memory_bytes: 3628
mod = 1000000007

L = input()

threes = [1] * (len(L) + 1)
for i in range(1, len(L) + 1):
    threes[i] = threes[i-1] * 3 % mod

ans1 = 1
ans2 = 0
for i in range(len(L)):
    if L[i] == "0":
        continue
    ans2 += ans1 * threes[len(L) - i - 1] % mod
    ans2 %= mod
    ans1 *= 2
    ans1 %= mod
print((ans1 + ans2) % mod)


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

int main(void) {
  char c;
  long long int sum = 0;
  while (scanf("%c", &c) != EOF) {
    if (c == '\n' || c == '\0') { break; }
    sum += atoi(&c);
  }

  if (!(sum % 9)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 1640
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define MOD             1000000007
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)

using namespace std;

int main(void){
    //boost;
    LL x,y;
    cin>>x>>y;

    if(x*4<y) cout<<"No";
    else if(x*2>y) cout<<"No";
    else if(y%2!=0) cout<<"No";
    else cout<<"Yes";
}





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

int main(){
    int n,score = 0;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    rep(i,n){
        if(i%2 == 0){
            score += a[i];
        }
        else{
            score -= a[i];
        }
    }
    cout << score << endl;
}

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

// recursive algo, caused tle

/*ll bestval(int n, int w, ll *warr, ll *val)
{
	if(n==1){
		if(w>=warr[0]) return val[0];
		return 0;
	} 
	if(warr[n-1]>w) return bestval(n-1,w,warr,val);
	return max((bestval(n-1,w,warr,val)),(val[n-1]+bestval(n-1,w-warr[n-1],warr,val)));
}*/

ll bestval(int n, int W, ll *warr, ll *val)
{
	int i, w; 
   ll K[n+1][W+1]; 
  
   // Build table K[][] in bottom up manner 
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= W; w++) 
       { 
           if (i==0 || w==0) 
               K[i][w] = 0; 
           else if (warr[i-1] <= w) 
                 K[i][w] = max(val[i-1] + K[i-1][w-warr[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 
       } 
   } 
  
   return K[n][W]; 
}

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	int n,w,i;
	cin>>n>>w;
	ll warr[n],val[n];
	for(i=0;i<n;i++)
		cin>>warr[i]>>val[i];
	cout<<bestval(n,w,warr,val)<<"\n";
}


Measured memory_bytes: 79232
a=int(input())
ba=list(map(int,input().split()))
bb=list(map(int,input().split()))

ca=[0 for i in range(a)]
cb=[0 for i in range(a)]

ca[0]=ba[0]
cb[0]=ba[0]+bb[0]
for i in range(1,a):
  ca[i]=max(ca[i],ca[i-1]+ba[i])
for i in range(1,a):
  cb[i]=max(cb[i-1],ca[i])+bb[i]
  
print(cb[-1])

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		
		if(n % 2 == 0) {
			for(int i = n - 1; i >= 0; i -= 2) {
				System.out.print(a[i] + " ");
			}
			for(int i = 0; i < n; i += 2) {
				System.out.print(a[i] + " ");
			}
		} else {
			for(int i = n - 1; i >= 0; i -= 2) {
				System.out.print(a[i] + " ");
			}
			for(int i = 1; i < n; i += 2) {
				System.out.print(a[i] + " ");
			}
		}
	}
}


Measured memory_bytes: 92204
from itertools import combinations_with_replacement

N, M, Q = map(int, input().split(' '))
records = [tuple(map(int, input().split(' '))) for _ in range(Q)]

max_score = 0

for A in combinations_with_replacement(range(1, M + 1), r=N):
    A = sorted(A)
    score = 0
    for a, b, c, d in records:
        if A[b - 1] - A[a - 1] == c:
            score += d
    max_score = max(max_score, score)

print(max_score)


Measured memory_bytes: 9204
/* DELAPAN.3gp */
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
using namespace std;

#ifdef DEBUG
	#define debug(...) printf(__VA_ARGS__)
	#define GetTime() fprintf(stderr,"Running time: %.3lf second\n",((double)clock())/CLOCKS_PER_SEC)
#else
	#define debug(...) 
	#define GetTime() 
#endif

//type definitions
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vint;

//abbreviations
#define A first
#define B second
#define MP make_pair
#define PB push_back

//macros
#define REP(i,n) for (int i = 0; i < (n); ++i)
#define REPD(i,n) for (int i = (n)-1; 0 <= i; --i)
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for (int i = (a); (b) <= i; --i)
#define FORIT(it,c) for (__typeof ((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define ALL(a) (a).begin(),(a).end()
#define SZ(a) ((int)(a).size())
#define RESET(a,x) memset(a,x,sizeof(a))
#define EXIST(a,s) ((s).find(a) != (s).end())
#define MX(a,b) a = max((a),(b));
#define MN(a,b) a = min((a),(b));

inline void OPEN(const string &s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

/* -------------- end of DELAPAN.3gp's template -------------- */

char s[1111];

int main(){
	scanf("%s", s);
	int n = strlen(s);
	int r = 0, c = 0;
	int N = 0, E = 0, W = 0, S = 0;
	REP(i, n) {
		if (s[i] == 'N') {
			N = 1;
		} else if (s[i] == 'S') {
			S = 1;
		} else if (s[i] == 'W') {
			W = 1;
		} else if (s[i] == 'E') {
			E = 1;
		} else {
			assert(false);
		}
	}

	if (!(N ^ S) && !(W ^ E)) {
		puts("Yes");
	} else {
		puts("No");
	}
	
	return 0;
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int cnt[10005];

int main() {
	for (int x=1 ; x<=100 ; x++) {
		for (int y=1 ; y<=100 ; y++) {
			for (int z=1 ; z<=100 ; z++) {
				int br = x*x+y*y+z*z+x*y+y*z+z*x;
				if (br>10000) break;
				cnt[br]++;
			}
		}
	}
	int n;
	cin >>n;
	for (int i=1 ; i<=n ; i++) {
		cout <<cnt[i]<<'\n';
	}
	return 0;
}

Measured memory_bytes: 3624
l,r = map(int,input().split())
mod = 2019
line = (r // mod) * mod
if l*r < mod:
    print(l*r)
elif l < line < r:
    print(0)
else:
    ans = 0
    for i in range(l,r):
        for j in range(i+1,r+1):
            x = i * j
            x = x % mod
            if i==l and j==i+1:
                ans = x
            elif x < ans:
                ans = x
    print(ans)


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

public class Main{

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		int n=sc.nextInt();
		long k=sc.nextLong();
		long []a=new long [n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextLong();
		long value=0,num=0;
		for(int bit=60;bit>=0;bit--) {
			long x=1L<<bit;
			
			int zeros=0;
			for(long y:a)
				if((y&x)==0)
					zeros++;
			if(zeros>n-zeros && num+x<=k) {
				num+=x;
				value+=x*zeros;
			}
			else 
				value+=x*(n-zeros);
			
		}
		out.println(value);
		out.close();

	}
	
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 48200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+6;
const ll inf=1e15;
int n,a[N];
ll b[N];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<=n;i++) scanf("%d",&a[i]);
    b[0]=1;
    b[0]-=a[0];
    for(int i=1;i<=n;i++)
    {
        b[i]=b[i-1]*2;
        b[i]-=a[i];
        b[i]=min(b[i],(ll)inf);
    }
    for(int i=0;i<=n;i++)
        if(b[i]<0)
    {
        printf("-1\n");return 0;
    }
    ll ans=a[n],sum=a[n];
    for(int i=n-1;i>=0;i--)
    {
        sum=min(sum,b[i])+a[i];
        ans+=sum;
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 5000
#include <iostream>
#include <vector>
#include <cstring>



#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;

int main(){
    ll H,W;
    cin >> H >> W;
    string tmp;
    vector <string> S(H); 


    REP(i,H)
    {
        cin >> S[i];
    }

    ll delCnt = 0;

    bool flg = true;
    for(ll j = 0; j < S[0].size();j++)
    {
        flg = false;
        REP(i,H)
        {
            if(S[i][j] == '#')flg = true;
        }
        if(flg == false)
        {
            REP(i,H)
            {
                S[i].erase(j,1);
            }
            delCnt++;
            j--;
        }
    }

    //行削除
    REP(i,H)
    {
        flg = false;
        REP(j,W)
        {   
            if(S[i][j] == '#')flg = true;
        }

        if(flg == true)
        {
            cout << S[i] << endl;
        }
    }
}




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

using namespace std;

int main()
{
    long n;
    cin>>n;
    long arr[n+1],dp[n+1]={0};

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

    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
    {
        long small_jump,long_jump;
        long_jump = abs(arr[i-2]-arr[i]) + dp[i-2];
        small_jump = abs(arr[i-1]-arr[i]) + dp[i-1];

        if(long_jump>small_jump)
            dp[i] = small_jump;
        else
            dp[i] = long_jump;
    }

    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <vector>

const int N = 100001;

int n, m, l[N], r[N], diff[N], val[N], sum;
bool vis[N];
char s[N];
std::vector<int> graph[N];

void add_edge(int a, int b)
{
    graph[a].push_back(b);
    graph[b].push_back(a);
}

void dfs(int u)
{
    if (vis[u]) {
        return;
    }
    vis[u] = true;
    (sum += diff[u]) %= 26;
    for (auto v : graph[u]) {
        dfs(v);
    }
}

int main()
{
#ifdef LOCAL_JUDGE
    freopen("E.in", "r", stdin);
#endif
    scanf("%s", s);
    n = strlen(s);
    scanf("%d", &m);
    for (int i = 0; i < m; ++ i) {
        scanf("%d%d", l + i, r + i);
        l[i] --;
    }
    diff[0] = s[0] % 26;
    for (int i = 1; i < n; ++ i) {
        diff[i] = (s[i] % 26 + 26 - s[i - 1] % 26) % 26;
    }
    diff[n] = (26 - s[n - 1] % 26) % 26;
    for (int i = 0; i + i <= n; ++ i) {
        add_edge(i, n - i);
    }
    for (int i = 0; i < m; ++ i) {
        add_edge(l[i], r[i]);
    }
    bool ok = true;
    for (int i = 0; i < n && ok; ++ i) {
        if (!vis[i]) {
            sum = 0;
            dfs(i);
            ok &= !sum;
        }
    }
    puts(ok ? "YES" : "NO");
}



Measured memory_bytes: 9728
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;

typedef long double ld;
typedef long long int lli;
typedef pair <lli, lli> pii;
#define pb push_back
#define recout(x) return cout << (x), 0
#define f first
#define s second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
#define all(x) x.begin(), x.end()
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")
const lli N = 1e5 + 10, N2 = 2e5, delta = 46639, mod = 1e9 + 7, oo = 1e18, LOG = 20, SQ = 300;
const ld PI = 3.141592653589793;

lli dp[2][N];
vector <lli> v[N];

void dfs (lli x, lli par) {
	dp[0][x] = dp[1][x] = 1;
	for (auto u: v[x])
		if (u != par) {
			dfs (u, x);
			dp[0][x] *= ((dp[0][u] + dp[1][u]) % mod);
			dp[0][x] %= mod;
			dp[1][x] *= dp[0][u];
			dp[1][x] %= mod;
		}
}

int32_t main() {
	fast;
	lli n;
	cin >> n;
	for (lli i = 0; i < n - 1; i++) {
		lli x, y;
		cin >> x >> y;
		x--, y--;
		v[x].pb(y);
		v[y].pb(x);
	}
	dfs (0, -1);
	cout << (dp[0][0] + dp[1][0]) % mod << '\n';
	return 0;
}


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

int main(){
    int N,K; cin>>N>>K;
    ll R,S,P; cin>>R>>S>>P;
    string T; cin >>T;
    
    //高橋くんの出す手
    string taka="";
    ll ans=0;
    
    //int rl,sl,pl;
    rep(i,N){
        ll ik = i-K;
        bool ikflg = false;
        if(i-K>=0) ikflg = true;
        
        if(ikflg){
            if(T[i]=='r'){
                if(taka[ik]=='p'){
                    taka +='x';
                }else{
                    taka +='p';
                    ans +=P;
                }
            }
            
            if(T[i]=='s'){
                if(taka[ik]=='r'){
                    taka +='x';
                }else{
                    taka +='r';
                    ans +=R;
                }
            }
            if(T[i]=='p'){
                if(taka[ik]=='s'){
                    taka +='x';
                }else{
                    taka +='s';
                    ans += S;
                }
            }
            
        }
        
        if(!ikflg){
            if(T[i]=='r'){
                ans +=P;
                taka +='p';
            }
            if(T[i]=='s'){
                ans +=R;
                taka +='r';
            }
            if(T[i]=='p'){
                ans +=S;
                taka +='s';
            }
        }
        
    }
    
    //cout << taka << endl;
    cout << ans << endl;
}


Measured memory_bytes: 3752
n, x = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
# box = []
cnt = 0

for i in range(n):
    x = x - a[i]
    if(x >= 0):
        cnt += 1
    else:
        break
if(x != 0 and cnt == n):
    cnt -= 1
print(cnt)


Measured memory_bytes: 61804
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef pair <int, int> pii;


int main()
{
    int n;
    int ct = 0;
    cin >> n;
    for (int i = 1; i<=9; i++)
    {
        if (i<=n)
            ct++;
    }
    for (int i = 100; i<=999; i++)
    {
        if (i<=n)
            ct++;
    }
    for (int i = 10000; i<100000; i++)
    {
        if (i<=n)
            ct++;
    }
    cout << ct;
}

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

constexpr int MAX_N = 200000;
int A[MAX_N];
int lmax[MAX_N];
int rmax[MAX_N];

int main() {
  int N;
  std::cin >> N;
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  lmax[0] = A[0];
  for (int i = 1; i < N; ++i) {
    lmax[i] = std::max(lmax[i - 1], A[i]);
  }
  rmax[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; --i) {
    rmax[i] = std::max(rmax[i + 1], A[i]);
  }
  std::cout << rmax[1] << std::endl;
  for (int i = 1; i < N - 1; ++i) {
    std::cout << std::max(lmax[i - 1], rmax[i + 1]) << std::endl;
  }
  std::cout << lmax[N - 2] << std::endl;
  return 0;
}

Measured memory_bytes: 3968
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b

A, B, C, D = map(int, input().split())
E = C * D // gcd(C, D)

divc = B // C - (A - 1) // C
divd = B // D - (A - 1) // D
dive = B // E  - (A - 1) // E

print(B + 1 - A - (divc + divd - dive))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    if (S.size() == 3) reverse(ALL(S));
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3596