akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main () {
  int N, T;
  cin >> N >> T;
  vector<int>ad(N);
  for (int i = 0; i < N; i ++) cin >> ad[i];
  vector<int>mi(N);
  vector<int>ma(N);
  mi[0] = ad[0];
  ma[N - 1] = ad[N - 1];
  for (int i = 1; i < N; i ++) {
    int j = N - i - 1;
    mi[i] = min(mi[i - 1], ad[i]);
    ma[j] = max(ma[j + 1], ad[j]);
  }
  int gr = 0;
  int ans = 0;
  for (int i = 0; i < N; i ++) {
    int a = ad[i];
    int s = mi[i];
    int l = ma[i];
    if (a - s == gr) ans ++;
    if (l - a == gr) ans ++;
    if (a - s > gr) {
      gr = a - s;
      ans = 1;
    }
    if (l - a > gr) {
      gr = l - a;
      ans = 1;
    }
    //cout << gr << ' ' << ans << endl;
  }
  cout << ans / 2 << endl;
}



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

const int N=3e3+100;
int n,a[N],f[N];
int head[N],ce;
struct edge{int to,nxt;} e[N<<1];

void lnk(int a,int b) {e[++ce]=(edge){b,head[a]}, head[a]=ce;}

void dfs(int u,int lst)
{
	f[u]=0;
	for(int i=head[u];i;i=e[i].nxt)
	{
		int v=e[i].to;
		if(v == lst) continue;dfs(v,u);
		if(!f[v] && a[u]>a[v]) f[u]=1;
	}
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d",&a[i]);
	for(int i=1,u,v;i<n;++i)
		scanf("%d%d",&u,&v), lnk(u,v), lnk(v,u);
	for(int i=1;i<=n;++i)
	{
		dfs(i,0);
		if(f[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define PI 3.14159265
#define INF 2147483647
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}
ll fac(ll n ,int p){
	if(n==0) return 0;
	return n/p + fac(n/p,p);
}

ll go(ll n , int p){
	ll res = fac(n/2,p);
	if(p == 2) res += n/2;
	return res;

}

int main(){
	ll n; cin >> n;
	if(n&1){
		cout << 0 << endl;
		return 0;
	}

	ll ans = min(go(n,2),go(n,5));
	cout << ans << endl;
	return 0;
}

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

int main(){
  long n, m, k, tmp;  cin >> n >> m >> k;
  vector<long> a(n+1, 0), b(m+1, 0);
  for(int i=1; i<=n; i++){
    cin >> tmp;
    a[i] = a[i-1] + tmp;
  }
  for(int i=1; i<=m; i++){
    cin >> tmp;
    b[i] = b[i-1] + tmp;
  }
  int b_idx = m, ans = 0;
  for(int i=0; i<=n; i++){
    if(a[i] > k)  break;
    while(a[i] + b[b_idx] > k)  b_idx--;
    ans = max(ans, i+b_idx);
  }

  cout << ans << endl;

  return 0;
}


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

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

    vector<ll> h(n);
    vector<int> tree[n];
    rep(i,n) cin >> h[i];
    rep(i,m) {
        int a, b;
        cin >> a >>b;
        --a; --b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    ll ans = 0;
    rep(i,n){
        bool ok = true;
        for(int target : tree[i])
        {
            if(h[i] <= h[target]) {
                ok = false;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 8988
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <string>
//
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
constexpr double BIGP = 1000000007L;
constexpr double INF_I = std::numeric_limits<double>::max();
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> S(M);
    vector<ll> C(M);
    rep(i, M)
    {
        cin >> S[i] >> C[i];
    }
    /*if (M == 0)
    {
        cout << -1;
        return 0;
    }*/
    //
    vector<ll> tmp;
    rep(i, 1000)
    {
        string no = std::to_string(i);
        if (no.size() != N)
        {
            continue;
        }
        tmp.clear();
        for (char ch : no)
        {
            tmp.push_back(ch- '0');
        }
        //
        bool ok = true;
        rep(j, M)
        {
            if (tmp[S[j] - 1] != C[j])
            {
                ok = false;
            }
        }
        if (ok)
        {
            cout << i;
            return 0;
        }
    }
    cout << -1;

    return 0;
}

Measured memory_bytes: 3160
N = int(input())
p =list(map(int, input().split()))
ans = 0
for i in range(N - 1):
  if i + 1 == p[i]:
    p[i], p[i+1] = p[i+1], [i]
    ans += 1
print(ans + int(N == p[N-1]))


Measured memory_bytes: 14004
N, A, B = map(int, input().split())

med = N / 2 + 0.5
Sub = B - A

if (Sub) % 2 == 0:
    round_count = Sub // 2
else:
    round_count = min(A - 1, N - B) + 1 + (Sub - 1) // 2
            
print(round_count)

Measured memory_bytes: 3060
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
count = 0
for i in range(N):
    A = list(map(int,input().split()))
    total = C
    for j in range(M):
        total += A[j]*B[j]
    if total > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

const int INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<int>> f(n, vector<int>(10)), p(n, vector<int>(11));
    rep(i,n)rep(j,10) cin >> f[i][j];
    rep(i,n)rep(j,11) cin >> p[i][j];
    int ans = -INF;
    for(int S = 1; S < (1<<10); S++){
        int score = 0;
        rep(i,n){
            int c = 0;
            rep(j,10){
                if(f[i][j] && (S>>j & 1)) c++;
            }
            score += p[i][c];
        }
        chmax(ans, score);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

INF = 10**9 + 1

def precompute(N, M, data):
    data = data.reshape(-1, 3)
    A, B, C = data[:N].T
    D, E, F = data[N:].T
    X = np.unique(np.concatenate([A, B, D, [0, -INF, INF]]))
    Y = np.unique(np.concatenate([C, E, F, [0, -INF, INF]]))
    A = np.searchsorted(X, A)
    B = np.searchsorted(X, B)
    D = np.searchsorted(X, D)
    C = np.searchsorted(Y, C)
    E = np.searchsorted(Y, E)
    F = np.searchsorted(Y, F)
    return A, B, C, D, E, F, X, Y

def solve(A, B, C, D, E, F, X, Y):
    H, W = len(X), len(Y)
    N = H * W
    DX = X[1:] - X[:-1]
    DY = Y[1:] - Y[:-1]

    def set_ng(A, B, C, D, E, F, H, W):
        ng = np.zeros((H * W, 4), np.bool_)

        for i in range(len(A)):
            for x in range(A[i], B[i]):
                v = x * W + C[i]
                ng[v][1] = 1
                ng[v - 1][0] = 1

        for i in range(len(D)):
            for y in range(E[i], F[i]):
                v = D[i] * W + y
                ng[v][3] = 1
                ng[v - W][2] = 1
        return ng

    ng = set_ng(A, B, C, D, E, F, H, W)
    x0, y0 = np.searchsorted(X, 0), np.searchsorted(Y, 0)
    v0 = x0 * W + y0
    visited = np.zeros(N, np.bool_)
    visited[v0] = 1
    stack = np.empty(N, np.int32)
    p = 0
    ret = 0

    def area(x):
        x, y = divmod(x, W)
        return DX[x] * DY[y]

    def push(x):
        nonlocal p, ret
        stack[p] = x
        visited[x] = 1
        ret += area(x)
        p += 1

    def pop():
        nonlocal p
        p -= 1
        return stack[p]

    push(v0)
    move = (1, -1, W, -W)
    while p:
        v = pop()
        for i in range(4):
            if ng[v][i]:
                continue
            w = v + move[i]
            if visited[w]:
                continue
            x, y = divmod(w, W)
            if x == 0 or x == H - 1 or y == 0 or y == W - 1:
                return 0
            push(w)
    return ret

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    signature = '(i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1],i8[::1])'
    cc.export('solve', signature)(solve)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit()

from my_module import solve

N, M = map(int, readline().split())
data = np.int64(read().split())

x = solve(*precompute(N, M, data))
if x == 0:
    print('INF')
else:
    print(x)


Measured memory_bytes: 86112
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LLP;

int main() {
  
  int N, M;
  cin >> N >> M;
  vector<int> L(M), R(M), D(M);
  vector<bool> checked(M, false);
  vector<vector<int>> edges(N);
  vector<ll> pos(N, LINF);
  rep(i,M) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
    edges[L[i]].push_back(i);
    edges[R[i]].push_back(i);
  }

  rep(i,N) {
    if (edges[i].size() <= 0) continue;
    queue<int> que;
    for (int e: edges[i]) {
      if (!checked[e]) que.push(e);
    }
    if (que.empty()) continue;
    pos[i] = 0;
    while (!que.empty()) {
      int p = que.front(); que.pop();
      checked[p] = true;
      if (pos[L[p]] < LINF && pos[R[p]] < LINF) {
        if (pos[R[p]] - pos[L[p]] != D[p]) {
          cout << "No" << endl;
          return 0;
        }
      } else if (pos[L[p]] < LINF) {
        pos[R[p]] = pos[L[p]] + D[p];
        for (int e: edges[R[p]]) {
          if (!checked[e]) que.push(e);
        }
      } else {
        pos[L[p]] = pos[R[p]] - D[p];
        for (int e: edges[L[p]]) {
          if (!checked[e]) que.push(e);
        }
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}

Measured memory_bytes: 13368
def gcd(a,b):
    x=max(a,b)
    y=min(a,b)
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)
A,B,K=map(int,input().split())
G=gcd(A,B)
L=[]
for i in range(1,G+1):
    if G%i==0:
        L.append(i)
L.sort(reverse=True)
print(L[K-1])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    string s; cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl;
using namespace std;
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string S;
  cin >> S;
  int ans = 0;
  for(int i = 1; i <= n - 1; ++i){
  	string t = S.substr(0,i);
  	string s = S.substr(i,n - i);
  	int k = 0;
  	if(t.size() <= s.size()){
  		sort(all(t));
  		auto result = unique(all(t));
  		t.erase(result, t.end());
  		for(int j = 0;j < t.size(); ++j){
  			if(count(all(s),t[j]) > 0) k++;
  		}
  	}
  	else{
  		sort(all(s));
  		auto result = unique(all(s));
  		s.erase(result, s.end());
  		for(int j = 0;j < s.size(); ++j){
  			if(count(all(t),s[j]) > 0) k++;
  		}
  	}
  	ans = max(ans, k);
  }
  dunk(ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	
	int n,x=0;
	int max=0;
	char  str[105];
	int i;	
	scanf("%d",&n);
	scanf("%s",str);
	
	i=0;
	while(n>0  &&  n<=100){
		
	
	if(str[i]=='I'){
			x++;
	}
	else {
			x--;
	}
	
	
	if(max<x){
			max=x;
	}
	
	
	i++;
	n--;       
	
	}
	printf("%d",max);
	
	return 0;
}
	


Measured memory_bytes: 128
from heapq import heappop, heappush

N, M = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for u, v in X:
    graph[u].append(v)

INF = 10 ** 9 + 7
d = [[INF] * 3 for _ in range(N + 1)]
d[S][0] = 0
pq = []
heappush(pq, (0, S))

while pq:
    _, u = heappop(pq)
    for v in graph[u]:
        for i in range(3):
            if d[v][(i + 1) % 3] > d[u][i] + 1:
                d[v][(i + 1) % 3] = d[u][i] + 1
                heappush(pq, (d[v][(i + 1) % 3], v))

if d[T][0] == INF:
    print(-1)
else:
    print(d[T][0] // 3)


Measured memory_bytes: 114844
import sys

readline = sys.stdin.readline

A, B, C, D = map(int, readline().split())

def get_gcd(x, y):
    while True:
        if x > y:
            t = x % y
            a = y
            x = t
        else:
            t = y % x
            a = x
            y = t
        if t == 0:
            return a

c = B // C - (A - 1) // C
d = B // D - (A - 1) // D
lcm = C * D // get_gcd(C, D)
cd = B // lcm - (A - 1) // lcm


ans = B - (A - 1) - (c + d - cd)

print(ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K, S;
  cin >> K >> S;
  int count = 0;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      if(i+j <= S && S -i -j <= K)count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll ANS;
vector<ll> C(55);

vector<vector<ll>> E(55);

int main(){
  ll N,M;
  cin >> N >> M;
  rep(i,M){
    ll X,Y;
    cin >> X >> Y;
    E[X].pb(Y);E[Y].pb(X);
  }
  Rep(k,1,N+1){
  rep(j,E[k].size()){
    rep(i,N+3){
      C[i]=0;
    }
    queue<ll> Q;
    Q.push(1);
    C[1]=1;
    while(!Q.empty()){
      auto X = Q.front();
      // if(k==1){
      //   cout <<  X << endl;
      // }
      Q.pop();
      rep(i,E[X].size()){
        if(C[E[X][i]]==0 && ((k!=X || E[k][j]!=E[X][i])  && (E[k][j]!=X || k!=E[X][i]))){
          Q.push(E[X][i]);
          C[E[X][i]]=1;
        }
      } 
    }
    ll Z=0;
    Rep(i,1,N+1){
      if(C[i]==0){
        Z=1;
      }
    }
    if(Z){
      ANS++;
    }
  }
  }
  cout << ANS/2 << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEB // Iterator safety; out-of-bounds access for Containers, etc.
//#pragma GCC optimize "trapv" // abort() on (signed) integer overflow.
#include <bits/stdc++.h>

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define INF 1000000000
#define bits(n) __builtin_popcount(n)

void solve()
{
    string s;
    cin>>s;
    if(s[s.length()-1]=='s')
    cout<<s<<"es";
    else
    {
        cout<<s<<"s";
    }
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

int main(){
  int n,i,j,c=0,t,frag;
  scanf("%d",&n);
  int A[n];
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  frag=1;
  while(frag){
    frag=0;
    for(j=n-1;j>0;j--){
      if(A[j]<A[j-1]){
	t=A[j];
	A[j]=A[j-1];
	A[j-1]=t;
	c++;
	frag=1;
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d",A[i]);
    if(i<n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",c);
  return 0;
}



Measured memory_bytes: 2104
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int S = sc.nextInt();
    int W = sc.nextInt();
    if (W - S >= 0) {
      System.out.println("unsafe");
    } else {
      System.out.println("safe");
    }
  }
}

Measured memory_bytes: 26932
#include <bits/stdc++.h>
using namespace std;
typedef long long int l1;
#define pb push_back
#define input l1 t;cin>>t;while(t--)
l1 min(l1 a,l1 b){
    l1 ma=(a<b)?a:b;
    return ma;
}
l1 max(l1 a,l1 b){
    l1 ma=(a>b)?a:b;
    return ma;
}
l1 gcd(l1 a, l1 b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
# define pie 3.14159265358979323
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    l1 r;
    cin>>r;
    cout<<2*(pie*r);
        
}
 

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

lli dp[1020];

signed main(){

	lli d,g;
	cin>>d>>g;
	dp[0]=1;

	REP(i,0,d){
		lli p,c;
		cin>>p>>c;

		lli nextDp[1020];
		REP(i,0,1020)nextDp[i]=0;

		for(lli j=1;j<=p;j++){
			for(lli k=0;k<=1000;k++){
				lli score = j*(i+1)*100;
				if(j==p)score+=c;
				if(dp[k]){
					nextDp[k+j] = max(nextDp[k+j],dp[k]+score);
				}
			}
		}

		for(lli j=1;j<=1000;j++){
			dp[j] = max(dp[j],nextDp[j]);
		}
	}

	REP(i,0,1010){
		if(dp[i]>=g){
			cout<<i<<endl;
			return 0;
		}
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> a(3*n);
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += a[3*n-2-2*i];
    }

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


Measured memory_bytes: 2560
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        int h,w,i,j;
        Scanner s = new Scanner(System.in);
        while(true){
            h = s.nextInt();
            w = s.nextInt();
            if(h==0&&w==0)break;
            for(i=0;i<h;i++){
                for(j=0;j<w;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
System.out.println();
        }
    }
}



Measured memory_bytes: 34852
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    ll n,m,sum=0;
    cin>>n>>m;
    vector<pair<ll,ll>> a(n);
    rep(i,n) cin>>a[i].first>>a[i].second;
    sort(ALL(a));
    rep(i,n){
        if(a[i].second<=m){
            m -= a[i].second;
            sum += a[i].first*a[i].second;
        }else{
            sum += m*a[i].first;
            break;
        }
    }
    cout<<sum<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i <= n; i++)
#define repa(i, a, b) for(int i = (a); i < (b); i++)
#define repd(i, n) for(int i = (n)-1; i >= 0; i--)

#define TRACE(x...) x
#define watch(x) TRACE(cerr << #x" = " << x << endl)
#define watch_all(x) TRACE(cerr << #x" = "; for(auto __i : x) cerr << __i << " "; cerr << endl)

//=========================

void run_test() {
    int x, n; cin >> x >> n;
    vector<bool> u(110);
    rep(i, n) {
        int k; cin >> k;
        u[k] = 1;
    }
    int mn = 101, v = 0;
    for(int i = -1; i <= 101; i++) if(i < 0 || !u[i]) {
        if(abs(i-x) < mn) mn = abs(i-x), v = i;
    }
    cout << v << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	//int t = 1, _t; cin >> _t; while(t <= _t) { cout << "Case #" << t++ << ": "; run_test(); }
	// int t; cin >> t; while(t--) run_test();
	run_test();
	return 0;	
}



Measured memory_bytes: 3668
/**********************************************************************
   File hoge.cpp
   Author  harunaya
   Date   2020-05-17(Sun)
   note   
**********************************************************************/

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

int main() {
  int x, y; 
  cin >> x >> y;
  int ans_turu = (y - 2*x) / (4 - 2);
  int ans_kame = x - ans_turu;
  if (ans_turu >= 0 && ans_kame >= 0 && y % 2 == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0; 
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) (((n%m) + m)%m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

const int N = 1e5 + 100;

int accum[N];

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

	int n, m;
	cin >> n >> m;
	int mm = m;
	while (m--)
	{
		int a, b;
		cin >> a >> b;
		accum[a]++;
		accum[b + 1]--;
	}

	int sum = 0;

	erep(i, 1, n)
	{
		accum[i] += accum[i - 1];
		if (accum[i] == mm)
			sum++;
	}

	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 640
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
# from fractions import gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    R = INT()
    print(2*pi*R)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10048
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv,
    std.functional, std.math, std.numeric, std.range, std.stdio, std.string,
    std.random, std.typecons, std.container;

ulong MAX = 1_000_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
alias Pair = Tuple!(long, "l    ", long, "r");
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);

void main()
{
    auto s = sread();
    long cnt;
    foreach (i; iota(0, s.length - 1))
    {
        if(s[i] != s[i + 1])
            cnt++;
    }
    cnt.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
#define pb push_back
int N,M;
vector<int> mpp[100005];
bool visit[100005];
vector<int> path;
vector<int> path2;
void dfs(int t)
{
	visit[t]=true;
	path.push_back(t);
	for(int i=0;i<mpp[t].size();i++)
	{
		int nxt=mpp[t][i];
		if(visit[nxt]==false)
		{
			dfs(nxt);
			return;
		} 
	}
}
int main()
{
	cin>>N>>M;
	while(M--)
	{
		int a,b;
		cin>>a>>b;
		mpp[a].pb(b);
		mpp[b].pb(a);
	}
	dfs(1);
	swap(path,path2);
	dfs(1);
	cout<<path.size()+path2.size()-1<<endl;//1重复了,剪掉
	for(int i=(int)path2.size()-1;i>=1;i--)
	{
		cout<<path2[i]<<" ";
	}
	for(int i=0;i<path.size();i++) 
	{
		int t=path[i];
		cout<<t<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    if(n <= 999)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[200000];
int main()
{
	int n,k,M=-1,ti,i;
	long long s=0;
	cin>>n>>k;
	for(i=0;i<n;i++)
	   {cin>>a[i];s+=a[i];}
	if(n<=k){cout<<"0";return 0;}
	sort(a,a+n);
	for(i=1;i<=k;i++)
	    s-=a[n-i];
	cout<<s;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll k;
    cin>>k;
    string s;
    cin>>s;
    string ans="";
    if(s.length()<=k){
        ans=s;
    }
    else{
        for(ll i=0;i<k;++i){
            ans+=s[i];
        }
        for(ll i=0;i<3;++i){
            ans+=".";
        }
    }
    cout<<ans;

    return (0);
}


Measured memory_bytes: 3580
n=int(input())
s=input()

l=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
ans=[]
for st in s:
  ind=l.index(st)
  new_ind=ind+n
  if new_ind >25:
    new_ind-=26
  ans.append(l[new_ind])
print(*ans,sep="")



Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    vector<ll> a(n),b(n);
    rep(i,n){
        cin>>a[i];
    }

    ll ans=0;
    map<ll,ll> cnt;
    rep(i,n){
        ll t=a[i]-i;
        if(cnt.count(t)) ans+=cnt[t];
        cnt[-a[i]-i]++;
    }

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


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

double xs, ys, xt, yt;
ll N;

struct circle{double x, y, r;};

double cost[1002][1002];
double dst[1002];

double dist(double x1, double y1, double x2, double y2){
  return sqrt( (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) );
}

int main(){
  cin >> xs >> ys >> xt >> yt >> N;
  vector<circle> circles(1002);
  for(ll i = 0; i < N; i++){
    double x, y, r;
    cin >> x >> y >> r;
    circles[i].x = x;
    circles[i].y = y;
    circles[i].r = r;
  }
  
  for(ll i = 0; i < N; i++){
    for(ll j = i; j < N; j++){
      cost[j][i] = cost[i][j] = max((double)0, dist(circles[i].x, circles[i].y, circles[j].x, circles[j].y) - circles[i].r - circles[j].r);
    }
  }

  for(ll i = 0; i < N; i++){
    cost[N][i] = cost[i][N] = max((double)0, dist(xs, ys, circles[i].x, circles[i].y) - circles[i].r);
    cost[N+1][i] = cost[i][N+1] = max((double)0, dist(xt, yt, circles[i].x, circles[i].y) - circles[i].r);
  }

  cost[N][N+1] = cost[N+1][N] = dist(xt, yt, xs, ys);
  cost[N][N] = cost[N+1][N+1] = (double)0;
  
  for(ll i = 0; i < N + 2; i++){
    dst[i] = INF;
  }
  
  priority_queue< pair<double,ll>, vector< pair<double,ll> >, greater< pair<double,ll> > > pq;

  dst[N] = (double)0;
  pq.push(make_pair(dst[N], N));
  
  while(!pq.empty()){
    pair<double, ll> t;
    t = pq.top();
    pq.pop();
    for(ll i = 0; i < N + 2; i++){
      if(dst[i] > dst[t.second] + cost[t.second][i]){
	dst[i] = dst[t.second] + cost[t.second][i];
	pq.push(make_pair(dst[i], i));
      }
    }
  }

  cout << setprecision(10) << dst[N + 1] << endl;


}


Measured memory_bytes: 12404
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<string> vs;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

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

	int N;  cin >> N;
	vi T(N), A(N);
	FOR(i, 0, N) cin >> T[i] >> A[i];	

	vl nt(N), na(N);
	nt[0] = T[0];
	na[0] = A[0];

	FOR(i, 1, N) {
/*		ll r = 1;
		while (true) {
			if (T[i] * r >= nt[i - 1] &&
				A[i] * r >= na[i - 1]) break;
			r++;
		}*/
		ll r = max((nt[i - 1] + T[i] - 1) / T[i],
				   (na[i - 1] + A[i] - 1) / A[i]);

		nt[i] = T[i] * r;
		na[i] = A[i] * r;
	}

	ll ans = nt[N - 1] + na[N - 1];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
main = do
    n <- readLn
    if n == 0 then return () else do
        getLine -- skip length
        str <- getLine
        print $ count n str
        main

count :: Int -> String -> Int
count n s = count' (-1) s 0
    where
    count' _ "" t = t
    count' (-1) ('I':s) t = count' 0 s t
    count' (-1) ('O':s) t = count' (-1) s t
    count' l ('O':'I':s) t = count' (l+1) s (if l+1 >= n then t+1 else t)
    count' l ('I':s) t = count' 0 s t
    count' l ('O':s) t = count' (-1) s t

Measured memory_bytes: 80932
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	ll n;
	cin>>n;

	ll t=0,g=sqrt(n);
	for(int i=2; i<g+1; i++){
		ll n2=n;
		if(n2%i==1)t++;
		while(n2%i==0){
			n2/=i;
		}
		if(n2%i==1)t++;
		if(n2%i==1&&n%i==1&&n/i==i)t--;
	}
	if(n>2)cout<<t+2<<endl;
	else cout<<"1"<<endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
p = 0
g = 0
cnt = 0
for i in s:
    if i =='g':
        if p<g:
            p += 1
            cnt += 1
        else:
            g += 1
    else:
        if p<g:
            p += 1
        else:
            g += 1
            cnt -=1
print(cnt)



Measured memory_bytes: 73224
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

int main(void){
  int A,B,C;
  cin >> A >> B >> C;
  if( A == B && B == C ) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amin(T& a,T2 b){ if(a > b) a = b;}

int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	vector<VI> ba(3,VI(3));
	int n;
	rep(i, 3) rep(j, 3){ cin >>ba[i][j];}
	cin >>n;
	VI b(n);
	rep(g, n){
		int z; cin >>z;
		rep(i, 3) rep(j,3) if(ba[i][j] == z) ba[i][j] = -1;
	}
	//for(auto xl: ba){for(auto x :xl) cerr<<x<<" ";dbg("");}

	rep(i, 3){
		bool ok=1;
		rep(j, 3) if(ba[i][j] != -1) ok=0;
		if(ok==1){puts("Yes"); return 0;}
		ok=1;
		rep(j, 3) if(ba[j][i] != -1)ok=0;
		if(ok==1){puts("Yes"); return 0;}
		if(ba[1][1]==-1){
			if((ba[0][0]==-1 && ba[2][2]==-1) || (ba[0][2]==-1 && ba[2][0]==-1))
			{puts("Yes"); return 0;}
		}
	}

	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
    
    int a,b;
    
    while ((scanf("%d%d",&a,&b))!=EOF){
        int count=1;
        int c = a+b;
        while(c/10>0){
            c = c/10;
            count++;
        }
        printf("%d\n",count);
    }
    
    return 0;
}

Measured memory_bytes: 600
def resolve():
    N = int(input())
    zolo = 0
    for i in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            zolo += 1
            if zolo == 3:
                print("Yes")
                return
        else:
            zolo = 0
    print("No")

resolve()

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

using namespace std;

#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                        \
	sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
	{
sim > struct rge
{
	c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
	~debug()
	{
		cerr << endl;
	}
	eni(!=) cerr << boolalpha << i;
	ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
	sim dor(const c &)
	{
		ris;
	}
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define rfor(n, i) for (ll i = (n - 1); i >= 0; --i)
#define all(V) V.begin(), V.end()
#define rall(V) V.rbegin(), V.rend()
#define len(V) (int)V.size()
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define M_PI 3.14159265358979323846
#define EPS 1e-7

void solve()
{
        int n, m; cin >> n >> m;
        vector<string> a(n);
        for (int i = 0; i < n; ++i)
        {
                cin >> a[i];
        }
        for (int i = 0; i < m + 2; ++i)
        {
                cout << "#";
        }
        cout << endl;
        for (int i = 0; i < n; ++i)
        {
                cout << "#";
                for (int j = 0; j < a[i].size(); ++j)
                {
                        cout << a[i][j];
                }
                cout << "#" << endl;
        }
        for (int i = 0; i < m + 2; ++i)
        {
                cout << "#";
        }
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	solve();
}


Measured memory_bytes: 3620
people,point,quiz = map(int,input().split())
an = [int(input()) for _ in range(quiz)]
each_p = [point-quiz] * people

for x in an:
    each_p[x-1] += 1

for y in each_p:
    if y <= 0:
        print("No")
    else:
        print("Yes")


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

int main (){
	int n,x;
	while ( cin >> n >> x){
		if ( n == 0 && x == 0){
			break;
		}
		int anw = 0;
		for ( int p = 1 ; p < n - 1 ; p++)
		{
			for ( int  y = p + 1 ; y < n ; y++)
			{
				for ( int z = y + 1 ; z < n + 1 ; z++)
				{
					if ( x == p + y + z)
					{
						anw++;
					}
				}
			}
		}
		cout << anw << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

vector<pair<ll,ll>> factor_arr;

void myfactor(ll num){ 
    ll count = 0;   
    while (!(num % 2)) { 
        num >>= 1; count++; 
    }  
    if (count) factor_arr.push_back({2,count}); 
    for (auto i = 3; i <= sqrt(num); i += 2) { 
        count = 0; 
        while (num % i == 0) { 
            count++; 
            num /= i; 
        } 
        if (count) factor_arr.push_back({i,count}); 
    } 
    if (num > 2) factor_arr.push_back({num,1});
}

void virus(){
        ll t;cin>>t;
        if(t>=30) cout<<"Yes\n";
        else cout<<"No\n";
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k; cin >> n >> k;
    string s; cin >> s;
    vector<int> nums;
    int now = 1;
    int cnt = 0;
    rep(i,n) {
        if(s[i]==(char)('0'+now)) cnt++;
        else {
            nums.push_back(cnt);
            now ^= 1;
            cnt = 1;
        }
    }
    if(cnt) nums.push_back(cnt);
    if(nums.size()%2==0) nums.push_back(0);

    int ans = 0;
    int add = 2*k+1;
    int left = 0;
    int right = 0;
    int tmp = 0;
    for(int i = 0; i < nums.size(); i += 2) {
        int nleft = i;
        int nright = min(i+add,(int)nums.size());
        while(nleft > left) {
            tmp -= nums[left];
            left++;
        }
        while(nright > right) {
            tmp += nums[right];
            right++;
        }
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <utility>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <climits>

using namespace std;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void printA(const vector< vector<char> >& a) {
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < a[i].size(); j++) {
			cout << a[i][j];
		}
		cout << endl;
	}
}

void printAns(const vector< vector<int> >& a) {
	for (int i = 0; i < a.size(); i++) {
		for (int j = 0; j < a[i].size(); j++) {
			cout << a[i][j] << ' ';
		}
		cout << endl;
	}
}

int main() {
	int h, w;
	cin >> h >> w;

	vector< vector<char> > a(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}

	vector< vector<int> > ans(h, vector<int>(w, INT_MAX));

	// for right
	for (int i = 0; i < h; i++) {
		bool hitBlack = false;
		for (int j = 0; j < w; j++) {
			if (a[i][j] == '#') {
				hitBlack = true;
				ans[i][j] = 0;
			}
			else if (hitBlack) {
				chmin(ans[i][j], ans[i][j - 1] + 1);
			}
		}
	}

	// for left
	for (int i = 0; i < h; i++) {
		bool hitBlack = false;
		for (int j = w - 1; j >= 0; j--) {
			if ((!hitBlack) && (ans[i][j] != INT_MAX)) {
				hitBlack = true;
				continue;
			}
			
			if (hitBlack) {
				chmin(ans[i][j], ans[i][j + 1] + 1);
			}
		}
	}

	// for bottom
	for (int j = 0; j < w; j++) {
		bool hitBlack = false;
		for (int i = 0; i < h; i++) {
			if ((!hitBlack) && (ans[i][j] != INT_MAX)) {
				hitBlack = true;
				continue;
			}
			
			if (hitBlack) {
				chmin(ans[i][j], ans[i - 1][j] + 1);
			}
		}
	}

	// for top
	for (int j = 0; j < w; j++) {
		bool hitBlack = false;
		for (int i = h - 1; i >= 0; i--) {
			if ((!hitBlack) && (ans[i][j] != INT_MAX)) {
				hitBlack = true;
				continue;
			}
			
			if (hitBlack) {
				chmin(ans[i][j], ans[i + 1][j] + 1);
			}
		}
	}

	//printAns(ans);

	int maxVal = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			chmax(maxVal, ans[i][j]);
		}
	}

	cout << maxVal << endl;
	return 0;
}

Measured memory_bytes: 5248
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>

#define ll long long

using namespace std;

size_t H, W;
char mine = '#';
vector<vector<char>> S;
vector<vector<int>> a;

bool inarea(int k, int l)
{
    return (k >= 0 && k < H && l >= 0 && l < W);
}

void calc(int i, int j)
{
    for (int k = i - 1; k <= i + 1; k++) {
        for (int l = j - 1; l <= j + 1; l++) {
            if (inarea(k, l) && !(i == k && j == l)) {
                if (S[k][l] == mine) {
                    a[i][j]++;
                }
            }
        }
    }
}


int main()
{
    cin >> H >> W;
    S.resize(H);
    a.resize(H);
    for (size_t i = 0; i < H; i++) {
        S[i].resize(W);
        a[i].resize(W);
        for (size_t j = 0; j < W; j++) {
            cin >> S[i][j];
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                a[i][j] = -1;
            } else {
                a[i][j] = 0;
                calc(i, j);
            }
        }
    }

    for (size_t i = 0; i < H; i++) {
        for (size_t j = 0; j < W; j++) {
            if (a[i][j] < 0) {
                cout << '#';
            } else {
                cout << a[i][j];
            }
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * http://abc086.contest.atcoder.jp/tasks/abc086_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		
		int num = Integer.parseInt(a+b);
		int sqrt = (int)Math.sqrt(num);
		String ans = num==sqrt*sqrt ? "Yes" : "No";
		System.out.println(ans);
		

	}

}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
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; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll a,b,c;cin>>a>>b>>c;

  if(c-a-b<0)out("No");
  else{
    if(4*a*b<(c-a-b)*(c-a-b))out("Yes");
    else out("No");
  }


  return 0;
}


Measured memory_bytes: 256