akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DifferentialII
{
    class Program
    {
        static void Main(string[] args)
        {
            int row = 0;

            if (row > 50 || row < 1)
            {
                row = int.Parse(Console.ReadLine());
            }

            double[] results = new double[row];

            for (int i = 0; i < row; i++)
            {
                List<int> numberList = new List<int>();

                string numString = "";

                while (numString.Length != 8)
                {
                    numString = Console.ReadLine();
                }

                foreach (char item in numString)
                {
                    numberList.Add(int.Parse(item.ToString()));
                }

                numberList.Sort();

                int min = 0;
                int max = 0;

                for (int j = 0; j < numberList.Count; j++)
                {
                    min += (numberList[j] * (int)Math.Pow(10, (7 - j)));
                }

                numberList.Reverse();

                for (int j = 0; j < numberList.Count; j++)
                {
                    max += (numberList[j] * (int)Math.Pow(10, (7 - j)));
                }
                
                results[i] = max - min;
            }

            for (int i = 0; i < row; i++)
            {
                Console.WriteLine(results[i]);
            }
        }
    }
}


Measured memory_bytes: 16072
#include <stdio.h>
 
int main(){
    char ch;
    while((ch = getchar()) != EOF){
            if(ch >= 97 && ch <= 122)
                printf("%c",ch-32);
            else if(ch >= 65 && ch <= 90)
                printf("%c",ch+32);
            else
                printf("%c",ch);
    }
}


Measured memory_bytes: 2636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> rec(100005);
	rep(i, n) {
		int a;
		cin >> a;
		rec[a]++;
	}
	int ans = 0;
	int cnt2 = 0;
	rep(i, 100005) {
		if (rec[i] >= 3) {
			if (rec[i] % 2 == 0) {
				ans += rec[i] - 2;
				rec[i] = 2;
			}
			else {
				ans += rec[i] - 1;
				rec[i] = 1;
			}
		}
		if (rec[i] == 2) cnt2++;
	}
	ans += cnt2;
	if (cnt2 % 2 == 1) ans++;
	cout << n - ans << endl;
	return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1000000007;

int n, q;
vector<vector<int>> tree;
map<int, int> mp;
vector<int> ans;

void dfs(int s, int t, int x) {
  int temp = x;
  if (mp[s]) temp += mp[s];
  ans[s] = temp;
  for (int i: tree[s]) {
    if (i == t) continue;
    dfs(i, s, temp);
  }
}

void solve() {
  cin >> n >> q;
  tree.resize(n);
  ans.resize(n);
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    mp[p] += x;
  }
  dfs(0, -1, 0);
  rep(i,n) cout << ans[i] << " ";
  cout << endl;
}

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

Measured memory_bytes: 46200
#include <iostream>
using namespace std;
int count(int x, int c){
    if(x >= 500){
        return count(x-500, c+1);
    }
    if(x >= 100){
        return count(x-100, c+1);
    }
    if(x >= 50){
        return count(x-50, c+1);
    }
    if(x >= 10){
        return count(x-10, c+1);
    }
    if(x >= 5){
        return count(x-5, c+1);
    }
    if(x == 0){
        return c;
    }
    else {
        return count(x-1,c+1);
    }
}

int main (void){
    int x;
    while (true){
        cin >> x;
        if(x == 0) {
            break;
        }
        cout << count(1000 - x, 0) << endl;
    }
}


Measured memory_bytes: 3040
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>

typedef long long int llint;


int main(void){
  std::string s;
  std::cin >> s;

  int a = 0;
  if(s == "SUN") a = 7;
  if(s == "MON") a = 6;
  if(s == "TUE") a = 5;
  if(s == "WED") a = 4;
  if(s == "THU") a = 3;
  if(s == "FRI") a = 2;
  if(s == "SAT") a = 1;
  
  std::cout << a << std::endl;
  return 0;
}


Measured memory_bytes: 256
//AtCoder ABC065 A - Expired?
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll x,a,b;
    cin>>x>>a>>b;
    if(a+x<b) {
        cout<<"dangerous"<<endl;
    } else if(a>=b){
        cout<<"delicious"<<endl;
    } else {
        cout<<"safe"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.algorithm, std.conv;
const long INF = long.max/3;

void main() {
    while(solve()){}
}

bool solve() {
    int N = readln.chomp.to!int;
    if (N == 0) return false;

    long[] as = new long[N];
    foreach(i; 0..N) {
        as[i] = readln.chomp.to!long;
    }

    long res = -INF;
    long s = 0;
    foreach(i; 0..N) {
        s = max(as[i], s + as[i]);
        res = max(res, s);
    }
    res.writeln;

    return true;
}



Measured memory_bytes: 2368
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

def dfs(al, n, m, all_al):
    if len(al) == n:
        all_al.append(al)
    else:
        last = al[-1]
        for i in range(last, m+1):
            dfs(al+[i], n, m, all_al)

def main():
    n, m, Q = map(int, input().split()) 
    ql = []
    for _ in range(Q):
        ql.append( list(map(int, input().split())) )

    all_al = []
    for i in range(1,m+1):
        dfs([i], n, m, all_al)

    ans = 0
    for al in all_al:
        curr_sum = 0
        for q in ql:
            if al[q[1]-1]- al[q[0]-1] == q[2]: curr_sum += q[3]
        ans = max(curr_sum, ans)

    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 22900
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(N), sum(N + 1, 0);
    rep(i, N) { cin >> A[i]; }

    map<ll, ll> cnt;
    ll ans = 0;
    rep(i, N) { sum[i + 1] = sum[i] + A[i]; }

    rep(i, N + 1) { cnt[sum[i] % M]++; }

    for (auto c : cnt) {
        ans += (c.second * (c.second - 1)) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5760
//Author ::  ABHINAV3010 ::

#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define fast ios_base::sync_with_stdio(false)
typedef long long ll;
typedef pair<ll,ll> p;
ll mod=998244353;
ll gcd(ll a,ll b)
{
    return (b==0)?a:gcd(b,a%b);
}
ll power(ll x, ll y, ll p=mod)
{ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1;x = (x*x) % p;}return res;}
int main()
{
fast;
ll n;
cin>>n;
vector<ll>cnt(n+1,0);
ll mx=0ll;
bool flag=false;
for(ll i=0;i<n;i++)
{
    ll a;
    cin>>a;
    if(i==0)
    {
        if(a==0)
        {
            flag=true;
        }
    }
    cnt[a]++;
    mx=max(a,mx);
}
if(cnt[0]!=1)
{
    cout<<0<<endl;
    return 0;
}
if(!flag)
{
     cout<<0<<endl;
    return 0;
}
ll ans=1ll;
for(ll i=1;i<=mx;i++)
{
    if(cnt[i]==0)
    {
        ans=0;
        break;
    }
    ll x=power(cnt[i-1],cnt[i])%mod;
    ans=(ans*x)%mod;
}
cout<<ans%mod<<endl;
return 0;
}


Measured memory_bytes: 1152
from collections import Counter
n=int(input())
c=Counter(list(map(int, input().split())))
l=list()
for k,v in c.items():
    for _ in range(v//2):
        l.append(k)

l.sort()
l.reverse()
if len(l)>=2:
    print(l[0]*l[1])
else:
    print(0)

Measured memory_bytes: 22040
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        Long[] a = new Long[n];
        for(int i=0; i<n; i++) {
            a[i] = Long.parseLong(sc.next());
        }
        
        Arrays.sort(a, Collections.reverseOrder());

        long sum = a[0];
        
        int x = 1;
        for(int i=0; i<n-2; i++) {
            sum += a[x];
            if(i % 2 == 1) {
                x++;
            }
        }
        
        System.out.println(sum);
    }
}

Measured memory_bytes: 65528
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t N;
	int64_t A, B;
	scanf("%d%" PRId64 "%" PRId64, &N, &A, &B);

	vector<int64_t> h(N);
	for (int32_t i = 0; i < N; i++)
		scanf("%" PRId64, &h[i]);
	sort(h.begin(), h.end());

	int64_t start = 0;
	int64_t end = 1000000000;
	int64_t ok = end, ng = start;
	while (ok - ng > 1) {
		int64_t mid = (ok + ng) / 2;
		bool isOk;
		if (h[N - 1] > mid * B) {
			auto it = upper_bound(h.begin(), h.end(), mid * B);
			int64_t rest_turn = mid;
			for (int32_t i = it - h.begin(); i < N; i++) {
				int64_t rest_hp = h[i] - mid * B;
				rest_turn -= rest_hp / (A - B);
				if (rest_hp % (A - B) != 0)
					rest_turn--;
			}
			isOk = rest_turn >= 0;
		} else {
			isOk = true;
		}
		if (isOk)
			ok = mid;
		else
			ng = mid;
	}
	printf("%" PRId64 "\n", ok);

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>

const int MAXN = 200005;

int n;
long long int a[MAXN];
long long int cnt[MAXN];
long long int sum = 0ll;

int main(){
	std::cin >> n;
	for(int i = 1; i <= n; ++i)
	scanf("%d", a + i), ++cnt[a[i] ];
	for(int i = 1; i <= n; ++i)
	--cnt[i], sum += cnt[i] * ( cnt[i] + 1) / 2;
	for(int i = 1; i <= n; ++i)
	printf("%lld\n", sum - cnt[ a[i]] );
	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,a[100],i,l;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
  }
  for(l=0;l<n;l++){
    cout<<a[l];
    if(n-l-1)cout<<" ";
  }
  cout<<endl;
  int k,j;
  for(i=1;i<n;i++){
    k=a[i];
    j=i-1;
    while(k<a[j] && j>=0){
      a[j+1]=a[j];;
      j--;
    }
    a[j+1]=k;
    for(l=0;l<n;l++){
      cout<<a[l];
      if(n-l-1)cout<<" ";
    }
    cout<<endl;
  }

  return 0;
}

  



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, x;
    cin >> n >> x;
    ll ans;
    if(GCD(n, x) == 1){
        ans = 3*(n-1);
    }else{
        ll g = GCD(n, x);
        n /= g;
        x /= g;
        ans = 3*(n-1)*g;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
using namespace std;

string s;
int nyak[130];

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

	cin >> s;
	int p = s.size();
	if(s == "zyxwvutsrqponmlkjihgfedcba"){
		printf("-1\n");
		return 0;
	}
	for(int x = 0 ; x < p ; x++) nyak[s[x] - 'a']++;

	for(int y = p - 1 ; y >= -1 ; y--){

		int now;
		if(y == p - 1) now = 0;
		else now = s[y + 1] - 'a' + 1;
		for(int z = now; z < 26 ; z++){
			if(nyak[z] == 0){
				for(int x = 0 ; x <= y ; x++){
					printf("%c",s[x]);
					
				}
				printf("%c", z + 'a');
				printf("\n");
				return 0;
			}
		}
		nyak[s[y] - 'a']--;
	}
}

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

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

  // ここにプログラムを追記
  for ( int i = 0; i < N; i++) {
    cin >> S; 
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if ( i == N-1 && S != "Y") {
      cout << "Three" << endl;
    } 
  }
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int MaxV(int, int);
int MinV(int);
 
int x;
 
main(){
  int n, j, minv, maxv;
 
  maxv = pow(10, 9) * (-1);
 
  scanf("%d", &n);
  scanf("%d", &minv);
 
  for( j = 1; j <= n-1; j++){
 
    maxv = MaxV(maxv, minv);
 
    minv = MinV(minv);
 
  }
 
  printf("%d\n", maxv);
 
  return 0;
 
}
 
int MaxV(int maxv, int minv){
  scanf("%d", &x);
 
  if( maxv > x - minv ) return maxv;
  else return x - minv;
 
}
 
int MinV(int minv){
 
  if( minv < x ) return minv;
  else return x;
 
}


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

#define ll long long
#define ld long double
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define ppb pop_back
#define vll vector<ll>
#define vi vector<int>
#define endl "\n"

const ll INF = 1000000007;
const int max_size = 100001;
int parent[max_size];
int Size[max_size];

int root(int x){
	while(x!=parent[x]){
		parent[x] = parent[parent[x]];
		x = parent[x];
	}
	return x;
}

void sunion(int x,int y){
	int rx = root(x);
	int ry = root(y);
	if(rx != ry){
		if(Size[rx] > Size[ry]){
			parent[ry] = parent[rx];
			Size[rx] += Size[ry];
		}
		else{
			parent[rx] = parent[ry];
			Size[ry] += Size[rx];
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--){
		int k;
		cin >> k;
		queue <ll> q;
		for(ll i=1ll;i<=9ll;i++) q.push(i);
		ll x;
		for(int i=1;i<=k;i++){
			x = q.front();
			q.pop();
			if(x%10 != 0) q.push(10*x+x%10-1);
			q.push(10*x+x%10);
			if(x%10!=9) q.push(10*x+x%10+1);
		}
		cout << x << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using namespace std;

bool check(vector<int> h){
	bool flag = true;
	int n = (int)h.size(), mx = h[n-1];
	vector<bool> dec(n, 0);
	for (int i = n-2; i >= 0; i--) {
		if (h[i] <= h[i+1]) {
			continue;
		}
		else if (h[i] - 1 == h[i+1]){
			h[i]--;
		}
		else{
			flag = false;
			break;
		}
	}
	return flag;
}

class CBuildStairs {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n;
		vector<int> h;
		int x;

		in >> n;
		for (int i = 0; i < n; i++)
			in >> x, h.pb(x);

		vector<int> h1(h);
		h1[n-1]--;
		bool flag = check(h) || check(h1);
		out << (flag ? "Yes" : "No");


	}
};

int main() {
	CBuildStairs solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1912
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100],n,k;
int F()
{
	int res,i,t=1;
	for(i=0;i<k;++i)
		t*=a[i];
	res=t;
	for(;i<n;++i)
	{
		t/=a[i-k];
		t*=a[i];
		res=max(res,t);
	}
	return res;
}
int main()
{
	int i,j,ck,t;
	while(scanf("%d%d",&n,&k),n)
	{

		for(t=i=0;i<n;++i)scanf("%d",a+i);
		ck=F();
		for(i=0;i<n;++i)
		{
			for(j=i+1;j<n;++j)
			{
				swap(a[i],a[j]);
				t=max(t,F());
				swap(a[i],a[j]);
			}
		}
		if(ck>t)puts("NO GAME");
		else printf("%d\n",t-ck);
	}
	return 0;
}

Measured memory_bytes: 756
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;  cin >> n ;
    vector<int> arr(n);
    for(int&p:arr) cin >> p;
    int ans = 0 ;
    int i = 0 ;
    while(i<n)   
    {
        if(ans > 1000000)
        {
            cout << -1 << endl;
            return 0;
        }
        if(arr[i]==2)
        {
            cout << ans+1 << endl;
            return 0 ;
        }
        if(arr[i]!=2)
        {
            i = arr[i]-1;
            ans ++ ;
        }
    }
    return 0 ;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int dp[50][500][500];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ma,mb;
    cin>>n>>ma>>mb;
    vector<int> a(n),b(n),c(n);
    rep(i,n) cin>>a[i]>>b[i]>>c[i];
    int inf=1e5;
    rep(i,50)rep(j,500)rep(k,500) dp[i][j][k]=inf;
    dp[0][0][0]=0;
    rep(i,n)rep(j,401)rep(k,401){
      dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
      if(j+a[i]<=400 && k+b[i]<=400){
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
    int ans=inf;
    rep(j,401)rep(k,401){
      //cout<<dp[n][j][k]<<' ';
      if(j*mb==k*ma && ans>dp[n][j][k] && dp[n][j][k]!=0) ans=dp[n][j][k];
    }
    if(ans!=inf) cout<<ans<<endl;
    else cout<<-1<<endl;
}

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

int main(){
  int N;
  cin >>N;
  vector<vector<int>>a(2,vector<int>(N));
  for(int i=0;i<N;i++)
    cin >> a.at(0).at(i);
  for(int i=0;i<N;i++)
    cin >> a.at(1).at(i);
  int ans=0;
  vector<int>s(N,0);
  for(int i=0;i<N;i++){
    int tmp=0;
    for(int j=0;j<=i;j++)
      tmp+=a.at(0).at(j);
    for(int j=i;j<N;j++)
      tmp+=a.at(1).at(j);
    ans=max(tmp,ans);
  }
  cout << ans<<endl;
}

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

#define NUM 200
vector<long long int>data1( NUM );
vector<long long int>data2;
vector<long long int>memo1;
vector<long long int>memo2;

long long int saiki1( long long int N ) {
	if( N < 0 ) {
		return INT_MAX / 6;
	}
	if( memo1[N] != INT_MAX / 6 ) {
		return memo1[N];
	}
	long long int ret = INT_MAX / 6;
	auto ite = lower_bound( data1.begin(), data1.end(), N );
	while( ite != data1.begin() ) {
		ret = min( ret, saiki1( N - (*ite) ) + 1 );
		ite--;
	}
	if( ret == INT_MAX / 6 ) {
		ret = N;
	}
	return memo1[N] = ret;
}

long long int saiki2( long long int N ) {
	if( N < 0 ) {
		return INT_MAX / 6;
	}
	if( memo2[N] != INT_MAX / 6 ) {
		return memo2[N];
	}
	long long int ret = INT_MAX / 6;
	auto ite = lower_bound( data2.begin(), data2.end(), N );
	while( ite != data2.begin() ) {
		ret = min( ret, saiki2( N - (*ite) ) + 1 );
		ite--;
	}

	if( ret == INT_MAX / 6 ) {
		ret = N;
	}
	return memo2[N] = ret;
}

int main() {
	memo1.resize( 1e6, INT_MAX / 6 );
	memo2.resize( 1e6, INT_MAX / 6 );
	iota( data1.begin(), data1.end(), 1 );
	for( size_t i = 1; i < NUM; i++ ) {
		data1[i] += data1[i - 1];
	}
	for( size_t i = 1; i < NUM; i++ ) {
		data1[i] += data1[i - 1];
	}
	for( size_t i = 0; i < NUM; i++ ) {
		if( data1[i] % 2 ) {
			data2.emplace_back( data1[i] );
		}
	}
	long long int N;
	while( cin >> N, N ) {
		cout << saiki1( N ) << " " << saiki2( N ) << endl;
	}
}

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

#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(void) {
    string s;
    bool flg = true;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length() - 1) {
        if (s[i] == s[i + 1]) {
            flg = false;
        }
    }

    cout << (flg? "Good" : "Bad") << "\n";
    return 0;
}

Measured memory_bytes: 256
n = $stdin.gets.chomp
a = $stdin.gets.split.map(&:to_i)
count = 0
loop do
  flag = false
  a.each do |num|
    flag = true if num % 2 != 0
  end
  break if flag
  a.map!{ |num| num / 2 }
  count += 1
end
puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    ll N, K;
    cin >> N >> K;
    ll d;
    d = N / K;
    ll ans1, ans2;
    ans1 = N - (K * d);
    ans2 = abs(ans1 - K);
    if (ans1 < ans2){
        cout << ans1 << endl;
    }
    else{
        cout << ans2 << endl;
    }
}

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

int main() {
    string s, t;
    int ans;
    cin >> s >> t;
    ans = t.length();

    for(unsigned int i=0; i<=(unsigned int)(s.length()-t.length()); i++)
    {
        int match=0;
        for(unsigned int j=0; j<(unsigned int)t.length(); j++)
        {
            if(s[i+j] == t[j])
            {
                match++;
            }
        }
        if(ans > (t.length()-match))
        {
            ans = (t.length()-match);
        }
    }

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



Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=a;i<(b);i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  int ans = 0;
  int S = 0;
  REP(i,s.size() ){
    if( s[i] == 'S' ){
      S++;
    }else if( s[i] == 'T' ){
      if( S > 0 )
	S--;
      else
	ans++;
    }else{
      S = 0;
      ans++;
    }
  }
  cout << ans + S << endl;
  return 0;
}


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

using namespace std;

int t[1000][1003];

vector<pair<pair<int,int>, pair<int,int>>> v;
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			scanf("%d", &t[i][j]);
		}
	}

	for (int i = 1; i <= n; ++i) {
		if (i % 2 == 1) {
			// w prawo
			for (int j = 1; j < m; ++j) {
				if (t[i][j] % 2 != 0) {
					--t[i][j];
					++t[i][j + 1];
					v.push_back({{i, j}, {i, j + 1}});
					// printf("%d %d %d %d\n", i, j, i, j + 1);
				}
			}
			if (t[i][m] % 2 != 0 && i < n) {
				--t[i][m];
				++t[i + 1][m];
				// printf("%d %d %d %d\n", i, m, i + 1, m);
				v.push_back({{i, m}, {i + 1, m}});
			}
		}
		else {
			// w lewo
			for (int j = m; j > 1; --j) {
				if (t[i][j] % 2 != 0) {
					--t[i][j];
					++t[i][j - 1];
					// printf("%d %d %d %d\n", i, j, i, j - 1);
					v.push_back({{i, j}, {i, j - 1}});
				}
			}
			if (t[i][1] % 2 != 0 && i < n) {
				--t[i][1];
				++t[i + 1][1];
				// printf("%d %d %d %d\n", i, 1, i + 1, 1);
				v.push_back({{i, 1}, {i + 1, 1}});
			}
		}
	}
	printf("%d\n", v.size());
	for (auto i : v) {
		printf("%d %d %d %d\n", i.first.first, i.first.second, i.second.first, i.second.second);
	}
	// for (int i = 1; i <= n; ++i) {
	// 	for (int j = 1; j <= m; ++j)
	// 		printf("%d ", t[i][j]);
	// 	printf("\n");
	// }
}

Measured memory_bytes: 6256
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int t = 0, n = 0;
  cin >> t >> n;
  if(n == 1 || t == n) {
    cout << 0 << endl;
  } else {
    cout << (t - n) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, t) = (v[0], v[1]);
    let mut pairs = vec![];
    for _ in 0..n {
        let v = read_vec::<usize>();
        pairs.push((v[0], v[1]));
    }
    pairs.sort();
    let w = pairs.iter().map(|&x| x.0).collect::<Vec<_>>();
    let v = pairs.iter().map(|&x| x.1 as i64).collect::<Vec<_>>();

    let mut dp: Vec<i64> = vec![-1; t + 1];
    dp[0] = 0;
    for i in 0..n {
        for j in (0..t).rev() {
            if dp[j] == -1 {
                continue;
            }
            if j + w[i] < t {
                dp[j + w[i]] = max(dp[j] + v[i], dp[j + w[i]]);
            } else {
                dp[t] = max(dp[j] + v[i], dp[t]);
            }
        }
        //debug!(dp);
    }
    let ans = *dp.iter().max().unwrap();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
'use strict';

const main = (input) => {
    const lines = input.split('\n');
    const header = lines[0].split(' ');
    const height = parseInt(header[0], 10);
    const width = parseInt(header[1], 10);
    const map = [];
    const empty_col = new Array(width);
    for (let j = 0; j < height; j++) {
        let map_line = [];
        const l = lines[j + 1];
        if (l.indexOf('#') == -1) {
            continue; // skip empty_line
        }
        for (let i = 0; i < width; i++) {
            map_line[i] = l[i];
            if (l[i] == '#') {
                empty_col[i] = 1;
            }
        }
        map.push(map_line);
    }
    map.forEach((v) => {
        let line = '';
        for (let i = 0; i < width; i++) {
            if (empty_col[i] == 1) {
                line += v[i];
            }
        }
        console.log(line);
    });
};

const isTest = false;

if (isTest) {
    main('4 4\n##.#\n....\n##.#\n.#.#\n');
    main('3 3\n#..\n.#.\n..#\n');
    main('4 5\n.....\n.....\n..#..\n.....\n');
    main('7 6\n......\n....#.\n.#....\n..#...\n..#...\n......\n.#..#.');
} else {
    main(require('fs').readFileSync('/dev/stdin', 'utf8'));
}

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

using namespace std;

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

int main() {

    
    int n;
    cin >> n;
    vector<int> a(n);
    
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    vector<int> ans(n + 1);
    vector<int> ret;
    
    for (int i = n; i >= 1; --i)
    {
        int sum = 0;
        for (int j = 2 * i; j <= n; j += i)
        {
            sum += ans[j];
        }
        if (sum % 2 == a[i - 1])
        {
            ans[i] = 0;
        }
        else
        {
            ans[i] = 1;
            ret.push_back(i);
        }
    }
    
    sort(ret.begin(), ret.end());
    cout << ret.size() << endl;
    for (int i = 0; i < ret.size(); ++i)
    {
        if (i == (ret.size() - 1))
        {
            cout << ret[i] << endl;
            break;
        }
        cout << ret[i] << " ";
    }
    
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pi 2*acos(0.0)
#define mod 998244353

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

    ll d, n;
    cin >> d >> n;

    if(d==0){
        if(n!=100)
            cout << n<<endl;
        else
            cout << 101<<endl;
    }

    else if(d==1){
        if(n!=100)
            cout << 100*n<<endl;
        else
            cout << 101*100<<endl;
    }

    else{
        if(n!=100)
            cout << 10000*n<<endl;
        else
            cout << 101*10000<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
 
public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    static int parent[]; 
 
    public static void main(String[] args) throws IOException {
        Scanner scanner = new Scanner(System.in);
 
        int N = scanner.nextInt();
        int M = scanner.nextInt();
     
        parent = new int [N+1];
 
           
        ArrayList<Integer> matrix [] = new ArrayList [N+1];
 
        for (int x=1; x<=N; x++) {
            matrix[x] = new ArrayList<Integer>();
        }
 
        for (int x=1; x<=M; x++) {
            int one = scanner.nextInt();
            int two = scanner.nextInt();
            matrix[one].add(two);
            matrix[two].add(one);
        }
    
        bfs(matrix, 1);
        
        boolean flag = true;
        for (int x=1; x<=N; x++) {
            if(parent[x] == 0){
                flag = false;
                break;
            }
        }
        if(flag){
            System.out.println("Yes");
            for (int x=2; x<=N; x++) {
                System.out.println(parent[x]);
            }
        }
        else{
            System.out.println("No");
        }
        
    
    }
        
    public static boolean bfs (ArrayList [] matrix,  int start) {
        Queue <Integer> queue = new LinkedList<Integer>();
        queue.add(start);
        
        while (!queue.isEmpty()) {
            int cur = queue.poll();
            for (int x=0; x<matrix[cur].size(); x++) {
                int now = (int) matrix[cur].get(x);
                if(parent[now]==0){
                    parent[now] = cur;
                    queue.add(now);
                }
            }
        }
        return false;
    }
}

Measured memory_bytes: 76008
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n,m;
	ll a[51],b[51],c[51],d[51];

	cin>>n>>m;

	rep(i,n){
		cin>>a[i]>>b[i];
	}
	rep(i,m){
		cin>>c[i]>>d[i];
	}
	rep(i,n){
		ll total=1000000000000000;
		int r=0;
		rrep(j,m){
			if(total>=(max(a[i],c[j])-min(a[i],c[j]))+(max(b[i],d[j])-min(b[i],d[j]))){
				r=j;
				total=(max(a[i],c[j])-min(a[i],c[j]))+(max(b[i],d[j])-min(b[i],d[j]));
			}
		}
		cout<<r+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
/***************************************************************************
                                AUTHOR: SPARSH SINHA
            **************************************************************************/


#include <bits/stdc++.h>
using namespace std;
#define si(N) scanf("%d",&N);
#define sll(N) scanf("%lld",&N);
#define ss(s) scanf("%s",s);
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a; i<=b;i++)
#define fori(i,n) for(int i = 0 ; i < n; i++)
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define debug(x)       cerr<< #x <<" : "<<x<<endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
const int INF = 1e9 + 7;

bool check( int root){
     //checks whether root is a perfect square or not
     if(root == 0) return true;
     int s =  1 , e = root;
     while(s <=e){
           int mid = ( s + e )/ 2;
           if( mid*mid == root) return true;
           if( mid*mid > root) e = mid - 1; //because square root is less than mid
           else s = mid + 1;
     }
     return false;
}
int main()
{
     ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0);
     int N , D;
     cin>>N>>D;
     vector<vector<int>> X(N + 1 ,vector<int>( D + 1));
     for(int i = 1 ; i <= N ; ++i){
           for( int j = 1 ; j <=D; ++j){
                cin>>X[i][j];
           }
     }
      int cnt = 0;

     for(int i = 1 ; i <= N ; ++i){
           for( int j = i + 1 ; j <=N;  ++j){
                 int root = 0 ; 
                 for(int k = 1 ; k<=D ;++k){
                      root = root + (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
                 }
               //   cout<<root<<" is root between "<<i<<j<<endl;
                 if(check(root) == true) cnt++;
           }
     }
     cout<<cnt<<endl;
     // for(int i = 0 ; i <=10000; i++){
     //      if(check(i) == true )cout<<i<<endl;
     // }
}

Measured memory_bytes: 256
import * as fs from "fs";

// inputで受け取り配列化する
const input = fs.readFileSync("/dev/stdin", "utf8");

let res = 0;
let temp = 0;
for (let index = 0; index < input.length; index++) {
  if (input[index] === "R") {
    temp++;
  } else {
    res = Math.max(res, temp);
    temp = 0;
  }
}

res = Math.max(res, temp);

console.log(res);


Measured memory_bytes: 29684
using System;
using System.Linq;

namespace _0197
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x[0] == 0 && x[1] == 0)
                {
                    break;
                }
                Array.Sort(x);
                int n = 0;
                while (x[0] != 0)
                {
                    x[1] = x[1] % x[0];
                    Array.Reverse(x);
                    n++;
                }
                Console.WriteLine(x[1] + " " + n);
            }
        }
    }
}

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

using namespace std;

int main()
{
  vector<int> a;
  int s; cin >> s;
  a.push_back(s);

  for (int i = 1; i < 1000000; ++i) {
    a.push_back((a[i-1] % 2 == 0 ? a[i-1] / 2 : 3 * a[i-1] + 1));

    for (int j = 0; j < a.size(); ++j) {
      if (i != j and a[i] == a[j]) {
        cout << i + 1;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#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 <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    int n;
    cin >> n;
    int a[n];
    for( int i = 0; i < n; ++i ) cin >> a[i];

    int cnt = 0;
    int res = 0;
    for( int i = 1; i < n; ++i ) {
        if( a[i - 1] < a[i] ) {
            res = max( res, cnt );
            cnt = 0;

        } else {
            ++cnt;

        }
    }
    cout << max( res, cnt ) << endl;
    return 0;
}



Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] input = new String[N];
        int k = 0;
        for(String s: sc.next().split("")){
            input[k] = s;
            k++;
        }
        int max_count = -1;
        for (int i = 1; i < N; i++){
            String[] tmpA = Arrays.copyOfRange(input, 0, i);
            String[] tmpB = Arrays.copyOfRange(input, i, N);
            List<String> listA = Arrays.asList(tmpA);
            List<String> listB = Arrays.asList(tmpB);
            List<String> dist_listA = new ArrayList<>(new HashSet<>(listA));
            List<String> dist_listB = new ArrayList<>(new HashSet<>(listB));
            int count = 0;
            for(int j = 0; j < dist_listA.size(); j++){
                if(dist_listB.indexOf(dist_listA.get(j)) != -1){
                    count++;
                }
            }
            if(max_count < count){
                max_count = count;
            }
        }
        System.out.println(max_count);
    }
}


Measured memory_bytes: 23764
H,W=map(int,input().split())
matrix=[list(map(str,input().split())) for i in range(H)]
count_delete_H=0
count_delete_W=0

for i in range(H):
  matrix[i-count_delete_H]=list(*matrix[i-count_delete_H])
  if(matrix[i-count_delete_H].count('#')==0):
    del matrix[i-count_delete_H]
    count_delete_H+=1
    
matrix_t = [list(x) for x in zip(*matrix)]
for i in range(W):
  if(matrix_t[i-count_delete_W].count('#')==0):
    del matrix_t[i-count_delete_W]
    count_delete_W+=1
    
matrix_tt = [list(x) for x in zip(*matrix_t)]
for i in range(H-count_delete_H):
  for j in range(W-count_delete_W):
    print(matrix_tt[i][j],end='')
  print('')

Measured memory_bytes: 4724
// Created by js0805
#include <bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
int dp[3001][3001] ;
string LCS(int len, string s1, string s2) {
    string ans;
    int i = 0, j = 0;
    while (len > 0) {
        if (s1[i] == s2[j]) {
            ans.push_back(s1[i]);
            i++;
            j++;
            len--;
        }
        else {
            if (dp[i][j + 1] > dp[i + 1][j]) {
                j++;
            }
            else {
                i++;
            }
        }
    }
    return ans;
}
int lenLCS(string& s1, string& s2, int i, int j) {
    if (i >= s1.length() or j >= s2.length()) {
        return 0;
    }
    if (dp[i][j] != -1)
        return dp[i][j];
    if (s1[i] == s2[j]) {
        return dp[i][j] = 1 + lenLCS(s1, s2, i + 1, j + 1);
    }
    else {
        return dp[i][j] = max(lenLCS(s1, s2, i + 1, j), lenLCS(s1, s2, i, j + 1));
    }

}
void solve() {
    string s1, s2;
    cin >> s1 >> s2;
    memset(dp, -1, sizeof dp);
    int f = lenLCS(s1, s2, 0, 0);
    cout << LCS(f, s1, s2);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    solve();
    return 0;
}

Measured memory_bytes: 39272
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	c := nextString()
	nextC := string([]rune(c)[0] + 1)
	fmt.Println(nextC)
}


Measured memory_bytes: 640
N = gets.to_i
h = Hash.new{|hash, key| hash[key] = []}

(N-1).times do |i|
  u, v, w = gets.split.map(&:to_i)
  h[u] = h[u].push([v,w]) # [繋がっている点 , 辺の長さ]
  h[v] = h[v].push([u,w])
end

ans_tbl = Hash.new(-1)
ans_tbl[1] = 0 # rootを1として考える。1の1からの距離は0
$stack = [[1,0]]

# dfs
loop{
  break if ($stack == [])
    nowp = $stack.pop
    nextp = h[nowp[0]]
    nextp.each{|i|
      n_point,n_len = i[0],i[1]
      if (ans_tbl[n_point] === -1)
        sum_len = nowp[1] + n_len
        ans_tbl[n_point] = sum_len
        $stack.push([n_point,sum_len])
      end
    }
}

N.times do |i|
  puts ans_tbl[i+1] % 2 === 0 ? "0" : "1"
end
# p h
# p ans_tbl

Measured memory_bytes: 39292
n, h = list(map(int, input().split(' ')))
k = [list(map(int, input().split(' '))) for _ in range(n)]
a = []
b = []
for i in range(n):
    a.append(k[i][0])
    b.append(k[i][1])

a.sort(reverse = True)
b.sort(reverse = True)
a.append(0)
b.append(0)
count = 0
x = 0
y = 0

while h > 0:
    if a[x] <= b[y]:
        h -= b[y]
        y += 1
        count += 1
    elif a[x] > b[y]:
        count += h//a[x]
        if h%a[x] != 0:
            count += 1
        h = 0
print(count)

Measured memory_bytes: 29320
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1e3 + 1;
const long long MOD = 998244353;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

llong b[MXN], n, m;

int main(){
	ios;
	cin >> n >> m;
	for(int i = 1; i <= m; i++){
		int u, v;
		cin >> u >> v;
		b[u]++;
		b[v]++;
	}for(int i = 1; i <= n; i++){
		if(b[i] % 2 == 1){
			cout << "NO";
			return 0;
		}
	}cout << "YES";

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    int k,a,b;
    scanf("%d",&k);
    scanf("%d %d",&a,&b);
    int e=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            e=1;
            break;
        }
    }
    if(e==0)printf("NG");
    else printf("OK");
    return 0;
}

Measured memory_bytes: 3752
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 1e9+7;
ll calc(ll x){
  x %= MOD;
  return (x+MOD)%MOD;
}
signed main(){
  init_io();
  ll n,k,ans=1;
  cin >> n >> k;
  vector<ll> a(n),po,ne;
  for(int i=0;i<n;i++){
    cin >> a[i];
    if(a[i]>=0) po.push_back(a[i]);
    if(a[i]<0) ne.push_back(a[i]);
    if(k==n){
      ans = calc(ans*a[i]);
    }
  }
  if(k==n){
    cout << ans << endl;
    return 0;
  }
  ll posum = po.size(),nesum=ne.size();
  ll pdx=0,ndx=0;
  ll check = (nesum==n&&k%2==1);
  if(check){
      vector<ll> v;
      for(auto &i: ne){
        v.push_back(-i);
      }
      for(auto &i: po){
        v.push_back(i);
      }
      sort(v.begin(),v.end());
      for(int i=0;i<k;i++){
        ans = calc(ans*v[i]);
      }
      ans = calc(ans*-1);
      cout << ans << endl;
      return 0;
  }
  sort(po.begin(),po.end(),greater<ll>());
  sort(ne.begin(),ne.end());
  for(int i=0;i<k;i+=2){
    if(i==k-1){
      ans = calc(ans*po[pdx]);
    }else{
      ll v0,v1;
      v0 = v1 = -1e18;
      if(pdx + 1 < posum){
        v0 = po[pdx]*po[pdx+1];
      }
      if(ndx + 1 < nesum){
        v1 = ne[ndx]*ne[ndx+1];
      }
      if(v0>v1){
        v0 %= MOD;
        pdx += 2;
        ans = calc(ans*v0);
      }else{
        v1 %= MOD;
        ndx += 2;
        ans = calc(ans*v1);
      }
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 6912
from collections import defaultdict


def main():
    K, S = map(int, input().split())
    ans = 0
    for x in range(K + 1):
        for y in range(K + 1):
            z = S - x - y
            if 0 <= z <= K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
import heapq
N = int(input())
A = [ i for i in list(map(int,input().split()))]
heapq.heapify(A)

for i in range(N-1):
  a = heapq.heappop(A)
  b = heapq.heappop(A)
  heapq.heappush(A, ((a+b)/2))

print(heapq.heappop(A))

Measured memory_bytes: 38384