akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define ll long long
int main()
{
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0;i<n;i++)cin>>a[i];
  vector<ll>v;ll pre=0;
  for(int i=0;i<k;i++)pre+=a[i];
  v.push_back(pre);
  int i=1,j=k;
  while(j<n){
    pre+=a[j];
    pre-=a[i-1];
    i++;
    j++;
    v.push_back(pre);
  }
  for(int i=1;i<v.size();i++){

    if(v[i]<=v[i-1]){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
  }

}


Measured memory_bytes: 6684
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
///////////////////////////////////////



int main() {
	string S; cin >> S;
	REP(i, S.size()) {
		cout << 'x';
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define all(x) x.begin(), x.end()
#define VI vector<int>
#define ll long long
#define INF 2e9
using namespace std;

void Main() {
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, 0, n) { cin >> v[i]; }
    sort(all(v));
    double ans = v[0];
    rep(i, 1, n) { ans = (ans + v[i]) / 2; }
    cout << ans << endl;
}

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

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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const int MOD = (int) 998244353;
const int maxn = (int) 200000 + 20;
const int maxm = (int) 1000000 + 20;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL m = MOD) {LL res = 1; for(; n; n >>= 1, a = a * a % m) if(n & 1) res = res * a % m; return res;}

int n;
int a[11], b[11];

LL func(int *f)
{
    LL p[11] = {0};
    int v[11] = {0};

    p[0] = 1;
    for(int i = 1; i <= n; i++) p[i] = p[i - 1] * i;

    int res = 0;
    for(int i = 0; i < n; i++)
    {
        int t = f[i];
        int c = 0;

        for(int j = 1; j < t; j++)
            if(v[j] == 0)
                c++;
        v[t] = 1;

        res += c * p[n - i - 1];
    }
    return res;
}

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

    cout <<labs(func(a) - func(b)) <<endl;
}

int main()
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
L, N = [int(_) for _ in input().split()]
X = [int(input()) for _ in range(N)]


def calc(X):
    cumsum = [0]
    for x in X:
        cumsum += [cumsum[-1] + x]
    res = 0
    for i in range(N):
        if (i + N) % 2:
            end = (i + N - 1) // 2
            d = 2 * (cumsum[end + 1] - cumsum[i]) + 2 * L * (
                N - 1 - end) - 2 * (cumsum[N] - cumsum[end + 1]) - X[end]
        else:
            end = (i + N) // 2
            d = 2 * (cumsum[end] - cumsum[i]) + 2 * L * (N - end) - 2 * (
                cumsum[N] - cumsum[end]) - (L - X[end])
        res = max(res, d)
    return res


print(max(calc(X), calc([L - x for x in X[::-1]])))

Measured memory_bytes: 32056
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

int main() {
    int a; cin >> a;
    if (a == 1) {
        cout << "Hello World" << endl;
        return 0;
    }

    int b, c; cin >> b >> c;
    cout << b + c << endl;


    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define vvi vector<vi>
#define Q queue<ll>
#define DQ deque<ll> 
#define pb push_back
#define pf push_front
#define popf pop_front
#define popb pop_back
#define mp make_pair
#define mt make_tuple
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define loop(x,y,z) for(ll i=x; i<=y; i+=z)
#define rloop(x,y,z) for(ll i=x; i>=y; i-=z)
#define all(x) x.begin(), x.end()
#define sum(x) accumulate(all(x),0LL)
#define minE(x) *min_element(all(x))
#define maxE(x) *max_element(all(x))
#define watch(x) cout<<(#x)<<" is "<<x
#define endl "\n"

ll gcd(ll a, ll b){
	return (!b)?a:gcd(b,a%b);
}

void display(vi &v,string c){
	for(auto x:v) cout<<x<<c;
}

ll solve(ll i, vi &dp, vi &v){
	if(i==0) return 0;
	if(i==1) return abs(v[i]-v[i-1]);
	if(dp[i]!=-1) return dp[i];
	return dp[i]=min(abs(v[i]-v[i-1])+solve(i-1,dp,v),abs(v[i]-v[i-2])+solve(i-2,dp,v));
}

int main(){
	IOS
	ll t;
	cin>>t;
	vi v(t),dp(t,-1);
	loop(0,t-1,1) cin>>v[i];
	cout<<solve(t-1,dp,v);
	return 0;
}


Measured memory_bytes: 4992
n, m = gets.split(" ").map(&:to_i)
h = gets.split(" ").map(&:to_i)
check = Array.new(n, 1)
for i in 1..m
  a, b = gets.split(" ").map(&:to_i)
  if h[a-1] < h[b-1]
    check[a-1] = 0
  elsif h[a-1] > h[b-1]
    check[b-1] = 0
  elsif h[a-1] = h[b-1]
    check[a-1] = 0
    check[b-1] = 0
  end
end

puts check.sum

Measured memory_bytes: 22680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
vector<ll> v1[N], v2[N];
ll c = 0, ans[N];
bool vis[N] = {0};


void solve(ll n, ll c) {
    for(ll j=0;j<v2[n].size();j++)c += v2[n][j];
    ans[n] = c;
    vis[n] = 1;
    for(ll j=0;j<v1[n].size();j++) {
        ll x = v1[n][j];
        if(!vis[x])solve(x, c);
    }
}
int main() {
   ll j, n, k = 0, x = 0, y = 0, i;
   cin>>n>>k;
   for(i=1;i<n;i++) {
       cin>>x>>y;
       v1[x].push_back(y);
       v1[y].push_back(x);
   }
   for(i=0;i<k;i++) {
       cin>>x>>y;
       v2[x].push_back(y);
   }
   c = 0;
   solve(1, 0);
   for(i=1;i<=n;i++)cout<<ans[i]<<" ";
}

Measured memory_bytes: 35200
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<set>
#include<functional>
#include<queue>
#include<cmath>
#include<algorithm>
#include<complex>
#include<cstdlib>
#include<cctype>

#define DBG cout << '!' << endl;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;}
#define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int n,ans = 0;
	
	cin >> n;
	
	iv v;	
	REP(i,n)
	{
		int tmp;
		cin >> tmp;
		v.PB(tmp);
	}
	
	sort(ALL(v));
	
	int ren = 0;
	for(int i = 0;i < v.size();i++)
	{
		if(v[i] == v[i+1])
		{
			ren++;
		}
		else
		{
			if(ren % 2 == 0)ans++;
			ren = 0;
		}
	}

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

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

#define P pair<lli,lli>

struct d{
	lli x,y;
	bool operator<(const d& right)const{
		if( (this->y-this->x) != (right.y-right.x) ){
			return this->y-this->x > right.y-right.x;
		}
		else{
			return this->y > right.y;
		}
	}
};

signed main(){

	lli n;
	cin>>n;

	vector<lli> a(n),b(n);
	vector<d> c;

	lli ans = 0;
	bool flag=true;
	vector<lli> dd;
	REP(i,0,n){
		cin>>a[i]>>b[i];
		if(a[i]!=b[i])flag=false;

		if(b[i]>=a[i])c.push_back({a[i],b[i]});
		else dd.push_back(b[i]);
	}
	if(flag){
		cout<<0<<endl;
		return 0;
	}
	lli left=0;

	sort(c.begin(),c.end());
	sort(dd.rbegin(),dd.rend());
	
	REP(i,0,c.size()){
		if(DEBUG)cout<<"cx="<<c[i].x<<" cy="<<c[i].y<<" left="<<left<<endl;
		ans += c[i].y;
	}

	REP(i,0,dd.size()-1){
		ans+=dd[i];
	}
	
	/*
	REP(i,0,n){
		if(DEBUG)cout<<"cx="<<c[i].x<<" cy="<<c[i].y<<" left="<<left<<endl;
		if(c[i].y+left>c[i].x){
			ans += c[i].x;
			left = c[i].y+left-c[i].x;
		}
		else break;
	}*/
	cout<<ans<<endl;



	return 0;
}

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#define int long long int
#define double long double
#define mod 1000000007
#define w(t) int t=1; while(t--)
#define f(i,a,n) for( int i=a;i<n;i++)
#define pb push_back
#define pob pop_back
#define mk make_pair
#define ARMY ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
vector<string> v;
int dp[101][100001];
int solve(int n,int *v,int *w,int wt)
   {  
    for(int i=0;i<=100000;i++)
      dp[1][i]=1e9+1;
      dp[1][0]=0;
      dp[1][v[0]]=w[0];
      for(int i=2;i<=n;i++)
         {
            for(int j=0;j<=100000;j++)
             {
                //dp[i][j]=dp[i-1][j];
                if(v[i-1]>j) dp[i][j]=min(dp[i-1][j], w[i-1]);
               else dp[i][j]=min(w[i-1]+dp[i-1][j-v[i-1]],dp[i-1][j]);
             }
         }
         int ans=0;
         for(int i=100000;i>=0;i--)
           if(dp[n][i]<=wt) return i;
         return 0;
   }
int32_t main()
  {
   ARMY
   w(t)
    {
       int n,wt;
       cin>>n>>wt;
       int a[n],w[n];
       f(i,0,n)
       cin>>w[i]>>a[i];
       cout<<solve(n,a,w,wt);
 
    } 
  }

Measured memory_bytes: 81740
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
 
int main(){
 
  int N;
  cin >> N;

  cout << "ABC" << N << endl;



  return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;



int main(){
    int n;
    cin >> n;
    unordered_map<ll,ll> table;
    table[0]++;
    ll a,sum=0;
    REP(i,n){
        cin >> a;
        sum+=a;
        table[sum]++;
    }
    ll cou=1,res=0;
    for(pair<ll,ll> p:table){
        ll pf=p.fr;
        ll ps=p.sc;
//        cout << pf << " " << ps << endl;
        res+=((ps-1)*ps)/2;
    }
    cout << res << endl;
}


Measured memory_bytes: 8520
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;

int parent(int uft[],int child){
    if(uft[child] == -1)return child;
    return uft[child] = parent(uft,uft[child]);
}

int main(){
    int N,M;
    int uft[MAX];

    for(int i = 0;i < MAX;i++){
        uft[i] = -1;
    }

    cin >> N >> M;
    for(int i = 0;i < M;i++){
        int x,y,z;
        cin >> x >> y >> z;
        x--;y--;
        
        int p1 = parent(uft,x);
        int p2 = parent(uft,y);
        if(p1 == p2)continue;
        uft[p1] = p2;
    }

    int ans = 0;
    for(int i = 0;i < N;i++){
        if(uft[i] == -1)ans++;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{


    static void Main(string[] args)
    {
        string W = Console.ReadLine();     
        string str;
        string[] Ti;
        int count = 0;     

        do
        {         
            str = Console.ReadLine();

            if (str == "END_OF_TEXT")
            {
                break;
            }

            Ti = str.Split(' ');
            
            foreach(var s in Ti)
            {
                
                if(W == s || W == s.ToLower() || W == s.ToUpper())
                {
                    count++;
                }
                              
            }
           

        } while (true);

        Console.WriteLine(count);

        
    }
}


Measured memory_bytes: 15868
S = gets.chomp.chars
ans = Array.new(S.size, 0)
cnt_r, cnt_l = 0, 0

S.size.times do |i|
    if S[i] == "R"
        cnt_r += 1
    else
        ans[i] += cnt_r / 2
        ans[i - 1] += (cnt_r + 1) / 2
        cnt_r = 0
    end
end

S.size.times do |i|
    j = S.size - i - 1
    if S[j] == "L"
        cnt_l += 1
    else
        ans[j] += cnt_l / 2
        ans[j + 1] += (cnt_l + 1) / 2
        cnt_l = 0
    end
end

puts ans.join(" ")




Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long n,a[100002],b[100002],ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n+1;i++)
	{
		FAST_IO::read(a[i]);
	}
	for(int i=1;i<=n;i++)
	{
		FAST_IO::read(b[i]);
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>=b[i])
		{
			ans+=b[i];
		}
		else
		{
			b[i]-=a[i];
			ans+=a[i];
			if(a[i+1]<=b[i])
			{
				//system("Pause");	
				ans+=a[i+1];
				a[i+1]=0;
			}
			else
			{
				a[i+1]-=b[i];
				ans+=b[i];
			}
		}
		//cout<<i<<" "<<ans<<endl;
	}
	cout<<ans;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	if (n == 1) {
		cout << "Hello World" << endl;
		return 0;
	}
	else {
		int a, b;
		cin >> a >> b;
		cout << a+b << endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

int tate[110][110];
int yoko[110][110];
int main(){
  int w,h;
  const int m = 100000;
  yoko[2][2]=tate[2][2]=1;
  yoko[2][1]=tate[1][2]=1;

  for(int i=0; i<105; i++){
    int y = i+2;
    for(int j=(i==0?1:0); j<105; j++){
      int x = j+2;
      yoko[y][x] = (m + yoko[y][x-1] + tate[y-2][x])%m;
      tate[y][x] = (m + tate[y-1][x] + yoko[y][x-2])%m;
    }
  }
  /*
  for(int i=0; i<10; i++){
    printf("yoko");
    for(int j=0; j<5; j++){
      printf("%4d ",yoko[i][j]);
    }
    puts("");
    printf("tate");
    printf(" ");
    for(int j=0; j<10; j++){
      printf("%4d ",tate[i][j]);
    }
    puts("");
  }
  */
  while(cin>>w>>h, w+h){
    h++; w++;
    cout << (yoko[h][w-1] + tate[h-1][w])%m << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int W,a,b; cin>>W>>a>>b;
    if(a>b) swap(a,b);
    int ans=max(0LL,b-(a+W));
    cout<<ans<<endl;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    int a,b,c;
    cin>>a>>b>>c;

    //cout <<fixed<<setprecision(16)<< << endl;

    if(a<= c && c<= b)cout << "Yes" <<endl;
    else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
#define fori(s,n) for(int i=s;i<n;i++) 
#define forj(s,n) for(int j=s;j<n;j++) 
#define vii vector<int>
int t = 1, n, m;
vector<vii> edges;
int dp[100000 + 1];
int solve(int i) {///1  2  
	if (edges[i].size() == 0) return 0;
	int& ret = dp[i];
	if (~ret) return ret;
	int r1 = 0;
	for (auto child : edges[i]) {
		r1 = max(r1, 1 + solve(child));
	}
	return ret=r1;
}
signed main()
{
	fast;
   //cin>>t;
	int u, v;
	while (t--)
	{
		memset(dp, -1, sizeof dp);
		cin >> n >> m;
		edges = vector<vii>(n + 1);
		while (m--) {
			cin >> u >> v;
			edges[u].push_back(v);
		}
		int ans = 0;
		fori(1, n + 1) {
			ans = max(ans, solve(i));
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 11452
use std::io;
use std::str::FromStr;

fn solve(x: i64, a: i64, b: i64) {
    if (x - a).abs() > (b - x).abs() {
        println!("B");
    } else {
        println!("A");
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let split : Vec<&str> = input.split(' ').collect();
    let x : i64 = i64::from_str(split[0].trim()).unwrap();
    let a : i64 = i64::from_str(split[1].trim()).unwrap();
    let b : i64 = i64::from_str(split[2].trim()).unwrap();
    solve(x, a, b);
}


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

int main(){
	string str;
	string hosino = "Hoshino";
	string hosina = "Hoshina";
	int n, index;
	cin>>n;cin.ignore();
	for(int i=0;i<n;i++){
		getline(cin,str);
		while((index = str.find(hosino.c_str(), 0)) != string::npos){
			str.erase(str.begin()+index, str.begin()+index+hosino.size());
			str.insert(index, hosina);
		}
		cout<<str<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

int width, hight = 0;
int map_data[91][91];
const int vx[4] = {0, 0, 1, -1};
const int vy[4] = {1, -1, 0, 0};

int solve(int x, int y, int cnt){
    int tmp = cnt;
    
    for(int i = 0;i < 4;i++){
        int nx = x + vx[i];
        int ny = y + vy[i];
        
        if(nx >= 0 && nx < width && ny >= 0 && ny < hight && map_data[ny][nx] == 1){
            map_data[ny][nx] = 0;
            tmp = max(tmp, solve(nx, ny, cnt+1));
            map_data[ny][nx] = 1;
        }
    }
    
    return tmp;
}

int main(){    
    while(1){
        scanf("%d %d", &width, &hight);
        if(width == 0 && hight == 0){
            break;
        }
        
        for(int i = 0;i < hight;i++){
            for(int j = 0;j < width;j++){
                scanf("%d", &map_data[i][j]);
            }
        }
        
        int result = 0;
        
        for(int i = 0;i < hight;i++){
            for(int j = 0;j < width;j++){
                if(map_data[i][j] == 1){
                    map_data[i][j] = 0;
                    result = max(result, solve(j, i, 1));
                    map_data[i][j] = 1;
                }
            }
        }
        
        printf("%d\n", result);
    }
    
    return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)

#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  int n;
  int count = 0;
  int minimum = INT_MAX;
  string s;
  vector<int> idx;
  cin >> n >> s;

  REP(i, n) {
    idx.push_back(count);
    if(s[i] == 'W') count++;
  }

  count = 0;
  RREP(i, n) {
    minimum = min(minimum, idx[i] + count);
    if(s[i] == 'E') count++;
  }

  cout << minimum << endl;

  return 0;
}


Measured memory_bytes: 2812
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
struct Buffer{
    enum { chunk = 1 << 16 };
    int idx;
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};
struct FastInput {
    Buffer buf;
    template <class T>
    FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

// 1-based
struct BIT{
    vector<int> data;
    BIT(int n): data(n + 1){ }
    void add(int idx, int num){
        for(; idx < (int)data.size(); idx += idx & -idx){
            data[idx] += num;
        }
    }
    int sum(int idx){
        int ret = 0;
        for(; idx; idx -= idx & -idx){
            ret += data[idx];
        }
        return ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, q;
    cin >> n >> m >> q;
    printde(n, m, q);
    vector<pair<int, int>> lrs(m), pqs(q);
    cin >> lrs >> pqs;
    printde(lrs, pqs);
    sort(lrs.begin(), lrs.end());
    vector<int> anss(q), qis(q);
    iota(qis.begin(), qis.end(), 0);
    sort(qis.begin(), qis.end(), [&](int i, int j){ return pqs[i] > pqs[j]; });
    int idx = m - 1;
    BIT bit(n);
    for(auto& qi : qis){
        while(idx >= 0 && pqs[qi].first <= lrs[idx].first){
            bit.add(lrs[idx].second, 1);
            idx--;
        }
        anss[qi] = bit.sum(pqs[qi].second);
    }
    for(auto& ans : anss){
        cout << ans << '\n';
    }
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
const int mod=1e9+7;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int qpow(int a,int b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

int n,to[N<<1],ww[N<<1],nxt[N<<1],tt=1,fac[N],ifac[N],h[N],V,E,st[N],tp=0,fe[N],p,f[N],sz[N],coef;
bool vis[N];

void dfs1(int u,int ff) {
	vis[u]=1;++V;fe[u]=ff;
	for(int i=h[u],v;v=to[i],i;i=nxt[i]) {
		++E;if(i==(ff^1)) continue;
		if(!vis[v]) dfs1(v,i);
		else if(!tp) {
			int x=u;st[tp=1]=i;
			while(x!=v) st[++tp]=fe[x],x=to[fe[x]^1];
		}
	}
}

int C(int n,int m) {
	if(m<0||n<m) return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}

void dfs2(int u,int ff) {
	sz[u]=0;f[u]=1;
	for(int i=h[u],v;v=to[i],i;i=nxt[i])
		if((i^ff^1)&&(i>>1)!=(p>>1)) {
			dfs2(v,i);
			if(ww[ff]<ww[i]) coef=1ll*coef*ifac[sz[v]]%mod*f[v]%mod;
			else sz[u]+=sz[v],f[u]=1ll*f[u]*f[v]%mod*C(sz[u],sz[v])%mod;
		}
	++sz[u];
}

int main() {
	cin>>n;
	for(int i=1,u,v;i<=n+n;i++) {
		u=gi(),v=gi()+n;
		to[++tt]=v,ww[tt]=u+v,nxt[tt]=h[u],h[u]=tt;
		to[++tt]=u,ww[tt]=u+v,nxt[tt]=h[v],h[v]=tt;
	}
	fac[0]=1;for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-1;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
	int ans=fac[n+n];
	for(int i=1,sum;i<=n+n;i++)
		if(!vis[i]) {
			V=E=tp=p=sum=0,dfs1(i,0);
			if(E/2!=V) return cout<<0,0;
			for(int j=1;j<=tp;j++) if((!p)||ww[st[j]]>ww[p]) p=st[j];
			coef=1,dfs2(to[p],p),sum=(sum+1ll*coef*f[to[p]]%mod*ifac[sz[to[p]]])%mod;
			coef=1,dfs2(to[p^1],p),sum=(sum+1ll*coef*f[to[p^1]]%mod*ifac[sz[to[p^1]]])%mod;
			ans=1ll*ans*sum%mod;
		}
	cout<<ans;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b)cout << c << endl;
	if (a == c)cout << b << endl;
	if (b == c)cout << a << endl;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 128
//C - Switches
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>
#include <bitset>

using namespace std;

#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 ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    int n, m;
    cin >> n >> m;

    vector<vector<int>> ss(m);
    REP(i, m) {
        int k;
        cin >> k;
        REP(j,k){
            int s;
            cin >> s;
            s--;
            ss[i].push_back(s);
        }
    }
    vector<int> p(m);
    REP(i,m) cin >> p[i];

    int ans=0;
    int maxPattern = pow(2,n);
    REP(i, maxPattern){
        bool allOn=true;
        REP(j, m){
            int onSwitchCnt=0;
            REP(k, ss[j].size()){
                onSwitchCnt += ((i >> ss[j][k]) & 1);
                //cout << i << " " << j << " " << k << ":" << ((i >> ss[j][k]) & 1) << endl;
            }
            if (p[j]!=onSwitchCnt%2){
                allOn = false;
                break;
            }
        }
        if (allOn) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4076
#include <iostream>
using namespace std;
int main()
{
	int n,s=0;
	cin>>n;
	int a[n+1];
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]>a[i-1])
		s+=a[i]-a[i-1];
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String args[]){
		Scanner scan = new Scanner(System.in);
		String w = scan.nextLine();
		String a = w.substring(0,1);
		String b = w.substring(1,2);
		String c = w.substring(2,3);
		String ans = "7";

			if (a.equals(ans)){
				System.out.println("Yes");
			}else if (b.equals(ans)){
				System.out.println("Yes");
			}else if (c.equals(ans)){
				System.out.println("Yes");
			}else{
				System.out.println("No");
		}
	}
}

Measured memory_bytes: 26972
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    
    double a = sc.nextDouble();
    double b = sc.nextDouble();
    int h = sc.nextInt();
    int m = sc.nextInt();
    double rads = 2.0 * Math.PI * ((double)m / 60.0);
    double radl = (Math.PI / 6) * h + (Math.PI / 6.0) * ((double)m / 60.0);
    double rad = 0.0;
    if (Math.abs(rads- radl) < Math.PI)
    	rad = Math.abs(rads - radl);
    else
      	rad = 2.0 * Math.PI - Math.abs(rads - radl);
    double c = Math.sqrt(a*a + b*b - 2.0*a*b*Math.cos(rad));

    System.out.println(c);
  }
}
      

Measured memory_bytes: 37552
#include <bits/stdc++.h>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    string name;
    int t;
    queue<pair<string, int>> Q;
    
    int n,q;
    cin >> n >> q;

    rep(i,n){
        cin >> name >> t;
        Q.push(make_pair(name,t)); //name(string型)とt(int型)の構造体をmake_pairで定義
    }

    int tsum=0;
    pair<string, int> u;
    while(!Q.empty()){
        u=Q.front();
        if(u.second >q){
            Q.push(make_pair(u.first,u.second-q));
            Q.pop();
            tsum += q;
        }
        else
        {
            tsum += u.second;
            cout << u.first << " " << tsum << endl;
            Q.pop();
        }
        
    }

    
}


Measured memory_bytes: 6208
A,B,N=map(int,input().split())
if B-1>N:
    x=N/B
else:
    x=(B-1)/B
x-=int(x)
print(int(A*x))










        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 9064
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

char s[105];
vi p[26];
int n;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n) p[s[i]-'a'].pb(i);
	int ans=n-1;
	REP(c,26){
		if(p[c].empty()) continue;
		int mx=p[c].front()-1;
		mx=max(mx,n-p[c].back());
		for(int i=0;i+1<p[c].size();i++)
			mx=max(mx,p[c][i+1]-p[c][i]-1);
		ans=min(ans,mx);
	}
	cout<<ans<<endl;
	return 0;
}

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

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

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

    cout << (ll)N * (N - 1) / 2 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		for (;;) {
			int x = s.nextInt(), y = s.nextInt(), t = s.nextInt();
			if (x < 1) {
				break;
			}
			int max = 0;
			for (int i = 1; i < t; ++i) {
				for (int j = 1; j <= t - i; ++j) {
					int a = (int) Math.floor(i * (100 + x) / 100.0);
					int b = (int) Math.floor(j * (100 + x) / 100.0);
					if (a + b == t) {
						int c = (int) Math.floor(i * (100 + y) / 100.0);
						int d = (int) Math.floor(j * (100 + y) / 100.0);
						max = Math.max(max, c + d);
					}
				}
			}
			System.out.println(max);

		}
	}
}

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

string a,b;

signed main()
{
	cin>>a>>b;
	int ans=0;
	for (int i=0;i<=a.size()-1;i++)
	{
		if (a[i]!=b[i])  ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

/* -- template -- */

int main() {
    int N;
    cin >> N;
    vector<vector<int>>G(N);
    int a[N - 1], b[N - 1];
    vector<P>v(N - 1);
    rep(i, N - 1) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
        G[a[i]].pb(b[i]);
        G[b[i]].pb(a[i]);
        v[i] = mp(a[i], b[i]);
    }
    vector<bool>visited(N, false);
    vector<int> parentColor(N, 0);
    map<P, int> color;
    visited[0] = true;
    queue<int>Q;
    Q.push(0);
    parentColor[0] = 0;
    while(!Q.empty()) {
        int q = Q.front(); Q.pop();
        int cur = 1;
        for(int next : G[q]) {
            if(visited[next])continue;
            if(cur == parentColor[q])++cur;
            Q.push(next);
            visited[next] = true;
            parentColor[next] = color[mp(q, next)] = color[mp(next, q)] = cur++;
        }
    }
    int maxv = 0;
    for(P i : v) {
        maxv = max(color[i], maxv);
    }
    cout << maxv << endl;
    for(P i : v) {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 21248
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	if (N < 1200) {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] t = new int[N][3];
		int tmp;
		for(int i=0;i<N;i++){
			for(int j=0;j<3;j++){
				t[i][j] = sc.nextInt();
				if(j==1&&t[i][0]>t[i][1]){
					tmp = t[i][0];
					t[i][0] = t[i][1];
					t[i][1] = tmp;
				}
				if(j==2&&t[i][1]>t[i][2]){
					tmp = t[i][1];
					t[i][1] = t[i][2];
					t[i][2] = tmp;
				}
			}
		}
		for(int i=0;i<N;i++){
			if(t[i][0]*t[i][0]+t[i][1]*t[i][1]==t[i][2]*t[i][2]){
				System.out.println("YES");
			}
			else{
				System.out.println("NO");
			}
		}
		
	}
}

Measured memory_bytes: 34000
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long A=sc.nextLong(),B=sc.nextLong();
		long ans=A/gcd(A,B)*B;
		System.out.println(ans);


	}

	public static long gcd(long a,long b) {
		if(a<b) {
			return gcd(b,a);
		}
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000



int main(){
	
	int H,W;
	cin>>H>>W;
	
	vector<string> S(H);
	for(int i=0;i<H;i++){
		cin>>S[i];
	}
	
	for(int i=H-1;i>=0;i--){
		bool f = true;
		for(int j=0;j<W;j++){
			if(S[i][j]=='#')f=false;
		}
		if(f){
			S.erase(S.begin()+i);
		}
	}
	
	for(int i=W-1;i>=0;i--){
		bool f = true;
		for(int j=0;j<S.size();j++){
			if(S[j][i]=='#')f=false;
		}
		if(f){
			for(int j=0;j<S.size();j++){
				S[j].erase(S[j].begin()+i);
			}
		}
	}
	
	for(int i=0;i<S.size();i++){
		cout<<S[i]<<endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int N = nextInt();
		ArrayList<Integer> list = nextIntArray();
		int output = (int)Math.pow(3, N);
		int even = 1;
		for(int i = 0; i < N; i++){
			if(list.get(i) % 2 == 0){
				even *= 2;
			}
		}
		myout(output - even);
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


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

vector<long long> P(2);
vector<long long> M = {1000003, 1000007};
vector<long long> MOD = {1000000007, 1000000009};

int A[400005], B[200005], C[30][200005];
string S, T;

void func(int k)
{
    vector<long long> hashx(2), hashy(2);

    for(auto t : T)
        for(int i=0; i<2; i++)
        {
            hashx[i] = (hashx[i] * M[i] + t) % MOD[i];
            hashy[i] = (hashy[i] * M[i] + ('0' + (1 ^ (t - '0')))) % MOD[i];
        }
    
    vector<long long> curr(2);

    for(int i=0; i<T.size(); i++)
        for(int j=0; j<2; j++)
            curr[j] = (curr[j] * M[j] + S[i]) % MOD[j];
    
    if(curr == hashx)
        C[k][0] = 0;
    if(curr == hashy)
        C[k][0] = 1;

    for(int i=T.size(); i<S.size(); i++)
    {
        for(int j=0; j<2; j++)
            curr[j] = (curr[j] * M[j] + S[i] - P[j] * S[i-T.size()] % MOD[j] + MOD[j]) % MOD[j];
        
        if(curr == hashx)
            C[k][i-T.size()+1] = 0;
        if(curr == hashy)
            C[k][i-T.size()+1] = 1;
    }
}

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

    int N;
    cin >> N;

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

    P[0] = P[1] = 1;

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

        for(int j=0; j<2; j++)
            P[j] = P[j] * M[j] % MOD[j];
    }

    long long ans = 0;
    memset(C, -1, sizeof(C));

    for(int i=0; i<30; i++)
    {
        S.clear(), T.clear();

        for(int j=0; j<2*N; j++)
            S.push_back((char)('0' + (((1 << i) & A[j]) > 0)));
        for(int j=0; j<N; j++)
            T.push_back((char)('0' + (((1 << i) & B[j]) > 0)));

        func(i);
    }

    for(int i=0; i<N; i++)
    {
        int ans = 0;

        for(int j=0; j<30; j++)
        {
            if(C[j][i] == -1)
            {
                ans = -1;
                break;
            }
            else if(C[j][i])
                ans += (1 << j);
        }

        if(ans != -1)
            cout << i << " " << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 30084
from bisect import bisect_left

def main():
    A, B, Q = map(int, input().split())
    S = [0] * A
    T = [0] * B
    for i in range(A):
        S[i] = int(input())
    for i in range(B):
        T[i] = int(input())
    
    for _ in range(Q):
        x = int(input())
        s_cnt = bisect_left(S,x)
        t_cnt = bisect_left(T,x)
        s_cand = []
        t_cand = []
        if s_cnt == 0:
            s_cand.append(S[s_cnt])
        elif s_cnt == A:
            s_cand.append(S[s_cnt-1])
        else:
            s_cand.append(S[s_cnt])
            s_cand.append(S[s_cnt-1])
        if t_cnt == 0:
            t_cand.append(T[t_cnt])
        elif t_cnt == B:
            t_cand.append(T[t_cnt-1])
        else:
            t_cand.append(T[t_cnt])
            t_cand.append(T[t_cnt-1])
        d = float('inf')
        for i in s_cand:
            for j in t_cand:
                tmp = abs(x - i) + abs(i - j)
                d = min(d, tmp)

        for i in t_cand:
            for j in s_cand:
                tmp = abs(x - i) + abs(i - j)
                d = min(d, tmp)
        print(d)


if __name__ == "__main__":
    main()

Measured memory_bytes: 74072
n=int(input())
f=False
c=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    c+=1
    if c==3:
      f=True
      break
  else:
    c=0
if f:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 62480
strn=input()
K = int(input())
wordindex=[]
minindex=list(set(strn))
minindex.sort()
def IndexPoint(index,word):
    return [i for i,x in enumerate(index) if x == word]
while len(wordindex) < K:
    for m in minindex:
        point = IndexPoint(strn,m)
        for p in point:
            tmp = ""
            for i in range(p,min(len(strn),p+K+1)):
                tmp += strn[i]
                wordindex.append(tmp)
wordindex = list(set(wordindex))
wordindex.sort()
print(wordindex[K-1])

Measured memory_bytes: 5428
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x))
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 20 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
ll n,W,memo[100][N];
pair<ll,ll>arr[N];
ll solve(ll ind, ll w)
{
    if(w > W)
        return -1e9;
    if(ind == n)
        return 0;
    ll &ans = memo[ind][w];
    if(~ans)
        return ans;
    ans = max(solve(ind + 1, w), solve(ind + 1, w + arr[ind].first) + arr[ind].second);
    return ans;
}
int main()
{
    MuhammedAly
    memset(memo,-1,sizeof memo);
    cin >> n >> W;
    for(int i = 0;i<n;i++)
        cin >> arr[i].first >> arr[i].second;
    cout << solve(0,0);
    return 0;
}

Measured memory_bytes: 78464
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	if (ceil((double)A/D) >= ceil((double)C/B)){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3612