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

using ll = long long;
using ld = long double;
using vl = vector<ll>;
using ml = map<ll,ll>;

#define ff first
#define ss second
#define endl '\n'
#define ins insert
#define eb emplace_back
#define sz(c) (ll) c.size()
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define itr(x,c) for(auto &x : c)
#define tc ll t; cin >> t; while (t--)
#define rep(i,a,n) for(ll i = a ; i < n ; ++i)
#define per(i,a,n) for(ll i = n-1 ; i >= a ; --i)
#define dx(x) cout << #x << ": " << x << endl;
#define dc(c) itr(x,c) cout << x << " "; cout << endl;
#define dm(m) itr(x,m) cout << x.ff << " -> " << x.ss << endl;
#define godspeed cin.tie(0) -> sync_with_stdio(0);

int main() {
    godspeed;
    string s; cin >> s;
    cout << ((s == "ABC") ? "ARC" : "ABC"); 
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, z, n) for(ll i = z; i <= n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

using namespace std;

int main(){
  ll x;
  cin >> x;

  rep(i, 0, 1000){
    for(ll j=-1000;j<=1000;j++){
      ll sum = i*i*i*i*i-j*j*j*j*j;
      if(sum ==x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

using namespace std;

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

	vector<vector<int>> v(m, vector<int>(2));
	
	for (auto &&e : v) {
		cin >> e[0] >> e[1];
	}
	
	sort(v.begin(), v.end(), [](auto& a, auto& b) { return a[0] < b[0]; });
	
	int count = 1, tb = 0, te = n;
	for (int i = 0; i < m; ++i) {
		if (tb < v[i][0]) {
			tb = v[i][0];
			
			if (tb >= te) {
				++count;
				te = n;
			}
		}
		
		if (te > v[i][1]) {
			te = v[i][1];
		}
	}
	
	cout << count << endl;
}

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

using P = pair<ll, ll>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  ll n, x, d;
  cin >> n >> x >> d;
  if (d == 0) {
    if (x == 0) cout << "1\n";
    else cout << n+1 << endl;
    return 0;
  }
  map<int, vector<P>> mp;
  rep(i, n+1) {
    ll s = i*x;
    ll l = (ll)i*(i-1)/2;
    s += l*d;
    ll rm = (s+(d<<30))%d;
    mp[rm].emplace_back((s-rm)/d, (n-i)*i);
  }
  ll ans = 0;
  for (auto p : mp) {
    auto a = p.second;
    vector<P> ev;
    for (auto pp : a) {
      ev.emplace_back(pp.first, 1);
      ev.emplace_back(pp.first+pp.second+1, -1);
    }
    sort(ev.begin(), ev.end());
    int cnt = 0;
    ll pre = -1e18;
    for (auto pp : ev) {
      ll len = pp.first - pre;
      if (cnt > 0) ans += len;
      cnt += pp.second;
      pre = pp.first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 22144
#include<iostream>
#include<queue>

using namespace std;

long powerful_discount_tickets(int n, int m, int a[]){
  priority_queue<int> que;
  for(int i=0;i<n;i++) {
    que.push(a[i]);
  }

  while(m!=0) {
    int price = que.top();
    que.pop();
    int discounted_price = price / 2;
    que.push(discounted_price);
    m--;
  }
  unsigned long ans = 0;

  while(!que.empty()) {
    ans += que.top();
    que.pop();
  }
  return ans;
}

int main () {
  int n, m;
  cin >> n >> m;
  int a[n];

  for(int i=0;i<n;i++) {
    cin >> a[i];
  }
  cout << powerful_discount_tickets(n, m, a);
}

Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int A,B,C;
   cin>>A>>B>>C;
   int K;
   cin>>K;
   for(int i=0;i<K;i++){
       if(A>=B){
         B = B*2;
       }else if(B>=C){
         C = C*2;
       }
   }
   if(C>B&&B>A){
       cout<<"Yes"<<endl;
   }else{
       cout<<"No"<<endl;
   }
 
}

Measured memory_bytes: 3612
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

using namespace std;

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF (int)(1e9+10)
#define LLINF (lint)(1e18+10)

struct weightedUnionFind{

    vector<int> par, rank, wei;

    void init(int n){
        par.resize(n);
        rank.resize(n, 0);
        wei.resize(n, 0);
        rep(i, n){
            par[i] = i;
        }
        return;
    }

    int root(int x){
        if(par[x] == x){
            return x;
        }else{
            int r = root(par[x]);
            wei[x] += wei[par[x]];
            return par[x] = r;
        }
    }

    void unite(int x, int y, int w){
        w = -w;
        w += weight(x);
        w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx == ry){
            return;
        }
        if(rank[rx] < rank[ry]){
            swap(rx, ry);
            w = -w;
        }
        if(rank[rx] == rank[ry]){
            rank[rx]++;
        }
        par[ry] = rx;
        wei[ry] = w;
        return;
    }

    bool same(int x, int y){
        return root(x) == root(y);
    }

    int weight(int x){
        root(x);
        return wei[x];
    }

    int diff(int x, int y){
        return weight(x) - weight(y);
    }

};

int main(){
    int n, q;
    cin >> n >> q;
    weightedUnionFind wuf;
    wuf.init(n);
    rep(i, q){
        int query;
        cin >> query;
        if(query == 0){
            int x, y, z;
            cin >> x >> y >> z;
            wuf.unite(x, y, z);
        }else if(query == 1){
            int x, y;
            cin >> x >> y;
            if(wuf.same(x, y)){
                cout << wuf.diff(x, y) << endl;
            }else{
                cout << "?" << endl;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE h(n); rep(i, n)cin >> h[i];
	int tmp = 0;
	rep(i, n)chmax(tmp, h[i]);
	int ans = 0;
	for(int i = 1; i <= tmp; i++) {
		int now = 0;
		rep(j, n) {
			if (h[j] >= i) {
				now = 1;
			}
			else {
				if (now) {
					ans++;
					now = 0;
				}
			}
		}
		if (now) {
			ans++;
			now = 0;
		}
	}
	cout << ans << endl;
	return 0;
}


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

const int N = 500 + 5;

int n, m;
char c;
char a[N][N], b[N][N];

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i ++) a[1][i] = '#', a[n][i] = '.';
	for (int i = 2; i <= n - 1; i ++)
		for (int j = 1; j <= m; j ++)
			a[i][j] = j & 1 ? '#' : '.';
	for (int i = 1; i <= m; i ++) b[1][i] = '.', b[n][i] = '#';
	for (int i = 2; i <= n - 1; i ++)
		for (int j = 1; j <= m; j ++)
			b[i][j] = j & 1 ? '.' : '#';
	for (int i = 1; i <= n; i ++)
		for (int j = 1; j <= m; j ++)
		{
			std::cin >> c;
			if (c == '#')
			{
				if (j & 1)
					b[i][j] = '#';
				else
					a[i][j] = '#';
			}
		}
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= m; j ++)
			std::cout << a[i][j];
		printf("\n");
	}
	printf("\n");
	for (int i = 1; i <= n; i ++)
	{
		for (int j = 1; j <= m; j ++)
			std::cout << b[i][j];
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1280
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	int ans = 1;
	while(N--){
		if( ans*2 < ans+K ){
			ans *= 2;
		}else{
			ans += K;
		}
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

Measured memory_bytes: 256
#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA cerr << "AAAAA" << endl
#define debug_ cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                     \
    cout << #v << endl;                  \
    for (int i = 0; i < v.size(); i++) { \
        cout << v[i] << " ";             \
    }                                    \
    cout << endl;
#define debug_vec2(v)                           \
    cout << #v << endl;                         \
    for (int i = 0; i < v.size(); i++) {        \
        for (int j = 0; j < v[i].size(); j++) { \
            cout << v[i][j] << " ";             \
        }                                       \
        cout << endl;                           \
    }

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
void quit(T a) {
    cout << a << endl;
    exit(0);
}

using Graph = vector<vector<int>>;
using P = pair<int, int>;
using P1 = pair<int, pair<int, int>>;  // クラスカル法とかで、{cost, {from,
                                       // to}}的に使う。
const ll LINF = 10010020030040056ll;
const int INF = 1001001001;
const double pi = acos(-1);

int main() {
    int a, b;
    cin >> a >> b;
    int cnt = 1;
    for (int i = 0; i < 100; i++) {
        if (cnt >= b) {
            cout << i << endl;
            return 0;
        }
        cnt = cnt + a - 1;
    }

    return 0;
}


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

using namespace std;

long long n;
vector<long long > A;

long long solve(int p) {
  long long res = 0;
  long long curr = 0;
  for (int i = 0; i < n; ++i) {
    if ((i+p)%2 == 0) {
      if (curr + A[i] <= 0) {
        res += abs(curr+A[i]-1);
        curr = 1;
      } else {
        curr += A[i];
      }
    } else {
      if (curr + A[i] >= 0) {
        res += abs(curr+A[i]+1);
        curr = -1;
      } else {
        curr += A[i];
      }
    }
  }
  return res;
}


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

  cin >> n;
  A.resize(n);
  for (auto &a : A) cin >> a;
  cout << min(solve(0), solve(1)) << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

ll dp[110][100100] = {0};

int main() {

    int n, W;
    cin >> n >> W;
    
    vector<int> w(n), v(n);
    for(int i = 0; i < n; i++) {
        cin >> w[i] >> v[i];
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j <= W; j++) {
            if (j - w[i] >= 0)
                chmax(dp[i+1][j], dp[i][j-w[i]]+v[i]);
            chmax(dp[i+1][j], dp[i][j]);
        }
    }

    cout << dp[n][W] << endl;



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

Measured memory_bytes: 79360
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	d := nextInt()
	clist := make([]int, 26)
	for i := 0; i < 26; i++ {
		clist[i] = nextInt()
	}
	var slist [365][26]int
	for i := 0; i < d; i++ {
		for j := 0; j < 26; j++ {
			tmp := nextInt()
			//fmt.Println(tmp)
			slist[i][j] = tmp
		}
	}

	tlist := make([]int, d)
	last := map[int]int{}

	for i := 0; i < d; i++ {
		tlist[i] = nextInt() - 1
	}

	vlist := make([]int, d)
	for i := 0; i < d; i++ {
		todaytype := tlist[i]
		last[todaytype] = i + 1

		// 基礎満足度増加計算
		if i == 0 {
			vlist[i] += slist[i][todaytype]
		} else {
			vlist[i] += vlist[i-1] + slist[i][todaytype]
		}

		// 満足度低下計算
		teika := 0
		for j := 0; j < 26; j++ {
			teika += clist[j] * (i + 1 - last[j])
		}
		vlist[i] -= teika
	}

	// 出力
	for i := 0; i < d; i++ {
		fmt.Printf("%d\n", vlist[i])
	}

}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 2004
n = int(input())
s = []
for i in range(n):
    s.append(input())
s.sort()
a = []
an = 0
t = ''
tn = 0
s.append('')
for si in s:
    if si != t:
        if tn > an:
            a = [t]
            an = tn
        elif tn == an:
            a.append(t)
        t = si
        tn = 0
    tn += 1
print('\n'.join(a))

Measured memory_bytes: 24136
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;


int main() {
	
	string h;
	cin >> h;
	int i = 0;
	while(i<h.size()){
		string a, b;
		a = h.substr(i, 5);
		b = h.substr(i, 2);
	//	if (b == "er")i += 2;
		if (a == "dream") {
			i += 5;
			b = h.substr(i, 2);
			
		if (b == "er"&&(h[i+2]=='d'|| h[i + 2] == 'e'||i+2>=h.size()))i += 2;

		}
		else if (a == "erase") {
			i += 5;
			b = h.substr(i, 1);
			if (b == "r"&&(h[i + 1] == 'd' || h[i + 1] == 'e'||i+1>=h.size()))i += 1;
		}
		
		else {
			cout << "NO" << endl;
			return 0;
		}//cout << a;
	}
	cout << "YES" << endl;

	return 0;

}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int gcd(int a, int b) {
    while (a && b) {
        if (a >= b)
            a %= b;
        else
            b %= a;
    }
    return a + b;
}

int main() {
    #ifdef LOCAL
    assert(freopen("a.in", "r", stdin));
    #else
    #endif
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    forn (i, n)
        cin >> a[i];
    sort(all(a));
    int g = 0;
    forn (i, n) {
        g = gcd(g, a[i]);
    }
    if (k <= a[n - 1] && k % g == 0) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long A, long long B, long long C, long long K){
  for(long long i = 0; i <= K; i++) {
    for(long long j = 0; j <= K; j++) {
      for(long long k = 0; k <= K; k++) {
        if((i+j+k) <= K && (A*pow(2, i)) < (B*pow(2, j)) && (B*pow(2, j)) < (C*pow(2, k))) {
          cout << YES << endl;
          return;
        }
      }
    }
  }

  cout << NO << endl;
}


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  long long C;
  scanf("%lld",&C);
  long long K;
  scanf("%lld",&K);
    solve(A, B, C, K);
    return 0;
}


Measured memory_bytes: 4156
import itertools
from sys import stdin

N = list(map(int, stdin.readline().strip().split()))[0]
st = list(stdin.readline().strip())
count = 0
stt = set(st)
stt = list(stt)
num = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
num = [s for s in num if s in stt]
num_list = ["".join(i) for i in itertools.product(num, repeat=3)]
cnt = 0
for number in num_list:

    for i in range(N):
        if number[cnt] == st[i]:
            cnt += 1
            if cnt==2:
                if number[cnt] in st[i+1:]:
                    count+=1
                break
    cnt = 0

print(count)

Measured memory_bytes: 3700
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
   int a[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
   int N ; 
   cin >> N ;
   cout << a[N-1] << endl;
}

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

int dp[100001] ;

int mex(set<int> s){
    int i =0 ;
    while(s.find(i)!=s.end())i++;
    return i;
}

int grundy(int *arr,int k,int n){

    if(k==0) return 0;
    if(dp[k]!=-1) return dp[k];

    set<int> s;

    for(int i = 0 ; i < n ; i++) if(k-arr[i]>=0 )s.insert(grundy(arr,k-arr[i],n));

    return dp[k] = mex(s);

}


int main(){

    for(int i = 0 ;i < 100001;i++) dp[i] = -1;
    int n,k;
    cin >> n >> k;
    int *arr = new int[n];
    for(int i =0 ;i < n ;i++) cin >> arr[i];
    int a = grundy(arr,k,n);
    if(a==0) cout << "Second";
    else cout << "First";
}


Measured memory_bytes: 20992
H,W = map(int,input().split())
s = [input() for _ in range(H)]
if H==1 and W==1:
    if s[0][0] == '.':print('Yes')
    else:print('No')
else:
    island = False
    for i in range(H):
        for j in range(W):
            if s[i][j] == '#':
                bis = False
                if i-1>=0:
                    if s[i-1][j] == '#':bis = True
                if i+1<H:
                    if s[i+1][j] == '#':bis = True
                if j-1>=0:
                    if s[i][j-1] == '#':bis = True
                if j+1<W:
                    if s[i][j+1] == '#':bis = True
                if bis == False:
                    island = True
    if island:
        print('No')
    else:
        print('Yes')

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

#include <bits/stdc++.h>

using namespace std;

class agc029_b {
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            in >> A[i];
        }
        sort(begin(A), end(A));
        reverse(begin(A), end(A));
        constexpr int MXT = 30;
        int res = 0;
        map<int, set<int>> ind;
        for (int i = 0; i < N; ++i) {
            ind[A[i]].insert(i);
        }
        multiset<int> seen;
        for (int i = 0; i < N; ++i) {
            if (A[i] >= 1) {
                for (int shift = 0; shift <= MXT; ++shift) {
                    int val = (1 << shift);
                    int need = val - A[i];
                    auto it = seen.find(need);
                    if (it != end(seen)) {
                        seen.erase(it);
                        ind[A[i]].erase(i);
                        A[*ind[need].begin()] = 0;
                        ind[need].erase(ind[need].begin());
                        A[i] = 0;
                        ++res;
                        break;
                    }
                }
            }
            if (A[i] >= 1) {
                seen.insert(A[i]);
            }
        }
        out << res << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	agc029_b solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 38528
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint k;
    cin >> k;

    if (k == 2 || k == 5) {
        cout << "-1" << endl;
        exit(0);
    }

    lint cur = 7 % k;
    lint mul = 70;
    int res = 1;

    while (cur != 0) {
        cur += mul;
        cur %= k;
        mul *= 10;
        mul %= k;
        res++;
        if (res >= k+2) {
            cout << "-1" << endl;
            exit(0);
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3576
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	fmt.Scan(&a, &b)

	switch {
	case math.Abs(a-b) >= 1:
		fmt.Println(math.Max(a, b)*2 - 1)
	case math.Abs(a-b) < 1:
		fmt.Println(math.Max(a, b) * 2)
	}
}


Measured memory_bytes: 1836
#include <stdio.h>

int main(void){
    // Your code here!
    int N,K;
    int ans = 1;
    
    scanf("%d%d",&N,&K);
    
    for(int i=0;i<N-1;i++){
        ans *= (K-1);
    }
    
    printf("%d\n",ans*K);
}


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

int main(){

    int n;
    string s;
    cin >> n >> s;

    int lookatright[n];
    int lookatleft[n];

    lookatleft[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i-1] == 'W'){
            lookatleft[i] = lookatleft[i-1] + 1;
        }else{
            lookatleft[i] = lookatleft[i-1];
        }
    }

    lookatright[n-1] = 0;
    for(int i=n-2; i>=0; i--){
        if(s[i+1] == 'E'){
            lookatright[i] = lookatright[i+1] + 1;
        }else{
            lookatright[i] = lookatright[i+1];
        }
    }

    int min_num = 1000000000;
    for(int i=0; i<n; i++){
        min_num = min(min_num, lookatright[i] + lookatleft[i]);
    }

    cout << min_num << endl;
    return 0;
}

Measured memory_bytes: 3076
#include<stdio.h>
int main(void){
  int X,Y,W,H,N;
  int num;
  int cat=0;
  int i,j;
  int x[101],y[101];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    cat=0;
    scanf("%d %d %d %d",&X,&Y,&W,&H);
    scanf("%d",&N);
    for(j=0;j<N;j++){
      scanf("%d %d",&x[j],&y[j]);
      if((x[j]>=X && x[j]<=X+W) && (y[j]>=Y && y[j]<=Y+H))
	cat++;
    }
    printf("%d\n",cat);
  }
  return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = 0;
  set<ll> s;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      s.insert(i);
      s.insert(n / i);
    }
  }
  for (auto &a : s) {
    ll m = n / a - 1;
    if (m <= 0) continue;
    if (n % m == n / m)
      ans += m;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {

    int A, B, C;
    cin >> A >> B >> C;

    int tmp = A;
    int i = 0;
    while (tmp <= B) {
        tmp += A;
        i += 1;
        if (i == C)
            break;
    }
    cout << i << endl;
    return 0;
}


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VI a(n);
  rep(i, n) cin >> a[i];

  int tmp =  n + 10000;
  int ans = 0;
  rep(i, n) {
    if (tmp > a[i]) ans++;
    tmp = min(tmp, a[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
def modpow(d, b, p, mod=2019):
    ret = 1
    while p > 0:
        if p % 2 == 1:
            ret = ret * b % mod
        b = b * b % mod
        p //= 2
    return (d * ret) % mod


S = input()
C = [0]
for i in range(len(S)):
    C.append((C[-1] + modpow(int(S[-(i + 1)]), 10, i)) % 2019)
Cd, C0 = {}, 0
for c in C[1:]:
    if c == 0:
        C0 += 1
    else:
        Cd[c] = Cd.get(c, 0) + 1
print(C0 + C0 * (max(0, C0 - 1)) // 2
      + sum([v * (v - 1) // 2 for v in Cd.values()]))


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, C;
  cin >> N >> C;
  int maxc = 100000;
  vector<vector<int>> CS(C, vector<int>(maxc + 1, 0));
  for (int i = 0; i < N; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    c--;
    CS[c][s - 1]++, CS[c][t]--;
  }
  for (int c = 0; c < C; c++) {
    for (int i = 0; i < maxc - 1; i++) {
      CS[c][i + 1] += CS[c][i];
    }
  }
  int res = 0;
  for (int i = 0; i < maxc - 1; i++) {
    int cnt = 0;
    for (int c = 0; c < C; c++) {
      if (CS[c][i] > 0) cnt++;
    }
    res = max(res, cnt);
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
int main() {
	int x; cin >> x;
	int ans = 1;
	for(int i=1;i*i<=x;i++){
		int a = i*i;
		for(int j=1;j<=x;j++){
			if(a<=x && a*i<=x){
				a*=i;
			}else if(a<=x && a*i>x){
				break;
			}
		}
		ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10 , OO = 0x3f3f3f3f;

#define clr(arr,val) memset(arr , val , sizeof (arr))
#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n)-1;i >= 0;i--)
#define xloop(i,a,b) for(int i = int(a);i <= int(b);i++)
#define range(n) for(int &x : n) cin >> x;
#define ALL(v) ((v).begin()) , ((v).end())
#define SZ(v)  ((int)((v).size()))
typedef pair <int,int> pii ;
typedef vector < pii > vii ;
typedef vector < int > vi;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
//int dx[]={2,1,-1,-2,-2,-1,1,2};int dy[]={1,2,2,1,-1,-2,-2,-1};//Knight Direction
//int dx[6]={2,1,-1,-2,-1,1};int dy[6]={0,1,1,0,-1,-1}; //Hexagonal Direction
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

int rkm1 , rkm2;


int main()
{   

      ios_base::sync_with_stdio(0) , cin.tie(0);cout.tie(0);

      cin >> rkm1 >> rkm2;
      if(rkm1 >= 1 && rkm1 <= 9 && rkm2 >= 1 && rkm2 <= 9)
            cout << (rkm1*rkm2) << "\n";
      else cout << "-1\n";





    
      return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <climits>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define si(x) int x = scanInt();
#define sll(x) LL x = scanLong();
#define sci(x) int x; scanf("%d", &x);
#define scll(x) LL x; scanf("%lld", &x);
#define pi(x) printf("%d ", x)
#define pll(x) printf("%lld ", x)
#define nl printf("\n")
#define clr(a) memset(a, 0, sizeof(a))
#define PB push_back
#define MP make_pair
using namespace std;
typedef unsigned int UI; // 32 bit integer
typedef long int LI; // 32 bit integer
typedef unsigned long int ULI; // 32 bit unsigned integer
typedef long long int LL; // 64 bit integer
typedef unsigned long long int  ULL; // 64 bit unsigned integer
typedef long double LD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
const LL MOD = 1e9+7;

/* Fast I/O */
inline int scanInt() {
	int n = 0;
	char ch = getchar();
	int sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(int)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

inline LL scanLong() {
	LL n = 0;
	char ch = getchar();
	LL sign = 1;
	while(ch < '0' || ch > '9') {
		if(ch == '-')	sign = -1;
		ch = getchar();
	}
	while(ch >= '0' && ch <= '9') {
		n = (n<<1)+(n<<3)+(LL)(ch-'0');
		ch = getchar();
	}
	return n*sign;
}

int main() {
	sll(a); sll(b); sll(k);
	VLL divs;
	rep(d, 101, 1) {
		if(a%d == 0 && b%d == 0)	divs.push_back(d);
		if(divs.size() >= k)	break;
	}
	pll(divs[k-1]); nl;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    int A[2][N];
    int u[N], d[N];

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

    u[0] = A[0][0];
    d[N-1] = A[1][N-1];

    for(int i=1; i<N; i++){
        u[i] = u[i-1] + A[0][i];
        d[N - i - 1] = d[N-i] + A[1][N - i - 1];
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        int temp = u[i] + d[i];
        ans = max(ans, temp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<complex>
#include<cmath>
using namespace std;typedef double elem;typedef complex<elem> point,vec;
const elem eps=1.0e-8;
#define ERR 0x00
#define FRONT 0x01
#define RIGHT 0x02
#define BACK 0x04
#define LEFT 0x08
#define OVER 0x10
point origin(0,0);bool eq(elem a, elem b){ return abs(a-b) < eps; }bool lt(elem a, elem b){ return !eq(a,b) && a < b; }bool leq(elem a, elem b){ return eq(a,b) || a < b; }bool gt(elem a, elem b){ return !eq(a,b) && a > b; }bool geq(elem a, elem b){ return eq(a,b) || a > b; }bool ltz(elem a){ return lt( a, 0 ); }bool gtz(elem a){ return gt( a, 0 ); }elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); }elem dist(point a, point b){ return abs(a-b); }int ccw(point a, point b, point x){vec vb = b - a;vec vx = x - a;elem z = cross( vb, vx );if( eq(abs(vb),0) )return ERR;if( eq(z,0) ){elem d_ab = dist(a,b);elem d_bx = dist(b,x);elem d_ax = dist(a,x);if( eq(d_ab,d_ax+d_bx) )return OVER;if( gt( d_ax, d_ab ) && gt( d_ax, d_bx ) )return FRONT;if( gt( d_bx, d_ab ) && gt( d_bx, d_ax ) )return BACK;}else if( gtz( z ) )return LEFT;else if( ltz( z ) )return RIGHT;return ERR;}int main(){while(true){double D,px,py,vx,vy;scanf("%lf",&D);if(D==0)break;scanf("%lf%lf%lf%lf",&px,&py,&vx,&vy);point p(px,py);vec v(vx,vy);int progress = ccw(p,p+v,origin);double going = -1;if(progress&(FRONT|OVER)&&leq(dist(p,origin),D))going=dist(p,origin);else if(progress&BACK&&leq(2-dist(p,origin),D))going=2-dist(p,origin);if(gtz(going))printf("%.6lf\n",going);else puts("impossible");}return 0;}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define inf 100000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
 
using namespace std ;

typedef tree<lli,null_type,less<lli>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define N 400000+5


int main () 
{
/////////////////////////////////////
    
    fastio;

    string s;
    cin>>s;

    loopl(i,1,4)
    {
        if(s[i] == s[i-1])
        {
            cout<<"Bad";
            return 0;
        }
    }

    cout<<"Good";


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  vector<ll> xx, yy;
  for (ll i = 0; i <= F; i++)
  {
    for (ll j = 0; j <= F; j++)
    {
      ll x = 100 * A * i + 100 * B * j;
      ll y = C * i + D * j;
      if (x <= F) xx.push_back(x);
      if (y <= F) yy.push_back(y);
    }
  }

  ll X = 100 * A, Y = 0;
  for (ll i = 0; i < xx.size(); i++)
  {
    for (ll j = 0; j < yy.size(); j++)
    {
      ll x = xx.at(i), y = yy.at(j);

      if (x + y > F)
        continue;
      if (100 * y > x * E)
        continue;
      
      if (y * (X + Y) > Y * (x + y))
        X = x, Y = y;
    }
  }

  cout << X + Y << " " << Y << endl;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <string.h>

#define L 14
#define M 1052693//1000000に近い素数

char H[M][L];

int GetChar(char c);
long long GetKey(char *c);
int h1(int);
int h2(int);
int h(int,int);
int find(char *c);
int insert(char *c);

int main(){
    int n,i;
    char ins[] = "insert";
    char fin[] ="find";
    scanf("%d",&n);

    for(i=0; i<M; i++) H[i][0] = '\0';

    for(i=0; i<n; i++){

        char order[7],str[L];
        scanf("%s %s",order,str);

        if(strcmp(order,ins) == 0){
            insert(str);
        }else if(strcmp(order,fin) == 0){
            if(find(str)) printf("yes\n");
            else printf("no\n");
        }
    }

    return 0;
}



int GetChar(char c){
    if(c == 'A') return 1;
    else if(c == 'C') return 2;
    else if(c == 'G') return 3;
    else if(c == 'T') return 4;
}

long long GetKey(char c[]){
    long long i,p=1,sum = 0;
    for(i=0; i<strlen(c); i++){
        sum += p*(GetChar(c[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return key%M;
}

int h2(int key){
    return 1+key%(M-1);    
}

int h(int key,int i){
    return (h1(key)+i*h2(key))%M;
}

int find(char c[]){
    long long key,ind,i=0;
    key = GetKey(c);
    while(1){
        ind = h(key,i);
        if(strcmp(c,H[ind]) == 0) return 1;
        else if (strlen(H[ind]) == 0) return 0;
        i++;
    }
}

int insert(char c[]){
    long long i=0,j,key;
    key = GetKey(c);
    while(1){
        j = h(key,i);
        if(strcmp(c,H[j]) == 0) return 1;
        else if(strlen(H[j]) == 0){
            strcpy(H[j],c);
            return 0;
        }
        i++;
    }
}



Measured memory_bytes: 17032
def resolve():
    n = int(input())
    t_b, x_b, y_b = 0, 0, 0
    count = 0
    for i in range(1, n+1):
        t, x, y = map(int, input().split())
        dist = abs(x-x_b) + abs(y-y_b)
        dt = abs(t-t_b)
        if dist <= dt and dist % 2 == dt % 2:
            t_b, x_b, y_b = t, x, y
            count += 1
    print("Yes" if count == n else "No")

if __name__ == '__main__':
    resolve()

Measured memory_bytes: 48344
package main

import "fmt"

func main() {
	card := make([][]int, 4)
	for i := 0; i < 4; i++ {
		card[i] = make([]int, 13)
	}

	var n int
	fmt.Scanf("%d", &n)

	for i := 0; i < n; i++ {
		var c string
		var x int
		fmt.Scanf("%s %d", &c, &x)
		if c == "S" {
			card[0][x-1] = 1
		} else if c == "H" {
			card[1][x-1] = 1
		} else if c == "C" {
			card[2][x-1] = 1
		} else {
			card[3][x-1] = 1
		}
	}

	for i := 0; i < 4; i++ {
		for j := 0; j < 13; j++ {
			if card[i][j] == 0{
				if i == 0{
					fmt.Printf("S %d\n",j+1)
				}else if i == 1{
					fmt.Printf("H %d\n",j+1)
				}else if i == 2{
					fmt.Printf("C %d\n",j+1)
				}else{
					fmt.Printf("D %d\n",j+1)
				}
			}
		}
	}
}



Measured memory_bytes: 1132
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    
    long n,k,q,a[100000];
    
    scanf("%ld%ld%ld",&n,&k,&q);
    for(int i=0;i<q;i++) scanf("%ld",&a[i]);
    
    long nn[100000+1]={0};
    
    for(int i=0;i<q;i++) nn[a[i]]++;
    
    for(int i=1;i<=n;i++){
        if(nn[i]+(k-q)>0) printf("Yes\n");
        else printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int V[N];
  for(int i = 0; i < N; i++) cin >> V[i];
  sort(V, V + N);
  double total_value = V[0];
  for(int i = 0; i < N; i++) total_value = (double(V[i]) + total_value) / 2;
  cout << setprecision(15) << total_value << endl;
  return 0;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int k=fsc.nextInt(), x=fsc.nextInt();
        fsc.close();
        System.out.println(k*500>=x?"Yes":"No");
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21204
#include<iostream>

using namespace std;

int main(void){

    int a, b;

    cin >> a >> b;

    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

int main(){
    int n, x;
    cin >> n >> x;
    vector<int> A(n);
    REP(i, n) cin >> A[i];

    int cnt = 0;
    sort(A.begin(), A.end());
    REP(i, n){
        x -= A[i];
        cnt++;
    }
    cnt += x / A[0];
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
n, m, q = map(int, input().split())
#line = [list(map(int, input().split())) for _ in range(m)]
ans = [[0] * (n + 1) for _ in range(n + 1)]
for _ in range(m):
	l, r = map(int, input().split())
	l -= 1
	r -= 1
	ans[0][r] += 1
	ans[l + 1][n] += 1
	ans[0][n] -= 1
	ans[l + 1][r] -= 1

for i in range(n + 1):
	for j in range(n):
		ans[i][j + 1] += ans[i][j]

for j in range(n + 1):
	for i in range(n):
		ans[i + 1][j] += ans[i][j]

for _ in range(q):
	p, q = map(int, input().split())
	print(ans[p - 1][q - 1])

Measured memory_bytes: 9588
h, w = map(int, input().split())
a = [''] * h
for i in range(h):
	a[i] = input()
 
row = [False] * h
col = [False] * w
for i in range(h):
	for j in range(w):
		if a[i][j] == '#':
			row[i] = True
			col[j] = True
            
for i in range(h):
	if row[i]:
		for j in range(w):
			if col[j]:
				print(a[i][j], end = '')
		print()

Measured memory_bytes: 4468
#include<bits/stdc++.h>
using namespace std;
int gcd(int x, int y){
 if (x < y) swap(x, y);
 if (x % y) return gcd (y, x%y);
 return y;
}   
int main(){
    int K, ans = 0, temp;
    cin >> K;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= K; j++){
            for(int k = 1; k <= K; k++){
                temp = gcd(i, j);
                ans += gcd(temp, k);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <sstream>
#include <cstdlib>

using namespace std;

int main()
{
   long x;
   cin>>x;
   long a;
   a=x/500;
   int b;
   b=x%500;
   int c;
   c=b%5;
   cout<<a*1000+b-c<<endl;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> ans;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        ans[s]++;
    }
    cout << "AC" << " " << "x" << " "  << ans["AC"] << "\n";
    cout << "WA" << " " << "x" << " "  << ans["WA"] << "\n";
    cout << "TLE" << " " << "x" << " " << ans["TLE"] << "\n";
    cout << "RE" << " " << "x" << " " << ans["RE"] << "\n";

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A, 0), t(B, 0);
    for(int i = 0; i < A; i++) cin >> s[i];
    for(int i = 0; i < B; i++) cin >> t[i];
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());

    for(int i = 0; i < Q; i++) {
        ll x;
        cin >> x;
        ll ans = LLINF;

        int sp = lower_bound(s.begin(), s.end(), x) - s.begin();
        int tp = lower_bound(t.begin(), t.end(), x) - t.begin();
        vector<int> S, T;
        if(sp < A) S.push_back(sp);
        if(tp < B) T.push_back(tp);
        if(sp > 0) S.push_back(sp-1);
        if(tp > 0) T.push_back(tp-1);
        for(auto ss: S) {
            tp = lower_bound(t.begin(), t.end(), s[ss]) - t.begin();
            if(tp < B) T.push_back(tp);
            if(tp > 0) T.push_back(tp-1);
        }
        for(auto tt: T) {
            sp = lower_bound(s.begin(), s.end(), t[tt]) - s.begin();
            if(sp < A) S.push_back(sp);
            if(sp > 0) S.push_back(sp-1);
        }
        for(auto ss : S) for(auto tt :T) {
            ans = min(ans, abs(x - s[ss]) + abs(s[ss] - t[tt]));
        }
        for(auto tt : T) for(auto ss : S) {
            ans = min(ans, abs(x - t[tt]) + abs(t[tt] - s[ss]));
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
import sys
inf = sys.maxsize

n, k = map(int,input().split())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[0] = 0
for i in range(1,n):
    if i < k:
        dp[i] = inf
        for j in range(1, i + 1):
            if dp[i - j] + abs(h[i] - h[i - j]) < dp[i]:
                dp[i] = dp[i - j] + abs(h[i] - h[i - j])
    elif i >= k:
        dp[i] = inf
        for j in range(1, k + 1):
            if dp[i - j] + abs(h[i] - h[i - j]) < dp[i]:
                dp[i] = dp[i - j] + abs(h[i] - h[i - j])
print(dp[n - 1])


Measured memory_bytes: 52704
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 
#define int long long
#define double long double

////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////


signed main(){
  int n,a[110];cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n){
    if(a[i] % 2 == 0 && a[i] % 3 != 0 && a[i]%5 != 0){
      cout << "DENIED" << endl;return 0;
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


Measured memory_bytes: 2148