akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[] arr = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1,
				51 };
		Scanner sc = new Scanner(System.in);
		int k = Integer.parseInt(sc.next());
		System.out.println(arr[k - 1]);

	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {

	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < (int)s.size(); i++) {
		if (s[i] == 'a')
			a++;
		if (s[i] == 'b')
			b++;
		if (s[i] == 'c')
			c++;
	}
	if (max(a, max(b, c)) - min(a, min(b, c)) > 1)
		cout << "NO";
	else
		cout << "YES";
}


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

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

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

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

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

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

  pii maxmass = make_pair(100,-1);
  for(int i = 0; a*i <= f/100; i++){
    for(int j = 0; a*i+b*j <= f/100; j++){
      int maxsolt = (a*i+b*j) * e;
      for(int k = 0; k*c <= min(maxsolt, f-(a*i+b*j)*100); k++){
        int l = (min(maxsolt, f-(a*i+b*j)*100) - k*c) / d;
        if(i==0 && j == 0)
          continue;
        long double mass = 100.0 * (k*c+l*d) / ((a*i+b*j)*100+k*c+l*d);
        //cout << maxsolt << " " << f-(a*i+b*j)*100 << endl;
        //cout << i << " " << j << " " << k << " " << l << endl;
        //cout << mass << "\n";
        if(maxmass.SE * 100.0 / (maxmass.FI + maxmass.SE) < mass){
          maxmass.FI = (a*i+b*j)*100;
          maxmass.SE = k*c+l*d;
        }

      }
    }
  }

  cout << maxmass.SE + maxmass.FI << " " << maxmass.SE << endl;
  
}


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

using namespace std;

int main()
{
    long long n,m,a,b;
    cin>>n>>m;
    vector<pair<long long,long long>>v;
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;
        v.push_back({a,b});
    }
    sort(v.begin(),v.end());
    long long ans=0,x=m;
    for(int i=0;i<n;i++)
    {
        ans+=v[i].first*(min(v[i].second,x));
        x-=v[i].second;
        if(x<=0)
            break;
    }
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define mem(a,val) memset(a,val,sizeof(a))
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x

using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	char ch;
	cin >> ch;

	int val = (int)ch;
	if (val <= (int)'z' && val >= (int)'a')cout << 'a';
	else cout << 'A';
	// cout <<  << ;
	return 0;
}

Measured memory_bytes: 3648
n=int(input())
ans=0
def count_cases(n):
    n-=1
    cur=1
    cnt=0
    while cur*cur<=n:
        if n%cur==0:
            if n//cur!=cur:
                if (n+1)%(n//cur)==1:
                    cnt+=1
#                    print(n//cur)
                if (n+1)%cur==1:
                    cnt+=1
#                    print(cur)
            else:
                if (n+1)%cur==1:
                    cnt+=1
#                    print(cur)
        cur+=1
    return cnt
#count non divisible cases 
ans+=count_cases(n)
#print(ans,end=' ans\n')
#exit()
#count divisible type cases
cur=2
while cur*cur<=n:
    #check if cur,cur**2,cur**3,cur**4 are a valid one
    if n%cur==0:
        num=n
        div=cur
        while num%div==0:
            num//=div
        if num%div==1:
 #           print(div)
            ans+=1
        div=n//cur
        if cur!=(n//cur):
            num=n
            while num%div==0:
                num//=div
 #              print(div)
            if num%div==1:
                ans+=1
    cur+=1
print(1+ans)#extra 1 due to k=n case 



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

typedef pair<int, int>P;

const int INF = 100000;
int h, w;
char s[60][60];
int d[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int bfs()
{
	int ans = INF;
	queue<P> que;

	for (int i = 1; i <= w; i++)
	{
		for (int j = 1; j <= h; j++)
		{
			d[i][j] = INF;
		}
	}

	que.push(P(1, 1));
	d[1][1] = 0;

	while (!que.empty())
	{
		P p = que.front();
		que.pop();

		if (p.first == w && p.second == h)
		{
			ans = d[w][h] + 1;
			break;
		}

		for (int i = 0; i <= 3; i++)
		{
			int nx = p.first + dx[i];
			int ny = p.second + dy[i];

			if (1 <= nx && nx <= w && 1 <= ny && ny <= h && s[ny][nx] == '.' && d[nx][ny] == INF)
			{
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}
	return ans;
}

int main()
{
	cin >> h >> w;

	int sum = 0;
	for (int i = 1; i <= h; i++)
	{
		for (int j = 1; j <= w; j++)
		{
			cin >> s[i][j];
	
			if (s[i][j] == '.')
			{
				sum++;
			}
		}
	}

	if (bfs() != INF)
	{
		cout << sum - bfs() << endl;
	}
	else
	{
		cout << -1 << endl;
	}
}

Measured memory_bytes: 256
n = int(input())
_ = list(map(int, input().split()))
a = []
for i in range(1,n+1):
  a.append([_[i-1], i])
  
ans = []
a_sort = (sorted(a, key=lambda x: x[0]))
for i in range(n):
  ans.append(a_sort[i][1])
  
print(' '.join(list(map(str, ans))))


Measured memory_bytes: 28856
x = int(input())
count = [0 for i in range(5)]
for i in range(x):
    name = input()
    if name[0] == 'M':
        count[0] += 1
    elif name[0] == 'A':
        count[1] += 1
    elif name[0] == 'R':
        count[2] += 1
    elif name[0] == 'C':
        count[3] += 1
    elif name[0] == 'H':
        count[4] += 1

p = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2]
q = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3]
r = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4]
res = 0
for i in range(10):
    res += count[p[i]]*count[q[i]]*count[r[i]]

print(res)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        char[] input = sc.next().toCharArray();
        boolean flag = false;
        loop: for(char c: input){
            if(c == '9'){
                flag = true;
                break loop;
            }
        }
        if(flag){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){
	
	int n;
	cin >> n;

	set<string> s;

	rep(i,n){
		string t;
		cin >> t;
		s.insert(t);
	}

	cout << s.size() << endl;
	
	
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://atcoder.jp/contests/abc164/tasks/abc164_b


Measured memory_bytes: 19260
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
bool dp[MAXN];
int a[101];
int main()
{
    int n, K; scanf("%d%d", &n, &K);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= K; i++)
    {
        bool f = 0;
        for (int j = 1; j <= n; j++) if (i >= a[j])
            if (!dp[i - a[j]]) {f = 1; break;}
        dp[i] = f;
    }
    dp[K] ? puts("First") : puts("Second");
    return 0;
}

Measured memory_bytes: 384
use std::io::*;
use std::str::FromStr;

fn func(a: usize, s: &Vec<char>, t: &Vec<char>, d: &Vec<bool>) -> usize {
    let mut a = a;
    for i in 0..t.len() {
        if a == 0 || a > s.len() {
            return a;
        }
        if s[a-1] == t[i] {
            if d[i] {
                a -= 1;
            } else {
                a += 1;
            }
        }
    }
    return a;
}

fn main() {
    let n: usize = read();
    let q: usize = read();
    let s: Vec<char> = read::<String>().chars().collect();

    let mut t: Vec<char> = vec![];
    let mut d: Vec<bool> = vec![];  //true:L
    for _ in 0..q {
        let ti: Vec<char> = read::<String>().chars().collect();
        let di: Vec<char> = read::<String>().chars().collect();
        t.push(ti[0]);
        d.push(di[0] == 'L');
    }
    
    let mut ok = 0;
    let mut ng = n+1;
    while ng > ok + 1 {
        let mid = (ng + ok) / 2;
        if func(mid, &s, &t, &d) == 0 {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    let l = ok;

    ok = n+1;
    ng = 0;
    while ok > ng + 1 {
        let mid = (ng + ok) / 2;
        if func(mid, &s, &t, &d) > n {
            ok = mid;
        } else {
            ng = mid;
        }
    }
    let r = ok;
    println!("{}", r - l - 1);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 6524
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a, b, c; cin >> a >> b >> c;
	cout << (char)toupper(a[0]) << (char)toupper(b[0]) << (char)toupper(c[0]) << endl;
	return 0;
}

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

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;

/* global variables */
vector<int> out;
vector< vector<int> > Adj(MAX);
vector<int> indeg(MAX, 0), color(MAX, WHITE);
/* function */
void bfs(int u);

/* main */
int main() {

    int V, E, v, u;
    cin >> V >> E;

    for (int i = 0; i < E; i++) {
        cin >> v >> u;
        Adj[v].push_back(u);
        indeg[u]++;
    }

    for (int u = 0; u < V; u++) {
        if (indeg[u] == 0 && color[u] == WHITE) {
            bfs(u);
        }
    }

    for (auto o : out)
        cout << o << '\n';

}

void bfs(int u) {
    queue<int> Q;
    int s, t;
    Q.push(u);
    color[u] = GRAY;
    while (!Q.empty()) {
        s = Q.front();
        Q.pop();
        out.push_back(s);

        for (int i = 0; i < Adj[s].size(); i++) {
            t = Adj[s][i];
            indeg[t]--;
            if (indeg[t] == 0 && color[t] == WHITE) {
                color[t] = GRAY;
                Q.push(t);
            }
        }
    }
}


Measured memory_bytes: 3492
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
# row = [int(input().rstrip()) for _ in range(n)]
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def resolve():
    import sys
    input = sys.stdin.readline

    s = int(input().rstrip())

    k = s // 3

    ans = 0
    for i in range(1, k+1):
        ans = ans % 1000000007
        # i項目の順列の場合

        # totalnumをi個に分ける
        total_num = s - 3 * i

        # i地点から重複を許してtotal_num個を選ぶ
        ans += combinations_count(i+total_num-1, total_num)

    print(ans)

if __name__ == "__main__":
    resolve()


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string x,y;
    cin>>x>>y;
    if(x<y) cout << "<"<<endl;
    else if(x>y) cout << ">"<<endl;
    else cout << "="<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <cctype>

using namespace std;

class D {
public:
	int sets;
	int n;
	list<D*> child;
	D() :child() {
		n = 0;
		sets = 0;
	};
	~D() {
	}
};

char c[10002];

int get(D *d, int &l) {
	int sum = 0;
	if (c[l] == '[') {
		while (c[l] == '[') {
			D *dd = new D();
			++l; //'['
			sum += get(dd, l);
			d->child.push_back(dd);
			d->sets++;
			l++; //']'
		}
		d->n = sum;
	} else {
		int num = c[l] - '0';
		for (l++; isdigit(c[l]); l++) {
			num = num * 10 + (c[l] - '0');
		}
		d->n = num;
		return num;
	}
	return sum;
}

int ans(D *d) {
	//cout << "in" << endl;
	if (d->sets == 0) {
		//cout << "okk" << endl;
		return d->n / 2 + 1;
	}
	//else
	auto func = [](D *d1, D *d2){return d1->n < d2->n;};
	d->child.sort(func);
	//cout << "sets::" << d->sets << endl;
	list <int> ilist;
	auto it = d->child.begin();
	for (int i = 0; i < d->sets; i++) {
		D *cur = *it;
		//cout << i << ":::" << cur->n << endl;
		ilist.push_back(ans(cur));
		it++;
	}
	ilist.sort([](int &i1, int &i2){return i1 < i2;});
	int sum = 0;
	auto iit = ilist.begin();
	for (int i = 0; i < d->sets / 2 + 1; i++) {
		sum += *iit;
		iit++;
	}
	return sum;
}

	
void solve() {
	int n;
	int l;
	cin >> n;
	//cout << n << endl;
	for (int i = 0; i < n; i++) {
		cin >> c;
		//cout << c << endl;
		D *d = new D();
		l = 1;
		get(d, l);
		cout << ans(d) << endl;
		//cout << "hoge" << endl;
		delete d;
	}
}

int main(void) {
	solve();
}

Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
// 7903247656
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define eb emplace_back
#define pb push_back
#define mk make_pair
#define mt make_tuple

#define Umap unordered_map
#define graph vector<vector<int>>

#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl

#define INF 1e9+5
#define N 40001
#define MAXN   100001


bool sortbysec(const tuple<int, int, int>& a,  
               const tuple<int, int, int>& b) 
{ 
    return (get<1>(a) < get<1>(b)); 
}
// void dfs(int s, graph &g, bool vis[], int path){
// 	vis[s] = true;
	
// 	for(int i=0;i<g[s].size();i++){
// 		if(!vis[g[s][i]]) {dfs(g[s][i],g,vis); }
// 	}

// }

string common_prefix(vector<string>& strings){
	string prefix;
	for(string s : strings){
		for(int i=0;i<s.size() && s[i]!='*';++i){
			if(i<prefix.size()){
				if(s[i]!=prefix[i]) return "*";
			}
			else prefix+=s[i];
		}
	}
	return prefix;
}

void reverse(vector<string>& strings){
	for(string& s : strings){
		reverse(s.begin(),s.end());
	}
}

int spf[0];
void sieve(){
	spf[1] = 1;
	for(int i=2;i<MAXN;i++) spf[i] = i;

	for(int i=4;i<MAXN;i+=2) spf[i] = 2;

	for(int i=3; i*i<MAXN;i++){
		if(spf[i]==i){
			for(int j=i*i;j<MAXN;j+=i){
				if(spf[j]==j) spf[j] = i;
			}
		}
	}
}
vector<int> getFactorization(int x){

	vector<int> primeFactors;
	while(x>1){
		primeFactors.pb(spf[x]);
		x /= spf[x];
	}
	return primeFactors;
}


#define ll long long
void max_self(int& a, int b) {
    a = max(a, b);
}
int dfs(int s, graph& g, vector<bool>&vis){
	vis[s] = true;
	
	int path = 0;

	for(auto& vertex : g[s]){
		if(!vis[vertex]){
			
			max_self(path,dfs(vertex,g,vis)+1);
		}
	}
	return max(path,1);
}

void B(){
	// sieve(); 
	int n,k;  cin>>n>>k;
	vector<int>num(n); set<int>st;
	for(int i=0;i<n;i++) {cin>>num[i]; st.insert(num[i]);}

	int size = st.size();
	if(size > k) {cout<<-1<<endl; return ;}

	cout<<n*k<<endl;
	for(int i=0;i<n; i++){
		for(auto& x : st) cout<<x<<" ";
		for(int j=0;j<k-size;j++) cout<<1<<" ";
	}
	cout<<endl;
}
void solve(){
	int n; cin>>n;
	vector<int>height(n);
	for(int& x : height) cin>>x;

	vector<int>dp(n);
	dp[0] = 0;
	for(int i=1;i<n;i++){
		if(i==1){
			dp[i] = abs(height[i]-height[i-1]);
			continue;
		}

		dp[i] = min(dp[i-1] + abs(height[i]-height[i-1]),dp[i-2]+abs(height[i]-height[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

int main() {
IOS;
	int t=1; 
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();

		System.out.println(core(h,w,n));
	}
	
	static int core(int h , int w, int n ) {
		int max = Math.max(h,w);
		return (int)Math.ceil(  (double)n /(double) max);
	
	}	
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main(){
  string s;
  cin>>s;
  long long int sum=0,ans=0,temp=0;
  for(int bit=0;bit<(1<<(s.size()-1));bit++){
    temp=s[0]-'0';
    sum=0;
    for(int i=0;i<(s.size()-1);i++){
      if(bit & (1<<i)){
        sum+=temp;
        temp=s[i+1]-'0';
      }else{
        temp*=10;
        temp+=s[i+1]-'0';
      }
    }
    sum+=temp;
    ans+=sum;
  }
  cout<<ans<<endl;
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ");
        var H = int.Parse(input[0]);
        var W = int.Parse(input[1]);
        var K = int.Parse(input[2]);

        var table = new List<List<char>>();
        for(int i = 0; i < H; i++)
        {
            var row = new List<char>();
            var line = Console.ReadLine();
            for(int j = 0; j < W; j++)
            {
                row.Add(line[j]);
            }
            table.Add(row);
        }

        var count = 0;
        for (int hBit = 0; hBit < (1 << H); ++hBit)
        {
            // 行に対してBit全探索
            var rows = GenerateCopyList(table);
            for (int i = 0; i < H; ++i)
            {
                if((hBit & (1 << i)) != 0)
                {
                    for(int j = 0; j < W; j++)
                    {
                        rows[i][j] = '.';
                    }
                }
            }
            for (int wBit = 0; wBit < (1 << W); ++wBit)
            {
                var columns = GenerateCopyList(rows);
                // 列に対してBit全探索
                for (int i = 0; i < W; ++i)
                {
                    if ((wBit & (1 << i)) != 0)
                    {
                        for(int j =0; j < H; j++)
                        {
                            columns[j][i] = '.';
                        }
                    }
                }
                if (CountSharp(columns) == K) count++;
            }
        }

        Console.WriteLine(count);
    }

    private static List<List<char>> GenerateCopyList(List<List<char>> source)
    {
        var copyList = new List<List<char>>();
        foreach(var row in source)
        {
            copyList.Add(new List<char>(row));
        }
        return copyList;
    }

    private static int CountSharp(List<List<char>> list)
    {
        var count = 0;
        foreach(var row in list)
        {
            foreach (var item in row)
            {
                if (item == '#') count++;
            }
        }

        return count;
    }

}


Measured memory_bytes: 30020
#include <bits/stdc++.h>
using namespace std; 
using ll = long long;
vector<vector<ll>> memo (1e2+5, vector<ll> (1e5+5, -1));

ll dp(vector<int> &v, vector<int> &vv, int i, int w){
	if(i >= v.size())
		return 0;
	if(memo[i][w] != -1)
		return memo[i][w];
	memo[i][w] = dp(v, vv, i+1, w);
	if(v[i] <= w)
		memo[i][w] = max(dp(v, vv, i+1, w-v[i])+vv[i], memo[i][w]);
	return memo[i][w];
}

signed main() { 
	cin.tie(0);
	cin.sync_with_stdio();
	int n, w; 
	cin>>n>>w;
	vector<int> v(n), vv(n);
	for(int i = 0; i < n; i++){
		int aa, bb, cc;
		cin>>aa>>bb;
		v[i] = aa;
		vv[i] = bb;
	}
	cout<<dp(v, vv, 0, w);
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k; cin>>n>>k;
    int r,s,p; cin>>r>>s>>p;
    string t; cin>>t;
    ll ans=0;
    rep(i,n){
        if (i<k){
            if (t[i]=='r') ans+=p;
            if (t[i]=='s') ans+=r;
            if (t[i]=='p') ans+=s;
        }else{
            if (t[i-k]==t[i]){
                t[i] = '*';
            }
            if (t[i]=='r') ans+=p;
            if (t[i]=='s') ans+=r;
            if (t[i]=='p') ans+=s;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var < (end); var++)
#define RFOR(var, begin, end) for (int var = (begin) - 1; var >= (end); var--)
#define REP(var, length) FOR(var, 0, length)
#define RREP(var, length) RFOR(var, length, 0)
#define SORT(vector) sort(vector.begin(), vector.end())

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

void solve(istream& cin, ostream& cout) {
  int n, W, V;
  cin >> n >> W;

  V = 1000 * n + 1;
  vector<vector<ll>> dp(n + 1, vector<ll>(V + 1, MAX));

  REP(i, n) {
    ll w;
    int v;
    cin >> w >> v;
    REP(j, v) {
      dp[i + 1][j] = dp[i][j];
    }
    dp[i + 1][v] = min(dp[i][v], w);
    FOR(j, v + 1, V + 1) {
      dp[i + 1][j] = min(dp[i][j], dp[i][j - v] + w);
    }
  }

  RREP(i, V + 1) {
    if (dp[n][i] <= W) {
      cout << i << endl;
      return;
    }
  }
}

#ifndef TEST
int main() {
  solve(cin, cout);
}
#endif


Measured memory_bytes: 81520
import sys
for line in sys.stdin:
	l=0
	for l in range(len(line)):
		if(line[l] == ' '):
			p = l
			break
	a = line[0:p]
	b = line[p+1:]
	c = int(a)+int(b)
	d = 1
	while(int(c/10) != 0):
		d += 1
		c = int(c/10)
	print(d)


Measured memory_bytes: 5604
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,m,Q;
char a[N],b[N];
int sa[N],sb[N];

int main() {
	scanf("%s",a+1),n=strlen(a+1);
	scanf("%s",b+1),m=strlen(b+1);
	for (int i=1;i<=n;++i) sa[i]=sa[i-1]+1+(a[i]=='B');
	for (int i=1;i<=m;++i) sb[i]=sb[i-1]+1+(b[i]=='B');
	Q=read();
	while (Q--) {
		int la=read(),ra=read(),lb=read(),rb=read();
		puts((sa[ra]-sa[la-1])%3==(sb[rb]-sb[lb-1])%3?"YES":"NO");
	}
	return 0;
}

Measured memory_bytes: 4560
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
void dfs(void);
void visit(int);
 
int A[N][N],n;
int d[N],f[N],color[N],time;
 
int main(){
   int i,j,k,u,v;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      A[i][j] = 0;
    }
  }
  for(i = 0; i < n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j = 0; j < k; j++){
      scanf("%d",&v);
      v--;
      A[u][v] = 1;
    }
  }
  dfs();
  return 0;
}
  void dfs(){
    int u;
    for(u = 0; u < n; u++) color[u] = WHITE;
    time = 0;
    for(u =0 ; u < n; u++){
      if(color[u] == WHITE) visit(u);
    }
    for( u = 0; u < n; u++){
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
  }
  void visit(int u){
    int v;
    color[u] = GRAY; 
    d[u] = ++time;
    for(v = 0; v < n; v++){
      if(A[u][v] == 0) continue;
      if(color[v] == WHITE){
    visit(v);
      }
    }
    color[u] = BLACK;
    f[u] = ++time;
  }

Measured memory_bytes: 636
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
fn = lambda: [int(x) for x in input().split()]
N, M = fn()
data, row_idx, col_idx = [0]*M, [0]*M, [0]*M
for i in range(M):
    ai, bi, ci = fn()
    row_idx[i] = ai - 1
    col_idx[i] = bi - 1
    data[i] = ci

G = csr_matrix((data, (row_idx, col_idx)), shape=(N, N), dtype=int)
D, P = floyd_warshall(G, directed=False, return_predecessors=True)
edges = []
for i in range(N):
    for j in range(N):
        Pji = P[j][i]
        if Pji < 0 or i == Pji:
            continue
        edges.append((min(i, Pji), max(i, Pji)))
edges = set(edges)
print(M - len(edges))

Measured memory_bytes: 21212
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
p = [int(x) for x in input().split()]

ok = 1
minp = [p[0]]

for i in range(1,n):
    if p[i] < minp[i-1]:
        minp.append(p[i])
        ok = ok + 1
    else:
        minp.append(minp[i-1])

print(ok)



Measured memory_bytes: 26012
#include <bits/stdc++.h>
#ifdef BUG
  #include "debug.hpp"
#else
  #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int main(const int argc, char **argv) {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  size_t n;
  cin >> n;
  std::vector<int> a(n);
  cin >> a;
  size_t out = 0;
  int rmax = 0;
  for (const auto i: a) {
    out += rmax <= i;
    rmax = max(rmax, i);
  }
  std::cout << out;

  return EXIT_SUCCESS;
}


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


int main() {
	
	string o, e, p;
	cin >> o >> e;
	for (int i=0; i<e.size(); i++){
		p += o.at(i);
		p += e.at(i);
	}
	if (o.size() - e.size() == 1) p += o.back();
	
	cout << p << endl;
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
ll MOD = ll(1e8) + 9;

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){

    int N, M, X;
    cin >> N >> M >> X;
    vector<vector<ll>> texts(N, vector<ll>(M));
    vector<ll> costs(N);
    for (int i = 0; i < N; i++) {
        ll C, Aij;
        cin >> C;
        costs[i] = C;
        for (int j = 0; j < M; j++) {
            cin >> Aij;
            texts[i][j] = Aij;
        }
    }

    ll maxval = 10000000;
    ll ans = maxval;
    vector<ll> know(M);
    for (int i = 0; i < (1 << N); i++) {
        // initialize
        ll tmpcost = 0;
        for (int j = 0; j < M; j++) know[j] = 0;
        for (int k = 0; k < N; k++) {
            if ((i >> k) & 1) {
                tmpcost += costs[k];
                for (int ti = 0; ti < M; ti++) {
                    know[ti] += texts[k][ti];
                }
            }
        }

        bool truth = true;
        for (int k = 0; k < M; k++) {
            if (know[k] < X) {
                truth = false;
            }
        }
        if (truth) {
            ans = min(ans, tmpcost);
        }
    }

    if (ans == maxval) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}



Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; cin>>N;
  vector<int> S(N);
  int A=0;
  for(int i=0; i<N; i++){
    cin>>S.at(i);
    if(S.at(i)%2==0){
      if(S.at(i)%3!=0&&S.at(i)%5!=0)
        A++;
    }
    else continue;
  }
  if(A==0)
    cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int INF = 100000000;
int n, x[10001][2], list[4], save[10001], l1 = 0, l2 = 0, ans = INF;
vector<int> v1, v2, v3;
int solve(int a){
	l1 = 0; l2 = 0;
	for (int i = 1; i < v2.size(); i++){
		if (v2[a + i] == v2[a]){
			l1++;
		}
		else
			break;
	}
	for (int i = 1; i < v2.size(); i++){
		if (v2[a - i] == v2[a]){
			l2++;
		}
		else
			break;
	}
	if (l1 + l2 >= 3){
		v2.erase(v2.begin() + a - l2, v2.begin() + a + l1 + 1);
		solve(a - l2-1);
	}
	else{
		return v2.size();
	}
}
int main(){
	while (true){
		cin >> n;
		if (n == 0){
			break;
		}
		for (int i = 1; i <= n; i++){
			cin >> x[i][0];
			v1.push_back(x[i][0]);
			if (i - list[x[i][0]] == 2){
				save[i - 1] = 2;
			}
			list[x[i][0]] = i;
			if (x[i][0] == x[i - 1][0] && x[i][0] == x[i - 2][0]){
				save[i + 1] = 1;
				save[i - 3] = 1;
			}
		}
		for (int i = 1; i <= n; i++){
			if (save[i] == 1){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				if (x[i + 1][0] == x[i + 2][0] && x[i + 1][0] == x[i + 3][0]){
					v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				}
				else if (x[i - 1][0] == x[i - 2][0] && x[i - 1][0] == x[i - 3][0]){
					v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				}
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i + 1][0] == x[i + 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i + 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else if (save[i] == 2 && x[i - 1][0] == x[i - 2][0]){
				v2 = v1;
				v2.erase(v2.begin() + i - 1);
				v2.insert(v2.begin() + i - 1, x[i - 1][0]);
				ans = min(solve(i - 1), ans);
			}
			else save[i] = 0;
		}
		cout << ans << endl;
		for(int i=1;i<=n;i++){
			x[i][0]=0;
			save[i]=0;
		}
		//list[0]=0;
		//list[1]=0;
		//list[2]=0;
		//list[3]=0;
		ans=INF;
		v1=v3;
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) {
    cin >> L.at(i);
  }
  int mx = *max_element(L.begin(), L.end());
  int sum = accumulate(L.begin(), L.end(), 0);
  if (mx < sum - mx) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

using namespace std;

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

        long len = 0;
        long l = 0;
        long m = 0;
        while (l < n){
                len += 1;
                l += pow(26,len);
                if (l >= n){
                        break;
                }
                m = l;
        }

        string ans;
        char a;
        for (int i = 1; i <= len; i++){
                a = 'a';
                for (int j = 1; j <= 26; j++){
                        if (m + pow(26,len-i) >= n){
                                break;
                        }else{
                                m += pow(26, len-i);
                                a += 1;
                        }
                }
                ans += a;
        }

        cout << ans << endl;

}

Measured memory_bytes: 4100
#include <stdio.h>
#pragma warning(disable: 4996)

int main() {
	int n, x, cnt = 1, s = 0; scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) {
		int l; scanf("%d", &l);
		s += l;
		if (s <= x) {
			cnt++;
		}
		else {
			break;
		}
	}
	printf("%d", cnt);
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> A(300);
  for (int i = 0; i < n; i++){
    cin >> A.at(i);
  }

  int count = 0;

  while (true){
    bool odd = false;
    for (int i = 0; i < n; i++){
      if (A.at(i)%2 != 0) odd = true;
    }
    if (odd) break;

    for (int i = 0; i < n; i++){
      A.at(i) /= 2;
    }
    count ++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
class ST {
	private:
		vll st;
		int n;
		int lf(int n) {return n<<1;}
		int rt(int n) {return 1+(n<<1);}
		void up(int p, int L, int R, int i, ll v) {
			if(L > i || R < i) {return;}
			if(L == R) {st[p] += v;return;}
			int M = (L+R)/2;
			up(lf(p),L,M,i,v);
			up(rt(p),M+1,R,i,v);
			st[p] = max(st[lf(p)],st[rt(p)]);
		}
		ll rq(int p, int L, int R, int i, int j) {
			if(L > j || R < i) {return 0;}
			if(L >= i && R <= j) {return st[p];}
			int M = (L+R)/2;
			ll sa = rq(lf(p),L,M,i,j);
			ll sb = rq(rt(p),M+1,R,i,j);
			//printf("%lld %d %d\n",sa,L,M);
			//printf("%lld %d %d\n",sb,M+1,R);
			return max(sa,sb);
		}
	public:
		ST(int sz) {
			n = sz;
			st.assign(4*n,0);
		}
		void up(int i, ll v) {
			up(1,0,n-1,i,v);
		}
		ll rq(int i, int j) {return rq(1,0,n-1,i,j);}

};
int n;
ll b[200100],h[200100];
int main() {
	scanf("%d ",&n);
	ST st(n+5);
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);
		h[i] = t;
	}
	for(int i=0;i<n;i++) {
		int t;
		scanf("%d ",&t);
		b[i] = t;
	}
	ll m = 0;
	for(int i=0;i<n;i++) {
		ll mb = st.rq(0,h[i]-1);
		st.up(h[i],mb+b[i]);
		m = max(m,mb+b[i]);
	}
	printf("%lld\n",m);
}


Measured memory_bytes: 9600
#include<iostream>
using namespace std;
int main(){
  int a[100]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout << a[k-1] << endl;
}
    

Measured memory_bytes: 3600
#include <map>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

ll vs[1000+10];

vector<int> ans;

int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  ll best;
  {
    ll *p = max_element(vs, vs+n);
    best = *p;
    int idx = p - vs;
    int rest = n;
    REP(i, idx) {
      ans.push_back(1);
      --rest;
    }
    REP(i, n-idx-1) {
      ans.push_back(rest);
      --rest;
    }
  }

  REP(p, 2) {
    ll cur = 0;
    vector<int> hoge;
    int last = -1;
    bool exist = false;
    int rest = n;
    REP(i, n) {
      if(i % 2 == p && vs[i] > 0) {
        exist = true;
        cur += vs[i];
        if(last == -1) {
          REP(j, i) {
            hoge.push_back(1);
            --rest;
          }
        } else {
          REP(j, (i-last)/2-1) {
            hoge.push_back(3);
            rest -= 2;
          }
          hoge.push_back(2);
          rest -= 2;
        }
        last = i;
      } else {
        // nothing
      }
    }
    if(last >= 0) {
      REP(i, n-last-1) {
        hoge.push_back(rest);
        --rest;
      }
    }
    if(exist && cur > best) {
      best = cur;
      ans.swap(hoge);
    }
  }
  printf("%lld\n", best);
  printf("%d\n", (int)ans.size());
  REP(i, ans.size()) {
    printf("%d\n", ans[i]);
  }

  return 0;
}


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

Y, M, D = map(int, input().split('/'))

if Y == 2019:
    if M == 4:
        if D <= 30:
            print('Heisei')
        else:
            print('TBD')
    elif M > 4:
        print('TBD')
    elif M < 4:
        print('Heisei')
elif Y > 2019:
    print('TBD')
elif Y < 2019:
    print('Heisei')


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

int main()
{
	int n, b, f, r, v;
	int i, j, k;
	int count[4][3][10]={0};

	cin >> n;

	for(i = 0; i < n; i++)
	{
			cin >> b >> f >> r >> v;
				count[b - 1][f - 1][r - 1] += v;
	}
	
	for(i = 0; i < 4; i++)
		{
			for(j = 0; j < 3; j++)
			{
				for(k = 0; k < 10; k++)
				{
					cout << " " << count[i][j][k];
				}
				cout << endl;
			}
			if(i < 3)
			{
				cout << "####################" << endl;
			}
		}
		
		return 0;
}

Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define inf 1e18
int main()
{
	ll n,q;
	cin>>n;
	ll a[n+2];
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		ans=ans^a[i];
	}
	for(int i=0;i<n;i++)
	{
		cout<<(ans^a[i])<<" ";
	}
	cout<<"\n";
}


Measured memory_bytes: 5184
N = int(input())
a = list(map(int, input().split()))


if N % 2 == 1:
    b = [a[i] for i in range(len(a)) if i % 2 == 0][::-1]
    c = [a[i] for i in range(len(a)) if i % 2 == 1]
    ans = list(map(str, b + c))
    print(" ".join(ans))
else:
    b = [a[i] for i in range(len(a)) if i % 2 == 1][::-1]
    c = [a[i] for i in range(len(a)) if i % 2 == 0]
    ans = list(map(str, b + c))
    print(" ".join(ans))


Measured memory_bytes: 34832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int x, t;
	cin >> x >> t;
	if (x - t >= 0) {
		cout << x - t << endl;
	}
	else if (x - t < 0) {
		cout << 0 << endl;
	} 
}

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

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

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

using namespace std;

#define f first
#define s second

pair<char, int> r[10];

bool sameColor(char x, char y, char z){
  if(x == y && y == z) return true;
  else return false;
}

bool sameNumber(int x, int y, int z){
  if(x == y && y == z) return true;
  else return false;
}

bool isContinue(int x, int y, int z){
  if((x == y-1 && x == z-2) || (x == y+1 && x == z+2)) return true;
  else return false;
}

bool solve(){
    do{
    int cnt = 0;
    
    for(int i = 0 ; i <= 6 ; i += 3){
      if(sameColor(r[i].f, r[i+1].f, r[i+2].f)){
	if(isContinue(r[i].s, r[i+1].s, r[i+2].s) ||
	   sameNumber(r[i].s, r[i+1].s, r[i+2].s)){
	  cnt++;
	}
      }
    }
    if(cnt == 3){
      return true;
    }
    }while(next_permutation(r, r+9));
}

int main(){
  int cs;

 
  cin >> cs;
  while(cs--){
    int B=0, G=0, R=0;
    
    for(int i = 0 ; i < 9 ; i++) cin >> r[i].s;
    for(int i = 0 ; i < 9 ; i++){
      cin >> r[i].f;
      if(r[i].f == 'B') B++;
      if(r[i].f == 'G') G++;
      if(r[i].f == 'R') R++;
    }
    
    if(B%3 != 0 || G%3 != 0 || R%3 != 0){
      cout << 0 << endl;
      continue;
    }

    bool ans = false;
    ans = solve();
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
s = input()
start0 = 0
start1 = 0
for i,j in enumerate(s):
    if ~i&1:
        start0 += (j=="1")
        start1 += (j=="0")
    else:
        start0 += (j=="0")
        start1 += (j=="1")
print(min(start0,start1))

Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <cctype>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

int main () {
    
    int n; cin >>n;
    vector<int> p(n); REP(i,n) cin >> p[i];

    int count = 0;
    for (int i = 1; i <= n; i++) {
        if (i != p[i-1]) {
            count++;
        } 
    }

    if (count <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    } 

    return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll w, h, x, y;
  scanf("%lld%lld%lld%lld", &w, &h, &x, &y);
  printf("%lf %d", w * h / 2.0, (!(w & 1) && !(h & 1) && x == w / 2 && y == h / 2) ? 1 : 0);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int i, j;
	int sort[5];
	int tmp;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &sort[i]);
	}
	
	for (i = 0; i < 5; i++){
		for (j = 4; j > i; j--){
			if (sort[j] > sort[j - 1]){
				tmp = sort[j - 1];
				sort[j - 1] = sort[j];
				sort[j] = tmp;
			}
		}
	}
	
	for (i = 0; i < 5; i++){
		printf("%d", sort[i]);
		if (i < 4){
			printf(" ");
		}
	}
	printf("\n");
	
	return (0);
}

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

#define ran 101101

int n, m;
pair<int, int> v[ran];
priority_queue<int> q;

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<n;i++) {
		scanf("%d%d", &v[i].first, &v[i].second);
	}
	sort(v, v+n);
	
	while(!q.empty()) q.pop();
	int it = 0;
	long long ans = 0;
	for(int i=m;i>0;i--) {
		while(it<n && v[it].first + i <= m+1) {
			q.push(v[it++].second);
		}
		if (!q.empty()) {
			ans += q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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


typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;
typedef vector<vll> vvll;


#define F first
#define S second
#define pb push_back
#define mp make_pair

// don't edit before this line 



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



ll n;
vld arr;
ld memo[3000][3000];
bool check[3000][3000];

ld func(int x,int h){
	if(x==n-1)
	{
		if(h>n/2)
			return (ld)1.0;
		else
		{
			if(h==n/2)
				return arr[n-1];
			else
				return (ld)0.0;
		}
		
	}

	if(check[x][h])
		return memo[x][h];
	check[x][h]=true;
	return memo[x][h]=arr[x]*func(x+1,h+1) + ((ld)1.0-arr[x])*func(x+1,h);
	
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n;
	arr.resize(n);

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

	for(int i=0;i<3000;i++)
		for(int j=0;j<3000;j++){
			check[i][j]=false;
		}
	cout<<func(0,0)<<"\n";
	
	return 0;
}


Measured memory_bytes: 149888
import math
n,k=map(int, input().split())
ans=0
for i in range(1,n+1):
    temp = math.log2(k)-math.log2(i)
    if temp<0:
        ans+=1/n
    else:
        ite = math.ceil((math.log2(k)-math.log2(i))/math.log2(2))
        ans+=pow(0.5,ite)/n
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  rep(i,h) cin>>a[i];
  vi b(26);
  rep(i,h)rep(j,w) b[a[i][j]-'a']++;
  bool f=true;
  if(h%2&&w%2){
    int x=0,y=0;
    rep(i,26){
      if(b[i]%2) x++;
      if(b[i]%4==2) y++;
    }
    if(x==1&&y<=(h-1)/2+(w-1)/2) f=true;
    else f=false;
  }else if(h%2==0&&w%2==0){
    rep(i,26) if(b[i]%4!=0) f=false;
  }else{
    int x;
    if(h%2) x=w/2;
    else x=h/2;
    int p=0;
    rep(i,26){
      if(b[i]%4==2) p++;
      if(b[i]%2) f=false;
    }
    if(f&&(p<=x)) f=true;
    else f=false;
  }
  YesNo(f);
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256