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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, K;
vector<int> G[100010];

int dfs(int v, int p)
{
	int n;
	if (p!=-1)
	{
		n = K - 2;
	}
	else
	{
		n = K - 1;
	}
	int res = 1;
	for (auto e : G[v])
	{
		if (e == p)continue;
		res = (res*n) % MOD;
		n--;
	}

	if (n < 0)
	{
		return 0;
	}

	for (auto e : G[v])
	{
		if (e == p)continue;
		res = (res*dfs(e, v)) % MOD;
	}

	return res % MOD;
}

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

	cin >> N >> K;
	int a, b;
	rep(i, 0, N - 1)
	{
		cin >> a >> b;
		a--, b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	cout << (K*dfs(0, -1))%MOD << endl;

	return 0;
}

Measured memory_bytes: 10368
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x, y) debug(x), debug(y)
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))
const int mxN = 2e5 + 5;
const int MOD = 998244353;

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

struct BIT{
	vector<ll> bit;
	BIT(){
		bit.assign(mxN, 0LL);
	}
	void update(int ind, ll val){
		for(; ind < mxN; ind += (ind & (-ind))) bit[ind] += val;
	}
	ll query(int ind){
		ll ret = 0LL;
		for(; ind; ind -= (ind & (-ind))) ret += bit[ind];
		return ret;
	}
};

ll dp[mxN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vi l(k), r(k);
	rep(i, k) cin >> l[i] >> r[i];
	dp[1] = 1;
	BIT bit;
	repn(i, 1, n + 1){
		if(i != 1) dp[i] = (bit.query(i) + MOD) % MOD;
		rep(j, k) if(i + l[j] <= n){
			bit.update(i + l[j], dp[i]);
			bit.update(i + r[j] + 1, -dp[i]);
		}
	}
	cout << (dp[n] + MOD) % MOD << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

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

signed main()
{
    int n; cin >> n;
    vector<int> sub(n+1,0);
    for (int i = 2; i <= n; ++i){
        int tmp;
        cin >> tmp;
        ++sub[tmp];
    }

    rep(i,n) cout << sub[i+1] << endl;

    return 0;
}


Measured memory_bytes: 4000
N,D = map(int,input().split())
X = []
count = 0

for n in range(N):
  x = list(map(int,input().split()))
  X.append(x)
  
for i in range(N):
  for j in range(i+1,N):
    distance = 0
    for k in range(D):
      distance += abs(X[i][k] - X[j][k])**2 
    if (distance**0.5).is_integer():
      count += 1
      
print(count)

Measured memory_bytes: 9396
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String aStr = sc.next();
        String bStr = sc.next();
        String cStr = sc.next();

        String currentA = aStr;
        String currentB = bStr;
        String currentC = cStr;
        String ans = "";
        boolean finish = false;

        // 初回の処理
        String next = String.valueOf(aStr.charAt(0));
        currentA = aStr.substring(1);
        while (!finish) {

            switch (next) {
                case "a":
                    if (currentA.length() == 0) {
                        ans = "A";
                        finish = true;
                        break;
                    }
                    next = String.valueOf(currentA.charAt(0));
                    currentA = currentA.substring(1);
                    break;
                case "b":
                    if (currentB.length() == 0) {
                        ans = "B";
                        finish = true;
                        break;
                    }
                    next = String.valueOf(currentB.charAt(0));
                    currentB = currentB.substring(1);
                    break;
                case "c":
                    if (currentC.length() == 0) {
                        ans = "C";
                        finish = true;
                        break;
                    }
                    next = String.valueOf(currentC.charAt(0));
                    currentC = currentC.substring(1);
                    break;
            }

        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int R = scan.nextInt();
    if (N < 10) {
      R += 100 * (10 - N);
    }
    System.out.printf("%d\n", R);
  }
}

Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>

using namespace std;

int main()
{
	int N;
	cin >> N;
	
	cout <<pow(N,3)<<endl;
	
	
	
	
	
	
	
	return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long int 
#define double /*long*/ double
#define endl '\n'
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vppll vector<pair<pll,pll>>
#define mp make_pair
#define pb push_back
#define mapll map<ll,ll>
#define fir first
#define sec second
#define _cin ios_base::sync_with_stdio(0);  cin.tie(0);
#define fo(i,b) for(i=0;i<b;i++)
#define repa(i,a,b) for(i=a;i<b;i++)
#define repb(i,a,b) for(i=a;i>=b;i--)
#define all(x) (x).begin(), (x).end()
#define s(v) v.size()
const long long int MAX = (ll)(1e18+1);
const long long int MIN = (ll)(-1e18-1);
const long long int mod = (ll)(1e9+7);
using namespace std;

ll max(ll a,ll b,ll c) {return max(max(a, b), c);}
ll min(ll a,ll b,ll c) { return min(min(a, b), c);}
ll max(ll a,ll b) {return (a>b) ? a : b;}
ll min(ll a,ll b) {return (a<b) ? a : b;}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power_mod(ll a, ll n, ll mod_){ ll p=1; while(n){ if(n%2){ p=(p*a)%mod_;} n/=2; a=(a*a)%mod_;} return p%mod_;}
                                                 /*Code Begins*/

vector<vector<ll>> mat_mul(vector<vector<ll>>& a , vector<vector<ll>>& b , ll n){
    vector<vector<ll>> c(n);
    ll i , j , k;
    fo(i,n) c[i].assign(n,0);
    fo(i,n){
        fo(j,n){
            fo(k,n){
                c[i][j] += (a[i][k]*b[k][j])%mod;
                c[i][j]%=mod;
            }
        }
    }
    return c;
}

vector<vector<ll>> mat_exp(vector<vector<ll>>& a , ll n , ll k ){
    vector<vector<ll>> I = {{1,0,0},{0,1,0},{0,0,1}};
    if(k==0) return I;
    if(k==1) {
        int i, j;
        fo(i, n){
            fo(j, n) a[i][j]%=mod;
        }
        return a;
    }
    vector<vector<ll>> c = mat_exp(a,n,k/2);
    c = mat_mul(c , c, n);
    if(k%2==1){
        c = mat_mul(a , c , n);
    }
    return c;
}

int main(){

    _cin;
    // cout << setprecision(15);
    ll mn = MAX, mx = MIN;
    ll n, t, m, k, i, j,  sum=0,  prev, flag=0, cnt=0;
    ll x=0, y=0, fx, diff, tot=0, l , r;
    int TC=1;
    // cin >> TC;
while(TC--){
    cin >> n >> k;
    vector<vector<ll>> a(n);
    fo(i,n) a[i].assign(n,0);
    fo(i,n) fo(j,n) cin >> a[i][j];
    vector<vector<ll>> c = mat_exp(a , n , k);
    cnt=0;
    fo(i,n){
        fo(j,n) cnt = (cnt + c[i][j])%mod;
    }
    cout << cnt ;
}
 return 0;      
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int n,d,x[15][15],i,j,k,ans=0;
	cin>>n>>d;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=d;j++)
		{
			cin>>x[i][j];
		}
	}
	for (i=1;i<=n;i++)
	{
		for (j=i+1;j<=n;j++)
		{
			int dist=0,t;
			for (k=1;k<=d;k++)
			{
				dist+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
			}
			t=(int)sqrt((double)dist);
			if (dist==t*t) ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
package main

import (
    "bufio"
    "fmt"
    "os"
  "strconv"
  "strings"
)

func main() {
  var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()  
  var count, _ = strconv.Atoi(sc.Text())
  
  var countAc int = 0
  var countWa int = 0
  var countTle int = 0
  var countRe int = 0
  
     for i := 0; i < count; i++ {
       sc.Scan()
       var word = sc.Text()
       if strings.Contains(word, "AC") {
       	countAc += 1
       } else if word == "WA" {
       	countWa += 1
       } else if word == "TLE" {
       	countTle += 1
       } else if word == "RE" {
       	countRe += 1
	    }
     }
       
       fmt.Printf("AC x %d\n", countAc)
       fmt.Printf("WA x %d\n", countWa)
       fmt.Printf("TLE x %d\n", countTle)
       fmt.Printf("RE x %d", countRe)
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define sz(v) (ll)(v).size()
#define F first 
#define S second 
#define lc "\n"
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll ncr(ll n,ll k){if(k==0)return 1;if(k>n-k)k=n-k;ll a=1,b=1,d;while(k){a*=n;b*=k;d=__gcd(a,b);a/=d;b/=d;n--;k--;}return a;} 
ll MAX=1e18 , MIN=-1e18 , MOD=1000000007;
void YJ()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
}
void dfs(ll s,vector<ll>adj[],vector<ll>&vis)
{
	vis[s]=1;
	for(auto i: adj[s])
	{
		if(!vis[i])
		dfs(i,adj,vis);
	}
}
int main() 
{
    YJ(); fastio
    ll n,m,i,j,u,v,c=0; cin>>n>>m; 
    vector<ll>adj[n+1]; vector<ll>vis(n+1,0);
    for(i=0;i<m;i++)
    {
    	cin>>u>>v;
    	adj[u].pb(v); adj[v].pb(u);
    }
    for(i=1;i<=n;i++)
    {
    	if(!vis[i])
    	{
    		c++; 
    		dfs(i,adj,vis); 
    	}
    }
    cout<<c-1;
    return 0;
}

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

int che(string s, string t){
    int n = s.length();
    int cou = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == '?'){
            cou++;
        }else{
            if(s[i] != t[i]){
                cou = -1;
                break;
            }
        }
    }

    return cou;
}

int main(){

    string s, t;
    cin >> s >> t;

    int s_n = s.length();
    int t_n = t.length();

    vector<int> poj;
    for(int i = 0; i < s_n - t_n + 1; i++){
        int k = che(s.substr(i, t_n), t);

        if(k != -1){
            poj.push_back(i);
        }
    }

    if(poj.empty()){
        cout << "UNRESTORABLE" << endl;
    }else{
        vector<string> ans;
        for(int i= 0; i < poj.size(); i++){
            int k = poj[i];
            string p;
            for(int i= 0; i < k; i++){
                if(s[i] == '?'){
                    p += 'a';
                }else{
                    p += s[i];
                }
            }

            p += t;

            for(int i = k + t_n; i < s_n; i++){
                if(s[i] == '?'){
                    p += 'a';
                }else{
                    p += s[i];
                }
            }
            ans.push_back(p);
        }

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

        cout << ans[0] << endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>

int search(int A[],int n,int k){
	int i=0;
	A[n]=k;
	while(A[i]!=k)i++;
	
	return i != n;
}


int main(void){
	int n,q,i,k,sum=0;
	int A[114514];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&k);
		if(search(A,n,k))sum++;
	}
	printf("%d\n",sum);
	return 0;
}


Measured memory_bytes: 2060
#include<bits/stdc++.h>
using namespace std;
#define next Next
const int N=1e6+5;
#define int long long
int n,m,top,vis[N],dis[N],head[N];
struct node{
	int too,next,zh;
}edge[N];
void add(int a,int b,int c)
{
	edge[++top].too=b;edge[top].zh=c;
	edge[top].next=head[a];head[a]=top;
}
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
void dfs(int u,int dep)
{
	if(vis[u])
	{
		if(dis[u]!=dep)
		{
			puts("No");
			exit(0);
		}
		return;
	}
	vis[u]=1;
	dis[u]=dep;
	for(int i=head[u];i;i=edge[i].next)
	{
		int v=edge[i].too,w=edge[i].zh;
		dfs(v,dep+w);
	}
}
signed main()
{
	n=read(),m=read();
	for(int i=1;i<=m;i++)
	{
		int x=read(),y=read(),z=read();
		add(x,y,z);
		add(y,x,-z);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])dfs(i,0);
	puts("Yes");
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
int main() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  cout << fixed << setprecision(10) << w*h/2 << " ";
  if (x == w/2 && y == h/2) cout << 1;
  else cout << 0;
  cout << el;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swap(数値交換)
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define cncn int cnt=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　（A＋B）÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	int n, a, b;
	cin >> n >> a >> b;
	if (n * a <= b)cout << n * a << rt;
	else cout << b << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

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

using ll = int64_t;
const int MAX = 2e5;

int32_t main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, k; cin >> n >> k;
    vector<int> v(n);
    for (int &it : v) cin >> it;

    int L = 0, R = 1e9;
    while (R-L > 1) {
        ll cut = (L+R)/2, cnt = 0;
        for (int i : v) cnt += (i-1)/cut;
        if (cnt > k) L = cut;
        else R = cut;
    }
    cout << R;

    return 0;
}

Measured memory_bytes: 3968
import Control.Monad
main :: IO()
main = do
  [n, x] <- toIntAll . words <$> getLine
  xs <- toIntAll . words <$> getLine
  let result = calcMaxD xs x
  print result

calcMaxD :: [Int] -> Int -> Int
calcMaxD [] x = error "error"
calcMaxD xs x = gcdAll $ map (abs . subtract x) xs

gcdAll :: [Int] -> Int
gcdAll (x:xs) = foldl gcd x xs

toIntAll :: [String] -> [Int]
toIntAll = map (read :: String -> Int)

Measured memory_bytes: 36220
import java.util.Arrays;
import java.util.Scanner;

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

		int N = scan.nextInt();
		int L[] = new int[N];

		int ans = 0;

		for(int i = 0;i < N; i++) {
			L[i] = scan.nextInt();
		}

		Arrays.sort(L);

		for(int i = 0; i < N - 2; i++) {
			for(int j = i + 1; j < N - 1; j++) {
				for(int k = j + 1; k < N; k++) {
					if(!(L[i] == L[j] || L[j] == L[k]) && L[i] + L[j] > L[k]) {
						ans++;
					}
				}
			}
		}

		System.out.println(ans);

	}
}

Measured memory_bytes: 27356
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    char[] S,T;
    private void solve() {
        S = next().toCharArray();
        T = next().toCharArray();

        int N = S.length;
        TreeSet<Integer>[] st = new TreeSet[26];
        TreeSet<Integer>[] ts = new TreeSet[26];
        for(int i = 0;i < 26;i++) {
            st[i] = new TreeSet<>();
            ts[i] = new TreeSet<>();
        }
        for(int i = 0;i < N;i++) {
            int s = S[i] - 'a';
            int t = T[i] - 'a';

            st[t].add(s);
            ts[s].add(t);
        }

        for(int i = 0;i < 26;i++) {
            if (st[i].size() > 1) {
                out.println("No");
                return;
            }

            if (ts[i].size() > 1) {
                out.println("No");
                return;
            }
        }

        out.println("Yes");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 27892
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
int n, m, P, dp[MAXN][MAXN][2];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n), read(P), m = (n - 1) / 2;
	dp[0][0][0] = 1;
	for (int i = 1; i <= m; i++)
	for (int j = 0; j <= n; j++) {
		update(dp[i][j][1], dp[i - 1][j][0]);
		if (j >= i) update(dp[i][j][1], dp[i][j - i][1]);
		dp[i][j][0] = dp[i][j][1];
		if (j >= i) update(dp[i][j][0], dp[i][j - i][0]);
	}
	int ans = 0;
	if (n & 1) {
		for (int i = 1; i <= n; i++)
		for (int j = 0; j * (m + 1) <= n - i; j++)
			update(ans, dp[m][n - i - j * (m + 1)][0]);
	} else {
		for (int i = 1; i <= n; i++)
		for (int j = 0; j * (m + 1) <= n - i; j++)
			update(ans, 1ll * dp[m][n - i - j * (m + 1)][0] * (j + 1) % P);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 98560
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

class Point
{
public:
   double x;
   double y;
};

void koch(int n, Point a, Point b){
   if(n == 0) return;

   Point s, u, t;
   double si60 = sqrt(3.0)/2.0;
   double co60 = 0.5;

   s.x = (a.x + a.x + b.x) / 3.0;
   s.y = (a.y + a.y + b.y) / 3.0;
   t.x = (a.x + b.x + b.x) / 3.0;
   t.y = (a.y + b.y + b.y) / 3.0;
   u.x = (t.x - s.x) * co60 - (t.y - s.y) * si60 + s.x;
   u.y = (t.x - s.x) * si60 + (t.y - s.y) * co60 + s.y;

   koch(n-1, a, s);
   printf("%.8f %.8f\n", s.x, s.y);
   koch(n-1, s, u);
   printf("%.8f %.8f\n", u.x, u.y);
   koch(n-1, u, t);
   printf("%.8f %.8f\n", t.x, t.y);
   koch(n-1, t, b);
}

int main(){
   int n;
   Point a, b;
   a.x = 0.0;
   a.y = 0.0;
   b.x = 100.0;
   b.y = 0.0;
   cin >> n;
   printf("%.8f %.8f\n", a.x, a.y);
   koch(n, a, b);
   printf("%.8f %.8f\n", b.x, b.y);
   return 0;
}


Measured memory_bytes: 3204
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IMAX 2147483647
#define LMAX 9223372036854775807
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define PII pair<int,int>
#define PIII pair<int,PII>
#define VPII vector<PII>
#define VPIII vector<PIII>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define th se.se
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define rotateleft(vec,n) rotate(a.begin(),a.begin()+n,a.end())
#define rotateright(vec,n) rotate(a.rbegin(),a.rbegin()+n,a.rend())
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define countif(vec,condition_VAR) count_if(all(vec),[&](auto VAR){return condition_VAR;})
#define replaceif(vec,condition_VAR,n) replace_if(all(vec),[&](auto VAR){return condition_VAR;},n)
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_VAR) for_each(all(vec),[&](auto&VAR){VAR=calc_VAR;});
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return max(a,b);}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}
template<class C>int binarysearch(vector<C> vec,C n,char c){int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;while(right-left>1){int mid=left+(right-left)/2;bool OK=vec[mid]*getmin>=n*getmin;if(outleft==OK) left=mid;else right=mid;}return outleft?left:right;}


#define int int64_t
// #define double long double


// map
// segmenttree

signed main(){
  IOS;

  in(int,n);

  int ans=0;
  if(n>=105)ans++;
  if(n>=135)ans++;
  if(n>=165)ans++;
  if(n>=189)ans++;
  if(n>=195)ans++;
  out(ans);
  
}

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

int main() {
  long long n;
  cin >> n;
  long long ans=1e21;
  for(int i=1;i<sqrt(n)+1;i++) {
    if(n%i==0) {
      ans=min(ans,n/i+i-2);
    }
  }
  cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  auto dfs = [&](auto dfs, int l, int r, ll cl, ll cr) -> ll {
    if (r - l == 1) return 0;
    ll res = 1e18;
    for (int i = l+1; i <= r-1; i++) {
      res = min(res, dfs(dfs, l, i, cl, cl+cr) + dfs(dfs, i, r, cl+cr, cr) + (cl+cr)*a[i]);
    }    
    return res;
  };
  cout << dfs(dfs, 0, n-1, 1, 1) + a[0] + a[n-1] << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;

int main(){
	string s;
	cin>>s;
	if(s=="MON") cout<<"6"<<endl;
	else if(s=="TUE") cout<<"5"<<endl;
	else if(s=="WED") cout<<"4"<<endl;
	else if(s=="THU") cout<<"3"<<endl;
	else if(s=="FRI") cout<<"2"<<endl;
	else if(s=="SAT") cout<<"1"<<endl;
	else{
		cout<<"7"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

M = 2019

Ss = input().rstrip()

As = [0]
A = 0
d = 1
for S in reversed(Ss):
    A += int(S) * d
    A %= M
    As.append(A)
    d = (d*10) % M

As.reverse()
#print('As:', As)

cnt = Counter(As)

ans = 0
for A, num in cnt.items():
    ans += num*(num-1)//2

print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  ll x, y;
  cin >> x >> y;
  ll val = 1;
  int cnt = 0;
  while (x * val <= y){
    cnt++;
    val *= 2;
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 256
import math
n = int(input())
ans = 10**12
square = math.ceil(math.sqrt(n))+1
for i in range(1,square):
    if n%i == 0:
        ans = min(ans,n/i) 
if ans == 10**12:
    print(n-1)
    exit()	
b = n/ans
print(int(ans+b-2))

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

void warshall_floyd(int n, vector<vector<int>> &dist){
    for(int k=0; k<n; k++){
        for(int i=0; i<n; i++){
            for(int j=0; j<n; j++){
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }
}

int main(){
    while(1){
        int n, m; cin>>n>>m;
        if(n == 0) return 0;

        vector<vector<int>> cost(m, vector<int>(m, 1e9));
        vector<vector<int>> time(m, vector<int>(m, 1e9));
        for(int i=0; i<m; i++){
            cost[i][i] = time[i][i] = 0;
        }

        for(int i=0; i<n; i++){
            int s, t, co, ti; cin>>s>>t>>co>>ti;
            s--, t--;
            cost[s][t] = cost[t][s] = co;
            time[s][t] = time[t][s] = ti;
        }

        warshall_floyd(m, cost);
        warshall_floyd(m, time);

        int q; cin>>q;
        while(q--){
            int s, t, r; cin>>s>>t>>r;
            s--, t--;
            if(r == 0){
                cout << cost[s][t] << endl;
            }
            else{
                cout << time[s][t] << endl;
            }
        }
    }
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>                                                      
using namespace std;
int main()
{
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> A(M);
  for(int i=0; i<M; i++){
    cin >> A.at(i);
  }
  int count_r=0;
  int count_l=0;
  for(int i=X; i<N; i++){
    for(int j=0; j<M; j++){
      if(i==A.at(j))
        count_r++;
    }
  }
  for(int i=X; i>0; i--){
    for(int j=0; j<M; j++){
      if(i==A.at(j))
        count_l++;
    }
  }
  if(count_r>count_l)
    cout << count_l << endl;
  else
    cout << count_r << endl;
}


Measured memory_bytes: 256
# imos 法
from operator import itemgetter

N, C = map(int, input().split())
stc = [list(map(int, input().split())) for _ in range(N)]
stc.sort(key=itemgetter(2, 0))

cs = [0] * (10 ** 5 + 1)
pc = -1
for s, t, c in stc:
    if pc != c:
        pt = -1
        pc = c
    if pt == s:
        cs[s] += 1
    else:
        cs[s - 1] += 1
    cs[t] -= 1
    pt = t

for i in range(1, 10 ** 5 + 1):
    cs[i] += cs[i - 1]

print(max(cs))


Measured memory_bytes: 35460
#include <cmath>
#include <cstdio>
#include <iostream>
#include <utility>
using namespace std;

int main(){
	int n;
	scanf(" %d", &n);
	for(int i=0; i<n; ++i){
		double xa, ya, ra, xb, yb, rb;
		scanf(" %lf %lf %lf %lf %lf %lf", &xa, &ya, &ra, &xb, &yb, &rb);
		double dist=pow(xb-xa, 2) + pow(yb-ya, 2);
		double p, q;
		bool biga=true;
		if(ra>rb){ p=ra; q=rb; }
		else { q=rb; p=ra; biga=false; }
		
		int ans;
		if(dist>pow(p+q, 2)) ans=0;
		else if(pow(p-q, 2)<=dist && dist<=pow(p+q, 2)) ans=1;
		else{
			if(biga) ans=2;
			else ans=-2;
		}
		
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<stdlib.h>

int main()
{
  long long n,m,i;
  scanf("%lld%lld",&n,&m);
  long long tmp = m/n;
  for(i=tmp;i>1;)
  {
    if(m%i==0) break;
    else i--;
  }
  
  printf("%lld",i);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n; cin>>n;
  vector<pair<double,double>> p(n);
  rep(i,n){
    double x,y; cin>>x>>y;
    p[i]={x,y};
  }
  cout<<setprecision(10);
  vi a(n); rep(i,n) a[i]=i;
  double dist=0.0;
  do{
    rep(i,n-1){
      dist+=pow(pow((p[a[i]].first-p[a[i+1]].first),2.0)+pow(p[a[i]].second-p[a[i+1]].second,2.0),0.5);
    }
    //rep(i,n) cout<<a[i]<<" ";
    //cout<<endl;
  }while(next_permutation(a.begin(),a.end()));
  double kaijou=1;
  rep(i,n){
    kaijou*=(i+1);
  }
  cout<<dist/kaijou<<endl;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int partSum[1001];
  for(int i = 0; i <= 1000; i++) partSum[i] = i;
  partial_sum(partSum, partSum + 1001, partSum);
   
  int N;
  while(cin >> N, N){
    int cnt = 0;
    for(int i = 0; i < 1000; i++){
      for(int j = i + 2; j < 1001; j++){
    if(partSum[j] - partSum[i] == N) cnt++;
      }
    }
    cout << cnt << endl;
  }
   
  return 0;
}


Measured memory_bytes: 2972
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var s=input.trim().split("");
var abc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
s = s.map(v=> abc.indexOf(v));
var cnt = 0;
var memo = 0;
s.forEach(v=>{
   if(memo >= v)cnt++;
   memo = v;
});
console.log(cnt);


Measured memory_bytes: 15424
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000000000000;
const int mod = 1000000007;
int test[1234][1234], cost[1234][1234];
signed main() {
	vector<int> v; map<string, int> mn;
	int n, m, q, a = 0, b, c, cnt = 0, ans = 0; string s, t;
	cin >> n >> m; 
	if (n % 2 == 1) {
		for (int h = 0; h < m; h++) {
			cout << cnt + 1 << ' ' << n - cnt - 1 << endl; cnt++;
		}
	}
	else {
		int z = 0;
		for (int h = 0; h < n / 4; h++) {
			cout << cnt + 1 << ' ' << n - cnt << endl; cnt++; z++;
			if (z == m) { return 0; }
		}
		for (int h = 0; h < m / 2; h++) {
			cout << cnt + 1 << ' ' << n - cnt - 1 << endl; cnt++; z++;
			if (z == m) { return 0; }
		}
	}
	return 0;
}

Measured memory_bytes: 3604
#include <cstdio>
#define LEN 500

int C[LEN], S[LEN], F[LEN];
int main() {

    int N;
    scanf("%d", &N);
    for (int i = 0; i < N-1; i++) {
        scanf("%d %d %d", &C[i], &S[i], &F[i]);
    }
    for (int j = 0; j < N-1; j++) {
    int time = 0;
        for (int i = j; i < N-1; i++) {
            int diff = time - S[i];
            if (diff <= 0) {
                time = S[i] + C[i];
            }
            else {
                int qoi = diff % F[i];
                if (qoi) {
                    time += C[i] + (F[i] - qoi);
                }
                else {
                    time += C[i];
                }
            }

        }
            printf("%d\n", time);
    }
    printf("0\n");
}



Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;

vector<int> a;

bool judge(int x){
    vector<int> t=a;
    REP(i,t.size())t[i]=((t[i]>=x)?1:0);
    for(int i=(int)t.size()/2-1;i>=0;i--){
        if(t[i]==t[i+1]){
            if(t[i]==0){
                return false;
            }else{
                return true;
            }
        }else if(t[t.size()-i-2]==t[t.size()-i-1]){
            if(t[t.size()-i-1]==0){
                return false;
            }else{
                return true;
            }
        }
    }
    if(t[0]==0)return false;
    return true;
}

int main(){
    
    int N; cin>>N;
    a.resize(N*2-1);
    REP(i,N*2-1)cin>>a[i];
    
    int low=1, high=N*2-1;
    while(high-low>1){
        int mid=(low+high)/2;
        if(judge(mid)){
            low=mid;
        }else{
            high=mid;
        }
    }
    
    cout<<low<<endl;
    
    return 0;
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  ll x,y;
  cin >> x >> y;
  ll ans=INFL;
  if(x<y){
    if(0<=x && 0<=y)ans=min(ans, y-x );
    else if(0<=y && x<=0 && y>=-x)ans=min(ans,1+y+x);
    else if(0<=y && x<=0 &&-x>=y){
      ans=min(ans,-y-x+1);
      if(y==0)ans--;
    }
    else ans=min(ans,y-x);
  }
  else{
    if(0<=x && 0<=y){
      ans=min(ans,2+x-y);
      if(y==0)ans--;
    }
    else if(0<=x && x>=-y)ans=min(ans,1+x+y);
    else if(0<=x && x<=-y)ans=min(ans,1-y-x);
    else ans=min(ans,2-y+x);
  }
  if(x==0 && y==0) ans=0;
  cout<<ans<<endl;  
  
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int i,a,b,c,count;
    cin >> a >> b >> c;
    count=0;
    for (i=a;i<=b;i++){
        if (c % i ==0){
            count+=1;
        }
    }
    cout << count <<endl;
}


Measured memory_bytes: 3076
while True:
    a,op,b = input().split()
    A ,B = int(a),int(b)
    if op == "+":
        print(A + B)
    elif op == "-":
        print(A - B)
    elif op == "*":
        print(A * B)
    elif op == "/":
        print(A // B)
    else:
        break


Measured memory_bytes: 5600
mod = 1000000007
eps = 10**-9
inf = 10**9


def main():
    import sys
    input = sys.stdin.readline

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

    dp = [[-inf] * (N+1) for _ in range(4)]
    dp[0][N] = N
    for i in range(3):
        for j in range(N, -1, -1):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            if j - A[i] >= 0:
                dp[i+1][j-A[i]] = max(dp[i+1][j-A[i]], dp[i+1][j] + B[i] - A[i])
    N = max(dp[-1])
    dp = [[-inf] * (N + 1) for _ in range(4)]
    dp[0][N] = N
    for i in range(3):
        for j in range(N, -1, -1):
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
            if j - B[i] >= 0:
                dp[i + 1][j - B[i]] = max(dp[i + 1][j - B[i]], dp[i+1][j] + A[i] - B[i])
    print(max(dp[-1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 850948
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include <utility>
#include<unordered_set>
#include <algorithm>
using namespace std;

 
 
vector<int> bills(int N,int Y){
	vector<int> output(3,-1);
	if(N <0)
		return output;
	else if(N == 0){ 
		if(Y == 0){
			output = vector<int>(3,0);
			return output;
		}
		else
			return output;
	}
	int n1, n2, n3;
	
	n1 = max(Y/10000,N);
	while(n1 >=0){
		n2 = max((Y-10000*n1)/5000,N-n1);
		while(n2 >=0){
			n3 = N-n1-n2;
			if(10000*n1 + 5000*n2 + 1000*n3 ==Y){
				output[0] = n1;
				output[1] = n2;
				output[2] = n3;
				return output;
			}
			n2--;
		}
		n1--;
	}
	return output;
}
 
 
 
 
int main(){
	int N, Y;
	cin>>N>>Y;
	
	vector<int> output = bills(N,Y);
	
	cout<< output[0]<<" "<<output[1]<<" "<<output[2]<<"\n";
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using ll =  long long;

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

using namespace std;

int main(){

    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    rep(i,m) cin>>a[i];
    rep(i,m) n-=a[i];
    if(n<0)n=-1;
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String	O = sc.next(),E=sc.next();

		if(O.length()>E.length()) {
			System.out.println("GREATER");
		}else if(E.length()>O.length()){
			System.out.println("LESS");
		}else {
			for(int i=0;i<E.length();i++) {
				if(O.charAt(i)>E.charAt(i)) {
					System.out.println("GREATER");
					break;
				}else if(E.charAt(i)>O.charAt(i)) {
					System.out.println("LESS");
					break;
				}else if(i==O.length()-1){
					System.out.println("EQUAL");
				}
			}
		}
	}

	public static int sample() {
		return 1;
	}

}


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

#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rrep(i, N) for (int i = (int)(N)-1; i >= 0; --i)
#define debug(x) cout << #x << "=" << x << endl;
constexpr int MOD=1000000007;
constexpr ll INF = (1LL << 61) - 1;
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;} return false;}
template <typename T> void fail(T v){cout << v << endl;exit(0);}
//templte
const int P=1<<10;
int N;
int V[1<<18],W[1<<18],dp[P][100100];

void pre(int i){
    if (i >= P or i > N) return;
    int p = i >> 1;
    for (int j = 0; j < 100001; j++)
    {
        dp[i][j] = dp[p][j];
        if (j - W[i-1] >= 0) chmax(dp[i][j], dp[p][j - W[i-1]] + V[i-1]);
    }
    pre(i << 1);
    pre((i << 1) | 1);
}
void solve(){
    scanf("%d",&N);
    rep(i,N){
        scanf("%d %d",&V[i],&W[i]);
    }
    int Q;scanf("%d",&Q);
    pre(1);
    while(Q--){
        int i,l;
        scanf("%d %d",&i,&l);
        vector<int> s;
        int res=0;
        while(i>=P){
            s.push_back(i);i>>=1;
        }
        rep(j,1<<s.size()){
            int w=0,v=0;
            rep(k,s.size())if(1&j>>k){
                w+=W[s[k]-1];v+=V[s[k]-1];
                if(w>l)goto END;
            }
            chmax(res,v+dp[i][l-w]);

            END:;
        }
        printf("%d\n",res);
    }
}

int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(20);
    solve();
    return 0;
}

Measured memory_bytes: 405788
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=1LL<<60;


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

  return 0;
}



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

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 umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#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 h,w,n,a;
int ans[200][200] = {};
int x = 0,y = 0;
int main(){
    cin >> h >> w >> n;
    rep(i,1,n+1){
        cin >> a;
        rep(j,0,a){
            ans[y][x] = i;
            if(y&1)x--;
            else x++;
            if(x < 0){
                x = 0;
                y++;
            }
            if(w <= x){
                x = w-1;
                y++;
            }
        }
	}

	rep(i,0,h){
	    rep(j,0,w)PS(ans[i][j]);
	    cout << endl;
	}
	return  0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll a, b, x;
  cin >> a >> b >> x;
  fin(b / x - a / x + (a % x == 0));
}

Measured memory_bytes: 256