akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define PI 3.14159265359
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll dp[1023][100001];
int w[1000000];
int v[1000000];

int main() {
  int n, q;
  cin >> n;
  rep(i, n) {
    cin >> v[i] >> w[i];
  }

  rep(i, 100001) {
    dp[0][i] = (i < w[0] ? 0 : v[0]);
  }

  for (int i=1; i<min(n, 1023); i++) {
    rep(j, 100001) {
      dp[i][j] = max( dp[(i-1)/2][j], (j < w[i] ? 0 : dp[(i-1)/2][j-w[i]] + v[i]) );
    }
  }

  cin >> q;
  vector<P> query(q);
  rep(i, q) {
    cin >> query[i].first >> query[i].second;
  }
  rep(i, q) {
    int vid, l;
    vid = query[i].first - 1; l = query[i].second;

    if (vid < 1023) {
      cout << dp[vid][l] << endl;
    }

    else {
      vector<int> wt;
      int tsize = 0, tpow = 1;
      int vidt = vid;
      while (vidt >= 1023) {
        vidt = (vidt - 1) / 2;
        tsize++; tpow *= 2;
      }

      ll ans = 0;
      rep(j, tpow) {
        vidt = vid;
        ll vt = 0; int wt = 0;
        rep(k, tsize) {
          if ((j>>k) & 1) {
            vt += v[vidt]; wt += w[vidt];
          }
          vidt = (vidt - 1) / 2;
        }
        if (wt <= l) {
          ans = max( ans, vt + dp[vidt][l-wt] );
        }
      }
      cout << ans << endl;
    }
  }

/*  rep(i, min(n, 511)) {
    rep(j, 7) cout << dp[i][j] << " ";
    cout << endl;
  }*/

  return 0;
}

/*
*/


Measured memory_bytes: 805272
CP = 4
DP = 7

N = gets.strip.to_i

max = (N / CP) + 1

is_exist = false
max.times do |i|
  max.times do |j|
    if (i * CP) + (j * DP) == N  
      is_exist = true  
    end
  end
  break if is_exist
end
puts is_exist ? 'Yes' : 'No'


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n,i;
	cin>>n;
	int a,b,c;
	cin>>a>>b>>c;
	int dp[n][3];
	dp[0][0]=a;
	dp[0][1]=b;
	dp[0][2]=c;
	for(i=1;i<n;i++)
	{
		cin>>a>>b>>c;
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a;
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+b;
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+c;
	}
	cout<<max(dp[n-1][0],max(dp[n-1][2],dp[n-1][1]))<<endl;
	return 0;
}



Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    map<string, int> mp;

    rep(i, N) {
        string s;
        cin >> s;
        mp[s]++;
    }

    int res = 0;
    for(auto &p : mp) {
        res++;
    }

    cout << res << endl;
    

    return 0;
}

Measured memory_bytes: 19180
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[101000], K;
long long res;
int main() {
	int i;
	scanf("%d%d", &n,&K);
	for (i = 1; i <= n; i++) {
		scanf("%d", &w[i]);
		if (w[i] > K) {
			res += w[i] - K;
			w[i] = K;
		}
	}
	for (i = 2; i <= n; i++) {
		if (w[i] + w[i - 1] > K) {
			res += w[i] + w[i - 1] - K;
			w[i] = K - w[i - 1];
		}
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 512
n,k,s = map(int,input().split())
if s!=10**9:
  l = [s for i in range(k)]
  l1 = [10**9 for i in range(n-k)]
  print(*(l+l1))
  exit()
else:
  l = [s for i in range(k)]
  l1 = [1 for i in range(n-k)]
  print(*(l+l1))

Measured memory_bytes: 6688
/*AOJ 0011*/

#include<iostream>
#include<vector>

using namespace std;

int main(){
	int w,n;

	cin>>w;
	cin>>n;

	vector<int> a;
	vector<int> b;

	int ans[30];

	for(int i=0;i<n;i++){
		int tmp1,tmp2;
		scanf("%d,%d",&tmp1,&tmp2);
		a.push_back(tmp1-1);
		b.push_back(tmp2-1);
	}
	/*
	for(int i=0;i<n;i++){
		cout<<a[i]<<" "<<b[i]<<endl;
	}
	*/

	for(int i=0;i<w;i++){
		int point = i;

		for(int j=0;j<n;j++){
			if(point==a[j]){
				point = b[j];
			}
			else if(point==b[j]){
				point = a[j];
			}
		}
		ans[point] = i+1;
	}

	for(int i=0;i<w;i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}

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

const ll MAX = 510000;
const ll MOD = 1e9 + 7;

ll 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;
  }
}

ll 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();
  ll ans = COM(H + W - 2, W - 1);
  for (int i = 1; i <= B; i++) {
    ll a = COM(H - A - 1 + i - 1, i - 1);
    ll b = COM(A - 1 + W - i, W - i);
    ans = (ans + MOD - a * b % MOD) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12160
#include<iostream>

using namespace std;

long long dict[] = {3, 5, 7};

long long to753(long long x, int digits){
  long long base = 1, ret = 0;
  for(int i = 0; i < digits; i++){
    ret += base * dict[x % 3];
    base *= 10;
    x /= 3;
  }
  return ret;
}

bool is_753(long long x, int digits){
  bool check[3] = {};
  for(int i = 0; i < digits; i++){
    check[x % 3] = true;
    x /= 3;
  }
  return check[0] && check[1] && check[2];
}

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

  long long res = 0, end = 3;
  for(int digits = 1; digits <= 10; digits++){
    for(int i = 0; i < end; i++){
      if(!is_753(i, digits)){
	continue;
      }
      long long now = to753(i, digits);
      if(now > N){
	cout << res << endl;
	return 0;
      }
      res++;
    }
    end *= 3;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
 
#define rep(i,n) for(int i=0; i<n; ++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define repp(i,a,b) for(int i=a; i<=b; ++i)
#define repr(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define endl '\n'
#define fi first
#define INF 0x3f3f3f3f
#define se second
#define pb push_back
#define MAXN 1002
 
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)for(long blockTime=0;(blockTime==0?(blockTime=clock())!=0:false); debug("%s:%.4fs\n",d,(double)(clock()-blockTime)/CLOCKS_PER_SEC))
 
const ll mod = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	
	int a;
	cin >> a;
	
	repp(i, 1, 9)
		repp(j, 1, 9) {
			if(a == i*j) {
				cout << "Yes\n";
				return 0;
			}
		}
	
	cout << "No\n";
	return 0;
}



Measured memory_bytes: 256
import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

x, y = na()
for t in range(100):
    for k in range(100):
        if x == (t + k) and y == 2*t + 4*k:
            print("Yes")
            quit()
print("No")



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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	int v = 0;
	for(int i = 0; i < n; ++i){
		if(s[i] == 'I'){
			v++;
		}
		else{
			v--;
		}
		ans = max(ans, v);
	}
	
	cout << ans << endl;
	
	return 0;
}



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

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//#define int long long
#define ln '\n'
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define P(p) cout << (p) << endl;
#define S(s) cin << (s);
#define reps(i,a,b) for(int (i)=(a); (i)<(b); ++(i))
#define rep(i,n) reps(i,0,n)
#define repst(i,a,b) rep(i,s,(n)+1)
#define rept(i,n) rep(i,(n)+1)
#define reprt(i,a,b) for(int (i)=(a); (i)>=(b); --(i))
#define repr(i,n) reprt(i,n,0)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define debug(x) cerr << #x << ": " << x << '\n'
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

typedef unsigned usd;
typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<unsigned> vus;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;
const double EPS = 1e-9;
const double PI  = acos(-1.0);

/*********TEMPLATE**********/

int main() {

  int i, j, n, k;
  cin >> n;

  rep(j,n) {
    vus N(9);
    cin >> hex >> N[0] >> N[1] >> N[2] >> N[3] >> N[4] >> N[5] >> N[6] >> N[7] >> N[8];
    usd K = 0;
    rep(m,32) {
      i = 1;
      usd checksum = accumulate(all(N),0) - N.back();
      if ((checksum >> m & 1) != (N.back() >> m & 1)) K |= 1 << m;
      rep(k,9) N[k] ^= K & 1 << m;
    }
    cout << hex << K << endl;
  }

  return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<cstdio>
#include<vector>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mem(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define pb push_back
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mod=1e9+7;
const double eps=1e-8;
const int inf=0x3f3f3f3f;
const int N=2e5+10;
int main()
{
	int n,m,q,k;
	string s;
	cin>>s;
	if(s=="ABC") cout<<"ARC";
	else cout<<"ABC";
}


Measured memory_bytes: 3624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

class CCitySavers {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> A(n + 1), B(n);
    for (auto &a: A) cin >> a;
    for (auto &b: B) cin >> b;

    int64_t ans = 0;

    for (int i = n; i > 0; i--){
        ans += min(A[i], B[i - 1]);
        B[i - 1] = max(0, B[i - 1] - A[i]);
        ans += min(A[i - 1], B[i - 1]);
        A[i - 1] = max(0, A[i - 1] - B[i - 1]);
    }

    cout << ans << endl;
}
};

int main() {
	CCitySavers solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1152
def primes(m):
    res=[]
    a=[True for i in range(m)]
    a[0]=a[1]=False
    for i in range(2,m):
        if a[i]:
            if i%5==1:
                res.append(i)
            times=2
            while i*times<m:
                a[i*times]=False
                times+=1
    return res

N=int(input())
prime=primes(55555)
for num in prime[:N]:
    print(str(num)+" ",end="")
print()




Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
#define deb(x) cout << #x << ':' << x << endl; 
#define loop3(i, k, n) for(i=k; i<n; i++)
#define ll  long long int
#define loop(i,n) for(int i=0;i<n;i++)
#define loop2(i,n) for(int i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define v1d vector<ll> 
#define v2d vector<vector<ll>>
 
const int INF = 1e9 +5 ; 
 
 
int main()
{
    ll n,k;
    cin>>n>>k;
    v1d v(n);
    ll i;
    loop(i,n)
        cin>>v[i];
    v1d dp(n,INF);
    dp[0] = 0;
    loop(i,n)
    {
        for(int j = i+1; j<=i+k; j++)
        {
            if(j<n)
            {
                //deb(j);
                dp[j] = min(dp[j],dp[i] + abs(v[i] - v[j]));
            
            }
        }
    
    }
    cout<<dp[n-1];
}   
 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int A[4] = {}; 
	cin >> A[0] >> A[1] >> A[2] >> A[3]; 
	sort(A, A+4); 
	if(A[0] == 1 && A[1] == 4 && A[2] == 7 && A[3] == 9) cout << "YES" << endl;  
	else cout << "NO" << endl; 
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			String s = in.nextString();
			int n = s.length();
			int k = in.nextInt();

			Set<String> set = new HashSet<>();
			for (int i = 0; i < n; i++) {
				for (int j = 1; j <= 5; j++) {
					if (i + j > n) continue;
					set.add(s.substring(i, i+ j));
				}
			}
			List<String> list = new ArrayList<>(set);

			Collections.sort(list);
			out.println(list.get(k-1));
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 26040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#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()
{
    long n;
    string s, forward = "", back = "", reverseStr;

    cin >> s;

    ll half = s.length() / 2;
    ll length = half / 2;
    bool flag = true;

    rep(i, s.length())
    {
        if (i < half)
        {
            forward.push_back(s[i]);
        }
        else if (i > half)
        {
            back.push_back(s[i]);
        }
    }
    reverseStr = forward;
    reverse(reverseStr.begin(), reverseStr.end());
    if (forward == reverseStr && forward == back)
        flag = false;

    cout << (flag ? "No" : "Yes") << endl;
}

Measured memory_bytes: 256
a = Array.new(3).map { Array.new(3, nil) }
c = Array.new(3).map { Array.new(3, false) }
(0..2).each do |i|
  a[i][0], a[i][1], a[i][2] = gets.chomp.split(" ").map(&:to_i)
end

n = gets.chomp.to_i
b = Array.new(n)

(0..n - 1).each do |i|
  b[i] = gets.chomp.to_i
end

a.each.with_index do |rowelem, row|
  rowelem.each.with_index do |colelem, col|
    if b.include?(colelem)
      c[row][col] = true
    end
  end
end

c_t = c.transpose
naname1 = [c[0][0], c[1][1], c[2][2]]
naname2 = [c[0][2], c[1][1], c[2][0]]

if c[0].all? || c[1].all? || c[2].all? ||
   c_t[0].all? || c_t[1].all? || c_t[2].all? ||
   naname1.all? || naname2.all?
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 3836
N = int(input())
A = list(map(int, input().split()))
arr = {}
for i in range(N):
  arr[A[i]] = i + 1
for i in range(N):
  print(arr[i+1], end="")
  if i == N-1:
    print("\n", end="")
  else:
    print(" ",end="")

Measured memory_bytes: 20704
package main

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

func main() {
	a := nextInt()
	b := nextInt()
	h := nextInt()

	fmt.Println((a + b) * h / 2)
}

var s = bufio.NewScanner(os.Stdin)

func next() string {
	s.Split(bufio.ScanWords)
	s.Scan()
	return s.Text()
}

func nextValue() string {
	s.Scan()
	return s.Text()
}

func nextInt() int {
	s.Scan()
	i, _ := strconv.Atoi(s.Text())
	return i
}

func nextLine() string {
	s.Split(bufio.ScanLines)
	s.Scan()
	return s.Text()
}


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

using namespace std;

#ifndef aa
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double ld;
#define double long double
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frev(a,b,c) for(int a=c; a>=b; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
#define deb(x) cout << x << endl
#define done(x) {cout << x << endl;return;}
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
//const int mod = 998244353;
const int mod = 1e9 + 7;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pair<int, int>> vpii;
typedef map<int, int> mii;
typedef set<int> si;
typedef set<pair<int,int>> spii;
typedef queue<int> qi;


const int N = 1e6 + 5;

void solve() {

  int n,ans=0;
  cin>>n;
  vi a(n);
  rep(i,0,n)
   cin>>a[i];
  sort(all(a));
  rep(i,0,n)
   rep(j,i+1,n)
     rep(k,j+1,n)
       ans+=a[i]^a[j]&&a[j]^a[k]&&a[k]<a[i]+a[j];
  cout<<ans;
   
}


signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(15);
    int t = 1;
    //cin >> t;

    while (t--)
        solve();
#ifdef aa
    cout << endl << endl << endl << endl << "Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;
#endif
    return 0;
}




int powm(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = (res*a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return res;
}


int divide(int a, int b) {
    return (a % mod) * powm(b, mod - 2) % mod;
}

int norm(int a) {
    while (a >= mod) a -= mod;
    while (a < 0) a += mod;
    return a;
}


int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
#define rep(i,a,n)  for (int i=(int)(a); i<=(int)(n); ++i)
#define rrep(i,a,n) for (int i=(int)(a); i>=(int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size()-1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 30) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N,M,K,X,Y;
int a,b,c,d;
string S,T;
vector<int> A,B;
//=============================
void input()
{
    cin>>S;
    cin>>T;
}
//=============================
void func(){}
/*
 - 樹形図をかく
*/
//=============================
void solve()
{
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());

    if (S < T) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 200000;
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;
}
struct edge {
	int t;
	ll cost;
	edge(int _t, ll _cost) : t(_t)
		, cost(_cost) {
	}
};
bool isPrime(int n) {

	if (n == 1) return false;
	for (ll i = 2; i * i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}
void Solve() {
	
	ll a, b, c;
	cin >> a >> b >> c;
	int res = 0;
	if (a == b && a == c) {
		if (a % 2 == 0) {
			cout << -1 << endl;
		}
		else {
			cout << 0 << endl;
		}
		return;
	}
	while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0)
	{
		int halfa = a / 2;
		int halfb = b / 2;
		int halfc = c / 2;
		a = halfb + halfc;
		b = halfa + halfc;
		c = halfa + halfb;

		res++;
		if (res == 50) {
			break;
		}
	}
	
	cout << res << endl;
}
int main() {
	Solve();
	return 0;
}



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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n;
LL a[N];
LL k;

LL f(LL x)
{
	LL ans = 0;
	FOR(i, 0, n)
	{
		if (a[i] == 0)
		{
			if (x >= 0) ans += n - i - 1;
			continue;
		}
		
		if (a[i] > 0)
		{
			if (a[i] * a[i] > x) continue;
			auto it = upper_bound(a, a + n, x / a[i]) - a;
			ans += it - i - 1;
			continue;
		}
		
		if (a[i] < 0 && (i != n - 1))
		{
			if (a[i] * a[i + 1] <= x) 
			{
				ans += n - 1 - i;
				continue;
			}
			
			int l = i + 1, r = n, m;
			while(r - l > 1)
			{
				m = (l + r) >> 1;
				if (a[i] * a[m] <= x)
					r = m;
				else
					l = m;
			}
			
			ans += n - r;
		}
	}
	
	return ans;	
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n >> k;
	FOR(i, 0, n) cin >> a[i];
	sort(a, a + n);
	LL l = -LINF, r = LINF, m;
	//f(l) = 0, f(r) = n * (n - 1) / 2
	
	while(r - l > 1)
	{
		m = (l + r) >> 1;
		if (f(m) >= k)
			r = m;
		else 
			l = m;
	}
	
	cout << r << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include <map>
using namespace std;
typedef long long int ll;
#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define all(u) u.begin(),u.end()
#define pl pair<ll,ll>
#define fi first
#define se second
#define inf 1000000007
#define mp(a,b) make_pair(a,b)


ll V[25];
ll C[25];
ll t[25];
ll N;


int main() {
    cin >> N;
    rep(i,N){
        cin >> V[i];
    }
    rep(i,N){
        cin >> C[i];
    }
    ll ans = 0;
    rep(i,N){
        t[i] = V[i]-C[i];
        if (t[i] > 0){
            ans += t[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

iStock = 0
iMoney = 1000

for i in range(N-1):
    if A[i] < A[i + 1]:
        # A[i]Day 株購入 & A[i+1]Day 株売却
        iStock = iMoney // A[i]
        iMoney %= A[i]
        iMoney += iStock * A[i+1]
print(iMoney)

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

using namespace std;

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

    int n; cin >> n;
    string s; cin >> s;

    int ans = 0;
    for (int i = 0; i < n - 2; ++i) {
        if (s.substr(i, 3) == "ABC") ++ans;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
a, b = map(int, input().split())
count = 0
for i in range(a, b+1):
    num = str(i)
    if len(num) % 2 == 1:
        if num[:len(num)//2] == num[len(num)//2+1:][::-1]:
            count += 1
            continue
    else:
        if num[:len(num)/2] == num[len(num)/2+1:][::-1]:
            count += 1
            continue
print(count)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int dec(void* a,void* b){
  return *(int*)b - *(int*) a;
}

int main(){
  int K,N,V[51],maxim,sum1,sum2,ind;
  int list[51][51],index[50],index2[50]={0};
  scanf("%d %d",&N,&K);
  for(int i = 0;i < N;i++){
    scanf("%d",&V[i]);
  }
  sum1=0;
  for(int i = 0;i <= N;i++){
    sum2 = 0;
    for(int j = 0;j <= N-i;j++){
      list[i][j] = sum1+sum2;
      if(j != N){sum2 += V[N-j-1];}
    }sum1 += V[i];
  }
  for(int i = 0;i < N;i++){
    maxim = 10000001;ind=-1;
    for(int j = 0;j < N;j++){
      if(index2[j] == 0&&maxim > V[j]){ind=j;maxim = V[j];}
    }index[i] = ind;index2[ind] = 1;
  }
  maxim = 0;
  for(int i = 0;i <= N;i++){
    for(int j = 0;j <= N-i;j++){
      sum1 = 0;sum2 = list[i][j];
      for(int k = 0;k < N;k++){
        if(sum1 >= K-i-j){break;}
        if((index[k] <i||index[k] >= N-j)&&V[index[k]] < 0){sum2-=V[index[k]];sum1++;}
      }
      if(maxim < sum2&&i+j<=K){maxim = sum2;}
    }
  }
  printf("%d\n",maxim);
  return 0;
}

Measured memory_bytes: 128
use std::cmp;

fn main(){
  loop {
    let m:usize = read();
    let n:usize = read();

    if m == 0 && n == 0 { break; }

    let mut iv: Vec<Vec<u32>> = vec![vec![0;m+2]; n+2];

    for i in 1 .. n+1 {
      let tv: Vec<u32> = read_vec();
      for j in 0 .. m {
        iv[i][j+1] = tv[j];
      }
    }

    let mut ans: u32 = 0;

    for i in 1 .. n+1 {
      for j in 1 .. m+1 {
        ans = cmp::max(ans, dfs(&mut iv, i, j));
      }
    }

    println!("{}", ans);
    // println!("{:?}, {:?}, {:?}, {:?}, {:?}", dfs(&mut iv, 1, 1), 1, 11, 111, 1111);
  }
  // let x: u32 = read();
  // let y: i64 = read();
  // let z: f64 = read();
  // let a: String = read();
  // let b: Vec<u32> = read_vec();
  // println!("{:?}, {:?}, {:?}, {:?}, {:?}", x, y, z, a, b);
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn dfs(v: &mut Vec<Vec<u32>>, h: usize, w: usize) -> u32 {
  if v[h][w] == 0 {
    0
  } else {
    v[h][w] = 0;
    
    let l0 = dfs(v, h+1, w);
    let l1 = dfs(v, h, w+1);
    let l2 = dfs(v, h-1, w);
    let l3 = dfs(v, h, w-1);

    v[h][w] = 1;

    1 + cmp::max(
          cmp::max(l0, l1),
          cmp::max(l2, l3))
  }
}



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

int main(){
    vector<int> num(3);
    cin >> num[0] >> num[1] >> num[2];
    sort(num.begin(), num.end());
    int ans = num[2]-num[1];
    ans += (num[1]-num[0])/2;
    if((num[1]-num[0])%2==1){
        ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#coding:utf-8

def validate(N, points, c_x, c_y):
    #estimate height
    for n in range(N):
        h = points[n][2]
        if h != 0:
            x = points[n][0]
            y = points[n][1]
            estimated_height = h + abs(c_x - x) + abs(c_y - y)

    #validate height
    for n in range(N):
        x = points[n][0]
        y = points[n][1]
        h = points[n][2]
        height = max(estimated_height - abs(c_x - x) - abs(c_y - y), 0)

        if h != height:
            return -1
    return estimated_height

if __name__ == "__main__":
    N = int(input())
    points = [None] * N
    for n in range(N):
        x, y, h = map(int, input().split())
        points[n] = [x, y, h]

    candidates = [i for i in range(101)]
    for c_x in candidates:
        for c_y in candidates:
            height = validate(N, points, c_x, c_y)
            if height != -1:
                print(c_x, c_y, height)
                break


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>

int main()
{
	int N = 0, D = 0, ans = 0;
	double C = 0;

	std::cin >> N >> D;

	C = N / (2.0 * D + 1.0);

	ans = (int)(ceil(C));

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define int long long
#define ld long double
#define sb __builtin_popcount
#define vi vector<int>
#define vc vector<char>
#define ii pair<int, int>
#define pq priority_queue<ii, vector<ii>, greater<ii>>
#define vii vector<ii>
#define sz(a) int((a).size())
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <=n; i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rloop(i,a,b) for(int i=a;i>=b;i--)
#define in(a, b) (b.find(a) != string::npos)
#define minin(a) *min_element(all(a))
#define maxin(a) *max_element(all(a))
#define X first
#define Y second
#define fill(a, x) memset(a, x, sizeof(a))
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define rall(v) reverse(v.begin(), v.end())
#define el "\n"
#define mx3(a, b, c) max(max(a, b), c)
#define mn3(a, b, c) min(min(a, b), c)
#define S(v) accumulate(all(v), (ll)0)
#define SP(n) cout.precision(n)
#define PI = atan(1.0) * 4.0;
#define MOD = 1e9 + 7;
void start() {
    fio;
    SP(10);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
    start();
    int n, d;
    cin >> n >> d;
    int ans = 0;
    int x, y;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (x * x + y * y <= d * d)ans++;
    }
    cout << ans << el;
    return 0;
}


Measured memory_bytes: 3648
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        x: usize, y: usize, z: usize, k: usize,
        mut a: [i64; x],
        mut b: [i64; y],
        mut c: [i64; z],
    }
    a.sort();
    b.sort();
    c.sort();

    let mut que = BinaryHeap::new();
    let sum = a[x-1] + b[y-1] + c[z-1];
    que.push((sum, x-1, y-1, z-1));
    let mut memo = HashSet::new();
    let mut count = 0;
    while let Some((sum, x, y, z)) = que.pop() {
        if count == k {
            break;
        }
        if memo.contains(&(x, y, z)) {
            continue;
        }
        count += 1;
        println!("{}", sum);
        memo.insert((x, y, z));
        let x2 = x.saturating_sub(1);
        let y2 = y.saturating_sub(1);
        let z2 = z.saturating_sub(1);
        que.push((a[x2] + b[y] + c[z], x2, y, z));
        que.push((a[x] + b[y2] + c[z], x, y2, z));
        que.push((a[x] + b[y] + c[z2], x, y, z2));
    }

}


Measured memory_bytes: 2464
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void _main() {
  int N, A, B;
  cin >> N >> A >> B;

  int a=0, b=0, c=0;
  rep(i, 0, N) {
    int in;
    cin >> in;
    if (in <= A) a++;
    else if (in <= B) b++;
    else c++;
  }
  int ans = a;
  chmin(ans, b);
  chmin(ans, c);
  cout << ans << "\n";
}

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

using namespace std;

int h[4], w[4];
char tet[4][4][4];
char c[10][4], d[10][4];
int n;

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

  for(int i = 0; i < 4; i++){
    cin >> h[i] >> w[i];
    for(int y = 0; y < h[i]; y++){
      for(int x = 0; x < w[i]; x++){
        cin >> tet[i][x][y];
      }
    }
  }
  cin >> n;
  for(int q = 0; q < n; q++){
    for(int y = 0; y < 4; y++){
      for(int x = 0; x < 10; x++){
        cin >> c[x][y];
      }
    }
    int perm[4];
    for(int i = 0; i < 4; i++) perm[i] = i;
    bool ans = false;
    do{
      for(int y = 0; y < 4; y++){
        for(int x = 0; x < 10; x++){
          d[x][y] = c[x][y];
        }
      }
      int nx = 0;
      for(int y = 0; y < 4; y++){
        for(int x = 0; x < 10; x++){
          if(nx == 3) goto end;
          int id = perm[nx];
          if(x+w[id] > 10 || y+h[id] > 4) continue;
          bool flag = true;
          for(int i = 0; i < w[id]; i++){
            for(int j = 0; j < h[id]; j++){
              if(tet[id][i][j] == '#' && d[x+i][y+j] == '#'){
                flag = false;
                goto end2;
              }
            }
          }
          end2:;
          if(!flag) continue;
          for(int i = 0; i < w[id]; i++){
            for(int j = 0; j < h[id]; j++){
              if(tet[id][i][j] == '#') d[x+i][y+j] = '#';
            }
          }
          nx++;
        }
      }
      end:;
      if(nx == 3){
        ans = true;
        break;
      }
    }while(next_permutation(perm, perm+4));

    if(ans) cout << "Yes" << "\n";
    else cout << "No" << "\n";
  }
  flush(cout);

  return 0;
}



Measured memory_bytes: 3216
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

// Binary indexed Tree(BIT)
template <typename T>
struct BIT{
    private:
    vector<T> array;
    const int n;

    public:
    // 初期化
    BIT(int _n) : array(_n+1,0),n(_n) {}

    // 1番目からi番目までの累積和を求める
    T sum(int i){
        T s = 0;
        while(i > 0){
            s += array[i];
            // LSB減算
            i -= i & -i;
        }
        return s;
    }
    
    // [i,j]の要素の総和
    T sum(int i,int j){
        // 1番目からi-1番目までの総和
        T ret_i = sum(i-1);
        // 1番目からj番目までの総和
        T ret_j = sum(j);
        // i番目からj番目までの総和
        return ret_j - ret_i;
    }

    // i番目に要素xを追加
    void add(int i,T x){
        while(i <= n){
            array[i] += x;
            // LSB加算
            i += i & -i;
        }
    }
};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++){
      cin >> A[i];
    }
    vector<ll> S(N+1,0);
    for(int i=0; i<N; i++){
      S[i+1] = S[i] + (A[i]-K);
    }
    vector<ll> temp;
    temp = S;
    sort(temp.begin(),temp.end());
    temp.erase(unique(temp.begin(),temp.end()),temp.end());
    for(int i=0; i<=N; i++){
      S[i] = lower_bound(temp.begin(),temp.end(),S[i]) - temp.begin();
    }
    // for(int i=0; i<=N; i++){
    //   cout << S[i] << " \n"[i==N];
    // }
    BIT<int> bit(N+5);
    ll ans = 0;
    for(int i=0; i<=N; i++){
      ans += bit.sum(S[i]+1);
      bit.add(S[i]+1,1);
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7952
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
	
    ll i,n,t,k,j,x=0,y=0,m;

    ll a[sz*2];
    cin>>n;
    for(i=0;i<n;i++)
    {
    	cin>>a[i];
    }
    for(i=1;i<n;i++)
    {
    	if(a[i]<a[i-1])
    	{
    		x+= a[i-1]-a[i];
    		a[i]  =a[i-1];
    	}
    }
    cout<<x<<endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

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

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

  ll x;
  cin >> x;

  ll ans = 0;
  if(x >= 11){
    ans += 2 * (x / 11);
    x = x % 11;
  }

  if(x == 0){
    ans += 0;
  }else if(x <= 6){
    ans += 1;
  }else{
    ans += 2;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;
#define all(x) x.begin(),x.end()
const ll INF = 1e9;
const ll mod = 1e9 + 7;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    return ((a * b == 0)) ? 0 : (a / gcd(a,b) * b);
}

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


/////////////////////////////////////////////////////////////////////////////////////////

vector<pair<long long,long long>> prime_fact(ll n){
    vector<pair<long long,long long>> res;

    for (ll i = 2;i * i <= n;i++){
        if (n % i != 0) continue;
        ll num = 0;
        while(n % i == 0){
            num++;
            n /= i;
        }
        res.push_back(make_pair(i,num));
    }

    if (n != 1) res.push_back(make_pair(n,1));
    return res;
}

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

    ll a,b;
    cin >> a >> b;
    ll g = gcd(a,b);

    auto ans = prime_fact(g);

    cout << ans.size() + 1 << endl;
    return 0;
}


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

int main()
{
	stack<bool> st;
	string str;
	cin >> str;

	int ans = 0;
	for( char c : str )
	{
		bool bit = c - '0';
		if( st.empty() )
		{
			st.push( bit );
			continue;
		}

		if( st.top() ==  bit )
		{
			st.push( bit );
		}
		else
		{
			st.pop();
			ans += 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


ll f(ll b, ll n){
  if(n<b) return n;
  return f(b,n/b)+n%b;
}


signed main(){
  ll h,w,n; cin>>h>>w>>n;
  ll ans = n/max(h,w);

  if(n%max(h,w)>0) ans++;
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

#define MAX_N 2000001
#define MAX_K 10001

void countingSort(int,int*);

int A[MAX_N],B[MAX_N];

int main(){
  int n,i;
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",A+i);
  }
  countingSort(n,A);
  return 0;
}

void countingSort(int n,int *A){
  int i,C[MAX_K] = {0};
  for(i = 0 ; i < n ; i++){ C[A[i]]++; }
  for(i = 1 ; i < MAX_K ; i++){ C[i] += C[i-1]; }
  for(i = n-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i]; C[A[i]]--;
  }
  for(i = 0 ; i < n ; i++){
    printf("%d%c",B[i+1],i < n-1 ? ' ' : '\n');
  }
}

Measured memory_bytes: 16272
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	vector<int> heights(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> heights[i];
	}

	vector<vector<int> > roads(n + 1, vector<int> ());
	int a, b;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		roads[a].push_back(b);
		roads[b].push_back(a);
	}

	int good = 0;
	for (int i = 1; i <= n; ++i) {
		int peak = 0;
		for (int j = 0; j < (int) roads[i].size(); ++j) {
			peak = max(peak, heights[roads[i][j]]);
		}

		if (heights[i] > peak) {
			++good;
		}
	}

	cout << good << "\n";

	return 0;

}

Measured memory_bytes: 8676
import java.util.*;
 
class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    int[] x = new int[5];
    int index = 0;
    for(int i=0; i<5; i++){
      x[i] = sc.nextInt();
      if(x[i] == 0){
        index = i+1;
      }
    }
    System.out.println(index);

    sc.close();
  }
}


Measured memory_bytes: 35704
import java.util.*;

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

		List<String> list = new ArrayList<String>();
		for(int i=0; i<n; i++){
			String str = sc.next();
			list.add(str);
		}
		Map<String, Integer> map = new HashMap<>();
		map.put("AC",0);
		map.put("WA",0);
		map.put("TLE",0);
		map.put("RE",0);
		for (String key : list) {
    		Integer i = map.get(key);
    		map.put(key, i + 1);
		}
		System.out.println("AC x "+map.get("AC"));
		System.out.println("WA x "+map.get("WA"));
		System.out.println("TLE x "+map.get("TLE"));
		System.out.println("RE x "+map.get("RE"));
	}
}


Measured memory_bytes: 54660