akhauriyash/Code-Regression huggingface dataset:
import copy
n,m = map(int, input().split())


paths = [[] for _ in range(n)]
for i in range(m):
  a,b = map(int, input().split())
  paths[a-1].append(b-1)
  paths[b-1].append(a-1)
  
ans = 0

checked = [False for _ in range(n)]


def solve(i, c):
  c[i] = True

  global ans
  if c.count(False) == 0:
    ans += 1
    return
  else:
    for j in paths[i]:
      if c[j] == False: 
        solve(j, copy.deepcopy(c))
        
      

        
solve(0, copy.deepcopy(checked))
print(ans)
    
#print(paths[0])

Measured memory_bytes: 3444
#include <stdio.h>

int main() {
    int n, cont = 0;
    scanf("%d", &n);
    char str[n];
    scanf("%s", str);
    
    for (int i = 0; i < n-2; ++i){
        if (str[i] == 'A'){
            if (str[i+1] == 'B' && str[i+2] == 'C')
                cont += 1;
        }
    }
    
    printf("%d\n", cont);

    return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

ll n, k;
vi a, b;

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	cin >> n >> k;
	a.resize(n);
	b.resize(n);
	REP(i, n) cin >> a[i] >> b[i];
	ll ans = 0;
	set<int> bad;
	for (int i = 31; i >= 0; i--)
	{
		if ((k >> i) & 1)
		{
			ll sum = 0;
			REP(j, n)
			{
				if (bad.count(j)) continue;
				if ((a[j] >> i) & 1) continue;
				sum += b[j];
			}
			chmax(ans, sum);
		}
		else
		{
			REP(j, n)
			{
				if ((a[j] >> i) & 1) bad.insert(j);
			}
		}
	}
	ll sum = 0;
	REP(j, n)
	{
		if (bad.count(j)) continue;
		sum += b[j];
	}
	chmax(ans, sum);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5760
n = int(input())
travel_list = [[0,0,0]]
for i in range(n):
    travel_list.append([int(num) for num in input().split(" ")])
for i in range(1,n+1):
    t_step = travel_list[i][0]-travel_list[i-1][0]
    x_step = abs(travel_list[i][1]-travel_list[i-1][1])
    y_step = abs(travel_list[i][2]-travel_list[i-1][2])
    if x_step+y_step>t_step:
        print("No")
        exit()
    elif (t_step - (x_step + y_step))%2==1:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 21156
#include <iostream>
#include <vector>

using namespace std;

const int INFTY = 1000000;

int main()
{
    int N;
    cin >> N;
    vector<int> dp(N+1);

    int min;
    for(int i=1;i<N+1;i++){
        // 1の場合
        min = dp[i-1] + 1;
        for(int j=6;j<=i;j*=6){
            min = min > dp[i-j] + 1 ? dp[i-j] + 1 : min;
        }
        for(int j=9;j<=i;j*=9){
            min = min > dp[i-j] + 1 ? dp[i-j] + 1 : min;
        }
        dp[i] = min;
    }

    cout << min << endl;
}

Measured memory_bytes: 640
X, Y = map(int, raw_input().split())

#print X, Y

count=2

num = X
flag = False

if X % Y == 0:
    print -1
else:
    while num <= 1000000000000000000 :
        num = X * count
        if (num % Y) != 0:
            #        print num
            flag = True
            break
        else:
            count = count +1

    if flag == False:
        print -1
    else:
        print num


Measured memory_bytes: 2568
#include <stdio.h>
int main()
{
	int count;
	int max;
	int sum;
	int num;
	while(scanf("%d",&count)!=EOF)
	{
		sum=max=0;
		while(count--)
		{
			scanf("%d",&num);
			sum+=num;
			if(max<num){
				max=num;
			}
		}
		sum-=max/2;
		printf("%d\n",sum);
	}
 } 

Measured memory_bytes: 128
def append_list(num, yen):
    list = []
    while num>=0:
        list.append(num*yen)
        num-=1
    return list


y500 = int(input())
y100 = int(input())
y50 = int(input())
sum = int(input())
ans = 0

y500_list = append_list(y500, 500)
y100_list = append_list(y100, 100)
y50_list = append_list(y50, 50)

for i in y500_list:
    if i>sum:
        continue
    elif i==sum:
        ans+=1
        continue
    for j in y100_list:
        if i+j>sum:
            continue
        elif i+j==sum:
            ans+=1
            continue
        for k in y50_list:
            if i+j+k>sum:
                continue
            elif i+j+k==sum:
                ans+=1
                continue

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for((i)=1;(i)<=(n);(i)++)
using namespace std;
const double pi=acos(-1);
struct pnt{
	int x,y;
}a[105];
int n,cnt[205];
struct rg{
	double l,r;
};
bool cmp(rg x,rg y){
	return x.l<y.l;
}
double solve(int x){
	int i;
	vector<rg> v;
	rep(i,n) if(i!=x){
		rg t;
		t.l=atan2(a[i].x-a[x].x,a[x].y-a[i].y);
		t.r=t.l+pi;
		if(t.l<0) t.l+=2*pi;
		if(t.r<0) t.r+=2*pi;
		if(t.r>2*pi) t.r-=2*pi;
		v.push_back(t);
	}
	vector<double> all;
	for(i=0;i<v.size();i++){
		all.push_back(v[i].l);
		all.push_back(v[i].r);
	}
	sort(all.begin(),all.end());
	all.resize(unique(all.begin(),all.end())-all.begin());
	memset(cnt,0,sizeof(cnt));
	for(i=0;i<v.size();i++){
		int tl=upper_bound(all.begin(),all.end(),v[i].l)-all.begin();
		int tr=upper_bound(all.begin(),all.end(),v[i].r)-all.begin();
		cnt[tl]++;cnt[tr]--;
		if(tl>tr) cnt[0]++;
	}
	rep(i,all.size()) cnt[i]+=cnt[i-1];
	double ans=0;
	rep(i,all.size()) if(cnt[i]==v.size()){
		if(i!=all.size()) ans+=all[i]-all[i-1];
		else ans+=all[0]+2*pi-all[i-1];
	}
	return ans/(2*pi);
}
int main(){
	int i;
	scanf("%d",&n);
	rep(i,n){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	rep(i,n){
		printf("%.10f\n",solve(i));
	}
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;

typedef pair<int,int> pii;


int a[N][2];

vector<int> g[N][2];
int comp = 0;

bool vis[N];

void dfs(int cur, int ind){
	if(!vis[cur]){
		vis[cur] = 1;
		a[cur][ind] = comp;
		for(int c: g[cur][ind]){
			dfs(c, ind);
		}
	}
}

int main(){
	cin.tie(0);	
	cout.tie(0);	
	ios_base::sync_with_stdio(0);
	int n,k,l;
	cin >> n >> k >> l;
	while(k--){
		int x,y;
		cin >> x >> y;
		--x;--y;
		g[x][0].push_back(y);
		g[y][0].push_back(x);
	}
	while(l--){
		int x,y;
		cin >> x >> y;
		--x;--y;
		g[x][1].push_back(y);
		g[y][1].push_back(x);
	}
	for(int i = 0;i < n; ++i){
		if(!vis[i]){
			++comp;
			dfs(i,0);
		}
	}
	memset(vis,0,sizeof(vis));
	comp = 0;
	for(int i = 0;i < n; ++i){
		if(!vis[i]){
			++comp;
			dfs(i,1);
		}
	}
	map<pii, int> m;
	for(int i = 0;i < n; ++i){
		pii p = {a[i][0], a[i][1]};
		++m[p];
	}
	for(int i = 0; i < n; ++i){
		pii p = {a[i][0], a[i][1]};
		cout << m[p] << ' ';	
	}
	cout << '\n';
}


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

using namespace std;

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

  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  sort(A.rbegin(), A.rend());

  int alice = 0;
  int bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      alice += A[i];
    } else {
      bob += A[i];
    }
  }

  int answer = alice - bob;

  cout << answer << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h> 
typedef struct{
    int k,l,r;
}Node;
void insert(int, int);
void inParse(int);
void preParse(int);
Node T[500001];
int main(void)
{
    char s[8];
    int m;
    int num,count=0;
    int i;
   
    scanf("%d", &m);  
    for(i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ 
          scanf("%d", &num); 
          insert(count, num); 
          count++; 
        }
        if(s[0]=='p'){
          if(count>0) inParse(0);
            printf("\n");
            if(count>0) preParse(0);
            printf("\n");
        }
    }  
    return 0;  
}
   
void inParse(int p){
    if(T[p].l>=0) inParse( T[p].l);
    printf(" %d", T[p].k);
    if(T[p].r>=0) inParse( T[p].r);
}
   
void preParse(int p){
    printf(" %d", T[p].k);
    if(T[p].l>=0) preParse(T[p].l);
    if(T[p].r>=0) preParse(T[p].r);
}
   
void insert(int count, int z){
    int x=0, y;
    if(count<1) x=-1;
   
    T[count].k = z;
    T[count].l = -1;
    T[count].r = -1;
   
    while(x>=0){
        y = x; 
        if(z < T[x].k)x = T[x].l; 
        else x = T[x].r; 
    }
    if(count<1){}
    else if(z < T[y].k)T[y].l = count; 
    else T[y].r = count; 
}


Measured memory_bytes: 7588
#include <bits/stdc++.h>
using namespace std;
 
typedef long long LL;
typedef pair<int, int> pii;
 
#define fst first
#define snd second
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define REP(i, a, b)  for(int i = (a), i##end = (b); i < i##end; ++i)
#define DREP(i, a, b) for(int i=(a-1), i##end = (b); i >=i##end; --i)
 
template <typename T> bool chkmax(T& a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> bool chkmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
 
const int N = 200000;
const int P = (1 << 26);
const int oo = 0x3f3f3f3f;
 
template<typename T> T read() {
    T n(0), f(1);
    char ch = getchar();
    for(;!isdigit(ch); ch = getchar()) if(ch == '-') f = -1;
    for(; isdigit(ch); ch = getchar()) n = n * 10 + ch - 48; 
    return n * f;
}

char s[N + 5];
int Mn[P + 5];

int main() {
#ifdef Wearry
    freopen("data.txt", "r", stdin);
    freopen("ans.txt", "w", stdout);
#endif 

    int st = 0;
    scanf("%s", s);

    int tmp;
    memset(Mn, oo, sizeof Mn);

    Mn[0] = 0;
    REP(i, 0, strlen(s)) {
        st ^= 1 << (s[i] - 'a');

        tmp = Mn[st] + 1;
        REP(c, 0, 26) chkmin(tmp, Mn[st ^ (1 << c)] + 1);
        chkmin(Mn[st], tmp);
    }
    printf("%d\n", tmp);

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;
    bool f = true;
    rep(i, S.length()) {
        if ((i%2==0 && S[i] == 'L') || (i%2==1 && S[i] == 'R')) {
            f = false;
            break;
        }
    }
    Yes(f);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N, a[101];

    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }

    int ans = 1000000000;

    for (int x = -100; x <= 100; x++)
    {
        int cost = 0;

        for (int i = 0; i < N; i++)
        {
            cost += (a[i]-x) * (a[i]-x);
        }

        ans = min(ans, cost);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const int M = 1000000007;
ll n, A[3001], dp[3002][3002];
ll pref[3002], suf[3002];
ll play(int x, int y)
{
	if (x == y)
	{
		dp[x][y] = A[x];
		return 0;
	}
	if (dp[x][y]) return (pref[n]-pref[x-1]-suf[y+1]-dp[x][y]);
	dp[x][y]= max(A[x] + play(x + 1, y), A[y] + play(x, y - 1));
	return pref[n] - pref[x - 1] - suf[y + 1] - dp[x][y];
}
int main()
{
	cin >> n;
	loop(i, 1, n + 1)
	{
		cin >> A[i];
		pref[i] += A[i]+pref[i-1];
	}
	loop(i, 1, n + 1)
	{
		suf[n + 1 - i] += A[n + 1 - i]+suf[n - i+2];
	}
	cout<<pref[n]-(ll)2*play(1, n);
}



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

int main(){
  int N;
  cin >> N;
  int check = 1000;
  for(int i; i < N; i++){
    int A;
    int count = 0;
    cin >> A;
    while(A % 2 == 0){
      A /= 2;
      count += 1;
    }
    if(count < check){
      check = count;
    }
  }
  cout << check << endl;
}

Measured memory_bytes: 3588
h, w = gets.chomp.split.map(&:to_i)
k = gets.to_i
cum = Array.new(h + 1){[]}
cum[0] = Array.new(w + 1){[0, 0, 0]}
h.times{|i|
    line = gets.chomp
    temp = [[0, 0, 0]]
    w.times{|j|
        temp[j + 1] = temp[j].dup
        kind = (line[j] == 'J' ? 0 : (line[j] == 'O' ? 1 : 2))
        temp[j + 1][kind] += 1
    }
    temp.each_with_index{|ar, index|
        cum[i + 1][index] = cum[i][index].dup
        3.times{|j| cum[i + 1][index][j] += ar[j]}
    }
}
k.times{
    a, b, c, d = gets.chomp.split.map(&:to_i)
    temp = cum[c][d].dup
    3.times{|j| temp[j] -= cum[a - 1][d][j]}
    3.times{|j| temp[j] -= cum[c][b - 1][j]}
    3.times{|j| temp[j] += cum[a - 1][b - 1][j]}
    puts temp.join(" ")
}



Measured memory_bytes: 94228
#include<cstdio>

int main(void) {
	int s, amari;
	int flag1 = 0;
	int flag4 = 0;
	int count = 1;

	scanf("%d", &s);

	if (s == 2) {
		printf("4\n");
		return 0;
	}
	if (s == 1) {
		flag1++;
	}
	if (s == 4) {
		flag4++;
	}

	while (flag1 != 2 && flag4 != 2) {
		count++;
		amari = s % 2;
		if (amari == 0) {
			s = s / 2;
		}
		else {
			s = 3*s + 1;
		}

		if (s == 4) {
			flag4++;
		}
		if (s == 1) {
			flag1++;
		}
	}

	printf("%d", count);

	return 0;

}


Measured memory_bytes: 128
import numpy as np
N, D =map(int, input().split())

X_matrix=[]
for i in range(N):
  X = list(map(int, input().split()))
  X_matrix.append(X)
count=0  
for i in range(N-1):
  for j in range(i+1, N):
    dd=0
    for k in range(D):
      dd+=(X_matrix[i][k] - X_matrix[j][k])**2
    d=np.sqrt(dd)
    if d.is_integer():
      count+=1
print(count)

Measured memory_bytes: 13224
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

int main()
{
	double num, ans;
	while(cin >> num)
	{
		ans = num;
		num *= 2;
		ans += num;

		for(int i = 0; i < 4; i++)
		{
			num /= 3;
			ans += num;
			num *= 2;
			ans += num;
		}

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

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 8002

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<int, int> pii;

#define maxn 200005

int a[maxn] ;

pii tr[4*maxn] ;

pii Merge( pair<int,int> lres , pair<int,int> rres)
{
    pii res = lres ;
    if( a[rres.xx] < a[res.xx] ) res.xx = rres.xx ;
    if( a[rres.yy] < a[res.yy] ) res.yy = rres.yy ;
    return res ;
}


void build(int cn ,int b, int e)
{
    if( b==e )
    {
        if(b%2==0) tr[cn] = mp(0,b) ;
        else tr[cn] = mp(b,0) ;
        return ;
    }
    int lc = cn*2 , rc = cn*2 +1 , m = (b+e)/2 ;
    build(lc,b,m) ; build(rc,m+1,e) ;
    tr[cn] = Merge(tr[lc] , tr[rc]) ;
}

pii query(int cn ,int b, int e, int l, int r)
{
    if( e<l || b>r ) return mp(0,0) ;
    if( l<=b && e<=r ) return tr[cn] ;
    int lc = cn*2 , rc = cn*2 +1 , m = (b+e)/2 ;
    pii r1 = query(lc,b,m,l,r) , r2 = query(rc,m+1,e,l,r) ;
    return Merge(r1,r2) ;
}

map<pii, multiset<pii> > Map ;

int n ;
pair<int,int> call(int l, int r, pii p )
{
    if(l>r) return mp(0,0);

 //   printf(" --- %d %d\n",l,r) ;

    pii r1 = query(1,1,n,l,r) ;

    int idx1 ;
    if( l%2==0 ) idx1 = r1.yy ;
    else idx1 = r1.xx ;

    pii r2 = query(1,1,n,idx1+1,r) ;
    int idx2 ;
    if( l%2 == 0 ) idx2 = r2.xx ;
    else idx2 = r2.yy ;

    Map[p].insert( mp(a[idx1],a[idx2]) ) ;

//    printf("%d %d\n",idx1,idx2) ;

    call(l,idx1-1,mp(a[idx1],a[idx2])) ; call(idx1+1,idx2-1,mp(a[idx1],a[idx2])) ; call(idx2+1,r,mp(a[idx1],a[idx2])) ;

    return mp(a[idx1],a[idx2]) ;
}

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

    for(int i=1 ; i<=n ; i++) scanf("%d",&a[i]) ;
    a[0] = 2*maxn ;

    build(1,1,n) ;

 //   DBG ;

    pii r = call(1,n,mp(0,0)) ;

    set<pii> st ;
    st.insert(r) ;

    vector <int> ans ;

    while( st.size() > 0 )
    {
        r = (*st.begin()) ;
        st.erase( st.begin() ) ;

        ans.pb(r.xx) ; ans.pb(r.yy) ;

        for( auto p:Map[r] ) st.insert(p) ;
    }

    for( auto p:ans ) printf("%d ",p) ;
    printf("\n") ;
    return 0 ;
}


Measured memory_bytes: 35828
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <cstdlib>
#include <climits>
#include <ctype.h>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int INF=0x3f3f3f3f;
const LL mod=1e9+7;
const int MAXN=1e6+5;
const int MAXM=1e6+5;
struct A
{
    LL num;
    int t;
    bool operator <(A b)const
    {
        return num<b.num;
    }
}a[100005];
map<LL,int> mp;
int n;
int main()
{

    scanf("%d",&n);
    mp.clear();
    LL s;
    int id=0;
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&s);
        if(mp.count(s))
        {
            (a[mp[s]].t)++;
        }
        else
        {
            mp[s]=id;
            a[id].num=s;
            a[id].t=1;
            id++;
        }
    }
    sort(a,a+id);
    int f=0;
    LL temp;
    LL ans=0;
    for(int i=id-1;i>=0;i--)
    {
        if(f==0&&a[i].t>=4)
        {
            ans=(a[i].num)*(a[i].num);
            break;
        }
        else if(f==1&&a[i].t>=2)
        {
            ans=temp*(a[i].num);
            break;
        }
        else if(f==0&&a[i].t>=2)
        {
            temp=(a[i].num);
            f=1;
        }
    }
    printf("%lld\n",ans);




    return 0;
}


Measured memory_bytes: 8064
#include<stdio.h>
int main(void)
{
	int H,A,i;
	
	scanf("%d",&H);
	scanf("%d",&A);

	for(i=0;;i++){
		H-=A;
		if(H<=0){
			printf("%d\n",i+1);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll h,w,n;cin>>h>>w>>n;
	ll m = max(h,w);
	cout<<(n+m-1)/m<<"\n";
	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

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

using namespace std;

int main() {

    int X, Y;
    cin >> X >> Y;

    if (Y % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    if (X * 4 < Y) {
        cout << "No" << endl;
        return 0;
    }

    int turu = 0;
    int kame = 0;

    for (int i = 0; i <= X; i++) {
        int number = 4 * i + 2 * (X - i);

        if (number == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;

	Point(double x = 0, double y = 0) :x(x), y(y){}

	Point operator + (Point p){ return Point(x + p.x, y + p.y); }
	Point operator - (Point p){ return Point(x - p.x, y - p.y); }
	Point operator * (Point p){ return Point(x * p.x, y * p.y); }
	Point operator / (Point p){ return Point(x / p.x, y / p.y); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x * x + y * y; }

	bool operator<(const Point &p){ return (x != p.x) ? (x < p.x) : (y < p.y); }
	bool operator==(const Point &p)
	{
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;
typedef Point Segment;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthogonal(a1 - a2, b1 - b2);
}

//bool isOrthogonal(Segment s1, Segment s2){
//	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0);
//}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1 - a2, b1 - b2);
}

int main()
{
	int n; cin >> n;
	for (int i = 0; i < n; ++i)
	{
		Point a1, a2, b1, b2;
		cin >> a1.x >> a1.y >> a2.x >> a2.y >> b1.x >> b1.y >> b2.x >> b2.y;
		if (isParallel(a1, a2, b1, b2))
			cout << 2 << endl;
		else if (isOrthogonal(a1, a2, b1, b2))
			cout << 1 << endl;
		else
			cout << 0 << endl;
	}
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  
  vector<int> t(n);
  for (int i = 0; i < n; i++)
    cin >> t.at(i);
  
  int m;
  cin >> m;
  
  int p, x, ans, temp;
  
  for (int i = 0; i < m; i++) {
    cin >> p >> x;
    
    temp = t.at(p-1);
    t.at(p-1) = x;
    
    ans = 0;
    for (int y : t) ans += y;
    cout << ans << endl;
    
    t.at(p-1) = temp;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>

int main() {
  std::string s;
  std::getline(std::cin, s);

  for (std::string::reverse_iterator iter = s.rbegin();
       iter != s.rend(); ++iter) {
    std::cout << *iter;
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, M;
llint x[100005], y[100005];

llint get(llint qx)
{
	llint ret = 0;
	for(int i = 1; i <= n; i++){
		llint a = y[i]+M, b = qx-x[i];
		if(b < 0 || a < b) continue;
		if((a&b) == b) ret++;
	}
	return ret % 2;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	M = (1LL<<57)-1;
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	
	llint p;
	for(llint i = 1e-18; i <= 1e18; i += 1e17){
		if(get(i)){
			p = i;
			break;
		}
	}
	
	llint ub = p, lb = -1e18, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		if(get(mid)) ub = mid;
		else lb = mid;
	}
	cout << ub << endl;
	
	return 0;
}

Measured memory_bytes: 5200
#include<iostream>
//#include <cmath>
#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define ROF(i,a,n) for(int i=(a);i>(n);--i)

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt","r",stdin);
    //reopen("output.txt","w",stdout);
    int n;cin>>n;
    int ac=0, wa=0,tle=0,re=0;
    FOR(i,0,n){
        string s;cin>>s;
        if(s=="AC")ac++;
        else if(s=="WA")wa++;
        else if(s=="TLE")tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
}

Measured memory_bytes: 3652
n, m = map(int, input().split())
A = []
b = []

for i in range(n):
    A.append([int(s) for s in input().split()])

for i in range(m):
    b.append([int(input())])

for i in range(n):
    sum_i = 0
    for j in range(m):
        sum_i += A[i][j] * b[j][0]

    print(sum_i)


Measured memory_bytes: 6016
S = input()
num = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "L":
            print("No")
            break
        else:
            num += 1
    else:
        if S[i] == "R":
            print("No")
            break
        else:
            num += 1
if num == len(S):
    print("Yes")


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
int main(){
	while(1){
		std::vector<int> vec(5);
		std::vector<int> vec2(5);
		int a=0;
		std::cin>>a;
		if(a==0)break;
		int d=0,e=0,f=0;
		if(a==1)d++;
		if(a==2)e++;
		if(a==3)f++;
		vec[0]=a;
		
		for(int i=1;i<5;i++){
			int b;
			std::cin>>b;
			if(b==1)d++;
			if(b==2)e++;
			if(b==3)f++;
			vec[i]=b;
		}
		if(d>=1&&e>=1&&f>=1||d==5||f==5||e==5){
			for(int i=0;i<5;i++){
				vec2[i]=3;
			}
		}else if(d>=1&&e>=1&&f==0){
			for(int i=0;i<5;i++){
				if(vec[i]==1)vec2[i]=1;
				if(vec[i]==2)vec2[i]=2;
			}
		}else if(d>=0&&e>=1&&f>=1){
			for(int i=0;i<5;i++){
				if(vec[i]==2)vec2[i]=1;
				if(vec[i]==3)vec2[i]=2;
			}
		}else if(d>=1&&e>=0&&f>=1){
			for(int i=0;i<5;i++){
				if(vec[i]==1)vec2[i]=2;
				if(vec[i]==3)vec2[i]=1;
			}
		}
		for(int i=0;i<5;i++){
			std::cout<<vec2[i]<<std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

bool re[200];

int main()
{
	ios::sync_with_stdio(false);
	int n,k,m,w,ans=0;
	cin>>n>>k;
	while(k--)
	{
		cin>>m;
		while(m--)
		{
			cin>>w;
			re[w]=true;
		}
	}
	for(int i=1;i<=n;i++)
	if(!re[i]) ans++;
	cout<<ans;
	return 0;
}




Measured memory_bytes: 3692
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int N, M;
  cin >> N >> M;
  int a[40];
  for (int i = 0; i < 40; i++) a[i] = 1;

  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    set<int> x;
    for (int j = 0; j < k; j++) {
      int tmp;
      cin >> tmp;
      tmp--;
      x.insert(tmp);
    }

    for (int j = 0; j < 40; j++) {
      if (!EXIST(x, j)) {
        a[j] = 0;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < M; i++) {
    ans += a[i];
  }

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


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
void dfs(vector<vector<pii>> &root, vi &color, int current, vi &checked){
  for(pii a : root[current]){
    if(!a.second){
      color[a.first] = color[current];
    }else{
      color[a.first] = (color[current] ^ 1);
    }
    if(!checked[a.first]){
      checked[a.first] = 1;
      dfs(root, color, a.first, checked);
    }
  }
}
int main(){
  int n;
  cin >> n;
  vi color(n, -1);
  color[0] = 1;
  vector<vector<pii>> root(n);
  rep(i, n - 1){
    int u,v,w;
    cin >> u >> v >> w;
    u--; v--;
    w %= 2;
    root[u].push_back(make_pair(v, w));
    root[v].push_back(make_pair(u, w));
  }
  vi checked(n);
  dfs(root, color, 0, checked);
  rep(i, n) cout << color[i] << endl;
}

Measured memory_bytes: 9344
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    REP(i,10001){
        int ta = (int)((double)i*0.08);
        int tb = (int)((double)i*0.10);
        if(ta==a&&tb==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){

int n;
int a[10001];
int d = 0;
cin >> n;
for(int i=1; i<=n; i++){
	cin >> a[i];
	for(; a[i] % 2 == 0 ; a[i] = a[i] / 2 ){
		d++;
	}
}
cout << d;

return 0;

}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n);
  ll ans = 0;
  ll flag = 0;
  rep(i, n)
  {
    cin >> a[i];
    if(a[i] < 0) flag++;
    a[i] = abs(a[i]);
    ans += a[i];
  }
  sort(all(a));
  if(flag % 2 == 1)
  ans -= (2 * a[0]);
  fin(ans);
}
//前処理
int main()
{
  ifstream in("text.txt");
  cin.rdbuf(in.rdbuf());
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;
const int MOD = 1000000007;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}
ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}


int main() {
    int n; cin >> n;
    vector<int> v;
    for(int i = 0;i < n;i++){
        int x; cin >> x; v.push_back(x);
    }
    sort(v.begin(),v.end());
    cout << v[n/2] - v[n/2-1];
}


Measured memory_bytes: 3932
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,M;
    cin >> N >> M;
    lint A[N];
    rep(i,N) cin >> A[i];
    multiset<lint> item;
    rep(i,N) item.insert(A[i]);
    rep(i,M){
        auto itr=item.end();
        itr--;
        lint num=*itr;
        item.erase(itr);
        num/=2;
        item.insert(num);
    }
    lint ans=0;
    while(!item.empty()){
        auto itr=item.begin();
        ans+=*itr;
        item.erase(itr);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5760
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int N; cin >> N;
	cout << N*N*N << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

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

  ll ans = 0;
  rep3(i, 1, n + 1) {
    // 1 の倍数の和 g(n) = n(n + 1)/2
    // 2 の倍数の和 2 * g(n / 2)
    ans += 1LL * i * (n / i) * (n / i + 1) / 2;
  }
  cout << ans << endl;
}


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

#define ll      long long
#define MAX     100007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);

int nprime;
bool mark[MAX];

void sieve (void)
{
    long long i,j,lim=sqrt(MAX*1.0)+2;
    mark[0]=mark[1]=1;
    for(i=4;i<MAX;i+=2)
        mark[i]=1;
    for(i=3;i<=lim;i+=2)
    {
        if(!mark[i])
        {
            for(j=i*i;j<=MAX;j+=2*i)
                mark[j]=1;
        }
    }
}
ll q,l,r,res[MAX];
void pre()
{
    for(ll i=1;i<MAX;i+=2)
    {
        if(!mark[i] && !mark[(i+1)>>1])
        {
            res[i]++;
        }
    }
    for(ll i=1;i<MAX;i++)
    {
        res[i] += res[i-1];
    }
}
int main ()
{
    sieve();
    pre();
    scanf("%lld",&q);
    while(q--)
    {
        scanf("%lld %lld",&l,&r);
        printf("%lld\n",res[r]-res[l-1]);
    }
}



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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static int MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}

template<typename T> T my_lcm(T a, T b){
	return a * b / my_gcd(a, b);	
}

template<typename T> struct UF {
    vector<int> par;
    vector<T> sz;

    UF(int n) {
        par.resize(n);
        sz.resize(n);
        for (int i = 0; i < n; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find_root(int x) {
        return par[x] == x ? x : par[x] = find_root(par[x]);
    }

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

    void unite(int x, int y) {
        x = find_root(x);
        y = find_root(y);
        if (x == y) return;
        
        if (sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }

    T size_of_tree(int x) {
        return sz[find_root(x)];
    }
};

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int M = n + 1;
    vector<int> A(n), B(n);
    rep(i, n) {
        A[i] = M * (i + 1);
        B[i] = M * (n - i);
    }

    rep(i, n) A[p[i] - 1] += i + 1;

    rep(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    rep(i, n) {
        if (i) cout << " ";
        cout << B[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<numeric>
#include<math.h>
using namespace std;
#define INF (1 << 30) - 1
#define LINF 1LL << 60
const int MOD = 1000000007;
using ll = long long;
using P = pair<int, int>;

vector<ll> divisors(ll n){ 
	vector<ll> res;
	for(ll i = 1; i * i <= n; ++i){
		if(n % i)continue;
		res.push_back(i);
		if(i * i != n)res.push_back(n / i);
	}
	return res;
}

int main(){
  ll n;
  cin >> n;
  ll cnt = 0;

  for(ll k : divisors(n)){
  	if(k == 1)continue;
  	ll tmp = n;
  	while(tmp % k == 0)tmp /= k; 
  	if(tmp % k == 1)++cnt;
  }

  cnt += divisors(n - 1).size() - 1;

  cout << cnt << endl;
  return 0;
}


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

typedef long long ll;
int T, n;
ll a[210], b[64];
char s[210];

bool ins(ll x) {
	for (int i = 60; ~i; i--) if (x >> i & 1) {
        if (!b[i]) { b[i] = x; return x; }
        x ^= b[i];
	}
    return x;
}

int main() {
    scanf("%d", &T);
    while (T--) {
        scanf("%d", &n);
        for (int i = 1; i <= n; i++) {
            scanf("%lld", &a[i]);
        }
        scanf("%s", s + 1);
        memset(b, 0, sizeof(b));
        bool flag = 1;
        for (int i = n; i; i--) {
            if (s[i] == '0') ins(a[i]);
            else flag &= !ins(a[i]);
        }
        printf("%d\n", !flag);
    }
    return 0;
}

Measured memory_bytes: 3716
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

int main() {
    fastio();

    int x, a, b;

    cin >> x >> a >> b;

    if (a >= b) {
        cout << "delicious" << endl;
    } else if (a + x >= b) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>
using namespace std;
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 ll = long long;

ll w[110];
ll v[110];
ll dp[110][100010] = { 0 };

int main() {
    int N,W; 
    cin >> N>>W;
    for (int i = 0; i < N; ++i) {
        cin >> w[i] >> v[i];
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= W; ++j) {
            if (j >= w[i]) {
                chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
            }
            chmax(dp[i + 1][j], dp[i][j]);
        }
    }
    cout << dp[N][W] << endl;
}

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

namespace Atc_0037
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int P = int.Parse(s.Split(' ')[0]);
            int Q = int.Parse(s.Split(' ')[1]);
            int R = int.Parse(s.Split(' ')[2]);

            List<int> Times = new List<int>();

            Times.Add(P + Q);
            Times.Add(Q + R);
            Times.Add(R + P);

            Console.WriteLine(Times.Min());
        }
    }
}


Measured memory_bytes: 28264
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<time.h>
#include<cmath>
#include<vector>
using namespace std;

int main(void)
{
	int n,m;

	cin >> n;
	vector<int> t(n);
	int sum1 = 0;

	for (int i = 0; i < n; i++) {
		cin >> t[i];
		sum1 += t[i];
	}

	cin >> m;
	vector<int>p(m),x(m);
	for (int i = 0; i < m; i++) {
		int sum2=sum1;
		cin >> p[i] >> x[i];
		sum2 = sum1 - t[p[i]-1] + x[i];
		cout << sum2 << endl;

	}
	cout << endl;
}


Measured memory_bytes: 384