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

using namespace std;
using ll = long long;

const int MOD = 1000000007;
ll dp[101][4][4][4] = {0};

bool ng(int a, int b, int c) {
  return (a == 1 && b == 2 && c == 3);
}

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

  // TTT
  dp[0][0][0][0] = 1;

  // T = 0, A = 1, G = 2, C = 3
  for (int i = 0; i < N; i++) {
    for (int a = 0; a < 4; a++) {
      for (int b = 0; b < 4; b++) {
        for (int c = 0; c < 4; c++) {
          for (int d = 0; d < 4; d++) {
            // AGC, GAC, ACG
            if (ng(b, c, d) || ng(c, b, d) || ng(b, d, c)) continue;
            // AXGC, AGXC
            if (ng(a, c, d) || ng(a, b, d)) continue;

            dp[i + 1][b][c][d] = (dp[i + 1][b][c][d] + dp[i][a][b][c]) % MOD;
          }
        }
      }
    }
  }
  ll res = 0;
  for (int a = 0; a < 4; a++) {
    for (int b = 0; b < 4; b++) {
      for (int c = 0; c < 4; c++) {
        res = (res + dp[N][a][b][c]) % MOD;
      }
    }
  }
  cout << res << '\n';
  return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];

    vector<int> nums(n);
    for(int i = 0; i < n; i++) nums[i] = i+1;
    int cnt = 1;
    int ppos = 0, qpos = 0;
    while(next_permutation(nums.begin(), nums.end())){
        bool check = true;
        for(int i = 0; i < n; i++){
            if(nums[i] != p[i]) check = false;
        }
        if(check) ppos = cnt;

        check = true;
        for(int i = 0; i < n; i++){
            if(nums[i] != q[i]) check = false;
        }
        if(check) qpos = cnt;
        
        cnt++;
    }


    cout << abs(qpos - ppos) << endl;

    return 0;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 110;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

string s;
int q;
vector<char> b[2];
int rev = 0;
int beg = 0, en = 1;

void print() {
    FORE(i,SZ(b[beg])-1,0) cout << b[beg][i];
    if (rev) reverse(ALL(s));
    cout << s;
    FOR(i,0,SZ(b[en])-1) cout << b[en][i];
    cout << endl;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> s;
    cin >> q;

    while (q--) {
        int ch;
        cin >> ch;
        if (ch == 1) {
            rev = 1-rev;
            swap(beg, en);
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) b[beg].push_back(c);
            else b[en].push_back(c);
        }
    }
    print();
    
    return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
class Deux{
  public:
    int a, b;
    Deux() {
        a = 0;
        b = 0;
    }
    Deux(int w, int x) {
        a = w;
        b = x;
    }
};
bool cmp(const Deux &a1, const Deux &a2) {
    return a1.b > a2.b;
}
void Main(){
    int N = read(), M = read();
    int_fast64_t ans = 0;
    vector<int> A(N);
    for (auto& a:A) a = read();
    sort(A.begin(), A.end());
    vector<Deux> BC(M);
    int b, c;
    for (auto& bc:BC) {
        b = read();
        c = read();
        bc = Deux(b, c);
    }
    sort(BC.begin(), BC.end(), cmp);
    int i = 0, j = 0;
    for (; i < N; i++) {
        if (BC[j].a == 0) j++;
        if (BC[j].b <= A[i]) break;
        if (j >= M) break;
        ans += BC[j].b;
        BC[j].a--;
    }
    for (; i < N; i++) {
        ans += A[i];
    }
    printf("%lld\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long unsigned int ll;
 
int main() {
 
  int a,b,c,d;
  cin >> a;
  cin >>b;
  cin >>c;
  cin >>d;
  
  if(a+b>c+d){
    cout << "Left" << endl;
  }else if(a+b==c+d){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
  
   return 0;
}


Measured memory_bytes: 256
s = gets.chomp
str = 0
fin = 0
for i in 0..s.length-1
  if s[i] == "A"
    str = i
    break
  end
end
  
for i in 0..s.length-1
  if s[-1-i] == "Z"
    fin = s.length - i
    break
  end
end

puts fin - str

Measured memory_bytes: 2172
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define uqv(v) v.erase(unique(all(v)), v.end());
#define INF 1e9
#define LINF 1e18

using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2 * b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> beki;
    for(int i=1;i<35;i++) beki.push_back((1LL<<i) - 1);

    ll x = 0;
    REP(i,N){
        cin >> a[i];
        x ^= a[i];
    }
    ll ans = 0;

    for(int j = 32;j>=0;j--) if(x & (1 << j)){
        REP(i,N){
            ll ax = a[i] ^ (a[i]-1);
            if(ax == beki[j]){
                x ^= ax;
                ans++;
                break;
            }
        }
    }
    

    if(x == 0) cout << ans << endl;
    else cout << -1 << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define ll long long
using namespace std;

int n;

int main()
{
	cin.sync_with_stdio(0);		cin.tie(0);		cout.tie(0);

	cin >> n;
	int ans = 1000000000;
	for(int x = 1; x <= n - 1 ; x++){
		int a = x;
		int b = n - x;
		int now = 0;
		while(a > 0){
			now += a % 10;
			a = a / 10;
		}
		while(b > 0){
			now += b % 10;
			b = b / 10;
		}
		ans = min(ans,now);
	}
	cout << ans << "\n";
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        int ans =(X-Z)/(Y+Z);
        System.out.println(ans);
        }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    string s; cin >> s;
    int n = s.size();
    int cnt1 = 0;
    int cnt2 = 0;
    rep(i, n) {
        if(i%2==0 && s[i] == '1') {
            cnt1++;
        }
        if(i%2==1 && s[i] == '0') {
            cnt1++;
        }
        if(i%2==0 && s[i] == '0') {
            cnt2++;
        }
        if(i%2==1 && s[i] == '1') {
            cnt2++;
        }
    }
    cout << min(cnt1, cnt2);
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
	int N; cin >> N;
	ll res = 1;
	ll M = 1000000007;

	// 素数判定
	bool is_prime[1005];
	for (int i = 0; i <= N; i++)
		is_prime[i] = true;
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= N; i++) {
		if (is_prime[i]) {
			for (int j = i * 2; j <= N; j += i)
				is_prime[j] = false;
		}
	}
	// 素数格納
	int prime_num[1005];
	int p = 0;
	for (int i = 0; i <= N; i++)
		if (is_prime[i]) prime_num[p++] = i;

	// 素因数格納
	ll factor[1005];
	for (int i = 0; i < p; i++)
		factor[i] = 1;
	for (int i = 0; i < p; i++) {
		for (int j = 1; j <= N; j++) {
			int a = j;
			while (a%prime_num[i] == 0) {
				a /= prime_num[i];
				factor[i]++;
			}
		}
	}

	// 約数の個数を計算
	for (int i = 0; i < p; i++) {
		res *= factor[i];
		res %= M;
	}

	cout << res << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 256
data =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
line =int(input())

print(data[line -1])

Measured memory_bytes: 2940
#!/usr/bin/env python3
def main():
    a, b = map(int, input().split())

    can_a = str(a) * b
    can_b = str(b) * a
    if can_a < can_b:
        print(can_a)
    else:
        print(can_b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9040
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] a= new int[n+1];
    int[] b= new int[n];
    for(int i=0;i<=n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<n;i++){
      b[i]=sc.nextInt();
    }
    long df=0;
    for(int i=0;i<n;i++){
      int kl=Math.min(a[i],b[i]);
      df+=kl;
      b[i]=b[i]-kl;
      kl=Math.min(a[i+1],b[i]);
      df+=kl;
      a[i+1]=a[i+1]-kl;
    }
    System.out.println(df);
  }
}

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

long long f(long long x){
    if(x == 1) return 1;
    long long a = f(x/2);
    return a * 2 + 1;
}

int main(){
    long long h;
    cin >> h;
    cout << f(h) << endl;
    return 0;
}

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

int main() {
	static long long N, A[100000];
	vector<long long> V;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> A[i], V.push_back(A[i]);
	sort(V.begin(), V.end());
	V.erase(unique(V.begin(), V.end()), V.end());
	if (V.size() > 3) {
		cout << "No" << endl;
		return 0;
	}
	if (V.size() == 1) {
		if (V[0] != 0) {
			cout << "No" << endl;
			return 0;
		}
		else {
			cout << "Yes" << endl;
			return 0;
		}
	}
	else if (V.size() == 2) {
		if (V[0] != 0) {
			cout << "No";
			return 0;
		}
		else {
			map<int, int> mp;
			for (int i = 0; i < N; i++) {
				mp[A[i]]++;
			}
			if (mp[V[0]] == mp[V[1]] || mp[V[0]] * 2 == mp[V[1]]) {
				cout << "Yes" << endl;
				return 0;
			}
			else {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	if ((V[0] ^ V[1]) != V[2]) {
		cout << "No" << endl;
		return 0;
	}
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		mp[A[i]]++;
	}
	if (mp[V[0]] == mp[V[1]] && mp[V[1]] == mp[V[2]]) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1912
#include<bits/stdc++.h>
#define minf 0x80000000
using namespace std;
int n,k,r,s,p;
string t;

int add(vector<bool>&v,int i){
	int num;
	if(t.at(i)=='r')num=p;
	else if(t.at(i)=='s')num=r;
	else num=s;
	v.at(i)=true;
	return num;
}

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	cin>>n>>k>>r>>s>>p;
	cin>>t;
	vector<bool>v(t.size(),false);
	int ans=0;
	for(int i=0;i<v.size();++i){
		if(v.at(i)==false){
			ans+=add(v,i);
			bool change=true;
			for(int j=i+k;j<v.size();j+=k){
				if(t.at(j)==t.at(j-k)&&change==true){
					change=false;
					v.at(j)=true;
				}else if(t.at(j)==t.at(j-k)&&change==false){
					ans+=add(v,j);
					change=true;
				}else{
					ans+=add(v,j);
					if(j+k<v.size()&&t.at(j)==t.at(j+k)){
						change=true;
					}else{
						change=false;
					}
				}
			}
		}else break;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    bool flag = true;
    rep(i,n){
        int x; cin >> x;
        if(x % 2 == 0)
            if(x % 3 == 0 || x % 5 == 0);
            else flag = false;
    }
    cout << (flag? "APPROVED" : "DENIED");
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
import sys
from functools import lru_cache

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

MOD = 10 ** 9 + 7
N = ir()

def ok(last4):
    if last4.find('AGC') != -1:
        return False
    for i in range(3):
        s = list(last4)
        s[i], s[i+1] = s[i+1], s[i]
        if ''.join(s).find('AGC') != -1:
            return False
    return True

@lru_cache(None)
def dfs(i, last3):
    if i == N:
        return 1
    ret = 0
    for la in 'AGCT':
        if ok(last3+la):
            ret += dfs(i+1, last3[1:]+la)
    return ret % MOD

answer = dfs(0, 'TTT')
print(answer % MOD)


Measured memory_bytes: 5584
#include <bits/stdc++.h>
#define f(i,a,b) for(int i=a;i<=b;++i)
using namespace std;
int M=998244353,N,K,a,s[303],d[303][303][303]={1};
main(){string S;cin>>S>>K;K=min((int)S.size(),K);
for(auto c:S)c=='0'?++N:++s[N];
f(i,0,N)f(j,0,K)f(k,0,j)f(l,-min(k,s[i]),K-j)(d[i+1][j+max(l,0)][k+l]+=d[i][j][k])%=M;
f(i,0,K)(a+=d[N+1][i][0])%=M;cout<<a;}

Measured memory_bytes: 58004
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    	Scanner sc = new Scanner(System.in);
	    	int n = sc.nextInt();
	    	for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				if (i * j == n) {
					System.out.println("Yes");
					return;
				}
			}
		}
	    	System.out.println("No");
	}
}


Measured memory_bytes: 23892
#include<stdio.h>
main(){
  char a;
  int c,d;
  scanf("%d ",&c);
  while(1){
    scanf("%c",&a);
    if(a=='='){
      printf("%d\n",c);
      return 0;
    }
    scanf("%d ",&d);
    switch(a){
    case'+':
      c+=d;
      break;
    case'-':
      c-=d;
      break;
    case'*':
      c*=d;
      break;
    case'/':
      c/=d;
      break;
    }
  }
}

Measured memory_bytes: 596
import numpy as np

A = np.asarray([list(map(int, input().split())), list(map(int, input().split())), list(map(int, input().split()))])
n = int(input())
B = []
for _ in range(n):
    B.append(int(input()))

ans = np.zeros((3, 3))


def is_bingo(card) -> bool:
    if card[0, 0] == card[0, 1] == card[0, 2] == 1:
        return True
    if card[1, 0] == card[1, 1] == card[1, 2] == 1:
        return True
    if card[2, 0] == card[2, 1] == card[2, 2] == 1:
        return True
    if card[2, 0] == card[2, 1] == card[2, 2] == 1:
        return True
    if card[0, 0] == card[1, 0] == card[2, 0] == 1:
        return True
    if card[0, 1] == card[1, 1] == card[2, 1] == 1:
        return True
    if card[0, 2] == card[1, 2] == card[2, 2] == 1:
        return True
    if card[0, 0] == card[1, 1] == card[2, 2] == 1:
        return True
    if card[0, 2] == card[1, 1] == card[2, 0] == 1:
        return True
    return False


for b in B:
    if b in A:
        index = np.where(A == b)
        ans[index] = 1
    if is_bingo(ans):
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 26936
#include<stdio.h>
int main(){
  int a,b,x;
  scanf("%d %d %d",&x,&a,&b);

  x = x - a;
  while(1){
    if((x - b)>=0)
      x = x - b;
    else break;
  }

  printf("%d",x);

  return 0;
}


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

int main(){
    char a[7];
    
    scanf("%s",a);
    
    if(a[0]==a[1] || a[1]==a[2] || a[2]==a[3]){
        printf("Bad\n");
    }
    
    else{
        printf("Good\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <array>
#include <string>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ost;

const ll maxN = 1e7;
const ll INF = 1e17;

ll xs[] = {-1, 1, 0, 0};
ll ys[] = {0, 0, -1, 1};

int main(){
	cin.sync_with_stdio(false);
	cin.tie(0);
	ll t;
	cin >> t;
	ll x, y, ans = 0;
	while(t--){
		cin >> x >> y;
		ans += (y-x+1);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
#include <utility>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
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 = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.exe
int digit(int a){
    int count = 0;
    for (int i = 0; i < a; i++)
    {   if (a == 0)
        {
            break;
        }else
        {
            a = a/10;
            count++;
        }     
    }
    return count;
}
//pow(x,n) == x^n

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

int n,sum = 0;
cin >> n;
vector<vector<int>> x(n,vector<int>(2));
rep(i,n)rep(j,2) cin >> x.at(i).at(j);

rep(i,n){
    sum += (x.at(i).at(1)-x.at(i).at(0))+1;
}
cout << sum << endl;

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 384
#include<iostream>
#include<string>
  
using namespace std;
  
int main(){
    int n,m;
    int a[11000],b[11000];
    int c[1000],d[1000];
    while(true){
    int count=0;
    cin>>n>>m;
    if(n==0&&m==0)
        break;
    for(int i=1;i<n+1;i++){
        c[i]=0;
        d[i]=0;
    }
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];
        if(a[i]==1)
            c[b[i]]=1;
    }
    for(int i=0;i<m;i++){
        if(c[a[i]]==1)
            d[b[i]]=1;
        if(c[b[i]]==1)
            d[a[i]]=1;
    }
    d[1]=0;
    for(int i=1;i<n+1;i++){
        if(c[i]==1)
            d[i]=1;
        count+=d[i];
    }
    cout<<count<<endl;
    }
    return 0;
}

Measured memory_bytes: 1252
N = int(input())
A = list(map(int, input().split()))

negA = []
posA = []
for a in A:
    if a >= 0:
        posA.append(a)
    else:
        negA.append(a)

ans = sum(posA) - sum(negA)

if len(negA) % 2 == 1:
    ans -= min([abs(a) for a in A]) * 2

print(ans)


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

int main()
{
	int N;
	cin >> N;
	int a[200];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	bool f = true;
	int j = 0;
	while (1) {
		for (int i = 0; i < N; i++) {
			if (a[i] % 2 == 0) {
				a[i] = a[i] / 2;
			}
			else {
				f = false;
				break;
			}
		}
		if (! f) {
			break;
		}
		j += 1;
	}
	cout << j << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int r;
	cin>>r;
	ld Radius = r;
	ld pi = 3.14159265359;
	cout<<fixed<<setprecision(8)<<2*pi*Radius<<"\n";
	return 0;
}

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

using namespace std;

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) cout << "error" << endl;
  else cout << a + b << endl;
}



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

#define pb push_back
#define sz size() 
#define ll long long

ll binpow(ll a, ll b, ll mod) {
    a %= mod;
    ll res = 1ll;
    while (b>0) {
        if (b & 1)
            res = res * a % mod;
        a = a*a % mod;
        b>>= 1; 
    }
    return res;
}

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

    n = s.size();

    int i;
    int nuli = 0;
    for (i=0;i<n;i++)
    if (s[i] == '1') {
        nuli++;
    }

    int n1 = nuli - 1;
    int n2 = nuli + 1;

    ll presm1 = 0;
    ll presm2 = 0;

    for (i=0;i<n;i++)
    if (s[i] == '1') {
        if (n1>0) presm1 += binpow(2, n-i-1, n1);
        presm2 += binpow(2, n-i-1, n2);
    }

    if (n1>0) presm1 %= n1;
    if (n2>0) presm2 %= n2;

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

        int curr=0;

        if (s[i] == '1') {
            if (n1>0) {    
                curr = presm1;
                ll kolku = binpow(2, n-i-1, n1);
                curr = (curr + n1 - kolku) % n1;   
            }

            if (nuli == 1) {
                cout<<"0\n";
                continue;
            }

        } else {
            curr = presm2;
            ll kolku = binpow(2, n-i-1, n2);
            curr = (curr + kolku) % n2;
        }
      
        int br=1;
        while (curr) {
            curr = curr % __builtin_popcount(curr);
            br++;
        }
        cout<<br<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3756
#include <iostream>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;

int64_t gcd(int64_t m, int64_t n)
{
    if(n==0) return abs(m);
    return gcd(n, m%n);
}

int64_t lcm(int64_t m, int64_t n)
{
    return abs(n*m)/gcd(m,n);
}

int main()
{
    int64_t a,b,c,d;
    cin >> a >> b >> c >> d;
    
    int64_t e = max(c,d) % min(c,d) == 0 ? max(c,d) : lcm(c,d);
    
    int64_t n1 = b / c - (a-1)/c;
    int64_t n2 = b / d - (a-1)/d;
    int64_t n3 = b / e - (a-1)/e;
    cout << ((b - a + 1) - (n1 + n2 - n3)) << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 1000000000;
const double EPS = 1e-10;


int num[105];

ll solve(int n){
	vector<vector<ll> > dp(105, vector<ll>(21, 0));
	dp[0][num[0]] = 1;
	rep(i, n){
		rep(j, 21){
			ll m = 0;
			if(j-num[i+1] >= 0) m = dp[i][j-num[i+1]];
			ll p = 0;
			if(j+num[i+1] <= 20)p = dp[i][j+num[i+1]];
			dp[i+1][j] = m+p;
		}
	}

	return dp[n-1][0];
}

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

	rep(i, n){
		cin >> num[i];
	}

	cout << solve(n) << endl;

	return 0;
}

Measured memory_bytes: 1228
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    cnt1 = 0
    cnt2 = 0
    for j in range(n):
        if j <= i and a[i] > a[j]:
            cnt1 += 1
        elif j > i and a[i] > a[j]:
            cnt2 += 1
    ans += ((cnt2 * k) + ((cnt1 + cnt2) * k * (k - 1) // 2)) % (10 ** 9 + 7)
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <set>
#include <utility>
using namespace std;

int main() {
  int a, b; cin >> a >> b;
  if (a+b == 15)
    cout << "+" << endl;
  else if (a*b == 15)
    cout << "*" << endl;
  else
    cout << "x" << endl;
}


Measured memory_bytes: 256
n = int(input())
c = list(map(str, input().split()))
c_copy = list(c)

def bubble_sort(c, n):
    for i in range(n):
        for j in range(n - 1, i, -1):
            if c[j][1] < c[j - 1][1]:
                c[j], c[j - 1] = c[j - 1], c[j]
    return c

def selection_sort(c, n):
    for i in range(n):
        minj = i
        for j in range(i+1, n):
            if c[minj][1] > c[j][1]:
                minj = j
        c[minj],c[i]=c[i],c[minj]
    return c

def is_stable(c1, c2):
    if c1 == c2:
        print("Stable")
    else:
        print("Not stable")

c1 = bubble_sort(c, n)
print(' '.join(c1))
print('Stable')
c2 = selection_sort(c_copy, n)
print(' '.join(c2))
is_stable(c1,c2)


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

int main() {

  int64_t X; cin >> X;
  
  int64_t X500, X5;
  
  X500 = X / 500;
  X5 = ( X % 500 ) / 5;
  
 cout << X500 * 1000 + X5 * 5 << endl;

}


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

using namespace std;
typedef long long LL;

int main(){
    int N;
    while(cin >> N) {
        vector<int> M(N);
        vector<int> L(N);
        vector<vector<int>> child(N);
        vector<int> degree(N);
        
        REP(i, N) {
            cin >> M[i] >> L[i];
            if(L[i] != -1) {
                child[ L[i] ].push_back(i);
                degree[ L[i] ]++;
            }
        }

        queue<int> que;
        REP(i, N) if(degree[i] == 0) que.push(i);

        vector<LL> cost(N);
        vector<int> weight(N);
        
        while(!que.empty()) {
            int u = que.front(); que.pop();
            if(L[u] != -1 && --degree[ L[u] ] == 0) {
                que.push(L[u]);
            }
            vector<int> ws;
            cost[u] = 0;
            for(int c : child[u]) {
                ws.push_back(weight[c]);
                cost[u] += cost[c];
            }
            sort(ws.begin(), ws.end());
            LL tmp = 0;
            for(int w : ws) {
                cost[u] += tmp;
                tmp += w;
            }
            weight[u] = M[u] + accumulate(ws.begin(), ws.end(), 0LL);
        }

        LL ans = 0;
        REP(u, N) if(L[u] == -1) ans += cost[u];
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 79300
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000+100;
const db pi=acos(-1.0);
#define lowbit(x) ((x)&(-x))
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

inline ll readll()
{
    ll x=0;int f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

int n,s,x[N];
ll ans=0,p[N];

void solve(int l,int r,int lst)
{
    if (s<x[l]) {ans+=x[r]-s;return;}
    if (s>x[r]) {ans+=s-x[l];return;}
    if (p[l]>=p[r])
    {
        if (l!=lst) ans+=(x[r]-x[l]);
        p[l]+=p[r];solve(l,r-1,l);
    }
    else 
    {
        if (r!=lst) ans+=(x[r]-x[l]);
        p[r]+=p[l];solve(l+1,r,r);
    }
}

int main()
{
    n=read();s=read();
    rep(i,1,n) {x[i]=read();p[i]=read();}
    solve(1,n,0);
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=10000000007;

int main(){
  ll n;
  cin>>n;
  ll ans=0;
  Rep(i,1,n+1){
    if(i%3!=0 && i%5!=0){
      ans+=i;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int x[m];
    for(int i=0;i<m;i++)cin >> x[i];
    sort(x,x+m);
    if(n>=m)cout << 0 << endl;
    else{
        int y[m-1];
        for(int i=0;i<m-1;i++)y[i]=x[i+1]-x[i];
        sort(y,y+m-1);
        int ans=0;
        for(int i=0;i<m-n;i++)ans+=y[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define LINF 1e18
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;

template<typename Monoid>
class BIT {
public:
	size_t len, size;
	Monoid* arr;
	Monoid* tree;
	uint32 i;
	//?????????????????????
	BIT(const size_t &length) {
		len = length;
		size = length;
		if (size & 0xffff0000) { size = size & 0xffff0000; }
		if (size & 0xff00ff00) { size = size & 0xff00ff00; }
		if (size & 0xf0f0f0f0) { size = size & 0xf0f0f0f0; }
		if (size & 0xcccccccc) { size = size & 0xcccccccc; }
		if (size & 0xaaaaaaaa) { size = size & 0xaaaaaaaa; }
		size <<= 1;
		tree = (Monoid *)calloc(size, sizeof(Monoid));
	}
	//0?????????
	void set() {
		for (i = 0; i < size; ++i) tree[i] = 0;
	}
	//array??§?????????
	void set(Monoid* array) {
		--array;
		for (i = 1; i <= len; ++i) {
			tree[i] = array[i] + range(i);
		}
		++array;
	}
	//[0,a)???????????????
	Monoid range(size_t a) {
		Monoid ret = tree[a];
		a &= a - 1;
		while (a) {
			ret += tree[a];
			a &= a - 1;
		}
		return ret;
	}
	//index:a???data?????????
	void update(const size_t &a, const Monoid &data) {
		int32 b = int32(a);
		++b;
		while (b < size) {
			tree[b] += data;
			b += b&(-b);
		}
	}
	//
	size_t up_b(Monoid data) {
		size_t s = size >> 1;
		size_t t = size;
		size_t ret = 0;
		while (t>>=1) {
			if (tree[s] <= data) {
				data -= tree[s];
				s += t >> 1;
				ret += t;
			}
			else {
				s -= t >> 1;
			}
		}
		return ret;
	}
};

struct IN {
	int32 x, d, l;
};

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	size_t n, q;
	cin >> n >> q;
	vector<int64> ans(n+1, 0);
	vector<IN> t(q);
	rep(i, 0, q)
		cin >> t[i].x >> t[i].d >> t[i].l;
	BIT<int64> R(n), L(n);
	R.set();L.set();
	rep(i, 0, n) {
		R.update(i, 1);
		L.update(i, 1);
	}
	R.update(n, LINF);
	L.update(n, LINF);
	size_t temp;
	for (int32 i = q - 1;~i;--i) {
		if (t[i].d == 1) {
			temp = L.up_b(t[i].x);
			ans[0] += t[i].l;
			ans[temp] -= t[i].l;
			R.update(n - temp, t[i].l << 1);
		}
		else {
			temp = n - R.up_b(n - t[i].x);
			ans[temp] += t[i].l;
			ans[n] -= t[i].l;
			L.update(temp, t[i].l << 1);
		}
	}
	rep(i, 0, n)
		ans[i + 1] += ans[i];
	rep(i, 0, n)
		printf("%lld\n", ans[i]);
	return 0;
}

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


Measured memory_bytes: 2040
from scipy.sparse.csgraph import csgraph_from_dense, shortest_path


def main():
    import heapq
    import sys
    input = sys.stdin.buffer.readline
    N, M, L = map(int, input().split())

    G = [[-1]*N for i in range(N)]

    for i in range(M):
        A, B, C = map(int, input().split())
        A -= 1
        B -= 1
        G[A][B] = C
        G[B][A] = C
    g = csgraph_from_dense(G, null_value=-1)
    D = shortest_path(g)
    G2 = [[-1]*N for i in range(N)]
    for i in range(N):
        for j in range(N):
            if D[i][j] >= 0 and D[i][j] <= L:
                G2[i][j] = 1

    g2 = csgraph_from_dense(G2, null_value=-1)
    D = shortest_path(g2)

    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        if D[s][t] <= N**2:
            print(int(D[s][t])-1)
        else:
            print(-1)


main()


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

vector<vector<int> > to;
vector<int> c;
vector<bool> done;
vector<int> nodes;
vector<pair<int,int> > ab;
int nodecount;

queue<int> q;

void bfs(int id)
{
	q.push(id);
	while(!q.empty())
	{
		int now=q.front();q.pop();

		done[now]=true;
		nodes[now]=c[nodecount];
		nodecount++;
		for(int i=0;i<to[now].size();i++)
		{
			int nxid=to[now][i];
			if(done[nxid]==false)
				q.push(nxid);
		}
	}
}

int val(void)
{
	int ans=0;
	for(int i=0;i<ab.size();i++)
		ans+=min(nodes[ab[i].first],nodes[ab[i].second]);
	return ans;
}

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

	to=vector<vector<int> >(n);
	
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		ab.push_back(make_pair(a,b));
		to[a].push_back(b);
		to[b].push_back(a);
	}
	c=vector<int>(n);
	for(int i=0;i<n;i++)
		cin >> c[i];
	sort(c.rbegin(),c.rend());

	int ansid=0;

	done=vector<bool>(n,false);
	nodes=vector<int>(n,0);
	nodecount=0;
	bfs(0);
	int ans=val();

	cout << ans << endl;

	done=vector<bool>(n,false);
	nodes=vector<int>(n,0);
	nodecount=0;
	bfs(ansid);
	for(int i=0;i<n;i++){
		if(i!=0) cout << " ";
		cout << nodes[i];
	}
	cout << endl;
}

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

int main(){
    int n,m;// n:node m:road
    cin >> n >> m;
    Graph G(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }

    vector<int> d(n,-1);
    d.at(0) = 0;
    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();

        for(int nv : G.at(v)){
            if(d.at(nv) != -1)continue;
            d.at(nv) = d.at(v)+1;
            que.push(nv);
        }
    }
    vector<int> ans(n,0);
    rep(i,n){
        for(int nv : G.at(i)){
            if(d.at(nv) == d.at(i)-1)ans.at(i)=nv;
        }
    }
    cout<< "Yes" << endl;
    for(int i=1;i<n;i++)cout << ans.at(i)+1 << endl;;
    
}

Measured memory_bytes: 10548
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb emplace
#define pi pair <int, int>
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0

int n, m, dist[200100], ans[200100];
vector <int> G[200100];

void bfs(int source) {
    memset(dist, -1, sizeof(dist));
    queue <int> q;
    q.pb(source);
    dist[source] = 0;
    while (q.size()) {
		int u = q.front();
		q.pop();
		for(int j = 0; j < G[u].size(); ++j) {
			int v = G[u][j];
			if (dist[v] == -1) {
				q.push(v);
				dist[v] = dist[u] + 1;
                ans[v] = u;
			}
		}
	}
    // assert(0);
    // if (dist[1] != -1) ans.push_back(dist[1]); 
}

int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        int a, b; cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    bfs(1);
    bool ok = true;
    for(int i = 2; i <= n; ++i) {
        if (dist[i] == -1) ok = false;
    }
    if (ok) {
        cout << "Yes\n";
        for(int i = 2; i <= n; ++i) {
            cout << ans[i] << '\n';
        }
        time;
    } else {
        cout << "No";
        time;
    }
}

Measured memory_bytes: 17216
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RGBBoxes | diff RGBBoxes.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RGBBoxes.cpp && ./a.out

/*
 
 5/11/2019
 
 5:17-
 
 */

int R,G,B,N;

void solve() {
  int res=0;

  REPE(r,N)REPE(g,N) {
    int bb=N-r*R-g*G;
    if(bb<0) continue;
    if(bb%B!=0) continue;
    ++res;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>R>>G>>B>>N;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i = 0; i < n; i++)


int ok(int n, int *d)
{
    string s;
    s = to_string(n);
    REP(i, s.length()) {
        if(d[s[i]-'0']==1) {
            return 0;
        }
    }
    return 1;
}

int main(void)
{
    int n,k;
    int d[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int a;
    cin >> n >> k;
    REP(i,k) {
        cin >> a;
        d[a] = 1;
    }
    while(!ok(n,d)) n++;
    cout << n<< endl; 

}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main(){
    int N;
    cin >> N;
    set<string> S;
    for(int i = 0; i < N; ++i){
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << S.size() << endl;


    return 0;
}

Measured memory_bytes: 19228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll h, w, k;
    cin >> h >> w >> k;
    vector<string> v(h);
    string s;
    rep(i,h){
        cin>>s;
        v[i] = s;
    }
    ll ans = 0;

    for(ll bit=0;bit<(1<<h);bit++){//bit<(1<<桁数)
        for(ll bit2=0;bit2<(1<<w);bit2++){
            ll cnt = 0;
            bool flag = false;
            for(ll hi=0;hi<h;hi++){//i<桁数
                for(ll wi=0;wi<w;wi++){
                    if(!(bit&(1<<hi) || bit2&(1<<wi))){//立ってる時の処理
                        if(v[hi][wi] == '#') cnt++;
                    }
                    if(cnt > k){
                        flag = true;
                        break;
                    }
                }
                if(flag) break;
            }
            if(cnt == k) ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			(a).begin(),(a).end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				(1000 * 1000 * 1000 * 2)
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<int, int>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int execOne(int i, char one, string &ans)
{
	int val = one - '0';
	if (i == 0) {
		ans += "+";
	} else {
		val = val * (-1);
		ans += "-";
	}
	ans += one;
	return val;
}


// メイン
int main()
{
	string str;
	cin >> str;
	REP(i, 2) {
		REP(j, 2) {
			REP(k, 2) {
				string ans;
				int ret = str[0] - '0';
				ans += str[0];
				ret += execOne(i, str[1], ans);
				ret += execOne(j, str[2], ans);
				ret += execOne(k, str[3], ans);
				if (ret == 7) {
					ans += "=7";
					cout << ans << endl;
					return 0;
				}
			}
		}
	}

	cout << "" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
int main() {
    int n;
    scanf("%d", &n);

    vector<int> x(n);
    rep(i, n) scanf("%d", &x[i]);

    // 配列xのコピーを作って昇順
    vector<int> y(x);
    sort(y.begin(), y.end());

    // 中央値が2種類。
    // 中央からみて右側から要素を消した場合
    int right = y[n / 2 - 1];
    // 中央からみて左側から要素を消した場合
    int left = y[n / 2];

    rep(i, n) {
        int ans = (x[i] <= right) ? left : right;
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4840
/*Author - Shubham Gupta (@shubham107)*/
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<ll> vl;      typedef vector<int> vi;
typedef vector<vl> vvl;     typedef vector<vi> vvi;
typedef pair<ll, ll> pll;   typedef pair<int, int> pii;
#define forn(i,n) for(int i=0;i<n;i++)
#define rforn(i,n) for(int i=n-1;i>=0;i--)
#define forne(i,n) for(int i=1;i<=n;i++)
#define forse(i,s,e) for(int i=s;i<e;i++)
#define rforse(i,s,e) for(int i=e-1;i>=s;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define trav(a,x) for(auto &a:x)
#define INF ll(1e18)
#ifdef SHUBHAM107
#include "../trace.h"
#else
#define trace(args...)
#endif
void solve() {
    ll n, m, k;
    cin >> n >> m >> k;
    vl a(n), b(m), prefa(n + 1), prefb(m + 1);
    forn(i, n) cin >> a[i], prefa[i + 1] = prefa[i] + a[i];
    forn(i, m) cin >> b[i], prefb[i + 1] = prefb[i] + b[i];
    int ans = 0;
    forn(i, n + 1) {
        ll fir = prefa[i];
        if(fir > k)
            break;
        ll sec = k - fir;
        int pos = upper_bound(all(prefb), sec) - prefb.begin() - 1;
        ans = max(i + pos, ans);
    }
    cout << ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifdef SHUBHAM107
    freopen("inp.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("err.txt", "w", stderr);
#endif
    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 9532
#encoding:utf-8 No.0048 2014.10.2
def judge_class(n)
  if n <= 48.00
    return "light fly"
  elsif n > 48.00 && n <= 51.00
    return "fly"
  elsif n > 51.00 && n <= 54.00
    return "bantam"
  elsif n > 54.00 && n <= 57.00
    return "feather"
  elsif n > 57.00 && n <= 60.00
    return "light"
  elsif n > 60.00 && n <= 64.00
    return "light welter"
  elsif n > 64.00 && n <= 69.00
    return "welter"
  elsif n > 69.00 && n <= 75.00
    return "light middle"
  elsif n > 75.00 && n <= 81.00
    return "middle"
  elsif n > 81.00 && n <= 91.00
    return "light heavy"
  else
    return "heavy"
  end
end

while gets
  puts judge_class($_.to_f)
end

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int n, m; cin >> n >> m;
    V<string> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    V<string> b(m);
    for(int i = 0; i < m; i++) cin >> b[i];

    for(int i = 0; i < n - m + 1; i++){
        for(int j = 0; j < n - m + 1; j++){
            int y = i;
            int x = j;
            bool flag = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(b[k][l] == a[y][x]) x++;
                    else{
                        flag = false;
                        break;
                    }
                }
                y++;
                x = j;
            }
            if(flag){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3644