akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> ans;
int a[105];
int n,i,schimbat,j;
int main()
{
    //freopen("data.in","r",stdin);
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    while(n>0)
    {
        schimbat=0;
        for(i=n;i>=1&&(!schimbat);i--)
        {
            if(a[i]==i)
            {
                for(j=i;j<n;j++)
                    a[j]=a[j+1];
                ans.push_back(i);
                n--;
                schimbat=1;
            }
        }
        if(!schimbat)
        {
            cout<<"-1";
            return 0;
        }
    }
    reverse(ans.begin(),ans.end());
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<'\n';
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll calc[(ll)5e5 + 42] = {0};
ll mod = 998244353;
int main() {

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

  ll n = 0, k = 0;

  cin >> n >> k;

  vector<pair<ll, ll> > lr(k);

  for(ll i = 0; i < k; i++) cin >> lr[i].fi >> lr[i].se;

  ll cur = 0;

  for(ll j = 0; j < k; j++)
    for(ll i = lr[j].fi; i <= lr[j].se; i++) {
      calc[i] += 1;
      calc[i + 1] += -1;
    }

  for(ll i = 1; i < n; i++) {
    calc[i] = (calc[i] + mod) % mod;
    cur += calc[i];
    cur %= mod;
    for(ll j = 0; j < k; j++) {
      calc[i + lr[j].fi] += cur;
      calc[i + lr[j].fi] %= mod;
      calc[i + lr[j].se + 1] -= cur;
      calc[i + lr[j].se + 1] %= mod;
    }
  }

  for(ll i = 1; i < n; i++) { calc[i] += calc[i - 1]; calc[i] %= mod; }

  cout << (((calc[n - 1] % mod) + mod) % mod);

  return 0;
}
/*

*/


Measured memory_bytes: 6716
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long n,k;
  cin >> n >> k;
  if((n-1)*(n-2)/2<k){
    cout << -1 << endl;
    return 0;
  }
  cout << n-1+(n-1)*(n-2)/2-k << endl;
  for(int i=2;i<=n;i++){
    cout << 1 << " " << i << endl;
  }
  long long cnt=0;
  for(int i=2;i<=n-1;i++){
    for(int j=i+1;j<=n;j++){
      if(cnt==(n-1)*(n-2)/2-k){
        return 0;
      }
      cout << i << " " << j << endl;
      cnt++;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0,c-(a-b))<<endl;    
    return 0;
}

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

// 1個置くと3増えて全体でN*Q
// クオリティQは3の倍数になる必要がある(N != 0 mod 3)

using block = vector<string>;
// Quality 1
block b3 = {
        "a..",
        "a..",
        ".aa"
};
// Quality 3
block b4 = {
        "aacd",
        "bbcd",
        "cdaa",
        "cdbb"
};
// Quality 3
block b5 = {
        "aabbc",
        "bc..c",
        "bc..d",
        "c.ccd",
        "cddee"
};
// Quality 3
block b7 = {
        "ac..c..",
        "ac..c..",
        "b.cc.cc",
        "bc..c..",
        "ac..c..",
        "a.cc.cc",
        ".aabbaa"
};

void horizontal_add(block &a, block b){
    for (int i = 0; i < a.size(); ++i) a[i] += b[i];
}

void vertical_add(block &a, block b){
    a.insert(a.end(), b.begin(), b.end());
}

block solve_k(int n, block b){
    block res = b;
    for (int i = 0; i < n - 1; ++i) {
        horizontal_add(res, b);
    }
    block unit = res;
    for (int i = 0; i < n - 1; ++i) {
        vertical_add(res, unit);
    }
    return res;
}

block solve(int n){
    block res;
    if (n % 3 == 0) return solve_k(n/3, b3);
    if (n % 4 == 0) return solve_k(n/4, b4);
    int t = __builtin_ctz(n);
    int m = n >> t; // m >= 5 が保証される
    if ((m - 1) % 4) res = b7;
    else res = b5;
    for (int i = 0; i < (m - 5) / 4; ++i) {
        horizontal_add(res, block(res.size(), "...."));
        string s(res.size(), '.');
        block below(4, s);
        horizontal_add(below, b4);
        vertical_add(res, below);
    }
    return solve_k(n/m, res);
}

int main() {
    int N;
    cin >> N;
    if (N == 2) {
        cout << -1 << "\n";
    } else {
        auto ans = solve(N);
        for (int i = 0; i < N; ++i) {
            cout << ans[i] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

char a[40][5];
int b[40];
int mark[40], tt[40];
int n;
bool flag;

void bubble_sort() {
	for(int i=0; i<n-1; i++) {
		for(int j=n-1; j>i; j--) {
			if(b[mark[j]] < b[mark[j-1]]) {
				swap(mark[j], mark[j-1]);
			}
		}
	}
}

void select_sort() {
	for(int i=0; i<n-1; i++) {
		int tmp = i;
		for(int j=i; j<n; j++) {
			if(b[mark[tmp]] > b[mark[j]]) {
				tmp = j;
			}
		}
		if(tmp != i) {
			swap(mark[tmp], mark[i]);
		}
	}
}

bool check_stable() {
	for(int i=0; i<n; i++) {
		if(mark[i] != tt[i]) return false;
	}
	return true;
}

void mark_init() {
	for(int i=0; i<n; i++) {
		mark[i] = i;
	}
}

void output() {
	for(int i=0; i<n; i++) {
		cout << a[mark[i]];
		if(i == n-1) cout << endl;
		else cout << " ";
	}	
	if(flag) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}

int main() {
//	freopen("/Users/liyingyan/Documents/ACM/in.txt", "r", stdin);
	std::ios::sync_with_stdio(false);
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> a[i];
		b[i] = a[i][1] - '0';
	}
	
	mark_init();
	bubble_sort();
	flag = true;
	output();
	for(int i=0; i<n; i++) {
		tt[i] = mark[i];
	}
	

	mark_init();
	select_sort();
	flag = check_stable();
	output();	
	return 0;
}


Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int x, y;

        while(true) {
            x = sc.nextInt();
            y = sc.nextInt();

            if(x==0 && y==0) {
                break;
            } else if(x<y) {
                System.out.printf("%d %d\n", x, y);
            } else {
                System.out.printf("%d %d\n", y, x);
            }

        }
    }
}


Measured memory_bytes: 41692
S = input()
li = []
a = 0
cnt = 0
for i in range(len(S)):
    if a == 0 and S[i] == "A":
        a = 1
        cnt += 1
    elif a == 1 and S[i] == "Z":
        cnt += 1
        li.append(cnt)
    elif a == 1:
        cnt += 1
print(max(li))

Measured memory_bytes: 7504
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string.h>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 500010;
int n = 0, q = 0;

struct Query{
	int id, l, r;
	bool operator< (Query a) const{
		return r < a.r;
	}
}query[maxn];



int v[maxn], sum[maxn], ans[maxn];

int lowbit(int x){
	return x & (-x);
}

void change(int i, int a){
	while(i <= n){
		sum[i] += a;
		i += lowbit(i);
	}
}

int getsum(int i){
	int sum_t = 0;
	while(i > 0){
		sum_t += sum[i];
		i -= lowbit(i);
	}
	return sum_t;
}

int main() {
	
	scanf("%d", &n);
		memset(v, 0, sizeof(v));
		memset(sum, 0, sizeof(sum));
		memset(ans, 0, sizeof(ans));
		
		int t = 0;scanf("%d", &q);
		for(int i = 1; i <= n; i++){
			scanf("%d", &v[i]);
		}
		
		for(int i = 1; i <= q; i++){
			scanf("%d%d", &query[i].l, &query[i].r);
			query[i].id = i;
		}
		sort(query + 1, query + q + 1);
		
		int pre = 1;
		map<int, int> mymap;
		for(int i = 1; i <= q; i++){
			for(int j = pre; j <= query[i].r; j++){
				//已存在 
				if(mymap[v[j]]){
					change(mymap[v[j]], -1);
				}
				mymap[v[j]] = j;
				change(j, 1);
			}
			pre = query[i].r + 1;
			ans[query[i].id] = getsum(query[i].r) - getsum(query[i].l - 1);
		}
		
		for(int i = 1; i <= q; i++){
			cout << ans[i] << endl;
		}
	
    int ab;
    cin>>ab;
	return 0;
}

Measured memory_bytes: 38872
N = int(input())
D = []
for i in range(N):
    D.append(list(map(int,input().split())))
ans = 0
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0] ==D[i+2][1]:
        ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

template<class T>bool chmax( T& a, const T& b ) { if( a < b ) { a = b; return 1; } return 0; }
template<class T>bool chmin( T& a, const T& b ) { if( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int N, D; cin >> N >> D;
    cout << ( N + 2 * D ) / ( 2 * D + 1 ) << endl;
}


Measured memory_bytes: 256
def digit(x):
    cnt = 0
    if x == 0: cnt = 1
    else:
        while x > 0:
            x //= 10
            cnt+=1
    return cnt
n = int(input())
ans = 0
for i in range(1,n+1):
    if digit(i) % 2 == 1: 
        ans+=1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 10000000
using namespace std;
int main(){
  int n;
  cin >> n;
  string str[51];
  int table[60][30]={};
  for(int i=0; i<n; i++){
    cin >> str[i];
    for(int j=0; j<str[i].size(); j++){
      table[i][str[i][j]-'a']++;
    }
  }
  vector<char> ans;
  for(int i=0; i<30; i++){
    int Min = INF;
    for(int j=0; j<n; j++){
      Min = min(table[j][i],Min);
      //cout << Min << endl;
    }
    for(int j=0; j<Min; j++){
      ans.push_back(i+'a');
    }
  }
  for(int i=0; i<ans.size(); i++){
    cout << ans[i];
  }
  cout << endl;
  /*
  for(int i=0; i<n; i++){
    for(int j=0; j<26; j++){
      cout << table[i][j] << " ";
    }
    cout << endl;
    }*/
  return 0;
}


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

using namespace std;

int main()
{   
    long long n = 0;
    cin >> n; 
    if(n % 2 == 0){
        cout << n/2;
    }else{
        cout << (n-1)/2 + 1;
    }
    return 0;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===




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

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

	double ans;

	if (d == 0) {
		ans = (double)(m - 1) / n;
	}
	else {
		ans = (double)2 * (n - d) * (m - 1) / ((double)n * n);
	}

	cout << setprecision(9) << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main() {
	int N;
	cin >> N;
	ll os = 0, es = 0, ma = LLONG_MIN;
	vector<ll> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		if (i & 1) {
			if (A[i] > 0)os += A[i];
		}
		else {
			if (A[i] > 0)es += A[i];
		}
		ma = max(ma, A[i]);
	}
	queue<int> Q;
	if (os == 0 && es == 0) {
		cout << ma << endl;
		int ti;
		for (ti = N - 1;ti >= 0;ti--) {
			if (A[ti] == ma)break;
			Q.push(ti + 1);
		}
		for (int i = 0;i < ti;i++) {
			Q.push(1);
		}
		cout << Q.size() << endl;
		while (!Q.empty()) {
			cout << Q.front() << endl;
			Q.pop();
		}
		return 0;
	}

	bool ze = 1;
	if (es > os) {
		cout << es << endl;
		for (int i = 0;i < N;) {
			if (A[i] < 0) {
				Q.push(i + 1);
				if (i != N - 1) {
					A.erase(A.begin() + i + 1);
					N--;
				}
				if (i != 0) {
					A.erase(A.begin() + i - 1);
					N--;
				}
				else {
					i++;
					ze = 0;
				}
			}
			else {
				i += 2;
			}
		}
	}
	else {
		cout << os << endl;
		ze = 0;
		for (int i = 1;i < N;) {
			if (A[i] < 0) {
				Q.push(i + 1);
				if (i != N - 1) {
					A.erase(A.begin() + i + 1);
					N--;
				}
				A.erase(A.begin() + i - 1);
				N--;
			}
			else {
				i += 2;
			}
		}
	}

	for (int i = ze;i < N;) {
		Q.push(i + 1);
		if (i == 0) {
			i++;
			N--;
		}
		else {
			N -= 2;
		}
	}
	cout << Q.size() << endl;
	while (!Q.empty()) {
		cout << Q.front() << endl;
		Q.pop();
	}
}

Measured memory_bytes: 256
n = input()
if n.count(n[0]) == 3:
    print(n)
else:
    num = int(str(n[0])+str(n[0])+str(n[0]))
    if int(n) > num:
        a = min(int(n[0])+1, 9)
        print("%d%d%d" % (a, a, a))
    else:
        print(num)


Measured memory_bytes: 9124
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const ll MOD = 10000000007;
int main()
{
    string s, t;
    cin >> s >> t;
    int res = 0;
    for (int i = 0; i <= s.length() - t.length(); ++i)
    {
        int ct = 0;
        for (int j = 0; j < t.length(); ++j)
        {
            if (t[j] == s[i + j])
            {
                ct++;
            }
        }
        res = max(ct, res);
    }
    cout << t.length() - res << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>

using namespace std;

void solve(string s) {
    vector<int> bin(3, 0);
    int len = s.size();
    for (int i = 0; i < len; i++) {
        bin[s[i] - 'a']++;
    }
    if (len >= 4 && abs(bin[0]-bin[1]) <= 1 && abs(bin[0]-bin[2]) <= 1 && abs(bin[2]-bin[1]) <= 1 ) {
        std::cout << "YES" << std::endl;
    } else if (len == 3 && bin[0] == bin[1] && bin[0] == bin[2]){
        std::cout << "YES" << std::endl;
    } else if (len == 2 && (bin[0] != 2 && bin[1] != 2 && bin[2] != 2)) {
        std::cout << "YES" << std::endl;
    } else if(len == 1) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}

int main() {
    struct timeval start,end;
    long long span;
    string s;

    gettimeofday(&start,NULL);

    std::cin >> s;
    solve(s);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


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

using namespace std;

int main()
{
	long long x;
	cin >> x;
	if(x&1)
	{
		cout << 0 << endl;
		return 0;
	}
	long long n=x;
	long long ans=0;
	while(x>=5)
	{
		ans+=x/5;
		x/=5;
	}
	x=n;
	while(x>=5)
	{
		ans-=(x/5+1)/2;
		x/=5;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
use text_io::*;

fn main() {
    let n: usize = read!();
    let m: usize = read!();
    let x: usize = read!();
    
    let mut books = vec![vec![]; n];
    let mut costs = vec![];
    for i in 0..n {
        let c: usize = read!();
        costs.push(c);
        for _ in 0..m {
            let a: usize = read!();
            books[i].push(a);
        }
    }
    
    let mut min: Option<usize> = None;
    
    for i in 0..1 << n {
        let mut cost = 0;
        let mut vec = vec![0; m];
        for j in 0..n {
            if (1 << j) & i == 0 {
                cost += costs[j];
                for k in 0..books[j].len() {
                    vec[k] += books[j][k];
                }
            }
        }
        if vec.iter().all(|&y| y >= x) {
            min = Some(min.unwrap_or(std::u64::MAX as usize).min(cost));
        }
    }
    
    println!("{}", min.map(|y| y as isize).unwrap_or(-1));
}




Measured memory_bytes: 2168
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,m,x;

Vi c;
matrix a;


int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>m>>x;
    c.resize(n);
    a.resize(m,Vi(n));
    rep(i,n){
        cin>>c[i];
        rep(j,m){
            cin>>a[j][i];

        }
    }
    ll ans =INF;
    rep(i,1LL<<n){
        ll tmp = 0;
        Vi v(m,0);
        rep(j,n){
            if(i & (1LL<<j)){
                tmp += c[j];
                rep(k,m){
                    v[k] += a[k][j];
                }
            }
        }
        bool ck = true;
        rep(j,m){
            if(v[j]<x){
                ck = false;
                break;
            }
        }
        if(ck)chmin(ans,tmp);
    }
    if(ans!=INF)print(ans);
    else print(-1);
    return 0;
}

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

typedef long long ll;

const int Maxn = 5005;

int k, q;
ll d[Maxn], D[Maxn];

ll getSmall(ll a, ll b, ll x, ll mod)
{
    if (x == 0) return -1;

}

int main()
{
    scanf("%d %d", &k, &q);
    for (int i = 1; i <= k; i++)
        scanf("%lld", &d[i]);
    while (q--) {
        ll n, x, mod; scanf("%lld %lld %lld", &n, &x, &mod);
        ll zers = 0, sum = 0;
        D[0] = x % mod;
        for (int i = 1; i <= k; i++) {
            D[i] = D[i - 1] + d[i] % mod;
            if (d[i] % mod == 0) zers++;
            sum += d[i] % mod;
        }
        ll tims = (n - 1) / k;
        int lst = (n - 1) % k;
        ll lef = D[0];
        ll rig = tims * sum + D[lst];
        ll all = rig / mod - (lef > 0? (lef - 1) / mod: 0);
        all += tims * ll(zers);
        for (int i = 1; i <= lst; i++)
            all += d[i] % mod == 0;
        ll res = n - 1 - all;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 384
fun main(args:Array<String>){
    val line = readLine()!!.split(" ").map { it.toLong() }
    val h = line[0]
    val w = line[1]
    if(h==1L||w==1L){
        println(1)
    }else {
        if (h * w % 2 == 0L) println(h * w / 2) else println(h * w / 2 + 1)
    }
}

Measured memory_bytes: 37904
#include <bits/stdc++.h>
#define roop0(n) for(long long i = 0;i < n;i++)
#define roop1(n) for(long long i = 1;i < n;i++)
#define rep(i,a,b) for(long long i = a; i < b; i++)
#define print(a) for(auto x : a) cout << x << " "; cout << "\n"
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using namespace std;
typedef long long ll;
using vi   = vector<int>;
using vll  = vector<ll>;
using vs   = vector<string>;
using vvi  = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvs  = vector<vector<string>>;

int main () {
  int n; cin >> n;
  ll A[n]; roop0(n) cin >> A[i];
    
  ll money = 1000;
  ll kabu = 0;
  for (int i = 0;i < n - 1;i++) {
    
    if (A[i] >= A[i + 1]) // 今日が高いから売る
    {
        money += A[i] * kabu;
        kabu = 0;
    }
    else if (A[i] < A[i + 1]) // 今日が安いから買う
    { 
      ll buyable = money / A[i];
      money -= buyable * A[i];
      kabu += buyable;
    }
    // debug3(A[i],money,kabu);
  }
  if (kabu > 0) money += kabu * A[n - 1];
  cout << money << endl;
  
  return 0;
}


Measured memory_bytes: 3588
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
void solv() {
	int n;
	cin >> n;
	ll sum = 0;
	ll mi = INF;
	ll ma = -INF;
	for (size_t i = 0; i < n; i++)
	{
		ll a;
		cin >> a;
		sum += a;
		mi = min(a, mi);
		ma = max(a, ma);
	}
	cout << mi << " " << ma << " " << sum << endl;
}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int w,h,i,j;
int field[52][52];

void dfs(int x, int y){
    //埋め立て
    field[x][y]=0;
    
    if(field[x][y+1]==1) dfs(x,y+1);
    if(field[x][y-1]==1) dfs(x,y-1);
    
    if(field[x+1][y+1]==1) dfs(x+1,y+1);
    if(field[x+1][y-1]==1) dfs(x+1,y-1);
    if(field[x+1][y]==1) dfs(x+1,y);
    
    if(field[x-1][y+1]==1) dfs(x-1,y+1);
    if(field[x-1][y-1]==1) dfs(x-1,y-1);
    if(field[x-1][y]==1) dfs(x-1,y);
}


int main(){
    while(cin>>w>>h && w!=0 && h!=0){
        for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
                int a;
                scanf("%d",&a);
                field[i][j]=a;    
            }
        }
    
        int cnt=0;
    
        for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
                if(field[i][j]==1){
                    dfs(i,j);
                    cnt++;
                }    
            }
        }
        
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3436
(defun main ()
  (let* ((N (read))
         (p-list (loop for x from 1 to N
                       collect (read))))
    (setq p-list (sort p-list #'>))
    (let ((result 0)
          (first-step nil))
      (dolist (x p-list)
        (if (null first-step)
          (progn (setq result (+ result (/ x 2)))
                 (setq first-step t))
          (setq result (+ result x))))
      (princ result))))

(main)

Measured memory_bytes: 12512
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    double r,S,L,PI;
    PI = M_PI;
    cin >> r;

    S = r*r*PI;
    L = 2*r*PI;

    printf("%f %f\n",S,L );
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  
  string T;
  T += S.at(0);
  for (int i = 1; i < N; i++)
  {
    if (T.at(i - 1) == '0') T += '1';
    else T += '0';
  }
  
  int ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (S.at(i) != T.at(i)) ans++;
  }
  
  cout << ans << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 1e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

int h[MAXN];
ll dp[MAXN];
void solve() {
    int n;
    cin >> n;
    dp[1] = 0;
    for(int i=1;i<=n;++i){
        cin >> h[i];
    }
    dp[0] = inf_ll;
    for(int i=2;i<=n;++i){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n]<<"\n";

}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout <<endl<< (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 1408
n = int(input())
*lst, = map(int, input().split())

for i in range(1, n):
    print(*lst)
    v = lst[i]
    j = i - 1

    while j>=0 and lst[j]>v:
        lst[j+1] = lst[j]
        j -= 1

    lst[j+1] = v
    
print(*lst)


Measured memory_bytes: 5980
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
    string s; cin >> s;
    ll n = s.size();
    int k; cin >> k;
    vector<vector<pair<ll,ll>>> dp(n+2,vector<pair<ll,ll>>(103,make_pair(0,0)));
    dp.at(1).at(0) = make_pair(1,0);
    dp.at(1).at(1) = make_pair((ll)(s.at(0) - '1'),1);
    for(int i=1;i<n;i++){
        for(int j=0;j<=i;j++){
            dp.at(i+1).at(j).first += dp.at(i).at(j).first;
            dp.at(i+1).at(j+1).first += dp.at(i).at(j).first * 9;
            if(dp.at(i).at(j).second == 1){
                if(s.at(i) == '0'){
                    dp.at(i+1).at(j).second = 1;
                }else{
                    dp.at(i+1).at(j).first++;
                    dp.at(i+1).at(j+1).first += (ll)(s.at(i) - '1');
                    dp.at(i+1).at(j+1).second = 1;
                }
            }
        }
    }
    /*
    rep(i,n+1){
        rep(j,10){
            cout << dp.at(i).at(j).first << dp.at(i).at(j).second << " ";
        }
        cout << endl;
    }
    */
    cout << dp.at(n).at(k).first + dp.at(n).at(k).second << endl;
}

Measured memory_bytes: 384
# coding:utf-8
import math
x = int(input())
num = math.floor(x ** 0.5)
ans = 1

for i in range(1, num + 1):
    for j in range(2, x):
        if i ** j > x:
            break
        if i ** j > ans:
            ans = i ** j

print(ans)


Measured memory_bytes: 3060
#!python3

iim = lambda: map(int, input().rstrip().split())
from collections import defaultdict

def resolve():
    N, K, C = iim()
    S = input()

    C1 = C+1
    i, cnt, ax = N-1, 0, [0] * K
    while i >= 0:
        if S[i] != "o":
            i -= 1
        else:
            cnt += 1
            ax[K-cnt] = i
            i -= C1
            if cnt == K:
                break

    ans, ri, cnt, i  = [], len(ax)-1, 0, 0
    while i < N:
        if S[i] != "o":
            i += 1
        else:
            if i == ax[cnt]:
                ans.append(i+1)
            i += C1
            cnt += 1
            if cnt == K:
                break
    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 24156
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

  double ans = 0;
  for(int i = 0; i < n; i++){
    double temp; cin >> temp;
    ans += 1/temp;
  }

  cout << setprecision(6) << 1/ans << endl;

  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF ((1<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()



int n, k; 
int a[200000];
int imos[200001];


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

	cin >> n >> k;
	rep(i, n)cin >> a[i];

	rep(_, min(k, 50)) {
		rep(i, n + 1)imos[i] = 0;
		rep(i, n) {
			imos[max(0, i - a[i])]++;
			imos[min(n, i + a[i] + 1)]--;
		}
		int x = 0;
		rep(i, n) {
			x += imos[i];
			a[i] = x;
		}
	}

	rep(i, n) {
		if (i)cout << ' ';
		cout << a[i];
	}
	cout << endl;


	return 0;
}


Measured memory_bytes: 5216
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int A, B, C, X ,Y;
    cin >> A >> B >> C >> X >> Y;
    int base=0;
    if(A+B>2*C){
        if(X>Y){
            base=Y*(2*C);
        }
        else{
            base=X*(2*C);
        }
    }
    else{
        if(X>Y){
            base=Y*B+Y*A;
        }
        else{
            base=X*B+X*A;
        }
    }
    if(X>Y){
        if(A>2*C){
            base+=(X-Y)*(2*C);
        }
        else{
            base+=(X-Y)*A;
        }
    }
    else if(Y>X){
        if(B>2*C){
            base+=(Y-X)*(2*C);
        }
        else{
            base+=(Y-X)*B;
        }
    }

    cout << base << endl;
}

Measured memory_bytes: 256
def asindex(c):
    return ord(c) - ord('a')


def asstr(i):
    return chr(i + ord('a'))


def main():
    n = int(input())
    S = [50 for _ in range(26)]

    for _ in range(n):
        tmp = [0 for _ in range(26)]
        for c in input():
            tmp[asindex(c)] += 1

        for i in range(26):
            S[i] = min(S[i], tmp[i])

    ans = ''
    for i in range(26):
        for _ in range(S[i]):
            ans += asstr(i)

    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
    ll N,K;
    cin>>N>>K;
    ll h[N];
    rep(i,N) cin>>h[i];
    sort(h, h+N);
    // rep(i, N) cout<<h[i]<< " ";
    // cout << endl;
    ll d_min = h[N-1] - h[0];
    ll d = 0;
    for(ll i=K-1; i<N; i++){
        d = h[i] - h[i-K+1];
        // cout << h[i-K+1] << " " << h[i] << ":" << d << endl;
        if(d < d_min){
            d_min = d;
        }
    }
    cout << d_min << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>

#define FOR(i,N) for(int i=0;i<N;i++)

using namespace std;

int main(){
	int N[3];
	FOR(i,3){
	cin>>N[i];
	}
	if(N[0]==N[1]){
		if(N[0]==N[2]){
			cout<<"1";
		}
		else 
			cout<<"2";
	}
	else if(N[0]==N[2])
		cout<<"2";
	else if(N[1]==N[2])
		cout<<"2";
	else
		cout<<"3";
return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 0; i < 100000; i++) {
        if (i * i <= N) {
            ans = i * i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	if (n == 1) {
		cout << 1;
		return 0;
	}
	int ans = 1;
	string prv = s.substr(0, 1);
	for (int i = 1; i < n; i++) {
		if (s.substr(i, 1) != prv) {
			ans++;
			prv = s.substr(i, 1);
		}
		else if(s.substr(i, 2) != prv) {
			ans++;
			prv = s.substr(i, 2);
			i += 1;
		}
	}
	cout << ans;
}


Measured memory_bytes: 640
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.stream.Stream;

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

        int N = sc.nextInt();
        int[] A = new int[N];
        for (int i = 0; i < A.length; ++i) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(A));

        sc.close();
    }

    static long solve(int[] A) {
        Map<Integer, Integer> lengthToCount = new HashMap<>();
        for (int length : A) {
            lengthToCount.put(length, lengthToCount.getOrDefault(length, 0) + 1);
        }

        int[] sortedLengths = lengthToCount.keySet().stream().filter(length -> lengthToCount.get(length) >= 2)
                .flatMap(length -> (lengthToCount.get(length) >= 4) ? Stream.of(length, length) : Stream.of(length))
                .sorted(Collections.reverseOrder()).mapToInt(x -> x).toArray();

        return (sortedLengths.length >= 2) ? ((long) sortedLengths[0] * sortedLengths[1]) : 0;
    }
}

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

int main(){
   
   while(1){
       vector<int>vec(2);
       cin >>vec.at(0)>>vec.at(1);
       if((vec.at(0) != 0)||(vec.at(1) != 0)){
            sort(vec.begin(), vec.end());
            cout << vec.at(0)<<" "<<vec.at(1)<< endl;
       }else{
           break;
       }
   }
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(void){
    int N; cin>>N; 
    vector<ll> a(N);
    for(int i=0;i<N;i++) cin>>a[i];
    vector<int> s(N+1,0);
    for(int i=0;i<N;i++) s[i+1]=s[i]+a[i];
    
    // 区間 [left, right) の総和を求める
    int ans=INF;
    for(int i=0;i<N;i++){
        chmin(ans,abs(s[i+1]-(s[N]-s[i+1])));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
S = sorted([int(input()) for _ in range(n)])
ans = 0
caution = 0
flag = 1
for s in S:
    ans += s
    if flag:
        if s % 10:
            caution = s
            flag = 0
if ans % 10 == 0:
    if caution:
        ans -= caution
    else:
        ans = 0
print(ans)        

Measured memory_bytes: 3064
from collections import deque

K=int(input())
# BFS
M=0
L=9
tmp=deque([1,2,3,4,5,6,7,8,9])
while L<K:
    k=str(tmp.popleft())
    if int(k[-1])-1>=0:
        tmp.append(int(k+str(int(k[-1])-1)))
        L+=1
    tmp.append(int(k+k[-1]))
    L+=1
    if int(k[-1])+1<10:
        tmp.append(int(k+str(int(k[-1])+1)))
        L+=1
    M+=1# 取り出した数

print(tmp[K-1-M])

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

#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second

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

const int MOD = 1e9+7;

int main() {

	ios::sync_with_stdio(0);
	cin.tie(0);

	ll x,k,d;
	cin >> x >> k >> d;
	x = abs(x);
	ll need = (x-1)/d+1;
	if (need<k) {
		k-=need;
		if (k&1) {
			cout << min(abs(x-(need*d)+d),abs((x-need*d)-d));
		} else {
			cout << abs(x-(need*d)) << "\n";
		}
	} else {
		cout << abs(x-(k*d)) << "\n";
	}
}

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

int main(void){
	int a, b;
	cin>>a>>b;
	char grid[100][100];
	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			if(i<50){
				grid[i][j] = '.';
			}else{
				grid[i][j] = '#';
			}
		}
	}
	a--;
	b--;
	int x = 1, y = 1;
	while(b>0){
		grid[x][y] = '#';
		if(y+2 >= 100){
			y = 1;
			x+= 2;
		}else{
			y+=2;
		}
		b--;
	}
	x = 51;
	y = 1;
	while(a>0){
		grid[x][y] = '.';
		if(y+2 >= 100){
			y = 1;
			x+= 2;
		}else{
			y+=2;
		}
		a--;
	}
	cout << 100 << " " << 100 << endl;
	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			cout<<grid[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(100000, 0);
  for (int i = 0; i < n; i++) {
    int ai; cin >> ai;
    if(ai != 0) a[ai - 1]++;
    a[ai]++;
    if(ai != 99999) a[ai + 1]++;
  }
  int ans = 0;
  for (int i = 0; i < 100000; i++) {
    ans = max(ans, a[i]);
  }
  cout << ans;
}

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

int main(){
	int A,B,C,D;
	int ans;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	if (B<C||D<A){
		ans=0;
	}
	else{
		if (A<C){
			if (B<D){
				ans=B-C;
			}
			else{
				ans=D-C;
			}
		}
		else{
			if (D<B){
				ans=D-A;
			}
			else{
				ans=B-A;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define gt(n) scanf("%d", &n)
#define gtll(n) scanf("%ld", &n)
#define out(n) printf("%d", n)
#define outll(n) printf("%ld", n)
#define loop(n) for(int i=0; i<n; i++)
#define MAXX 1001
#define mem(x, y) memset(x, y, sizeof(x))
#define loop1(n) for(int i=1; i<=n; i++)
#define ll long long
#define pb push_back
#define pi acos(-1)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
//(only in c)char[33];itoa(n,buffer,base);printf("%s",buffer);
#define dec_to_bin(n) std::string binary = std::bitset<64>(n).to_string();
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
fast;
int x,y;
cin>>x>>y;
if(x<y)cout<<0<<endl;
else cout<<10<<endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string S, T; cin >> S >> T;
    REP(i, 0, S.size()) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

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


int main(){

	double w;
	while(~scanf("%lf",&w)){
		if(w <= 48.0){
			cout << "light fly" << endl;
		}
		else if(48.0 < w && w <= 51.0){
			cout << "fly" << endl;
		}
		else if(51.0 < w && w <= 54.0){
			cout << "bantam" << endl;
		}
		else if(54.0 < w && w <= 57.0){
			cout << "feather" << endl;
		}
		else if(57.0 < w && w <= 60.0){
			cout << "light" << endl;
		}
		else if(60.0 < w && w <= 64.0){
			cout << "light welter" << endl;
		}
		else if(64.0 < w && w <= 69.0){
			cout << "welter" << endl;
		}
		else if(69.0 < w && w <= 75.0){
			cout << "light middle" << endl;
		}
		else if(75.0 < w && w <= 81.0){
			cout << "middle" << endl;
		}
		else if(81.0 < w && w <= 91.0){
			cout << "light heavy" << endl;
		}
		else if(91.0 < w){
			cout << "heavy" << endl;
		}
	}
}

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

int main() {
  int N,cnt_r=0,cnt_b=0;
  string s;
  cin >> N >> s;
  for(int i=0; i<N; i++) {
    if(s[i]=='R') {
      cnt_r++;
    }
    else {
      cnt_b++;
    }
  }
  if(cnt_r>cnt_b) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,k;
    cin >> n >> k;

    int cnt = 1;
    while(true)
    {
        n -= 2;
        if(n > 0){
            cnt++;
        }else{
            break;
        }
    }
    
    if(cnt >= k){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b;
  while(cin >> a >> b){
    int g = __gcd(a,b);
    cout << g << " " << a/g*b << endl;
  }
}




Measured memory_bytes: 3020
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstring>

using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    vector<bool>br(N + 1);
    for(int i = 0; i < M; i++){
        int temp;
        cin >> temp;
        br[temp] = 1;
    }
    vector<int>dp(N + 2);
    const int mod = 1000000007;
    dp[N] = 1;
    for(int i = N - 1; i >= 0; i--){
        if(br[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod; 
    }
    cout << dp[0] << endl;
}

Measured memory_bytes: 640
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;
use nalgebra::max;
use std::cmp::min;

#[fastout]
fn main() {
    input! {
    s: Chars,
    t: Chars
    }
    let mut ans = std::usize::MAX;
    let ns = s.len();
    let nt = t.len();
    for i in 0..=ns - nt{
        let mut tmp = 0;
        for j in 0..nt {
            if s[i + j] == t[j] {
                tmp += 1;
            }
        }
        ans = min(ans, nt - tmp);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2144