akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

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

    int n,m,c;cin>>n>>m>>c;
    vint b(m); rep(i,m)cin>>b[i];
    vvi a(n,vi(m));rep(i,n)rep(j,m)cin>>a[i][j];

    int res=0;

    rep(i,n){
        int tmp=0;
        rep(j,m){
            tmp+=a[i][j]*b[j];
        }
        if(tmp+c>0) res++;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    while(x % y != 0)
    {
        int r = x % y;
        x = y;
        y = r;
    }
    cout << y << "\n";
    
    return 0;
}


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

class UnionFind {
public:
  std::vector<int> data; // sizeとparを同時に管理する
  UnionFind(int size) : data(size, -1) {}

  int find(int x) {
    return data[x] < 0 ? x : data[x] = find(data[x]);
  }

  void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) {
      if (data[py] < data[px]) std::swap(px, py);
      data[px] += data[py]; data[py] = px;
    }
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return -data[find(x)];
  }
};

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> count(n, 1);
  UnionFind uf(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    count[a] += 1;
    count[b] += 1;
    uf.unite(a, b);
  }
  for (int i = 0; i < k; ++i) {
    int c, d;
    cin >> c >> d;
    --c; --d;
    if (uf.same(c, d)) { 
      count[c] += 1;
      count[d] += 1;
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << uf.size(i)-count[i];
    if (i < n-1) cout << " ";
    else cout << "\n";
  }
}


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

#define fto(i, x, y) for(int i = (x); i <= (y); ++i)
#define fdto(i, x, y) for(int i = (x); i >= (y); --i)
#define ftoa(i, x, y, a) for(int i = (x); i <= (y); i += a)
#define ftoit(it, var) for (__typeof(var.begin()) it = var.begin(); it != var.end(); ++it)

#define ii pair<int, int>
#define mp make_pair

#define FF first
#define SS second

#define vi vector<int>
#define vii vector<ii>
#define ll long long
#define vll vector<ll>

#define eb emplace_back
#define ef emplace_front
#define lb lower_bound
#define ub upper_bound

#define oo 1000000007LL
#define OO 1000000000000000007LL

using namespace std;

#define Pro "tmp"
#define maxN 100007

ll _a[maxN], _b[maxN], _c[maxN];
ll a[maxN], b[maxN], l[maxN], r[maxN];

int main() {
//    #ifndef ONLINE_JUDGE
//        freopen(Pro".inp", "r", stdin);
//        freopen(Pro".out", "w", stdout);
//    #endif // ONLINE_JUDGE

    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);

    vii vc;
    int n = x+y+z;

    fto (i, 1, n) {
        scanf("%lld%lld%lld", &_a[i], &_b[i], &_c[i]);
        vc.eb(_a[i]-_b[i], i);
    }
    sort(vc.begin(), vc.end());

    ll ans = 0LL;
    priority_queue <ll> q;

    fto (i, 0, x+y+z-1) {
        int j = vc[i].SS;
        a[i+1] = _a[j]-_c[j];
        b[i+1] = _b[j]-_c[j];
        ans += _c[j];
    }

    fto (i, 1, n) {
        l[i] = l[i-1]+b[i];
        q.emplace(-b[i]);

        if ((int)q.size() > y) {
            l[i] += q.top();
            q.pop();
        }
    }

    while (!q.empty()) q.pop();

    fdto (i, n, 1) {
        r[i] = r[i+1]+a[i];
        q.emplace(-a[i]);

        if ((int)q.size() > x) {
            r[i] += q.top();
            q.pop();
        }
    }

    ll res = LLONG_MIN;
    fto (i, y, n-x) {
        res = max(res, l[i]+r[i+1]);
    }

    ans += res;
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 7796
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main()
{
	string a;

	getline(cin, a);

	for (int i = 0; i < a.size();i++)
	{
		if ('a' <= a[i] && a[i] <= 'z')
		{
			a[i] -= 32;
		}
		else if ('A' <= a[i] && a[i] <= 'Z')
		{
			a[i] += 32;
		}
		cout << a[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3080
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.next();
			if("-".equals(s)){
				break;
			}
			int m = sc.nextInt();
			for(int i = 0; i < m; i++){
				int h = sc.nextInt();
				s = s.substring(h) + s.substring(0, h);
			}
			System.out.println(s);
		}
	}
}



Measured memory_bytes: 26456
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c1 = s.charAt(0);
		char c2 = s.charAt(1);
		char c3 = s.charAt(2);
		char c4 = s.charAt(3);
		boolean bool =  false;
		if(c1 == c2)
		{
			if(c3 == c4 && c1 != c3)
				bool = true;
		}
		if(c1 == c3) {
			if(c2 == c4 && c1 != c2)
				bool = true;
		}
		if(c1 == c4) {
			if(c2 == c3 && c1 != c2)
				bool = true;
		}
		System.out.println(bool ? "Yes" : "No");
		}
}



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

#define rep(i, j, k) for(int i = (int) j; i < (int) k; ++i)
#define sz(x) ((int) (x).size())
#define ll long long
#define mp make_pair
#define pii pair<int, int >
#define fi first
#define se second
#define pb push_back
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define zero(x) memset((x), (0), sizeof (x))
#define zerox(x, y) memset((x), (y), sizeof (x))

using namespace std;

int main()
{
#ifdef PIT
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
#endif //PIT

	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, a;
	cin >> n;
	map<int, int > m;
	m.clear();
	rep(i, 0, n) {
		cin >> a;
		if(m[a] == 0) m[a]++;
		else m[a] = 0;
	}
	int t = 0;
	for(auto & u: m) if(u.se) ++t;
	cout << t << endl;
	
#ifdef PIT
flush(cout);
cerr << endl << "Time: " << (clock() / double(CLOCKS_PER_SEC)) << endl;
#endif //PIT
	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
 

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p(n);
    
    for(int i=0; i<n; i++){
        cin >> p[i];
    }
    int q=1000, w=1000;
    for(int e=0;e<100;e++){
        int ans1=0;
        for(int j=0; j<n; j++){
            if((x+e)!=p[j]){
                ans1++;
            }
        }
        if(ans1==n){
            q=x+e;
            break;
        }
    }
    for(int e=0; e<100; e++){
        int ans2=0;
        for(int j=0; j<n; j++){
            if((x-e)!=p[j]){
                ans2++;
            }
        }
        if(ans2==n){
            w=x-e;
            break;
        }
    }
    if((q-x)<(x-w)){
        cout << q << endl;
    }
    else cout << w << endl;
    
    return 0;
 }


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

const int MAX_N = 205;
int H, W, A[MAX_N][MAX_N], B[MAX_N][MAX_N], C[MAX_N][MAX_N];
bool used[MAX_N][MAX_N];

struct edge {
	int to, cap, rev;
};

class MaxFlow {
public:
	vector<edge> G[MAX_N * 2 + 4];
	bool used[MAX_N * 2 + 4];

	void add_edge(int u, int v, int c) {
		G[u].push_back(edge{ v, c, (int)G[v].size() });
		G[v].push_back(edge{ u, 0, (int)G[u].size() - 1 });
	}
	int dfs(int pos, int to, int f) {
		if (pos == to) return f;
		used[pos] = true;

		for (int i = 0; i < G[pos].size(); i++) {
			if (used[G[pos][i].to] == true || G[pos][i].cap == 0) continue;

			int Z = dfs(G[pos][i].to, to, min(f, G[pos][i].cap));
			if (Z == 0) continue;

			G[pos][i].cap -= Z;
			G[G[pos][i].to][G[pos][i].rev].cap += Z;
			return Z;
		}
		return 0;
	}
	vector<pair<int, int>> max_flow(int u, int v) {
		while (true) {
			for (int i = 0; i < MAX_N * 2 + 4; i++) used[i] = false;
			int F = dfs(u, v, (1 << 30));
			if (F == 0) break;
		}

		vector<pair<int, int>> L;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < G[i].size(); j++) {
				if (G[i][j].to < H || G[i][j].to >= 2 * H) continue;
				if (G[i][j].cap == 0) L.push_back(make_pair(i, G[i][j].to - H));
			}
		}
		return L;
	}
};

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) { cin >> A[i][j]; A[i][j]--; }
	}
	for (int i = 0; i < W; i++) {
		MaxFlow V;
		for (int j = 0; j < H; j++) {
			for (int k = 0; k < W; k++) {
				if (used[j][k] == false) V.add_edge(j, H + (A[j][k] / W), 1);
			}
		}
		for (int i = 0; i < H; i++) {
			V.add_edge(2 * H, i, 1);
			V.add_edge(H + i, 2 * H + 1, 1);
		}
		vector<pair<int, int>> E = V.max_flow(2 * H, 2 * H + 1);
		for (int j = 0; j < E.size(); j++) {
			for (int k = 0; k < W; k++) {
				if (used[E[j].first][k] == false && (A[E[j].first][k] / W) == E[j].second) {
					used[E[j].first][k] = true;
					B[E[j].first][i] = A[E[j].first][k];
					break;
				}
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) C[i][j] = B[i][j];
	}
	for (int i = 0; i < W; i++) {
		vector<int> I;
		for (int j = 0; j < H; j++) I.push_back(C[j][i]);
		sort(I.begin(), I.end());
		for (int j = 0; j < H; j++) C[j][i] = I[j];
	}

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) { if (j) cout << " "; cout << B[i][j] + 1; } cout << endl;
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) { if (j) cout << " "; cout << C[i][j] + 1; } cout << endl;
	}
	return 0;
}

Measured memory_bytes: 848
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<lint, lint> P;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	while (1) {
		sort(A);
		if (A[0] == A[N - 1])break;
		for (int i = 1; i < N; i++) {
			if (A[i] % A[0] != 0) {
				A[i] = A[i] % A[0];
			}
			else {
				A[i] = A[0];
			}
		}
	}
	cout << A[0] << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int a, b;

int main()
{
	scanf("%d%d", &a, &b);
	
	if (b == 1)
	{
		printf("0\n");
		return 0;
	}
	
	int nums = 1;
	int curCount = a;
	while (curCount < b)
	{
		curCount = curCount + (a - 1);
		nums++;
	}
	
	printf("%d\n", nums);
	

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using System.Runtime.CompilerServices;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
	return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    static int n, a, b;
    static int[] h;
    
    static bool enough(int times)
    {
	int c = (a - b);
	int t = 0;
	for (int i = 0; i < n; i++)
	{
	    int hr = h[i] - b*times;
	    if(hr > 0)
	    {
		t += (hr + c - 1) / c;
		if (t > times) return false;
	    }
	}
	return true;
    }
    
    public static void Main()
    {
	var tmp = ReadIntArray();
	n = tmp[0]; a = tmp[1]; b = tmp[2];
	h = new int[n];

	int hmax = 0;
	for (int i = 0; i < n; i++)
	    hmax = Math.Max(hmax, h[i] = int.Parse(ReadLine()));

	int l = 0, r = (hmax + b - 1) / b;
	int m = -1;
	while (l < r)
	{
	    m = (l + r) / 2;
	    //WriteLine($"{hmax} {l} {r} {m}");
	    if (enough(m)){ r = m; }
	    else { l = m + 1; }
	}
	WriteLine(r);
    }
}


Measured memory_bytes: 17872
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	long long int n, yojo, yan;
	string s;
	cin >> n;
	yan = sqrt(n);
	for (int i = yan; i >= 1;i--) {
		if (n%i)continue;
		yojo = n / i;
		break;
	}
	s = to_string(yojo);
	cout << s.size() << endl;
	return 0;
}

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

int NUM[1000001];
int n;
bool BinSearch(int target)
{
    int hi=0;int lo=n;
    while(hi<lo)
    {
        int mi=(hi+lo)/2;
        if(target<NUM[mi])
        {
            lo=mi;
            continue;
        }
        else if(target>NUM[mi])
        {
            hi=mi+1;
            continue;
        }
        else
        {
            return true;
        }
    }
    return false;
}
int main() {
   cin>>n;
    int p=0;
    for(int i=0;i<n;i++)
        cin>>NUM[i];
    int q;
    cin>>q;
    for(int j=0;j<q;j++)
    {
        int t;
        cin>>t;
        if(BinSearch(t)) p++;
    }
    cout<<p<<endl;
}

Measured memory_bytes: 3384
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (ll i = 0; i < (ll)n; i++)
#define frab(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef double ld;

const ll INF = 1e9 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;
const ll M = 15;
const ll N = 1e6 + 10;



int main() {
    //freopen("a.in", "r", stdin);
    ll n, m;
    cin >> n >> m;
    cout << (100 * (n - m) + 1900 * m) * (1 << m);

}


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

using namespace std;

int sec[200010];
int n;

bool check(int x)
{
    for(int i=0;i<n;i++)
    {
        if((sec[n+i]<=x&&sec[n+i+1]<=x)||(sec[n-i]<=x&&sec[n-i-1]<=x)) return 1;
        if((sec[n+i]>x&&sec[n+i+1]>x)||(sec[n-i]>x&&sec[n-i-1]>x)) return 0;
    }
    return sec[1]<=x;
}

int main()
{
    cin>>n;
    for(int i=1;i<=2*n-1;i++)
    {
        cin>>sec[i];
    }
    int l=1,r=2*n-1;
    while(l<r)
    {
        int mid=l+r>>1;
        if(check(mid))
        {
            r=mid;
        }
        else
        {
            l=mid+1;
        }
    }
    cout<<l<<'\n';
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i=0;
    while(s[i]!='C'){i++;if(i==s.size()){cout<<"No"<<endl;return 0;}}
	while(s[i]!='F'){i++;if(i==s.size()){cout<<"No"<<endl;return 0;}}
    cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int h,w,a,b;
int main(){
	cin >> h >> w >> a >> b;
	rep(i,h){
		rep(j,w){
			if(i<b&&j<a) printf("1");
			else if(i>=b&&j>=a) printf("1");
			else printf("0");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, 0, n) cin >> h[i];

    int ans = 1;
    rep(i, 1, n) {
        bool flag = true;
        rep(j, 0, i) {
            if (h[i] < h[j]) flag = false;
        }
        if (flag) ans++;
    }

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


Measured memory_bytes: 256
import math

n = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

l = make_divisors(n)
n = len(l)
ans = []
for i in range(n):
	ans.append(l[i] + l[n-i-1])

print(min(ans)-2)


Measured memory_bytes: 3544
#!/usr/bin/python3
# -*- coding: utf-8 -*-
x1 = list(map(int, input().split()))
x2 = list(map(int, input().split()))
x3 = list(map(int, input().split()))
x = x1 + x2 + x3
n = int(input())
a = [0] * 9
for i in range(0, n):
    b = int(input())
    if b in x:
        a[x.index(b)] = 1

if a[0] == 1 and a[1] == 1 and a[2] == 1:
    print("Yes") 
elif a[3] == 1 and a[4] == 1 and a[5] == 1:
    print("Yes") 
elif a[6] == 1 and a[7] == 1 and a[8] == 1:
    print("Yes") 
elif a[0] == 1 and a[3] == 1 and a[6] == 1:
    print("Yes") 
elif a[1] == 1 and a[4] == 1 and a[7] == 1:
    print("Yes") 
elif a[2] == 1 and a[5] == 1 and a[8] == 1:
    print("Yes") 
elif a[0] == 1 and a[4] == 1 and a[8] == 1:
    print("Yes") 
elif a[2] == 1 and a[4] == 1 and a[6] == 1:
    print("Yes") 
else:
    print("No")

Measured memory_bytes: 3064
var lines = []; var N = 0; var result = Infinity;

var readline = require('readline');
var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
})

rl.on('line', function (x) {
    lines.push(x);
});

rl.on("close", function () {
    N = Number(lines[0]);

    var dp = Array(Math.max(N, 730)).fill(0);

    dp[0] = 0;
    dp[1] = 1;
    dp[Math.pow(6, 1)] = 1; dp[Math.pow(6, 2)] = 1; dp[Math.pow(6, 3)] = 1; dp[Math.pow(6, 4)] = 1; dp[Math.pow(6, 5)] = 1; dp[Math.pow(6, 6)] = 1;
    dp[Math.pow(9, 1)] = 1; dp[Math.pow(9, 2)] = 1; dp[Math.pow(9, 3)] = 1; dp[Math.pow(9, 4)] = 1; dp[Math.pow(9, 5)] = 1;


    for (var index = 1; index <= N; index++) {
        var a = Infinity;
        var b = Infinity, c = Infinity, d = Infinity, e = Infinity, f = Infinity; g = Infinity;
        var h = Infinity, i = Infinity, j = Infinity, k = Infinity, l = Infinity

        if (1 <= index) a = dp[index - 1] + dp[1];

        if (Math.pow(6, 1) <= index) b = dp[index - Math.pow(6, 1)] + dp[Math.pow(6, 1)];
        if (Math.pow(6, 2) <= index) c = dp[index - Math.pow(6, 2)] + dp[Math.pow(6, 2)];
        if (Math.pow(6, 3) <= index) d = dp[index - Math.pow(6, 3)] + dp[Math.pow(6, 3)];
        if (Math.pow(6, 4) <= index) e = dp[index - Math.pow(6, 4)] + dp[Math.pow(6, 4)];
        if (Math.pow(6, 5) <= index) f = dp[index - Math.pow(6, 5)] + dp[Math.pow(6, 5)];
        if (Math.pow(6, 6) <= index) g = dp[index - Math.pow(6, 6)] + dp[Math.pow(6, 6)];

        if (Math.pow(9, 1) <= index) h = dp[index - Math.pow(9, 1)] + dp[Math.pow(9, 1)];
        if (Math.pow(9, 2) <= index) i = dp[index - Math.pow(9, 2)] + dp[Math.pow(9, 2)];
        if (Math.pow(9, 3) <= index) j = dp[index - Math.pow(9, 3)] + dp[Math.pow(9, 3)];
        if (Math.pow(9, 4) <= index) k = dp[index - Math.pow(9, 4)] + dp[Math.pow(9, 4)];
        if (Math.pow(9, 5) <= index) l = dp[index - Math.pow(9, 5)] + dp[Math.pow(9, 5)];

        dp[index] = Math.min(a, b, c, d, e, f, g, h, i, j, k, l);
    }

    console.log(dp[N]);
});


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

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

    string res = "Yes";
    char tail;
    vector<string> w(n);
    for (int i = 0; i < n; i++) {
        cin >> w.at(i);
        if (i != 0) {
            if (tail != w.at(i).at(0)) res = "No";
        }
        tail = w.at(i).at(w.at(i).size()-1);
    }

    sort(w.begin(), w.end());
    for (int i = 1; i < n; i++) {
        if (w.at(i-1) == w.at(i)) res = "No";
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3596
n=int(input())
ll=[]
for i in range(n):
    ll.append([int(i) for i in input().split()])
dp=[[0]*3 for i in range(n)]
dp[0]=ll[0]
for i in range(1,n):
    for j in range(3):
        dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+ll[i][j]
print(max(dp[n-1]))
   
            
        
    


Measured memory_bytes: 73944
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}
	
	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int M=1e6+10;
	ll fac[M],facinv[M],Inv[M];ll C(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,M-1) fac[i]=fac[i-1]*i%MOD;
		facinv[M-1]=invm(fac[M-1]);fd(i,M-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,M-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}
	const int N=3e5+10;
	//------------------FIXED------------------
	pll a[N];int dp[N][50];vc<ll> hh;
	void main()
	{
		int n=qread(),T=qread(),m=0;
		fo(i,1,n)
		{
			pll t;t.FR=qread()+1,t.SE=qread()+1;
			if(t.FR!=1) a[++m]=t; else hh.PB(t.SE);
		}
		hh.PB(0);sort(all(hh));fo(i,1,sz(hh)-1) hh[i]+=hh[i-1];
		
		sort(a+1,a+m+1,[&](pll a,pll b){return b.SE*(a.FR-1)<a.SE*(b.FR-1);} );
		mem(dp,0x3f);dp[m+1][0]=1;
		fd(i,m,1) fo(ct,0,38)
		{
			chmin(dp[i][ct],dp[i+1][ct]);
			dp[i][ct+1]=min(1ll*dp[i][ct+1],1ll*dp[i+1][ct]*a[i].FR+a[i].SE);
		}
		int ans=0;fo(ct,0,39) fo(i,0,sz(hh)-1) if(dp[1][ct]+hh[i]<=T+1) chmax(ans,ct+i);write(ans);
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::PRE();//线性预处理模意义
	mine::main();
	debug("\n---------------------Zory---------------------\nTime: %.2lf s",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 87796
import sys
input = sys.stdin.readline


class Dice:
    """
    0:top, 1:south, 2:east, 3:west, 4:north, 5:bottom
    """

    def __init__(self, surfaces):
        self.init_surface = surfaces
        self.surface = surfaces

    def init_dice(self):
        self.surface = self.init_surface

    def roll(self, direction: str):
        if direction == "E":
            self.surface = [self.surface[3], self.surface[1], self.surface[0],
                            self.surface[5], self.surface[4], self.surface[2]]

        elif direction == "N":
            self.surface = [self.surface[1], self.surface[5], self.surface[2],
                            self.surface[3], self.surface[0], self.surface[4]]

        elif direction == "S":
            self.surface = [self.surface[4], self.surface[0], self.surface[2],
                            self.surface[3], self.surface[5], self.surface[1]]

        elif direction == "W":
            self.surface = [self.surface[2], self.surface[1], self.surface[5],
                            self.surface[0], self.surface[4], self.surface[3]]

        return

    def spin(self):
        self.surface = [self.surface[0], self.surface[3], self.surface[1],
                        self.surface[4], self.surface[2], self.surface[5]]
        return

    def get_surface(self, num):
        if num in self.surface:
            indexes = [i for i, x in enumerate(self.surface) if x == num]
            return indexes
        else:
            return []

    def get_top(self):
        return self.surface[0]

    def get_south(self):
        return self.surface[1]

    def get_east(self):
        return self.surface[2]


def is_same_dice(dice1: Dice, dice2: Dice):
    top1 = dice1.get_top()
    indexes = dice2.get_surface(top1)
    for cur in indexes:
        dice2.init_dice()
        if cur == 0:
            pass
        elif cur == 1:
            dice2.roll("N")
        elif cur == 2:
            dice2.roll("W")
        elif cur == 3:
            dice2.roll("E")
        elif cur == 4:
            dice2.roll("S")
        elif cur == 5:
            dice2.roll("S")
            dice2.roll("S")
        for _ in range(4):
            dice2.spin()
            if dice1.surface == dice2.surface:
                return True
    return False


def main():
    n = int(input())
    dices = list()
    for _ in range(n):
        surface = [int(i) for i in input().strip().split()]
        dices.append(Dice(surface))

    for i in range(n-1):
        for j in range(i + 1, n):
            if is_same_dice(dices[i], dices[j]):
                print("No")
                return

    print("Yes")
    return


if __name__ == "__main__":
    main()



Measured memory_bytes: 5640
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    x = ni()
    print("Yes" if x >= 30 else "No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 11184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=105;
int n;
struct P{int x,y;}a[N],b[N];
set<int>S;
set<int>::iterator it; 
inline int cmp(P a,P b){return a.x<b.x||a.x==b.x&&a.y<b.y;}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j;
	scanf("%d",&n);
	for(i=1;i<=n;++i){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	for(i=1;i<=n;++i){
		scanf("%d%d",&b[i].x,&b[i].y);
	}
	sort(a+1,a+1+n,cmp);
	sort(b+1,b+1+n,cmp);
	int ans=0;
	for(i=j=1;i<=n;++i){
		for(;j<=n&&a[j].x<=b[i].x||a[j].x==b[i].x&&a[j].y<=b[i].y;++j){
			S.insert(-a[j].y);
		}
		if(S.size()){
			it=S.lower_bound(-b[i].y);
			if(it==S.end())continue;
			S.erase(it);++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
	vector<int> N(4);
	rep(i,4)
		cin >> N.at(i);
	sort(N.begin(), N.end());

	if(N.at(0)==1 && N.at(1)==4 && N.at(2)==7 && N.at(3)==9)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    sort(a.begin(), a.end());
    int nmax = a.at(n-1);
    bool even = false;
    if(nmax % 2 == 0) {
        even = true;
    }

    int nmin = 0;
    int mint = 1e+9;

    if(even) {
        int nmid = nmax/2;
        for(int i = 0; i < n-1; ++i) {
            int comp = abs(a.at(i)-nmid);
            if(mint > comp) {
                nmin = a.at(i);
                mint = comp;
            }
        }
    }else {
        int nmid1 = nmax/2;
        int nmid2 = nmid1 + 1;
        for(int i = 0; i < n-1; ++i) {
            int comp = min(abs(a.at(i)-nmid1), abs(a.at(i)-nmid2));
            if(mint > comp) {
                nmin = a.at(i);
                mint = comp;
            }
        }
    }

    cout << nmax << " " << nmin << endl;
}

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

int main(int argc, char *argv[])
{
    int A, B, C;
    std::cin >> A >> B >> C;

    if (A == B) {
        std::cout << C << std::endl;
    } else if (B == C) {
        std::cout << A << std::endl;
    } else {
        std::cout << B << std::endl;
    }
    return 0;
}

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

using ll = long long;
const int MOD = 1e9+7;
const int MAXN = 3005;
ll dp[MAXN][MAXN][2];
int n, m;

void add(ll& a, ll b) {
    a += b;
    if (a >= MOD) a -= MOD;
}


int main() {
    cin >> n >> m;
    for (int j = 0; j <= n; ++j) dp[0][j][j == 0] = 1;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j <= n; ++j) {
            for (int k = 0; k < 2; ++k) {
                for (int j1 = 0; j1 <= 1; ++j1) for (int j2 = 0; j2 <= 1; ++j2) {
                    if (j == 0 && j1) continue;
                    if (j == n && !j1) continue;
                    int nj = j+1-j1-j2;
                    int nk = k || (j == j1);
                    add(dp[i+1][nj][nk], dp[i][j][k]);
                }
            }
        }
    }

    ll res = 0;
    for (int j = 0; j <= n; ++j) add(res, dp[m][j][1]);
    cout << res << endl;
    return 0;
}


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

int main() {
	int n, sum = 0;
	while (true) {
		cin >> n;
		if (n == 0) break;
		else {
			vector<int>a(n);
			for (int i = 0; i < n; i++) {
				cin >> a.at(i);
				sum += a.at(i);
			}
			double ave = sum / n;
			int ans = 0;
			for (int i = 0; i < n; i++) {
				if (a.at(i) <= ave) ans++;
			}
			cout << ans << endl;
		    n = 0, sum = 0, ave = 0;
		    for (int i = 0; i < n; i++) {
			a.at(i) = 0;
		    }
		}
	}
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
typedef long long ll;
#define endl '\n'
using namespace std;
const int MOD = 1000000007, MAX = 2000000007, MAXN = 100005;
int boss[2*MAXN], sub[2*MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
    cin>>n;
    for(int i=2; i<=n; i++)
    {
        cin>>boss[i];
        sub[i] = 0;
    }
    sub[0] = 0;
    sub[1] = 0;
    for(int i=2; i<=n; i++)
    {
        sub[boss[i]]++;
    }
    for(int i=1; i<=n; i++)
        cout<<sub[i]<<endl;
	return 0;
}

Measured memory_bytes: 5208
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

const INF: usize = std::usize::MAX;

fn main() {
   input! {
      n: usize,
      a: [usize; n]
   }
   let mut b = vec![0; n + 1];
   for i in 0..n {
      b[i + 1] = b[i] + a[i];
   }
   let mut dp = vec![vec![INF; n + 1]; n + 1];
   for i in 0..n {
      dp[i][i + 1] = 0;
   }

   for l in 2..n + 1 {
      for i in 0..n - l + 1 {
         for m in i + 1..i + l {
            dp[i][i + l] = std::cmp::min(dp[i][i + l], dp[i][m] + dp[m][i + l]);
         }
         dp[i][i + l] += b[i + l] - b[i];
      }
   }
   println!("{}", dp[0][n]);
}


Measured memory_bytes: 4352
import java.util.*;
import java.awt.*;


 
class Main {
 
    private static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        int n = Integer.parseInt(sc.next());
        ArrayList<Point> j = new ArrayList<Point>();
        for(int i = 0; i<n; i++){
            j.add(new Point(Integer.parseInt(sc.next()),
                Integer.parseInt(sc.next())));
        }
        String ans = "Yes";
        int nowTime = 0;        
        j.sort(Comparator.comparing(Point::getY)
        .thenComparing(Point::getX));
        for(Point p :j){
            nowTime += p.x;
            if(nowTime > p.y){
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }


}

Measured memory_bytes: 109048
package main

import "fmt"

func main() {
	// Code for C - Skill Up
	var N, M, X int
	fmt.Scan(&N, &M, &X)

	C := make([]int, N)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&C[i])
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}

	var n int = N
	var money int
	var flag int
	var min int = 10000000000
	for i := 0; i < (1 << n); i++ {
		sum := make([]int, M)
		money = 0
		flag = 0
		for j := 0; j < n; j++ {
			if i>>j&1 == 1 {
				money += C[j]
				for k := 0; k < M; k++ {
					sum[k] += A[j][k]
				}
			}
		}

		for k := 0; k < M; k++ {
			if sum[k] < X {
				flag = 1
			}
		}
		if flag == 0 {
			if min > money {
				min = money
			}
		}
	}

	if min == 10000000000 {
		fmt.Println("-1")
	} else {
		fmt.Println(min)
	}
}


Measured memory_bytes: 2236
#include <cstdio>

int main()
{
	int n;
	int i, max;
	long long int sum = 0;
	scanf("%d", &n);
	scanf("%d", &max);
	for (i = 0; i < n - 1; i++) {
		int a;
		scanf("%d", &a);
		if (a > max) {
			max = a;
		} else if (max > a) {
			sum += max - a;
		}
	}
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 1732
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
string s;
int main(){
	cin>>s;
	for(int i=0;s[i];i++)
		if(s[i]=='9'){
			puts("Yes");
			return 0;
		}
	puts("No");
	return 0;
}

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

int main(){
int N;
  cin>>N;
vector<int>A(N);
vector<int>d(N);  
int ans=0;  
  for(int i=0; i<N; i++){
    cin>>A[i];
    while(A[i]%2==0){
     A[i]/=2;
     d[i]++;}
    ans=*min_element(d.begin(), d.end());
   }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string S, T, U;
int A, B;

int main()
{
   cout << fixed << setprecision(10);
   cin >> S >> T >> A >> B >> U;
   if (S == U) {
      cout << A - 1 << " " << B << endl;
   } else {
      cout << A << " " << B - 1 << endl;
   }
   return 0;
}



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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;

template <typename T>
ostream& operator<<(ostream& s, const vector<T> &vec){
    for(int i=0;i<vec.size();i++){
        if(i) s << ',';
        else s << '{';
        s <<setw(2)<< vec[i];
    }
    s << '}' << endl;
    return s;
}
long long powm(long long a, long long b, long long mod=1000000007){
    if(b<0) b+=mod-1;
    if(b>0){
        if(b%2==1) return a*powm(a*a%mod,b/2)%mod;
        else return powm(a*a%mod,b/2)%mod;
    }else{
        return 1;
    }
}


ll mod = 1e9+7;
int main(){
    ll k,ans=0;;cin>>k;
    rept(i,1,k+1){
        ll h =k/i;
        ans+=(h+1)*h/2*i;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3584
A,B,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))

ans = min(a) + min(b)

for i in range(m):
    x,y,c = map(int,input().split())
    ans = min(ans,a[x-1]+b[y-1]-c)

print(ans)


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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vi64> g(n, vi64(n, 1e18));
  rep(i, n) {
    g[i][i] = 0;
  }
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = c;
  }
  rep(k, n) rep(i, n) rep(j, n) {
    amin(g[i][j], g[i][k] + g[k][j]);
  }
  vector<vi32> h(n, vi32(n, 1e9));
  rep(i, n) {
    h[i][i] = 0;
  }
  rep(i, n) rep(j, n) {
    if (g[i][j] <= l) {
      h[i][j] = 1;
    }
  }
  rep(k, n) rep(i, n) rep(j, n) {
    amin(h[i][j], h[i][k] + h[k][j]);
  }
  int q;
  cin >> q;
  rep(i, q) {
    int s, t;
    cin >> s >> t;
    s--, t--;
    int ans = h[s][t];
    if (ans == 1e9) ans = 0;
    cout << ans - 1 << endl;
  }
}

Measured memory_bytes: 1664
N = int(input())
s = [0]*N
l = [0]*N
for i in range(N):
    a, b = map(int, input().split())
    s[i] = (-a, -b)

for i in range(N):
    c, d = map(int, input().split())
    l[i] = (c, d)

l.sort()
s.sort()

ans = 0
dp = [True]*N
for e in l:
    c = e[0]
    d = e[1]

    ind = -1
    high = -1
    for i in range(N):
        if dp[i]:
            a = -s[i][0]
            b = -s[i][1]
            
            if a < c and b < d:
                hoge = b
                if hoge > high:
                    high = hoge
                    ind = i
    if ind != -1:
        dp[ind] = False
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cassert>
#include <deque>
#include <fstream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define POW(n) ((n)*(n))
#define ALL(a) (a).begin(),(a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr if(true) cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string& s) { istringstream is(s); T res; is >> res; return res; }
template <class T> string to_s(const T& a) { ostringstream os; os << a; return os.str(); }

vll list[4];
ll base;

void solve(long long N, long long W, vector<long long> w, vector<long long> v){
	ll ans = 0;

	REP(i,N){
		list[w[i]].push_back(v[i]);
	}

	REP(i,4){
		sort(ALL(list[i]));
		list[i].push_back(0);
		reverse(ALL(list[i]));

		FOR(j,1,list[i].size())list[i][j] += list[i][j-1];
	}


	REP(i,list[0].size())
	REP(j,list[1].size())
	REP(k,list[2].size())
	REP(l,list[3].size()){
		if(base*i + (base+1)*j + (base+2)*k+ (base+3)*l <= W){
			// printf("%d %d %d %d  %d\n",i,j,k,l,(int)(list[0][i] + list[1][j] + list[2][k]+ list[3][l]));
			ans = max(ans,list[0][i] + list[1][j] + list[2][k]+ list[3][l]);
		}
	}

	cout << ans << endl;
}



int main(){
	ios::sync_with_stdio(false);
	long long W;
	long long N;
	cin >> N;
	vector<long long> w(N-1+1);
	vector<long long> v(N-1+1);
	cin >> W;
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> w[i];
		cin >> v[i];
	}
	base = w[0];
	for(int i = 0 ; i <= N-1 ; i++){
		w[i] -= base;
	}
	solve(N, W, w, v);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int n, a;

	scanf("%d%d", &n, &a);

	if (n % 500 <= a) {
		printf("Yes");
	}
	else {
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstdlib>
using namespace std;
int n;
vector<int>G[100010];
int state[100010];
int ans;
void dfs(int x,int p)
{
	int all[22];
	for(int i=0;i<=20;i++)all[i]=0;
	state[x]=0;
	for(int i=0;i<G[x].size();i++)
	{
		int y=G[x][i];
		if(y==p)continue;
		dfs(y,x);
		state[x]|=state[y];
	    for(int j=0;j<=20;j++)
	    {
	    	if(state[y]>>j&1)
	    	{
	    		all[j]++;
	    	}
	    }
	}
	int res=0;
	for(int i=20;i>=0;i--)
	{
		if(all[i]>1)
		{
			res=i+1;
			break;
		}
	}
	for(int i=res;i<=20;i++)
	{
		if(state[x]>>i&1)continue;
		res=i;
		break;
	}
	state[x]|=(1<<res);
	for(int i=0;i<res;i++)if(state[x]>>i&1)state[x]^=(1<<i);
	ans=max(ans,res);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a); 
	}
	dfs(1,0);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 18688
#include <iostream>
using namespace std;
int main()
{int n,s,g;
cin>>n;
s=n/10;
g=n%10;
if(s==9||g==9)
{
cout<<"Yes"<<endl;
}
if(s!=9&&g!=9) 
{
cout<<"No"<<endl;

}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>

#define rep(i,n) (int i = 0; i < (n); i++)
#define FOR(i,a,b) (int i=(a); i < (b); i++)
#define INF 100000000000
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n,m,j;
    cin >> n >> m;
    vector<int> a{n};
    for (int i = 0; i < m; i++) {
        cin >> j;
        n -= j;
    }

    if (n < 0) {
        cout << -1 << endl;
    } else {
        cout << n << endl;
    }

    return 0;
}

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

namespace ConsoleApp2
{
	class Program
	{
		static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			var data = new int[N];
			var temp = Console.ReadLine().Split(' ');
			for (int i = 0; i <data.Length; i++)
			{
				data[i] = int.Parse(temp[i]);
			}
			var max = data.Max();
			var mix = data.Min();

			Console.WriteLine(max - mix);
		}
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const int MAX = 2000001;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if(n < k)
        return 0;
    if(n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    long long ans = 0;
    int K;
    // int MOD = 1000000007;
    string S;
    cin >> K >> S;
    int l = S.size();
    COMinit();
    for(int i = 0; i <= K; i++) {
        ans = (ans + ((COM(i + l - 1, i) * modpow(25, i, MOD)) % MOD) *
                         modpow(26, K - i, MOD)) %
              MOD;
        // cout << ans << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 51204