akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	res := map[string]int{
		"AC":  0,
		"WA":  0,
		"TLE": 0,
		"RE":  0,
	}
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		res[s]++
	}

	fmt.Printf("AC x %d\n", res["AC"])
	fmt.Printf("WA x %d\n", res["WA"])
	fmt.Printf("TLE x %d\n", res["TLE"])
	fmt.Printf("RE x %d\n", res["RE"])
}


Measured memory_bytes: 6332
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
 
     
int main(){
 
    double a,b,c,d,e,f,kai1,kai2;
 
    while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
 
 
        kai1=(c*e/b-f)/(a*e/b-d);
 
        kai2=(c-a*kai1)/b;
 
 
 
        printf("%.3lf %.3lf\n",kai1+0.00001,kai2+0.00001);
 
    }
    return 0;
}

Measured memory_bytes: 652
//Date and time of submission: 
 
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=1e5+5;
ll a,b,c;
int main() {
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	cin>>a>>b>>c;
	if(b-a==c-b)
	cout<<"YES";
	else
	cout<<"NO";
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
//const int nax = 2e5+500;
//const ll INF = 1e18+5;
//vector<int> t;
//void build(vector<int> &a, int v, int tl, int tr) {
	//if(tl == tr) {
		//t[v] = a[tl];
		//return;
	//}
	//int mid = (ll)(tl+tr)/2;
	//build(a,v*2,tl,mid);
	//build(a,v*2+1,mid+1,tr);
	//t[v] = max(t[v*2],t[v*2+1]);
//}
//int getmax(int v, int tl, int tr, int l, int r) {
	//if(l > r) return -1;
	//if(l == tl && r == tr) {
		//return t[v];
	//}
	//int mid = (ll)(tl+tr)/2;
	//return max(getmax(v*2,tl,mid,l,min(r,mid)),getmax(v*2+1,mid+1,tr,max(l,mid),r));
//}
int main() {
	int n;
	cin >> n;
	//ll base = 1;
	//while(base<=n) {
		//base*=2;
	//}
	//t.assign(2*base,0);
	vector<int> a(n);
	for(int &i:a) {
		cin >> i;
	}
	//int root = 1, tl = 0, tr = n-1;]
	//build(a,root,tl,tr);
	ll needed = 0;
	int myet = -1;
	for(int i=0;i<n;i++) {
		myet = max(myet,a[i]);
		if(myet > a[i]) {
			needed+=myet - a[i];
		}
	}
	cout<<needed;
}


Measured memory_bytes: 3956
#getting input from user
#cranes and turtle already give the information
#condition yes or no 
X,Y= map(int,input().split())
cranes= 2
turtles= 4
ans="No"
for i in range(X+1):
    b=X-i
    if cranes*i + turtles*b == Y:
        ans = "Yes"
print(ans)

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#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 REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n;
    cin >> n;

    vll a(n);
    REP(i, n) {
      cin >> a[i];
    }

    vll back_add(n);

    back_add[0] = a[n - 1];
    FOR(i, 1, n - 1) {
      back_add[i] = (a[n - i - 1] + back_add[i - 1]) % MOD ;
    }
    // COUTA(i, back_add);

    ll ans = 0;
    REP(i, n - 1) {
      ans += (a[i] * back_add[n - i - 2]) % MOD;
    }

    COUT(ans % MOD);

}

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

/*

3 2
*/


Measured memory_bytes: 6352
#include<bits/stdc++.h>
using namespace std;
      
int main(){
  string S;
  cin >> S;
  int N=S.size();
  int count1=0,count2=0;
  for(int i=0;i<N;i++){
    if(i%2==0 && S.at(i)=='0'){
      count1++;
    }
    else if(i%2==1 && S.at(i)=='1'){
      count1++;
    }
    if(i%2==0 && S.at(i)=='1'){
      count2++;
    }
    else if(i%2==1 && S.at(i)=='0'){
      count2++;
    }
  }
  cout << min(count1,count2) << endl;
}
    

Measured memory_bytes: 3664
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;

int main(int argc, char* argv[]) {

	int N, D, X,i,cnt,ans = 0;

	cin >> N;
	cin >> D >> X;

	vector<int> A(N);

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

	for (int j = 0; j < N; j++) {
		ans++;
		i = 1;
		cnt = i * A[j] + 1;
		while(cnt <= D) {
			i++;
			ans++;
			cnt = i * A[j] + 1;
		}
	}

	ans+=X;

	cout << ans << endl;

	return 0;

}


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

class Myon

{
    public Myon() { }
    public static int Main()
    {
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }
    static Scanner cin;

    void calc()
    {
        int N = cin.nextInt();
        string S = cin.next();
        int pre = 0;
        int now = 0;
        foreach (var c in S)
        {
            if (c == '(') now++;
            else now--;
            if(now < 0) { now++; pre++; }
        }
        Console.WriteLine(new string('(', pre) + S + new string(')', now));
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
        
    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}





Measured memory_bytes: 11092
import math
N=int(input())
dp=[math.inf for _ in range(N+1)]
dp[0]=0
for i in range(1,N+1):
	p=1
	q=1
	while p<=i:
		dp[i]=min(dp[i],dp[i-p]+1)
		p*=6
	while q<=i:
		dp[i]=min(dp[i],dp[i-q]+1)
		q*=9
print(dp[N])

Measured memory_bytes: 9792
#include "bits/stdc++.h"
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define LLINF (long long) 1e18//1234567890987654321
#define INF 1234567890ll
#define pb push_back
#define ins insert
#define f first
#define s second	
#define db 0
#define EPS (1e-7)    //0.0000001 the value
#define PI (acos(-1))
#define MAXN (300006)
#define MAXK 26
#define MAXX 15000006
#define ll long long int 
#define ld long double
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
#define FOR(ii, ss, ee) for(ll ii = ss; ii < ee; ii++)
#define space " "
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define ph push
#define btinpct(x) __builtin_popcountll(x)
#define p2(x) (1LL<<(x))
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
typedef pair <ll, ll> pi;
typedef pair <ll, pi> spi;
typedef pair <pi, pi> dpi;
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss
ll n, q;
string A;
pair <char,char> Q[MAXN];
int main()
{
	FAST
	cin >> n >> q >> A;
	for(ll i=0;i<q;i++) cin>>Q[i].f>>Q[i].s;
	ll st = -1, en = n, mid = 0;
	while(en-st>1) {
		mid = (st+en)>>1;
		ll co = mid; bool can = 0;
		for(ll i=0;i<q;i++) {
			if(co >= n||co<0) break;
			if(Q[i].f == A[co]) {
				co -= (Q[i].s == 'L');
				co += (Q[i].s == 'R');
			}
		}
		if(co==-1) can = 1;
		if(can) st=mid;
		else en=mid;
	}
	ll tmp = st+1; cerr << tmp << '\n';
	st = -1, en = n, mid = 0;
	while(en-st>1) {
		mid = (st+en)>>1ll;
		ll co = mid; bool can = 0;
		for(ll i=0;i<q;i++) {
			if(co >= n||co<0) break;
			if(Q[i].f == A[co]) {
				co -= (Q[i].s == 'L');
				co += (Q[i].s == 'R');
			}
		}
		if(co>=n) can = 1;
		if(can) en = mid;
		else st = mid;
	}
	cerr << en << '\n';
	ll out = tmp + (n-en);
	cout << n-out << '\n';
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    fastio;
    int r;
    cin >> r;
    cout << 2 * M_PI * r << "\n";
    return 0;
}


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

int main()
{
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    rep(i, N) cin >> p[i];
    int min = 9999999;
    int min_n = X;
    for (int i = -1; i <= 110; i++)
    {
        auto cIter = find(p.begin(), p.end(), i);
        if (cIter == p.end())
        {
            if (min > abs(i - X))
            {
                min = abs(i - X);
                min_n = i;
            }
        }
    }
    cout << min_n << endl;
}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

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

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

int main(){
    int n; cin >> n;
    ll ans = -1 * 1e11;
    vector<vector<int>> lis(n, vector<int>(10, 0)), lis2(n, vector<int>(11, 0));
    REP(i, 0, n){
        REP(l, 0, 10){cin >> lis[i][l];}
    }
    REP(i, 0, n){
        REP(l, 0, 11){cin >> lis2[i][l];}
    }
    vector<int> lis3(n, 0);
    REP(i, 1, (1 << 10)){
        int k = i;
        int ind = 0;
        //cout << k << endl;
        while(k > 0){
            if(k & 1){
                REP(l, 0, n){
                    //cout << lis3[l] << lis[l][ind] << endl;
                    lis3[l] = lis3[l] + lis[l][ind];
                }
            }
            k = (k >> 1);
            ind++;
        }
        ll mid = 0;
        REP(l, 0, n){
            mid += lis2[l][lis3[l]];
        }
        ans = max(ans, mid);
        lis3 = vector<int>(n, 0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;
mint dp[101][100001];
int N,K;
int main(){
	cin>>N>>K;
	dp[0][0] = 1;
	rep(i,N){
		int a;
		cin>>a;
		V<mint> tmp(K+1);
		rep(j,K+1){
			tmp[j] += dp[i][j];
			if(j+a+1 <= K) tmp[j+a+1] -= dp[i][j];
		}
		rep(j,K) tmp[j+1] += tmp[j];
		rep(j,K+1) dp[i+1][j] = tmp[j];
	}
	cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 40064
//AtCoder ABC105 B - Cakes and Donuts
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
    ll N; cin>>N;
    ll amx=N/4;
    ll bmx=N/7;
    bool ans=false;
    for(ll i=0;i<=amx;++i){
        for(ll j=0;j<=bmx;++j){
            if(N==i*4+j*7) ans=true;
        }
    }
    cout<<(ans?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int N;
  cin >> N;
  
  vector<int> A(N);
  
  int num = 1e9;
  int num2 = -1e7;
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  for(int i = 0;i < N;++i){
    num = min(num,A[i]);
    num2 = max(num2,A[i]);
  }
  
  cout << num2 - num << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int cnt = sc.nextInt();
      String str = sc.next();
	  //Sの長さを求める
      int len = str.length();
      if(len <= cnt)
      {
      	 System.out.println(str);
      }
      else
      {
      	String new_str = str.substring(0, cnt);
        new_str += "...";
        System.out.println(new_str);
      
      }
    }
}

Measured memory_bytes: 38428
fun main(args: Array<String>) {
    abc058C()
}

fun abc058C() {
    val n = readLine()!!.toInt()
    val firstString = readLine()!!.toCharArray().sortedArray()
    val stringList = (1 until n).map { readLine()!!.toCharArray().sortedArray().toMutableList() }
    val buff = mutableListOf<Char>()

    firstString.forEach {
        if (stringList.all { charList -> charList.contains(it) }) {
            buff += it
            stringList.forEach { charList -> charList.remove(it) }
        }
    }

    buff.sort()

    println(buff.joinToString(separator = ""))
}


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

vector<int>ans[2000];
int square[40][40];
void disp(int N,int K) {
	cout << N << ' ' << K << endl;
	rep(i, N) {
		rep(j, ans[i].size()) {
			if (j)cout << ' '; cout << ans[i][j];
		}cout << endl;
	}
}

signed main() {
	int K = 38, N = K*(K - 1) + 1;

	rep(i, K - 1) {
		rep(j, K - 1) {
			square[i][j] = K + i*(K - 1) + j + 1;
		}
	}

	rep(i, K) {
		ans[i].push_back(1);
		rep(j, K - 1)ans[i].push_back(i * (K-1) + j+2);
	}

	rep(i, K - 1) {
		rep(j, K - 1) {
			int L = K + i*(K - 1) + j;
			ans[L].push_back(i + 2);
			rep(m, K-1) {
				ans[L].push_back(square[m][(i*m+j)%(K-1)]);
			}
		}
	}

	disp(N, K);
}

Measured memory_bytes: 1280
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
        for(int i=0;i<b;i++){int c = sc.nextInt();
                            a-=c;}
		System.out.println(Math.max(-1,a));
	}
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A,B,C;
  cin>>A>>B>>C;
  if(A<=C&&C<=B)cout<<"Yes"<<endl;
  else if(B<=C&&C<=A)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n, w, wi, vi;
    cin >> n >> w;
    
    vector<int> dp(1000*n+1, INF);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> wi >> vi;
        for (int j = 1000*n; j >= vi; --j) {
            dp[j] = min(dp[j], dp[j - vi] + wi);
        }
    }
    
    for (int i = 1000*n; i >= 0; --i) {
        if (dp[i] <= w) return cout << i << "\n", 0;
    }
    
    return 0;
}

Measured memory_bytes: 3984
word = input()


def check(word):
  flg = True
  n = len(word)
  for i in range(int(n/2)):
    if word[i] != word[n-i-1]:
      flg = False
      break
  
  return flg

n = len(word)
if check(word) and check(word[:int((n-1)/2)]) and check(word[int((n+3)/2)-1:]):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a,b,k=1,len=0,sum,q;
    cin>>a>>b;
    while(k<=b)
    {
        k=k*10;
        len=len+1;
    }
    sum=a*pow(10,len)+b;
    q=sqrt(sum);
    if (q*q==sum)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        
        int n = scan.nextInt();
        int[] arr = new int[n];
        int sum = 0;
        for(int i = 0; i < n; i++) {
            arr[i] = scan.nextInt();
            sum += arr[i];
        }
        
        int t = scan.nextInt();
        while(t-- > 0){
            int index = scan.nextInt() - 1;
            int time = scan.nextInt();
            
            System.out.println(sum + time - arr[index]);
        }
    }
}


Measured memory_bytes: 25300
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

n,a,b,c,d = map(int,input().split())
Max = 1005
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def C(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod
#mod計算した順列の計算
def P(n,r):
    if n < r:
        return 0
    if n<0 or r<0:
        return 0
    return (fac[n]*finv[n-r])%mod

#dp[i][j]:i人以下のグループだけでj人使っている場合の数
dp = [[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=1

for i in range(a,b+1):
    for j in range(1,n+1):
        dpij = dp[i-1][j]
        k = c
        while k <= j//i and k <= d:
            x = (fac[j] * finv[j - k * i] * finv[k] * pow(finv[i], k, mod)) % mod
            dpij += (dp[i - 1][j - k * i] * x) % mod
            k += 1
        dp[i][j] = dpij%mod
print(dp[b][n])

Measured memory_bytes: 130524
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int n = 0 ;
    bool flg = 0 ;
    int num[200][3] = {0} ;
    cin >> n ;
    for ( int i = 0 ; i < n ; i++ )
    {
        cin >> num[i][0] >> num[i][1] >> num[i][2] ;
    }
    for ( int i = 0 ; i < 3 ; i++ )
    {
        for ( int j = 0 ; j < n-1 ; j++ )
        {
            flg = false ;
            for ( int k = j+1 ; k < n ; k++ )
            {
                if ( num[j][i] == num[k][i] )
                {
                    num[k][i] = 0 ;
                    flg = true ;
                }
            }
            if ( flg ) num[j][i] = 0 ;
        }
    }
    for ( int i = 0 ; i < n ; i++ )
    {
        cout << num[i][0]+num[i][1]+num[i][2] << endl ;
    }

    return 0 ;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using node = pair<string,ll>;
const ll inf = numeric_limits<ll>::max()/3;
const ll mod = 1e9+7;

int main(void) {
  string s;
  cin >> s;
  vector< ll > bindex;
  for(int i = 0;i < (int)s.size();++i){
    if(s[i] == 'B'){
      bindex.push_back((ll)(i+1));
    }
  }
  reverse(bindex.begin(),bindex.end());
  ll res = 0;
  for(int i = 0;i < (int)bindex.size();++i){
    res += (ll)s.size() - i - bindex[i];
  }
  cout << res << endl;
}


Measured memory_bytes: 2680
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#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>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#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 fi first
#define sc second
#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 LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010],ans=0,now=2;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ans+=a[0]-1;
    rep2(i,1,n){
        if(a[i]<now) continue;
        if(a[i]==now){
            now++;
            continue;
        }
        ans+=a[i]/now-(a[i]%now==0);
        a[i]-=(a[i]/now-(a[i]%now==0))*now;
        now=max(now,a[i]);
        // cout<<i<<" "<<ans<<" "<<now<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define pb push_back
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto i : x) {cerr << " [" <<  i << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vii = vector<pii>;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 1e18 + 100;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int n, l, sum = 0, mn = inf, answer;
	cin >> n >> l;
	for (int i = 1; i <= n; i++){
		sum += l + i - 1;
	}
	for (int i = 1; i <= n; i++){
		int temp = 0;
		for(int j = 1;j <=n;j++){
			if(i != j){
				temp += l + j - 1;
				if(abs(temp - sum) < mn){
					mn = abs(temp - sum);
					answer = temp;
				}
			}
		}
	}
	cout << answer << "\n";
	return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	In := readLineInt()
	sort.Ints(In)

	if In[0] == In[1] {
		fmt.Println(In[2])
	} else if In[1] == In[2] {
		fmt.Println(In[0])
	} else {
		fmt.Println(In[1])
	}
}

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

func readLineInt() []int {
	result := make([]int, 0)
	for _, v := range strings.Split(readLine(), " ") {
		i, _ := strconv.Atoi(v)
		result = append(result, i)
	}
	return result
}

var reader = bufio.NewReaderSize(os.Stdin, 1e6)

func readLine() string {
	result := make([]byte, 0, 1e6)
	for {
		line, remains, e := reader.ReadLine()
		if e != nil {
			panic(e)
		}
		result = append(result, line...)
		if !remains {
			break
		}
	}
	return string(result)
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
int main()
{
	string a,b; 
	cin>>a>>b;
	a=a+b;
	int i,x=0;
	for(i=0;i<=a.size()-1;i++)
		x=x*10+(a[i]-'0');
	
	i=1;
	while(i<=x)
	{
		if(i*i==x)
		{
			cout<<"Yes";
			return 0;
		}
		else
			i++;
	}
	
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	set<string> s;
	long long int n;
	cin>>n;
	string st;
	for(int i=0;i<n;i++){
		cin>>st;
		s.emplace(st);
	}
	cout<<s.size()<<endl;
}

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

#define int long long
#define ll long long
#define pb push_back

main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        mp[a[i]]++;
    }
    int ans = 0;
    for (auto v : mp){
        ans += (v.second * (v.second - 1) / 2);
    }
    for(int i = 0; i < n; i++){
        if (i > 0){
            int y = mp[a[i - 1]];
            mp[a[i - 1]]++;
            ans = ans - (y * (y - 1) / 2) + ((y + 1) * y / 2);
        }
        int x = mp[a[i]];
        mp[a[i]]--;
        ans = ans - (x * (x - 1) / 2) + ((x - 1) * (x - 2) / 2);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 11008
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 5e5+5, MOD = 1e9+7;
int t,n,m,k,x,y;
const int M=160*80+1;
int dp[81][81][M];
int a[81][81];
int b[81][81];

int main()
{
	IOS;
	cin>>n>>m;
	forn(i,n)forn(j,m) cin>>a[i][j];
	forn(i,n)forn(j,m) cin>>b[i][j];
	x = abs(a[0][0]-b[0][0]);
	dp[0][0][x]=1;
	forn(i,n){
		forn(j,m){
			forn(k,M){
				if(dp[i][j][k]){
					dp[i+1][j][k+abs(a[i+1][j]-b[i+1][j])]=1;
					dp[i+1][j][abs(k-abs((a[i+1][j]-b[i+1][j])))]=1;

					dp[i][j+1][k+abs(a[i][j+1]-b[i][j+1])]=1;
					dp[i][j+1][abs(k-abs((a[i][j+1]-b[i][j+1])))]=1;				
				}
			}
		}
	}
	int ans=0;
	forn(i,M){
		if(dp[n-1][m-1][i]){
			ans=i;
			break;
		}
	}
	cout<<ans<<ln;
}


Measured memory_bytes: 326784
H, W = map(int, input().split())
a = list()
for _ in range(H):
    a.append(input())

row = [False] * H
col = [False] * W
for i in range(H):
    for j in range(W):
        if a[i][j] == '#':
            row[i] = True
            col[j] = True
for i in range(H):
    if row[i]:
        for j in range(W):
            if col[j]:
                print(a[i][j], end='')
        print()


Measured memory_bytes: 4468
#include<stdio.h>
#include<stdlib.h>
 
int preOrder[40],inOrder[40];

void solve(int l,int r){
  int i;
  static int p=0;
  // int x=preOrder[p];

  if(l>r) return;
  if(l==r){
    if(inOrder[l]==preOrder[0]){
      printf("%d",inOrder[l]);
    }
    else{
      printf("%d ",inOrder[l]);
    } 
    p++;
    return;
  }
  //printf("aaa");
  int x=preOrder[p];
  p++;
  for(i=l;i<=r;i++){
    if(inOrder[i]==x) break;
  }
  solve(l,i-1);
  solve(i+1,r);
   
  if(x==preOrder[0]) printf("%d",x);
  else printf("%d ",x);
}
 
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&preOrder[i]);
  for(i=0;i<n;i++) scanf("%d",&inOrder[i]);
  solve(0,n-1);
  printf("\n");
  return 0;
}

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

int main() { 
  string s;
  cin>>s;
  if(s.size()<6) cout<<"No";
  else{
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes";
    else cout<<"No";
  }
  return 0; 
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanln(&n)
	v := make([]int, n)
	c := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&v[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&c[i])
	}

	ans := 0
	for i := 0; i < n; i++ {
		diff := v[i] - c[i]
		if diff > 0 {
			ans += diff
		}
	}
	fmt.Println(ans)
}


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

#define SWAP(type, a, b) do { type t = a; a = b; b = t; } while(0)

int cnt = 0;

void selectionSort(int *array, int n) {
    for(int i = 0; i < n - 1; i++) {
        int minIdx = i;
        for(int j = i + 1; j < n; j++) {
            if(array[j] < array[minIdx]) {
                minIdx = j;
            }
        }
        if(i != minIdx) {
            SWAP(int, array[i], array[minIdx]);
            cnt++;
        } // AOJ
    }
}

void printArray(int *array, int n) {
    for(int i = 0; i < n;) {
        printf("%d", array[i]);
        i++;
        if(i < n) {
            printf(" ");
        }
    }
    printf("\n");
}

int main(void) {
    int n;

    scanf("%d", &n);

    int *array = malloc(n * sizeof(int));
    if(array == NULL) {
        return 1;
    }

    for(int i = 0; i < n; i++) {
        scanf("%d", &array[i]);
    }

    selectionSort(array, n);

    printArray(array, n);

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

    return 0;
}


Measured memory_bytes: 2112
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

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

   int num[200] = {0};

   rep(i,s.size()){
      num[s[i]]++;
   }

   int ans = -1;
   for(int i=97;i<123;i++){
      if(num[i] == 0) {
         ans = i; 
         break;
      }
   }

   if(ans == -1) cout << "None" << endl;
   else cout << char(ans) << endl;

   return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 10'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << "-1\n";
  } else {
    cout << a * b << '\n';
  }
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

long double a, b, x;

void input() {
    cin >> a >> b >> x;
}

long double f(long double a, long double b, long double x) {
    long double ans;
    if(a * a * b / 2.0 <= x) {
        ans = atan(2 * (a * a * b - x) / (a * a * a));
    } else {
        ans = PI / 2 - atan(2 * x / (a * b * b));
    }
    return ans;
}

void solve() {
    input();
    cout << fixed << setprecision(10) << f(a, b, x) * 180.0 / PI << endl;
    return;
}

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


Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    int s;
    int a[1000000],i,j;
    scanf("%d",&s);
    a[0]=s;
    for(i=0;i<1000000;i++){
        if(a[i]%2==0){
            a[i+1]=a[i]/2;
        }else{
            a[i+1]=3*a[i]+1;
        }
        for(j=0;j<i;j++){
            if(a[j]==a[i]){
                printf("%d",i+1);
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
  int a,b,d,r;
  double f;
  cin >> a >> b;
  d = a/b;
  r = a%b;
  f = (double)a/(double)b;
  cout << d << " " << r << " " ;
  printf("%.8lf\n",f);
}



Measured memory_bytes: 3244
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char a[5];
    for(int i=0;i<4;i++)
    scanf("%c",&a[i]);
    if((a[0]==a[1])||(a[1]==a[2])||(a[2]==a[3])||(a[3]==a[4]))
    printf("Bad\n");
    else
        printf("Good\n");
    return 0;
}


Measured memory_bytes: 256
[x, y] = [x for x in map(int, input().split(' '))]
flg = -1
if y % 2 == 1:
  flg = 1
else:
  for i in range(0, x):
    if i * 2 + (x - i) * 4 == y or (x - i) * 2 + i * 4 == y:
      flg = 0
      break
print('Yes' if flg == 0 else 'No')

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N; cin>>N;
    vector<long long int> H(N);
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    reverse(H.begin(),H.end());
    bool can=false;
    if(N==1){
        cout<<"Yes";
    }
    for(int i=1;i<N;i++){
        if(H[i-1]>=H[i]){
            can=true;
        }
        else{
            H[i]=H[i]-1;
            if(H[i-1]>=H[i]&&H[i]>=0){
                can=true;
            }
            else{
                cout<<"No";
                return 0;
            }
        }
    }
    if(can){
        cout<<"Yes";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string alp = "abcdefghijklmnopqrstuvwxyz";
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
void neg() {cout << -1 << endl;}

//幅優先探索(グリッド)
//{i, j}:始点の添字
//{gi, gj}:終点の添字
//visit:1:訪問済みの添字
//task:訪問予定の添字
//pushしたマスは訪問済みにすること
//returnの仕方は問題に合わせて適宜変更すること
vi bfs1 = {1, 0, -1, 0}, bfs2 = {0, 1, 0, -1};
void bfs(ll h, ll w, vector<vll> &grid, ll i, ll j, ll height) {
  vector<vll> visit(h, vll(w, 0));
  queue<vll> task;
  grid.at(i).at(j) = height;
  task.push({i, j});
  visit.at(i).at(j) = 1;
  while (task.size() > 0) {
    ll sz = task.size();
    for (ll k = 0; k < sz; k++) {
      ll xx = task.front().at(0), yy = task.front().at(1);
      for (ll l = 0; l < 4; l++) {
        ll xxx = xx + bfs1.at(l), yyy = yy + bfs2.at(l);
        if (0 <= xxx && xxx < w) {
          if (0 <= yyy && yyy < h) {
            if (visit.at(xxx).at(yyy) == 0) {
              grid.at(xxx).at(yyy) = grid.at(xx).at(yy) + 1;
              task.push({xxx, yyy});
              visit.at(xxx).at(yyy) = 1;
            }
          }
        }
      }
      task.pop();
    }
  }
  return;
}

int main() {
  ll n;
  cin >> n;
  vll x(n), y(n), h(n);
  for (ll i = 0; i < n; i++) cin >> x.at(i) >> y.at(i) >> h.at(i);
  if (n == 1) {
    cout << x.at(0) << " ";
    cout << y.at(0) << " ";
    cout << 1 << endl;
    return 0;
  }
  vector<vll> ans(0); //{x座標, y座標, 高さ}
  for (ll i = 0; i < n; i++) {
    if (i == 0 && h.at(i) == 0) {
      x.push_back(x.at(0));
      y.push_back(y.at(0));
      h.push_back(h.at(0));
      x.erase(x.begin());
      y.erase(y.begin());
      h.erase(h.begin());
      i--;
      continue;
    }
    vector<vll> grid(101, vll(101));
    bfs(101, 101, grid, x.at(i), y.at(i), h.at(i));
    if (i == 0) {
      for (ll j = 0; j < 101; j++) {
        for (ll k = 0; k < 101; k++) {
          ans.push_back({j, k, grid.at(j).at(k)});
        }
      }
    }
    else {
      vector<vll> subans(0);
      for (ll j = 0; j < ans.size(); j++) {
        if (h.at(i) == 0) {
          if (ans.at(j).at(2) <= grid.at(ans.at(j).at(0)).at(ans.at(j).at(1))) {
            subans.push_back(ans.at(j));
          }
        }
        else {
          if (ans.at(j).at(2) == grid.at(ans.at(j).at(0)).at(ans.at(j).at(1))) {
            subans.push_back(ans.at(j));
          }
        }
      }
      if (subans.size() == 1) {
        cout << subans.at(0).at(0) << " ";
        cout << subans.at(0).at(1) << " ";
        cout << subans.at(0).at(2) << endl;
        return 0;
      }
      ans = subans;
    }
  }
}

Measured memory_bytes: 1340
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, M, s, t = map(int, input().split())
e = dd(list)
ee = dd(list)
for i in range(M):
  u, v, a, b = map(int, input().split())
  e[u].append((v, a))
  e[v].append((u, a))
  ee[u].append((v, b))
  ee[v].append((u, b))

import heapq
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 10)
      v0 = v // (10 ** 10)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 10) + p[0])
    return d
dij = dijkstra(N, e)
edij = dijkstra(N, ee)
p = dij.path(s, 0)
revp = edij.path(t, 0)
mny = pow(10, 15)
table = [0] * (N + 1)
for x in range(1, N + 1):
  table[x] = mny - p[x] - revp[x]
csmx = [0] * (N + 1)

for i in range(N, 0, -1): csmx[i - 1] = max(csmx[i - 1], table[i], csmx[i])
for i in range(N): print(csmx[i])

Measured memory_bytes: 132336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = tolower(S[K - 1]);
    cout << S << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

int main()
{
    int n;
    cin >> n;
    vector<ll> x(n);
    rep(i,n){
        cin >> x[i];
    }
    vector<ll> sorted;
    sorted = x;
    sort(sorted.begin(),sorted.end());
    ll left = sorted[n/2-1];
    ll right = sorted[n/2];
    rep(i,n){
        if(x[i]<=left){
            cout << right << endl;
        }else{
            cout << left << endl;
        }
    }
    
}


Measured memory_bytes: 5376
import itertools
from collections import Counter
import bisect
a = []
for i in range(3, 10):
    for j in itertools.product(["3", "5", "7"], repeat=i):
        if len(Counter(j)) == 3:
            a.append(int("".join(j)))
n = int(input())
print(bisect.bisect_right(a, n))

Measured memory_bytes: 4468
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		List<Integer> list = new ArrayList<>();
		list.add(sc.nextInt());	// P
		list.add(sc.nextInt());	// Q
		list.add(sc.nextInt());	// R
		
		list.sort(Comparator.naturalOrder());
		
		System.out.println(list.get(0) + list.get(1));
	}
	
	
}

Measured memory_bytes: 21844
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); ++i)
#define ROF(i,a,b) for (int i = (b); i >= (a); --i)
#define debug() cout << 1 << endl
#define fi first
#define se second
#define pii pair<int, int>
#define mp make_pair
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define ins insert
#define lb lower_bound
#define ub upper_bound
const long long mod = 1e9 + 7;
const double PI = acos(-1);
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int MAXN = 1e5 + 10;
#define LOCAL
template<class I>
inline void read(I &x) {
    x = 0; I f = 1; char c = getchar();
    while(c < '0' || c > '9') {if(c == '-') f = -1; c = getchar(); }
    while(c >= '0' && c <= '9') {x = x * 10 + c - '0'; c = getchar(); }
    x *= f;
}
int qpow(int a, int b){int res=1;while(b>0){if(b&1)res=res*a%mod;b=b>>1;a=a*a%mod;}return res % mod;}
ll gcd(ll a,ll b) { return b ? gcd(b, a % b) : a;}

int main() 
{
	ios::sync_with_stdio(false);
	cout.tie(0), cin.tie(0);
	// #ifdef LOCAL
	// freopen("data.in", "r", stdin);
	
	// #endif
	int t;
	ll x, k, d;
	cin >> x >> k >> d;
	ll c = abs(x) / d;
	ll ans = 0;
	if (c < k) {
		ll con = k - c;
		if (con >= 2) {
			con %= 2;
		}
		ll dis;
		if (x < 0) {
			dis = x + c * d;
			if (con == 0) {
				ans = abs(dis);
			}
			else {
				ans = min(abs(dis + d), abs(dis - d));
			}
		}
		else {
			dis = x - c * d;
			if (con == 0) {
				ans = abs(dis);
			}
			else {
				ans = min(abs(dis + d), abs(dis - d));
			}
		}
	}
	else {
		if (x < 0) {
			ans = abs(x + k * d);
		}
		else {
			ans = abs(x - k * d);
		}
	}
	cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644