akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long N, M, A, B, P, Q;
	cin >> N >> M >> A >> B >> P >> Q;
	if (A == 1 && B == 1) {
		long long d = M / (P + Q);
		long long ret = (M > N * (P + Q) ? M - N * (P + Q) : N * (P + Q) - M);
		if (d <= N) ret = min(ret, M - d * (P + Q));
		if (d <= N - 1) ret = min(ret, (d + 1) * (P + Q) - M);
		cout << ret << endl;
	}
	else {
		double lim = log(2 * M) / max(log(A), log(B));
		int rep = int(lim + 0.01);
		long long mulA = 1, mulB = 1;
		vector<long long> v;
		for (int i = 0; i <= rep && i < N; ++i) {
			v.push_back(P * mulA + Q * mulB);
			mulA *= A;
			mulB *= B;
		}
		int S = v.size();
		int SL = S / 2, SR = S - S / 2;
		vector<long long> vl(1 << SL), vr(1 << SR);
		for (int i = 0; i < SL; ++i) {
			for (int j = 1 << i; j < 2 << i; ++j) {
				vl[j] = vl[j - (1 << i)] + v[i];
			}
			vector<long long> mem(2 << i);
			merge(vl.begin(), vl.begin() + (1 << i), vl.begin() + (1 << i), vl.begin() + (2 << i), mem.begin());
			copy(mem.begin(), mem.end(), vl.begin());
		}
		for (int i = 0; i < SR; ++i) {
			for (int j = 1 << i; j < 2 << i; ++j) {
				vr[j] = vr[j - (1 << i)] + v[i + SL];
			}
			vector<long long> mem(2 << i);
			merge(vr.begin(), vr.begin() + (1 << i), vr.begin() + (1 << i), vr.begin() + (2 << i), mem.begin());
			copy(mem.begin(), mem.end(), vr.begin());
		}
		int ptr = 1 << SR;
		long long ans = M;
		for (int i = 0; i < 1 << SL; ++i) {
			while (ptr != 0 && vl[i] + vr[ptr - 1] > M) --ptr;
			if (ptr != 0) ans = min(ans, M - vl[i] - vr[ptr - 1]);
			if (ptr != (1 << SR)) ans = min(ans, vl[i] + vr[ptr] - M);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 52124
def f(k):
    T = S*k
    N = len(T)
    cur = T[0]
    cnt = 1
    ans = 0
    for i in range(1,N):
        if T[i]==cur:
            cnt += 1
        else:
            ans += cnt//2
            cur = T[i]
            cnt = 1
    ans += cnt//2
    return ans
S = input().strip()
K = int(input())
ans1 = f(1)
ans2 = f(2)
ans3 = f(3)
d1 = f(2)-f(1)
d2 = f(3)-f(2)
k = (K-1)//2
if (K-1)%2==0:
    print(f(1)+(d1+d2)*k)
else:
    print(f(1)+(d1+d2)*k+d1)

Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define for0(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{

  float a,b,c,d,x,y;
  cin >> a >> b >> c >> d;

 while(1){
  c -= b;
    if(c<=0){
      cout<<"Yes";
      return 0;
    }
  a-= d;
    if(a<=0){
      cout<<"No";
      return 0;
    }

 }



  return 0 ;
}


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

int main()
{
  int M, N;
  map< string, pair< int, int > > mp;
  stack< int > s;
  bool v[100][256] = {{}};
  
  cin >> M;
  for(int i = 0; i < M; i++) {
    string name;
    int lb, rb;
    cin >> name >> lb >> rb;
    mp[name] = {lb, rb};
  }
  
  cin >> N;

  for(int i = 0; i < N; i++) {
    string e;
    cin >> e;
    
    if(string("+-*/").find(e[0]) == string::npos) {
      if(mp.find(e) == mp.end()) {
        v[i][stoi(e)] = true;
      } else {
        auto p = mp[e];
        for(int j = p.first; j <= p.second; j++) v[i][j] = true;
      }
    } else {
      int b = s.top(); s.pop();
      int a = s.top(); s.pop();
      if(e[0] == '+') {
        for(int j = 0; j < 256; j++)
          for(int k = 0; k < 256; k++)
            v[i][(j + k) % 256] |= v[a][j] & v[b][k];
      } else if(e[0] == '-') {
        for(int j = 0; j < 256; j++)
          for(int k = 0; k < 256; k++)
            v[i][(j - k + 256) % 256] |= v[a][j] & v[b][k];
      } else if(e[0] == '*') {
        for(int j = 0; j < 256; j++)
          for(int k = 0; k < 256; k++)
            v[i][(j * k) % 256] |= v[a][j] & v[b][k];
      } else {
        if(v[b][0]) {
          cout << "error" << endl;
          exit(0);
        } else {
          for(int j = 0; j < 256; j++)
            for(int k = 1; k < 256; k++)
              v[i][j / k] |= v[a][j] & v[b][k]; 
        }
      }
    }
    s.push(i);
  }
  
  cout << "correct" << endl;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    ll n;
    cin >> n;
    ll sum = 0;
    sum = n * (n - 1) / 2;
    cout << sum << endl;
}

Measured memory_bytes: 256
N, M, Q = [int(s) for s in input().split()]
dat = [[int(s) for s in input().split()] for _ in range(Q)]
A = [0] * N
result = []


def Calc(count):
    global result
    global A
    cnt = 0
    if count == N:
        for d in dat:
            if A[d[1] - 1] - A[d[0] - 1] == d[2]:
                cnt += d[3]
        return cnt
    else:
        max_val = 0
        if count == 0:
            start = 1
        else:
            start = A[count-1]

        for i in range(start, M + 1):
            A[count] = i
            max_val = max(max_val, Calc(count + 1))
        return max_val


print(Calc(0))


Measured memory_bytes: 9244
#include <bits/stdc++.h>
#define S second
#define F first
#define ll long long

using namespace std;

const ll N = 2e5 + 5;

int main()
{
    // freopen("output.txt", "w", stdout);
    ll n, a, b;
    scanf("%lld%lld%lld", &n, &a, &b);
    if(a > b) swap(a, b);
    if((a - b)&1) printf("%lld\n", min(a-1, n - b) + (b - a + 1)/2);
    else printf("%lld\n", (b - a + 1)/2);
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d", &a, &b);
    if(a==b)
    {
        printf("Draw");
    }
    else if(a==1)
    {
        printf("Alice");
    }
    else if(b==1)
    {
        printf("Bob");
    }
    else if(a>b)
    {
        printf("Alice");
    }
    else{
        printf("Bob");
    }
    return 0;
}

Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define size1 10
int main(){
	int n;
	cin>>n;
	vector<int> p(n),q(n);
	vector<int> sorted;
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	for(int i=0;i<n;i++)
		cin>>q[i];
	sorted=p;
	int a=0,b=0;
	do{
		a++;
	}while(next_permutation(p.begin(),p.end()));
	do{
		b++;
	}while(next_permutation(q.begin(),q.end()));
	cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 3588
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
using namespace std;
int main()
{
    ll a,b;
    cin>>a>>b;
    ll c=a*b;
    cout<<c<<endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int ans=a+b+c;
    int m = max(max(a,b),c);
    // cout << m << ans;
    ans-=m;
    rep(i,k){
        m*=2;
    }
    ans+=m;
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n, t;
  cin >> n >> t;
  ll res = 0;
  ll curr = 0;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    if(x >= curr){
      res += t;
      curr = x + t;
    }else{
      res += t - (curr - x);
      curr = x + t;
    }
  }
  cout << res << endl;
	return 0;
}


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

#define MAX 100000
int num[MAX];

void update(int i, int x){
  num[i] = x;
}

void find(int s, int t){
  int min = num[s];
  for(int i=s+1; i<=t; i++){
    if(num[i] < min){ min = num[i]; }
  } cout << min << endl;
}

int main(){
  int n, q;
  cin >> n >> q;
  int com[q], x[q], y[q];
  for(int i=0; i<n; i++){ num[i] = 2147483647; }

  for(int i=0; i<q; i++){ cin >> com[i] >> x[i] >> y[i]; }

  for(int i=0; i<q; i++){
    if(com[i]==0){ update(x[i], y[i]); }
    else if(com[i]==1){ find(x[i], y[i]); }
  }

  return 0;
}


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;

ll mfact(ll a) {
	ll res = 1;
	for (ll i = 2; i <= a; i++) {
		res *= i;
		res %= mod;
	}
	return res;
}

int main(void) {
	ll N, M; cin >> N >> M;
	if (abs(N - M) >= 2) {
		cout << 0 << endl;
		return 0;
	}

	if (M > N)swap(N, M);
	ll fm = mfact(M);

	if (N == M) {
		cout << (2 * (fm * fm) % mod) % mod << endl;
	}
	else {
		ll fn = fm;
		for (ll i = M + 1; i <= N; i++)fn = (fn * i) % mod;
		cout << (fm * fn) % mod << endl;
	}

	return 0;
}

Measured memory_bytes: 3592
#include<cstdio>
#include<cstring>

#define M 1000001
#define L 14

char H[M][L];

int getChar(char ch) {
  if (ch == 'A') return 1;
  else if (ch == 'C') return 2;
  else if (ch == 'G') return 3;
  else if (ch == 'T') return 4;
  else return 0;
}

long long getKey(char str[]) {
  long long sum = 0, p = 1, i;
  for (i = 0; i < strlen(str); i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int h(int key, int i) {
  return (h1(key) + i * h2(key)) % M;
}

bool insert(char str[]) {
  long long key, i, hash;
  key = getKey(str);

  for (i = 0;; i++) {
    hash = h(key, i);
    if (strcmp(H[hash], str) == 0) return 1;
    else if (strlen(H[hash]) == 0) {
      strcpy(H[hash], str);
      return 0;
    }
  }
}

bool find(char str[]) {
  long long key, i, hash;

  key = getKey(str);

  for (i = 0;; i++) {
    hash = h(key, i);
    if (strcmp(H[hash], str) == 0) return 1;
    else if (strlen(H[hash]) == 0) return 0;
  }
}

int main() {
  for (int i = 0; i < M; i++) H[i][0] = '\0';

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

  char command[6], str[L];
  for (int i = 0; i < n; i++) {
    scanf("%s %s", command, str);
    if (strcmp(command, "insert") == 0 ) insert(str);
    else if (strcmp(command, "find") == 0) {
      if (find(str)) printf("yes");
      else printf("no");
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 16492
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
//#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -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;
}
// ----------------------------------------------------------------------------

int main(){
  ll N;
  cin >> N;
  int ans=mod;
  for(ll i=1; i*i<=N; i++){
    if(N%i == 0){
      ll x,y;
      x = i;
      y = N/i;
      int x_cnt=0,y_cnt=0;
      while(x){
        x_cnt++;
        x /= 10;
      }
      while(y){
        y_cnt++;
        y /= 10;
      }
      chmin(ans,max(x_cnt,y_cnt));
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

const ll INF = 1LL << 58;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  ll L;
  cin >> N >> M >> L;
  vector<vector<ll>> A(N, vector<ll>(N, INF));
  for (int i = 0; i < M; i++) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    A[a][b] = A[b][a] = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        A[i][j] = min(A[i][j], A[i][k] + A[k][j]);
      }
    }
  }
  vector<vector<ll>> B(N, vector<ll>(N, INF));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (A[i][j] <= L) B[i][j] = 1;
    }
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        B[i][j] = min(B[i][j], B[i][k] + B[k][j]);
      }
    }
  }
  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    ll s, t;
    cin >> s >> t;
    s--, t--;
    cout << (B[s][t] != INF ? B[s][t] - 1 : -1) << '\n';
  }
  return 0;
}


Measured memory_bytes: 2048
let arr = readLine()!.characters.split{$0 == " "}.map{ Int(String($0))! }
let a = arr[0]
let b = arr[1]
var sum = a
var ret = 1



while sum < b {
  sum += a - 1
  ret += 1
}

if b == 1 {
  ret = 0
}

print(ret)

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod= 1e9+7;
const ll INF = 1LL<<40;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ld x[20];
string y[20];
main(){
  ll n,k,d,ks=0,kkind=0;
  cin>>n;
  ld ans=0;
  rep(i,0,n)cin>>x[i]>>y[i];
  rep(i,0,n){
    if(y[i]=="JPY")ans+=x[i];
    else ans+=x[i]*380000.0;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

map<int64, int64> decomposition(int64 N) {
  map<int64, int64> result;
  int64 tmp = N;
  int64 amari;
  for (int64 i = 2; i * i <= N; i++) {
    if (tmp == 1) {
      break;
    }
    amari = tmp % i;
    if (amari == 0) {
      result[i] = 0;
      while (amari == 0) {
        tmp /= i;
        result[i]++;
        amari = tmp % i;
      }
    }
  }
  if (tmp != 1) result[tmp] = 1;
  return result;
}

int main() {
  int64 A, B;
  cin >> A >> B;
  int64 gcd = __gcd(A, B);
  map<int64, int64> mp = decomposition(gcd);
  cout << mp.size() + 1 << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>

using namespace std;

class dice{
private:
	int me[6];
public:
	int set();
	int right(int f,int t);
	int show(int k);
};

int dice::set(){
	int i;

	for (i = 0; i < 6; i++)
		cin >> me[i];

	return 0;
}

int dice::right(int f, int t){
	int i,j;
	for (i = 0; i < 6; i++){
		if (me[i] == f)
			break;
	}

	for (j = 0; j < 6; j++){
		if (me[j] == t)
			break;
	}

	switch (i){
	case 0:
		switch (j){
	case 1:return 3;
	case 3:return 4;
	case 4:return 2;
	case 2:return 1;
	}
	case 1:
		switch (j){
		case 0:return 2;
		case 2:return 5;
		case 5:return 3;
		case 3:return 0;
	}
	case 2:
		switch (j){
		case 5:return 1;
		case 1:return 0;
		case 0:return 4;
		case 4:return 5;		
		}
	case 3:
		switch (j){
		case 5:return 4;
		case 4:return 0;
		case 0:return 1;
		case 1:return 5;
		}
	case 4:switch (j){
	case 5:return 2;
	case 2:return 0;
	case 0:return 3;
	case 3:return 5;
	}
	case 5:switch (j){
	case 3:return 1;
	case 1:return 2;
	case 2:return 4;
	case 4:return 3;
	}
	}
	return 0;
}

int dice::show(int k){

	cout << me[k] << endl;
	return 0;
}

int main(){
	int n;
	int i;
	int f, t;
	dice d;
	
	d.set();

	cin >> n;

	for (i = 0; i < n; i++){
		cin >> t >> f;
		d.show(d.right(f, t));
	}


}

Measured memory_bytes: 1160
def solve():
    ans = "Yes"
    for i in range(1,N-1):
        if H[i] > H[i+1]:
            H[i] -= 1
            if H[i] > H[i+1]:
                ans = "No"
                break
            if H[i-1] > H[i]:
                ans = "No"
                break
        elif H[i-1] <= H[i]-1:
            H[i] -= 1
    print(ans)

if __name__ == "__main__":
    N = int(input())
    H = list(map(int, input().split()))  
    solve()


Measured memory_bytes: 20584
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var V = Read().Split();
            char a = V[0][0];
            char b = V[1][0];
            var A = new string(a, int.Parse(V[1]));
            var B = new string(b, int.Parse(V[0]));
            Console.WriteLine(A.CompareTo(B) < 0 ? A : B);
        }
    }
}


Measured memory_bytes: 13280
#include <stdio.h>

int main(void){
    // Your code here!
    int N,T[1000],A[1000];
    long long takahashi=0,aoki=0,tmp_t=0,tmp_a=0;
    
    scanf("%d",&N);
    
    for(int i=0;i<N;i++){
        scanf("%d%d",&T[i],&A[i]);
    }
    
    for(int i=0;i<N;i++){
        tmp_t = T[i];
        tmp_a = A[i];
        if(tmp_t < takahashi || tmp_a < aoki){
            long long max = 0;
            long long Tmax = (takahashi+tmp_t-1)/tmp_t;
            long long Amax = (aoki+tmp_a-1)/tmp_a;
            if(Tmax > Amax){
                max = Tmax;
            }
            else{
                max = Amax;
            }
            
            tmp_t *= max;
            tmp_a *= max;
        }
        
        takahashi = tmp_t;
        aoki = tmp_a;
        //printf("takahashi_%lld,aoki_%lld\n",takahashi,aoki);
    }
    
    printf("%lld\n",takahashi+aoki);
}


Measured memory_bytes: 128
import itertools
import math
K = [i for i in range(1, int(input()) + 1)]
numbers = itertools.combinations_with_replacement(K, 3)

sum_gcd = 0
for i in numbers:
    a = math.gcd(i[0], i[1])
    b = math.gcd(a, i[2])

    if i[0] != i[1] != i[2]:
        sum_gcd += b * 6
    elif i[0] == i[1] == i[2]:
        sum_gcd += b
    else:
        sum_gcd += b * 3

print(sum_gcd)

Measured memory_bytes: 9164
#include<iostream>
using namespace std;
int main(){
    int r, c;
    cin >> r >> c;
    int a[r+1][c+1];
    for(int i = 0; i < r+1; i++){
        a[i][c] = 0;
    }
    for(int i = 0; i < c+1; i++){
        a[r][i] = 0;
    }
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> a[i][j];
            a[i][c] += a[i][j];
            a[r][j] += a[i][j];
            a[r][c] += a[i][j];
        }
    }
    for(int i = 0; i <= r; i++){
        for(int j = 0; j < c; j++){
            cout << a[i][j] << " ";
        }
        cout << a[i][c] << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3140
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<cstring>
#include<queue>
#include<iostream>
#include<map>
using namespace std;
typedef long long ll;
typedef double lf;
typedef unsigned un;
typedef int in;
#define mian main
#define maxn 10000+10
#define maxm 10000+10
#define _(a) read(a)
#define non void
#define inf 2147483647
#define bre break
#define con continue
#define prq priority_queue
#define re register
#define bu bool
#define cz char
#define cst const
#define ope operator
#define inl inline
#define upp upper_bound
#define low lower_bound
#define next_per next_permutation
inl cz gc(){static cz buf[100000],*L=buf,*R=buf;return L==R&&(R=(L=buf)+fread(buf,1,100000,stdin),L==R)?EOF:*L++;}
template<typename T>inl T Max(T a,T b){return a>b?a:b;}
template<typename T>inl T Min(T a,T b){return a<b?a:b;}
template<typename T>inl T Abs(T a){return a<0?-a:a;}
template<typename T>inl non read(T &a){a=0;T k=1;char c=gc();while(c<'0'||c>'9')k=c=='-'?-1:k,c=gc();while(c>='0'&&c<='9')a=a*10+(c^48),c=gc();if(c!='.'){a*=k;return;}T t=0.1;while(c<'0'||c>'9')c=gc();while(c>='0'&&c<='9')a+=t*(c^48),c=gc(),t*=0.1;a*=k;}
template<typename T>non write(T a,cz t=' '){if(a==0){putc(48,stdout),putc(t,stdout);return;}if(a<0){a=-a;putc('-',stdout);}cz c[30];in le=0;while(a){c[++le]=a%10+48;a/=10;}for(re in i=le;i>=1;--i)putc(c[i],stdout);putc(t,stdout);}
cz a,b;
in main()
{
	cin>>a>>b;
	if(a!=b)cout<<"D"<<endl;
	else cout<<"H"<<endl;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
}


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

int main() {
  int N; cin >> N;
  int t=0, x=0, y=0;
  rep(i,N){
    int ta, xa, ya; cin >> ta >> xa >> ya;
    if( (ta-t)%2 == (abs(xa-x)+abs(ya-y))%2 && abs(xa-x)+abs(ya-y) <= ta-t ){
      x = xa;
      y = ya;
      t = ta;
    }else{
      cout << "No" << endl;
      return 0;
    }
  }
   
   cout << "Yes" << endl;
   return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int n, m; std::cin >> n >> m;
    std::vector<std::vector<int>> edg(n);
    for (int i = 0; i < m; i++) {
        int u, v; std::cin >> u >> v;
        u--; v--;
        edg[u].push_back(v);
    }
    int s, t; std::cin >> s >> t;
    s--; t--;
    std::vector<std::vector<int>> dist(n, std::vector<int>(3, 1e9));
    std::priority_queue<std::pair<int, std::pair<int, int>>> que;
    que.push({ 0, {s, 0} });
    dist[s][0] = 0;
    while (!que.empty()) {
        int d = -que.top().first;
        int pos = que.top().second.first;
        int st = que.top().second.second;
        que.pop();

        int nxtst = (st + 1) % 3;
        int nxtd = d + (st == 2);
        for (int e : edg[pos]) {
            if (dist[e][nxtst] <= nxtd) continue;
            dist[e][nxtst] = nxtd;
            que.push({ -nxtd, { e, nxtst } });
        }
    }
    std::cout << (dist[t][0] != 1e9 ? dist[t][0] : -1) << std::endl;
    return 0;
}

Measured memory_bytes: 11136
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int A = in.Int();
            int B = in.Int();
            out.println((A - 1) * (B - 1));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 21204
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		ArrayList<Long>hp=new ArrayList<>();

		//モンスターの数
		long N=sc.nextLong();
		//使える必殺技の回数
		long K=sc.nextLong();
		//フェネックの総攻撃回数
		long attackResult=0;
		int count=0;

		//個々のモンスターの体力
		for(int i=0;i<N;i++) {
			hp.add(sc.nextLong());
		}

		Collections.sort(hp);
		
		if(N>K) {
			
			for(long i=0;i<(N-K);i++) {
				attackResult=attackResult+hp.get(count);
				count++;
			}

			System.out.println(attackResult);

		}else {
			System.out.println(0);
		}
	}
}

Measured memory_bytes: 93196
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
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()
{
    //int N, K, S;
    int X, Y,Z;
    //int A[200000];
    lli N, A, B;

    lli count = 0;
    lli temp, temp2;
    lli max = -LLINF,min = LLINF;
    lli sum = 0;
    lli num = 0;
    bool flag = false;

    
    scanf("%lld%lld%lld",&N,&A,&B);

    if ((B - A) % 2 == 0)
        printf("%lld", (B - A) / 2);
    else 
        printf("%lld", MIN(A - 1, N - B)+1+(B-A-1)/2);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define R register
using namespace std;
namespace chu_xuan{
    void swap(int &a,int &b){R int tmp=a;a=b,b=tmp;}
    void read(int &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
    int In() {int a=0,b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*b;}
    int max(int a,int b){return a>b?a:b;}
    int min(int a,int b){return a>b?b:a;}
}using namespace chu_xuan;

int n,a[15],maxx=-0x3f3f3f3f,sum;

int main()
{
    read(n);
    for(int i=1;i<=n;i++)
    {
        read(a[i]);
        sum+=a[i];
        if(maxx<a[i]) maxx=a[i];
    }
    cout<<(maxx<sum-maxx?"Yes":"No")<<'\n';
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	a := getInt()
	b := getInt()
	c := getInt()

	ans := "Yes"

	if c < a || c > b {
		ans = "No"
	}

	fmt.Println(ans)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


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

using namespace std;

#define FOR(i,a,b)		for(int i=(a),_b=(b);i<(_b);++i)
#define FORD(i,a,b)		for(int i=(a),_b=(b);i>(_b);--i)
#define pb			push_back
#define mp			make_pair
#define	all(c)			(c).begin(),(c).end()
#define	present(c,x)		((c).find(x) != (c).end())
#define	cpresent(c,x)		(find(all(c),x) != (c).end())
#define	endl			'\n'

typedef long long		ll;
typedef unsigned long long	ull;
typedef unsigned char	 	byte;
typedef vector<int>		vi;
typedef pair<int, int>		pii;
typedef pair<ll, ll>		pll;
typedef vector<pii>		vpii;

const int MX = 100005;

const int MOD = 1000000007;
int N;

vi g[MX];
ll dp[MX][2];
bool visited[MX];

ll solve(int u, int c)
{
	if (dp[u][c]) return dp[u][c];
	visited[u] = true;
	ll ret = 1;
	FOR(i,0,g[u].size()) {
		int v = g[u][i];
		if (visited[v]) continue;
		ll res = solve(v,0);
		if (c == 0) res += solve(v,1);
		res %= MOD;
		ret *= res;
		ret %= MOD;
	}
	visited[u] = false;
	return dp[u][c] = ret;
}

int main(int argc, char *argv[])
{
#ifdef	HTRINH_UNIT_TEST
	freopen(argv[1],"r",stdin);
	ifstream cin(argv[1]);
#endif
#if 0
	ofstream cout(argv[2]);
#endif
	ios :: sync_with_stdio(false);
	cin.tie(NULL);

	cin >> N;
	int u,v;
	FOR(i,0,N-1) {
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	ll ans = solve(1,0);
	ans += solve(1,1);
	cout << ans%MOD << endl;
	return 0;
}


Measured memory_bytes: 14336
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<set>
using namespace std;
int main(){
	char a[1000];
	scanf("%[^\n]s",a);
	for(int i = 0;i < strlen(a);i++)
	{
		if(i==0)printf("%c",a[i]);
		else if(a[i-1]==' ')printf("%c",a[i]);
		}
	return 0;
	}

Measured memory_bytes: 256
def f(x, y, z):
    return x**2+y**2+z**2+x*y+y*z+z*x
n = int(input())
ans = {}
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = f(x, y, z)
            if tmp > n:
                break
            else:
                if tmp not in ans:
                    ans[tmp] = 1
                else:
                    ans[tmp] += 1

for i in range(1, n+1):
    if i in ans:
        print(ans[i])
    else:
        print(0)

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

void Vacation(vector<vector<int>> &profit)
{
	int n = profit.size();

	vector<vector<int>> dp(n, vector<int>(3, 0));

	/* dp[i][act] represents the total profit that you can get till i-th day 
	 * when you choose the act activity on the i-th day
	 */
	
	for(int act = 0; act <3; act++)
		dp[0][act] = profit[0][act];

	for(int i = 1; i < n; i++)
	{
		for(int prev_act = 0; prev_act < 3; prev_act++)
		{
			for(int curr_act = 0; curr_act < 3; curr_act++)
			{
				if(prev_act == curr_act)
					continue;

				dp[i][curr_act] = max(dp[i][curr_act], dp[i-1][prev_act] + profit[i][curr_act]);
			}
		}
	}

	int res = 0;
	for(int last_act = 0; last_act < 3; last_act++)
		res = max(res, dp.back()[last_act]);

	cout << res << endl;
}

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

	vector<vector<int>> profit(n, vector<int>(3, 0));

	for(auto &row_vec : profit)
		for(auto &ele : row_vec)
			cin >> ele;

	Vacation(profit);
	return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<math.h>
int main()
{
  long int N,com=1;
  char ans[100];
  int i,j,d;
 
  scanf("%ld",&N);
  for(i=0;i<100&&com<=N;++i){
    com+=pow(26,i+1);

  }
com-=pow(26,i);
N=N-com;
  for(j=0;j<i;j++){
d=i-1-j;
    com=N/pow(26,d);
	N=N%(long int)pow(26,d);
    
   ans[j]=com+97; 
  }
  ans[i]='\0';
  printf("%s",ans);
    return 0;
}

Measured memory_bytes: 2520
N = int(input())
t_list = list(map(int, input().split()))
v_list = list(map(int, input().split()))
t_sum = sum(t_list)
v_max = [0.0] * (2 * t_sum + 1)

t_i = 0
v_i = 0
t = t_list[t_i]
v = v_list[v_i]
time = 0
for i in range(1, 2 * t_sum + 1):
    time += 0.5
    if time >= t:
        time = 0
        t_i += 1
        v_i += 1
        if t_i >= N:
            break
        t = t_list[t_i]
        v_max[i] = min(min(v, v_list[v_i]), v_max[i - 1] + 0.5)
        v = v_list[v_i]
        continue
    v_max[i] = min(v, v_max[i - 1] + 0.5)

t_i = N - 1
v_i = N - 1
t = t_list[t_i]
v = v_list[v_i]
v_max[-1] = 0
time = 0
for i in range(2 * t_sum - 1, -1, -1):
    time += 0.5
    if time >= t:
        t_i -= 1
        v_i -= 1
        if t_i < 0:
            break
        t = t_list[t_i]
        v = v_list[v_i]
        time = 0
    if v_max[i] > v_max[i + 1] + 0.5:
        v_max[i] = v_max[i + 1] + 0.5

ans = 0
for i in range(len(v_max)-1):
    ans += (v_max[i] + v_max[i+1]) * 0.25
print(ans)


Measured memory_bytes: 3444
n=int(input())
t=list(map(int,input().split()))
m=int(input())
a=[[int(i) for i in input().split()] for l in range(m)]
for y in a:
    w=[]
    for x in range(len(t)):
        if y[0]-1==x:w.append(y[1])
        else:w.append(t[x])
    print(sum(w))

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

using ll = long long int;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

	int n; cin >> n;
	vector<int> v(n);
	for (auto &i : v)
		cin >> i;
	v.push_back(-1);
	ll money = 1000, stocks = 0;
	for (int i = 0; i < n; ++i) {
		if (v[i] > v[i+1]) { // Sell everything
			money += stocks*v[i];
			stocks = 0;
		}
		else { // Buy as much as possible
			stocks += money/v[i];
			money %= v[i];
		}
	}
	cout << money << '\n';
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


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

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

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













 
int main(){
    ll t1, t2, a1, a2, b1, b2;
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
    ll p = (a1 - b1) * t1, q = (a2 - b2) * t2;
    if(p > 0){
        p *= -1;
        q *= -1;
    }
    if(p + q < 0){
        cout << 0 << endl;
        return 0;
    }
    if(p + q == 0){
        cout << "infinity" << endl;
        return 0;
    }
    ll s = -p / (p + q);
    ll t = -p % (p + q);
    cout << s * 2 + (t != 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const int M=2e2+20;
ll v[N];
ll C[M][M]; 
void init()
{
	memset(C,0,sizeof(C));
	C[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}
int main()
{
	int n,A,B;
	init();
	while(cin>>n>>A>>B)
	{
		double ave=0;
		for(int i=0;i<n;i++)
			cin>>v[i];
		sort(v,v+n);
		reverse(v,v+n);
		for(int i=0;i<A;i++) 
			ave+=v[i];
		ave/=A;
		int num=0,k=0;
		for(int i=0;i<n;i++)
		{
			if(v[i]==v[A-1])
			{
				num++;
				if(i<A)
					k++;
			}
		}	
		ll ans=0; 
		if(k==A)
		{
			for(int i=A;i<=B;i++)
				ans+=C[num][i];
		}
		else
			ans+=C[num][k];
 
 		cout.precision(20);
 		cout<<fixed<<ave<<endl;
 		cout<<ans<<endl;
	}
	return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

/*-------------------------------------------*/

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

    int n;
    cin >> n;
    bitset<50000> b(1);
    rep(i, n) {
        int s;
        cin >> s;
        b |= b << s;
    }
    FORR(i, 100 * n + 1) {
        if(i % 10 && b[i]) {
            cout << i << endl;
            return 0;
        }
    }
    cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 384
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes\n"
#define no cout<<"No\n"
 
 
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a,b;
	cin>>a>>b;
	cout<<(a+2*b)/(2*b+1)<<endl;
	
}












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


int main() {
  
  long long N;
  cin >> N;
  vector<long long> num(N+10,2);
  num[1] = 1;
  
  for(int i = 2;i <= N;i++) {
    //if(num[i] > 2) continue;
    for(int j = i*2;j <= N;j += i) {
      num[j]++;
    }
  }

  long long ans = 0;
  for(int i = 1;i <= N;i++) {
    ans += num[i]*i;
    //cout << i << " " << num[i] << " ";
  }

  cout << ans << endl;

}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const ll NN = 1e10 + 7;
const int N = 1e5 + 7;
const int M = 11;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;
const int B = sqrt(N);

ll n,k;
ll d[N];

ll bnp( ll x , ll y )
{
    if( y == 0 )return 1;
    if( (y & 1) ){
        return x * bnp( x , y - 1 ) % mod;
    }else{
        ll b = bnp( x , y / 2 );
        return b * b % mod;
    }
}

void solve1()
{
    cin >> n >> k;
    ll ans = 0;
    for( int i = k; i >= 1; i-- ){
        ll xx = k / i;
        d[i] = bnp( xx , n );
        for( int j = i + i; j <= k; j += i ){
            d[i] = ( d[i] - d[j] + mod ) % mod;
        }
        ans = ( ans + d[i] * i % mod ) % mod;
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

int t_ans;
int main()
{
	int N, ans, n;
	cin >> N;
for( n = 105; n <= N; n+=2 ) {
	ans = 1;
	for(int i = 1, imax = n/2; i < imax; i++ )
	{
		if( (n % i)==0 ) {
			ans++;
		}
	}
	if( ans == 8 ) {
		t_ans ++;
	}
}
cout << t_ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	cin >> n;
	while (n--) {
		int ans = 196470;
		int y, m, d;
		cin >> y >> m >> d;
		y--;
		m--;
		d--;
		ans -= (y / 3)*(20 * 20 + 19 * 10);
		ans -= (y % 3)*(20 * 5 + 19 * 5);
		if(y%3!=2)
		ans -= (m /2)*(20 + 19);
		else
			ans -= (m / 2)*(20 + 20);
		ans -= (m % 2)*(20);
		ans -= d;
		cout << ans << endl;
	}
}

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

using namespace std;

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

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

    int max_times = 0;
    int max = N;
    rep(i, N){
        int tmp = i+1;
        int counter = 0;
        while(tmp % 2 == 0){
            tmp /= 2;
            counter++;
        }
        if(max_times < counter){
            max_times = counter;
            max = i+1;
        }
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
#define vii vector<int>
#define vll vector<long long>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
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 (b<a) { a = b; return 1; } return 0; }
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, m;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    cin >> n >> m;
    n = (n - 2 >= 0 ? n - 2 : n);
    m = (m - 2 >= 0 ? m - 2 : m);
    cout << n * m << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
# coding: utf-8
import sys
sys.setrecursionlimit(10000000)

#const
dxdy=((1,0),(0,1))
# my functions here!
def pin(type=int):
    return map(type,input().rstrip().split())
    

def resolve():
    N,K=pin()
    ans=0
    k=K//1000
    for z in range(k//10,-2,-1):
        if z==-1:
            print(-1,-1,-1)
            return
        for y in range(N-z,-1,-1):
            x=N-(y+z)
            if z*10+y*5+x==k:
                print(z,y,x)
                return
"""         
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """9 45000"""
        output = """4 0 5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """20 196000"""
        output = """-1 -1 -1"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000 1234000"""
        output = """14 27 959"""
        self.assertIO(input, output)

    def test_入力例_4(self):
        input = """2000 20000000"""
        output = """2000 0 0"""
        self.assertIO(input, output)

if __name__=="__main__":resolve()

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()
#define fst first
#define sec	second
#define pb push_back

typedef long long ll;
typedef vector<int> vi;
typedef pair<long,long> P;

const int mod = 1e9 + 7;


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

	string s,t;
	cin >> s >> t;
	int ans=0;
	rep(i,3){
		if(s[i] == t[i]){
			ans++;
		}
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx; int dy = ty - sy;
	rep(i, dx) {
		cout << "R";
	}
	rep(i, dy) {
		cout << "U";
	}
	rep(i, dx) {
		cout << "L";
	}
	rep(i, dy) {
		cout << "D";
	}
	cout << "D";
	rep(i, dx + 1) {
		cout << "R";
	}
	rep(i, dy + 1) {
		cout << "U";
	}
	cout << "L";
	cout << "U";
	rep(i, dx + 1) {
		cout << "L";
	}
	rep(i, dy + 1) {
		cout << "D";
	}
	cout << "R";
	cout << endl;
    return 0;
}

Measured memory_bytes: 256