akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <vector>

using namespace std;

int main(){

  int n=0, cnt=0;
  cin >> n;
  vector<int> p(n);

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

  for(int i=1; i<n-1; ++i){
    if (p[i-1]>p[i] && p[i]>p[i+1]){
      ++cnt;
    }else if (p[i-1]<p[i] && p[i]<p[i+1]){
      ++cnt;
    }
  }

  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ull t;cin>>t;while(t--)
#define pll pair<ll,ll>
#define puu pair<ull,ull>
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define Vint vector<int>
#define Vll vector<ll>
#define Vull vector<ull>
#define nl cout<<endl
#define sp cout<<" "
#define MOD 1000000007
#define all(x) x.begin(),x.end()
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
 
int main() 
{
	// ios::sync_with_stdio(0);
	// cin.tie(0);
	// cout.tie(0);
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll ans = LLONG_MIN;
	ans = max(ans,a*c);
	ans = max(ans,a*d);
	ans = max(ans,b*c);
	ans = max(ans,b*d);
	cout<<ans;

}

Measured memory_bytes: 3644
#include<stdio.h>

int main(void)
{
	int m, f, r;
	int s;

	while(1){
		scanf("%d%d%d", &m, &f, &r);
		if(m == -1 && f == -1 && r == -1) break;
		if(m < 0 || f < 0) puts("F");
		else{
			s = m + f;
			if(s >= 80)
				puts("A");
			else if (s >= 65)
				puts("B");
			else if (s >= 50)
				puts("C");
			else if (s < 30)
				puts("F");
			else if (r >= 50)
				puts("C");
			else if (r < 50)
				puts("D");
		}
	}
	return 0;
}


Measured memory_bytes: 2072
#include <cstdio>
#include <vector>
using namespace std;
int main () {
  int H, W;
  while(1) {
    scanf("%d %d", &H, &W);
    if(H == 0 && W == 0)
      break;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
	if((i + j) % 2 == 0)
	  printf("#");
	else
	  printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
}

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

int main(){
  long long n,c,k;
  long long answer = 0;
  cin >> n >> c >> k;
  vector<long long> time(n);
  
  for(int i=0; i<n; i++){
    cin >> time[i];
  }
  sort(time.begin(), time.end());
  
  for(int i=0; i<n;){
    long long limit = time[i]+k, ii=i, count=0;
    while(count < c){
      if(time[ii] <= limit){
        count++;
      }else{
        break;
      }
      ii++;
    }
    answer++;
    i += count;
  }
  
  cout << answer << endl;
  
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
  int[] a = new int[200];
  int top;

  Main(){
    top = 0;
  }

  void push(int x){
    a[++top] = x;
  }

  int pop(){
    return a[top--];
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);

    Main stack = new Main();


    while(stdIn.hasNext()){
      String input = stdIn.next();

      if(input.equals("+")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a + b);
      }
      else if(input.equals("*")){
        int a = stack.pop();
        int b = stack.pop();
        stack.push(a * b);
      }
      else if(input.equals("-")){
        int b = stack.pop();
        int a = stack.pop();
        stack.push(a-b);
      }
      else
        stack.push(Integer.parseInt(input));

    }


    System.out.println(stack.pop());
  }
}

Measured memory_bytes: 26060
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 62296
// Date: 2020-02-26

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef long double LD;
typedef vector<int> VI;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
#define FIO ios::sync_with_stdio(false);cin.tie(0)
#define rep(i, a, b) for(int i = int(a); i <= int(b); ++i)
#define per(i, b, a) for(int i = int(b); i >= int(a); --i)
#define mem(x, y) memset(x, y, sizeof(x))
#define all(x) (x).begin(),(x).end()
#define mk make_pair
#define pb push_back
#define fi first
#define se second
const LL INF = 1e18;
const LL mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int N = 700 + 10;
template <typename T> void chkMax(T &x, T y) { x = max(x, y); }
template <typename T> void chkMin(T &x, T y) { x = min(x, y); }
LL qpow(LL x, LL y, LL MOD) {LL a=1; while(y){ if(y&1) a=a*x%MOD; x=x*x%MOD; y>>=1; } return a;}

int n, m;
int f[N], g[N][N], col[N], sz[N][2], tot;
bool flag;

void dfs(int u, int id) {
    sz[id][col[u]-1]++;
    rep(v, 1, n) if(!g[u][v]) {
        if(col[v]) {
            if(col[v] == col[u]) {
                flag = 0;
                return;
            }
        } else {
            col[v] = 3-col[u];
            dfs(v, id);
        }
    }
}

int solve() {
    f[0] = 1;
    rep(i, 1, tot) {
        per(j, n, 0) {
            bool x = false;
            if(j >= sz[i][0]) x |= f[j-sz[i][0]];
            if(j >= sz[i][1]) x |= f[j-sz[i][1]];
			f[j] = x;
        }
    }
    int ans = inf;
    rep(i, 0, n) {
        if(f[i]) chkMin(ans, (i*(i-1)+(n-i)*(n-i-1))/2);
    }
    return ans;
}

int main() {
    scanf("%d%d", &n, &m);
    rep(i, 1, m) {
        int u, v;
        scanf("%d%d", &u, &v);
        g[u][v] = g[v][u] = 1;
    }
    rep(i, 1, n) g[i][i] = 1;
    flag = 1;
    rep(i, 1, n) if(!col[i]) {
        ++tot;
        col[i] = 1, dfs(i, tot);
    }
    if(!flag) {
        puts("-1");
        return 0;
    }
    printf("%d\n", solve());
    

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h> 
#define pb push_back
#define mp make_pair 
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
#define F(i,n) for(i=0;i<n;i++)
  
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;

int32_t main() {

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

    int n,m,i,sum=0,count=0,a[10000];
    cin>>n>>m;
    F(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    //sort(a,a+n,greater<int>());
    int store=ceil((sum/(4.0*(double)m)));
    for(i=0;i<n;i++){
        if(a[i]>=store)
        count++;
    }
    //cout<<count<<" "<<sum<<" "<<store<<endl;
   if(count>=m)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    


}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  ll ans=0;
  rep(i,10)rep(j,10)rep(k,10){
    int x=0;
    rep(l,n){
      if(x==2){
        if(s[l]=='0'+k)x++;
      }
      if(x==1){
        if(s[l]=='0'+j)x++;
      }
      if(x==0){
        if(s[l]=='0'+i)x++;
      }
      if(x==3){
        ans++;
        x++;
      }
    }
  }
  cout << ans << endl;
      
      
}

Measured memory_bytes: 3680
import sys
input=sys.stdin.readline
n=int(input())
cnt=n
for i in range(n):
	a=int(input())
	if a==1:
		cnt-=1
		continue
	for j in range(2,min(int(a**0.5)+2,a)):
		if a%j==0:
			cnt-=1
			break
print(cnt)



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


int main()
{
	int staySum, specialBorder, normalPrice, specialPrice,Kbox;
	cin >> staySum >> specialBorder >> normalPrice >> specialPrice;
	if (staySum <= specialBorder) {
		specialPrice = 0; Kbox = staySum;
	}
	else Kbox = specialBorder;//Kboxみたいな役割なんていうんやろな…
	cout << normalPrice *  Kbox + (staySum - specialBorder) * specialPrice << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = 0
while max(a) >= n:
    count = 0
    for i in range(n):
        count += a[i]//n
        a[i] = a[i]%n - a[i]//n
    for i in range(n):
        a[i] += count
    ans += count
print(ans)


Measured memory_bytes: 41452
#include <stdio.h>
 
int a , b, c;
 
int main(void) {
  	scanf("%d %d %d", &a, &b, &c); 
  	if ((a == b && b != c) || (a == c && a != b) || (b == c && b != a)) {
      printf("Yes");
    }
  	else printf("No");
	return 0;
}

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

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

    bool flag = true;
    for (auto k : nums){
        if (k % 2 == 0){
            if (k % 3 != 0 && k % 5 != 0){
                flag = false;
                break;
            }
        }
    }
    if (flag){
        cout << "APPROVED" << endl;
    } else {
        cout << "DENIED" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------

signed main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3112
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import re

BIGNUM = 10 ** 9 + 7

def main():
    A, B, C = map(int, input().split())

    if C <= A+B+1:
        print(C+B)
    else:
        print(B+(B+A)+1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <algorithm>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.rbegin(), v.rend());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define MOD (ll)(1e9+7)
#define MAX (ll)(1e5*2+200)
#define print(x) cout << x << endl;
#define length(arr) sizeof arr / sizeof arr[0];
#define printArr(arr) REP(i, (sizeof arr / sizeof arr[0])){print(arr[i])}
#define printVec(vec) REP(i, vec.size()){print(vec[i])}

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A, B;
    cin >> N >> A >> B;
    ll x0, x1;
    cin >> x0;
    ll ans = 0;
    REP(i, N-1){
        cin >> x1;
        ans += min((x1-x0)*A, B);
        x0 = x1;
    }
    print(ans);
    return 0;
}


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

int main()
{
    int a, b;
    cin >> a >> b;
    if (b < 10)
    {
        b += 10 * a;
    }
    else if (b < 100)
    {
        b += 100 * a;
    }
    else
    {
        b += 1000 * a;
    }
    for (int i = 1; i * i <= b; i++)
    {
        if (i * i == b)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <stdio.h>
#include <map>
#define MAXN 200005
using namespace std;
int a[500];
int main(){
    int n,d,x,cost = 0;
	scanf("%d%d%d",&n,&d,&x);
	for(int i = 1;i<=n;i++)
	  scanf("%d",&a[i]);
	  for(int i =1;i<=n;i++){
	  	for(int j = 1;j*a[i]+1<=d;j++)
	  	  cost++;
	  }	
	  cost+=n;
	  printf("%d\n",cost+x);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n;
	cin >> n;
	int i, j;
	string s = "No";
	for (i = 1; i < 10; i++)
	{
		for (j = 1; j < 10; j++)
		{
			if (n == i * j)
				s = "Yes";
		}
	}
	cout << s << endl;
	
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<cstring>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;

int main(){
    int a,b;
    int tmp, tim;
    int len;
    string s;
    string ans="Yes";
    cin >> a >> b;
    cin >> s;

    tim=0;
    for(int i=0; i<a; i++){
        if(s[i]=='-'){
            ans = "No";
        }
    }
    if(s[a]!='-'){
        ans = "No";
    }
    for(int i=a+1; i<a+b; i++){
        if(s[i]=='-'){
            ans="No";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
     string a,b,c;
     cin>>a>>b>>c;
     cout<<a[0];
     cout<<b[0];
     cout<<c[0];

    return 0;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
int topping = 100, hasil = 700;
string s;
cin>>s;
for (int i=0;i<s.length();i++)
{
    if (s[i] == 'o')
    {
        hasil+=100;
    }
}
cout<<hasil<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int a[3], b[2];
  cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1];
  cout << min(min(a[0], a[1]), a[2]) + min(b[0], b[1]) - 50 << endl;
  return 0;
}

Measured memory_bytes: 1160
def solve(dx, dy):
    route = 'U'*dy + 'R'*dx + 'D'*dy + 'L'*(dx+1) \
        + 'U'*(dy+1) + 'R'*(dx+1) + 'DR' \
        + 'D'*(dy+1) + 'L'*(dx+1) + 'U'
    print(route)

def main():
    sx, sy, tx, ty = map(int, input().split())
    solve(tx-sx, ty-sy)

main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
# define f(a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define ll long long
#define INF 1000000000
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define fast ios::sync_with_stdio(0);cin.tie(0);
void solveA()
{
	int n,m,y;
	cin>>n>>m;
	map<int,int> mp;
	for(int i=0;i<m;i++) cin>>y,mp[y]=1;
	int found=0,x=1;
	if(mp[n]==0) {
		cout<<n<<endl;
		return;	
	}
	while(1)
	{
		//cout<<x<<endl;
		if(mp[n-x]==0) {
			cout<<n-x<<endl;
			return;
		}
		else if(mp[n+x]==0)
		{
			cout<<n+x<<endl;
			return;	
		}
		else
			x++;
	}
}
int main()
{
	fast;
//	int t;
//	cin>>t;
//	while(t--)
	solveA();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast() {std::cin.tie(0); ios::sync_with_stdio(false);}} fast;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define MOD 1000000007

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    vector<pair<ll, ll>> D(M);
    rep(i, M) {
        ll b, c; cin >> b >> c;
        D[i] = mp(c, b);
    }

    sort(all(D), greater<pair<ll, ll>>());

    int x = 0;
    bool f = true;

    rep(i, M) {
        ll b, c;
        tie(c, b) = D[i];

        rep(j, b) {
            if (c <= A[x] || x >= N) {
                f = false;
                break;
            }
            else {
                A[x] = c;
                x++;
            }
        }
        if (!f) break;
    }

    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
}


Measured memory_bytes: 2560
S = list("abcdefghijklmnopqrstuvwxyz")

N = int(input())

P = 0

for i in range(1,15):
    if P+26**i >= N:
        n = i
        break
    else:
        P += 26**i
        
X = [0]*n

NN = N - P - 1###0-indexedの26進法なので
for i in range(n):
    X[n-i-1] = S[NN % 26]
    NN //= 26

print("".join(X))



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

int main()
{
   int64_t A,B,C;
  cin >> A >> B >> C;
  if(A+B>=C)
  {
    cout << "No" << endl;
  }
  else
  {
    if(4*A*B<(C-A-B)*(C-A-B))
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    ll divisor = 1000000007;
    ll comb(ll n , ll r){
    //cout << "comb_n:" << n << " comb_r:" << r << endl;
    if(n < 0 || r < 0 || r > n){
    cout << "comb-error" << endl;
    }
    if(n - r < r) r = n - r;
    if(r == 0) return 1;
    if(r == 1) return n;
    vector<ll> num, deno;
    for(ll k = 0 ; k < r; k++){
    num.push_back(n-r+k+1);
    deno.push_back(k+1);
    }
    ll pivot , offset;
     for(ll p = 2; p <= r ; p++){
    pivot = deno[p-1];
    if(pivot > 1){
    offset = (n - r) % p;
    for(ll k = p - 1 ; k < r; k+= p){
    num[k - offset] /= pivot;
    deno[k] /= pivot; 
    }
    }
    }
    ll result = 1;
    for(ll k = 0; k < r ; k++){
    if(num[k] > 1) result *= num[k];
    result = result % divisor;
    }
    //cout << "comb:" << result << endl;
    return result;
    }

    
    int main(){
        ll n , k;
        cin >> n >> k;
        ll a , b , c , d , red , blue , ans;
        for(ll i = 1 ; i <= k ; i++){
            if( n - k < i - 1 || k < i ){
                cout << 0 << endl;
                continue;
            }
            if(n - k == i - 1){
                red = 1;
            }else{
                red = comb(n - k + 1 , n - k - i + 1);
            }
            if(i == k){
                blue = 1;
            }else{
                blue = comb( k - 1 , k - i);
            }
            
            ans = red * blue % divisor;
            cout << ans << endl;
        }
        
        
        return 0;
        
    }

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

ll f(ll n) {
	if (n == 1)return 1;
	return 2 * f(n / 2) + 1;
}

int main() {
	ll h;
	cin >> h;
	cout << f(h) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

  int r,g,b,n;
  scanf("%d %d %d %d", &r, &g, &b, &n);
  long count = 0;
  int left;
  for (int i = 0; i*r <= n; i++) {
    for (int j = 0; i*r+j*g <= n; j++) {
      left = n-i*r-j*g;
      if (left%b == 0 && left/b >= 0) {
        count++;
      }
    }
  }
  printf("%ld\n", count);

  return 0;
}

Measured memory_bytes: 128
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;



int main()
{
  int n;
  cin >> n;
  int a = 0;
  for(int i = 1; i <= n; i++) {
    int x; cin >> x;
    if((i & 1) && (x & 1))
      a++;
  }
  cout << a << endl;
  return 0;
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String s[] = S.split("");
        String T = sc.next();
        String t[] = T.split("");
        int sum = 0;
        for(int i=0;i<S.length();i++)
        {
            if(s[i].equals(t[i]))
            {
                sum++;
            }
        }
        if(sum== S.length())
        {
            System.out.println("Yes");
        }
        else
        {
            System.out.println("No");
        }
        
    }
}


Measured memory_bytes: 35764
// 22
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define fors(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fors(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define forrs(_, x, n, s) for (int _ = x; _ > n; _ -= s)
#define forrn(_, x, n) forrs(_, x, n, 1)
#define rrep(_, n) forrn(_, n - 1, -1)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> adj(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].pb(y);
  }
  vector<int> lp(n);
  function<int(int)> dfs = [&](int u) {
    if (lp[u] != 0) return lp[u];
    int maxL = 0;
    for (auto & v : adj[u]) maxL = max(maxL, dfs(v));
    return lp[u] = maxL + 1;
  };
  int ans = 0;
  rep(i, n) {
    ans = max(ans, dfs(i));
  }
  cout << ans - 1 << endl;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 8832
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ a, b, c ] <- readInts
	print $ a * b `div` 2

Measured memory_bytes: 380
#include<cstdio>
#include<cmath>
#include<algorithm>
#define MAXN 2000+5

using namespace std;

int main() {
	int n;
	scanf("%d",&n);
	int a,b,c,d;
	a=n%10,n/=10;
	b=n%10,n/=10;
	c=n%10,n/=10;
	d=n%10,n/=10;
	if(a==b&&b==c&&c==d){
		printf("Yes");
	}
	else if((a==b&&b==c)||(b==c&&c==d)){
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

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

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

  if (x=='a'||x=='i'||x=='u'||x=='e'||x=='o'){
    cout << "vowel"<< endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3564
#include<stdio.h>
#define M 100
#define NIL -1
#define WHITE 1
#define BLACK 0

int G[M][M];
int n;
int INFTY = 1<<21;
int prim();

int main(){
  int i;
  int j;
  int x;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&x);
      if(x == -1) G[i][j] = INFTY;
      else G[i][j] = x;
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int u,mincost,i,v,sum=0;
  int color[M],d[M],pi[M];

  for(u=0;u<n;u++){
    d[u] = INFTY;
    pi[u] = NIL;
    color[u] = WHITE;
  }
  d[0] = 0;
  
  while(1){
    mincost = INFTY;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INFTY) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && G[u][v] < d[v]){
	pi[v] = u;
	d[v] = G[u][v];
      }
    }
  }
  for(i=0;i<n;i++){
    if(pi[i] != -1) sum += G[i][pi[i]];
  }
  return sum;
}



Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


int main() {
	int n, q; cin >> n >> q;
	vector<int> a(n - 1), b(n - 1);
	vector<vector<int>> g(n);
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i] >> b[i];
		a[i] -= 1; b[i] -= 1;
		g[b[i]].emplace_back(a[i]);
	}

	for (int i = 0; i < n; i++) {
		sort(g[i].begin(), g[i].end());
	}

	vector<int> p(n, 0);//クエリの+値を保持。

	for (int i = 0; i < q; i++) {
		int a, b; cin >> a >> b;
		a--;
		p[a] += b;
	}

	vector<int> ans(n);
	ans[0] = p[0];
	for (int i = 1; i < n; i++) {
		int check= *lower_bound(g[i].begin(), g[i].end(), 0);
		ans[i] = p[i] + ans[check];
	}

	for (auto x : ans) {
		cout << x << " ";
	}





	return 0;
}

Measured memory_bytes: 16512
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


def comb(n, r):
    if r > n: return 0
    fact = 1
    for i in range(n - r + 1, n + 1):
        fact = fact * i % mod

    divisor = 1
    for j in range(1, r + 1):
        divisor = divisor * j % mod

    return fact * pow(divisor, mod - 2, mod) % mod



n,k = LI()
for i in range(1, k+1):
    print(comb(n - k + 1, i) * comb(k - 1, i - 1) % mod)

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

using namespace std;
const int maxn = 1e5+10;
int n,m;
int a,b,c,f;


int main(){
	string s;
	cin >> s;
	char c = s[s.length()-1];
	if(c=='2'||c=='4'||c=='5'||c=='7'||c=='9'){
		cout << "hon" << endl;
	}
	else if(c=='0'||c=='1'||c=='6'||c=='8'){
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
	
	
	
	
	
	return 0;
} 

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;
using ll = long long;

ll wa[100001]={};
bool ac[100001]={};
int main(){
    ll n,m;
    cin >> n >> m;
    ll pena=0,accept=0;
    for(ll i=0;i<m;i++){
        string str;
        ll p;
        cin >> p >> str;
        if(ac[p-1]==0){
            if(str=="WA"){
                 wa[p-1]++;
            }
            else if(str=="AC"){
                 accept++;
                 ac[p-1] = 1;
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(ac[i]==1)    pena+=wa[i];
    }
    cout << accept << " " << pena << endl;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define M 2000000
#define INF 1000

#define parent(x) (x/2)
#define left(x) (x*2)
#define right(x) (x*2+1)

void insert(int *,int);
int extract(int *);
void heapIncreaseKey(int *,int,int);
void maxHeapify(int *,int);

int size;

int main(){
  int buf;
  int i;
  int A[M];
  char c[10];
  
  
  while(1){
    scanf("%s",c);
    if(strcmp(c,"end")==0) break;
    if(strcmp(c,"insert")==0){
      scanf("%d",&buf);
      insert(A,buf);
    }else printf("%d\n",extract(A));
  }
  
  return 0;
}

void insert(int *A,int buf){
  size=size+1;
  A[size]=-INF;
  heapIncreaseKey(A,size,buf);
}

void heapIncreaseKey(int *A,int i,int buf){
  int temp;
  
  if(buf<A[i]) fprintf(stderr,"new key is smaller than current key\n");
  A[i]=buf;
  while(i>1 && A[parent(i)]<A[i]){
    temp=A[i];
    A[i]=A[parent(i)];
    A[parent(i)]=temp;
    
    i=parent(i);
  }
}

int extract(int *A){
  int max;
  if(size < 1) fprintf(stderr,"heap underflow\n");
  max=A[1];
  A[1]=A[size];
  size--;
  maxHeapify(A,1);
  return max;
}

void maxHeapify(int *A,int i){
  int l,r,large,temp;

  l=left(i);
  r=right(i);

  if(l<=size && A[l]>A[i]) large=l;
  else large=i;
  if(r<=size && A[r] > A[large]) large=r;
  if(large!=i){
    temp=A[i];
    A[i]=A[large];
    A[large]=temp;
    maxHeapify(A,large);
  }
}



Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define eF(i,u) for(int i=h[u];i;i=nxt[i])
#define Mod 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll,int> pli;

int n,m,S,T;
ll Ans;
int U[200001],V[200001],D[200001];
int h[100001],nxt[400001],to[400001],w[400001],tot;
void ins(int x,int y,int z){nxt[++tot]=h[x];to[tot]=y;w[tot]=z;h[x]=tot;}

ll d1[100001],d2[100001],g1[100001],g2[100001];bool v1[100001],v2[100001];
priority_queue<pli,vector<pli>,greater<pli> > pq;

void Dij(ll*d,ll*g,bool*v,int s){
	d[s]=0ll;
	pq.push(pli(0ll,s));
	g[s]=1;
	while(!pq.empty()){
		pli P=pq.top(); pq.pop();
		int u=P.second; ll du=P.first;
		if(v[u]||d[u]<du) continue;
		v[u]=1;
		eF(i,u){
			if(d[to[i]]==du+w[i])
				g[to[i]]=(g[to[i]]+g[u])%Mod;
			if(d[to[i]]>du+w[i])
				g[to[i]]=g[u],
				d[to[i]]=du+w[i], pq.push(pli(d[to[i]],to[i]));
		}
	}
}

int main(){
	int x,y,z;
	scanf("%d%d",&n,&m);
	scanf("%d%d",&S,&T);
	F(i,1,m) scanf("%d%d%d",&x,&y,&z), ins(x,y,z), ins(y,x,z), U[i]=x, V[i]=y, D[i]=z;
	memset(d1,0x3f,sizeof d1);
	Dij(d1,g1,v1,S);
	memset(d2,0x3f,sizeof d2);
	Dij(d2,g2,v2,T);
	ll Dist=d1[T];
	Ans=g1[T]*g1[T]%Mod;
	F(i,1,n){
		if(d1[i]+d2[i]==Dist&&d1[i]==d2[i])
			Ans=(Ans-g1[i]*g1[i]%Mod*g2[i]%Mod*g2[i]%Mod)%Mod;
	}
	int u,v,d;
	F(i,1,m){
		u=U[i], v=V[i], d=D[i];
		if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
			Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
		}
		u=V[i], v=U[i], d=D[i];
		if(d1[u]+d+d2[v]==Dist && d1[u]+d>d2[v] && d2[v]+d>d1[u]){
			Ans=(Ans-g1[u]*g2[v]%Mod*g1[u]%Mod*g2[v]%Mod)%Mod;
		}
	}
	printf("%lld",(Ans%Mod+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 15632
#include <stdio.h>

int main(void) {
    int n,x;
    while(1) {
        scanf( "%d %d", &n, &x );
        if( n==0 && x==0 ) break;
        int sum=0;
        for( int  a=1; a<=n-2; a++ ){
            for( int b=a+1; b<=n-1; b++){
                int c=x-a-b;
                if( b<c && c<=n ) sum+=1;
            }
        }
        printf( "%d\n", sum );
    }
    return 0;
}


Measured memory_bytes: 2732
#include <iostream>
using namespace std;
int main()
{
  int a, b;
  cin >> a >> b;
  string ans = "";
  if (0 < a && 0 < b)
    ans = "Positive";
  if (a <= 0 && 0 <= b)
    ans = "Zero";
  if (a < 0 && b < 0)
  {
    if ((-1 * a + (-1) * b) % 2 == 0)
      ans = "Negative";
    else
      ans = "Positive";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    ans = 0

    for i in range(1, n):
        if a[i] == a[i - 1]:
            a[i] = 1001
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


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

const int MAXN = 1e3;
int a[MAXN];

int main(void){
    string s;
    cin >> s;
    for(int i=0; i<s.size(); i++){
        if(a[s[i]-'0']){
            cout << "no" << endl;
            return 0;
        }
        a[s[i]-'0']++;
    }
    cout << "yes" << endl;
    return 0;
}

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

int N,res;
vector<int>A;
int main(){
	cin>>N;
	A=vector<int>(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	sort(A.begin(),A.end());
	for(int i=0;i<A.size();i++){
		if(i!=A.size()-1&&A[i]==A[i+1])continue;
		bool f=true;
		for(int j=1;j*j<=A[i];j++){
			if(A[i]%j==0){
				if(binary_search(A.begin(),A.begin()+i,j)||binary_search(A.begin(),A.begin()+i,A[i]/j)){
					f=false;
					break;
				}
			}
		}
		res+=f;
	}
	cout<<res<<endl;
}


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



int main(){
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    vector<int> c(26);  
    vector<vector<int>> s(D,vector<int>(26));
    rep(i,26) cin >> c[i];    
    rep(d,D) rep(i, 26) cin >> s[d][i];

    vector<int> t(D);
    vector<int> last(26,-1);
    int ans = 0;
    rep(d,D) {
        cin >> t[d];
        t[d]--;
        ans += s[d][t[d]];
        last[t[d]] = d;
        rep(i,26) {
            ans -= c[i]*(d-last[i]);
        }
        cout << ans << endl;
    }
    //chmax(ans,0);
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> v(n),c(n);
  rep(i, 0, n) cin >> v[i];
  rep(i, 0, n) cin >> c[i];
  int ans = 0;
  rep(i,0,n){
    if (v[i] > c[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265
 
const ll N = 100005;

void solve(){
    string s;
    cin>>s;
    map<ll,ll> m;
    ll n = s.length();
    ll res=0;
    m[0]++;
    ll p = 1;
    ll q = 2019;
    ll cnt = 0;
    repb(i,n-1,0){
        res = (res + (s[i]-'0')*p)%q;
        p = (p*10)%q;
        cnt += m[res];
        m[res]++;
    }
    cout<<cnt<<endl;
    return;
}

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

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

#define MEM(a, b) memset(a, (b), sizeof(a))
#define PI 3.1415926535897932384626433832795
#define endl '\n'
#define exists(s, e) (s.find(e)!=s.end())
#define WHILE(n)
#define pb push_back
#define f first
#define s second
#define UNI(vec) vec.erase(std::unique(vec.begin(), vec.end()),vec.end());
#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;
typedef long long ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::pair<int, pii> piii;

const ll INF = 0x3f3f3f3f;
#define MAXN 401
using namespace std;
ll n,m,ans;
ll dp[MAXN][MAXN], psa[MAXN];
vector<ll> a; bool b[MAXN];
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    MEM(dp,INF);
    cin>>n; a.pb(0);
    for (int i =1,x; i <= n; i++){
        cin>>x;
        a.pb(x);
        psa[i] = psa[i-1] + x;
    }
    for(int i = 1; i <= n; i++){
        dp[i][i] = 0;
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j+i <= n; j++){
            for(int k = j; k < i+j; k++){
                dp[j][i+j] = min(dp[j][i+j], dp[j][k] + dp[k+1][i+j] + psa[i+j] - psa[j-1]);
                //cout<<j<<" "<<k<<" "<<i+j<<endl;
                //cout<<psa[j-1]<<endl;
            }
        }
    }

    cout<<dp[1][n];



}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, R; cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100 * (10 - N) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)

	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&arr[i])
	}

	sort.Sort(sort.Reverse(sort.IntSlice(arr)))

	alice := 0
	bob := 0
	for i := 0; i < n; i++ {
		if i%2 == 0 {
			alice += arr[i]
		} else {
			bob += arr[i]
		}
	}
	fmt.Println(alice - bob)
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_M = 100001;

ll a[100001] = {};
ll s[100001] = {};
ll b[100001] = {};
ll w[100001] = {};

int main() {
	ll n, k; cin >> n >> k;
	repe(i, 1, n) {
		cin >> a[i];
		s[i] += s[i - 1] + a[i];

		if (a[i] > 0) {
			b[i] += b[i - 1] + a[i];
			w[i] += w[i - 1];
		}
		else {
			w[i] += w[i - 1] + a[i];
			b[i] += b[i - 1];
		}
	}
	ll ans = 0;
	repe(i, 1, n - k + 1) {
		ll minW = b[i - 1] - b[0]
			+ b[n] - b[i + k - 1];
		ll minB = s[i + k - 1] - s[i - 1]
			+ minW;

		ans = max(max(minW, minB), ans);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

s, = map(str, input().split())
t, = map(str, input().split())

slist = list(s)
tlist = list(t)

ans= 0
for i in range(len(slist)):
    if slist[i] == tlist[i]:
        ans+=1

print(ans)


Measured memory_bytes: 13876
import sys
import numpy as np

n,m = map(int, input().split())
a = [list(input()) for _ in range(n)]
b = [list(input()) for _ in range(m)]
a = np.array(a)
b = np.array(b)

for i in range(0, n-m+1):
    for j in range(0, n-m+1):
        if (a[i:i+m,j:j+m] == b).all():
            print('Yes')
            sys.exit()

print('No')

Measured memory_bytes: 12404
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <limits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define REP(i,b,n) for(i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

double ma = numeric_limits<double>::min(), mn = numeric_limits<double>::max();

int main()
{
	double a;
	
	while(cin >> a, !cin.eof())
	{
		ma = max(ma, a);
		mn = min(mn, a);
	}
	
	
	cout << ma - mn << endl;
	
	return 0;
}

Measured memory_bytes: 0
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int ans = a[0] + a[1];
		System.out.println(ans);
		sc.close();
	}
	
    
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

void solve()
{
  ll n,d1,d2,cnt=0;
  bool b=false,ans=false;
  cin>>n;
  while(n--)
  {
    cin>>d1>>d2;
    if(d1==d2 && (b))
    {
      cnt++;
    }
    else if(d1==d2 && !(b))
    {
      b=true;
      cnt++;
    }
    else if(d1!=d2 && (b))
    {
      b=false;
      cnt=0;
    }

    if(cnt==3)
    ans=true;
  }
  if(ans)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


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


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

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i = 0; i < N; i++) cin >> H.at(i);
  int ans = 0;
  int count = 0;
  for(int i = 0; i < N - 1; i++) {
    if (H.at(i) >= H.at(i + 1)) {
      count++;
      if (ans < count) {
        ans = count;
      }
    }
    else {
      count = 0;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef double db;
#define fo(i,j,k) for(i=j;i<=k;i++)
#define fd(i,j,k) for(i=j;i>=k;i--)
#define cmax(a,b) (a=(a>b)?a:b)
#define cmin(a,b) (a=(a<b)?a:b)
const int N=5e3+5,mo=1e9+7,rt=3;
ll f[N][N],i,j,n,m;
char s[N];
int main()
{
	scanf("%lld %s",&n,s+1);
	m=strlen(s+1);
	f[0][0]=1;
	fo(i,0,n-1)
		fo(j,0,i) 
		{
			(f[i+1][j+1]+=f[i][j])%=mo;
			if (j) 
				(f[i+1][j-1]+=f[i][j]*2)%=mo;
			else (f[i+1][j]+=f[i][j])%=mo;
		}
	printf("%lld\n",f[n][m]);
}

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

#define SWAP(a,b) ((a != b)? (a += b,b = a - b,a -= b) : 0 ) //数値のみ
#define SWAPs(type,a,b) { type temp = a; a = b; b = temp; } //型指定する ポインタ, 構造体等
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
  int a, b, n, ans = 0;
  map<string, int> m;
  string s;
  cin >> n;
  //vector<ll> c(n), v(n);
  //rep(i, n) cin >> c.at(i);
  rep(i, n){
    cin >> s;
    m[s]++;
  }
  cout << "AC x " << m["AC"] << "\nWA x " << m["WA"] << "\nTLE x " << m["TLE"] << "\nRE x " << m["RE"] << endl;
}


Measured memory_bytes: 3640
from collections import deque, defaultdict
import sys
def main():
    readline = sys.stdin.readline
    write = sys.stdout.write
    N = int(readline())
    G = [[] for i in range(N)]
    for i in range(N-1):
        a, b = map(int, readline().split()); a -= 1; b -= 1
        G[a].append(b)
        G[b].append(a)

    H = [-1]*N
    MOD = 10**9 + 9
    X1 = [0]*N; v1 = 13
    X2 = [0]*N; v2 = 17
    U = [0]*N
    que = deque([0])
    U[0] = 1
    D = [0]
    while que:
        v = que.popleft()
        for w in G[v]:
            if U[w]:
                continue
            U[w] = 1
            que.append(w)
            D.append(w)
    M = defaultdict(int)
    for v in reversed(D):
        h = 0
        su1 = su2 = 0
        for w in G[v]:
            if H[w] == -1:
                continue
            h = max(h, H[w])
            su1 += X1[w]; su2 += X2[w]
        H[v] = k = h+1
        X1[v] = w1 = (su1*v1 + 1) % MOD
        X2[v] = w2 = (su2*v2 + 1) % MOD
        M[k, w1, w2] += 1
    ans = 0
    for v in M.values():
        ans += v*(v-1)//2
    write("%d\n" % ans)
main()


Measured memory_bytes: 48880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int x[100], y[100];

ll calc(ll a, ll b) {
	return a * a + b * b;
}

int main() {
	cin >> N;
	REP(i, N) scanf("%d %d", x + i, y + i);
	
	vector<pair<double, int> > v;
	REP(i, N) {
		v.push_back(make_pair(atan2(y[i], x[i]), i));
		v.push_back(make_pair(v.back().fi + 2*M_PI, i));
	}
	sort(ALL(v));
		
	ll ans = 0;
	REP(i, N) {
		ll sumx = 0, sumy = 0;
		FOR(j, i, i + N) {
			int u = v[j].se;
			sumx += x[u];
			sumy += y[u];
			chmax(ans, calc(sumx, sumy));
		}
	}
	
	printf("%.15lf\n", sqrt(ans));
	
	return 0;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


bool func(int c, vector<int> h, int A, int B){
	int n = h.size();
	for (int i = 0; i < n; i++){
		h[i] -= B*c;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (h[i]>0)
			cnt += (int)ceil((double)h[i] / (A - B));
	}
	cerr << c << " " << (cnt <= c ? true : false) << endl;
	if (cnt <= c) return true;
	else return false;
}

signed main(){

	int N, A, B;
	vector<int> h;
	cin >> N >> A >> B;
	int sum = 0;
	for (int i = 0; i < N; i++){
		int t;
		cin >> t;
		h.push_back(t);
		sum += t / B+1;
	}
	sort(h.begin(), h.end(), greater<int>());

	int l = 0, r = sum;
	while (r - l > 1){
		int mid = (r + l) / 2;

		if (func(mid, h, A, B))
			r = mid;
		else
			l = mid;
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1908
# N//m==N%m=k
# N=k*m+k=k(m+1)=kM
N=int(input())
arr=[]
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        arr.append(N//i)
        if N//i!=i:
            arr.append(i)
arr.sort()

ans=0
for M in arr:
    m=M-1
    if m==0:continue
    if N%m==N//m:
        ans+=m
print(ans)
        


Measured memory_bytes: 66344