akhauriyash/Code-Regression huggingface dataset:
#include <map>
    #include <set>
    #include <list>
    #include <cmath>
    #include <deque>
    #include <queue>
    #include <stack>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <complex>
    #include <cstdlib>
    #include <cstring>
    #include <iomanip>
    #include <numeric>
    #include <utility>
    #include <iostream>
    #include <algorithm>
    #include <functional>
    #include <unordered_map>
    #include <unordered_set>
     
    using namespace std;
     
    #define INF (1 << 30)
    #define INFL (1LL << 62)
    #define MOD7 1000000007
    #define MOD9 1000000009
    #define EPS 1e-10
     
    #define ll long long
    #define ull unsigned long long
    #define P pair<int, int>
    #define pii pair<int, int>
    #define pll pair<ll, ll>
    #define pul pair<ull, ull>
    #define all(a) (a).begin(), (a).end()
    #define FOR(i,a,b) for (int i=(a);i<(b);++i)
    #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
    #define REP(i,n) for (int i=0;i<(n);++i)
    #define RREP(i,n) for (int i=(n)-1;i>=0;--i)
     
    void YES() { cout << "YES" << endl; }
    void NO() { cout << "NO" << endl; }
    void Yes() { cout << "Yes" << endl; }
    void No() { cout << "No" << endl; }
    void yes() { cout << "yes" << endl; }
    void no() { cout << "no" << endl; }
    void digit(int d) { cout << fixed << setprecision(d); }
    void ioup() { cin.tie(0); ios::sync_with_stdio(false); }
     
    int main() {
    	int h, w;
    	string s;
    	cin >> h >> w;
    	for (int i = 1; i <= h; ++i) {
    		for (int j = 1; j <= w; ++j) {
    			cin >> s;
    			if (s == "snuke") {
    				cout << (char)(j - 1 + 'A') << i << endl;
    				return 0;
    			}
    		}
    	}
     
    	return 0;
    }

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

ans = "Yes"
H[0] -= 1
for i in range(1, N):
    if H[i - 1] > H[i]:
        ans = "No"
        break
    if H[i - 1] < H[i]:
            H[i] -= 1

print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<math.h>

using namespace std;
int main() {
	long long a;
	long long b;

	cin >> a;
	//cout << a << endl;
	long long i = 0;
	long long k = 1;
	int t = 0;
	i = sqrt(a);

	for (i = sqrt(a); i >0 ; i--) {
		if (a % i == 0) {
			k = i;
			break;
			}

	}
	long long ans = (k - 1) + (a / k - 1);


	

	cout << ans << endl;

}

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

typedef long long ll;
using namespace std;

int main()
{
	string S;
	cin >> S;
	int N = S.length();
	int i, j;
	std::vector<ll> DP(N + 1);
	std::vector<ll> C(N + 1);

	DP[0] = 0;
	C[0] = 1;
	for (i = 0; i<N + 1; i++){
		for (j = 1; j<i + 1; j++){
			ll tmp = std::stoll(S.substr(i - j, j));
			C[i] += C[i - j];
			DP[i] += (DP[i - j] + tmp*C[i - j]);
		}
	}
	cout << DP[N] << endl;
}

Measured memory_bytes: 384
def main():
    import sys
    from collections import defaultdict
    input = sys.stdin.readline

    class UnionFind():
        def __init__(self, n):
            self.n = n
            self.root = [-1] * (n + 1)
            self.rnk = [0] * (n + 1)

        def find_root(self, x):
            if self.root[x] < 0:
                return x
            else:
                self.root[x] = self.find_root(self.root[x])
                return self.root[x]

        def unite(self, x, y):
            x = self.find_root(x)
            y = self.find_root(y)
            if x == y:
                return
            elif self.rnk[x] > self.rnk[y]:
                self.root[x] += self.root[y]
                self.root[y] = x
            else:
                self.root[y] += self.root[x]
                self.root[x] = y
                if self.rnk[x] == self.rnk[y]:
                    self.rnk[y] += 1

        def isSameGroup(self, x, y):
            return self.find_root(x) == self.find_root(y)

        def size(self, x):
            return -self.root[self.find_root(x)]

    class Bit:
        def __init__(self, n):
            self.size = n
            self.inf = 10 ** 15
            self.tree = [self.inf] * (n + 1)

        def query(self, i):
            s = self.inf
            while i > 0:
                s = min(self.tree[i], s)
                i -= i & -i
            return s

        def update(self, i, x):
            while i <= self.size:
                self.tree[i] = min(self.tree[i], x)
                i += i & -i

    N, D = map(int, input().split())
    A = list(map(int, input().split()))

    tmp = [(a, i+1) for i, a in enumerate(A)]
    tmp.sort(key=lambda x: x[0])
    segtree_plus = Bit(N+5)
    segtree_minus = Bit(N+5)
    edge = []
    val2idx_plus = defaultdict(int)
    val2idx_minus = defaultdict(lambda: N+3)
    edge_append = edge.append
    inf = 10**15
    for a, i in tmp:
        val_plus = a+D*i
        val_minus = a-D*i
        segtree_plus.update(N+1-i, val_plus)
        segtree_minus.update(i, val_minus)
        i_ori = val2idx_plus[val_plus]
        if i > i_ori:
            val2idx_plus[val_plus] = i
        i_ori = val2idx_minus[val_minus]
        if i < i_ori:
            val2idx_minus[val_minus] = i
        plus_min = segtree_plus.query(N-i)
        if plus_min < inf:
            j_plus = val2idx_plus[plus_min]
            edge_append((i, j_plus, A[i-1] + A[j_plus-1] + D*(j_plus - i)))
        minus_min = segtree_minus.query(i-1)
        if minus_min < inf:
            j_minus = val2idx_minus[minus_min]
            edge_append((i, j_minus, A[i-1] + A[j_minus-1] + D * (i - j_minus)))

    edge.sort(key=lambda x: x[2])
    UF = UnionFind(N + 1)
    ans = 0
    for u, v, cost in edge:
        if UF.isSameGroup(u, v):
            continue
        ans += cost
        UF.unite(u, v)
    print(ans)


if __name__ == '__main__':
    main()


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

int dp[205][10005]={0};
int n,w;
int wi[10005]={0};

int main(){
  int i,j,k=0;
  cin >> n >>w;
  for(i=0;i<n;i++)cin >> wi[i];
  sort(wi,wi+n);
  for(i=0;i<=w;i++)dp[0][i]=1;
  for(i=0;i<=n;i++)dp[i][0]=1;
  for(i=0;i<n;i++){
    for(j=1;j<=w;j++){
      if(wi[i]>j)dp[i+1][j]=dp[i][j]%1000000007;
      else if(wi[i]+k<=j)dp[i+1][j]=1%1000000007;
      else dp[i+1][j]=dp[i][j-wi[i]]+dp[i][j]%1000000007;
      //cout << dp[i+1][j]<<" ";
    }
    k+=wi[i];
    //cout << endl;
  }
  cout << dp[n][w]%1000000007<<endl;
  
  return 0;
}



Measured memory_bytes: 10916
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

//ll mod = 1000000007;
ll mod = 998244353;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}



int main() {
	int n, m;
	cin >> n >> m;
	vector<int>ans(n, -1);
	vector<vector<int>>path(n);
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	queue<int>todo;
	todo.push(0);
	ans[0] = 0;
	while (todo.empty() != 1) {
		int tmp = todo.front();
		todo.pop();
		for (int t : path[tmp]) {
			if (ans[t] == -1) {
				ans[t] = tmp;
				todo.push(t);
			}
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i < n; i++) {
		if (ans[i] == -1)cout << "No" << endl;
		else {
			cout << ans[i] + 1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 10340
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t N, M;
  cin >> N >> M;
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  } else if (N == 1 || M == 1) {
    cout << max(N, M) - 2 << endl;
  } else {
    cout << (N - 2) * (M - 2) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define each(e,v) for(auto&& e:(v))
#define DEBUG(x) cout<<#x<<": "<<x<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;

int main() {
    string s; cin >> s;
    cout << s[0] << s[1] << s[2] << s[3] << " " << s[4] << s[5] << s[6] << s[7] << s[8] << s[9] << s[10] << s[11] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int n;
  string str;
  cin >> n >> str;

  int ans = 0;
  REP(i, 1001) {
    int f = i / 100;
    int s = (i / 10) % 10;
    int t = i % 10;
    int state = 0;
    REP(j, n) {
      int c = (str[j] - '0');
      if (state == 0 && c == f) {
        state++;
        continue;
      }
      if (state == 1 && c == s) {
        state++;
        continue;
      }
      if (state == 2 && c == t) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
import sys
input = sys.stdin.readline

H, W = list(map(int, input().split()))
S = ["#" * (W+2)] + ["#" + input().strip() +
                     "#" for _ in range(H)] + ["#" * (W+2)]

ans = 0

for j in range(1, H+1):
    for i in range(1, W+1):
        if S[j][i] != ".":
            continue
        m = [[-1] * (W+2) for _ in range(H+2)]

        q = deque()
        q.append((j, i, 0))
        m[j][i] = 0

        while q:
            y, x, v = q.popleft()
            if ans < v:
                ans = v
            for dj, di in ((y, x+1), (y, x-1), (y+1, x), (y-1, x)):
                if S[dj][di] == "#" or m[dj][di] != -1:
                    continue
                q.append((dj, di, v+1))
                m[dj][di] = v+1
print(ans)


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

typedef long long ll;
#define rep(i,n) for( ll (i)=0; (i)<(n); ++(i) )
#define rpi(i,n) for( int (i)=0; (i)<(n); ++(i) )
#define rpv(d) for(auto& v:d)
#if __cplusplus < 201703L
  std::ostream& co_(){ return std::cout << std::endl; }
  std::istream& cn_(){ return std::cin; }
  template<class Head, class... Args>
  std::ostream& co_( Head&& head, Args&&... args ){ std::cout << head; return co_(std::forward<Args>(args)...); }
  template<class Head, class... Args>
  std::istream& cn_( Head&& head, Args&&... args ){ std::cin >> head; return cn_(std::forward<Args>(args)...); }
#else
  template<class... Args>
  std::ostream& co_( Args... args ){ return std::cout << ... << args << std::endl; }
  template<class... Args>
  std::istream& cn_( Args... args ){ return std::cin >> ... >> args; }
#endif
#define co(...) co_(__VA_ARGS__);
#define cn(...) cn_(__VA_ARGS__);
#define all(x) (x).begin(), (x).end()
#define rgt(x,i) (x).begin(), (x).begin()+(i)

int main(){
  int a,b;cn(a,b)
  rep(i,100000){
    if (floor(0.08*i)==a&&floor(0.1*i)==b){
      co(i)
      return 0;
    }
  }
  co("-1")
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
  long long val;
  constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
    if (val < 0) val += MOD;
  }
  constexpr int getmod() { return MOD; }
  constexpr Fp operator - () const noexcept {
    return val ? MOD - val : 0;
  }
  constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
  constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
  constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
  constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
  constexpr Fp& operator += (const Fp& r) noexcept {
    val += r.val;
    if (val >= MOD) val -= MOD;
    return *this;
  }
  constexpr Fp& operator -= (const Fp& r) noexcept {
    val -= r.val;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr Fp& operator *= (const Fp& r) noexcept {
    val = val * r.val % MOD;
    return *this;
  }
  constexpr Fp& operator /= (const Fp& r) noexcept {
    long long a = r.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    val = val * u % MOD;
    if (val < 0) val += MOD;
    return *this;
  }
  constexpr bool operator == (const Fp& r) const noexcept {
    return this->val == r.val;
  }
  constexpr bool operator != (const Fp& r) const noexcept {
    return this->val != r.val;
  }
  friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
    return os << x.val;
  }
  friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
    if (n == 0) return 1;
    auto t = modpow(a, n / 2);
    t = t * t;
    if (n & 1) t = t * a;
    return t;
  }
};
using mint = Fp<MOD>;

int main(){
  int N; cin >> N;
  vector<int> C(N);
  rep(i, N) {
    cin >> C[i];
  }
  sort(ALL(C));
  reverse(ALL(C));

  mint ans = 0;
  rep(i, N) {
    ans += mint(i + 2) * mint(C[i]);
  }
  ans *= modpow(mint(2), 2*(N-1));
  cout << ans << endl;
  return 0;
}

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

int main()
{
    ll A, B, K; cin >> A >> B >> K;
    if (A <= K) {
        K -= A;
        A = 0;
        if (B <= K) {
            K -= B;
            B = 0;
        }
        else {
            B -= K;
        }
    }
    else {
        A -= K;
    }

    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d,count,i;
	count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		 d = c%i;
		 if(d==0){
		 count=count+1;
		 }
		 else{
		 }
	}
	printf("%d\n",count);
	
	return 0;
}

Measured memory_bytes: 596
import java.util.Scanner;

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

        int happy = (x / 500) * 1000;
        x = x % 500;
        happy += (x / 5) * 5;

        System.out.println(happy);
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <algorithm>



    
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());
    int mid = A[N / 2];
    long long res = 0;
    for(int i = 0; i < N; i++){
        res += abs(A[i] - mid);
    }
    cout << res << endl;

    return 0;       
}


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

int main(){
  int count=0;
  int flag=0;
  int N;
  cin>>N;
  vector<int>X(N);
  rep(i,N){
    cin>>X[i];
  }
  rep(i,N){
    rep(j,i){
      if(X[j]>X[i]){
        flag++;
      }
    }
      if(flag==0){
        count++;
      }
      flag=0;
    
  }
  cout<<count;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

int n, m;
Vi v;

void init()
{
	cin >> n >> m;
	v.resize(n + 1);
}


int main()
{
	init();

	REP(_i, m)
	{
		int l, r;
		cin >> l >> r; --l; --r;

		v[l]++; v[r + 1]--;
	}

	int ans = 0;
	int tmp = 0;
	REP(i, n)
	{
		tmp += v[i];
		if (tmp >= m)
			++ans;
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
A=[list(map(int,input().split())) for i in range(3)]
N=int(input())
b=[int(input()) for i in range(N)]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i]==A[j][k]:
                A[j][k]=0

if (A[0][0]==0 and A[0][1]==0 and A[0][2]==0)\
or (A[1][0]==0 and A[1][1]==0 and A[1][2]==0)\
or (A[2][0]==0 and A[2][1]==0 and A[2][2]==0)\
or (A[0][0]==0 and A[1][0]==0 and A[2][0]==0)\
or (A[0][1]==0 and A[1][1]==0 and A[2][1]==0)\
or (A[0][2]==0 and A[1][2]==0 and A[2][2]==0)\
or (A[0][0]==0 and A[1][1]==0 and A[2][2]==0)\
or (A[0][2]==0 and A[1][1]==0 and A[2][0]==0):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
# 解説と 13355391 を参考に実装予定


import math


def solve():
    N = int(input())
    ABs = [[int(i) for i in input().split()] for _ in range(N)]
    mod = 10 ** 9 + 7

    lonlieness = 0
    pairs = {}
    for AB in ABs:
        a, b = AB
        if a == 0 and b == 0:
            lonlieness += 1
            continue
        elif a == 0:
            a, b = -1, 0
            bad_a, bad_b = 0, 1
        elif b == 0:
            a, b = (0, 1)
            bad_a, bad_b = -1, 0
        else:
            _gcd = math.gcd(a, b)
            a //= _gcd
            b //= _gcd
            bad_a = -b
            bad_b = a
            if b < 0:
                a, b = -a, -b
            if bad_b < 0:
                bad_a, bad_b = -bad_a, -bad_b
        pairs.setdefault((a, b), 0)
        pairs.setdefault((bad_a, bad_b), 0)  # 仲の悪いグループも登録しておく
        pairs[(a, b)] += 1

    permutations = []
    for i, pair in enumerate(pairs.keys()):
        if i % 2 == 1:
            continue
        a, b = pair
        bad_a, bad_b = -b, a
        if bad_b < 0:
            bad_a, bad_b = -bad_a, -bad_b
        group_num = pow(2, pairs[(a, b)], mod) - 1
        badgroup_num = pow(2, pairs[(bad_a, bad_b)], mod) - 1
        permutations.append(group_num + badgroup_num + 1)

    result = 1
    for p in permutations:
        result = result * p % mod

    result = (result + lonlieness - 1) % mod
    print(result)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 115992
n,m=map(int,input().split())
A=[]
for i in range(n):
    A.append(list(map(int,input().split())))


ma=0

for i in range(8):
    for d in range(3):
        if bin(i)[2:].zfill(3)[d]=="1":
            for j in range(n):
                A[j][d]*=-1

    B=[]
    for j in range(n):
        B.append(sum(A[j]))

    B.sort()
    ma2=0
    for k in range(m):
        ma2+=B[n-k-1]
    ma=max(ma,ma2)

    for d in range(3):
        if bin(i)[2:].zfill(3)[d]=="1":
            for j in range(n):
                A[j][d]*=-1

print(ma)


Measured memory_bytes: 3316
#include<iostream>
#include<queue>
using namespace std;
int n,m,giao=0,hp;
int xx[]={0,-1,0,0,1};
int yy[]={0,0,-1,1,0};
char c[110][110];
struct nd
{int x,y,time;};
int bfs(int x,int y)
{
    queue<nd>q;
    nd now,next;
    now.x=x;now.y=y;now.time=0;
    q.push(now);
    while(!q.empty())
    {
        now=q.front();
        q.pop();
        if(now.x==n&&now.y==m)return now.time;
        for(int i=1;i<=4;i++)
        {
            next.x=now.x+xx[i];
            next.y=now.y+yy[i];
            next.time=now.time+1;
            if(next.x>0&&next.x<=n&&next.y>0&&next.y<=m&&c[next.x][next.y]=='.')
            {
                c[next.x][next.y]='#';
                q.push(next);
            }
        }
    }
    return -1;
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>c[i][j];
			if(c[i][j]=='#')giao++;
		}
	c[1][1]='#';
	hp=bfs(1,1);
	if(hp!=-1)
	cout<<n*m-hp-giao-1;
	else cout<<-1;
}

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

int main()
{
	int N;
	while (cin >> N, N) {
		vector<int> guy(N), L(N);
		for (int i = 0, M; i < N; i++) {
			cin >> M >> L[i];
			for (int j = 0, s, e; j < M; j++) {
				cin >> s >> e; s -= 6, e -= 6;
				guy[i] |= (1 << e) - (1 << s);
			}
		}
		vector<long long> dp(1 << 16);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < (1 << 16); j++) {
				if ((guy[i] & j) == 0) {
					dp[j + guy[i]] = max(dp[j + guy[i]], dp[j] + L[i]);
				}
			}
		}
		cout << dp[(1 << 16) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<cmath>
#include<map>
#include<string>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;

int N;
int s[300000];
int maxi=0;
string str;
map<string,int>m;
int main(){
    cin>>N;
    rep(i,0,N){
        cin>>str;
        m[str]++;
        if(maxi < m[str])maxi=m[str];
    }
    for(auto i=m.begin();i!=m.end();i++){
        if(i->second==maxi){
            puts(i->first);
        }
    }
}

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

int main() {
    int64_t n;
    cin >> n;
    vector<int64_t> l(100);
    l[0] = 2, l[1] = 1;
    for (int64_t i = 0; i + 2 < 100; i++) l[i+2] = l[i+1] + l[i];
    cout << l[n] << endl;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i, n) for (int i = 0; i < int(n); i++)
#define FOR1(i, m, n) for (int i = int(m); i < int(n); i++)
#define MAX(a, b) ((a) >= (b) ? (a) : (b))
#define MIN(a, b) ((a) <= (b) ? (a) : (b))

int main(int argc, char *argv[]) {
  int Q, H, S, D, N;

  cin >> Q >> H >> S >> D;
  cin >> N;

  int price1 = min(4 * Q, 2 * H);
  price1 = min(price1, S);

  int price2 = min(2 * price1, D);

  ll ans = (ll)(N/2) * price2;
  ans += (ll)(N%2) * price1;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline T gcd(T a, T b) {
  return __gcd(a, b);
}

template<typename T> inline T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}

template<typename T> inline T floor(T a, T b) {
  return a / b * b <= a ? a / b : a / b - 1;
}

template<> inline float floor(float a, float b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<> inline double floor(double a, double b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<> inline long double floor(long double a, long double b) {
  return floor(a / b) * b <= a ? floor(a / b) : floor(a / b) - 1;
}

template<typename T> inline T ceil(T a, T b) {
  return floor(a + b - 1, b);
}

template<typename T> inline T round(T a, T b) {
  return floor(a + b / 2);
}

template<typename T> inline T mod(T a, T b) {
  return a - floor(a, b) * b;
}

template<typename T> inline T factorial(T n) {
  return n <= 1 ? 1 : factorial(n - 1) * n;
}

template<typename T> inline T square(T n) {
  return n * n;
}

template<typename T> inline T cube(T n) {
  return n * n * n;
}

template<typename T> inline T norm(T x1, T y1, T x2, T y2) {
  return square(x1 - x2) + square(y1 - y2);
}

inline long long sqrt(long long n) {
  return sqrt((long double)n);
}

int main() {
  int64_t n, x = -1, y = -1, t, a;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> t >> a;
    if (i == 0) {
      x = t;
      y = a;
    } else {
      auto k = max(ceil(x, t), ceil(y, a));
      x = k * t;
      y = k * a;
    }
  }
  cout << x + y << endl;
}


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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll ans = 0;
    iter(c, S) ans += c == '1';
    cout << ans << endl;
    return 0;
}


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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int mp[105][105], ps[105][105];

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    while (1) {
        int n; cin >> n;
        if (!n) break;

        int w, h; cin >> w >> h;
        rep(i, 0, w + 1) rep(j, 0, h + 1) mp[i][j] = 0, ps[i][j] = 0;
        rep(i, 0, n) {
            int a, b; cin >> a >> b;
            mp[a][b] = 1;
        }
        int s, t; cin >> s >> t;
        rep(i, 1, w + 1) rep(j, 1, h + 1) ps[i][j] = ps[i - 1][j] + ps[i][j - 1] - ps[i - 1][j - 1] + mp[i][j];
        int ans = 0;
        rep(i, s, w + 1) rep(j, t, h + 1) {
            ans = max(ans, ps[i][j] - ps[i - s][j] - ps[i][j - t] + ps[i - s][j - t]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3176
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    int solve(string& s, string& t) {
        string S = s;
        while (S.length() < t.length()) {
            S += s;
        }
        int n = S.length();

        S += S;
        
        int m = t.length();
        vector<int> next(m + 1, -1);
        for (int i = 0, j = -1; i < m; ++i) {
            while (j != -1 && t[j] != t[i]) {
                j = next[j];
            }
            next[i + 1] = ++j;
        } 

        vector<int> pos;
        for (int i = 0, j = 0; i < S.length(); ++i) {
            if (S[i] == t[j]) {
                if (++j == m) {
                    int beg = i - m + 1;
                    pos.push_back(beg % n);
                    j = next[j];
                }
            } else {
                while (j != -1 && S[i] != t[j]) {
                    j = next[j];
                }
                if (j == -1) {
                    j = 0;
                } else {
                    --i;
                }
            }
        }

        vector<vector<int>> graph(n);
        vector<int> degrees(n, 0);
        
            vector<bool> ok(n, false);
            for (auto x : pos) {
                ok[x] = true;
            }
            for (int i = 0; i < n; ++i) {
                if (ok[i]) {
                    int j = (i + m) % n;
                    if (ok[j]) {
                        graph[i].push_back(j);
                        degrees[j] += 1;
                    }
                }
            }
        

        vector<int> ord;
        for (int i = 0; i < n; ++i) {
            if (degrees[i] == 0) {
                ord.push_back(i);
            }
        }

        for (int i = 0; i < ord.size(); ++i) {
            int u = ord[i];
            for (auto v : graph[u]) {
                if (--degrees[v] == 0) {
                    ord.push_back(v);
                }
            }
        }

        for (int i = 0; i < n; ++i) {
            if (degrees[i] != 0) {
                return -1;
            }
        }


        reverse(ord.begin(), ord.end());

        vector<int> dp(n, 0);

        for (auto u : ord) {
            if (!ok[u]) {
                continue;
            }
            int ans = 0;
            for (auto v : graph[u]) {
                ans = max(ans, dp[v]);
            }
            ans += 1;
            dp[u] = ans;
        }

        int res = *max_element(dp.begin(), dp.end());
        return res;

    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    string s;
    string t;
    cin >> s >> t;

    Solution sol;
    cout << sol.solve(s, t) << "\n";

    return 0;
}

Measured memory_bytes: 71232
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii;
import std.typecons, std.functional;
import std.algorithm, std.container;

void main()
{
    long N = scanElem;
    primes(55555).filter!"a%5==1".take(N).each!writeln;

}

class UnionFind{
    UnionFind parent = null;

    void merge(UnionFind a)
    {
        if(same(a)) return;
        a.root.parent = this.root;
    }
    UnionFind root()
    {
        if(parent is null)return this;
        return parent = parent.root;
    }
    bool same(UnionFind a)
    {
        return this.root == a.root;
    }
}

void scanValues(TList...)(ref TList list)
{
    auto lit = readln.splitter;
    foreach (ref e; list)
    {
        e = lit.fornt.to!(typeof(e));
        lit.popFront;
    }
}

T[] scanArray(T = long)()
{
    return readln.split.to!(long[]);
}

void scanStructs(T)(ref T[] t, size_t n)
{
    t.length = n;
    foreach (ref e; t)
    {
        auto line = readln.split;
        foreach (i, ref v; e.tupleof)
        {
            v = line[i].to!(typeof(v));
        }
    }
}

T scanElem(T = long)()
{
    char[] res;
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        res ~= cast(char) c;
        c = getchar;
    }
    return res.strip.to!T;
}

template fold(fun...) if (fun.length >= 1)
{
    auto fold(R, S...)(R r, S seed)
    {
        static if (S.length < 2)
        {
            return reduce!fun(seed, r);
        }
        else
        {
            import std.typecons : tuple;

            return reduce!fun(tuple(seed), r);
        }
    }
}

struct Factor
{
    long n;
    long c;
}

Factor[] factors(long n)
{
    Factor[] res;
    for (long i = 2; i ^^ 2 <= n; i++)
    {
        if (n % i != 0)
            continue;

        int c;
        while (n % i == 0)
        {
            n = n / i;
            c++;
        }
        res ~= Factor(i, c);
    }
    if (n != 1)
        res ~= Factor(n, 1);

    return res;
}
long[] primes(long n)
{
    if(n<2)return [];
    auto table = new long[n+1];
    long[] res;
    for(int i = 2;i<=n;i++)
    {
        if(table[i]==-1) continue;
        for(int a = i;a<table.length;a+=i)
        {
            table[a] = -1;
        }
        res ~= i;
    }
    return res;
}
bool isPrime(long n)
{
    if (n <= 1)
        return false;
    if (n == 2)
        return true;
    if (n % 2 == 0)
        return false;
    for (long i = 3; i ^^ 2 <= n; i += 2)
        if (n % i == 0)
            return false;
    return true;
}

Measured memory_bytes: 2684
import java.util.*;

 
class Main {
 
    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        String s=sc.next();
        char[] si  = s.toCharArray();
        char s0='0';
        char s1='1';
        ArrayList<Integer> numS =new ArrayList<Integer>();
        int now = 1;
        int count=0;
        //101111011->11412へ
        for(char curr:si){
            if(Character.getNumericValue(curr) == now){
                count++;
            }else{
                numS.add(count);
                now=1-now;
                count=1;
            }
        }
        if(count!=0)numS.add(count);
        if(numS.size()%2==0)numS.add(0);
        //System.out.println(numS);
        int add = 2 * k + 1;
        int ans = 0;
        //11412
        int left =0;
        int right =0;
        int tmp =0;
        for(int nextleft = 0; nextleft < numS.size(); nextleft += 2)
        {
            int nextright = Math.min( nextleft + add, numS.size() );

            while(nextleft > left)
            {
                tmp -=numS.get(left);
                left++;
            }
            while(nextright > right)
            {
                tmp +=numS.get(right);
                right++;
            }
            ans = Math.max(tmp,ans);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 26912
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d, e, f, g, h;
	cin >> a >> b >> c >> d;
	
	e = c - d + b;
	f = d + c - a;

	g = a + b - d;
	h = b + c - a;
	cout << e << " " << f << " " << g << " " << h << endl;


	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        var tt = ReadIntArray();
        int t = tt[0], x = tt[1];
        double ans = (double) t / x;
        WriteLine(ans);
    }
}


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

using namespace std;

int main()
{
  char c;

  cin >> c;

  bool vowel = false;

  if (c == 'a')
  {
    vowel = true;
  }
  else if (c == 'i')
  {
    vowel = true;
  }
  else if (c == 'u')
  {
    vowel = true;
  }
  else if (c == 'e')
  {
    vowel = true;
  }
  else if (c == 'o')
  {
    vowel = true;
  }

  printf(vowel ? "vowel" : "consonant");
}

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


int main() {
	int N,D;
    int i,j,k,l,p,q;
    double dis;
    int count = 0;
    cin >> N >> D;

	vector<vector<int>> A(10,vector<int>(10));
  	
	for(i=0;i<N;i++){
      for(j=0;j<D;j++){
        cin >> A.at(i).at(j);
      }
    }

	for(k=0;k<N;k++){
      for(l=0;l<k;l++){
        dis = 0;
        for(p=0;p<D;p++){
          dis += (A.at(k).at(p)-A.at(l).at(p))*(A.at(k).at(p)-A.at(l).at(p));
        }
        if((sqrt(dis))-ceil(sqrt(dis))==0){
          count++;
      	}
      }
    }
      cout << count;
	return 0; 
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;


int main()
{
    int n;
    scanf("%d",&n);
    double x[n];
    double p=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lf",&x[i]);
        p=p+(x[i]/n);
    }

    if(p-(int)p>0.5)
    {
        p=(int)p+1;
    }
    else
    {
        p=(int)p;
    }
    
    int ans=0;

    for(int i=0;i<n;i++)
    {
        ans=ans+(p-x[i])*(p-x[i]);
    }
    


    
    printf("%d\n",ans);


    return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=16;
const int maxm=(1<<maxn)+5;
const int mod=1e9+7;
int n,m;
int a[maxn],fac[maxm],ifac[maxm],dp[maxn+1][maxm];
int C(int a,int b){
	if(a<0||b<0||a<b)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}

int main(){
	scanf("%d%d",&n,&m);
	rep(i,m)scanf("%d",&a[i]);
	reverse(a,a+m);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=(1<<n);i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	REP(i,(1<<n))ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	dp[0][0]=1;
	rep(i,m)rep(mask,1<<n){
		int cur=dp[i][mask];
		if(!cur)continue;
		dp[i+1][mask]+=cur;
		if(dp[i+1][mask]>=mod)dp[i+1][mask]-=mod;
		int len=0;
		rep(j,n)if((mask>>j)&1)len+=(1<<j);
		rep(j,n)if(!((mask>>j)&1)){
			int now=(1<<n)-a[i];
			dp[i+1][mask|(1<<j)]-=1LL*cur*C(now-len,(1<<j)-1)%mod*fac[(1<<j)]%mod;
			if(dp[i+1][mask|(1<<j)]<0)dp[i+1][mask|(1<<j)]+=mod;
		}
	}
	int ans=0;
	rep(mask,1<<n){
		int cur=dp[m][mask];
		if(!cur)continue;
		int len=0;
		rep(i,n)if((mask>>i)&1)len+=(1<<i);
		ans+=1LL*cur*fac[(1<<n)-1-len]%mod;
		if(ans>=mod)ans-=mod;
	}
	printf("%d\n",1LL*ans*(1<<n)%mod);
	return 0;
}

Measured memory_bytes: 4352
#include <stdio.h>
 
long long int max(long long int a,long long int b,long long int c){
    if(a>=b&&a>=c)return a;
    else if(b>=a&&b>=c)return b;
    return c;
}
long long  int min(long long int a,long long int b,long long int c){
    if(a<=b&&a<=c)return a;
    else if(b<=a&&b<=c)return b;
    return c;
}
int main(void){
    long long int H,W;
    scanf("%lld %lld",&H,&W);
    long long int karix,kariy;
    karix=H/3;kariy=W/3;
    long long int karians[4];
    long long int kari[3];
    long long int ans;
    kari[0]=karix*W;
    kari[1]=(H-karix)*(W/2);
    kari[2]=(H-karix)*W-kari[1];
    if(karix==0)karians[0]=1000000000;
    else karians[0]=max(kari[0],kari[1],kari[2])-min(kari[0],kari[1],kari[2]);
    
    kari[0]+=W;
    kari[1]-=(W/2);
    kari[2]=(H-karix-1)*W-kari[1];;
    karians[1]=max(kari[0],kari[1],kari[2])-min(kari[0],kari[1],kari[2]);
    
    kari[0]=kariy*H;
    kari[1]=(W-kariy)*(H/2);
    kari[2]=(W-kariy)*H-kari[1];
    if(kariy==0)karians[2]=1000000000;
    else karians[2]=max(kari[0],kari[1],kari[2])-min(kari[0],kari[1],kari[2]);
    
    kari[0]+=H;
    kari[1]-=(H/2);
    kari[2]=(W-kariy-1)*H-kari[1];
    karians[3]=max(kari[0],kari[1],kari[2])-min(kari[0],kari[1],kari[2]);
    
    if(H%3==0||W%3==0)printf("0");
    else{
        ans=min(karians[0],karians[1],karians[2]);
ans=min(ans,karians[3],H);
if(ans>W)ans=W;
        printf("%lld",ans);
    }
    return 0;
}

Measured memory_bytes: 128
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
#include <iomanip>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp(a, b) make_pair(a, b)
#define mt(a,b,c) make_tuple(a,b,c)
#define rank qwertyuio
#define next dfghjk
#define plus fsghsf
#define minus ytryr
#define pb push_back
using namespace std;
 
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
 
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int mod = (int)1e9 + 7;
const int mod1 = (int)1e9 + 9;
const int mod2 = 998244353;
const int mod3 = (int)1e6+3;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;
bool lexi(string& a,string& b){
    return lexicographical_compare(a.begin(),a.end(),b.begin(),b.end());
}
ll maxll(ll a,ll b){
    return a<b? b:a;
}
 
int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);<<" "
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        cout<<a-k<<" "<<b;
    }
    else{
        cout<<0<<" "<<maxll(a+b-k,0);
    }
        
    
    return 0;
             
    
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	k := scanInt()
	t := 0
	for i := 0; i < 1e6; i++ {
		t = (t*10%k + 7%k) % k
		if t == 0 {
			fmt.Fprintln(wr, i+1)
			return
		}
	}

	fmt.Fprintln(wr, -1)
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int kingaku, coin_1, total;
 
  // 変数aで入力を受け取る
  cin >> kingaku;
  cin >> coin_1;
  
  total = kingaku - 500 * (kingaku / 500);
  if (total <= coin_1) {
    cout << "Yes" << endl;
  } else {
     cout << "No" << endl;
  }
 }

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

int main(){
    int n,m,l;
    cin >> n >> m >> l;
    vector<vector<ll>> a(n,vector<ll>(m)),b(m,vector<ll>(l)),c(n,vector<ll>(l));
    
    rep(i,n) rep(j,m) cin >> a[i][j];
    rep(i,m) rep(j,l) cin >> b[i][j];
    
    rep(i,n) rep (j,l) rep(k,m) c[i][j]+=a[i][k]*b[k][j];
    
    rep(i,n){
        rep(j,l){
            cout << c[i][j] << ((j!=(l-1)) ? " " : "\n");
        }
    }
    return 0;
    
}


Measured memory_bytes: 3232
N,Q=map(x->parse(Int,x),split(readline()))
A=Array{Int}(0)
now=0
p='K'
for c=chomp(readline())
	if p=='A'&&c=='C'
		now+=1
	end
	push!(A,now)
	p=c
end
for _=1:Q
	l,r=map(x->parse(Int,x),split(readline()))
	println(A[r]-A[l])
end


Measured memory_bytes: 154504
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
int main(){
    int a[100010],b[100010],c[100010],d[100010][3]={0},n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    for(int i=1;i<=n;i++){
        d[i][0]=max(d[i-1][1],d[i-1][2])+a[i];
        d[i][1]=max(d[i-1][0],d[i-1][2])+b[i];
        d[i][2]=max(d[i-1][0],d[i-1][1])+c[i];
    }
    cout<<max(d[n][2],max(d[n][0],d[n][1]))<<endl;
        
}


Measured memory_bytes: 5868