akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n;
ll K,a[200100],b[200100];
ll g(ll x,ll aa,ll bb)
{
    ll y=0;
    ll st=0,en=1e12;
    while(st<=en)
    {
        ll m=(st+en)/2;
        if((aa-m)*bb<=x)
        {
            y=m;
            en=m-1;
        }
        else
            st=m+1;
    }
    return y;
}
bool OK(ll x)
{
    ll k=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]*b[i]<=x) continue;
        if(k>K)
            return 0;
        ll y=g(x,a[i],b[i]);
        k+=y;
        if(k>K)
            return 0;
    }
    return k<=K;
}
int main()
{
    go;
    cin>>n>>K;
    for(int i=0;i<n;i++)
        cin>>a[i];
    for(int i=0;i<n;i++)
        cin>>b[i];
    sort(a,a+n);
    sort(b,b+n);
    reverse(b,b+n);
    ll st=0,en=1e12,ans=-1;
    while(st<=en)
    {
        ll mid=(st+en)/2;
        if(OK(mid))
        {
            ans=mid;
            en=mid-1;
        }
        else
            st=mid+1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){

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

    int l = 0, m = 0;
    while(a>=b){
        b *= 2;
        l++;
    }
    while(b>=c){
        c *= 2;
        m++;
    }

    if(l+m<=k) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

ll times(ll i, ll k) {
  ll res = i;
  ll now = 0;
  for (;;) {
    if (res >= k) {
      return now;
    }
    now++;
    res *= 2;
  }
}

int main() {
  init();

  ll N, K;
  cin >> N >> K;

  double ans = 0;
  REP(i, 1, N + 1) {
    ll n = times(i, K);
    ans += (1.0 / N) * pow(0.5, n);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
'use strict';
function main(arg) {
    // 処理
    arg = arg.split("\n")
    arg = arg[0]
  	if (arg[0] !== "A") {
        console.log('WA')
        return
    }


    var numC = 0
    for(var i = 1; i < arg.length; i++){
        if(i >= 2 && i <= arg.length - 2 && arg[i] == "C"){
            numC++;
            if(numC > 1){
                console.log("WA");
                return 0;
            }
        }else if(arg[i].search(/[a-z]/) == -1){
            console.log("WA");
            return 0;
        }
    }
  	if(numC != 1){
        console.log("WA")
    } else {
        console.log('AC')
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
from numpy import cumsum
n = int(input())
s = input()
def conv(i):
    if i == 'E': return 1
    return 0
s2 = [conv(i) for i in s]
cum = cumsum(s2)
ans = n - 1
b = cum[-1]
for i in range(n):
    a = cum[i]
    s1 = b - a
    s3 = (i+1) - cum[i]
    if s2[i] == 0:
        s3 -= 1
    ans = min(ans, s1+s3)
print(ans)

Measured memory_bytes: 21668
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
 
typedef unsigned long long ULLONG;
typedef long long LLONG;
 
template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}
 
	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}
 
	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}
 
	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;
template <class _T> static _T tp_pow(int base, int exp)
{
	_T ans = 1;
 
	for (int i = 0; i < exp; i++) {
		ans *= base;
	}
	return ans;
}
 
static void C_task();
 
int main()
{
	C_task();
	fflush(stdout);
	return 0;
}
 
static void C_task()
{
	LLONG A;
	std::cin >> A;
	long double B;
	std::cin >> B;
 	B *= (long double)(1000.0);
	long double ans = A * B;
	ans /= (long double)(1000.0);
	printf("%lld\n", (LLONG)ans);
}

Measured memory_bytes: 3784
D=list(map(int,input().split()))

#print(D)
s=input()
for i in range(len(s)):
    if s[i]=="E":
        E=[D[3],D[1],D[0],D[5],D[4],D[2]]
        D=E
    elif s[i]=="W":
        W=[D[2],D[1],D[5],D[0],D[4],D[3]]
        D=W
    elif s[i]=="S":
        S=[D[4],D[0],D[2],D[3],D[5],D[1]]
        D=S
    elif s[i]=="N":
        N=[D[1],D[5],D[2],D[3],D[0],D[4]]
        D=N
print(D[0])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int MAXN = 20001, base = 20009;
inline int read() {
  char c = getchar();
  int x = 0, f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return x * f;
}
int N, a[MAXN], b[MAXN];
int main() {
  N = read();
  for (int i = 1; i <= N; i++) a[i] = base * i;
  for (int i = 1; i <= N; i++) b[i] = base * (N - i + 1);
  for (int i = 1; i <= N; i++) {
    int x = read();
    a[x] -= (N - i + 1);
  }
  for (int i = 1; i <= N; i++) printf("%d ", a[i]);
  puts("");
  for (int i = 1; i <= N; i++) printf("%d ", b[i]);
  return 0;
}


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

int main() {
    
    int n;
    cin >> n;
    int arr[n];
    for(int i=0;i<n;i++)
    cin >> arr[i];
    
    double sum=0.0;
    
    for(int i=0;i<n;i++) {
        sum+=(1.0/arr[i]);
    }
    
    cout << 1.0/sum;
    
    
    return 0;
}

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

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

typedef long long ll;

int main() {
    long long a, b;
    cin >> a >> b;
    if (a == b) {
        cout << 1 << endl;
        return 0;
    }
    long long p = 1;
    int len = 0;
    forn (i, 61) {
        if ((a & p) != (b & p)) {
            len = i;
        }
        p *= 2;
    }
    a &= (1ll << len) - 1;
    b &= (1ll << len) - 1;
    long long ans = (1ll << len) - a;
//    cerr << a  << " " << b << endl << ans << endl;
    p = 1;
    int len_b = 0;
    forn (i, 61) {
        if (b & p) {
            len_b = i + 1;
        }
        p *= 2;
    }
    long long l = (1ll << len_b) - 1;
    long long r = a;
//    cerr << l << " " << r << endl;
    if (l >= r) {
        ans += 1ll << len;
    } else {
        ans += l + 1 + (1ll << len) - r;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define N 1 << 16 | 3
const int mod = 1000000007;
int n, m, s[20];
long long fac[N], inv[N];
long long f[17][N], ans, U;
void update(long long &x, long long y) {if ((x += y) >= mod) x -= mod;}
long long C(long long a, long long b) {
	if (a < b) return 0;
	return fac[a] * inv[b] % mod * inv[a - b] % mod;
}
int main () {
	scanf("%d%d", &n, &m); U = 1 << n;
	for (int i = 1; i <= m; i++) scanf("%d", s + m - i);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i < U; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = inv[mod % i] * (mod - mod / i) % mod;
	}
	for (int i = 2; i < U; i++) inv[i] = inv[i - 1] * inv[i] % mod; 
	f[0][0] = 1;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < U; j++) {
			update(f[i + 1][j], f[i][j]);
			for (int k = 0; k < n; k++) {
				if (!(j & (1 << k))) update(f[i + 1][j | 1 << k], f[i][j] * fac[1 << k] % mod * C(U - j - s[i], (1 << k) - 1) % mod);
			}
		}
	}
	for (int i = 0; i < U; i++) {
		long long tmp = f[m][i] * fac[U - i - 1] % mod;
		update(ans, __builtin_parity(i) ? (mod - tmp) : tmp);
	}
	printf("%lld\n", ans * U % mod);
	return 0;
}

Measured memory_bytes: 9344
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
    int N;
    int K;

    if (scanf("%d %d", &N, &K) < 2) return 0;

    printf("%d\n", K * (int)pow(K - 1, N - 1));
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
bool t[3][500][500];
int n,h,x,y;
string s;
int main(){
	while(cin>>n>>h&&n+h){
	int c,a=0;
	r(i,3)r(j,n)r(k,n)t[i][j][k]=0;
	r(u,h){
		cin>>s>>x>>y;x--,y--;
		if(s=="xy"){
			t[0][x][y]=1;
			r(i,n){
				c=0;
				if(t[1][x][i])c++;
				if(t[2][y][i])c++;
				if(c==2)c--;
				a+=c;
			}
		}
		if(s=="xz"){
			t[1][x][y]=1;
			r(i,n){
				c=0;
				if(t[0][x][i])c++;
				if(t[2][i][y])c++;
				if(c==2)c--;
				a+=c;
			}
		}
		if(s=="yz"){
			t[2][x][y]=1;
			r(i,n){
				c=0;
				if(t[0][i][x])c++;
				if(t[1][i][y])c++;
				if(c==2)c--;
				a+=c;
			}
		}
	}
	cout<<n*(n*n-h)+a<<endl;
	}
	return 0;
}

Measured memory_bytes: 3852
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
lint lcm(lint a,lint b){
      return a/__gcd(a,b)*b;
  }
  int main(){
     lint N,K;
     cin>>N>>K;
     lint A[N];
     rep(i,N){
         cin>>A[i];
     }
     lint gc;
     rep(i,N-1){
            gc=__gcd(A[i],A[i+1]);
     }
     rep(i,N){
         lint h=A[i]-K;
         if(h==0){
             cout<<"POSSIBLE";
             return 0;
         }
         if(h>0&&h%gc==0){
             cout<<"POSSIBLE";
             return 0;
         }
     }
     cout<<"IMPOSSIBLE";
  }
  

Measured memory_bytes: 1024
from collections import defaultdict

def main():
    N = int(input())

    dd = defaultdict(int)

    for _ in range(N):
        si = input()
        dd[si] += 1

    maxv = max(dd.items(), key = lambda item: item[1])[-1]
    strings = [key for key, val in dd.items() if val == maxv]

    strings = sorted(strings)

    for string in strings:
        print(string)

if __name__ == '__main__':
    main()


Measured memory_bytes: 35912
//header{{{
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/math/common_factor_rt.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
  
using namespace std;
//using namespace boost;
//using namespace multiprecision;  

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9+7; 
constexpr int mod2 = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
inline int square(int a){ return a * a;}
inline int updiv(int a,int b){ return (a + b - 1) / b; }

template <class A, class B> inline int Max(const A &a, const B &b){ return (a < b ? b : a); }
template <class A, class B> inline int Min(const A &a, const B &b){ return (a > b ? b : a); }

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


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

    vector<int> a(5);
    rep(i,5){
        cin >> a[i];
        if(a[i] == 0){
            cout << i + 1 << '\n';
            return 0;
        }
    }

    return (0);
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int N, M;
string A[55], B[55];

bool check(int th, int tw)
{
    if (N - th + 1 < M || N - tw + 1 < M)
        return false;
    REP(h, M)
    {
        REP(w, M)
        {
            if (A[th + h][tw + w] != B[h][w])
                return false;
        }
    }
    return true;
}

int main()
{
    cin >> N >> M;
    REP(i, N)
    {
        cin >> A[i];
    }
    REP(i, M)
    {
        cin >> B[i];
    }

    string ans = "No";
    REP(h, N)
    {
        REP(w, N)
        {
            if (check(h, w))
            {
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PB push_back
#define M 1000000007
int n;
ll dp[1005];
vector<int>g[1005];
bool o[1005];
int t[1005];
void dfs(int v,int p){
    vector<ll>x;
    for(int i=0;i<g[v].size();i++){
        int u=g[v][i];
        if(u==p)continue;
        dfs(u,v);
        x.PB(dp[u]);
    }
    if(t[v]==0){
        dp[v]=1;
        for(int i=0;i<x.size();i++)dp[v]=dp[v]*x[i]%M;
    }else if(t[v]==1){
        for(int i=0;i<x.size();i++)dp[v]=(dp[v]+x[i])%M;
    }else{
        int w=x.size();
        for(int i=1;i<1<<w;i++){
            ll e=1;
            for(int j=0;j<w;j++)if(i>>j&1)e=e*x[j]%M;
            dp[v]=(dp[v]+e)%M;
        }
    }
    if(o[v])dp[v]=(dp[v]+1)%M;
}
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        char s[5];
        scanf(" %s",s);
        if(s[0]=='A')t[i]=1;
        if(s[0]=='R')t[i]=2;
        if(s[1]=='?')o[i]=true;
    }
    for(int i=0;i<n-1;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        g[--a].PB(--b);
        g[b].PB(a);
    }
    dfs(0,-1);
    printf("%lld\n",dp[0]);
}



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

struct vec{
    int x,y;
    vec () {}
    vec(int x,int y):x(x),y(y) {}
    vec operator-(const vec &rhs)const {
        return vec(x-rhs.x,y-rhs.y);
    }
    int cross(const vec &rhs)const {
        return x*rhs.y-y*rhs.x;
    }
    bool operator<(const vec &rhs)const {
        return x==rhs.x ? y<rhs. y : x<rhs.x;
    }
}arr[200];
int n;

int ccw(vec a,vec b){
    int v=a.cross(b);
    if(v>0) return 1;
    else if(v==0) return 0;
    else return -1;
}
int ccw(vec p,vec a,vec b) {
    return ccw(a-p,b-p);
}

const int MOD=998244353;
int power(int a,int p) {
    int ret=1;
    while(p) {
        if(p&1) ret=1ll*ret*a%MOD;
        a=1ll*a*a%MOD;
        p>>=1;
    }
    return ret;
}
int main() {
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d%d",&arr[i].x,&arr[i].y);

    int ans=(power(2,n)-n-1+MOD)%MOD;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++) if(i!=j && arr[i]<arr[j]) {
        int cnt=2;
        for(int k=0;k<n;k++) if(i!=k && j!=k && ccw(arr[i],arr[j],arr[k])==0) {
            if(arr[k] < arr[i] || arr[k] < arr[j]) {
                cnt=0;
                break;
            }
            cnt++;
        }
        ans = (ans - (power(2,cnt)-cnt-1) + MOD)%MOD;
    }
    printf("%d\n",ans);
    
    return 0;
}


Measured memory_bytes: 256
def resolve():
    cnt = 0
    ans ='No'
    for i in range(int(input())):
        a,b = map(int,input().split())
        if a == b :
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
            break
    print(ans)
resolve()

Measured memory_bytes: 9172
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,j,k;
  char s[260],c[260];
  scanf("%d",&n);
  fgets(s,260,stdin);
  while(n--){
    fgets(s,260,stdin);
    for(i=1;1;i+=2){
      if(i%13==0)continue;//printf("%d\n",i);
      for(j=0;j<26;j++){
	for(k=0;s[k];k++){
	  if('a'<=s[k]&&s[k]<='z')c[k]=((s[k]-'a')*i+j)%26+'a';
	  else c[k]=s[k];
	}
	c[k]=0;
	if(strstr(c,"that")||strstr(c,"this"))break;
      }
      if(j-26)break;
    }
    printf("%s",c);
  }
  return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 1000000007
#define INF 10000000000
#define MAX 500008

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

  int left=0;
  int right=1000000000;
  while(left+1<right){
    int x=(left+right)/2;
    ll count=0;
    for(int i=0;i<N;i++){
      count+=(ll)((A[i]-1)/x);
    }
    if(count<=K){
      right=x;
    }else{
      left=x;
    }
  }
  cout<<right<<endl;
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
int dp[2][76866],dg[76866],bit[76866],pos[1<<20],n,cnt=0,dgtmp=0,tmp=1;
int main(){
	for(int i=0;i<(1<<20);i++){
		int f=0;
		for(int j=0,b1=1,b2=2;j<20;j++,b1<<=1,b2<<=1)if((i&b1)&&(i&b2))f++;
		if(f<2){
			pos[i]=cnt;
			if(i==tmp){
				dgtmp++;
				tmp<<=1;
			}
			dg[cnt]=dgtmp;
			bit[cnt]=i;
			cnt++;
		}
	}
	cin>>n;
	for(int cs=1;cs<=n;cs++){
		int ans=0;
		int w,h;cin>>w>>h;
		int p=(1<<(w-1)),v[400];
		for(int i=0;i<w*h;i++)cin>>v[i];
		for(int i=0;i<76866;i++)dp[0][i]=dp[1][i]=-1;
		dp[0][0]=0;
		for(int step=0;step<=w*h;step++){
			int now=step%2,nxt=(step+1)%2;
			if(step==w*h){
				for(int i=0;i<76866;i++){
					if(w<dg[i])break;
					ans=max(ans,dp[now][i]);
				}
				break;
			}
			for(int i=0;i<76866;i++){
				if(w<dg[i])break;
				if(dp[now][i]<0)continue;
				int flg=bit[i];
				if(((flg&p)==0)&&(((flg&1)==0)||((step%w)==0))){
					int nxtflg=(flg<<1)+1;
					dp[nxt][pos[nxtflg]]=max(dp[nxt][pos[nxtflg]],dp[now][i]+v[step]);
				}
				if(flg&p){
					int nxtflg=((flg^p)<<1);
					dp[nxt][pos[nxtflg]]=max(dp[nxt][pos[nxtflg]],dp[now][i]);
				}
				else{
					int nxtflg=(flg<<1);
					dp[nxt][pos[nxtflg]]=max(dp[nxt][pos[nxtflg]],dp[now][i]);
				}
				dp[now][i]=-1;
			}
		}
		cout<<"Case "<<cs<<": "<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 5284
N, T = map(int, input().split())

c = [0] * N
t = [0] * N

for i in range(N):
    c[i], t[i] = map(int, input().split())

min = 1001
for i in range(N):
    if(t[i] <= T ):
        if(min > c[i]):
            min = c[i]

if(min == 1001):
    print("TLE")
else:
    print(min)


Measured memory_bytes: 3060
#include <stdio.h>
 
int main() {
char a;
char ch[120];
char c[120];
char b[120];
int i,j,k,l,m,n,o;
m = 0;
n = 0;
i=0;
l=0;
 
while(1) {
scanf("%c",&a);
 
if(a == '\n') {
 break;
}
 
ch[i] = a;
i=i+1;
 
}
 
j=0;
while(1) {
scanf("%c",&a);
if(a == '\n') {
break;
}
c[j] = a;
j +=1;
}
/*??????????????§??\??????*/
 
for(k=0;k<i;k++) {
 
if(c[0] == ch[k] ) {       /*???????????????????????¨?????????????????? */
 l = k;
n = 0;                         /* ??????????????´???????????????*/
for(m=0;m<i-k;m++) {         /* c[k]????????????????§????????????? */
n = n +1;
l  +=1;
b[m] = ch[l-1];
}
l=0;
for(m=n;m<n+1+k;m++) {
l +=1;
b[m] = ch[l-1];            
}
o=0;
for(n=0;n<j;n++) {
/*printf("b[%d] = %c\n c[%d] = %c\n",n,b[n],n,c[n]); */
if(b[n] == c[n]){
o +=1;
}
}
}
 
/* printf("i = %d\nj = %d\n",i,j); */
 
 
if(o == j) {
printf("Yes\n");
break;
} else if(k==i-1) {
printf("No\n");
}
}
  
return 0;
 
}


Measured memory_bytes: 2608
use std::io;

#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

const SPLIT_DELIMITER: char = ' ';
#[allow(dead_code)]
fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

fn f(v: &Vec<Vec<isize>>, d: usize, a: usize, b: usize) -> usize {
    let mut buf = 0;
    for z in 0..d {
        let buf2 = v[a][z] - v[b][z];
        buf += buf2 * buf2;
    }
    let ans = (buf as f64).sqrt();
    let ans = ans as isize;
    if ans * ans == buf {
        1
    } else {
        0
    }
}

fn main() {
    let n: usize;
    let d: usize;
    let mut ans = 0;
    input!(n, d);
    let v: Vec<Vec<isize>> = input_vector2d(n);

    for i in 0..n {
        for j in 0..n {
            if i == j {
                continue;
            }
            ans += f(&v, d, i, j);
        }
    }
    p(ans/2);
}

Measured memory_bytes: 4352
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String[] red = new String[N];
    for (int i=0; i<N; i++) {
      red[i] = sc.next();
    }
    int M = sc.nextInt();
    String[] blue = new String[M];
    for (int i=0; i<M; i++) {
      blue[i] = sc.next();
    }
    int[] countN = new int[N];
    for (int i=0; i<N; i++) {
      countN[i] =1;
      for (int j=i+1; j<N; j++) {
        if (red[i].equals(red[j])) {
          countN[i]++;
        }
      }
      for (int k=0; k<M; k++) {
        if (red[i].equals(blue[k])) {
          countN[i]--;
        }
      }
    }
    int max =0;
    for (int i=0; i<N; i++) {
      if (countN[i] > max) {
        max = countN[i];
      }
    }
    System.out.println(max); 
  }
}

Measured memory_bytes: 22740
#include<iostream>
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  int size[N];

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

  int counter = 0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<i; j++) {
      if (size[j] == size[i]) {
        counter--;
        break;
      }
    }
    counter++;
  }
  cout << counter;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second

void solve(){  
	int a,b;
	cin>>a>>b;
	cout<<max(2*a-1,max(2*b-1,a+b))<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords) // bufio.ScanLines
	return sc
}

func main() {
	sc = initScanner(os.Stdin)
	fmt.Println(resolve(parseProblem()))
}

type matrixSize struct{ row, col int }

func calcNum(i, j matrixSize) int {
	return i.row * j.col * i.col
}

func parseProblem() (int, []matrixSize) {
	n := scanInt(sc)
	sizes := make([]matrixSize, n)
	for i := 0; i < n; i++ {
		sizes[i] = matrixSize{row: scanInt(sc), col: scanInt(sc)}
	}
	return n, sizes
}

var dp [][]int

func initDP(n int) {
	dp = make([][]int, n+1)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, n+1)
		for j := 0; j < len(dp[i]); j++ {
			dp[i][j] = math.MaxInt64
		}
	}
}

func resolve(n int, sizes []matrixSize) int {
	// TODO 復習
	initDP(n)
	_rec(sizes, 0, n)
	return dp[0][n]
}

func _rec(sizes []matrixSize, l, r int) int {
	if dp[l][r] != math.MaxInt64 {
		return dp[l][r]
	}
	if r-l <= 1 {
		dp[l][r] = 0
		return 0
	}
	num := math.MaxInt64
	for i := l + 1; i < r; i++ {
		v := _rec(sizes, l, i) + _rec(sizes, i, r) + calcNum(matrixSize{sizes[l].row, sizes[i].row}, matrixSize{sizes[i].row, sizes[r-1].col})
		if v < num {
			num = v
		}
	}
	dp[l][r] = num
	return dp[l][r]
}

// snip-scan-funcs
func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return int(i)
}
func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 1204
#include<bits/stdc++.h> 
using namespace std;
int main(){
	int n,m;
	cin>>n;
	int ok=1;
	for(int i=0;i<n;i++){
		cin>>m;
		if(m%2==0){
			if(m%3==0||m%5==0);
			else ok=0;
		}
	}
	if(ok)cout<<"APPROVED"<<endl;
	else cout<<"DENIED"<<endl;
		
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int x,y,d,ch;

	scanf("%d %d",&x,&y);
	if(x < y){
		ch = x;
		x = y;
		y = ch;
	}

	d = x % y;
	while(d > 0){
		x = y;
		y = d;
		d = x % y;
	}
	printf("%d\n",y);

	return 0;
}


Measured memory_bytes: 2144
# coding: utf-8
# Your code here!
import copy

def minus(num):
    for i in range(N):
        eva[i][num]*=(-1)
    return 0

N,M=map(int,input().split())

eva=[]
for _ in range(N):
    x,y,z=map(int,input().split())
    eva.append([x,y,z])
    

ans=[]
for _ in range(2):
    minus(0)
    for __ in range(2):
        minus(1)
        for ___ in range(2):
            minus(2)
            eva.sort(key=lambda x:sum(x),reverse=True)
            #print(eva)
            temp=copy.deepcopy(eva[:M])
            ans.append(temp)
            #print(ans)
            
shin=0
for item in ans:
    temp=0
    for comp in item:
        temp+=sum(comp)
        
    shin=max(temp,shin)
    
print(shin)

Measured memory_bytes: 5224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>	
#include <time.h>
#include <vector>
#include <stdio.h>
#include <memory.h>
#include <string>
#include <string.h>
#include <map>
#include <algorithm>
#include <queue>
#include <set>
#include <time.h>
#include <assert.h>
#include <sstream>
//#include <unordered_map>
#include <bitset>
#include <utility>
#include <iomanip>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <math.h>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;

const int N = 2e5 + 10;
int n, m, vis[N], in[N];
vector<int>adj[N];
vector<pair<int,int> >who[N];
vector<int>roots;
map<ll, ll>pos;
vector<pair<pair<int, int>, int> >s;
int DFS(int u) {
	if(in[u])
		return 1;
	vis[u] = 1;
	in[u] = 1;
	int flag = 0;
	for(int i = 0; i < adj[u].size(); ++i) {
		int v = adj[u][i];
		flag = 1;
		if(vis[v])
			continue;
		DFS(v);
	}
	if(!flag)
		roots.push_back(u);
	in[u] = 0;
	return 0;
}
void calc(ll cur, ll p) {
	if(pos.find(cur) != pos.end())
		return;
	pos[cur] = p;
	for(int j = 0; j < who[cur].size(); ++j) {
		int r = who[cur][j].first;
		ll d = who[cur][j].second;
		calc(r, p + d);
	}
}

int main() {

	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; ++i) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		--l; --r;
		adj[r].push_back(l);
		who[l].push_back(make_pair(r,d));
		s.push_back({{l,r},d});
	}
	for(int i = 0; i < n; ++i)
		if(!vis[i] && DFS(i))
			return 0 * puts("No");
	memset(vis, 0, sizeof vis);
	for(int i = 0; i < roots.size(); ++i) {
		int cur = roots[i];
		calc(cur, 0);
	}
	for(int i = 0; i < s.size(); ++i) {
		int l = s[i].first.first;
		int r = s[i].first.second;
		int d = s[i].second;
		if(pos.find(l) == pos.end() || pos.find(r) == pos.end() || pos[l] + d != pos[r])
			return 0 * puts("No");
	}
	for(int i = 0; i < n; ++i)
		if(pos.find(i) == pos.end() || pos[i] > 1000000000)
			return 0 * puts("No");
	puts("Yes");


	return 0;
}

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

int n, c, a[6], f[1 << 5][1 << 5][305][305];

int main() {
  scanf("%d%d", &n, &c);
  c *= n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    a[i] *= n;
  }
  sort(a, a + n);
  f[0][0][0][a[n - 1]] = 1;
  long long ans = 0, all = 1;
  for (int k = 0; k < c; k++) {
    for (int i = 0; i < 1 << n - 1; i++) {
      for (int j = 0; j < 1 << n - 1; j++) {
        for (int l = 0; l <= c; l++) if (f[i][j][k][l]) {
          if (i == (1 << n - 1) - 1 && l == c) ans += f[i][j][k][l];
          for (int x = k + 1; x < l; x++) if (x % n && !((j >> (x % n - 1)) & 1)) {
            for (int y = 0; y < n - 1; y++) if (!((i >> y) & 1)) {
              f[i | 1 << y][j | 1 << (x % n - 1)][x][min(c, max(x + a[y], l))] += f[i][j][k][l];
            }
          }
        }
      }
    }
  }
  for (int i = 1; i < n; i++) {
    all *= i * c / n;
  }
  printf("%.13Lf\n", (long double) ans / all);
}


Measured memory_bytes: 273024
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long;
//#define int ll
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<V<T>>;
#define fi first
#define se second
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1), EPS = 1e-10;
const ll MOD = 1e9+7;
void cioacc(){//accelerate cin/cout
cin.tie(0);
ios::sync_with_stdio(false);
}
int abct(string &s){
  int res = 0;
  int now = 0;
  while(now<(int)s.size()&&((now = s.find("AB",now)) != -1)){
    res++;
    now+=2;
  }
  return res;
}
signed main(){
  int n;
  cin >> n;
  vector<string> s(n);
  int a=0,b=0,id=0;
  int ans = 0;
  REP(i,n) {
    cin >> s[i];
    ans += abct(s[i]);
    if(s[i].back()=='A'&&s[i].front()=='B') id++;
    else if(s[i].back()=='A') ++a;
    else if(s[i].front()=='B') ++b;
  }
  if(n==1){
    cout << abct(s[0]) << endl;
    return 0;
  }
  if(id){
    ans += id-1;
    if(a) ans++,a--;
    if(b) ans++,b--;
  }
  ans += min(a,b);
  cout << ans << endl;
}


Measured memory_bytes: 768
<?php

class UnionFind
{
    private $parents;

    public function __construct($n)
    {
        $this->parents = array_fill(0, $n, -1);
    }

    public function root($a)
    {
        if ($this->parents[$a] < 0) {
            return $a;
        }

        $this->parents[$a] = $this->root($this->parents[$a]);

        return $this->parents[$a];
    }

    public function size($a)
    {
        return -1 * $this->parents[$this->root($a)];
    }

    public function connect($a, $b)
    {
        $ra = $this->root($a);
        $rb = $this->root($b);
        if ($ra == $rb) {
            return false;
        }

        if ($this->size($ra) > $this->size($rb)) {
            $this->parents[$ra] += $this->parents[$rb];
            $this->parents[$rb] = $ra;
        } else {
            $this->parents[$rb] += $this->parents[$ra];
            $this->parents[$ra] = $rb;
        }
        return true;
    }

    public function isConnect($a, $b)
    {
        return $this->root($a) == $this->root($b);
    }

    public function show()
    {
        print_r($this->parents);
    }
}

fscanf(STDIN, "%d %d", $N, $M);
$P = array_map('intval', explode(' ', trim(fgets(STDIN))));
for ($i = 0; $i < $N; ++$i) {
    --$P[$i];
}

$X = [];
$Y = [];
for ($i = 0; $i < $M; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    --$x;
    --$y;
    $X[] = $x;
    $Y[] = $y;
}

$uni = new UnionFind($N);
for ($i = 0; $i < $M; ++$i) {
    $uni->connect($P[$X[$i]], $P[$Y[$i]]);
}

$cnt = 0;
for ($i = 0; $i < $N; ++$i) {
    if ($uni->isConnect($i, $P[$i])) {
        ++$cnt;
    }
}

echo $cnt, PHP_EOL;


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

int main(){
  string s;
  cin >>s;
  
  int len = s.size();
  string ans;
  
  repeat(i,0,len){
    if(s[i]=='0') ans += '0';
    else if(s[i]=='1') ans += '1';
    else if(s[i]=='B' and ans.size()!=0) ans.erase(ans.size()-1,1);
  }
     
  cout <<ans<< endl;
}

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

const int DIM = 2e5 + 5;

int arr[DIM];

int main( void ) {
    
    int n, k;
    cin >> n >> k;
    
    if( k == 1 && n == 1 )
        cout << "Yes\n1\n";
    else
    if( k == 1 || k == 2 * n - 1 )
        cout << "No\n";
    else
    if( n == 2 )
        cout << "Yes\n1\n2\n3\n";
    else {
        cout << "Yes\n";
        
        if( k != 2 * n - 2 ) {
            arr[n - 1] = k + 1;
            arr[n] = k;
            arr[n + 1] = k - 1;
            arr[n + 2] = k + 2;
        
            for( int i = 1, j = 1; i <= n * 2 - 1; i ++, j ++ ) {
                while( i >= n - 1 && i <= n + 2 )
                    i ++;
                while( j >= k - 1 & j <= k + 2 )
                    j ++;
            
                arr[i] = j;
            }
        }
        else {
            arr[n - 1] = k - 1;
            arr[n] = k;
            arr[n + 1] = k + 1;
            arr[n + 2] = k - 2;
            
            for( int i = 1, j = 1; i <= n * 2 - 1; i ++, j ++ ) {
                while( i >= n - 1 && i <= n + 2 )
                    i ++;
                while( j >= k - 2 & j <= k + 1 )
                    j ++;
                
                arr[i] = j;
            }
        }
        
        for( int i = 1; i <= n * 2 - 1; i ++ )
            cout << arr[i] << "\n";
    }
    
    return 0;
}

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

int main(){
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	for(int i=1;i<=k;i++){
		if(a>=b)b*=2;
		else if(b>=c)c*=2;
		else{
			cout<<"Yes";
			return 0;
		}
	}
	if(a<b&&b<c)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3588
require 'scanf'
while true 
    h,w,d=STDIN.gets.scanf("%d %d %d")
    exit if h==0 and w==0 and d==0
    d2_min=[h*h+w*w,w*w+d*d,d*d+h*h].min
    n=STDIN.gets.to_i
    for i in 0..n-1 do
        r=STDIN.gets.to_i
        print "OK\n" if 4*r*r>d2_min
        print "NA\n" if 4*r*r<=d2_min
    end
end

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

#define endl "\n"
#define si(a) scanf("%d ",&a);
#define si2(a,b) scanf("%d %d ",&a,&b);
#define si3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define sll(a) scanf("%lld ",&a);
#define sll2(a,b) scanf("%lld%lld",&a,&b)
#define sll3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define sf(a) scanf("%f ",&a);
#define sd(a) scanf("%lf ",&a);
#define sc(a) scanf("%c ",&a);
#define ss(a) scanf("%s ",a);
#define sf2(a,b) scanf("%f %f ",&a,&b);
#define sd2(a,b) scanf("%lf %lf ",&a,&b);
#define sz s.size();
#define mp(a,b) make_pair(a,b)
#define pb(x) push_back(x)
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<n;i++)
#define forq(i,q,n) for(int i=q;i<n;i++)
#define form(i,n) for(int i=n;i>=0;i--)
#define forp(i,q,n) for(int i=q;i>=n;i--)
#define fi first
#define se second
#define INF 1000000010
#define MOD 1000000007
#define MAXN
#define LL long long int


using namespace std;

int n;

void init(){
	si(n);
	LL m = n * 800;
	int div = n / 15;
	LL sub = m - (div * 200);
	printf("%lld\n", sub);
}

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

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;

int main() {
	string S,T,X;
	char a;
	cin >> S >> T;
	X = S;
	if (S.size() == T.size()) {
		for (int j = 0; j < S.size(); j++) {
			a = S[S.size() - 1];
			for (int i = 0; i < S.size() - 1; i++) {
				S[i + 1] = X[i];
			}
			S[0] = a;
			X = S;
			if (S == T) {
				cout << "Yes" << endl;
				break;
			}
		}
	}
	if (S != T) {
		cout << "No" << endl;
	}

}

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

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
int W, H;
char board[30][30];

int dfs(int y, int x) {
   board[y][x] = '#';
   int ret = 1;
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < H && nx >= 0 && nx < W && board[ny][nx] == '.') {
         ret += dfs(ny, nx);
      }
   }
   return ret;
}

int main() {
   while (cin >> W >> H, W) {
      for (int i = 0; i < H; i++) {
         cin >> board[i];
      }

      for (int i = 0; i < H; i++) {
         for (int j = 0; j < W; j++) {
            if (board[i][j] == '@') {
               cout << dfs(i, j) << endl;
            }
         }
      }
   }

   return 0;
}


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

int main(){
  int x,y,s;
  while(1){
    cin >> x >> y >> s;
    if(x==0&&y==0&&s==0)break;
    int maxp=0;
    for(int s1=1;s1<s;s1++){
      for(int s2=1;s2<s;s2++){
        if(s1*(100+x)/100+s2*(100+x)/100==s){
          int price=s1*(100+y)/100+s2*(100+y)/100;
          maxp = max(maxp,price);
        }
      }
    }
    cout << maxp << endl;
  }
  return 0;
}



Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
inline void chmin(int &x, int v) { if (x > v) x = v; }

int K;
int dp[100000];
vector<P> G[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> K;
  rep(x, K) {
    rep(k, 10) G[x].pb(P((10*x+k)%K, k));
  }

  priority_queue<P, vector<P>, greater<P> > q;
  rep(i, K) dp[i] = INF;
  for (int k=1; k<=9; k++) {
    if (dp[k] > k) {
      dp[k] = k;
      q.push(P(k, k));
    }
  }
  while (!q.empty()) {
    int r = q.top()._1, x = q.top()._2;
    q.pop();
    if (dp[x] < r) continue;
    for (P p : G[x]) {
      int t = p._1, cost = p._2;
      if (dp[t] > dp[x] + cost) {
        dp[t] = dp[x] + cost;
        q.push(P(dp[t], t));
      }
    }
  }

  cout << dp[0] << "\n";
  return 0;
}


Measured memory_bytes: 20216
#include<stdio.h>

int main(void){

	char string[200001];
	char changedString[200001];

	int p = 'P', d = 'D', question = '?';
	int i, answerp =0, answerd =0;

	gets(string);

	//copystring
	for (i = 0;string[i] != '\0';i++) {
		changedString[i] = string[i];
	}
	changedString[i] = '\0';

	//changechar
	for (i = 0;string[i] != '\0';i++) {
		if (string[i] == question) {
			string[i] = p;
			changedString[i] = d;
		}
	}

	//count
	for (i = 1;string[i]!='\0';i++) {
		if (string[i] == d ) {
			answerp++;
			if (string[i - 1] == p) {
				answerp++;
			}
		}
	}

	for (i = 1;changedString[i] != '\0';i++) {
		if (changedString[i] == d) {
			answerd++;
			if (string[i - 1] == p) {
				answerd++;
			}
		}
	}

	if (answerp > answerd) {
		printf("%s", string);

	}
	else
	{
		printf("%s", changedString);

	}


	}

Measured memory_bytes: 2032
#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>
#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(){
	int a,b;
	scan(a>>b);
	if(a>0){
		prin("Positive");
	}
	else if(a<=0&&b>=0){
		prin("Zero");
	}
	else if((b-a)%2==0){
		prin("Negative");
	}
	else{
		prin("Positive");
	}
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b, c = map(int, input().split())
    print("Yes" if len({a, b, c}) == 2 else "No")


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;

void solve()
{
    ll n, m, k;
    ll maxPos = 0;
    cin>>n>>m>>k;
//    cout<<"nmk\n";
    vector<ll> a(n+1), b(m+1);
    a[0] = b[0] = 0;
//    cout<<"workng\n";
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        a[i]+=a[i-1];
//		cout<<a[i]<<" ";
    }
//    cout<<"working\n";
    for(int i=1; i<=m; i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
//		cout<<b[i]<<" ";
    }
//	cout<<"\n";
    for(int i=0; i<=n;i++)
    {
        ll diff = k-a[i];
        ll ans = 0;
        if(diff<0)
            break;
        ll low = 1, high = m;
        while(low<=high)
        {
            ll mid = low + (high-low)/2;
            if(b[mid]<=diff)
            {
                ans = mid;
                low = mid+1;
            }
            else
            {
                high = mid-1;
            }
        }
        maxPos = max(maxPos, ans+i);
    }
    cout<<maxPos<<"\n";
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    freopen("abc172dInput.txt", "r", stdin);
    int t = 1;
//	cin>>t;
    while(t--)
    {
//    	cout<<"ENTER\n";
        solve();
    }
    return 0;
}

Measured memory_bytes: 6428