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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){ 
    ll h,w,n;
    cin >> h >> w >> n;
    ll a[n] = {};

    rep(i,0,n) cin >> a[i];

    ll grid[h][w] = {};
    ll memo = 1,cnt = a[0];
    rep(i,0,h){
        rep(k,0,w){
            ll j;
            if(cnt <= 0){
                cnt = a[memo];
                memo++;
            }
            if(i % 2 == 0) j = k;
            else j = w-k-1;

            grid[i][j] = memo;
            cnt--;
        }
    }


    rep(i,0,h){
        rep(j,0,w){
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3692
import java.util.Scanner;

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

		int R = sc.nextInt();
		int G = sc.nextInt();
		int B = sc.nextInt();
		int n = sc.nextInt();
		int ans = 0;

		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= n-i; j++) {
				int kk = n - i * R - j * G;
				if (kk % B == 0 && kk >=0) {
					int k = (n - i * R - j * G) / B;
						ans++;
//						System.out.println("i:" + i + " j:" + j + " b:" + k);
					}
				}
			}

		System.out.println(ans);
	}
}


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

int c[10][10];

void run_time()
{
    for(int k = 0; k < 10; k++)
    {
        for(int i = 0; i < 10; i++)
        {
            for(int j = 0; j < 10; j++)
            {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
}

int main()
{
    int h, w;
    cin >> h >> w;
    
    for(int i = 0; i < 10; i++)
    {
        for(int j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    
    run_time();
    
    int ans = 0;
    
    for(int i = 0; i < h * w; i++)
    {
        int x;
        cin >> x;
        if(x == -1) continue;
        ans += c[x][1];
    }
    
    cout << ans << endl;
    return 0;
}


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

int main(){

    int n;
    int m,s=0;
    int t=0;
    cin >> n >> m;
    vector<int> a(n);

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

        cin >> a.at(i);

        t+=a.at(i);
        
    }

    for(int i=0; i<n; i++){
        
        if(a.at(i)>t/(4*m) && t%(4*m)!=0){

            s+=1;

        }

        if(a.at(i)>t/(4*m)-1 && t%(4*m)==0){

            s+=1;

        }

    }
    
    if(s>=m){

        cout << "Yes" << endl;

    }

    else{

        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n,b[100],i,j,k = 0,ans[100];

    scanf("%d",&n);
    for(i = 0; i < n; i++)scanf("%d",&b[i]);

    for(j = 0; j < n;k++)
    {
        for (i = n - 1; i >= 0; i--)
        {
            if(i + 1 == b[i])
            {
                ans[k] = i + 1;
                break;
            }
        }
        if(i == -1)break;
        for (; i < n - 1; i++)
        {
            b[i] = b[i + 1];
        }
        n--;
    }

    if(n == 0)
    {
        for (i = k - 1; i >= 0; i--)
        {
            printf("%d ",ans[i]);
        }
    }
    else
    {
        printf("-1");
    }
    
    
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 100000

typedef struct{ 
  int p,l,r;
}Node;

Node T[N];

int dep,hl,hr;

main(){
  int i, j, d, v, c, l, n,tmp;
  
  scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ) {
      T[i].p = T[i].l = T[i].r = -1;
    }
    for (i = 0; i <n ; i++){
      scanf("%d %d %d", &v, &d, &c);
      T[d].p=v;
      T[c].p=v;
      T[v].l=d;
      T[v].r=c; 
    }
       
    for ( i = 0; i < n; i++){
      print(i);
    }
    return 0;
}

int sibling(int u){
  if(T[u].p == -1) return -1;
  else if(T[T[u].p].l == u)return T[T[u].p].r;
  else return T[T[u].p].l;
}

int degree(int u){
  if (T[u].l == -1 && T[u].r == -1) return 0;
  else if(T[u].l != -1 && T[u].r != -1) return 2;
  else  return 1;
}

int depth(int u){
  if(T[u].p == -1) return 0;
   if(T[u].p != -1){
     dep++;
    depth(T[u].p);
   }
   return dep;
}

int hight(int u){
  int hl = 0, hr = 0;
  if(T[u].l != -1) {
    hl = hight(T[u].l) + 1;
  }
  if(T[u].r != -1){
    hr = hight(T[u].r) + 1;
  }
  if(hl < hr) return hr;
  else return hl;
}

void print(int u){
  printf("node %d: parent = %d, sibling = %d, degree = %d, ",u,T[u].p,sibling(u),degree(u));
  dep=0;
  printf("depth = %d, height = %d, ",depth(u),hight(u));  
  if(T[u].p == -1)printf("root\n");
  else if(T[u].l == -1 && T[u].r == -1)printf("leaf\n");
  else printf("internal node\n");
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int n, a, b;
  cin >> n >> a >> b;
  cout << min(n * a , b);
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
bool cmp(int a,int b)
{
    return a>b;
}
using namespace std;
int main()
{
    int n,k,s=0;
    int N[55];
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&N[i]);
    }
    sort(N,N+n,cmp);
    for(int i=0;i<k;i++)
    {
        s=s+N[i];
    }
    printf("%d",s);
    return 0;
}


Measured memory_bytes: 128
import math
n,k=map(int,input().split(" "))
if k<=n:#最初にk以上を出す確率
  p=n-k+1
else:
  p=0
#0を1度も引かない場合勝てる。
for i in range(min(n,k-1)):#0~k-2
  x=math.ceil(math.log2(k/(i+1)))#割り切れてしまった場合1多くカウントすることになる
  p+=(0.5)**x
print(p/n)
  

Measured memory_bytes: 3064
X, Y, A, B, C = map(int,input().split())
p = sorted(list(map(int,input().split())))[::-1][:X]
q = sorted(list(map(int,input().split())))[::-1][:Y]
r = sorted(list(map(int,input().split())))
print(sum(sorted((p+q+r),reverse = True)[:X+Y]))


Measured memory_bytes: 109804
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int n;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

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

int main() {
    scanf("%d", &n);
    int p[n * n];
    rep(i, n * n) scanf("%d", &p[i]), --p[i];
    int dist[n][n];
    bool exist[n][n];
    rep(i, n * n) {
        int x = i / n, y = i % n;
        dist[x][y] = min({x, n - 1 - x, y, n - 1 - y});
        exist[x][y] = true;
    }
    int ans = 0;
    rep(k, n * n) {
        int x = p[k] / n, y = p[k] % n;
        ans += dist[x][y];
        exist[x][y] = false;
        rep(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            chmin(dist[x][y], in(nx, ny) ? (dist[nx][ny] + exist[nx][ny]) : 0);
        }
        queue<pii> que;
        que.emplace(x, y);
        while (!que.empty()) {
            auto [tx, ty] = que.front();
            que.pop();
            rep(i, 4) {
                int nx = tx + dx[i], ny = ty + dy[i];
                if (in(nx, ny) &&
                    chmin(dist[nx][ny], dist[tx][ty] + exist[tx][ty])) {
                    que.emplace(nx, ny);
                }
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 5888
package main

import (
	"fmt"
	"math"
)

func main() {
	var N int
	fmt.Scan(&N)
	W := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&W[i])
	}

	ans := 99999
	for t := 1; t < N; t++ {
		l, r := 0, 0
		for i := 0; i < N; i++ {
			if i < t {
				l += W[i]
			} else {
				r += W[i]
			}
		}

		d := math.Abs(float64(r - l))
		ans = int(math.Min(float64(ans), d))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;
int gcd(int a, int b)
{
    return b?gcd(b, a%b):a;
}
const int mod = 1e9+7;
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        long long ans = 1;
        for(int i = 1;i <= n;i++)
            ans *= i, ans %= mod;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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; }
// --------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin >> N >> K;
  ll ans = K;
  for(int i=0; i<N-1; i++){
    ans *= K-1;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
from collections import Counter
n = int(input())
aa = list(map(int, input().split()))
ar = [a+i for i, a in enumerate(aa)]
arc = Counter(ar)
al = [i-a for i, a in enumerate(aa)]
alc = Counter(al)
ans = 0
for k, c in arc.items():
    ans += c * alc[k]
print(ans)

Measured memory_bytes: 63796
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4765
const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005]; // パスカルの三角形 (4000ちょいあれば十分 (5 はどこから来るのだろう...)))
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i + 1][j] += c[i][j];
      c[i + 1][j + 1] += c[i][j];
    }
  }
}

mint comb(int n, int k) {
  return c[n][k];
}

mint f2(int n, int k) {
  return comb(n + k - 1, k - 1);
}

mint f(int n, int k) {
  if (n < k) return 0;
  if (n == 0 && k == 0) return 1;
  return f2(n - k, k); // (解説で導入した) f' を f2() として実装する
}

int main() {
  init();
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= k; i++) {
    mint blue = f(k, i); // k 個を i グループに分ける
    mint red = 0;
    {
      red += f(n - k, i - 1);
      red += f(n - k, i);
      red += f(n - k, i);
      red += f(n - k, i + 1);
    }
    mint ans = blue * red;
    printf("%lld\n", ans.x);
  }

  return 0;
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

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

    string s,t;
    cin >> s >> t;
    int n = s.size(),k = t.size();
    int ans = mod;
    for(int i = 0; i+k-1 < n; i++){
        int can = 0;
        for(int j = 0; j < k; j++){
            if(s[i+j] != t[j]) can++;
        }
        ans = min(ans,can);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define Test(tt) cout << "Case #" << tt << ": "

using namespace std;

void euclid(ll a, ll b, ll c, ll& x, ll& y) {
    if(b == 0) {
        y = 0;
        x = c / a;
        return ;
    }
    euclid(b, a % b, c, x, y);
    ll x0 = x, y0 = y;
    x = y0;
    y = x0 - (a / b) * y0;
}


int main() {
#ifdef HOME
    ifstream cin("B.in");
    ofstream cout("B.out");
#endif
    //int ;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    n *= 2;

    ll k = n - 1;
    for(ll a = 1; a * a <= n; a++) {
        if(n % a == 0) {
            ll b = n / a;
            if(__gcd(a, b) == 1) {
                ll x, y;
                euclid(a, b, 1, x, y);
                
                ll cur = min(llabs(a * x), llabs(b * y));
                if(cur > 0)
                    k = min(k, cur);
                
                
                /*for(ll val = b; val - 1 < k; val += b) {
                    ll r = val % a;
                    if(r == 1) {
                        k = min(k, val - 1);
                        break;
                    }
                    if(r == a - 1) {
                        k = min(k, val);
                        break;
                    }
                }*/
            }
        }
    }
    cout << k;


    return 0;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int sz = 150000;
    vector<ll> pow10(sz, 1);
    rep(i, sz-1) pow10[i+1] = pow10[i]*10 % 13;

    string S; cin >> S;
    reverse(S.begin(), S.end());
    int lenS = S.length();
    vector<ll> dp[lenS];
    rep(i, lenS) dp[i].resize(13, 0);
    if(S[0] == '?'){
        rep(i, 10) dp[0][i] = 1;
    }
    else dp[0][S[0]-'0'] = 1;
    for(int i = 0; i < lenS-1; i++){
        for(int j = 0; j <= 12; j++){
            if(S[i+1] == '?'){
                rep(dig, 10){
                    int to = (j + pow10[i+1]*dig) % 13;
                    dp[i+1][to] = (dp[i+1][to] + dp[i][j]) % mod;
                }
            }
            else{
                int dig = S[i+1]-'0';
                int to = (j + pow10[i+1]*dig) % 13;
                dp[i+1][to] = (dp[i+1][to] + dp[i][j]) % mod;
            }
        }
    }
    cout << dp[lenS-1][5] << endl;
    return 0;
}

Measured memory_bytes: 14800
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

ll N,M,K;
ll fact[220010];

ll extgcd(ll a,ll b,ll& x, ll& y){
	ll d=a;
	if(b)d=extgcd(b,a%b,y,x),y-=(a/b)*x;
	else x=1,y=0;
	return d;
}

ll mod_inverse(ll a,ll m){
	ll x,y;
	extgcd(a,m,x,y);
	return ((ll)m+x%m)%m;
}

ll nCr(ll n,ll r){
	if(n<0 || r<0 || r>n)return 0;
	return fact[n]
	*mod_inverse(fact[r],MOD) %MOD
	*mod_inverse(fact[n-r],MOD) %MOD;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	fact[0]=1;
	rep2(i,1,220010)fact[i]=fact[i-1]*i%MOD;
	
	cin>>N>>M>>K;
	ll ans=0;
	rep(x,K+1){
		int y=K-x;
		ll resx=nCr(N+x*2,x)-nCr(N+x*2,x-1)+MOD;
		ll resy=nCr(M+y*2,y)-nCr(M+y*2,y-1)+MOD;
		ans+=resx*resy %MOD *nCr(N+M+K*2,N+x*2);
		ans%=MOD;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2912
// inputに入力データ全体が入る
function Main(str) {
  const num = str.split(' ');
  const num1 = parseInt(num[0]);
  const num2 = parseInt(num[1]);

  const result = [
    num1 + num2,
    num1 - num2,
    num1 * num2
  ];

  const max = Math.max(...result);

  if (max === -0 || max === +0) {
    console.log(0)
  } else {
    console.log(max);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 11468
#include <stdio.h>

int main(void){
  int a[5] = { 0 };
  for(int i = 0; i < 4; i++) scanf("%d" , &a[i]);
  a[0] -= a[1];
  a[2] -= a[1];
  a[4] = a[0] - a[2];
  for(int i = 0; i < 5; i++){
    if(a[i] < 0) a[i] = -a[i];
  }
  if(a[4] <= a[3] || (a[0] <=a[3] && a[2] <= a[3])) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  int n;
  string s;
  cin>>s;
  n = s.size();
  int ans = 0;
  fr(i, n/2) if(s[i] != s[n-1-i]) ans++;
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
import numpy as np

mod = 998244353
N = int(input())
a = np.array([int(input()) for i in range(N)])
sum_a = np.sum(a)
dp = np.zeros((N+1, sum_a+1), dtype=np.int64)
dp[0,0] = 1

for i in range(1, N+1):
    a_i = a[i-1]
    dp[i,a_i:] += dp[i-1,:-a_i]
    dp[i,:] += dp[i-1,:] * 2
    dp[i,:] %= mod

exc = np.sum(dp[N, (sum_a+1)//2:]) % mod
res = 3**N % mod - exc * 3

if sum_a % 2 == 0:
    dp = np.zeros((N+1, sum_a+1), dtype=np.int64)
    dp[0,0] = 1
    for i in range(1, N+1):
        a_i = a[i-1]
        dp[i,a_i:] += dp[i-1,:-a_i]
        dp[i,:] += dp[i-1,:]
        dp[i,:] %= mod
    res += dp[N, sum_a//2] * 3

print(res % mod)

Measured memory_bytes: 223224
#include <bits/stdc++.h>
#include <vector>3
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}
 
int main(){
init();
unsigned long long k,a=100,b=0;
cin>>k;
while(a<k){
    a=a*.01+a;
    b++;
    if(a==k){
        break;
    }
}
cout<<b;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int T,n,m,k,q,a[100010];
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	int cur=0,o_cnt,e_cnt,pos;
	bool flag;
	while(true){
		o_cnt=e_cnt=flag=0,pos=-1;
		for(int i=1;i<=n;i++){
			if(a[i]%2==0) o_cnt++;
			else pos=i,e_cnt++;
			if(a[i]==1) flag=true;
		}
		if(flag) return puts((o_cnt&1)^cur?"First":"Second"),0;
		if(o_cnt&1) return puts(cur?"Second":"First"),0;
		if(e_cnt>1&&!(o_cnt&1)) return puts(cur?"First":"Second"),0;
		cur^=1;
		a[pos]--;
		int g=a[1];
		for(int i=2;i<=n;i++) g=gcd(a[i],g);
		for(int i=1;i<=n;i++) a[i]/=g;
	}
}


Measured memory_bytes: 4084
#include <iostream>
#include <cstring>
#include<cstdio>
using namespace std;
long long int c(long long m,long long n)
{
    long long ans=1;
    for(long long k=1; k<=n; k++)
    {
        ans=(ans*(m-n+k))/k;
    }
    return ans;
}
int main()
{
    long long  l, k;
    while(cin >> l >> k)
    {
        long long  i, j;
        long long sum = 0;
        for( i=1; i<=(l+1)/2; i++)
        {
            sum++;
            for( j=1; j<=i; j++ )
            {
                if( i-j+k*j + i-1 > l) break;
                sum += c(i,j);
            }
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#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 out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n,m; cin >> n >> m;
    vector<pair<int,int>> a[100001];
    REP(i,m){int p,y; cin >> p >> y; a[p].push_back({y,i});}
    pair<int,int> ans[100001];
    for(int i=1; i<=n; i++){
        SORT(a[i]);
        REP(j,a[i].size()) ans[a[i][j].second] = {i,j+1};
    }
    REP(i,m) printf("%06d%06d\n", ans[i].first, ans[i].second);

    return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
char s[100],t[100];
int n,m;
int main(){
	scanf("%s%s",s+1,t+1);
	n=strlen(s+1);m=strlen(t+1);
	fd(i,n-m+1,1){
		bool ok=1;
		fo(j,1,m){
			if (s[i+j-1]=='?') continue;
			if (s[i+j-1]==t[j]) continue;
			ok=0;
			break;
		}
		if (ok){
			fo(j,1,n) if (s[j]=='?') s[j]='a';
			fo(j,1,i-1) putchar(s[j]);
			fo(j,1,m) putchar(t[j]);
			fo(j,i+m,n) putchar(s[j]);
			return 0;
		}
	}
	printf("UNRESTORABLE\n");
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
import java.io.*;
import java.math.*;

public class Main
{

    public static void process()throws IOException
    {
        int n=ni();
        long arr[]=new long[n];
        boolean flag=false;
        for(int i=0;i<n;i++){
         	arr[i]=nl();
         	if(arr[i]==0)
         		flag=true;
         }

         if(flag){
         	pn(0);
         	return;
         }

         long prod=1l;
         for(int i=0;i<n;i++){
         		if(prod*arr[i]<prod || prod*arr[i]>(long)1e18){
         			pn(-1);
         			return;
         		}

         		prod*=arr[i];
         }
         pn(prod);
    }


    static FastReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        out = new PrintWriter(System.out);
        sc=new FastReader();

        long s = System.currentTimeMillis();
        int t=1;
        //t=ni();
        while(t-->0)
            process();

        out.flush();
        System.err.println(System.currentTimeMillis()-s+"ms");
    }
    
    
    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static int ni()throws IOException{return Integer.parseInt(sc.next());}
    static long nl()throws IOException{return Long.parseLong(sc.next());}
    static double nd()throws IOException{return Double.parseDouble(sc.next());}
    static String nln()throws IOException{return sc.nextLine();}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}
    
    static long mod=(long)1e9+7l;

    static<T> void r_sort(T arr[],int n){
        Random r = new Random(); 
        for (int i = n-1; i > 0; i--){ 
            int j = r.nextInt(i+1); 
                  
            T temp = arr[i]; 
            arr[i] = arr[j]; 
            arr[j] = temp; 
        } 
        Arrays.sort(arr); 
    }
    
/////////////////////////////////////////////////////////////////////////////////////////////////////////
    static class FastReader{ 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader(){ 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next(){ 
            while (st == null || !st.hasMoreElements()){ 
                try{ st = new StringTokenizer(br.readLine()); } catch (IOException  e){ e.printStackTrace(); } 
            } 
            return st.nextToken(); 
        } 
  
        String nextLine(){ 
            String str = ""; 
            try{ str = br.readLine(); } catch (IOException e) { e.printStackTrace(); } 
            return str; 
        } 
    } 
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}

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

using namespace std;
typedef long long ll;

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

  vector<ll> t(n), a(n);
  for (int i = 0; i < n; i++) {
    cin >> t[i] >> a[i];
  }

  ll x = 1, y = 1;
  for (int i = 0; i < n; i++) {
    ll k = max((x + t[i] - 1) / t[i], (y + a[i] - 1) / a[i]);
    x = k * t[i]; y = k * a[i];
  }

  cout << x + y << endl;

  return 0;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
      fastio;

      int k,n;
      cin>>k>>n;
      ll a[n+1];
      for(int i=0;i<n;i++)
        cin>>a[i];
      a[n]=a[0];
      ll pre[n+1]={0};
      for(int i=1;i<n;i++)
        pre[i]=pre[i-1]+(a[i]-a[i-1]);
      pre[n]=pre[n-1]+(k-a[n-1]+a[0]);

      ll ans=pre[n-1];
      for(int i=1;i<n;i++)
      {
        int x=min(n,i+n-1);
        ll z=pre[x]-pre[i];
        z=z+pre[i-1];
        ans=min(ans,z);
      }
      cout<<ans<<endl;


    }

Measured memory_bytes: 3328
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}


bool check(vi v,int x) {
  int sum = 0;
  for(auto e : v)
    sum += e;
  int t = sum + x;
  if(t % 2 == 1 || t < 0)
    return false;
  t /= 2;
  bitset<8001> B;
  B[0] = 1;
  for(auto e : v)
    B |= B << e;
  return B.test(t);
}

int main(){
  string s;
  int x , y;
  cin >> s >> x >> y;
  int i = 0 , n = sz(s);
  while(i < n && s[i] == 'F') {
    --x;++i;
  }
  vi v[2];
  int d = 0 , go = 0;
  for(;i<n;++i) {
    if(s[i] == 'T') {
      if(go) v[d].pb(go);
      d ^= 1;
      go = 0;
    } else
      ++go;
  }
  if(go) v[d].pb(go);
  puts(check(v[0] , x) && check(v[1] , y) ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,m,val1,val2;cin>>n>>m;
    int ans[n+1]={0},a[n+1];
    for(int i=1;i<=n;i++) cin>>a[i];
    while(m--){
        cin>>val1>>val2;
        if(a[val1]==a[val2]){ ans[val2]=1;ans[val1]=1;}
        else if(a[val1]>a[val2]) {ans[val2]=1;}
        else if(a[val1]<a[val2]) {ans[val1]=1;}
    }
    int count=0;
    for(int i=1;i<=n;i++) count+=ans[i];
    cout<<n-count;
   
    return 0;
}




Measured memory_bytes: 4372
import math

A,B = map(int,input().split())

a,b = A,B

if a < b:
    a, b = b, a
while a % b != 0:
    a, b = b, a % b

S = b

def lcm(x, y):
    return (x * y) // S

print(lcm(A, B))

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
constexpr int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
auto dfs(vi& v, vi& visited, vi& next, int a) {
	if (v[a] == 0)return false;
	if (visited[a] == 2)return true;
	if (visited[a])return visited[a] == INF;
	visited[a] = 2;

	auto ret = dfs(v, visited, next, a + v[a]);
	if (ret) {
		next[a] = INF;
		visited[a] = INF;
	}
	else {
		visited[a] = 1;
	}
	return ret;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n; cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	vi b(n), visited(n, 0), next(n);
	REP(i, n) {
		if (v[i] != 0)b[i + v[i]] = 1;
	}
	REP(i, n) {

		if (b[i] == 0 && !dfs(v, visited, next, i)) {
			int a = i;
			vi t;
			while (v[a] != 0) {
				t.push_back(a);
				a += v[a];
			}
			REP(i, t.size())next[t[i]] = a;
			next[a] = a;
		}
	}

	REP(i, n) {
		if (visited[i] == 0 && v[i] != 0)next[i] = INF;
	}
	vl d(n, INF);
	d[0] = 0;
	queue<ll> q;
	q.push(0);
	while (!q.empty()) {
		ll p = q.front();
		assert(v[p] == 0);
		q.pop();
		for (int i = 1; i <= 6; ++i) {
			if (next[min(n - 1, p + i)] != INF) {
				if (chmin(d[next[min(n - 1, p + i)]], d[p] + 1)) {
					q.push(next[min(n - 1, p + i)]);
				}
			}
		}
	}
	cout << d[n - 1] << endl;
}


Measured memory_bytes: 9244
n = int(input())
la = [int(input()) for _ in range(n)]

dict_i = {}

for i, a in enumerate(la):
    dict_i[a] = i


m = 0
s = 0
j = -1
for a in range(1, n + 1):
    i = dict_i[a]
    if i > j:
        s += 1
        m = max(m, s)
    else:
        s = 1
    j = i

answer = n - m
print(answer)


Measured memory_bytes: 37900
import sys

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


def main():
    def calc(x):
        for row in range(n):
            for col in range(n):
                if s[(row + x) % n][col] != s[(col + x) % n][row]:
                    return 0
        return n

    n = int(readline())
    s = [input() for _ in range(n)]

    ans = 0

    for i in range(n):
        ans += calc(i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 73676
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#define SZ(x) ((int)(x).size())

typedef long long ll;

ll solve(std::vector<int>& a) {
	std::reverse(a.begin(), a.end());
	int it_be = 0, it_en = SZ(a) - 1;
	ll ret = 0, mi = 2e9;
	for(bool st = 0; it_be <= it_en; st ^= 1) {
		if(it_be == it_en) 
			it_be = SZ(a) - 1;
		ret += std::abs((ll)a[it_be] - a[it_en]);
		mi = std::min(mi, std::abs((ll)a[it_be] - a[it_en]));
		if(st) 
			++it_be;
		else
			--it_en;
	}
	return ret - mi;
}

int main() {
	std::vector<int> a;
	int n;
	std::cin >> n;
	for(int i = 1; i <= n; ++i) {
		int x;
		std::cin >> x;
		a.push_back(x);
	}
	std::sort(a.begin(), a.end());
	ll ans = std::max(solve(a), solve(a));
	std::cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 892
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    int n;
    cin >> n;
    ll a[300] = {};
    
    rep(i,0,n)cin >> a[i];

    ll cnt = 0;

    while(1){
        rep(i,0,n)if(a[i]%2 == 1){
            P(cnt);
            ret 0;
        }

        rep(i,0,n)a[i] /= 2;
        cnt++;
    }

	return  0;
}

Measured memory_bytes: 256
/*
 * 	Roses are red
 * 		Violets are blue
 * 			I cried
 * 				And so did you
 */
// #pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifndef rd
#define endl '\n'
#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

void solve() {
	int r,g,b,n;
	cin>>r>>g>>b>>n;
	int ans=0;
	for(int i=0; i<=n; i++) {
		for(int j=0; j<=n; j++) {
			if(i*r+j*g<=n&&(n-i*r-j*g)%b==0)
				ans++;
		}
	}
	cout<<ans<<endl;
}
signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}
public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			long M = inputArray[1];


			//答えの出力
			var ans = (N*(N-1))/2  + (M*(M-1))/2;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}


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

char s[123456];

int main()
{
	scanf("%s", s);
	int length = strlen(s);
	int ans1 = -1;
	int ans2 = -1;
	for (int i = 0; i < length - 1; ++i)
	{
		if (s[i] == s[i + 1])
		{
			ans1 = i + 1; 
			ans2 = i + 2;
		}
	}
	for (int i = 0; i < length - 2; ++i)
	{
		if (s[i] == s[i + 2])
		{
			ans1 = i + 1;
			ans2 = i + 3;
		}
	}
	printf("%d %d\n", ans1, ans2);
	return 0;
}

Measured memory_bytes: 256
# ABC79 D - Wall
from scipy.sparse.csgraph import floyd_warshall

H, W = map(int, input().split())
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]

C = floyd_warshall(C)  

cost = 0
for i in range(H):
    for a in A[i]:
        if a != -1:
            cost += C[a][1]

print(int(cost))

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

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int K;
  cin >> K;
  int remain = K;
  rep(i,(int)s.size()) {
    int v = s[i] - 'a';
    if( v == 0 ) continue;
    int need = (26-v);
    if( remain >= need ) {
      remain -= need;
      s[i] = 'a';
    }
  }
  remain %= 26;
  int id = (int)s.size()-1;
  while( remain ) {
    --remain;
    int tmp = s[id]-'a';
    ++tmp;
    tmp %= 26;
    s[id] = (char)(tmp+'a');
  }
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 512
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
 
using namespace std;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n;

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n;
   int t = (n + 1) / 2;
   cout << fixed << setprecision (10) << 1.0 * t / n;
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define ll long long
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
#define all(x) (x).begin(), (x).end()
using namespace std;
inline ll read()
{
	ll 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;
}
const int MOD = 1e9 + 7;
int n, a[200010];
ll abss(ll x)
{
	if(x < 0)return -x;
	return x;
}
ll x = 0, y = 0;
int main()
{
	n = read();
	rep(i, 1, n)
	{
		a[i] = read();
		y += a[i];
	}
	ll ans = 1e18;
	rep(i, 1, n - 1)
	{
		x += a[i];
		y -= a[i];
		if(abss(x - y) < ans) ans = abss(x - y);
	}
	cout << ans << endl;
	return 0;
}


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

int main(){

    int n, i=1, x;
    cin >> n;

    while(1){

        x = i;

        if(x % 3 == 0){
            cout << " " << i;
        }

        while(1){
            if(x % 3 == 0 && x == i){
                break;
            }
            do{   
                if((x % 10 == 3) || (x == 3 && i % 3 != 0)){
                    cout << " " << i;
                    break;
                }
                x /= 10;
            }while(x);
            break;
        }

        if( ++i > n){
            break;
        }        
    }

    cout << "\n";

    return 0;

} 


Measured memory_bytes: 3068
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll long long
#define dl double

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    	cin>>n;
	ll arr[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i] ;
		}
	sort(arr,arr+n);
	ll count=0;
	for(ll k=0;k<n-2;k++){
	for(ll i=n-1;i>=2;i--){
			for(ll j=i-1;j>=1;j--){
					if(arr[k]+arr[j]>arr[i] && arr[i] != arr[j] && arr[j]!=arr[k] && k<j && j<i){
						count++;
					}				
				}		
			}
		}
		cout<<count<<"\n";
		   return 0;
}

Measured memory_bytes: 3608