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

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

const long long INF = 1LL << 60;
const long long mod = 1000000007;


int main(void){
    string s; cin >> s;
    int ans = 0;
    for(int i=0;i<s.size();i++){
	for(int j=i;j<s.size();j++){
	    if(s[j]=='A'||s[j]=='C'||s[j]=='G'||s[j]=='T') ans = max(ans,j-i+1);
	    else break;
	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	Scanner sc;
	LinkedList<Integer> gdlist;
	boolean[] primegd;
	final int max = 3000001;
	
	
	void createGD() {
		primegd = new boolean[max];
		gdlist = new LinkedList<Integer>();
		for(int i=0;i<max;i++) {
			primegd[i] = true;
		}
		for(int i=1;;i++) {
			if(i*7-1>max) break;
			if(primegd[i*7-1]) {
				gdlist.add(i*7-1);
				for(int j=2*(i*7-1);j<max;j+=i*7-1) primegd[j] = false;
			}
			if(primegd[i*7+1]) {
				gdlist.add(i*7+1);
				for(int j=2*(i*7+1);j<max;j+=i*7+1) primegd[j] = false;
			}
		}
		
	}
	
	void run() {
		sc = new Scanner(System.in);
		createGD();
		while (true) {
			int n = sc.nextInt();
			if(n == 1) break;
			System.out.print(n + ":");
			for(Integer it:gdlist) {
				if(n == 1 || it > n) break;
				if(n % it != 0) continue;
				else {
					System.out.print(" ");
					System.out.print(it);
//					while(n%it==0) n /= it;
				}
			}
			System.out.println();
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 28000
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

long long max(long long x, long long y){return (x > y ? x : y);}
long long min(long long x, long long y){return (x < y ? x : y);}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

#define ll int
#define FOR(i,a) for(ll i=0;i<(ll)a.size();i++)
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=1e5+500;
const ll inf=1e9+800;
const ll mod=1e9+7;

ll dp[1<<16];
ll xx[1<<16];
void cal(){
	xx[0]=0;
	for(ll i=2;i<(1<<16);i+=2){
		ll lb;
		for(ll j=0;j<16;j++){
			if((i>>j)&1){
				lb=j;
				break;
			}
		}
		xx[i]=(xx[i^(1<<lb)]^lb);
  	}
	dp[0]=0;
	for(ll i=2;i<(1<<16);i+=2){
		for(ll mas=i;mas>0;mas=((mas-1)&i)){
			if(xx[mas]==0)dp[i]=max(dp[i],dp[i^mas]+1);
		}
	}
}

ll a[maxn];
ll cnt[16];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);	
	ll n;
	cin>>n;
	for(ll i=1;i<n;i++){
		ll v,u,w;
		cin>>v>>u>>w;
		a[v]^=w;
		a[u]^=w;
	}
	for(ll i=0;i<n;i++){
		cnt[a[i]]++;
	}
	cnt[0]=0;
	ll ans=0;
	for(ll i=0;i<16;i++){
		ans+=cnt[i]/2;
		cnt[i]%=2;
	}
	ll res=0;
	ll t=0;
	for(ll i=0;i<16;i++){
		if(cnt[i]){
			res+=(1LL<<i);
			t++;
		}
	}
	cal();
	cout<<ans+t-dp[res];
}

















Measured memory_bytes: 1152
import math
x,k,d=map(int,input().split())
x1=abs(x)
if k*d<x1:
    print(x1-k*d)
else:
    a=math.ceil(x1/d)
    if (k-a)%2==0:
        print(abs(x1-d*a))
    else:
        print(abs(x1-d*(a-1)))

Measured memory_bytes: 9180
#include <cmath>
#include <chrono>
#include <random>
#include <ctime>
#include <algorithm>
#include <iosfwd>
#include <iostream>
#include <list>
#include <ostream>
#include <streambuf>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define fori(i, n) for(ll i = 0; i < (n); ++i)
#define forI(i, n) for(ll i = 1; i <= (n); ++i)
#define pll pair<ll, ll>
#define ff first
#define ss second

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")

#define pt pair<ll, ll>
#define x first
#define y second

pll operator+(pll a, pll b) { return {a.x + b.x, a.y + b.y}; }

mt19937 kek(14);
ll rand0m() {return kek();}                   //[0 ... n)
ll rand0m(ll x) {return rand0m() % x;}               //[0 ... n)
ll rand0m(ll minn, ll maxx) {return rand0m(maxx - minn + 1) + minn;}   //[minn ... maxx]

const ll MAXN = 1e5 + 1;
const ll mod = 1e9 + 7;
const ll INF = 1e18;

ll n, m;
vector<ll> g[MAXN];
ll w[MAXN];
ll b[MAXN];

void dfs(ll v, ll par=-1){
    ll wh = 1, bl = 1;
    for(ll to: g[v]){
        if(to == par) continue;
        dfs(to, v);
        wh = wh * ((w[to] + b[to]) % mod) % mod;
        bl = bl * w[to] % mod;
    }
    w[v] = wh;
    b[v] = bl;
}

void solve() {
    cin >> n;
    ull seed = n;
    fori(i, n - 1){
        ll a, b;
        cin >> a >> b;
        seed ^= a ^ b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    kek = mt19937(seed);
    ll root = rand0m(1, n);
    dfs(root);
    cout << (b[root] + w[root]) % mod;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    solve();
}

Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)



int main(){
	int n;
	cin >> n;
	vector<ll>a(n),b(n);
	ll s1=0,s2=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		s1 += a[i];
	}
	for(int i=0;i<n;i++){
		cin >> b[i];
		s2 += b[i];
	}
	ll p = s2-s1;
	ll x=0,y=0;
	for(int i=0;i<n;i++){
		if(a[i]<b[i]){
			x += (b[i]-a[i]+1)/2;
		}
		if(b[i]<a[i]){
			y += (a[i]-b[i]);
		}
	}
	if(p>=x&&p>=y){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
 
using namespace std;
 
#define PB push_back
#define MP make_pair
#define REP(i,n) for(int i=0;i<(n);i++)
 
int main() {
    long long n;
    cin>>n;
    long long ans=n-1;
    for(long long i=1;i*i<=n;i++){
        if(n%i==0)ans=min(ans,i+(n/i)-2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

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

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

//(ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=a[0]/2;
    rep(i,1,n){
        ans+=(a[i]+a[i-1]%2)/2;
        a[i]=max(a[i]-a[i-1]%2,0ll);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

	public static void main(String[] args) {

		List<Integer> nums = new ArrayList<>();

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String a = "DENIED";

		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			if(num % 2 == 0) nums.add(num);
		}

		if(nums.size() == 0) {
			a = "APPROVED";
		} else {
			for(int i = 0; i < nums.size(); i++) {
				if(nums.get(i) % 3 == 0 || nums.get(i) % 5 == 0) {
					if(i == nums.size() - 1) a = "APPROVED";
				} else {
					break;
				}
			}
		}

		System.out.println(a);
	}
}

Measured memory_bytes: 35764
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, Z, W = getlist()
	A = getlist()
	if N == 1:
		print(abs(A[0] - W))
	else:
		ans = max(abs(A[-1] - W), abs(A[-1] - A[-2]))
		print(ans)
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> x(n);
  rep(snip_i, n) cin >> x.at(snip_i);
  vector<int> y(m);
  rep(snip_i, m) cin >> y.at(snip_i);
  mint xm = 0, ym = 0;
  rep(i, n){
    xm += (ll)x.at(i) * (i);
    xm -= (ll)x.at(i) * (n-i-1);
  }
  rep(i, m){
    ym += (ll)y.at(i) * i;
    ym -= (ll)y.at(i) * (m-i-1);
  }
  mint ans = xm * ym;
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>

using namespace std;

class Counting {
	unsigned long long p, n;
	vector<long long> invMemo, facMemo, facInvMemo;
public:
	Counting(unsigned long long nn, unsigned long long np) {
		p = np;
		n = nn;
		invMemo.resize(n + 1);
		facMemo.resize(n + 1);
		facInvMemo.resize(n + 1);
		facMemo[0] = 1;
		facMemo[1] = 1;
		facInvMemo[0] = 1;
		facInvMemo[1] = 1;
		invMemo[0] = 0;
		invMemo[1] = 1;
		for (unsigned long long i = 2; i <= n; i++) {
			invMemo[i] = p - (p / i)*invMemo[p%i] % p;
			facMemo[i] = (facMemo[i - 1] * i) % p;
			facInvMemo[i] = (facInvMemo[i - 1] * invMemo[i]) % p;
		}
	}
	unsigned long long fac(unsigned long long k) {
		return facMemo[k];
	}
	unsigned long long facInv(unsigned long long k) {
		return facInvMemo[k];
	}
	unsigned long long choose(unsigned long long n, unsigned long long k) {
		if (!(0 <= k && k <= n))
			return 0;
		return (((facMemo[n] * facInvMemo[k]) % p)*facMemo[n - k]) % p;
	}
	unsigned long long divide(unsigned long long a, unsigned long long b) {
		return (a * invMemo[b]) % p;
	}
	unsigned long long mod(unsigned long long a) {
		a %= p;
		if (a < 0) a += p;
		return a;
	}
	unsigned long long power(unsigned long long a, unsigned long long e) {
		unsigned long long ans = 1;
		for (; e > 0; e /= 2) {
			if (e % 2 != 0)
				ans = ans * a % p;
			a = a*a%p;
		}
		return ans;
	}
};

string s;
int main() {
	cin >> s;
	while (s.size() > 0) {
		if (s.size() < 5) {
			cout << "NO" << endl;
			return 0;
		}
		if (s.substr(s.size() - 5, 5) == "dream") {
			s.erase(s.size() - 5, 5);
			continue;
		}
		if (s.substr(s.size() - 5, 5) == "erase") {
			s.erase(s.size() - 5, 5);
			continue;
		}
		if (s.substr(s.size() - 6, 6) == "eraser") {
			s.erase(s.size() - 6, 6);
			continue;
		}
		if (s.substr(s.size() - 7, 7) == "dreamer") {
			s.erase(s.size() - 7, 7);
			continue;
		}
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int sum = 0;
        for (int i = 0; i < m; i++) {
            sum += scanner.nextInt();
        }
        
        if (n - sum < 0) {
            System.out.println(-1);
        } else {
            System.out.println(n - sum);
        }
    }
}

Measured memory_bytes: 46376
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int H, W, K;
    cin >> H >> W >> K;
    vector<string> S(H);
    rep(i,H) cin >> S[i];

    ll ans = 0;

    for (int i = 0; i < bit(H); i++) for (int j = 0; j < bit(W); j++) {
        int count = 0;
        rep(l,H) rep(m,W) {
            if (S[l][m] == '#' && (i&bit(l)) == 0 && (j&bit(m)) == 0) count++;
        }
        if (count == K) ans++;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld double
long double PI =3.14159265;
using ll = long long;

const ll modo=998244353;
const ll ms=1e6+5;
const ll inf=1e17;


ll ar[ms];
ll mm[ms]={0};

int main()
{
    idfc;


    ll n,x,m;
    cin>>n>>x>>m;

    mm[x]=1;
    ar[1]=x;
    int i;
    int p1;
    int p2;
    for(i=2;i<=n;i++)
    {
        ar[i]=(ar[i-1]*ar[i-1])%m;
        if(mm[ar[i]])
        {
            p1=mm[ar[i]];
            p2=i;
            break;
        }
        mm[ar[i]]=i;
    }
    ll ans=0;
    ll dis;
    ll rem;
    if(i>n)
    {
     for(i=1;i<=n;i++)ans+=ar[i];
     cout<<ans;
    }
    else{
        dis=p2-p1;
        rem=(n-(p1-1))/dis;
        ll md=(n-(p1-1))%dis;
       // cout<<p2<<" "<<p1<<"\n";
      //  cout<<rem<<" "<<dis<<" "<<md<<"\n";
        for(i=1;i<p1;i++)ans+=ar[i];

        for(i=p1;i<p2;i++)
        {
            ans+=(ar[i]*rem);
        }
        for(i=1;i<=md;i++)
        {
            ans+=ar[p1];
            p1++;
        }
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 4700
#pragma GCC opointimize("Ofset_asc")
#pragma GCC opointimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC opointimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        // freopen("error.txt","w",stderr);
    #endif
}
const int mxN=int(3e3)+100;
ll dp[mxN][mxN];
int main()
{
    vok();
    ll a,b,c,d;
    IN a>>b>>c>>d;
    loop(i,a,c+1)
    {
        loop(j,b,d+1)
        {
            if(i==a && j==b)
            {
                dp[i][j]=1;
                continue;
            }
            dp[i][j]=0;
            if(i>a && j>=b)
            {
                dp[i][j]+=(dp[i-1][j]*j);
                dp[i][j]%=M;
            }
            if(i>=a && j>b)
            {
                dp[i][j]+=(dp[i][j-1]*i);
                dp[i][j]%=M;
            }
            if(i>a && j>b)
            {
                dp[i][j]-=(dp[i-1][j-1]*(i-1)%M*(j-1)%M);
                dp[i][j]%=M;
                dp[i][j]+=M;
                dp[i][j]%=M;
            }
        }
    }
    OUT dp[c][d]<<endl
    return 0;
}

Measured memory_bytes: 76232
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X = il()
    L = il()
    d, ret = 0, 1
    for l in L:
        d += l
        if d <= X:
            ret += 1
        else:
            break
    print(ret)


if __name__ == '__main__':
    main()


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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var xyh = new Tuple<int, int, int>[n];
			for (int i = 0; i < n; i++) {
				var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				xyh[i] = new Tuple<int, int, int>(temp[0], temp[1], temp[2]);
			}

			var enables = xyh.Where(t => t.Item3 >= 1).ToArray();
			var first = enables[0];
			if (enables.Count() == 1) {
				Console.WriteLine($"{first.Item1} {first.Item2} {first.Item3}");
				return;
			}

			var ans = new Tuple<int, int, int>(0, 0, 0);
			for (int x = 0; x < 101; x++) {
				for (int y = 0; y < 101; y++) {
					int h = first.Item3 + Math.Abs(first.Item1 - x) + Math.Abs(first.Item2 - y);
					bool ok = true;
					for (int i = 0; i < n; i++) {
						if (xyh[i].Item3 == 0) {
							continue;
						}

						int h2 = xyh[i].Item3 + Math.Abs(xyh[i].Item1 - x) + Math.Abs(xyh[i].Item2 - y);
						if (h != h2) {
							ok = false;
							break;
						}
					}

					if (ok) {
						if (h > ans.Item3) {
							ans = new Tuple<int, int, int>(x, y, h);
						}
					}
				}
			}

			Console.WriteLine($"{ans.Item1} {ans.Item2} {ans.Item3}");
		}
	}
}


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

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"

void testCase() {
    int n;
    ll w;
    cin >> n >> w;
    //weight, value
    vector < pair<ll, ll> > val;
    for (int i=0; i<n; i++) {
        ll w1, v1;
        cin >> w1 >> v1;
        val.push_back (make_pair(w1, v1)); 
    }
    ll dp[n+2][w+2];
    for (int i=0; i<=w; i++)
        dp[n][i] = 0;
    for (int i=n-1; i>=0; i--) {
        for (int k=0; k<=w; k++) {
            ll val1 = dp[i+1][k];
            ll val2 = 0;
            if (k+val[i].first <= w) 
                val2 = dp[i+1][val[i].first+k] + val[i].second;
            dp[i][k] = max (val1, val2);
        }
    }
    ll ans = 0;
    for (int i=0; i<=w; i++)
        ans = max (ans, dp[0][i]);
    cout << ans << endl;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 79232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#include<map>
#include<iomanip>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using pdd = pair<double,double>;
using vvi = vector<vector<int> >;
using vvll =  vector<vector<ll> >;

int main(){
    int N,K; cin >> N >> K;
    string S; cin >> S;
    int ans = 0;
    int count = 0;
    //int itr = 0;
    int turn = 0;
    REP(itr,N - 1){
        if(S[itr] == S[itr+1]){
            count++;
        }
        else{
            turn++;
        }
    }
    if(((turn+1) / 2) <= K){
        ans = count + turn;
    }
    else{
        ans = count + 2*K;
    }
    //cout << count << " " << turn << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3720
//https://atcoder.jp/contests/dp/tasks/dp_a
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int arr[100000],vis[100000];
ll go(int h[],int i,int n)
{
    if(i>=n)
        return INT_MAX;
    else if(i==n-1)
      return 0;
    ll a=INT_MAX,b=INT_MAX;
    if(vis[i+1]==1)
        a=arr[i+1]+abs(h[i]-h[i+1]);
    else
    {
        vis[i+1]=1;
         a=abs(h[i]-h[i+1]);
         arr[i+1]=go(h,i+1,n);
         a+=arr[i+1];
    }
   if(i<n-2)
    {
        if(vis[i+2]==1)
        {
            b=arr[i+2]+abs(h[i+2]-h[i]);
        }
        else
        {
            vis[i+2]=1;
            b=abs(h[i]-h[i+2]);
            arr[i+2]=go(h,i+2,n);
            b+=arr[i+2];
        }
    }
    return min(a,b);
}
int main()
{
    int n;
    cin>>n;
    int h[n],i;
    for(i=0;i<n;i++)
    {
        cin>>h[i];
    }
    memset(vis,0,sizeof(vis));
    cout<<go(h,0,n)<<'\n';
}


Measured memory_bytes: 7680
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pll pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define vll ve<ll>
#define vpl ve<pll>
#define lr(n) for(ll i = 0; i < n; i++)
#define ltr(i, l, r) for (ll i = l; i <= r; i++)
#define rtl(i, l, r) for (ll i = r; i >= l; i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define be begin
#define sz(a) (ll)(a.size())
#define con continue
#define ret return
#define endl "\n"
const ll INF = 1e18;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

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

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }


void solve(ll T){
	ll x;
	cin>>x;
	cout << 1-x << "\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main(){
char s[200000]={0},t[200000]={0};
int i ;
int count=0;
  scanf("%s",s);
  scanf("%s",t);
for(i=0;i<200000;i++){
	if(s[i] != t[i]) count++;
}
printf("%d",count);
}

Measured memory_bytes: 2124
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter
from operator import mul
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

m = a[0]
for i in range(1,n):
    m = m^a[i]

sol = [str(m^a[i]) for i in range(n)]
print(' '.join(sol))


Measured memory_bytes: 35940
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <sstream>      // std::ostringstream
#include<climits>
using namespace std;
int merge(vector<int> &a,int left,int mid,int right);
int mergeSort(vector<int> &a, int left, int right);
vector<string> split_s(const string &str, char sep);
vector<int> split_i(const string &str, char sep);
vector<int> split_i(const string &str)
{
  return split_i(str, ' ');
}
int main()
{
  string line;
  getline(cin, line);
  int size=stoi(line);
  vector<int> a;
  getline(cin, line);
  a = split_i(line, ' ');
  int hikakucnt=mergeSort(a, 0, size);
  line = "";
  for (int i = 0; i < a.size();i++)
  {
    line+=to_string(a[i]);
    if (i==a.size()-1)
    {
      break;
    }
    line += " ";
  }

  printf("%s",line.c_str());
  printf("\n");
  printf("%d", hikakucnt);
  printf("\n");
}
//文字列を分割して取得
vector<string> split_s(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_i(const string &str, char sep)
{
  vector<int> veci;
  stringstream ss(str);
  string buffer;
  while( getline(ss, buffer, sep) ) {
    veci.push_back(stoi(buffer));
  }
  return veci;
}
int merge(vector<int> &a,int left,int mid,int right)
{
  //printf("left,mid,right = %d,%d,%d  before : \n", left, mid, right);
  /*
  for(int i:a)
  {
    printf("%d ", i);
  }
  printf("\n");
  */
  vector<int> l;
  //l.resize(mid-left+1);
  for (int a_index = left; a_index < mid;a_index++)
  {
    //printf("l,a=%d,%d", l[a_index - left], a[a_index]);
    l.push_back(a[a_index]);
  }
    vector<int> r;
  //r.resize(right - mid+1);
  for (int a_index = mid; a_index < right; a_index++)
  {
    r.push_back(a[a_index]);
  }
  //copy(a.begin() + left, a.begin() + mid, l.begin());
  //copy(a.begin() + mid,a.begin()+right,r.begin());
  //printf("%d",INT_MAX);//2147483647
  l.push_back(INT_MAX);
  r.push_back(INT_MAX);
  /*
  for(int l_ :l)
  {
    printf("%d ", l_);
  }
  printf("\n");
  for(int l_ :r)
  {
    printf("%d ", l_);
  }
  printf("\n");
  */
  int l_i = 0;
  int r_i = 0;
  int hikakucnt = 0;
  for (int i = left; i < right; i++)
  {
    int min;
    hikakucnt++;
    if (l.at(l_i) < r.at(r_i))
    {
      min = l.at(l_i);
      l_i++;
    }
    else
    {
      min = r.at(r_i);
      r_i++;
    }
    a[i] = min;
  }
  //printf("left,mid,right = %d,%d,%d  after : \n", left, mid, right);
  /*
  for(int i:a)
  {
    printf("%d ", i);
  }
  printf("\n");
  */
  return hikakucnt;
}
int mergeSort(vector<int> &a, int left,int right)
{
  int hikakucnt = 0;
  if (right - left > 1)
  {
    int mid = (left + right) / 2;
    //printf("left,mid,right = %d,%d,%d\n ", left, mid, right);
    hikakucnt+=mergeSort(a, left, mid);
    hikakucnt+=mergeSort(a,mid,right);
    hikakucnt+=merge(a, left, mid, right);
  }
  return hikakucnt;
}



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

vector<pair<char, int>> RLE(string s)
{
    vector<pair<char, int>> res;
    char c; int l;
    for (int i = 0; i < (int)s.length(); i++) {
        if (i == 0) {
            c = s[i]; l = 1;
        } else if (s[i] == c) {
            l++;
        } else {
            res.push_back({c, l});
            c = s[i]; l = 1;
        }
    }
    res.push_back({c, l});
    return res;
}

int main()
{
    string s; cin >> s;
    const int n = s.length();

    vector<pair<char, int>> rle = RLE(s);

    vector<int> ans(n, 0);
    int pos = 0;
    for (auto& x : rle) {
        if (x.first == 'R') {
            pos += x.second;
            ans[pos] += x.second / 2;
            ans[pos - 1] += (x.second + 1) / 2;
        } else {
            ans[pos] += (x.second + 1) / 2;
            ans[pos - 1] += x.second / 2;
            pos += x.second;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << (i ? " " : "") << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
H, W, K = map(int, input().split())
C = [input() for i in range(H)]
ctoi = lambda x: 1 if x == '#' else 0
F = list(list(map(ctoi, c)) for c in C)
ans = 0
for b1 in range(1<<H):
    for b2 in range(1<<W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if b1 & (1<<i) and b2 & (1<<j):
                    cnt += F[i][j]
        if cnt == K:
            ans += 1
print(ans)

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

using namespace std;

typedef long long int ll;

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

  string s;
  cin >> s;
  int n = s.length();

  int lo = 1, hi = n;
  int ans = 1;
  while (lo <= hi) {
    int mid = (hi - lo) / 2 + lo;
    int k = mid;
    int l = n - k, r = k - 1;

    if (l > r) {
      ans = max(ans, mid);
      lo = mid + 1;
    }

    bool ok = true;
    for (int j = n - k + 1; j <= k - 1; j++) {
      if (s[j] != s[n - k]) ok = false;
    }

    if (ok) {
      lo = mid + 1;
      ans = max (ans, mid);
    } else {
      hi = mid - 1;
    }
  }

  cout << ans << '\n';
}


Measured memory_bytes: 512
#include <cstdio>
using namespace std;
const long long NR=1100,MR=110000000;
long long h,n,a[NR],b[NR],dp[MR];
int main()
{
	scanf("%lld%lld",&h,&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
	}
	for(long long i=1;;i++)
	{
		for(long long j=1;j<=n;j++)
		{
			if(i>=b[j])
			{
				if((dp[i-b[j]]+a[j])>dp[i])
				{
					dp[i]=dp[i-b[j]]+a[j];
				}
			}
		}
		if(dp[i]>=h)
		{
			printf("%lld",i);
			return 0;
		}
	}
	return 0;
}

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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repr(i,n) for(int i{n};i-->0;)

signed main(){

  ll n,z,w;
  cin>>n>>z>>w;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  if(n==1){
    cout<<abs(a[0]-w)<<endl;
  }else{
    cout<<max(abs(a.back()-w),abs(a[n-1]-a[n-2]))<<endl;
  }

}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void)
{
  int N;
  scanf("%d",&N);
　int test[N-1];
　int i;
for(i=0;i<=N-1;i++)
{scanf("%d",&test[i]);}
int sum=0;
 for(i=0;i<=N-1;i++)
 {int j=0;
     while((test[i]%2)==0){ 
     test[i]=test[i]/2;
     j++;}
     sum=sum+j;
 }
 printf("%d",sum);
 return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
void solve(){
	int n;
	cin>>n;
	int cnt = 0, a = 0;
	for(int i = 0; i < n; i++){
		int x;
		cin>>x;
		cnt+=(x%4==0);
		a+=(x%2==0&&x%4!=0);
	}
	if(cnt+a/2>=n/2)cout<<"Yes\n";
	else cout<<"No\n";
}
signed main(){
	speed;
	int t=1;
	//cin>>t;
	while(t--)solve();
}

Measured memory_bytes: 3584
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n,m,a[40]={},ans=0;


int main(void){
	cin>>n>>m;
	rep(i,n){
		ll k;
		cin>>k;
		rep(i,k){
			ll b;
			cin>>b;
			a[b]++;
		}
	}
	reg(i,1,m){
		if(a[i]==n)ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n; cin >> n;
  cout << n << ": ";
  vector<pair<ll, ll> > a = prime_factorize(n);
  rep(i, a.size()) {
    rep(j, a[i].second) {
      cout << a[i].first;
      if (i == a.size()-1 && j == a[i].second-1) ;
      else cout << ' ';
    }
  }
  cout << '\n';
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int h,w;
  std::cin >> h >> w;
  vt<vt<char>> s(h+2,vt<char>(w+2));
  for(int i = 1; i <= h; i++)
    for(int j = 1; j <= w; j++)
      std::cin >> s[i][j];

  for(int i = 1; i <= h; i++)
    for(int j = 1; j <= w; j++){
      if(s[i][j] == '.')  continue;
      if(s[i-1][j] == '#' || s[i+1][j] == '#' || s[i][j-1] == '#' || s[i][j+1] == '#')
        continue;
      else{
        std::cout << "No" << '\n';
        return 0;
      }
    }

  std::cout << "Yes" << '\n';
  return 0;
}


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

int main(){
	int n,k,s;
	int dp[11][21][200];
	while(cin>>n>>k>>s,s|k|s){
		memset(dp,0,sizeof(dp));
		dp[0][0][0]=1;
		rep(i,k){
			rep(j,21){
				rep(g,s+1){
					for(int h=j+1;h<=n;h++){
						dp[i+1][h][g+h] += dp[i][j][g];
					}
				}
			}
		}
		int ans=0;
		rep(i,21)ans+=dp[k][i][s];
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1348
#include <bits/stdc++.h>
using namespace std;
const int N = 1e2 + 10;
int a[N];
int main()
{
	int n, k;
	cin >> n >> k;
	int ans = n;
	for (int i = 1, j = 0, k = 0; ; ++i)
	{
		if (i == n + 1)
		{
			if (k)
				--ans;
			break;
		}
		char x;
		cin >> x;
		if (x == j)
			++k;
		else
		{
			if (k)
				--ans;
			j = x;
			k = 1;
		}
	}
	for (; ans + 2 <= n && k; --k)
		ans += 2;
	cout << min(n - 1, ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#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 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 FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

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


    if ( S[S.size()-1] == 's') {
        S += "e";
    }
    S += "s";

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 3628
import java.util.*;

public class Main {

	static final int inf = 10000000;
	static char[][] grid = new char[21][21];
	static final int[] xmove = {1, -1, 0, 0};
	static final int[] ymove = {0, 0, -1, 1};


	private static int bfs(int x, int y) {
		// System.out.println(x + " " + y);

		int[][] dist = new int[21][21];
		int ans = 0;

		for(int i=0; i<21; i++) {
			for(int j=0; j<21; j++) {
				dist[i][j] = inf;
			}
		}
		dist[x][y] = 0;

		Queue<Integer> q = new LinkedList<Integer>();
		q.add(x);
		q.add(y);
		while(!q.isEmpty()) {
			int xx = q.remove();
			int yy = q.remove();
			// System.out.println(xx + " " + yy);
			for(int i=0; i<4; i++) {
				int xxx = xx + xmove[i];
				int yyy = yy + ymove[i];
				// System.out.println(xxx + " " + yyy + " new");
				if(xxx >= 0 && yyy >= 0 && grid[xxx][yyy] == '.') {
					// System.out.println(dist[xx][yy]);
					// System.out.println(xxx + " " + yyy + " passed");
					int tmp = dist[xx][yy] + 1;
					if(tmp < dist[xxx][yyy]) {
						dist[xxx][yyy] = tmp;
						// System.out.println(dist[xxx][yyy] + " new");
						q.add(xxx);
						q.add(yyy);
					}
					// System.out.println("Added.");
				}
			}
		}
		// System.out.println("Queue done.");

		for(int i=0; i<21; i++) {
			for(int j=0; j<21; j++) {
				if(grid[i][j] == '.') {
					// System.out.println(dist[i][j]);
					ans = Math.max(ans, dist[i][j]);
				}
			}
		}
		// System.out.println("Done.");

		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int ans = 0;

		int h = sc.nextInt();
		int w = sc.nextInt();
		sc.nextLine();
		// char[][] grid = new char[h+1][w+1];

		for(int i=0; i<h; i++) {
			String line = sc.nextLine();

			for(int j=0; j<w; j++) {
				grid[i][j] = line.charAt(j);
			}
		}
		// System.out.println(grid[2][1]);

		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				if(grid[i][j] != '#') {
					int tmp = bfs(i, j);
					// System.out.println(tmp);
					ans = Math.max(ans, tmp);
				}
			}	
		}
		System.out.println(ans);	
	}
}

Measured memory_bytes: 29220
n = gets.to_i
s = gets.chomp
memo = Array.new(n + 1) { Hash.new(0) }

memo[0][:left_black] = 0
1.upto(n) do |i|
  memo[i][:left_black] = memo[i - 1][:left_black]
  memo[i][:left_black] += 1 if s[i - 1] == "#"
end

memo[-1][:right_white] = 0
(n - 1).downto(0) do |i|
  memo[i][:right_white] = memo[i + 1][:right_white]
  memo[i][:right_white] += 1 if s[i] == "."
end

ans = memo.min_by { |m| m[:left_black] + m[:right_white] }
puts ans[:left_black] + ans[:right_white]


Measured memory_bytes: 59336
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    as <- replicateM n $ do
        [c, t] <- fmap read . words <$> getLine :: IO [Int]
        return (c, t)
    let bs = sortOn fst as
    let cs = dropWhile (\(a, b) -> b > m) bs
    if null cs
        then putStrLn "TLE"
        else print $ fst $ head cs

Measured memory_bytes: 1020
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<Integer> list = new ArrayList<>(n);
		for(int i = 0; i < n; i++) list.add(sc.nextInt());
		int count =0;
		while(list.stream().allMatch(i -> i %2 == 0)){
			list = list.stream().map(i -> i /2).collect(Collectors.toList());
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 27988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    static void Main()
    {
        int n;
        int m;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            n = int.Parse(words[0]);
            m = int.Parse(words[1]);
        }

        int[] cards = new int[n];
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            for (int i = 0; i < n; i++)
            {
                cards[i] = int.Parse(words[i]);
            }
        }
        Array.Sort(cards);

        Tuple<int, int>[] changes = new Tuple<int, int>[m];
        {
            for (int i = 0; i < m; i++)
            {
                var line = Console.ReadLine();
                var words = line.Split(' ');
                changes[i] = Tuple.Create(int.Parse(words[0]), int.Parse(words[1]));
            }
        }
        changes = changes.OrderByDescending(c => c.Item2).ToArray();

        int index = 0;
        foreach (var change in changes)
        {
            int count = change.Item1;
            int num = change.Item2;
            for (int j = 0; j < count; j++)
            {
                if (index == n)
                {
                    goto LOOPEND;
                }
                if (cards[index] < num)
                {
                    cards[index] = num;
                    index++;
                }
                else
                {
                    goto LOOPEND;
                }
            }
        }
    LOOPEND:

        long answer = 0;
        for (int i = 0; i < n; i++)
        {
            answer += cards[i];
        }
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 33468
#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	int n,y;
	cin>>n>>y;
	y/=1000;
	for(int i=0;i<=y/10;i++)
		for(int j=0;j<=y/5;j++)
		{
			int k=y-i*10-j*5;
			if(k>=0&&i+j+k==n){
				cout<<i<<' '<<j<<' '<<k;
				return 0;
			}
		}
	cout<<"-1 -1 -1";return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
from numba import njit


def read():
    N, S = map(int, input().strip().split())
    A = np.fromstring(input().strip(), dtype=np.int32, sep=" ")
    return N, S, A


@njit
def solve(N, S, A, MOD=998244353):
    dp = np.zeros((S+1), dtype=np.int32)
    dp[0] = 1
    for i in range(N):
        for j in range(S, -1, -1):
            v = 2 * dp[j]
            if j - A[i] >= 0:
                v += dp[j-A[i]]
            dp[j] = v % MOD
    return dp[S]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 110240
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
 
int main()
{
  int a, b;
  cin >> a >> b;
  int ans = a;
  if (a > b) ans--;
  cout << ans << endl;
}

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

int main(void)
{
    char s[100001];
    int i, n, hist[26]={0};

    scanf("%s", s);
    n = strlen(s);

    for (i=0; i<n; i++) {
        hist[s[i]-'a']++;
    }

    for (i=0; i<26; i++) {
        if (hist[i]==0) {
            printf("%c\n", i+'a');
            return 0;
        }
    }

    printf("None\n");

    return 0;
}

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

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for(ll i = a; i <= b; i++)

ll n, m, ans;
string S, T;

void process()
{
    n = S.size(), m = T.size();
    S = ' ' + S;
    T = ' ' + T;
    For(i, 1, n - m + 1)
    {
        ll res = 0;
        For(j, 1, m)
        if (S[i + j - 1] == T[j])
            res++;
        ans = max(ans, res);
    }
    cout << m - ans << "\n";
}

void input()
{
    cin >> S >> T;
}

int main()
{
    input();
    process();
}

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

int main(){
  int n,i,j,s;

  while(1){
    cin >> n;
    if(n==0)break;
    for(i=0;i<9;i++){
      cin >> s;
      n-=s;
    }
    cout << n << endl;

  }




}

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

int main() {
    vector<int> A(5);
    rep(i, 5) {
        cin >> A.at(i);
        if (A[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3596
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,X,T = MI()
print(T*((N+X-1)//X))


Measured memory_bytes: 61772
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n;
	cin>>n;
	string s;
	while(n!=0){
		n--;
		s+='a'+n%26;
		n/=26;
	}
	reverse(s.begin(),s.end());
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3568
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const S = input[0][0];

  return /^A[a-z]+C[a-z]+$/.test(S) ? "AC" : "WA";
};

console.log(main(read()));


Measured memory_bytes: 29656
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int mod = 1000000007;

vector<ll> arr(100005);

bool cmp(int a, int b){
    return arr[a-1]<arr[b-1];
}

int main() {
    int n;
    cin>>n;
    
    vector <int> ans(n);
    for(int i=0; i<n; i++) {
        cin>>arr[i];
        ans[i] = i+1;
    }
        
    
    sort(ans.begin(),ans.end(),cmp);
    
    for(int i : ans) cout<<i<<" ";
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

int main(){
    int N;
    cin>>N;
    for(int64_t i=1;i<=N;i++){
        if(i*(i-1)/2<N&&N<=i*(i+1)/2){
            int64_t sum=0;
            for(int j=i;j>0;j--){
                if(sum+j<=N){
                    cout<<j<<endl;
                    sum+=j;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> vs(N);
  vector<int> right(N);
  for (int &e : vs) cin >> e;
  sort(vs.begin(), vs.end());
  if (N%2 == 0) 
  {
    for (int i = 0; i < N; i++)
      right[i]=i/2*2+1;
  }
  else 
  {
    for (int i = 0; i < N; i++) 
      right[i]=(i+1)/2*2;
  }
  
  if (vs != right) {
    cout << 0 << endl;
  }
  
  else {
    int ans = 1;
    int p = N/2;
    for (int i = 0; i < p; i++) {
      ans *= 2;
      ans %= 1000000007;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 1024