akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<ll> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//const ll mod = 1e10;
//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;



int main() {
    int n;
    cin >> n;
    vector<ll> mis(n), mas(n);
    rep(i, n) cin >> mis[i] >> mas[i];


    auto h = [](int n, vector<ll> v) -> ll {
        sort(v.begin(), v.end());
        if (n % 2 == 0) {
            return (v[n / 2] + v[n / 2 - 1]);
        } else {
            return v[n / 2];
        }
    };


    ll a = h(n, mis), b = h(n, mas);

    ll ans = b - a + 1;
    cout << ans << endl;

}

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

const int nlimit=100, vmax=100;
int n;
long long int wsum;
int v[nlimit+1], w[nlimit+1];

int main(){
  cin >> n >> wsum;
  for(int i=1; i<=n; i++){
    cin >> v[i] >> w[i];
  }

  long long int dp[n+1][n*vmax+1];
  fill(dp[0], dp[0]+n*vmax+1, LLONG_MAX>>10);
  dp[0][0]=0;

  for(int i=1; i<=n; i++){
    for(int j=0; j<=n*vmax; j++){
      if(j<v[i]){
        dp[i][j] = dp[i-1][j];
      }else{
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i]] + w[i]);
      }
    }
  }
  
  int res=0;
  for(int i=0; i<=n*vmax; i++){
    if(dp[n][i]<=wsum) res=i;
  }

  cout << res << endl;

  return 0;
}



Measured memory_bytes: 11004
#include <iostream>
#include <vector>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

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

  int a[N];
  REP(i,N){
    cin >> a[i];
  }

  ans = 0;
  FOR(i,1,N){
    if(a[i] == a[i-1]){
      ans++;
      a[i] = 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 基本はdouble
//map<キー,値> p は辞書。p[キー] = 値
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}


int main() {
	int N, K, X, Y; cin >> N >> K >> X >> Y;
	if (N <= K)cout << X * N << endl;
	else cout << X * K + Y * (N - K) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n, a[4][3][10] = { {{0}} },b,f,r,v,i;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf(" %d %d %d %d", &b, &f, &r, &v);
		a[b-1][f-1][r-1] = a[b-1][f-1][r-1] + v;
	}
	for (b = 0; b < 4; b++)
	{
		for (f = 0; f < 3; f++)
		{
			for (r = 0; r < 10; r++)
			{
				printf(" %d", a[b][f][r]);
			}
			printf("\n");
		}
		if (b != 3)
		{
			printf("####################\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
def solve(string):
    k = int(string)
    if k % 2 == 0 or k % 5 == 0:
        return "-1"
    n = 7
    for i in range(k):
        if not n % k:
            return str(i + 1)
        n = (10 * n + 7) % k


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))


Measured memory_bytes: 9164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

struct con {
	int s, t, x;
};
bool operator<(const con& p1, const con& p2) {
	return p1.x < p2.x;
}
vector<con>v;
int q[200020];
set<int>st;
map<int, int>mp;
signed main() {
	int N, Q; cin >> N >> Q;
	v.resize(N);
	REP(i, N) {
		int s, t, x; cin >> s >> t >> x;
		t--;
		s -= x, t -= x;
		//pe(s)pe(t)print(x);
		v.push_back({ s,t,x });
	}
	//cout << endl;
	REP(i, v.size()) {
		//pe(v[i].s)pe(v[i].t)print(v[i].x);
	}
	REP(i, Q) {
		cin >> q[i];
		st.insert(q[i]);
	}
	VSORT(v);
	for (auto x : st) {
		mp[x] = -1;
	}
	st.insert(-INF); st.insert(INF);
	FOR(i, v.size() / 2 , v.size()) {
		int l = v[i].s, r = v[i].t;
		
		auto itr1 = st.lower_bound(l);
		auto itr2 = st.upper_bound(r);
		//pe(l)pe(r)print(v[i].x);
		//pe(*itr1)print(*itr2);
		vector<int>pos;
		while (itr1 != itr2) {
			pos.pb(*itr1);
			mp[*itr1] = v[i].x;
			itr1++;;
		}
		REP(j, pos.size()) {
			auto x = st.erase(pos[j]);
		}
	}
	REP(i, Q) {
		print(mp[q[i]]);
	}
}

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

int	main()
{
  int	n, x, m_min, iv;
  vector<int> m;
  
  cin >> n >> x;  
  cin >> iv;
  m.push_back(iv);
  m_min = m.at(0);
  for (int i = 1; i < n; i++)
  {
    cin >> iv;
    m.push_back(iv);
    if (m.at(i) < m_min)
      m_min = m.at(i);
  }
  cout << n + (x - accumulate(m.begin(), m.end(), 0)) / m_min << endl;
  return (0);
}

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    cout << (n-2) * 180 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{    
    int a,b,c;      
    public void yatary() {        
        Scanner sc = new Scanner(System.in);        
        a =sc.nextInt(); 
        b =sc.nextInt(); 
        c =sc.nextInt(); 
        if(a < b && b <c){
            System.out.println("Yes");
       }else{
            System.out.println("No");
       }   
    } 
    public static void main(String[] args){  
        new Main().yatary();   
    }
}

Measured memory_bytes: 17156
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define per(i,n) for(int i=(n)-1; i>=0; i--)
#define chmin(a,b) a = min(a,b)
#define chmax(a,b) a = max(a,b)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
const int MOD = 1000000007;

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    
    vector<ll> a(n+1,0), b(m+1,0);
    
    rep(i,n){
        cin>>a[i+1];
        a[i+1] += a[i];
    }
    
    
    rep(i,m){
        cin>>b[i+1];
        b[i+1] += b[i];
    }
    
    int ans = -1;
    
    int jbest = m;
    
    for(int i=0; i<=n; i++){
        for(int j=jbest; j>=0; j--){
            if(a[i]+b[j]<=k){
                ans = max(ans, i+j);
                jbest = j;
                break;
            }
        }
    }
    
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 6432
#include <bits/stdc++.h>
using namespace std;
char maze[21][21];
#define r(z,x) for(int z=0;z<x;z++)
int ans,a,b;
void bfs(int x,int y){
	int dx[4]={0,-1,0,1},dy[4]={1,0,-1,0};
	maze[x][y]='#',ans++;
	r(i,4)if(maze[x+dx[i]][y+dy[i]]=='.')bfs(x+dx[i],y+dy[i]);
}
int main(){
	while(cin>>a>>b,a||b){
		ans=0;
		fill(maze[0],maze[20],'#');
		r(i,b)r(j,a)cin>>maze[i][j];
		r(i,b)r(j,a)if(maze[i][j]=='@')bfs(i,j),cout<<ans<<endl;
	}
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int n, x;
ll vi[2 * 100100];
bool used[2 * 100100];

int main() {
	cin >> n >> x;
	fill(vi, vi + 2 * 100100, 0);
	fill(used, used + 2 * 100100, false);
	if (n == 2) {
		if (x == 2) {
			cout << "Yes" << endl;
			rep(i, 3)cout << i + 1 << endl;
		}
		else cout << "No" << endl;
	}
	else {
		if (x == 2 * n - 1 || x == 1)cout << "No" << endl;
		else {
			cout << "Yes" << endl;
			if (x != 2) {
				vi[n - 1] = x - 1;
				vi[n] = x;
				vi[n + 1] = x + 1;
				vi[n + 2] = x - 2;
				used[x - 1] = true;
				used[x] = true;
				used[x + 1] = true;
				used[x - 2] = true;
			}
			else {
				vi[n - 1] = x + 1;
				vi[n] = x;
				vi[n + 1] = x - 1;
				vi[n + 2] = x + 2;
				used[x + 1] = true;
				used[x] = true;
				used[x - 1] = true;
				used[x + 2] = true;
			}
			int now = 1;
			for (int i = 1; i <= 2 * n - 1; i++) {
				while (used[now])now++;
				if (vi[i] == 0) {
					used[now] = true;
					vi[i] = now;
				}
			}
			for (int i = 1; i <= 2 * n - 1; i++) {
				cout << vi[i] << endl;
			}
		}
	}
}

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

void solve(){
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for(auto& it: p) cin >> it;
	sort(p.begin(), p.end());
	long long ans = 0;
	for(int i = 0; i < k; i++){
		ans += p[i];
	}
	cout << ans << '\n';
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

Measured memory_bytes: 3680
// Created by code_sm
//
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp> 
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> pseudo_set;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
ll bigpow(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
void solve()
{
fastio
int n;
cin>>n;
ll a[n];
ll ans=0;
for(auto &x:a)
{
	cin>>x;
	ans^=x;
}
for(auto &x:a)
{
	ll out=x^ans;
	cout<<out<<" ";
}
//cout<<(5^7^22);
}
int main()
{
//code
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 5116
import sys
def input():
	return sys.stdin.readline().strip()

N, K = list(map(int, input().split()))

rootN = int(N**0.5)
num_list = [1]*rootN

now = rootN
for num in range(rootN, 0, -1):
	x = N//num
	num_list.append(x - now)
	now = x

dp = [[0]*len(num_list) for i in range(K)]
for i in range(len(num_list)):
	dp[0][i] = num_list[i]


mod = 10**9 + 7
for k in range(1, K):
	sum_before = [dp[k - 1][0]]
	for i in range(1, len(num_list)):
		sum_before.append(sum_before[-1]+dp[k - 1][i])
	for i in range(len(num_list)):
		dp[k][i] = (num_list[i]*sum_before[len(num_list) - 1 - i])%mod

print(sum(dp[-1])%mod)

Measured memory_bytes: 121108
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)

bool up, down;
int main(void)
{
	int N;
	cin >> N;

	int a, b;
	cin >> a;

	int ans = 1;
	rep(i, N - 1){
		cin >> b;
		if(a < b) up = true;
		if(a > b) down = true;
		if(up && down){
			up = down = false;
			ans++;
		}
		a = b;
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    string s,t;
    cin>>s>>t;
    int len=s.length();
    int count=0;
    for(int i=0;i<len;i++)
    if(s[i]!=t[i])
    count++;
    cout<<count<<endl;
    
    return 0;
}

Measured memory_bytes: 3916
x = list(map(int, input().split()))
a = [int(input()) for i in range(x[2])]
p = [x[1]-x[2]]*x[0]
for i in range(x[2]):
    p[a[i]-1]+=1
for i in range(len(p)):
    if p[i]>0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 10448
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int r;

	cin >> r;

	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll inf = 922337203685477;
const ll mininf = -922337203685477;
const ll nax = 2e5 + 5;

ll n, m, k, fac[nax], faciv[nax];

ll pangkat (ll x, ll y){
	if(y == 0){
		return 1;
	}
	ll temp = pangkat(x, y / 2) % mod;
	temp = (temp * temp) % mod;
	if(y % 2 == 1){
		return (temp * x) % mod;
	}
	else{
		return temp;
	}
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> m >> k;
	fac[0] = 1ll;
	for(ll i = 1; i <= n; i++){
		fac[i] = (i * fac[i-1]) % mod;
	}
	faciv[n] = pangkat(fac[n], mod - 2);
	for(ll i = n - 1; i >= 0; i--){
		faciv[i] = faciv[i + 1] * (i + 1) % mod;
	}
	ll ans = 0;
	for(ll i = 0; i <= k; i++){
		ll pilih = (fac[n - 1] * faciv[n-1-i] % mod) * faciv[i] % mod;
		ll comp = pangkat(m - 1, n - i - 1) % mod * m % mod;
		ll res = (pilih * comp) % mod;
		ans = (ans + res) % mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 6772
/* https://atcoder.jp/contests/abc093/tasks/arc094_a */

#include <iostream>
#include <vector>
#include <algorithm>

int solve(const int A, const int B, const int C)
{
  int min_cnt = 100;

  for (int i = 0; i <= 3; ++i) {
    int cnt = 0;
    std::vector<int> vals = {A, B, C};

    if (i != 3) {
      cnt++;
      for (int j = 0; j < 3; ++j) {
        if (i != j) {
          vals.at(j)++;
        }
      }
    }

    int max_val = *std::max_element(vals.begin(), vals.end());

    for (int j = 0; j < 3; ++j) {
      int diff = max_val - vals.at(j);

      if (diff%2 == 0) {
        cnt += diff/2;
      } else {
        cnt = min_cnt;
        break;
      }
    }

    min_cnt = std::min(min_cnt, cnt);
  }

  return min_cnt;
}

int main(int argc, char *argv[])
{
  // Input
  int A, B, C;

  std::cin >> A >> B >> C;

  // Output
  std::cout << solve(A, B, C) << std::endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            if (X >= 30) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27468
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#define ll long long 
using namespace std;

int main() {
	ll n, x;
	ll count = 0;
	ll a[100000];
	cin >> n >> x;
	for (ll i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (ll i = 0; i < n - 1; i++) {
		if (a[i] + a[i + 1] > x) {
			if (a[i] > x) {
				count += a[i + 1];
				a[i + 1] = 0;
				count += a[i] - x;
				a[i] = x;
			} else {
				count += a[i + 1] - x + a[i];
				a[i + 1] = x - a[i];
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int n;
    cin >> n;
    set<int> a;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        if(a.count(b))
        cnt++;
        a.insert(b);
    }
    cnt == 0 ? cout << "YES" : cout << "NO";
    cout << endl;
}


Measured memory_bytes: 9600
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

LL len(LL v)
{
	LL p=1;
	LL base=1;
	LL ret=0;
	for(;base<=v;p++){
		LL nex=10*base;
		LL up=min(nex-1,v);
		LL f=(up/3-(base-1)/3);
		LL b=(up/5-(base-1)/5);
		LL fb=(up/15-(base-1)/15);
		ret+=p*(up-base+1-f-b+fb);
		ret+=4*(f+b);
		base=nex;
	}
	return ret;
}
int main() {
	LL s;
	cin >> s;
	LL low=0;
	LL hi=1000; //3
	hi=hi*hi; // 6
	hi=hi*hi*hi; // 18;
	while(low+1<hi){
		LL mid=(low+hi)/2;
		if(s<=len(mid))
		{
			hi=mid;
		}
		else
		{
			low=mid;
		}
	}
	LL v=hi;
	string str;
	LL b=s-len(low)-1;
	for(LL i=v;str.size()<b+20;i++){
		ostringstream ostr;
		if(i%3==0){
			ostr<<"Fizz";
		}
		if (i%5==0){
			ostr<<"Buzz";
		}
		if(i%3!=0&&i%5!=0){
			ostr<<i;
		}
		str+=ostr.str();
	}
	cout << str.substr(b,20) << endl;
}

Measured memory_bytes: 1212
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = n % digsum(n) == 0;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }

    public static int digsum(int num) {
        int sum = 0;
        while (num > 0) {
            sum += num % 10;
            num /= 10;
        }
        return sum;
    }
}


Measured memory_bytes: 24020
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
struct var
{
    int b,c;
    var(int x, int y)
    {
        b=x,c=y;
    }
};
struct cmp
{
    bool operator() (var a, var b)  {return a.c<b.c;}
};
priority_queue< var, vector<var>, cmp > q;
vector<int> v;
int main()
{
    //freopen("inp","r",stdin);
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;++i)
    {
        int a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.begin(),v.end());
    //cout<<v[0]<<endl;
    for(int i=1;i<=m;++i)
    {
        int b, c;
        cin>>b>>c;
        q.push(var(b,c));
    }
    long long s=0ll;
    int b=q.top().b, c=q.top().c,i=0;
    q.pop();
    for(;i<(int)v.size();++i)
    {
        if((q.empty()&&b==0)||v[i]>c)  break;
        else if(b==0) b=q.top().b, c=q.top().c,q.pop();
        s=s+max(v[i],c);
        --b;
    }
    for(;i<(int)v.size();++i)  s+=v[i];
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 1784
import java.lang.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Main m = new Main();
    m.exec();
  }

  private void exec() {
    Scanner scan = new Scanner(System.in);

    int n = scan.nextInt();
    int k = scan.nextInt();
    int[] x = new int[n];
    for (int i = 0; i < x.length; i++) {
      x[i] = scan.nextInt();
    }

    int total = 0;
    for (int i = 0; i < n; i++) {
      int a = Math.abs(k - x[i]);
      int distance = x[i];
      if (distance > a) {
        distance = a;
      }
      total += distance * 2;
    }
    System.out.println(total);

    scan.close();
  }
}

Measured memory_bytes: 22740
/* 
 * Project: AtCoder Beginners Contest 139 B - Power Socket
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/08/25
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cstdint>
using namespace std;

uint16_t a, b;

void solve() {

    uint16_t num = 0;
    uint16_t taps = 0;
    while (taps < b-1) {
        taps += a-1;
        num++;
    }

    printf("%d\n", num);

}

int main() {

    scanf("%hd", &a);
    scanf("%hd", &b);

    solve();

}

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   ll n,now;
   cin >> n;
   now = 100;
   ll cnt=0;
   while (now < n)
   {
      now+=now/100;
      cnt++;
   }
   cout << cnt << endl;
   

   return 0;

}


Measured memory_bytes: 3636
def check_bingo(board)
  board.each do |l|
    stone = l.first
    return stone if l.all?{ |x| x == stone } && stone != '+'
  end

  return nil
end

def choose_winner(board)
  diagonal_board = [[0,1,2].map{|x| board[x][x]}, [0,1,2].map{|x| board[x][2-x]}]
  [board, board.transpose, diagonal_board].each do |b|
    stone = check_bingo(b)
    return stone unless stone.nil?
  end

  return "NA"
end

loop do
  board = []
  board << gets.chomp.chars
  break if board[0] == ['0']
  2.times do
    board << gets.chomp.chars
  end
  
  puts choose_winner(board)
end

Measured memory_bytes: 6104
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int H, W;
	cin >> H >> W;
	char a[100][100];
	vector<bool>tmp(H, false);
	vector<bool>row(W, false);
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#') {
				tmp[i] = true;
				row[j] = true;
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		if (tmp[i]) {
			for (int j = 0; j < W; j++) {
				if (row[j]) {
					cout << a[i][j];
				}
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
n, t = map(int, input().split())
c_list = []
for i in range(n):
    c_i, t_i = map(int, input().split())
    if t_i <= t:
        c_list.append(c_i)
if len(c_list) == 0: print("TLE")
else: print(min(c_list))

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int happy = 0;
		boolean b = false;
		
		if(X/500>=1){
			happy = X/500*1000;
			X -= X/500*500;
		}
		if(X/5>=1) happy += X/5*5;
		
		System.out.print(happy);
	}
}

Measured memory_bytes: 35784
#include <iostream>
#include <string>
#include <bits/stdc++.h>
#include <stdlib.h>

using namespace std;

int h[100002] = {0};
int memo[100002] = {-1};

int compute(int startPos, int n, int k){
    if(memo[startPos] != -1){
        return memo[startPos];
    }
    if(startPos == n - 1){
        return 0;
    }
    if(startPos == n - 2){
        return abs(h[startPos] - h[startPos + 1]);
    }
    int value = abs(h[startPos] - h[startPos + 1]) + compute(startPos + 1, n, k);
    for(int i = 2; i <= k; i++){
        if(startPos + i <= n - 1) value = min(value, abs(h[startPos] - h[startPos + i]) + compute(startPos + i, n, k));
    }
    memo[startPos] = value;
    return value;
}

int main(){
    int n, k;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        memo[i] = -1;
    }
    int answer = compute(0, n, k);
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 8832
import sys
from collections import deque
N, M = map(int, input().split())
edges = [[] for i in range(N)]
AB = []
for _ in range(M):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    AB.append((a-1, b-1))
def BFS(s):
    prev = [-1]*N
    que = deque([s])
    while que:
        v = que.pop()
        for nv in edges[v]:
            if nv == s:
                prev[nv] = v
                return (s, prev)
            if prev[nv]<0:
                que.append(nv)
                prev[nv] = v
    return (-1, prev)
for v in range(N):
    v0, prev = BFS(v)
    if v0>=0:
        break
if v0<0:
    print(-1)
    sys.exit()
circle = set()
circle.add(v0)
pv = prev[v0]
while pv != v0:
    circle.add(pv)
    pv = prev[pv]
for a, b in AB:
    if a in circle and b in circle and prev[b] != a:
        pv = prev[b]
        while pv != a:
            circle.remove(pv)
            pv = prev[pv]
        prev[b] = a
print(len(circle))
for i in circle:
    print(i+1)

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vll vector<ll>
#define vvll vecror<vector<ll>> 
#define sz size()
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll fact(ll n){ll s=1; for(ll i=1;i<=n;i++)s*=i; return s;}
ll ceil1(ll n,ll m){if(n%m==0){return n/m;}return n/m +1;}
vll factor(ll n){
    vll ans;
    if(n>0)ans.pb(1);if(n==2)ans.pb(2);
    for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
    return ans;
}
 
 
 

void solve()
{
	ll x,y,a,b,c;
	
	cin>>x>>y>>a>>b>>c;
	
	vector<ll> A(a),B(b),C(c);
	
	ll ans = 0;
	
	for(int i=0;i<a;i++)
	{
		cin>>A[i];
	}
	for(int i=0;i<b;i++)
	{
		cin>>B[i];
	}
	for(int i=0;i<c;i++)
	{
		cin>>C[i];
	}
	
	sort(all(A));
	sort(all(B));
	sort(all(C));
	
	ll l = c-1;
	
	priority_queue<ll,vector<ll>,greater<ll>> q;
	
	for(int i=a-x;i<a;i++)
	{
		ans+=A[i];
		q.push(A[i]);
	}
	
	for(int i=b-y;i<b;i++)
	{
		ans+=B[i];
		q.push(B[i]);
	}
	
	
	while(l >= 0 && !q.empty())
	{
		ll tmp = q.top();
		
		q.pop();
		
		
		if(C[l] > tmp)
		{
			ans= ans+C[l]-tmp;
			l--;
		}
		else
		{
			break;
		}
		
	}
	cout<<ans;	
}
 
int main()
{
    ll q;
    q=1;
    // cin>>q;
    while(q--)
    {
        solve();
    }
    return 0;
}


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

int main(){
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> c(n);
	vector<vector<int>> a(n, vector<int>(m));
	rep(i, n){
		cin >> c.at(i);
		rep(j, m) cin >> a.at(i).at(j);
	}
	int k = pow(2, n);
	vector<int> sc(m);
	ll ma = 10000000;
	rep(i, k){
    	bitset<12> b1(i);
//    	cout << b1 << ' ';
		ll sum = 0;
		rep(j, m) sc.at(j) = 0;
		rep(j, n){
			if(b1.test(j) == 1){
				sum += c.at(j);
				rep(l, m) sc.at(l) += a.at(j).at(l);
			}
		}
		int f = 0;
		rep(j, m) if(sc.at(j) < x) f = 1;
		if(f == 0 && sum < ma) ma = sum;
/*		cout << sum << ' ' << endl;
		rep(j, m) cout << sc.at(j) << ' ';
		cout << endl;*/
	}
	if(ma == 10000000){
		cout << -1 << endl;
	}else{
		cout << ma << endl;
	}
	return 0;
}


Measured memory_bytes: 4072
#include<bits/stdc++.h>
#define MAXN 3010010
#define Max 25
using namespace std;

int Prime[20];
int idx;
int ans[1010];

int pw(int a , int b) {
  int ans = 1;
  for(int i = 0 ; i < b ; i++) ans *= a;
  return ans;
}

int main()
{
    for(int i = 2 ; i < 35 ; i++)
    {
        for(int j = 2 ; ; j++)
        {
            if(pw(i, j) > 1010) break;
            ans[pw(i, j)] = 1;
        }
    }
    ans[1] = 1;
    vector<int> vec;
    for(int i = 0 ; i <= 1000 ; i++) if(ans[i])
    vec.push_back(i);
    int N;
    cin >> N;
    idx = lower_bound(vec.begin() , vec.end() , N) - vec.begin();
    if(binary_search(vec.begin() , vec.end() , N)) cout << vec[idx] << endl;
    else cout << vec[idx - 1] << endl;
}


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

int main()
{
    long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    long cap = a;

    if (cap > b) cap = b;
    if (cap > c) cap = c;
    if (cap > d) cap = d;
    if (cap > e) cap = e;

    cout << (long)((n + cap - 1)/cap + 4) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a[200],b[200],i=0,j,count=0,z;
	while(scanf("%d %d",&a[i],&b[i]) != EOF){
		i++;
	}
	for(j=0;j<i;j++){
		z=a[j]+b[j];
		for(count=0;z!=0;count++) z/=10;
		printf("%d\n",count);
		count=0;
	}
	return 0;
}

Measured memory_bytes: 1028
#include<stdio.h>
#include<string.h>
int main()
{
    int l,i,j,b,k;
    char n[1000];
    while(gets(n))
    {
        l=strlen(n);
        b=-1;
        for(i=0;i<l;i++)
        {
            if(n[i]==' ')
            {
                for(j=i-1;j>b;j--)
                printf("%c",n[j]);
                printf(" ");
                b=i;
            }
        }
        for(i=l-1;i>b;i--)
            printf("%c",n[i]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 908
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int N, K;
    cin >> N >> K;
    int d[K];
    int snk[N] = {0};
    for(int i = 0; i < K; i++){
        cin >> d[i];
        for(int j = 0; j < d[i]; j++){
            int a;
            cin >> a;
            snk[a - 1]++;
        }
    }
    int cnt = 0;
    rep(i, N){
        if(snk[i] == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int A[110000],idx[110000];
signed main() {
  cin>>N;
  for(int i=0;i<N;i++)cin>>A[i],idx[i]=i;
  sort(idx,idx+N,[](int a,int b){return A[a]<A[b];});
  int ans=0;
  for(int i=0;i<N;i+=2)if(idx[i]%2==1)ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
import sys
from itertools import accumulate
class Segtree:
    def __init__(self, A, intv, initialize = True, segf = max):
        self.N = len(A)
        self.N0 = 2**(self.N-1).bit_length()
        self.intv = intv
        self.segf = segf
        if initialize:
            self.data = [intv]*self.N0 + A + [intv]*(self.N0 - self.N)
            for i in range(self.N0-1, 0, -1):
                self.data[i] = self.segf(self.data[2*i], self.data[2*i+1]) 
        else:
            self.data = [intv]*(2*self.N0)
        
    def update(self, k, x):
        k += self.N0
        self.data[k] = x
        while k > 0 :
            k = k >> 1
            self.data[k] = self.segf(self.data[2*k], self.data[2*k+1])
    
    def query(self, l, r):
        L, R = l+self.N0, r+self.N0
        s = self.intv
        while L < R:
            if R & 1:
                R -= 1
                s = self.segf(s, self.data[R])
            if L & 1:
                s = self.segf(s, self.data[L])
                L += 1
            L >>= 1
            R >>= 1
        return s
    
    def binsearch(self, l, r, check, reverse = False):
        L, R = l+self.N0, r+self.N0
        SL, SR = [], []
        while L < R:
            if R & 1:
                R -= 1
                SR.append(R)
            if L & 1:
                SL.append(L)
                L += 1
            L >>= 1
            R >>= 1
        
        if reverse:
            for idx in (SR + SL[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx+1]):
                    idx = 2*idx + 1
                else:
                    idx = 2*idx
            return idx
        else:
            for idx in (SL + SR[::-1]):
                if check(self.data[idx]):
                    break
            else:
                return -1
            while idx < self.N0:
                if check(self.data[2*idx]):
                    idx = 2*idx
                else:
                    idx = 2*idx + 1
            return idx

readline = sys.stdin.readline
N, K = map(int, readline().split())
P = list(map(int, readline().split()))
STmax = Segtree(P, 0, True, max)
STmin = Segtree(P, 10**9, True, min)
ans = N - K + 1
upper = [0]*(N-1)
for i in range(N-1):
    if P[i] > P[i+1]:
        upper[i] = 1
upper = list(accumulate(upper)) + [0]
cnt = 0
for i in range(N-K):
    if upper[i+K-2] == upper[i-1]:
        cnt += 1
    elif P[i+K] == STmax.query(i+1, i+K+1) and P[i] == STmin.query(i, i+K):
        ans -= 1
if upper[N-2] == upper[N-K-1]:
    cnt += 1
print(ans - max(0, cnt-1))

Measured memory_bytes: 95440
import java.util.*;

class Main {
	  static int mod=1_000_000_007;
  public static void main(String[] args) {
	  Scanner sc = new Scanner(System.in);
      long cnt =0;
      long cnt2 =0;
      int flg=0;
      long X = sc.nextLong();
      long A = sc.nextLong();

      if(X<A) {
    	  System.out.println("0");
      } else {
    	  System.out.println("10");
      }
  }
  
 
}

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


int main() {
    string S;
    cin >> S;

    string e;
    char op[3];
    ll sum;
    
    for (int tmp = 0; tmp < pow(2,3); tmp++) {
        e = S[0];
        sum = stoll(e);

        for (int i=0;i<3;i++) {
            if ((tmp>>i)&1) {
                e = S[i+1];
                sum += stoll(e);
                op[i] = '+';
            }
            else {
                e = S[i+1];
                sum -= stoll(e);
                op[i] = '-';
            }
        }

        if (sum == 7) {
            for (int j=0;j<3;j++) {
                cout << S[j] << op[j];
            }
            cout << S[3] << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>

/* ??????????????? (0????????????) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
    if(i != mini) sw++;
  }
  return sw;
}

int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}

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

void solve()
{
	ll int n, x, m;
	cin >> n >> x >> m;
	ll a = x;
	int done[100001] = {0};
	vector<int> prog;
	int c = 1;
	ll ans = 0;
	for (; c <= n; c++)
	{
		if (done[a] != 0)
			break;
		done[a] = c;
		prog.push_back(a);
		ans += a;
		a = (a * a) % m;
	}
	ll ans1 = 0;
	for (int c1 = done[a] - 1; c1 < prog.size(); c1++)
		ans1 += prog[c1];
	ans += ans1 * ((n - c + 1) / (prog.size() - done[a] + 1));
	for (int c1 = done[a] - 1, i = 0; i < (n - c + 1) % (prog.size() - done[a] + 1); c1++, i++)
		ans += prog[c1];
	cout << ans << endl;
}
int main()
{

	int t;
	t = 1;
	for (int c = 0; c < t; c++)
		solve();
}

Measured memory_bytes: 4112
// E - Logs

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int N, K;
ll A[200000];

// 長さt以下にできるかどうか
bool is_ok(ll t) {
	if (t == 0) return false;

	ll cnt = 0;
	for (int i=0; i<N; i++) {
		cnt += (A[i] - 1) / t; // 切る回数
	}

	return cnt <= K;
}

ll find_min_ok(ll lower, ll upper) {
	if (!is_ok(upper - 1)) return -1; // 存在しない

	ll ok = upper - 1;
	ll ng = lower - 1;

	while(ok - ng > 1) {
		ll trying = (ng + ok) / 2;

		if (is_ok(trying)) {
			ok = trying;
		} else {
			ng = trying;
		}
	}

	return ok;
}

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

	for (int i=0; i<N; i++) {
		cin >> A[i];
	}

	ll ans = find_min_ok(0, 1e9+1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5084
#include<bits/stdc++.h>
#define pb                  push_back
#define mp                  make_pair

#define dd                  double
#define ll                  long long int

using namespace std;
#define pi                  pair<int,int>
#define pii                 pair< pair<int,int> ,int>


int solve()
{
    int n,m;cin>>n>>m;
    bool flag=true;
    int lol[n];
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>lol[i];
        sum+=lol[i];
    }
    double ans=0;
    ans=(1/(4*(double)m))*(double)sum;
    int c=0;

    for(int i=0;i<n;i++)
    {
        if(lol[i]>=ans)c++;
    }
    if(c>=m)cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}

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


Measured memory_bytes: 256
sa=list(input())
sb=list(input())
sc=list(input())
n='a'
while True:
  if n=='a':
    if len(sa)==0:
      print('A')
      exit()
    else:
      n=sa.pop(0)
  elif n=='b':
    if len(sb)==0:
      print('B')
      exit()
    else:
      n=sb.pop(0)   
  else:
    if len(sc)==0:
      print('C')
      exit()
    else:
      n=sc.pop(0)

Measured memory_bytes: 3064
import sys
input=sys.stdin.readline

def main():
    h,w,k=map(int,input().split())
    S=[]
    for _ in range(h):
        S.append(list(int(x) for x in list(input().strip())))
    #print(S)
    ans=float('inf')
    for bit in range(1<<(h-1)):
        cut=0
        tmp=bit
        while tmp:
            cut+=tmp&1
            tmp>>=1
        C=[]
        Tmp=S[0][:]
        for i in range(h-1):
            if (bit>>i)&1==1:
                C.append(Tmp)
                Tmp=S[i+1][:]
            else:
                for j in range(w):
                    Tmp[j]+=S[i+1][j]
        C.append(Tmp)
        #print(bit,C)
        m=0
        for c in C:
            m=max(m,max(c))
        if m>k:
            continue
        W=[0]*(cut+1)
        l=len(W)
        for i in range(l):
            W[i]+=C[i][0]
        for i in range(w-1):
            for j in range(l):
                W[j]+=C[j][i+1]
            #print(W)
            if max(W)>k:
                cut+=1
                for j in range(l):
                    W[j]=C[j][i+1]
        #print(bit,C,cut)
        ans=min(ans,cut)
    print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 47580
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  char s;
  cin >> s;
  if(int(s) >= 97){
    cout << 'a' << endl;
  }
  else{
    cout << 'A' << endl;
  }
  return 0;
}

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

import sys, math
sys.setrecursionlimit(300000)


def solve(N: int, x: "List[int]", y: "List[int]"):
    ret = 0
    total = 0
    for i in range(N):
        for j in range(i + 1, N):
            total += math.sqrt((x[j] - x[i]) ** 2 + (y[j] - y[i]) ** 2)
    comb = N * (N - 1) // 2
    perm = 1
    for i in range(1, N + 1):
        perm *= i
    ret = total * ((N - 1) * perm // comb)
    ret /= perm
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    x = [int()] * (N)  # type: "List[int]"
    y = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, x, y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k;
int d[110];
int a[110][110];

int solve() {
    int b[n];
    memset(b, 0, sizeof(b));
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < d[i]; j++) {
            b[a[i][j]-1]++;
        }
    }
    int res = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] == 0)
            res++;
    }
    return res;
}

void input() {
    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        cin >> d[i];
        for (int j = 0; j < d[i]; j++) {
            cin >> a[i][j];
        }
    }
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3144
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define ll long long int
#define PI acos(-1.0)
#define f first
#define se second
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   char ch1,ch2;
   cin>>ch1>>ch2;
   if(ch1=='H')
    cout<<ch2;
   else
   {
    if(ch2=='H')
     cout<<'D';
    else
     cout<<'H';
   }
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//参考 https://qiita.com/ofutonfuton/items/c17dfd33fc542c222396

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    int n,m;
    cin >> n >> m;
    UnionFind tree(n);
    for (int i = 0; i < m; i++)
    {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        if (a>b)
        {
            swap(a,b);
        }
        tree.unite(a,b);
    }
    map<int,int> mp;
    for (int i = 0; i < n; i++)
    {
        mp[i]=0;
    }
    
    for (int i = 0; i < n; i++)
    {
        mp[tree.root(i)]++;
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans = max(ans,mp.at(i));
    }
    cout << ans << endl;
    
    
}

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

int main(){
  int n; cin >> n;
  int a[200010], b[200010];;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b + n);
  int max = b[n - 1], max2 = b[n - 2];
  for (int i = 0; i < n; i++){
    if (a[i] == max) cout << max2 << endl;
    else cout << max << endl;
  }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}

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

  int n;
  cin>>n;
  vector<int> A(n);
  cin>>A;
  for(int &a:A) a--;
  
  vector<int> cnt(n,0);
  for(int i=0;i<n;i++){
    int a = A[i];
    if(a == 0) cnt[a] = 1;
    else cnt[a] = 1 + cnt[a-1];
  }

  int mx = -1;
  for(int i=0;i<n;i++) Max(mx, cnt[i]);
  int ans = n - mx;
  cout<<ans<<endl;
    


  return 0;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    for(auto& it:a) cin>>it;
    for(int i=0;i<n-1;i++) b[i]=a[i]^a[i+1];
    int sum=0;
    for(int i=0;i<n;i+=2) sum^=b[i];
    for(auto it:a) cout<<(sum^it)<<' ';

    return 0;
}



Measured memory_bytes: 4768