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

const int H = 5, W = 5;
int GetID(int x, int y) { return y * W + x; }
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, -1, 0, 1};

int n, a[25], score[6];

bool fall(int b[]) {
	bool ret = false;
	for (int x=0; x<5; ++x) {
		for (int y=3; y>=0; --y) {
			if (b[GetID(x, y)] != -1) {
				int cy = y;
				while (cy < 4 && b[GetID(x, cy+1)] == -1) {
					ret = true;
					swap(b[GetID(x, cy)], b[GetID(x, cy+1)]);
					++cy;
				}
			}
		}
	}
	return ret;
}

int vanish(int b[], int bonus) {
	bool flag[25];
	memset(flag, false, sizeof(flag));
	for (int y=0; y<5; ++y) for (int x=0; x<5; ++x) {
		if (y > 0 && y < 4 && b[GetID(x, y-1)] == b[GetID(x, y)] && b[GetID(x, y)] == b[GetID(x, y+1)]) {
			flag[GetID(x, y-1)] = flag[GetID(x, y)] = flag[GetID(x, y+1)] = true;
		}
		if (x > 0 && x < 4 && b[GetID(x-1, y)] == b[GetID(x, y)] && b[GetID(x, y)] == b[GetID(x+1, y)]) {
			flag[GetID(x-1, y)] = flag[GetID(x, y)] = flag[GetID(x+1, y)] = true;
		}
	}
	
	int ret = 0;
	for (int y=0; y<5; ++y) for (int x=0; x<5; ++x) {
		if (flag[GetID(x, y)]) {
			ret += score[b[GetID(x, y)]] * bonus;
			b[GetID(x, y)] = -1;
		}
	}
	return ret;
}

void print(int b[]) {
	for (int y=0; y<5; ++y) for (int x=0; x<5; ++x) cerr << b[GetID(x,y)] << (x<4 ? " " : "\n");
	cerr << "-----" << endl;
}

int calcScore() {
	int b[25], ret = 0, bonus = 1;
	for (int i=0; i<25; ++i) b[i] = a[i];
	do {
		ret += vanish(b, bonus);
		++bonus;
		//print(b);
	} while (fall(b));
	return ret;
}

int rec(int x, int y) {
	if (n == 0) return calcScore();
	int ret = calcScore();
	for (int d=0; d<4; ++d) {
		int nx = x + dx[d], ny = y + dy[d];
		if (nx < 0 || nx >= 5 || ny < 0 || ny >= 5) continue;
		--n;
		swap(a[GetID(x, y)], a[GetID(nx, ny)]);
		ret = max(ret, rec(nx, ny));
		++n;
		swap(a[GetID(x, y)], a[GetID(nx, ny)]);
	}
	return ret;
}

int main() {
	while (cin >> n, n != -1) {
		for (int y=0; y<5; ++y) for (int x=0; x<5; ++x) cin >> a[GetID(x, y)];
		for (int i=0; i<5; ++i) cin >> score[i+1];
		int ans = 0;
		for (int y=0; y<5; ++y) for (int x=0; x<5; ++x) ans = max(ans, rec(x, y));
		cout << ans << endl;
	}
}


Measured memory_bytes: 3116
import sys

input = sys.stdin.readline


def solve(X, Y):
    m, n = len(X), len(Y)
    dp = [[0] * (n + 1) for _ in range(m + 1)]
    for i, x in enumerate(X, start=1):
        dp_i = dp[i]
        dp_im = dp[i - 1]
        for j, y in enumerate(Y, start=1):
            if x == y:
                dp_i[j] = dp_im[j - 1] + 1
            elif dp_im[j] > dp_i[j - 1]:
                dp_i[j] = dp_im[j]
            else:
                dp_i[j] = dp_i[j - 1]
    return dp[m][n]


def main():
    q = int(input())
    X = [None] * q
    Y = [None] * q
    for i in range(q):
        X[i] = input().rstrip()
        Y[i] = input().rstrip()

    ans = [solve(x, y) for x, y in zip(X, Y)]
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()



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

using namespace std;

const int maxn = 200010;

int n, X, Y;

const int mod = 1e9+7;

pair<int,int> a[maxn];

int mc[maxn], mi[maxn];
int inv[maxn];

vector<int> g[maxn];
void add(int x,int y) {
//	cout<<x<<' '<<y<<endl;
	g[x].push_back(y);
	g[y].push_back(x);
}

int cc[maxn];

int vis[maxn];
int bfs(int x) {
	int ret = 1, cnt = 0;
	queue<int> q;
	vis[x] = 1; q.push(x);
	while(!q.empty()) {
		x = q.front(); q.pop(); cc[a[x].first]++;
		ret = 1ll * ret * (++cnt) % mod * inv[cc[a[x].first]] % mod; 
		for(auto y: g[x]) if(vis[y] != 1) { vis[y] = 1; q.push(y); }
	}
	vis[x] = 2; q.push(x);
	while(!q.empty()) {
		x = q.front(); q.pop(); cc[a[x].first]--;
		for(auto y: g[x]) if(vis[y] != 2) { vis[y] = 2; q.push(y); }
	}
	return ret;
}

int main() {
	scanf("%d%d%d", &n, &X, &Y);
	for(int i = 1; i <= n; ++i) mc[i] = mod;
	inv[0] = inv[1] = 1;
	for(int i = 2; i <= n; ++i) inv[i] = -1ll * (mod / i) * inv[mod % i] % mod;
	for(int i = 2; i <= n; ++i) if(inv[i] < 0) inv[i] += mod;
	for(int i = 1; i <= n; ++i) {
		int c, w; scanf("%d%d", &c, &w);
		a[i] = {c, w};
		if(w < mc[c]) { mc[c] = w; mi[c] = i; }
	}
	int m1 = mod, i1 = -1, m2 = mod, i2 = -1;
	for(int i = 1; i <= n; ++i) {
		if(mc[i] < m1) { m2 = m1, i2 = i1, m1 = mc[i], i1 = i; }
		else if(mc[i] < m2) { m2 = mc[i], i2 = i; }
	}
	for(int i = 1; i <= n; ++i) {
		int c, w; tie(c, w) = a[i];
		if(mi[c] != i && mc[c] + w <= X) add(mi[c], i);
		if(c != i1 && m1 + w <= Y) add(mi[i1], i);
		if(c != i2 && m2 + w <= Y) add(mi[i2], i);
	}
	long long ans = 1;
	for(int i = 1; i <= n; ++i) if(!vis[i]) ans = ans * bfs(i) % mod;
	cout << ans << endl;
}


Measured memory_bytes: 18024
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    int H = 100;
    int W = 100;
    vector<vector<char>> ans(H, vector<char>(W, '#'));
    int add = 0;
    if (B % (W/2) != 0) add = 1;
    rep(i, B / (W/2) + add + 1) {
        rep(j, W) {
            ans[i][j] = '.';
        }
    }

    int cnt = 0;
    int i1 = 0;
    while(1) {
        rep(j, W) {
            if (i1 % 2 == 0) {
                if ((i1 + j) % 2 == 0 && cnt < B) {
                    ans[i1][j] = '#';
                    cnt++;
                }
                else {
                    ans[i1][j] = '.';
                }
            }
            else {
                ans[i1][j] = '.';
            }
           
        }
        i1++;
        if (cnt >= B) break;

    }
    rep(j, W) {
        ans[i1][j] = '.';
    }
    i1++;
    rep(j, W) {
        ans[i1][j] = '#';
    }
    cnt = 0;
    REP(i, i1 + 1, 100) {
        rep(j, W) {
            if (i % 2 == 0) {
                if ((i + j) % 2 == 0 && cnt < A) {
                    ans[i][j] = '.';
                    cnt++;
                }
            }
            
        }
        if (cnt >= A) break;
    }

    cout << H << " " << W << endl;

    rep(i, H){
        rep(j, W) {
            cout << ans[i][j];
        }
        cout << endl;
    }

    return 0;
}

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

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

using namespace std;

typedef int Weight;
Weight INF = 1000000000;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int src, int dest, Weight weight) {
  g[src].push_back((Edge){src, dest, weight});
  g[dest].push_back((Edge){dest, src, weight});
}

// Dijkstra (Verified: AOJ2005)
void dijkstra(Graph &g, Array &d, int s) {
  d.assign(g.size(), INF);
  d[s] = 0;
  typedef pair<Weight,int> P;
  priority_queue<P, vector<P>, greater<P> > que;
  que.push(P(0, s));
  while (!que.empty()) {
    Weight dist = que.top().first;
    int v = que.top().second;
    que.pop();
    if (d[v] < dist) continue;
    REP(i, g[v].size()) {
      Edge e = g[v][i];
      if (d[e.dest] > d[v] + e.weight) {
        d[e.dest] = d[v] + e.weight;
        que.push(P(d[e.dest], e.dest));
      }
    }
  }
}

int main() {
  while(1) {
    int n,k;
    cin>>n>>k;
    if (!n) break;
    Graph g(n);
    REP(i,k) {
      int c;
      cin>>c;
      if (c==0) {
        int a,b;
        cin>>a>>b;
        --a;--b;
        Array d(n);
        dijkstra(g, d, a);
        if (d[b] < INF) {
          cout<<d[b]<<endl;
        } else {
          cout<<-1<<endl;
        }
      } else {
        int a,b,d;
        cin>>a>>b>>d;
        --a;--b;
        add_edge(g, a, b, d);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1264
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let q: usize = iterator.next().unwrap().parse().unwrap();
    let s: Vec<char> = iterator.next().unwrap().chars().collect();
    let mut t: Vec<usize> = vec![0; n + 1];
    for i in 1..n {
        if s[i - 1] == 'A' && s[i] == 'C' {
            t[i + 1] = t[i] + 1;
        } else {
            t[i + 1] = t[i];
        }
    }

    let mut result = String::new();
    for _ in 0..q {
        let l: usize = iterator.next().unwrap().parse().unwrap();
        let r: usize = iterator.next().unwrap().parse().unwrap();
        result.push_str(&format!("{}\n", t[r] - t[l]));
    }
    return result.trim().to_string();
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string t, b;
    cin >> t >> b;
    if (t.length() < b.length()) {
        cout << "0\n";
        return 0;
    }
    ll mod = 1000000007;
    int n = t.length();
    int m = b.length();
    ll d[n + 1][m + 1]{};
    // d[i][j] 部分文字列t[1..i]において、部分文字列b[1..j]が現れた回数
    d[0][0] = 1;
    for (int i = 0; i <= n; i++) {
        d[i][0] = 1;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            //if (d[i][j] == 0) continue;
            if (t[i] == b[j]) {
                d[i + 1][j + 1] = (d[i][j + 1] + d[i][j]) % mod;;
            } else {
                d[i + 1][j + 1] = d[i][j + 1];
            }
        }
    }
    // for (int i = 0; i <= n; i++) {
    //     for (int j = 0; j <= m; j++) {
    //         cout << d[i][j] << " ";
    //     }
    //     cout << "\n";
    // }
    cout << d[n][m] << "\n";
    return 0;
}


Measured memory_bytes: 11012
def s(n):
    c=0
    while n%10!=0:
        n+=1
        c+=1
    return c

l=[int(input()) for i in range(5)]
n=[]
for i in range(5):
    n.append(s(l[i]))
suml=sum(l)
sumd=sum(n)
maxn=max(n)
print(suml+sumd-maxn)

Measured memory_bytes: 3064
#include <bits/stdc++.h> 
typedef long long ll;using namespace std;int main() {int n; cin >> n;ll x[1005],y[1005];int mod;for (int i=0;i<n;i++){cin>>x[i]>>y[i];if(i==0)mod=abs(x[i]+y[i])%2;else if(mod!=abs(x[i]+y[i])%2){cout<<-1<<endl;return 0;}}vector<string> w(n,""),p(n,"");if(mod==0){cout<<32<<endl<<1<<" ";for(int i=0;i<=30;i++)cout<<(1<<i)<<" ";for (int i=0;i<n;i++){p[i]+="R";x[i]-=1;}}else{cout <<31<<endl;for (int i=0;i<=30;i++)cout<<(1<<i)<<" ";}cout<<endl;for(int i=0;i<n;i++){for (int j=30;j>=0;j--){ll d=1<<j;ll nx=d-1;if(abs(x[i]-d)+abs(y[i])<=nx){w[i]="R"+w[i];x[i]-=d;}else if(abs(x[i]+d)+abs(y[i])<=nx){w[i]="L"+w[i];x[i]+=d;}else if(abs(x[i])+abs(y[i]+d)<=nx){w[i]="D"+w[i];y[i]+=d;}else if(abs(x[i])+abs(y[i]-d)<=nx){w[i]="U"+w[i];y[i]-=d;}}cout<<p[i]+w[i]<<endl;}return 0;}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
const int maxn = 100;
int a[maxn][maxn];
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
int check(int x){
    int tmp = x;
    int pos = 0;
    while (tmp){
         pos =pos  * 10 + tmp % 10;
         tmp /= 10; 
    }
    return pos == x;
}
int main(){
    long long  n,m;
    scanf("%lld%lld",&n,&m);
    if (n == 1 && m == 1){
        printf("1\n");
        return 0;
    }
    if (n - 2 < 0)
    {
        printf("%lld\n", m - 2);
    }else 
    {
        if (m  - 2 < 0)
        {
            printf("%lld\n", n - 2);
        } else printf("%lld\n",(n - 2) * (m - 2));
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

int h, w, ch, cw, dh, dw;
struct pt
{
    int h, w;
};
char mp[1010][1010];
int dp[1010][1010];
int nxth[4] = {0, 0, 1, -1};
int nxtw[4] = {1, -1, 0, 0};
int32_t main()
{
    memset(dp, 0x7f, sizeof(dp));
    scanf("%d %d",&h,&w);
    scanf("%d %d",&ch,&cw);
    scanf("%d %d",&dh,&dw);
    for (int i = 1; i<=h; i++)
        scanf("%s",mp[i]+1);
    deque <pt> q;
    q.push_back({ch, cw});
    dp[ch][cw] = 0;
    while(!q.empty())
    {
        pt x = q.front();
        q.pop_front();

        for (int i = 0; i<4; i++)
        {
            int nh = x.h + nxth[i];
            int nw = x.w + nxtw[i];
            if (mp[nh][nw] == '.')
            {
                if (dp[x.h][x.w] < dp[nh][nw])
                {
                    dp[nh][nw] = dp[x.h][x.w];
                    q.push_front({nh, nw});
                }
            }
        }

        for (int i = -2; i<=2; i++)
        {
            for (int j = -2; j<=2; j++)
            {
                int nh = x.h+i; int nw = x.w+j;
                if (mp[nh][nw] == '.')
                {
                    if (dp[x.h][x.w] + 1 < dp[nh][nw])
                    {
                        dp[nh][nw] = dp[x.h][x.w]+1;
                        q.push_back({nh, nw});
                    }
                }
            }
        }
    }
    if (dp[dh][dw] > 1e8)
        printf("-1\n");
    else printf("%d\n",dp[dh][dw]);
}

Measured memory_bytes: 8860
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

const int MAX = 140000;
double memo[20][MAX];
int a[20];

double cr(int old, int next){
  return (double)abs(old - next) / old;
}

int main(){
  int n; scanf("%d",&n);
  REP(i,n) scanf("%d",a+i);

  const double bad = 1e10;

  REP(i,n) REP(j,MAX)
    memo[i][j] = bad;

  for(int j = 1; j < MAX; j++){
    memo[0][j] = cr(a[0], j);
  }

  REP(i,n - 1){
    REP(j,MAX) if(memo[i][j] != bad){
      for(int k = j; k < MAX; k += j){
	memo[i+1][k] = min(memo[i+1][k], max(memo[i][j], cr(a[i+1], k)));
      }
    }
  }

  double ans = 1e10;
  REP(i,MAX) if(memo[n-1][i] != bad){
    ans = min(ans, memo[n-1][i]);
  }

  /*
  REP(i,n){
    REP(j,25){
      printf("%.2f ", memo[i][j]);
    }
    puts("");
  }
  */

  printf("%.9f\n", ans);

  return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
	Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
	int i = n;
    while (i % 2 != 0) {
      i += n;
    }
    System.out.println(i);
  }
}


Measured memory_bytes: 21716
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include<bits/stdc++.h>

using namespace std;

#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define rep(i, a, b) for(__typeof(b) i = a; i < b; ++i) 
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; --i) 
#define mp make_pair
#define pb emplace_back

typedef pair<int, int> ii;
typedef vector<int> vi;		typedef vector<ii> vii;

// code start here //

const int N = 200005;
int dp[N], pos[N];

signed main() {
	fastio;
	int n, k, c; cin >> n >> k >> c;
	string s; cin >> s;
	rep(i, 1, n + 1) {
		if(s[i - 1] == 'x') {
			dp[i] = dp[i - 1];
			continue;
		}
		dp[i] = dp[i - c - 1] + 1;
	}	
	int cur, temp = k;
	if(dp[n] > k) return 0;
	Rep(i, n, 0) {
		if(dp[i] == temp && s[i - 1] == 'o') {
			if(temp == k) {
				pos[dp[i]] = i;
				cur = i;
				temp--;
				continue;
			}
			if(i + c + 1 <= cur) {
				pos[dp[i]] = i;
				cur = i;
				temp--;
			}
		}
	}
	vi num[k + 1];
	rep(i, 1, n + 1) {
		if(s[i - 1] == 'o' && i <= pos[dp[i]]) {
			num[dp[i]].pb(i);
		}
	}
	rep(i, 1, k + 1) {
		if(num[i].size() == 1) cout << num[i][0] << endl;
	}
}

Measured memory_bytes: 16080
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}


int main(){
    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];
    reverse(all(a));
    ll ans=a[0];
    bool ok=true;
    arep(i,1,n){
        if(a[i]==a[i-1]-1)continue;
        else if(a[i]<a[i-1]-1)ok=false;
        ans+=a[i];
    }
    if(a[n-1]!=0)ok=false;
    if(ok)cout<<ans<<endl;
    else cout<<-1<<endl;
    return 0;
}

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

struct store{
	int A;
	int B;
	bool operator<( const store& right ) const {
        return A == right.A ? B < right.B : A < right.A;
    }
};

int main()
{
	ll N,M;
	cin >> N >> M;
	vector<store> s(N);
	for(ll i(0);i<N;++i){
		cin >> s[i].A >> s[i].B;
	}
	sort(s.begin(), s.end());
	ll ans(0),cnt(0),j(0);
	for(ll i(0);i<M;++i){
		ans += s[j].A;
		cnt++;
		if(cnt == s[j].B){
			cnt=0;
			j++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll A1, A2, A3;
    cin >> A1 >> A2 >> A3;

    vector<ll> h;
    h.push_back(abs(A1 - A2));
    h.push_back(abs(A2 - A3));
    h.push_back(abs(A3 - A1));

    sort(h.begin(), h.end());

    cout << h[0] + h[1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	string s;
	getline(cin, s);
	while (s != "0"){
		int a = 0;
		for (int i = 0; i < s.size(); i++){
			a += (s[i] - 48);
		}
		cout << a << endl; 
		getline(cin, s);
	}
	return 0;
}


Measured memory_bytes: 3180
import math
from itertools import permutations 
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
#print('a')
#print(a)
#print()
List = list(range(n))
n_list = list(permutations(List,n))
#print('n_list')
#print(n_list)
#print()
length = 0
LENGTH = 0
for i in range(len(n_list)):
    for j in range(len(n_list[i])):
        if j+1 != n:
            length += math.sqrt((a[n_list[i][j]][0]-a[n_list[i][j+1]][0])**2+(a[n_list[i][j]][1]-a[n_list[i][j+1]][1])**2)
            #print(length)
    #print(length)  
    LENGTH += length
print(length/len(n_list))

Measured memory_bytes: 8052
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll N,M,ans;
int main() {

	cin>>N>>M;
	if(N>1 && M>1){
		ans=N*M-(2*N+2*M-4);
	}else if(N==1 && M==1){
		ans=1;
	}else{
		ans=N*M-2;
	}

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


Measured memory_bytes: 764
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;

#define MP make_pair
#define fastIO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
int INPUT_INT() { int d; cin >> d; return d; } // 入力をpush_back(d)やarray[d]に使う時に無駄な変数を使わない

// ------------------- include, typedef, define END. -------------------

void solve(VI in){
	FOR(i, 0, in.size()){
		if (in[i]){
			while (in[i]--){
				cout << "*";
			}
			cout << endl;
		}
		else{
			cout << "-" << endl;
		}
	}
}

int main(){
	int n;
	while (cin >> n,n){
		VI input(10,0);
		FOR(i, 0, n){
			input[INPUT_INT()]++;
		}
		solve(input);
	}
	return 0;
}

Measured memory_bytes: 1200
import math

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

#全部選ぶときの最大値は0+1+2+ ~ +nの(n+1)n/2

#k個は好きな選び方ができる。
#k個以上の数を選ぶときの最小値を考える
#その数は10**100 + 10**100+1 + ... + 10*100+k-1のk(k-1)/2である。

#sampleの例をよく見る。i=k ~ n+1まででループさせる。

#k個選んだ時の最大値と最小値を考える。n+(n-1)+(n-2)+ ... +(n-k+1) = k(2n-k+1)/2
max_num = 0
min_num = 0
result_sum = 0
for K in range(k,n+2):
    max_num = K*(2*n-K+1)/2
    min_num = (K-1)*K/2
    result_sum += max_num - min_num +1


result_before_division = result_sum

result = result_before_division % (10**9 + 7)

print(int(result))






Measured memory_bytes: 67632
function main()
  
  N = parse(Int,readline())
  P = map(x -> parse(Int,x), split(readline()))
  
  count = 1
  check = P[1]
  for i in 2:N

    if check >= P[i]
      count += 1
      check = P[i]
    end
    
  end
  
  println(count)
  
end

main()

Measured memory_bytes: 168700
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int a[200000];
ll sum[200000];
int main() {
  int n;
  cin >> n;
  REP(i,n){
    cin >> a[i];
  }

  REP(i,n) {
    if(i == 0) {
      sum[i] = a[i];
      continue;
    }
    sum[i] = sum[i-1] + a[i];
  }

  ll p, q, r, s;

  ll ans = -1;
  for(int i = 2; i < n-1; i++) {
    int ls = 0, le = i;
    while(le - ls > 1) {
      int j = (le+ls)/2;
      p = sum[j-1];
      q = sum[i-1] - p;
      if(p - q <= 0) {
        ls = j;
      } else {
        le = j;
      }
    }
    int rs = i, re = n;
    while(re - rs > 1) {
      int j = (re+rs)/2;
      r = sum[j-1] - sum[i-1];
      s = sum[n-1] - sum[j-1];
      if(r - s <= 0) {
        rs = j;
      } else {
        re = j;
      }
    }

    ll smax, smin;


    for(int j = -1; j < 2; j++) {
      if(ls + j < 0 || i-1 <= ls + j) continue;
      p = sum[ls+j];
      q = sum[i-1] - sum[ls+j];
      for(int k = -1; k < 2; k++) {
        if(rs + k < 0 || n - 1 <= rs + k) continue;
        r = sum[rs + k] - sum[i-1];
        s = sum[n-1] - sum[rs + k];

        smax = max(max(p,q), max(r,s));
        smin = min(min(p,q), min(r,s));
        if(ans >= abs(smax - smin) || ans == -1) {
          ans = abs(smax - smin);
        }
      }
    }
  }
  cout << ans << endl;
}


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

using namespace std;
#define lli long long int
#define ff first
#define ss second
#define lld long double
#define mp make_pair
#define pb push_back
#define mod 1000000007
const int nax=1000*1007;
lli revi(lli i){lli rev=0; while(i>0){rev=(rev*10)+(i%10); i=i/10;}  return rev;}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int s;
    cin>>s;
    int a=s%100;
    int b=s/100;
    if((a==0 && b>12) || (b==0 && a>12) ||(a==0 && b==0))
        cout<<"NA"<<endl;
    else if(a==0)
        cout<<"MMYY"<<endl;
    else if(b==0)
        cout<<"YYMM"<<endl;
    else if(a<=12 && b<=12)
        cout<<"AMBIGUOUS"<<endl;
    else if(b<=12)
        cout<<"MMYY"<<endl;
    else if(a<=12)
        cout<<"YYMM"<<endl;
    else
        cout<<"NA"<<endl;
}


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

using namespace std;

#define fin cin
#define fout cout
//ifstream fin("x.in"); ofstream fout("x.out");

const int nmax = 2000;
const long long inf = 1LL << 60;

long long d[ 2 ][nmax + 1];

int pos[ 2 ][nmax + 1];
int a[nmax + 1][nmax + 1], b[nmax + 1][nmax + 1];
pair<int, int> v[2 * nmax + 1];

int main() {
    fin.sync_with_stdio(false); fin.tie(); fout.tie();

    int n;
    fin >> n;

    for (int i = 1; i <= 2 * n; ++ i) {
        string c; int x;
        fin >> c >> x;
        v[ i ].second = x;
        v[ i ].first = (c == "B");

        pos[ v[ i ].first ][ v[ i ].second ] = i;
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j < i; ++ j)
            a[ i ][ 0 ] += (pos[ 0 ][ j ] > pos[ 0 ][ i ]);

        for (int j = 1; j <= n; ++ j) {
            a[ i ][ j ] = a[ i ][j - 1] + (pos[ 1 ][ j ] > pos[ 0 ][ i ]);
        }
    }

    for (int i = 1; i <= n; ++ i) {
        for (int j = 1; j < i; ++ j)
            b[ i ][ 0 ] += (pos[ 1 ][ j ] > pos[ 1 ][ i ]);

        for (int j = 1; j <= n; ++ j) {
            b[ i ][ j ] = b[ i ][j - 1] + (pos[ 0 ][ j ] > pos[ 1 ][ i ]);
        }
    }

    int ind = 0;
    for (int i = 0; i <= n; ++ i, ind = 1 - ind) {
        for (int j = 0; j <= n; ++ j) {
            if (i == 0 && j == 0)
                continue;

            d[ ind ][ j ] = inf;
            if (i - 1 >= 0) {
                d[ ind ][ j ] = min(d[ ind ][ j ], d[1 - ind][ j ] + pos[ 0 ][ i ] + a[ i ][ j ] - (i + j));
            }
            if (j - 1 >= 0) {
                d[ ind ][ j ] = min(d[ ind ][ j ], d[ ind ][j - 1] + pos[ 1 ][ j ] + b[ j ][ i ] - (i + j));
            }
        }
    }

    ind = 1 - ind;
    fout << d[ ind ][ n ] << "\n";
    return 0;
}



Measured memory_bytes: 31616
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<string.h>

int main()
{
	int card[5];
	
	while( scanf( "%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4] ) != EOF ){
	 	
		int a[20];
		memset( a, 0, sizeof( a ) );
		int c = 0;
		
		for( int i = 0; i < 5; i++ ) a[card[i]]++;
		
		for( int i = 0; i < 5; i++ ){
			 c = std::max( c, (int)std::count( card, card + 5, card[i] ) );
		}
		
		bool f = false, f2 = false;
		int m;
		
		switch( c ){
			case 4:
		 		puts( "four card" );
				break;
			case 3:
				for( int i = 0; i < 5; i++ ){
			 		if( std::count( card, card + 5, card[i] ) == 2 ){
						f = true; 
						break;
					}
				}
				
				if( f ){
				 	puts( "full house" );
				}
				else{
				 	puts( "three card" );
				}
				break;
			case 2:
				for( int i = 0; i < 5; i++ ){
					if( std::count( card, card + 5, card[i] ) == 2 && !f ){
					 	m = card[i];
						f = true;
					}
					if( card[i] != m && std::count( card, card + 5, card[i] ) == 2 && f ){
						puts( "two pair" );
						f2 = true;
						break;
					}
				}
				if( !f2 ) puts( "one pair" );
				break;
			case 1:	
				for( int i = 1; i <= 10; i++ ){
					if( a[i] == 1 && a[i+1] == 1 && a[i+2] == 1 && a[i+3] == 1 && a[(i+4)%13] == 1 ) f = true;
				}
				
				if( f ){
				 	puts( "straight" );
				}
				else{
					puts( "null" );
				}
				
				break;
		}

	}

 	return 0;
}

Measured memory_bytes: 1168
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))

    sa = [0 for i in range(n+1)]
    for i in range(n):
        sa[i+1] = sa[i] + a[i]

    mod_dict, ans = {}, 0
    for i in range(n+1):
        mm = sa[i] % m
        mod_dict[mm] = mod_dict.get(mm, 0) + 1
        ans += mod_dict[mm] - 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16540
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    string s;
    cin >> s;
    rp(i,s.length())
      if(s[i] != s[s.length() - i-1]){
        cout << "No"<<endl; return 0;
      }
    cout << "Yes" <<endl;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main() {
  int n;cin>>n;
  vector<int> a(n+1),b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll ans=0;
  rep(i,n){
    if(b[i]>a[i]){
      ans+=min(b[i],a[i]+a[i+1]);
      a[i+1]=max(a[i+1]-(b[i]-a[i]),0);
    }
    else ans+=b[i];
  }
  cout<<ans<<endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

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

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

  int A, B, C, D;
  cin >> A >> B >> C >> D;


  while (1) {
    C -= B;
    if (C <= 0) {
      cout << "Yes" << endl;
      break;
    }
    A -= D;
    if (A <= 0) {
      cout << "No" << endl;
      break;
    }
  }



  return 0;
};


Measured memory_bytes: 3636
import itertools
N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]
L = list(range(N))
jun = list(itertools.permutations(L))
# print(jun)

ans = 0


for j in jun:
    for num, index in enumerate(j):
        if num == 0:
            bx, by = XY[index]
            continue
        else:
            x, y = XY[index]
            ans += ((x - bx) ** 2 + (y - by) ** 2) ** (0.5)
            bx, by = x, y
# print(len(jun))
print(ans / len(jun))


Measured memory_bytes: 48620
"use strict"
const input = require('fs').readFileSync('/dev/stdin','utf8');
const arr = input.split('\n')
for (let i in arr) {
	const list = arr[i].split(' ');
	const w = parseInt(list[0]);
	const h = parseInt(list[1]);
	if (w === 0 && h === 0) break;
	printRect(w, h);
	console.log('');
}

function printRect(w, h) {
	let line = '';
	const c = '#';
	for (let i = 0; i < w; i++) {
		for (let j = 0 ;j < h; j++) {
			line += c;
		}
		console.log(line);
		line = '';
	} 
}



Measured memory_bytes: 18524
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

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

const long long mod = 1e9 + 7;


map<P, ll> m;
vector<vector<ll>> g;
vector<bool> ch;

ll dfs(ll v, ll c)
{
    ch[v] = 1;
    ll ret = 0;
    ll nc = 1;
    for (int i = 0; i < g[v].size(); ++i)
    {
        if (nc == c)
        {
            nc++;
        }
        if (ch[g[v][i]])
        {
            continue;
        }
        m[P(v, g[v][i])] = nc;
        m[P(g[v][i], v)] = nc;
        ret = max(ret, (ll)g[v].size());
        ret = max(ret, dfs(g[v][i], nc));
        nc++;
    }
    return ret;
}

int main() {
    
    
    ll n;
    cin >> n;
    vector<P> v(n);
    g = vector<vector<ll>>(n, vector<ll>());
    ch = vector<bool>(n);
    for (int i = 0; i < n - 1; ++i)
    {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        v[i] = P(a, b);
    }
    
    ll ret = dfs(0, 0);

    
    cout << ret << endl;
    
    for (int i = 0; i < n - 1; ++i)
    {
        cout << m[v[i]] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 20864
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  vector<int> prime(1000000 + 1, 1), p;
  int x = 2;
  while(x * x <= 1000000) {
    for(int i = x * 2; i <= 1000000; i += x) prime[i] = 0;
    do
      x++;
    while(!prime[x]);
  }
  for(int i = 2; i <= 1000000; i++)
    if(prime[i]) p.push_back(i);
  ll n;
  scanf("%lld", &n);
  int o = 0;
  for(auto x : p) {
    if(n % x == 0) {
      int c = 1;
      while((n /= x) % x == 0) c++;
      for(int i = 2; i <= 9; i++) {
        if((1 + i) * i / 2 > c) {
          o += i - 1;
          break;
        }
      }
    }
  }
  printf("%d\n", o + (n != 1));
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=LINF;
  reps(i,min(n,1000000LL)){
    if(n%i==0) chmin(ans,i+n/i-2);
  }
  cout<<ans<<endl;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
int n, k, s, ans;
int dp[11][155][21];
int solve(int deep = 0, int sum = 0, int back = 0) {
	if (deep == k) {
		return sum == s;
	}
	if (dp[deep][sum][back] >= 0)return dp[deep][sum][back];
	int res = 0;
	for (int i = back + 1; i <= n; i++) {
		res += solve(deep + 1, sum + i, i);
	}
	return dp[deep][sum][back]=res;
}
signed main() {
	while (cin >> n >> k >> s, n || k || s) {
		ans = 0;
		memset(dp, -1, sizeof(dp));
		cout << solve() << endl;

	}
	return 0;
}

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

public class Main
{
	static Scanner scan = new Scanner(System.in);
	public static void solve() throws Exception
	{
		//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer tk = new StringTokenizer(in.readLine());
		int n = scan.nextInt();
		int[] nums = new int[n];
		long res=0;
		for(int i=0;i<n;i++)
		{
			nums[i]=scan.nextInt();
			if(i==0)
				res=nums[i];
			else
				res=res^nums[i];
		}
		for(int i=0;i<n;i++)
		{
			System.out.print((nums[i]^res)+" ");
		}
		System.out.println();
	}
	public static void main(String[] args) throws Exception
	{
		if(scan.hasNext())
		{
			//int t= scan.nextInt();
			int t= 1;
			while(t-->0)
			{	
				solve();
			}
		}
	}
}

Measured memory_bytes: 54916
R,G,B,N = map(int, input().split())  

BALL = [0]*(N+100)
BALL[0] = 1

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + R <= N:
        BALL[num+R] += BALL[num]
for num in range(0,N+1,1):
    if BALL[num] != 0 and num + G <= N:
        BALL[num+G] += BALL[num]

for num in range(0,N+1,1):
    if BALL[num] != 0 and num + B <= N:
        BALL[num+B] += BALL[num]

print(BALL[N])






Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func COM(n, k int64) int64 {
	r := int64(1)
	for i := int64(0); i < k; i++ {
		r = ModMul(r, n-i)
		r = ModDiv(r, i+1)
	}

	return r
}

const (
	MOD = 1000000000 + 7
)

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	value int
	index int
	A, B  int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func FactoredPrimeNumber(num int) map[int]int {
	m := map[int]int{}
	return factor(m, num, 2)
}

func factor(result map[int]int, num, pnum int) map[int]int {
	if pnum*pnum > num {
		if num != 1 {
			result[num] += 1
		}
		return result
	}

	if num%pnum == 0 {
		num /= pnum
		result[pnum]++
	} else {
		pnum++
	}
	return factor(result, num, pnum)
}

func GCD(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

func LCM(a, b int64) int64 {
	return a * b / GCD(a, b)
}

func main() {
	var N, A, B int64
	fmt.Scanf("%d %d %d\n", &N, &A, &B)
	max := ModPow(2, int64(N)) - 1
	a := COM(N, A)
	b := COM(N, B)
	fmt.Println(ModSub(ModSub(max, int64(a)), int64(b)))
}

func Reverse(runes []rune) []rune {
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return runes
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		if(a<b && b<c)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 17272
import java.util.*;

class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int h = 1;
        int bLen = String.valueOf(b).length();
        for (int i=0 ; i<bLen ; i++) {
            h = h*10;
        }
        int ab = (a*h)+b;
        double lootb = Math.sqrt(ab);
        int lb = (int) (lootb);
        if(lb*lb==ab) 
        	System.out.println("Yes");
        else
        	System.out.println("No");
	}
}

Measured memory_bytes: 22864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
 
int main(){
    ll X, Y;
    cin >> X >> Y;
    cout << X+Y/2 << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip> 
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
int a=0,b=0,c=0;

signed main(){
    cin>>a;
    vector<int> A(a);
    
    for(int i=0;i<a;i++)
    {
    cin >> A.at(i);
    }

    rep(i,a){
        b=max(b,A[i]);
        if (A[i]>=b)
        {
            c+=0;
        }else
        {
            c+=b-A[i];
        } 
    }

    cout<<c<<endl;
    
}

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

#define int long long int
#define ff first
#define ss second
#define pb push_back


int bexp(int a, int b)
{
	int res = 1;

	while (b)
	{
		if (b & 1) res = (res * a);

		a = (a * a); 
		b >>= 1;
	}
	return res;
}

int gcd(int a, int b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

#define N 200010
#define MOD 1000000007


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	string s;
	cin >> s;

	int n = s.size();

	int f = 1;

	for (int i = 0; i < n / 2; ++i)
	{
		if (s[i] != s[n - i - 1])
		{
			f = 0;
			break;
		}
	}

	if (f)
	{
		for (int i = 0; i < (n - 1) / 2; ++i)
			if (s[i] != s[(n - 1) / 2 - i - 1])
				f = 0;
	}

	if (f)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

l = [0] * (n + 1) 

for i in range(k):
  d = int(input())
  a = input().split()
  #print(l[int(a[0])])
  for j in a:
    l[ int(j) ] = 1
    

print(n - sum(l))

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

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

	int l = 0;
	ll tmp = n;
	while (tmp != 0) {
		l++;
		tmp /= 26;
	}

	string ans;
	n--;
	ans += n % 26 + 'a';
	for (int i = 1; i < l; i++) {
		n /= 26;
		if (n == 0) break;
		n--;
		ans += n % 26 + 'a';
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

/* 先行順巡回*/
void preParse(int u) {
	if ( u ==  NIL ) return;
	printf(" %d", u);
	preParse(T[u].l);
	preParse(T[u].r);
}

/* 中間順巡回*/
void inParse(int u) {
	if ( u == NIL ) return;
	inParse(T[u].l);
	printf(" %d", u);
	inParse(T[u].r);
}

/* 後行順巡回*/
void postParse(int u) {
	if ( u == NIL ) return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d", u);
}

int main() {
	int i, v, l, r, root;
	
	scanf("%d", &n);
	for ( i = 0; i < n; i++ ) {
		T[i].p = NIL;
	}
	
	for ( i = 0; i < n; i++ ) {
		scanf("%d %d %d", &v, &l, &r);
		T[v].l = l;
		T[v].r = r;
		if ( l != NIL ) T[l].p = v;
		if ( r != NIL ) T[r].p = v;
	}
	
	for ( i = 0; i < n; i++ ) if ( T[i].p == NIL ) root = i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	
	return 0;
}



Measured memory_bytes: 2080
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int n,max=0,s=0;
    cin>>n;
    if(n==1) {cout<<"1"<<endl;return 0;}
    for(int i=n;i>=1;i--)
    {
        for(int j=10;j>=1;j--)
        {
            if(pow(2,j)==i) {cout<<i<<endl;return 0;}
        }
    }
    return 0;
}


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


int main()
{
    int a;
    cin >> a;
    if(a == 25)
        cout << "Christmas";
    else if(a == 24)
        cout << "Christmas Eve";
    else if(a == 23)
        cout << "Christmas Eve Eve";
    else
        cout << "Christmas Eve Eve Eve";
}


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

int main(){
    ll n, k;
    cin >> n >> k;

    ll sum = 0;
    if(k==0){
        sum = n*n;
        cout << sum << endl;
        return 0; 
    }

    for(ll i=1; i<n+1; i++){
        ll tmp = n/i;
        if(i>k){
            sum += tmp*(i-k);
        }

        if(n%i==0) continue;
        else if(n%i>=k){
            sum += n%i-k+1; 
        }
    }

    cout << sum << endl;
} 

Measured memory_bytes: 256
def main():
    n = int(input())
    s = list(input())
    ss = list(sorted(list(set(s))))
    s_sorted = list(sorted(s))
    if len(ss) < 3:
        print(0)
        return
    m = n-1
    sn = [0]*3
    j = 0
    flag = False
    for i, si in enumerate(ss):
        while s_sorted[j] == si:
            sn[i] += 1
            if j == m:
                flag = True
                break
            j += 1
        if flag:
            break
    ans = sn[0]*sn[1]*sn[2]
    for d in range(1, n//2+1):
        i = 0
        d2 = 2*d
        ma = n-d2
        while i < ma:
            si, sj, sk = s[i], s[i+d], s[i+d2]
            if si != sj and sj != sk and si != sk:
                ans -= 1
            i += 1
    print(ans)
                

if __name__ == "__main__":
    main()

Measured memory_bytes: 67860