akhauriyash/Code-Regression huggingface dataset:
H,W,Q,y,x,y1,x1,
A[2001][2001],
B[2001][2001],
C[2001][2001];
char S[2001][2001];
main(){
	scanf("%d%d%d%*c",&H,&W,&Q);
	for(y=0;y++<H;){
		gets(S[y]+1);
	}
	for(y=0;y++<H;){
		for(x=0;x++<W;){
			A[y][x]=A[y][x-1]+A[y-1][x]-A[y-1][x-1]+S[y][x]%2;
			B[y][x]=B[y][x-1]+B[y-1][x]-B[y-1][x-1]+S[y-1][x]*S[y][x]%2;
			C[y][x]=C[y][x-1]+C[y-1][x]-C[y-1][x-1]+S[y][x-1]*S[y][x]%2;
		}
	}
	for(;~scanf("%d%d%d%d",&y1,&x1,&y,&x);){
		printf("%d\n",
			A[y][x]-A[y1-1][x]-A[y][x1-1]+A[y1-1][x1-1]
			-(B[y][x]-B[y1][x]-B[y][x1-1]+B[y1][x1-1])
			-(C[y][x]-C[y1-1][x]-C[y][x1]+C[y1-1][x1])
		);
	}
}


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

const int MAXN = 1<<17;
const int UNSET = -1;


vector<vector<int>> g;
int dp[MAXN];


int dfs(int u) {
  if (dp[u] != UNSET) return dp[u];
  dp[u] = 0;
  for (int v : g[u]) {
    dp[u] = max(dfs(v) + 1, dp[u]);
  }
  return dp[u];
}


int main () {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int N, M; cin >> N >> M;
  g.resize(N);
  fill(dp, dp + N, UNSET);


  for (int i = 0; i < M; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    g[u].push_back(v);
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) ans = max(dfs(i), ans);
  cout << ans << '\n';



}


Measured memory_bytes: 7552
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(i,a,b) for (int i=(a),for_##i##_max=(b);i<=(for_##i##_max);++i)
#define RFOR(i,a,b) for (int i=(a),rfor_##i##_min=(b);i>=(rfor_##i##_min);--i)
#define REP(i,n) for (int i=0,rep_##i##_len=(n);i<(rep_##i##_len);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

namespace { // Basics

template<typename T>
void chmin(T &x, T y) {
  x = std::min(x, y);
}

template<typename T>
void chmax(T &x, T y) {
  x = std::max(x, y);
}

template<typename T>
__attribute__((unused))
const auto minimum = static_cast<T const &(*)(T const &, T const &)>(std::min);

template<typename T>
__attribute__((unused))
const auto maximum = static_cast<T const &(*)(T const &, T const &)>(std::max);

template<typename T>
int cmp3(T lhs, T rhs) { return (lhs == rhs) ? 0 : (lhs > rhs) ? 1 : -1; }

template<typename T>
__attribute__((unused))
T constexpr infty = std::numeric_limits<T>::max / 3;
template<>
__attribute__((unused))
auto constexpr infty<int> = 1'100'100'100;
template<>
__attribute__((unused))
auto constexpr infty<long long int> = 100'500'400'300'200'100LL;

using lli = long long int;
using ld = long double;

} // namespace

using namespace std;

lli solve(int n, lli limit, vector<tuple<lli,lli>> const &jewels) {
  lli const vmax = accumulate(begin(jewels), end(jewels), 10,
      [](auto x, auto jw) { return x + get<1>(jw); });
  vector<lli> dp(vmax, infty<lli>);
  dp[0] = 0;
  for(auto &&jwl: jewels) {
    lli w, v; tie(w, v) = jwl;
    RFOR(i, vmax, v) { chmin(dp[i], w + dp[i-v]); }
  }
  int ans = 0;
  REP(i, vmax) {
    if (limit >= dp[i]) { ans = i; }
  }
  return ans;
}

int main() {
  int N, W; cin >> N >> W;
  vector<tuple<lli,lli>> jewels;
  REP(i, N) {
    lli Wi, Vi; cin >> Wi >> Vi;
    jewels.emplace_back(Wi, Vi);
  }
  cout << solve(N, W, jewels) << endl;
  return 0;
}


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

int main()
{
	int a,b,size,flag=0;
	char s[102]={},t[102]={};
	
	scanf("%s %s",s,t);

	for(a=0;a<102;a++)
	{
		if(s[a]=='\0')break;
	}
	size=a;

	for(a=0;a<size;a++)
	{
		for(b=0;b<size;b++)
		{
			if(s[b]!=t[(b+a)%size])break;
		}
		if(b==size)
		{
			flag=1;
			break;
		}
	}

	if(flag==1)printf("Yes\n");
	else printf("No\n");


	return 0;
}

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    vector<int> B(M);
    for (int i = 0; i < M; ++i) {
        cin >> B[i];
    }
    int A[20][20] = {};
    for (int i = 0; i < N; ++i) {
        for (int k = 0; k < M; ++k) {
            cin >> A[i][k];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int sum = C;
        for (int k = 0; k < M; ++k) {
            sum += A[i][k] * B[k];
        }
        if (sum > 0) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    //const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<pair<i64,i64>> xy(N);
    rep(i,0,N) cin >> xy[i].first >> xy[i].second;

    i64 maxi=100000;
    vector<vector<i64>> l(maxi),r(maxi);
    rep(i,0,N){
        --xy[i].first;
        --xy[i].second;
        l[xy[i].first].emplace_back(xy[i].second);
        r[xy[i].second].emplace_back(xy[i].first);
    }

    vector<bool> donel(maxi),doner(maxi);
    i64 cntl=0,cntr=0;
    function<void(i64,i64)> dfs=[&](i64 lr,i64 u){
        if(lr==0){
            donel[u]=true;
            ++cntl;
            for(auto v:l[u]){
                if(doner[v]) continue;
                dfs(1,v);
            }
        }else {
            doner[u] = true;
            ++cntr;
            for(auto v:r[u]){
                if(donel[v]) continue;
                dfs(0,v);
            }
        }
    };

    i64 ans=0;
    rep(u,0,maxi){
        if(donel[u]) continue;
        dfs(0,u);
        ans+=cntl*cntr;
        cntl=0;
        cntr=0;
    }

    ans-=N;

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 14592
import bisect

N=int(input())
L=list(map(int, input().split()))

L.sort()
#print(L)
count=0

for i in reversed(range(2,N)):
  for j in reversed(range(1,i)):
    index=bisect.bisect_right(L,L[i]-L[j])
    #print(index,j,i)
    if index<j:
     count += j-index
            
print(count)
        


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

#define all(x) (x).begin(), (x).end()
#define li long long
#define itn int

using namespace std;

inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

void panic() {
	puts("No");
	exit(0);
}

int main(){

	int r = nxt(), c = nxt();
	int n = nxt();
	vector<vector<pair<int, int>>> R(r), C(c);
	vector<pair<int, int>> cells;
	for (int i = 0; i < n; i++) {
		int x = nxt() - 1, y = nxt() - 1, v = nxt();
		// R[x][y] = C[y][x] = v;
		R[x].push_back({y, v});
		C[y].push_back({x, v});
		cells.push_back({x, y});
	}

	for (int i = 0; i < r; i++) {
		sort(all(R[i]));
	}
	for (int i = 0; i < c; i++) {
		sort(all(C[i]));
	}

	vector<int> vals;
	for (int i = 0; i < r; i++) {
		for (auto p : R[i]) {
			vals.push_back(p.second);
		}
	}

	vector<vector<int>> ind_r(r), ind_c(c);
	sort(all(cells));
	int cur = 0;
	for (int i = 0; i < r; i++) {
		for (const auto& p : R[i]) {
			ind_r[i].push_back(cur++);
		}
	}

	for (itn i = 0; i < c; i++) {
		for (const auto& p : C[i]) {
			ind_c[i].push_back(lower_bound(all(cells), make_pair(p.first, i)) - cells.begin());
		}
	}

	vector<char> used(n);

	vector<long long> add_r(r, 0), add_c(c, 0);
	vector<char> set_r(r), set_c(c);

	for (int i = 0; i < n; i++) {
		if (!used[i]) {
			vector<int> st(1, i);
			used[i] = 1;
			add_r[cells[i].first] = 0;
			add_c[cells[i].second] = vals[i];
			set_r[cells[i].first] = set_c[cells[i].second] = 1;
			long long min_r = 0, min_c = add_c[cells[i].second];
			long long max_r = min_r, max_c = min_c;
			while (!st.empty()) {
				int x = cells[st.back()].first;
				int y = cells[st.back()].second;
				st.pop_back();
				for (int j = 0; j < (int)R[x].size(); j++) {
					// if (it->first == y) {
					// 	continue;
					// }
					int index = ind_r[x][j];
					if (used[index]) {
						continue;
					} else {
						if (set_c[R[x][j].first]) {
							if (add_r[x] + add_c[R[x][j].first] != R[x][j].second) {
								panic();
							}
						} else {
							set_c[R[x][j].first] = 1;
							add_c[R[x][j].first] = R[x][j].second - add_r[x];
							min_c = min(min_c, add_c[R[x][j].first]);
							max_c = max(max_c, add_c[R[x][j].first]);
						}
						st.push_back(index);
						used[index] = 1;
					}
				}
				for (int j = 0; j < (int)C[y].size(); j++) {
					// if (it->first == y) {
					// 	continue;
					// }
					int index = ind_c[y][j];
					if (used[index]) {
						continue;
					} else {
						if (set_r[C[y][j].first]) {
							if (add_r[C[y][j].first] + add_c[y] != C[y][j].second) {
								panic();
							}
						} else {
							set_r[C[y][j].first] = 1;
							add_r[C[y][j].first] = C[y][j].second - add_c[y];
							min_r = min(min_r, add_r[C[y][j].first]);
							max_r = max(max_r, add_r[C[y][j].first]);
						}
						st.push_back(index);
						used[index] = 1;
					}
				}
			}
			if (min_c + min_r < 0) {
				panic();
			}
		}
	}

	puts("Yes");

	return 0;
}


Measured memory_bytes: 25204
/*Author : Kartik Bansal
 *Date : 07/09/19
 *Time : 16:14 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
#define tc int t ;cin>>t ;while(t--)
#define pb push_back
#define FOR(i,n) for(int i =0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin() , v.end()
#define sort(v) sort(all(v))
#define vi  vector<int>
#define vll  vector<long long >
#define inf INT_MAX
#define minf INT_MIN
int32_t main()
{
  ios::sync_with_stdio(0) ;
  cin.tie(0) ; cout.tie(0) ;
  int n ;
  cin>>n ;
  vi v(n) ,temp(n) ;
  FOR(i,n)
    cin>>v[i] ;
    int i = 1 ;
for(auto it : v)
    {
        temp[it-1 ] = i  ;
        i++ ;
    }
    for(auto it : temp)
        cout<<it <<" " ;

  return 0 ;
}


Measured memory_bytes: 1664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    int N,M; cin>>N>>M;
    vector<bool>b(N+1,true);
    rep(i,M){
        int m; cin>>m;
        b[m]=false;
    }
    vector<ll>dp(N+1);
    dp[0]=1;
    rep(i,N){
        for(int j=i+1;j <= min(N,i+2);j++){
            if(b[j]){
                dp[j]+=dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[N]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main()
{
    int n, c, ans=0, *a;
    cin >> n;
    a=new int[n];
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(int i=0; i<n; i++)
    {
        cin >> c;
        a[i]-=c;
        if(a[i]>0)
            ans+=a[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;
int main() {
	int n, p;
	cin >> n >> p;
	string s;
	cin >> s;
	if(p == 2 || p == 5) {
		rep(r, n) {
			if((s[r]-'0') % p == 0) {
				ans += r+1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	vector<int> d(n+1);
	int ten = 1;
	for(int i = n-1; i >= 0; --i) {
		int a = (s[i]-'0') * ten % p;
		d[i] = (d[i+1]+a) % p;
		ten *= 10; ten %= p;
	}
	vector<int> cnt(p);
	ll ans = 0;
	for(int i = n; i >= 0; --i) {
		ans += cnt[d[i]];
		cnt[d[i]]++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1412
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<string>
#include<functional>
#include<queue>
#include<stack>
#include<math.h>
#define INF 999999

using namespace std;

typedef long long ll;

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

	int debt;
	debt = 100000;

	for (int i = 0; i < n; i++) {
		debt *= 1.05;
		if (debt % 1000 != 0)debt = (debt / 1000 + 1)*1000;
	}

	cout << debt << endl;
	return 0;
}

Measured memory_bytes: 3004
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

std::vector<std::string> split(const std::string &s, const std::string &delim) {
  using string = std::string;
  std::vector<string> v;
  string::size_type pos = 0;
  while (pos != string::npos) {
    string::size_type p = s.find(delim, pos);
    if (p == string::npos) {
      v.push_back(s.substr(pos));
      break;
    }
    v.push_back(s.substr(pos, p - pos));
    pos = p + delim.size();
  }
  return v;
}

main {
  vvi t = {{1, 3}, {6, 2}, {4, 5}, {1, 6}, {5, 3}, {3, 1}, {6, 6}};
  string s;
  while (cin >> s, s != "#") {
    vi v(s.size());
    transform(all(s), v.begin(), [](char c) { return c - '0'; });
    int st = 0;
    for (auto &x : v) st = t[st][x];
    cout << (st == 5 ? "Yes" : "No") << endl;
  }
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    ll q,h,s,d,n,one;
    cin >> q >> h >> s >> d;
    cin >> n;
    one = min({4*q,2*h,s});
    if(n%2 == 0){
        cout << min({one*n,d*n/2}) << endl;
    }else{
        cout << min({one*n,d*(n/2)+one}) << endl;
    }
    return 0;
}

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

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

  vector<string> a(n);
  rep(i,n) {
    cin >> a[i];
  }

  map<string,int> map;
  rep(i,n) {
    map[a[i]] += 1;
  }

  int ans = 0;
  rep(i, map.size()) {
    ans++;
  }
  cout << ans << endl;


}


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

int h,w;
string s[100];

void newland(int i, int j) {
  char t = s[i][j];
  s[i][j] = '.';
  if(j!=w-1 && t == s[i][j+1]) newland(i,j+1);
  if(i!=h-1 && t == s[i+1][j]) newland(i+1,j);
  if(j!=0 && t == s[i][j-1]) newland(i,j-1);
  if(i!=0 && t == s[i-1][j]) newland(i-1,j);
}

void solve() {
  int i,j;
  while(1) {
    int n=0;
    cin >> h >> w;
    if(h==0) break;
    for(i=0 ; i<h ; i++) {
      cin >> s[i];
    }
    for(i=0 ; i<h ; i++) {
      for(j=0 ; j<w ; j++) {
	if(s[i][j]!='.') {
	  newland(i,j);
	  n++;
	}
      }
    }
    cout << n << endl;
  }
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 2304
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val A, B, H, M = in.nextDouble

  val ah = math.Pi * (0.5 - (60 * H + M) / 360)
  val hx = A * math.cos(ah)
  val hy = A * math.sin(ah)
  val am = math.Pi * (0.5 - M / 30)
  val mx = B * math.cos(am)
  val my = B * math.sin(am)
  def sq(d: Double): Double = d * d

  println(math.sqrt(sq(hx - mx) + sq(hy - my)))
}

Measured memory_bytes: 55456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=100100100;
const int MOD=(int)1e9+7;
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,a,b) for(int i=a; i<b; i++)

int main(){
    string s;
    cin>>s;
    int ans =0;
    if(s=="SUN") ans=7; 
    if(s=="MON") ans=6; 
    if(s=="TUE") ans=5; 
    if(s=="WED") ans=4; 
    if(s=="THU") ans=3; 
    if(s=="FRI") ans=2; 
    if(s=="SAT") ans=1; 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        while(s.hasNext()) {
            int a = Integer.parseInt(s.next());
            char op = (s.next()).charAt(0);
            int b = Integer.parseInt(s.next());
            switch (op) {
                case '?':
                    return;
                case '+':
                    a += b;
                    break;
                case '-':
                    a -= b;
                    break;
                case '*':
                    a *= b;
                    break;
                case '/':
                    a /= b;
                    break;
            }
            System.out.println(a);
        }
    }
}

Measured memory_bytes: 17296
#include<iostream>
#include<cmath>
using namespace std;
const int N=2e5+10;
const double pi=acos(-1.0);
int main()
{
	double a,b,h,m;
	cin>>a>>b>>h>>m;
	double time=h*60+m;
	double minu,hour;
	minu=time*6.0;
	while(minu>=360) minu-=360;
	hour=time/2.0;
	while(hour>=360) hour-=360;
	double angle=min(abs(minu-hour),360-abs(minu-hour));
	double ret=cos(angle*pi/180);
	double ans=sqrt(a*a+b*b-ret*2*a*b);
	printf("%.20f",ans);
	return 0;
}

Measured memory_bytes: 4116
X, N = list(map(int, input().split()))
p = list(map(int, input().split()))
integer = [i for i in range(102)]
for i in range(N):
   integer.remove(p[i])
l = len(integer)
ans = -200
for i in range(l):
   if abs(ans) > abs(integer[i]-X):
      ans = integer[i] - X
print(ans + X)

Measured memory_bytes: 9076
#include<bits/stdc++.h>
using namespace std;
long long n,a[222222],sum,pos,cur,A,b,c,d,mn,mx,ans;
pair<long long,long long> pre[222222],suf[222222];
long long calc(long long a,long long b)
{
	return abs(a-2*b);
}
int main()
{
	scanf("%lld",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	sum=0;pos=1;
	for (int i=1;i<=n;i++)
	{
		sum+=a[i];
		while(pos<=i && calc(sum,cur)>calc(sum,cur+a[pos])) 
		{
			cur+=a[pos];pos++;
		}
		pre[i]=make_pair(cur,sum-cur);
	}
	sum=cur=0;pos=n;
	for (int i=n;i>=1;i--)
	{
		sum+=a[i];
		while(pos>=i && calc(sum,cur)>calc(sum,cur+a[pos]))
		{
			cur+=a[pos];pos--;
		}
		suf[i]=make_pair(cur,sum-cur);
	}
	ans=1e18;
	for (int i=2;i<n;i++)
	{
		A=pre[i].first;b=pre[i].second;c=suf[i+1].first;d=suf[i+1].second;
		mn=min(min(A,b),min(c,d));mx=max(max(A,b),max(c,d));
		if (mn==0) continue;
		ans=min(ans,mx-mn);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8704
#include <iostream>

int main() {
    int* buf = new int[100];
    int n;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        std::cin >> *buf;
        buf++;
    }
    for (int i = 0; i < n; i++) {
        buf--;
        std::cout << *buf;
        if (i != n-1)
            std::cout << ' ';
    }
    std::cout << std::endl;
    delete buf;
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep2(i, m, n) for (int i = m; i < n; ++i)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
// vvi data(n, vi(m));
using vll = vector<long long>;
using vvll = vector<vll>;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cassert>
#include<iomanip>

typedef double type_n;

struct Point{ type_n x, y; };

Point set_p(type_n a, type_n b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ type_n vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

type_n cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

type_n dist(const Point &p1, const Point &p2)
{
    return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

int main()
{
    int i, n;
    type_n *X, *Y;
    scanf("%d", &n);
    assert(n >= 3);

    X = new type_n [n + 1];
    Y = new type_n [n + 1];
    for(i = 0; i < n; i++){
        scanf("%lf %lf", &X[i], &Y[i]);
    }
    X[n] = X[0], Y[n] = Y[0];

    Point *Plg;
    Plg = new Point [n + 1];
    for(i = 0; i <= n; i++){
        Plg[i] = set_p(X[i], Y[i]);
    }

    int top = 0, bottom = 0;
    type_n diam = 0;
    type_n low = Y[0], high = Y[0];

    for(i = 1; i < n; i++){
        if(low > Y[i]){ bottom = i, low = Y[i]; }
        if(high < Y[i]){ top = i, high = Y[i]; }
    }
    diam = dist(Plg[top], Plg[bottom]);
    top--;

    for(int k = 0; k < n; k++){
        while(cross(set_v(Plg[bottom], Plg[bottom + 1]), set_v(Plg[top], Plg[top + 1])) >= 0){
            top++; if(top > n - 1) top -= n;
        };
        diam = max(diam, max(dist(Plg[bottom], Plg[top]), dist(Plg[bottom + 1], Plg[top])));
        bottom++; if(bottom > n - 1) bottom -= n;
    }

    printf("%.12f\n", diam);

    return 0;
}

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

int main() {
  long n;
  cin >> n;
  vector<long> a(n-1);
  vector<long> ans(n);
  for(long i=0;i<n-1;i++) cin >> a[i];
  for(long i=0;i<n-1;i++) {
    ans[a[i]-1]++;
  }
  for(long i=0;i<n;i++) cout << ans[i] << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int k,s;
  cin>>k>>s;
  int ans = 0;
  REP(x,k+1)REP(y,k+1){
    int z = s-x-y;
    if(0<=z && z<=k)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second

ll n,cnt,a[ohara],b,c,d,tmp,tmpp,m,h,w,x[ohara],y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
vector<ll> ans;
priority_queue<pair<ll,ll>> qu;

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>k;
    k++;
    rep(i,n)cin>>a[i],qu.push({a[i],i});
    int ok=0;
    while(1){
        ok=0;
        if(k<=0)break;
            ll last;
            while(!qu.empty()){
                pair<ll,ll> p=qu.top();
                qu.pop();
                if(p.fi==0){ok=1;break;}
                ans.push_back(p.se);
                a[p.se]--;
                last=p.se;
            }
            if(ok)break;
            rep(i,n){
                if(i==last)continue;
                if(a[i]==0){ok=1;break;}
                qu.push({a[i],i});
            }
            k--;
        if(ok)break;
    }

    if(k>0)Cout(-1);
    else{
        int lla=0;
        while(1){
            lla=0;
            rep(i,n){
                if(a[i]==0)continue;
                ans.push_back(i);
                a[i]--;
                lla=1;
            }
            if(lla==0)break;
        }
        Cout(Size(ans));
        rep(i,Size(ans)){
            if(i==Size(ans)-1)Cout(ans[i]+1);
            else cout<<ans[i]+1<<" ";
        }
    }
    return 0;
}


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

int main() {
  long long N, K, memo, answer;
  cin >> N >> K;
  
  answer = 0;
  
    for (long long i = K; i <= N + 1; i++) {
    memo = N*i - i*i + i + 1;
    answer += memo % 1000000007;
    }
  cout << answer % 1000000007 << endl;
}


Measured memory_bytes: 3644
N, Q = map(int, input().split())

edges = [[] for _ in range(N)]
for _ in range(N - 1):
    fr, to = map(int, input().split())
    fr -= 1
    to -= 1
    edges[fr].append(to)
    edges[to].append(fr)

ans = [0] * (N + 1)

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

st = [(0, N)]
while st:
    now, pr = st.pop()

    ans[now] += ans[pr]
    for to in edges[now]:
        if to == pr:
            continue
        st.append((to, now))
print(*ans[:N])


Measured memory_bytes: 56644
import Control.Applicative
import Control.Monad
import Data.List


main = do
    [h, w] <- map read . words <$> getLine
    lines <- replicateM h getLine
    let ans = solve w lines
    forM_ [0..(length ans - 1)] $ \i -> do
        putStrLn (ans !! i)

solve :: Int -> [String] -> [String]
solve w = compressCol w . compressRow

compressRow :: [String] -> [String]
compressRow = filter (\line -> not ((length $ group line) == 1 && (head line == '.')))

compressCol :: Int -> [String] -> [String]
compressCol w lines =
    let getCols 0 _ _ = []
        getCols n k lines = map (\line -> line !! (k - n)) lines : getCols (n - 1) k lines
        cols = getCols w w lines
        compressedCols = compressRow cols
    in getCols (length lines) (length lines) compressedCols


Measured memory_bytes: 1788
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
void read (int &x) {
	char ch = getchar(); int f = 0; x = 0;
	while (!isdigit(ch)) { if (ch == '-') f = 1; ch = getchar(); }
	while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar(); if (f) x = -x;
} const int N = 1e6 + 10, M = 1000;
int n, ka, kb, a[N], is[M], tot, p[M];
void Pre_work() {
	int mx = 1000;
	for (int i = 2; i <= mx; ++i) {
		if (!is[i]) p[++tot] = i;
		for (int j = 1; j <= tot && p[j] * i <= mx; ++j) {
			is[p[j] * i] = 1; if (i % p[j] == 0) break;
		}
	}
}
#define ull unsigned long long
int num[M * M + 5], used[M * M + 5];
signed main() {
	Pre_work(); read (n);
	for (int i = 1; i <= n; ++i) {
		read (a[i]); int tmp = a[i];
		for (int j = 1; j <= tot && p[j] <= tmp; ++j) {
			if (tmp % p[j] == 0) {
				if (num[p[j]]) ka = 1;
				++num[p[j]];
				if (i == n && num[p[j]] == n) kb = 1;
				while (tmp % p[j] == 0) tmp /= p[j];
			}
		} 
		if (tmp > 1) {
			if (num[tmp]) ka = 1; ++num[tmp];
			if (i == n && num[tmp] == n) kb = 1;
		}
	}
	if (!ka) return puts ("pairwise coprime"), 0;
	if (!kb) return puts ("setwise coprime"), 0;
	return puts ("not coprime"), 0;
}

Measured memory_bytes: 11368
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
S = input()

ones = []
zeros = []
current = '1'
n = 0
for i in range(N):
    if S[i] == current:
        n += 1
    else:
        if current == '1':
            ones.append(n)
            current = '0'
        else:
            zeros.append(n)
            current = '1'
        n = 1
if current == '1':
    ones.append(n)
else:
    zeros.append(n)
    ones.append(0)

L = len(zeros)
if L <= K:
    print(N)
else:
    ans = sum(ones[:K+1]) + sum(zeros[:K])
    now = ans
    for i in range(L-K):
        now += (ones[i+K+1]+zeros[i+K]-ones[i]-zeros[i])
        ans = max(ans,now)
    print(ans)

Measured memory_bytes: 4356
import time
N,Q = map(int, input().split())
S = input()
AC = [0]*(N+1)

for i in range(N):
    if S[i:i+2] == "AC":
        AC[i+1] = AC[i] + 1
    else:
        AC[i+1] = AC[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(AC[r-1] - AC[l-1])


Measured memory_bytes: 6184
from sys import stdin

N = int(stdin.readline().rstrip())

max_num = 1
max_count = 0

def division(n):
    count = 0
    while True:
        quo = n // 2
        rem = n % 2

        if quo == 0 or rem > 0:
            break
        else:
            count = count + 1

        n = quo

    return count


for i in range(1,N+1):
    count = division(i)
    if max_count < count:
        max_count = count
        max_num = i

print(max_num)


Measured memory_bytes: 3188
count = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = (int(x) for x in input().split())
    count[b - 1][f - 1][r - 1] += v

for b in range(4):
    for f in range(3):
        for r in range(10):
            print("", count[b][f][r], end="")
        print()
    if (b != 3) : print("####################")


Measured memory_bytes: 5636
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

int main(){

	int n;
	double t,sum=0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> t;
		sum += (1.0/t);
	}
	printf("%.5f\n",1.0/sum);

	return 0;
}

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

ll solve() {
  ll N, M; cin >> N >> M;
  if (!(N <= M)) swap(N, M);
  if (M == 1) return 1;
  if (N == 1) return M-2;
  return (N-2) * (M-2);
}  

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  cout << solve() << endl;
  return 0;
}



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

using namespace std;

#define MAX_N 210000

int main() {
    int N;
    long long A[MAX_N], AS[MAX_N];

    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%lld", &A[i]);

    AS[0] = A[0];
    for (int i = 1; i < N; i++) AS[i] = AS[i - 1] + A[i];
    AS[N] = 0;

    sort(AS, AS + N + 1);

    long long c = 0;
    for (int i = 0; i <= N; i++) {
        long long n = 1;
        while (i + 1 <= N && AS[i + 1] == AS[i]) {
            i++;
            n++;
        }
        c += n * (n - 1) / 2;
    }

    printf("%lld\n", c);
}



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

int n, ma, mb, a[50], b[50], c[50], inf = 1e9 + 7, dp[50][410][410];

int main(){
    cin >> n >> ma >> mb;
    for (int i = 0; i < n; i++){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
    }
    for (int i = 0; i <= n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                dp[i][j][k] = inf;
            }
        }
    }
    dp[0][0][0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j <= 400; j++){
            for (int k = 0; k <= 400; k++){
                if (dp[i][j][k] == inf) continue;
                dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
                dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
            }
        }
    }
    int ans = inf;
    for (int i = 1; i <= 400; i++){
        for (int j = 1; j <= 400; j++){
            if (i * mb == j * ma) ans = min(ans, dp[n][i][j]);
        }
    }
    if (ans == inf) ans = -1;
    printf("%d\n", ans);
}


Measured memory_bytes: 28928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N;
ll L[4000];

void input() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> L[i];
}

void solve() {
    input();
    vector<ll> v(N);
    for(int i = 0; i < N; i++) v[i] = L[i+1];
    sort(v.begin(), v.end());
    ll ans = 0;
    for(ll mid = N - 1; mid >= 0; mid--) {
        for(ll low = mid - 1; low >= 0; low--) {
            auto itr = lower_bound(v.begin(), v.end(), v[mid] + v[low]);
            ll ng = distance(itr, v.end());
            ans += (N - 1 - mid) - ng;
            //cerr << v[mid] + v[low] << " " << ng << " " << (N-1-mid)-ng << endl;
        }
    }
    cout << ans << endl;
    return;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;

int main(void) {
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    string T;
    cin >> T;
    string s(N, ' ');
    vector<int> dp(N+1);
    for(int i=1; i<=K; i++) {
        if(T[i-1] == 'r') {
            s[i-1]= 'r';
            dp[i] = dp[i-1] + P;
        } else if(T[i-1] == 's') {
            s[i-1] = 's';
            dp[i] = dp[i-1] + R;
        } else {
            s[i-1] = 'p';
            dp[i] = dp[i-1] + S;
        }
    }

    for(int i=K+1; i<=N; i++) {
        if(T[i-1] == 'r') {
            if(s[i-K-1] == 'r') {
                dp[i] = dp[i-1];
            } else {
                s[i-1] = 'r';
                dp[i] = dp[i-1] + P;
            }
        } else if(T[i-1] == 's') {
            if(s[i-K-1] == 's') {
                dp[i] = dp[i-1];
            } else {
                s[i-1] = 's';
                dp[i] = dp[i-1] + R;
            }
        } else {
            if(s[i-K-1] == 'p') {
                dp[i] = dp[i-1];
            } else {
                s[i-1] = 'p';
                dp[i] = dp[i-1] + S;
            }
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 896
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
 
int main(){
	vector<int> a(5);
    rep(i,5) cin>>a[i];
    int ans=0,cnt=0;
    rep(i,5){
        ans+=(a[i]+9)/10*10;
        if(a[i]%10) cnt=max(cnt,10-a[i]%10);
    }
    cout<<ans-cnt<<endl;
}

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

class Main
{
  static int[] A;
  
  static boolean isValid() //check if the current array needs swaps or doesn't need swaps:
  {
    for (int i = 0; i < A.length; i++)
    {
      if (A[i] == i + 1)
      {
        return false;
      }
    }
    return true;
  }
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    A = new int[N];
    for (int i = 0; i < N; i++)
    {
      A[i] = sc.nextInt();
    }
    int swaps = 0;
    while (!isValid())
    {
      //look through all elements through 1 to N - 1:
      for (int i = 0; i < A.length - 1; i++)
      {
        if (A[i] == i + 1) //xx or xo
        {
          swaps += 1;
          //swap A[i] and A[i + 1]:
          int temp = A[i];
          A[i] = A[i + 1];
          A[i + 1] = temp;
        }
      }
      if (A[N - 1] == N) //ox
      {
        swaps += 1;
        int temp = A[N - 1];
        A[N - 1] = A[N - 2];
        A[N - 2] = temp;
      }
    }
    System.out.println(swaps);
  }
}


Measured memory_bytes: 49276
#include<iostream>
#include<cstdio>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<map>
#include<numeric>
#include<stack>
#include<queue>
#include<functional>
#include<cassert>
#include<set>
#include<numeric>
#define rep(a,b) for(ll a=0;a<b;++a)
#define REP(a,b,c,d) for(ll a=b;a<c;a+=d)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define mod 1000000007
using namespace std;
using ll = long long;
using p_ll = pair<ll, ll>;
int main() {
	string S; cin >> S;
	ll zero = 0, one = 0;
	rep(i, S.size()) {
		if (i % 2 == 0 && S[i] != '0')zero++;
		if (i % 2 == 1 && S[i] != '1')zero++;
		if (i % 2 == 0 && S[i] != '1')one++;
		if (i % 2 == 1 && S[i] != '0')one++;
	}
	cout << min(zero,one) << endl;
	cin >> S;
}

Measured memory_bytes: 512
N = int(input())
monsters = list(map(int, input().split()))
heros = list(map(int, input().split()))
nums = 0

for i in range(len(heros)):
    if monsters[i] <= heros[i]:
        heros[i] -= monsters[i]
        nums += monsters[i]
        monsters[i] = 0

        if monsters[i+1] <= heros[i]:
            heros[i] -= monsters[i+1]
            nums += monsters[i+1]
            monsters[i+1] = 0
        else:
            nums += heros[i]
            monsters[i+1] -= heros[i]
            heros[i] = 0
    else:
        nums += heros[i]
        monsters[i] -= heros[i]
        heros[i] = 0

print(nums)


Measured memory_bytes: 19004
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
int main(void){
    long long ans=0;
    int n, t; cin>>n>>t;
    vector <long long> tim(n);
    for(int i=0;i<n;i++){
        cin>>tim[i];
    }
    tim.push_back(INF);
    for(int i=0;i<n;i++){
        if(tim[i+1]-tim[i]<=t){
            ans+=tim[i+1]-tim[i];
        }else{
            ans+=t;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4736
//Naveen Venkat
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int n, m, k;

int main(void)
{
	//freopen("fLIP.in", "r", stdin);
	//freopen("fLIP.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &k);
	FOR(i, 0, n + 1)
	{
		FOR(j, 0, m + 1)
		{
			if (j*n + i*m - 2 * i*j == k)
			{
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    int BestHeight = -1;

    for (int i = 0; i < n; i++)
    {
        BestHeight = max(BestHeight, h[i]);
        if(BestHeight <= h[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		Set<Integer> s=new HashSet<>();
		
		int n=cin.nextInt();
		for(int i=0;i<n;i++) {
			s.add(Integer.parseInt(cin.next()));
		}
		
		int res=0,q=cin.nextInt();
		for(int i=0;i<q;i++) {
			int t=Integer.parseInt(cin.next());
			if(s.contains(t))res++;
		}
		
		System.out.println(res);
	}

}



Measured memory_bytes: 38912
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
#define cld complex <double>

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e3 + 100;
const ll inf = 1e9;

ll n, m, k, t;

string S[maxn];

ll D[maxn][maxn];

bool in(ll x, ll y) {
    return x >= 0 && y >= 0 && x < n && y < m;
}

int main() {
    pyshnapyshnakaa
    ll q, w, e, a, b, c;
    cin >> n >> m;
    for (q = 0; q < n; q++) {
        cin >> S[q];
    }
    queue <pll> Q;
    for (q = 0; q < n; q++) {
        for (w = 0; w < m; w++) {
            if (S[q][w] == '#') {
                Q.push(mp(q, w));
                D[q][w] = 0;
            }
            else {
                D[q][w] = inf;
            }
        }
    }
    vector <pll> diff = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    while (!Q.empty()) {
        pll p = Q.front();
        Q.pop();
        ll x = p.first, y = p.second;
        for (auto d : diff) {
            ll nx = x + d.first;
            ll ny = y + d.second;
            if (!in(nx, ny)) {
                continue;
            }
            if (D[nx][ny] == inf) {
                Q.push(mp(nx, ny));
                D[nx][ny] = D[x][y] + 1;
            }
        }
    }
    ll ans = 0;
    for (q = 0; q < n; q++) {
        for (w = 0; w < m; w++) {
            ans = max(ans, D[q][w]);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 29132
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

double a,b,c;
cin>>a>>b>>c;
cout<<(double)a*b/2;


    return 0;
  }


Measured memory_bytes: 256
def LI():return list(map(int,input().split()))
def II():return int(input())
def yes():return print("Yes")
def no():return print("No")
INF=float("inf")
from collections import deque, defaultdict, Counter
from heapq import heappop, heappush
from itertools import product, combinations
from functools import reduce, lru_cache
from math import pi, gcd
from decimal import Decimal

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

class Unionfind:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

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


d,t,s=LI()

if (d<=t*s):
    print("Yes")
else:
    print("No")


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

namespace AC
{
    class shiokara
    {
        static void Main(string[] args)
        {
            var N = int.Parse(ReadLine());
            int a = 1, b = 1;
            long cnt = 0;
            long eqcnt = 0;
            for(;a * a < N; a++){
                for(b = a; a * b < N; b++){
                    if(a == b) eqcnt++;
                    else cnt++;
                }
            }
            var ans = cnt * 2 + eqcnt;
            WriteLine(ans);
        }
    }
}

Measured memory_bytes: 27516