akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int b[222222];
int vis[6222];
int a[6666];

vector<ll> S;

void dfs(int u, ll s)
{
	if(vis[u]) return ;
	vis[u]=1;
	s+=b[u];
	S.pb(s);
	dfs(a[u],s);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=0;i<n;i++) 
	{
		cin>>a[i]; a[i]--;
	}
	for(int i=0;i<n;i++) 
	{
		cin>>b[i]; 
	}
	ll ans = -ll(1e18);
	for(int i=0;i<n;i++)
	{
		memset(vis,0,sizeof(vis));
		dfs(i,0);
		if(S.back()>0&&k>=int(S.size()))
		{
			ll q = k/int(S.size());
			if(q>=1)
			{
				ll mx = -ll(1e18);
				if(q-1>0) mx=0;
				for(int i=0;i<int(S.size());i++)
				{
					mx=max(mx,S[i]);
				}
				ans=max(ans,(q-1)*S.back()+mx);
			}
			
			{
				int r = k%int(S.size());
				ll mx = 0;
				for(int i=0;i<r;i++)
				{
					mx=max(mx,S[i]);
				}
				ans=max(ans,mx+q*S.back());
			}
		}
		else
		{
			for(int j=1;j<=k;j++)
			{
				if(j-1<S.size()) ans=max(ans,S[j-1]);
				else break;
			}
		}
		S.clear();
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3872
mod = 10**9 + 7
n, k = map(int, input().split())
p = [i for i in range(n+1)]
ans = 0
mi = sum(p[:k])
ma = sum(p[n-k+1:])
for ki in range(k, n+2):
    ans += ma - mi + 1
    mi += ki
    ma += n - ki
print(int(ans % mod))

Measured memory_bytes: 18300
h,w=map(int,input().split())
g=[input() for _ in range(h)]
from collections import *
def bfs(sx,sy):
  d=[[-1]*w for _ in range(h)]
  d[sx][sy]=0
  q=deque([(sx,sy)])
  while q:
    x,y=q.popleft()
    for dx,dy in [(1,0),(0,1),(-1,0),(0,-1)]:
      nx,ny=x+dx,y+dy
      if 0<=nx<h and 0<=ny<w and g[nx][ny]=='.' and d[nx][ny]<0:
        r=d[nx][ny]=d[x][y]+1
        q.append((nx,ny))
  return r
print(max(bfs(sx,sy) for sx in range(h) for sy in range(w) if g[sx][sy]=='.'))

Measured memory_bytes: 9412
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 10e9+7
#define ll long long int

int main(void){
    char s[100001];
    scanf("%s", &s);
    int i = 0;
    while(s[i]!='\0')i++;
    char s1 = s[0];
    char se = s[i-1];
    if(i%2 == (s1!=se))printf("First\n");
    else printf("Second\n");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n);
	VEC(int, a, n);
	sort(ALL(a));
	reverse(ALL(a));
	int ans = 0;
	REP(i, n) {
		ans += (i % 2 == 1 ? -a[i] : a[i]);
	}
	OUT(ans)BR;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  int w,h,n; cin>>w>>h>>n;
  int x[n],y[n],a[n];
  int xleft=0,xright=w;
  int ydown=0,yup=h;
  rep(i,n){
    cin>>x[i]>>y[i]>>a[i];
    switch(a[i]){
      case 1:
        xleft=max(xleft,x[i]);
        break;
      case 2:
        xright=min(xright,x[i]);
        break;
      case 3:
        ydown=max(ydown,y[i]);
        break;
      case 4:
        yup=min(yup,y[i]);
    }
  }
  int xrange=max(0,xright-xleft);
  int yrange=max(0,yup-ydown);
  cout<<xrange*yrange;
}


Measured memory_bytes: 256
import collections
n = int(input())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


ns = make_divisors(n)

ans = 0
for i in ns:
    if i == 1:
        continue
    p = n
    while p % i == 0:
        p //= i
    if p % i == 1:
        ans += 1


ns = make_divisors(n - 1)
ans += len(ns) - 1
print(ans)


Measured memory_bytes: 68160
#include <cstdint>
#include <iostream>
using i8 = std::int_fast8_t;
using u8 = std::uint_fast8_t;
using i16 = std::int_fast16_t;
using u16 = std::uint_fast16_t;
using i32 = std::int_fast32_t;
using u32 = std::uint_fast32_t;
using i64 = std::int_fast64_t;
using u64 = std::uint_fast64_t;
inline void fast_io() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}
template <class T>
inline void in(T &now) {
    std::cin >> now;
}
template <class T, class... Args>
void in(T &head, Args &... tail) {
    in(head);
    in(tail...);
}
template <class T>
inline void out(T now) {
    std::cout << now;
}
template <class T, class... Args>
void out(T head, Args... tail) {
    out(head);
    out(tail...);
}
template <class T>
inline void up(T &a, const T &b) noexcept {
    if (a < b) {
        a = b;
    }
}
template <class T, class... Args>
void up(T &a, const T &head, const Args &... tail) noexcept {
    up(a, head);
    up(a, tail...);
}
template <class T>
inline void down(T &a, const T &b) noexcept {
    if (b < a) {
        a = b;
    }
}
template <class T, class... Args>
void down(T &a, const T &head, const Args &... tail) noexcept {
    down(a, head);
    down(a, tail...);
}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

    i32 n, sum{};
    in(n);
    vector<i32> all(n);
    for (auto &i : all) {
        in(i);
        sum += i;
    }
    i32 avg = sum / n, ans{}, ans2{};
    for (auto &i : all) {
        ans += pow((i - avg), 2);
    }
    for (auto &i : all) {
        ans2 += pow((i - (avg + 1)), 2);
    }
    down(ans, ans2);
    out(ans);

    return 0;
}


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

using namespace std;

const int N = 3e4;
const long long INF = 2e18;
long long dp[N];

void solve() {
    int h, n;
    cin >> h >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    for (int i = 1; i < N; i++) dp[i] = INF;
    long long ans = INF;
    for (int v = 1; v < N; v++) {
        for (int i = 0; i < n; i++) {
            if (v - a[i] < 0) continue;
            dp[v] = min(dp[v], dp[v - a[i]] + b[i]);
            if (v >= h) ans = min(ans, dp[v]);
        }
    }
    cout << ans;
}

int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(20);
    solve();
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;
long long int t(long long int a,long long int b){
long long int p=b-a+1;
return (a+b)*p/2;}
int main()
{
long long int n,k;
long long int s=0;
long long mod=1000000007;
cin>>n>>k;
{
for(long long int i=k-1;i<=n;i++)
    {
        s+=t(n-i,n)-t(0,i)+1;
        if(s>mod) s%=mod;
    }
    cout<<s%mod;
}
    return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find algo with array
// Find()
int findpar(int curr, int arr[])
{
  while(arr[curr] != curr) curr = arr[curr];
  return curr;
}
// Union()
void Union(int b, int spa, int arr[])
{
  while(arr[b] != b)
  {
    int c = arr[b];
    arr[b] = spa;
    b = c;
  }
  arr[b] = spa;
}

// Main Code

int main()
{
  ll a;
  cin>>a;
  ll z = sqrt(a);
  ll x, y;
  ll moves = LONG_MAX;
  for(int i = z; i >= 1; i--){
    if(a%i == 0){
      x = i;
      y = a / i;
      moves = min(moves, x+y-2);
      //cout<<x<<" "<<y<<endl;
    }
  }
  cout<<moves<<endl;
  return 0;
}


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

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

int K;
string S;

void inc()
{
    int N = S.size() - 1;
    for(int i = N; i >= 0; i--)
    {
        int now = S[i] - '0';
        if(i == 0)
        {
            S.clear();
            if(now == 9)
            {
                S.push_back('1');
                for(int j = 0; j < N + 1; j++)
                    S.push_back(max((char)(S[j] - 1), '0'));
            }
            else
            {
                S.push_back(now + 1 + '0');
                for(int j = 0; j < N; j++)
                    S.push_back(max((char)(S[j] - 1), '0'));
            }
            return;
        }

        int pre = S[i - 1] - '0';
        if(now != 9 && pre >= now)
        {
            S[i]++;
            for(int j = i + 1; j <= N; j++)
            {
                S[j] = max((char)(S[j - 1] - 1), '0');
            }
            return;
        }
    }
}

signed main()
{
    cin >> K;

    S = "1";
    rep(i, K - 1)
    {
        // cout << S << endl;
        inc();
    }

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        long H = sc.nextLong(), N = sc.nextLong();
        long[] A = new long[(int) N], B = new long[(int) N];

        for (int i = 0; i < N; i++) {
            A[i] = sc.nextLong();
            B[i] = sc.nextLong();
        }

        long INF = 1 << 60;
        long[][] dp = new long[(int) N][(int) H + 10001];
        for (long[] i : dp) {
            Arrays.fill(i, INF);
            i[0] = 0;
        }

        for (int i = 0; i < N; i++) {
            for (int j = 0; j <= H + 10000; j++) {
                if (i > 0) dp[i][j] = dp[i - 1][j];
                if (j >= A[i]) {
                    dp[i][j] = Math.min(dp[i][j - (int) A[i]] + B[i], dp[i][j]);
                }
            }
        }

        long ans = INF;
        for (long j = H; j <= H + 10000; j++) {
            ans = Math.min(ans, dp[(int) N - 1][(int) j]);
        }

        out.println(ans);

        out.close();
    }


    public static PrintWriter out;

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}


Measured memory_bytes: 244692
#import<iostream>
using namespace std;string s[]={"","Man","Oku","Cho","Kei","Gai","Jo","Jou","Ko","Kan","Sei","Sai","Gok","Ggs","Asg","Nyt","Fks","Mts"};int m,n;main(){for(;cin>>m>>n,m;){int a[19]={},i,j=1e4;*a=1;for(;n;--n)for(i=18;i+1;--i)a[i]*=m,a[i+1]+=a[i]/j,a[i]%=j;for(i=18;i+1;--i)if(a[i])cout<<a[i]<<s[i];cout<<endl;}}

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>

using namespace std;
#define endl '\n'
#define pb push_back
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1e9 + 7)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) > "Yes" : "No" ) << endl


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

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

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

void solve() {

	int n = in(), k = in();
	ll cnt = 0;

	if (k % 2 == 0) {
		FOR(i, 1, n) {
			if(i % k == k / 2) {
				cnt++;
			}
		}
	}

	out<ll>(cnt * cnt * cnt + (ll)pow(n / k, 3));

	return;
}

int main() {

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

	solve();

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define n_l '\n'
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; cout << to_string(__VA_ARGS__) << endl
template <typename T, size_t N> int SIZE(const T (&t)[N]){ return N; } template<typename T> int SIZE(const T &t){ return t.size(); } string to_string(const string s, int x1=0, int x2=1e9){ return '"' + ((x1 < s.size()) ? s.substr(x1, x2-x1+1) : "") + '"'; } string to_string(const char* s) { return to_string((string) s); } string to_string(const bool b) { return (b ? "true" : "false"); } string to_string(const char c){ return string({c}); } template<size_t N> string to_string(const bitset<N> &b, int x1=0, int x2=1e9){ string t = ""; for(int __iii__ = min(x1,SIZE(b)),  __jjj__ = min(x2, SIZE(b)-1); __iii__ <= __jjj__; ++__iii__){ t += b[__iii__] + '0'; } return '"' + t + '"'; } template <typename A, typename... C> string to_string(const A (&v), int x1=0, int x2=1e9, C... coords); int l_v_l_v_l = 0, t_a_b_s = 0; template <typename A, typename B> string to_string(const pair<A, B> &p) { l_v_l_v_l++; string res = "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; l_v_l_v_l--; return res; } template <typename A, typename... C> string to_string(const A (&v), int x1, int x2, C... coords) { int rnk = rank<A>::value; string tab(t_a_b_s, ' '); string res = ""; bool first = true; if(l_v_l_v_l == 0) res += n_l; res += tab + "["; x1 = min(x1, SIZE(v)), x2 = min(x2, SIZE(v)); auto l = begin(v); advance(l, x1); auto r = l; advance(r, (x2-x1) + (x2 < SIZE(v))); for (auto e = l; e != r; e = next(e)) { if (!first) { res += ", "; } first = false; l_v_l_v_l++; if(e != l){ if(rnk > 1) { res += n_l; t_a_b_s = l_v_l_v_l; }; } else{ t_a_b_s = 0; } res += to_string(*e, coords...); l_v_l_v_l--; } res += "]"; if(l_v_l_v_l == 0) res += n_l; return res; } void dbgm(){;} template<typename Heads, typename... Tails> void dbgm(Heads H, Tails... T){ cout << to_string(H) << " | "; dbgm(T...); } 
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgm(__VA_ARGS__); cout << endl

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef double db;
typedef vector<vi> vvi;
const ll mod=1000000007;
const ll N=200005; //check this
const db PI= 3.14159265359;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll powb(ll a,ll b) {ll res=1;a ; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int k;
    string s;
    cin>>k>>s;
    if(s.size()<=k)cout<<s;
    else {
        for(int i=0;i<k;i++)cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <set>
#include <string>
using namespace std;
typedef long long ll;
      
int main(void){
    int n;
    string str[200000];
    set<string> strset;
    
    cin >> n;
    cin.ignore();
    int count = 0;
    
    for (int i=0; i<n; i++){
        //cin >> str[i];
        getline(cin, str[i]);
        count ++;

        decltype(strset)::iterator it = strset.find(str[i]);
        if(it != strset.end()){
                count--;
                //break;
        }

        strset.insert(str[i]);
        //cout << str[i] << " " << count << " " << i << endl;
        
        /*
        for (int j=i-1; j>=0; j--){
            
            //if(str[i] == str[j]) {
            //if(equal(str[i].begin(), str[i].end(), str[j].begin(), str[j].end())){
            //if(equal(str[i].begin(), str[i].end(), str[j].begin())){    
            //cout << j << " " << str[i] << " " << str[j] << endl;
            if(it != strset.end()){
                count--;
                break;
            }
        }
        */
    }
 
 
    cout << count;
    return 0;
}

Measured memory_bytes: 25432
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k;
  int denko=1;
  cin >> n >> k;
  for(int i=0;i<n;i++){
    if(denko*2>denko+k)denko+=k;
    else denko*=2;
  }
  cout << denko << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		if (x * 2 <= y && y <= x * 4 && y % 2 == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

#define rep(i, n) for(int i=0; i<n; i++)
#define mp make_pair
#define pb push_back
typedef pair<int, int> pii;

const int INF = 1E9;
const int MAX_N = 111;
int n, w, d;
int p[MAX_N];
int s[MAX_N];


inline bool comp(const pair<pii, int>& x, const pair<pii, int>& y)
{
  return x.second != y.second ? x.second < y.second : x.first.first * x.first.second < y.first.first * y.first.second;
}


int main()
{
  while(cin >> n >> w >> d, w){
    rep(i, n) cin >> p[i] >> s[i];

    vector<pair<pii, int> > vec;
    vec.pb(mp(mp(w, d), 0));
    rep(i, n){
      pii t = vec[p[i] - 1].first;
      int num = vec[p[i] - 1].second;
      vec.erase(vec.begin() + p[i] - 1);
      s[i] %= 2 * (t.first + t.second);

      if(0 <= s[i] && s[i] < t.first){
        vec.pb(mp(mp(s[i], t.second), INF));
        vec.pb(mp(mp(t.first - s[i], t.second), INF));
      }
      else if(t.first <= s[i] && s[i] < t.first + t.second){
        vec.pb(mp(mp(t.first, s[i] - t.first), INF));
        vec.pb(mp(mp(t.first, t.first + t.second - s[i]), INF));
      }
      else if(t.first + t.second <= s[i] && s[i] < 2 * t.first + t.second){
        vec.pb(mp(mp(s[i] - t.first - t.second, t.second), INF));
        vec.pb(mp(mp(2 * t.first + t.second - s[i], t.second), INF));
      }
      else{
        vec.pb(mp(mp(t.first, s[i] - 2 * t.first - t.second), INF));
        vec.pb(mp(mp(t.first, 2 * (t.first + t.second) - s[i]), INF));
      }

      if(i >= n-1) rep(j, vec.size()) vec[j].second = INF;
      sort(vec.begin(), vec.end(), comp);

      rep(j, vec.size()) vec[j].second = j;
    }

    rep(i, vec.size()-1) cout << vec[i].first.first * vec[i].first.second << ' ';
    cout << vec[vec.size()-1].first.first * vec[vec.size()-1].first.second << endl;
  }

  return 0;
}

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

using namespace std;
using ll = long long;
constexpr ll mod = 1e9+7;
constexpr ll md = mod;
constexpr ll inf = 1e15;
int main(){
    ll n,t;
    cin>>n>>t;
    vector<ll> v(n);
    for(auto &a :v)cin>>a;
    vector<ll> tmp;
    ll cur = v[0];
    for(int i=1;i<n;++i){
        if(cur <= v[i])tmp.emplace_back(v[i] - cur);
        else{
            cur = v[i];
        }
    }
    sort(tmp.rbegin(),tmp.rend());
    ll num = 0;
    for(int i=0;i<(int)tmp.size();++i){
        if(tmp[i] == tmp[0])num++;
    }
    cout << num << endl;
    return 0;
}



Measured memory_bytes: 2168
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, Y;
    cin >> X >> Y;
    cout << X + Y/2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char board[101][101];
int check[100][100];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int h, w;

void dfs(int x, int y);

int main(void)
{
    int i, j, ans;
    scanf("%d %d", &h, &w);
    while (h) {
        for (i = 0; i < h; i++) {
            scanf("%s", board[i]);
            for (j = 0; j < w; j++) {
                check[i][j] = 0;
            }
        }
        ans = 0;
        for (i = 0; i < h; i++) {
            for (j = 0; j < w; j++) {
                if (!check[i][j]) {
                    dfs(i, j);
                    ans++;
                }
            }
        }
        printf("%d\n",ans);
        scanf("%d %d", &h, &w);
    }
}

void dfs(int x, int y)
{
    int i;
    for (i = 0; i < 4; i++) {
        if (board[x][y] == board[x+dx[i]][y+dy[i]]
                && !check[x+dx[i]][y+dy[i]] 
                && 0 <= x+dx[i] && x+dx[i] < h
                && 0 <= y+dy[i] && y+dy[i] < w) {
            check[x+dx[i]][y+dy[i]] = 1;
            dfs(x+dx[i], y+dy[i]);
        }
    }
}

Measured memory_bytes: 1120
S = input()
memo = [[0,0,0,0] for i in range(len(S))]
Q = 0
memo[0][0] = 1
if S[0] == 'A':
  memo[0][1] = 1
elif S[0] == '?':
  memo[0][0] = 3
  memo[0][1] = 1
l = 1
while l < len(S):
  s = S[l]
  if s == 'A':
    memo[l][0] = memo[l-1][0]
    memo[l][1] = memo[l-1][1] + memo[l-1][0]
    memo[l][2] = memo[l-1][2]
    memo[l][3] = memo[l-1][3]
  elif s == 'B':
    memo[l][0] = memo[l-1][0]
    memo[l][1] = memo[l-1][1]
    memo[l][2] = memo[l-1][2] + memo[l-1][1]
    memo[l][3] = memo[l-1][3]
  elif s == 'C':
    memo[l][0] = memo[l-1][0]
    memo[l][1] = memo[l-1][1]
    memo[l][2] = memo[l-1][2]
    memo[l][3] = memo[l-1][3] + memo[l-1][2]
  else:
    memo[l][0] = memo[l-1][0]*3
    memo[l][1] = memo[l-1][1]*3 + memo[l-1][0]
    memo[l][2] = memo[l-1][2]*3 + memo[l-1][1]
    memo[l][3] = memo[l-1][3]*3 + memo[l-1][2]
    Q += 1
  memo[l] = [i%(10**9+7) for i in memo[l]]
  l += 1
print(int(memo[l-1][3]))

Measured memory_bytes: 27608
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def calc(n):
    s = sum(map(int, str(n)))
    return n / s

def f(n):
    ld = list(map(int, str(n)))
    cand = []
    for i in range(len(ld)-1):
        d = len(ld)-1-i
        ld[d] = 9
        for i in range(1, 10):
            if i < ld[d-1]:
                continue
            ld[d-1] = i
            p = int("".join(map(str, ld)))
            cand.append((calc(p), p))
    cand.sort()
    return cand[0][1]

MAX = 10**15
def main():
    k = ri()
    cand = list(range(1, 10))
    n = 10
    while True:
        if n > MAX:
            break
        p = f(n)
        cand.append(p)
        n = p+1
    print("\n".join(map(str, cand[:k])))


if __name__ == '__main__':
    main()


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

 int main(){

    ll n,moto,ans=0;
    cin>>n>>moto;
    ll arr[n];
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
     for(int i=0;i<n;i++){
     	if(moto>0){
       moto-=arr[i];
       ans++;
   }
    }
   ll addi=0;
    for(int i=0;i<n;i++){
    	if(moto>0){
         addi=max(addi,moto/arr[i]);
    	}
    }
    cout<<ans+addi<<"\n";



 	return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  ll ans = 0;
  for (ll i = 0; i < 3; i++)
  {
    if (S.at(i) == T.at(i))
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define set set <ll>
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;
int main()
{
  fast();
  
  ll a, b;
  cin >> a >> b;
  ll gcd = __gcd(a, b);
  ll itr = gcd;
  ll ans = 1;
  
  f(ptr, 2, sqrt(itr) + 2)
  {
  	
  	if(gcd % ptr == 0)
  	{
  		ans++;
  	}
  	while(gcd % ptr == 0)
  	{
  		//cout << endl << gcd << " " << ptr;
  		gcd /= ptr;
  	}
  }
  if(gcd != 1)
  {
  	cout << ans + 1;
  	return 0;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let a = get_one!(isize);

    println!("{}", a + a * a + a * a * a);
}


Measured memory_bytes: 2120
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	int p[a], q[b], r[c];

	zip(i, 0, a) cin >> p[i];
	zip(i, 0, b) cin >> q[i];
	zip(i, 0, c) cin >> r[i];

	sort(p, p + a, greater<int>());
	sort(q, q + b, greater<int>());
	sort(r, r + c, greater<int>());

	vi v;
	zip(i, 0, x)
	v.pb(p[i]);
	zip(i, 0, y)
	v.pb(q[i]);
	zip(i, 0, c)
	v.pb(r[i]);

	sort(all(v), greater<int>());

	int ans = 0;
	zip(i, 0, x + y)
	{
		ans += v[i];
	}
	cout << ans << en;



	return 0;
}



Measured memory_bytes: 9760
import java.util.*;

public class Main{
	public static void main(String args[]){
      Scanner scan = new Scanner(System.in);
      String string = scan.next();
      char[] ch = new char[4];
      for(int i=0;i<4;i++){
        ch[i] = string.charAt(i);
      }
      if(ch[0]==ch[3] && ch[1]==ch[2] && ch[0]!=ch[1]){
        System.out.println("Yes");
      }else if(ch[0]==ch[1] && ch[2]==ch[3] && ch[0]!=ch[2]){
        System.out.println("Yes");
      }else if(ch[0]==ch[2] && ch[1]==ch[3] && ch[0]!=ch[1]){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
      
	}
}

Measured memory_bytes: 23764
h, w = gets.split.map(&:to_i)
board = []
h.times { board << gets.split.map(&:to_i) }
ans = []
h.times do |r|
  (w - 1).times do |c|
    if board[r][c].odd?
      board[r][c + 1] += 1
      ans << [r + 1, c + 1, r + 1, c + 2]
    end
  end
end
(h - 1).times do |r|
  if board[r][w - 1].odd?
    board[r + 1][w - 1] += 1
    ans << [r + 1, w, r + 2, w]
  end
end
puts ans.size
ans.each { |a| puts a.join(" ") }


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

const long long INFF = 1e18;

const int MAX_N = 11000;
using TYPE = long long; // ?????¢???????????\??????
vector<pair<int, TYPE> > G[MAX_N];

vector<TYPE> dijkstra(int start){
	vector<TYPE> dist(MAX_N, INFF);
	dist[start] = 0;//dist[i] :=???start->i?????§??????????????¢
	priority_queue<pair<TYPE, int>, vector<pair<TYPE, int> >, greater<pair<TYPE, int> > >  que;
	que.push(make_pair(0, start));
	while(!que.empty()){
		TYPE cost; int u;//????????§???????????£????????? ?????¨?????????
		cost = que.top().first, u = que.top().second;
		que.pop();
		if(dist[u] < cost) continue;
		dist[u] = cost;
		for (auto tmp : G[u]){
			int v = tmp.first; TYPE time = tmp.second;//??£??\???????????? ?????????????????§????????????
			if(dist[v] > dist[u] + time){//u->v
				// if(dist[v] != INFF) printf("%f %fa\n", dist[v], dist[u] + time);
				// dist[v] = dist[u] + time;
				que.push(make_pair(dist[u] + time, v));
			}
		}
	}
	return dist;
}


int main(void) {
	int n; cin >> n;
	rep(q, n) {
		int u, k; cin >> u >> k;
		vector<int> v(k); vector<long long> c(k);
		rep(i, k) cin >> v[i] >> c[i];
		rep(i, k) G[u].push_back(make_pair(v[i], c[i]));
	}
	auto dist = dijkstra(0);
	rep(i, n) printf("%d %d\n", i, dist[i]);
	return 0;
}

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

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

int N;
vint G[1111];
string S[1111];
int dep[1111];
void dfs(int v,int p,int d){
    dep[v]=d;
    rep(i,dep[v])cout<<".";
    cout<<S[v]<<endl;
    for(int to:G[v]){
        if(to==p)continue;
        dfs(to,v,d+1);
    }
}
signed main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>N;
    rep(i,N){
        int p;cin>>p;p--;
        if(p>=0)G[p].pb(i);
        cin>>S[i];
    }

    dfs(0,-1,0);
    return 0;
}

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

#ifdef LOCAL
#include "../debug.h"
#else
#define debug(x...) 141
#endif
#define forn(i,x,n) for(int i = x; i < n; ++i)
#define forit(it, m) for(auto it = m.begin(); it!=m.end(); ++it)
typedef long long ll;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,m,k,count,ans=0;

    cin>>n>>m>>k;
    vector<string> a(n);
    forn(i,0,n)
    	cin>>a[i];
    forn(i,0,1<<n)
    	forn(j,0,1<<m){
    		count=0;
    		forn(r,0,n)
    			forn(c,0,m)
    				if(!(i&(1<<r) || j&(1<<c)))
    					count+=a[r][c]=='#';
    		ans+=count==k;
    		if(count==k)
    			debug(i,j);
    	}
    cout<<ans<<'\n';
    
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
/*
どうしたら漏れないんだろう
r
  r     
          b
   b
  r
   b
bの最小xをみて、最小yを使って、最大rをとっていくとか
全部違うならmapがいいかな
100までだからかなり探索は可能
*/
int main(){
  ll N; cin>>N;
  map<pair<ll,ll>,bool> M;
  vector<pair<ll,ll>> R(N, make_pair(0,0)), B(N, make_pair(0,0));
  for(int i=0; i<N; i++){
    ll a,b; cin>>a>>b;
    R[i].first=a;
    R[i].second=b;
    M[make_pair(a,b)]=false;
  }
  for(int i=0; i<N; i++){
    ll c,d; cin>>c>>d;
    B[i].first=c;
    B[i].second=d;
    M[make_pair(c,d)]=false;
  }
  //赤は、y座標が大きいのから、青はx座標が小さいのから、探索
  sort(R.begin(), R.end(), [](auto& x, auto& y){return x.first > y.first;});
  sort(R.begin(), R.end(), [](auto& x, auto& y){return x.second > y.second;});
  sort(B.begin(), B.end(), [](auto& x, auto& y){return x.second < y.second;});
  sort(B.begin(), B.end(), [](auto& x, auto& y){return x.first < y.first;});
  ll ans=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(R[j].first >= B[i].first) continue;
      if(R[j].second >= B[i].second) continue;
      if(M[R[j]] || M[B[i]]) continue;
      M[R[j]]=true;
      M[B[i]]=true;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
H,W=map(int,input().split())
N=int(input())
A = list(map(int,input().split()))
G = [[0 for _ in range(W)] for _ in range(H)]
h,w=0,0
flag=0
for j,a in enumerate(A):
  for i in range(a):

    
    if w==W:
      h+=1;w-=1
      flag=1
    if w==-1:
      h+=1;w+=1
      flag=0

    if flag==0: 
      G[h][w]=j+1
      w+=1
    else:
      G[h][w]=j+1
      w-=1
      
for g in G:
  print(*g)


Measured memory_bytes: 3884
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        x: i64, y: i64
    }
    for t in 0..=x {
        let k = x - t;
        if 2*t + 4*k == y {
            println!("Yes");
            return;
        }
    }
    println!("No");

}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; 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;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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(){
    int n;
    cin >> n;
    VI a(n);
    rep(i,n) cin >> a[i];
    VI b = a;
    sort(all(b));
    rep(i,n){
        if (a[i] == b[n-1]) cout << b[n-2] << endl;
        else cout << b[n-1] << endl;
    }
    return 0;
}

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
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 ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

signed main() {
    IOS;

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = -LLINF;
    chmax(ans, a * c);
    chmax(ans, a * d);
    chmax(ans, b * c);
    chmax(ans, b * d);
    print(ans);

    return 0;
}


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

int main()
{
  int n,a,b,c,d;cin>>n>>a>>b>>c>>d;
  string s;cin>>s;
  a--;b--;c--;d--;
  int i;
  bool ok=true;
  for(i=a;i<c;i++)
  {
    if(s.at(i)=='#'&&s.at(i+1)=='#')ok=false;
  }
  for(i=b;i<d;i++)
  {
    if(s.at(i)=='#'&&s.at(i+1)=='#')ok=false;
  }
  if(c>d)
  {
    bool cok=false;
    for(i=b-1;i<d;i++)
    {
      if(s.at(i)=='.'&&s.at(i+1)=='.'&&s.at(i+2)=='.')
      {
        cok=true;
      }
    }
    if(!cok)ok=false;
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>
 
int main (void)
{
 int N,a,b;
 
scanf("%d",&N);
scanf("%d",&a);
scanf("%d",&b);
 
printf("%d",(a<b?a:b));
 
if(N>(a+b))
printf("  0");
else
printf("  %d",(a+b)-N);
 
return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
	   sc = new Scanner(System.in);
	 
	   while(true){
	   int h=sc.nextInt();
	   int w=sc.nextInt();
	   if(h==0&&w==0)break;
	   else for(int i = 0;i<h;i++){
		   int m=0;   
		   while(m<w){
			   System.out.print("#");
			   m=m+1;
		   }
		   
	         System.out.println();
   }
	   System.out.println();
  }  
 }
}

Measured memory_bytes: 26876
function main(input) {
    var N = input[0].split(" ")[0]-0;
    var a = input[0].split(" ")[1]-0;
    var b = input[0].split(" ")[2]-0;
  var ans = 0;
  for(var i=1;i<=N;i++){
    var sum = i.toString().split("").reduce((a,b)=>(a-0)+(b-0));
    if(a<=sum && b>=sum) ans += i;
  }
  console.log(ans);
    
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"))

Measured memory_bytes: 22672
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll A,B,K;
	scan(A>>B>>K);
	if(A>=K){
		printf("%lld %lld\n",A-K,B);
	}
	else{
		printf("0 %lld\n",max(0LL,B-(K-A)));
	}
	return 0;
}


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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S, T;
	int N;
	bool ans = true;

	cin >> S >> T;
	N = S.length();

	rep(i, N) {
		if (S[i] != T[i]) ans = false;
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>

using Int = long long;


int main() {

	Int A, B, C;
	std::cin >> A >> B >> C;

	Int sum_before = A + B + C;
	Int max = std::max({ A,B,C });

	if ((3 * max - sum_before) % 2 == 0)std::cout << (3 * max - sum_before) / 2 << std::endl;
	else std::cout << (3 * (max+1) - sum_before) / 2 << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal <int>, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
using ll = long long;
using ld = long double;
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define forn(i,a,b) for (ll i =a; i <=b; ++i)
void debug()
{
    cerr << "\n";
}
template<typename Head, typename... Tail>
void debug(Head H, Tail... T)
{
    cerr << H << " ";
    debug(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"] : ";debug(__VA_ARGS__);
const ll maxn = 1e6 + 10;
void solve()
{
    ll a,b;
    cin>>a>>b;
    cout<<a*b;
}
int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll t;
    // cin >> t;
    t=1;
    rep(i, t)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    val N = readLineInts
    if(Seq(1, 7, 9, 4).map(n => N.count(_ == n) == 1).forall(identity)) {
      println("YES")
    } else {
      println("NO")
    }
  }
}


Measured memory_bytes: 27340
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >> n;
    int k;
    cin >> k;
    int ans = 0;
    rep(i,n){
        int x;
        cin >> x;
        ans += min(x, abs(k - x)) * 2;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}

/*int dsu[100001], ranks[100001], arr[100001];

int find(int node){
    if(dsu[node] == node)
        return node;
    return dsu[node] = find(dsu[node]);
}

void combine(int a, int b){
    a = find(a); b = find(b);
    if(a == b) return;
    if(ranks[a] < ranks[b]){ dsu[a] = b; }
    else if(ranks[b] < ranks[a]){ dsu[b] = a; } else { dsu[a] = b; ranks[b]++;}
}*/

int main(){

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

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

    string s;
    cin >> s;

    vector<int> arr;
    arr.push_back(-1);

    for(auto i : s){
        //for(auto j : arr)
        //    cout << j << " ";
        //cout << endl;
        if(i == 'T'){
            if(arr.back() == 0){
                arr.pop_back();
            }else{
                arr.push_back(1);
            }
        } else {
            arr.push_back(0);
        }
    }

    cout << arr.size() - 1;

    return 0;
}


Measured memory_bytes: 1680
n = int(input())

s = len(str(n))

if s == 1:
    print(n)
elif s == 2:
    print(9)
elif s == 3:
    print(n-90)
elif s == 4:
    print(9+900)
elif s == 5:
    print(9+900+n-10000+1)
else:
    print(90909)


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

int n, a, m = 0;
set<int> nums;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        nums.insert(a);
        if (a == *(nums.begin()))
        {
            m++;
        }
    }

    cout << m;
}

Measured memory_bytes: 9600