akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>
#include <ciso646>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;

inline bool check(ll x, ll y, ll xMax, ll yMax) { return x >= 0 && y >= 0 && xMax > x && yMax > y; }
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(); }
template<class T> inline T sqr(T x) { return x*x; }
template<class T> inline T mypow(T x, ll n) { T res = 1; while (n > 0) { if (n & 1)res = res * x;	x = x * x;	n >>= 1; }return res; }
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

#define For(i,a,b)	for(ll (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define rFor(i,a,b)	for(ll (i) = (a-1);i >= (b);(i)--)
#define rrep(i,n)	rFor(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define tostr(a)	tostring(a)
#define dump(val) 	cerr << #val " = " << val << endl;
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

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

const ll mod = 1e9 + 7;
const ll INF = 1e17 + 9;

#define int ll
#define double ld

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

	int a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << min({ a * b, b * c,c * a }) << endl;

	return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))


int main() {
  int n,a ,t;
  scanf("%d\n",&n);
  scanf("%d %d\n",&t, &a);
  std::vector<int> h(n);
  int tmp;
  for (size_t i = 0; i < n; i++) {
    scanf("%d ",&h[i]);
  }
  float diff=1234567;
  int index;
  for (size_t i = 0; i < n; i++) {
    if (abs(a-(t-h[i]*0.006))<diff) {
      diff=abs(a-(t-h[i]*0.006));
      
      index=i;
    }
  }
  printf("%d\n",index+1 );
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    double A, B;
    cin >> A >> B;
    if(A > B){
        cout << "GREATER" << endl;
    }
    else if(A < B){
        cout << "LESS" << endl;
    }
    else{
        cout << "EQUAL" << endl;
    }
    return 0;
}

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

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define MOD 1000000007
const int N=100005;


int32_t main()
{
	int n;
	cin>>n;
	vector<int> a(n),suffix(n+1);
	for(auto &it:a)
	{
		cin>>it;
	}
	for(int i=n-1;i>=0;i--)
	{
		suffix[i]=(suffix[i+1]+a[i])%MOD;
	}
	int ans=0,res=0;;
	for(int i=0;i<n;i++)
	{
		ans=(a[i]*suffix[i+1])%MOD;
		res=(res+ans)%MOD;
	}
	cout<<res;
	
	
	
}


Measured memory_bytes: 6404
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n, m;
	cin >> n >> m;
	VV(int) G(n);
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		G[a - 1].push_back(b - 1);
		G[b - 1].push_back(a - 1);
	}
	VV(LL) dp;
	initvv(dp, n, 1 << n);
	dp[0][1] = 1;
	for(int S = 0; S < (1 << n); ++S){
		for(int i = 0; i < n; ++i){
			for(int j : G[i]){
				int T = S | 1 << j;
				if(S != T){
					dp[j][T] += dp[i][S];
				}
			}
		}
	}
	
	LL ans = 0;
	for(int i = 0; i < n; ++i){
		ans += dp[i].back();
	}
	cout << ans << endl;
}



}
int main() try{
//	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

c2 = 0
c4 = 0
for a in A:
    r4 = a % 4
    if r4 == 0:
        c4 += 1
    r2 = a % 2
    if r2 == 0:
        c2 += 1
if c4 * 2 + 1 >= N or c4 * 2 + max(0, c2-c4) >= N:
    print('Yes')
else:
    print('No')


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

int main() {
	int n;
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	multiset<int>s;
	s.insert(arr[0]);
	for(int i=1; i<n; i++){
		int val=arr[i];
		auto it=s.begin();
		int vals=(*it);
		if(val<=vals){
			s.insert(val);
			continue;
		}
		it=s.end();
		it--;
		vals=(*it);
		if(vals<val){
			s.erase(s.find(vals));
			s.insert(val);
			continue;
		}
		it=s.lower_bound(val);
		it--;
		s.erase(s.find((*it)));
		s.insert(val);
	}
	cout<<s.size();
	return 0;
}

Measured memory_bytes: 8492
#include<stdio.h>
int main(void)
{
    int n,T,c[100],t[100],i,ans,x=0,tmp;
    scanf("%d%d",&n,&T);
    for(i=0;i<n;i++)
        scanf("%d%d",&c[i],&t[i]);
    ans=c[0];
    for(i=0;i<n;i++){
        if((t[i]<=T)&&(ans>=c[i])){
            tmp=ans; ans=c[i]; c[i]=tmp;
        }
        else x++;
    }
    if(x!=n) printf("%d\n",ans);
    else printf("TLE\n");
    return 0;
}

Measured memory_bytes: 128
#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];
    }
    for(int i=n-1; i>=0; --i){
        if(i!=0)cout<<a[i]<<" ";
        else cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MAX= 1e9 + 7;
ll TopDown(vector< int > &heights, int n,int k)
{
    vector< ll > incurr(n);
    incurr[0] = 0;
    incurr[1] = abs(heights[0] - heights[1]);
    for(int i=2;i<n; i++){
        incurr[i] = MAX;
        for(int j=i-1; j>=0 && (i-j)<=k ;j--){
            incurr[i] = min(incurr[i],abs(heights[i] - heights[j])+incurr[j]);
        }
    }
    return incurr[n-1];
}
int main()
{
    //freopen("in.txt","r",stdin);
    int n,k;
    cin >> n >> k;
    vector< int >  heights(n);
    for(int i=0;i<n;i++){
        cin >> heights[i];
    }
    ll ans = TopDown(heights,n,k);
    cout << ans << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


const int N = 1e5+5;
vector<pii> g[N+1];
int col[N+1];
void dfs(int u= 1 , int p= -1 , int cur = 0){
	col[u] = cur ; 
	for(auto [v,w] : g[u]){
		if(v==p)continue;
		dfs(v,u,w^cur);
	}
}
void solve(){
	memset(col,0,sizeof col);
	int n ; 
	cin >> n ;
	rep(i,1,n){
		int x , y , w; 
		cin >> x >> y >> w;
		w%=2;
		g[x].emplace_back(y,w);
		g[y].emplace_back(x,w);
	}
	dfs();
	fr(i,1,n) cout << col[i]%2 << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();












#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 14104
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	ll n, k;
	cin >> n >> k;
	int ans = 0;
	while(n > 0) {
		n /= k;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'
function main() {
  const input = readFileSync('/dev/stdin', 'utf8')
  const inputs = input.trim().split('\n')
  const [n, k, q] = inputs[0].split(' ').map(v => parseInt(v))
  const winner = inputs.slice(1).map(v => parseInt(v))
  const array: number[] = []
  array.length = n
  array.fill(0)
  for (let i = 0; i < q; i++) {
    array[winner[i] - 1]++
  }
  const human: string[] = []
  human.length = n
  const border = q - k
  for (let i = 0; i < n; i++) {
    human[i] = array[i] > border ? 'Yes' : 'No'
    console.log(human[i])
  }
}
main()

Measured memory_bytes: 30904
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, c; cin >> n;
  map<int, int> di;
  vector<int> disort(n);
  int min = 100000, max = 0;
  for(int i = 0; i < n; i++) {
    cin >> c;
    disort.at(i) = c;
    if(c < min) {
      min = c;
    }
    if(c > max) {
      max = c;
    }
    if(di.count(c)) {
      di.at(c)++;
    }
    else {
      di[c] = 1;
    }
  }
  sort(disort.begin(), disort.end());
  int k = disort.at(n /2 -1) +1;
  if(disort.at(n /2) == k -1) {
    cout << 0 << endl;
  }
  else {
    int count = 1;
    while(disort.at(n /2) != k) {
      k++;
      count++;
    }
    cout << count << endl;
  }
}

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

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

  string S;
  cin >> S;
  int A[30] = {};
  bool ans = true;
  for(int i=0;i<S.size();i++){
    if(A[S[i] - 'a'] != 0){
      ans = false;
      break;
    }
    else{
      A[S[i] - 'a']++;
    }
  }
  if(ans) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 256
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

int main()
{
	fastIOS();
	ULL a, b, x;

	cin >> a >> b >> x;

	ULL fa = a/ x;
	ULL fb = b / x;
	ULL ans = fb - fa;
	if (a % x == 0)
		ans++;
	
	cout << ans << "\n";
}

Measured memory_bytes: 256
N = int(input())
A = sorted([int(i) for i in input().split(" ")],reverse=True)
ans = 1
flag = 1
if 0 in A:
    print(0)
else:
    for a in A:
        ans*=a
        if ans>10**18:
            print(-1)
            flag = 0
            break
    if flag:
        print(ans)

Measured memory_bytes: 21596
#include<iostream>
#include<utility>

using namespace std;

int A[200000];
int B[200000];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	long long cnt=0;
	cin>>n;
	for(int i=0; i<n; i++) cin>>A[i];

	int* p=A;
	int* q=B;
	for(int d=1; d<n; d*=2) {
		std::swap(p, q);
		int l=0, m=0, r=0;
		while(r<n) {
			l=r;
			m=std::min(r+d, n);
			r=std::min(r+d+d, n);
			int i, j, k;
			i=k=l;
			j=m;
			while(i<m&&j<r) {
				if(q[i]<=q[j]) p[k++]=q[i++];
				else {
					cnt+=j-k;
					p[k++]=q[j++];
				}
			}
			while(i<m) p[k++]=q[i++];
			while(j<r) {
				cnt+=j-k;
				p[k++]=q[j++];
			}
		}
	}
	cout<<cnt<<'\n';
	return 0;
}



Measured memory_bytes: 4672
n = int(input())
ais = list(map(int, input().split()))
a_mini = ais[0]
a_max = ais[0]
for i in range(1, n):
  if ais[i] < a_mini:
    a_mini = ais[i]
  if ais[i] > a_max:
    a_max = ais[i]
print(a_max - a_mini)

Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 100000000
#define MINS -20000000

int heapsize=0;
int A[MAX],X[MAX];
int p(int heap){
  return heap/2;
}
int l(int heap){
  return heap*2;
}
int r(int heap){
  return (heap*2+1);
}

main(){
  
  int i=0,k=0,left,right,key;
  char com[20];
  
  while(1){
    scanf("%s",com);
    if(com[0] == 'i'){
      scanf("%d",&key);
      maxHeapInsert(key);
    }else if(com[0] == 'e' && com[1] == 'x'){
      
      X[k]= heapExtractMax();
      
      k++;
    }else if(com[0] == 'e' && com[1] == 'n'){
      for(i = 0;i < k;i++)
	printf("%d\n",X[i]);
      break;
    }    
  }
  return 0;
}
int maxHeapify(i){
  int largest;
  int left = l(i);
  int right = r(i);
  if(left <= heapsize && A[i]< A[left]){
    largest = left;
  }else{
    largest = i;
  }
  if(right <= heapsize && A[right] > A[largest]){
    largest = right;
  }
  if(largest != i){
    int tmp;
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
int buildMaxHeap(){
  int i;
  for(i = (heapsize/2); i >= 1;i--){
    maxHeapify(i);
  }
}
int maxHeapInsert(int key){
  heapsize = heapsize+1;
  A[heapsize] = MINS;
  heapIncreaseKey(heapsize,key);
}
int heapIncreaseKey(int i,int key){
  int tmp;
  if(key < A[i]){
    return;
  }
  A[i] = key;
  while(i > 1 && A[p(i)] < A[i]){
    tmp = A[i];
    A[i] = A[p(i)];
    A[p(i)] = tmp;
    i = p(i);
  }
}

int heapExtractMax(){
  int max;
  if(heapsize < 1){
    return;
  }
  max = A[1];
  A[1] = A[heapsize];
  heapsize = heapsize - 1;
  maxHeapify(1);
  return max;
}

Measured memory_bytes: 8700
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int n; CI n;
	vector<int> a(n + 1); a[0] = 0; REP(i, n) { CI a[i + 1]; } a.push_back(0);
	int tmp = 0;

	REP(i, n+1) {
		tmp += abs(a[i] - a[i + 1]);
	}
	FOR(i,1, n) {
		CO tmp + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) EN;
	}

	return 0;
}

Measured memory_bytes: 1656
import java.lang.Math.*
fun main(args:Array<String>?): Unit {
    var case = 1
    while(true) {
        val (w, h, n) = readLine()!!.trim().split(' ')
        if (w == "0" && h == "0" && n == "0") return
        val width = w.toInt()
        val height = h.toLong()
        val coordinates = Array(n.toInt()){
            val (x, y) = readLine()!!.trim().split(' ')
            Coordinate(x.toInt(), y.toLong())
        }.groupBy(Coordinate::y).toList().sortedBy(Pair<Long, List<Coordinate>>::first).dropWhile{it.first == 1L}
        var initial = LongArray(width){0L}
        initial[0] = 1
        var current = 1L
        for ((y, coords) in coordinates){
            val block = BooleanArray(width){false}
            for ((x, _) in coords) block[x - 1] = true
            initial = move(move(initial, y - current - 1), block)
            current = y
        }
        if (current != height) initial = move(initial, height - current)
        println("Case ${case++}: ${initial.last()}")
    }
}
data class Coordinate(val x: Int, val y: Long)
const val mod = 1_000_000_009L
fun multiple(left: LongArray, right: Array<LongArray>): LongArray {
    val result = LongArray(right.first().size){0L}
    for (i in result.indices) for (j in right.indices){
        result[i] += left[j] * right[j][i]
        result[i] %= mod
    }
    return result
}
fun multiple(left: Array<LongArray>, right: Array<LongArray>): Array<LongArray> {
    val result = Array(left.size){LongArray(right.first().size){0L}}
    for (i in result.indices) for (j in result[i].indices){
        for (k in left[i].indices) {
            result[i][j] += left[i][k] * right[k][j]
            result[i][j] %= mod
        }
    }
    return result
}
fun pow2(base: Array<LongArray>): Array<LongArray> = multiple(base, base)
fun pow(base: Array<LongArray>, exp: Long): Array<LongArray> {
    if (exp == 0L) return (Array(base.size){r -> LongArray(base.size){if (it == r) 1L else 0L}})
    if (exp == 1L) return base
    if (exp % 2 == 0L) return pow2(pow(base, exp / 2))
    else return multiple(base, pow(base, exp - 1))
}
fun moveMatrix(h: Long, w: Int): Array<LongArray> {
    val base = Array(w){i -> LongArray(w){if (abs(it - i) <= 1) 1L else 0}}
    return pow(base, h)
}
fun move(line: LongArray, h: Long): LongArray {
    return if (h == 0L) line
    else multiple(line, moveMatrix(h, line.size))
}
fun move(line: LongArray, block: BooleanArray): LongArray {
    val result = LongArray(line.size){0L}
    for (i in result.indices){
        if (!block[i]) for (j in -1 .. 1) if (i + j in line.indices){
            result[i] += line[i + j]
        }
        result[i] %= mod
    }
    return result
}


Measured memory_bytes: 72336
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 200000;

int main() {
	int n, R[MAX];
	cin >> n;

	for (int i = 0; i < n; i++) cin >> R[i];

	int maxv = -2000000000;
	int minv = R[0];

	for (int j = 1; j < n; j++) {
		maxv = max(maxv, R[j]- minv);
		minv = min(minv, R[j]);
	}

	cout << maxv << endl;

	return 0;

}

Measured memory_bytes: 3864
#include<iostream>
#include<cstring>
using namespace std;
int graph[110][110];

int main(){
    int n,u,k,num;
    cin>>n;
    memset(graph,0,sizeof(graph));
    for(int i=1;i<=n;i++){
        cin>>u>>k;
        while(k--){
            cin>>num;
            graph[u][num]=1;
        }
    }

    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            cout<<graph[i][j]<<(j==n?"\n":" ");
}


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

typedef long long LL;
typedef pair<LL,LL> pll;

pll li[100005];
int n;
LL ans = 0LL;

bool cmp(pll a, pll b){
   LL da = a.first - b.second;
   LL db = b.first - a.second;
   return da > db;
}

int main(){
   cin >> n;
   for(int i=1;i<=n;i++) cin >> li[i].first >> li[i].second;
   sort(li+1,li+n+1,cmp);
   for(int i=1;i<=n;i++){
//      cout << li[i].first << " > " << li[i].second << endl;
      if(i&1) ans+=li[i].first;
      else ans-=li[i].second;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef long long ll;
typedef pair<ll,ll> P;


int main(){
    ll n,k;cin>>n>>k;
    ll p[1010];
    rep(i,0,n)cin>>p[i];
    sort(p,p+n);
    ll an=0;
    rep(i,0,k)an+=p[i];
    cout<<an<<endl;
}

    









Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <vector>

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(a) (a).begin(), (a).end()

#define INF 1000000000

using namespace std;

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

    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + (100 * (10 - N)) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	int n;
	double a[1001];
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	double ans;
	ans = 0;
	for (int i = 0; i < n; i++) {
		ans += 1 / a[i];
	}
	ans = 1 / ans;

	cout << ans << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


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

int main() {
  string  s;
  int t=0;
  cin >>s;

for (int i=0 ; i<s.size() ; i++)  
{ t+= s[i]-'0';}
if (t%9==0) {cout << "Yes" <<endl;
}
else {cout << "No" << endl;}
return 0 ;}


Measured memory_bytes: 3708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const int N = 1e5 + 5;

int n;
unordered_map<int, int> B;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for (int j = n - 1; j > 0; j -= 2) B[j] = 2;
  if (n & 1) B[0] = 1;
  for (int i = 1; i <= n; ++i) {
    int A; cin >> A;
    if (B.find(A) == B.end() || B[A] == 0) {
      cout << 0;
      return 0;
    }
    --B[A];
  }
  ll ans = 1;
  for (int i = 1; i * 2 <= n; ++i) (ans <<= 1) %= MOD;
  cout << ans;
  return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    vector<vector<int>> up(h, vector<int>(w));
    vector<vector<int>> down(h, vector<int>(w));
    vector<vector<int>> left(h, vector<int>(w));
    vector<vector<int>> right(h, vector<int>(w));
    for (int i = 0; i < w; ++i) {
        int cnt = 1;
        for (int j = 0; j < h; ++j) {
            if (grid[j][i] == '#') {
                cnt = 1;
                continue;
            }
            up[j][i] = cnt;
            cnt++;
        }
    }
    for (int i = 0; i < w; ++i) {
        int cnt = 1;
        for (int j = h - 1; j >= 0; --j) {
            if (grid[j][i] == '#') {
                cnt = 1;
                continue;
            }
            down[j][i] = cnt;
            cnt++;
        }
    }
    for (int i = 0; i < h; ++i) {
        int cnt = 1;
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#') {
                cnt = 1;
                continue;
            }
            left[i][j] = cnt;
            cnt++;
        }
    }
    for (int i = 0; i < h; ++i) {
        int cnt = 1;
        for (int j = w - 1; j >= 0; --j) {
            if (grid[i][j] == '#') {
                cnt = 1;
                continue;
            }
            right[i][j] = cnt;
            cnt++;
        }
    }
    int ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans, up[i][j] + down[i][j] + left[i][j] + right[i][j] - 3);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 67200
#include <iostream>

using namespace std;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  
  int n,x,m=0,m2=0,index=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x>m){m2=m;m=x;index=i;}
        else if(x>m2)m2=x;
    }


    for(int i=0;i<n;i++)
    {
        if(i==index)cout<<m2<<endl;
        else cout<<m<<endl;
    }
}


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

int main() {
  double n; cin >> n;
  cout << n * 2 * M_PI << endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<vector<int> > vec(N+1);
    for(int m=0; m<M; m++) {
        int a, b;
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a);
    }
    
    
    queue<int> que;
    que.push(1);
    vector<int> dist(N+1, -1);
    dist[1]=0;
    while(!que.empty()) {
        int cur=que.front();
        que.pop();
        
        for(int i=0; i<vec[cur].size(); i++) {
            if(dist[vec[cur][i]]!=-1) continue;
            dist[vec[cur][i]] = dist[cur]+1;
            
            que.push(vec[cur][i]);
        }
    }
    
    if(dist[N]==2) {
        cout << "POSSIBLE" << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
    
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long int

void solve(ll caseNo)
{
    int n;
    cin >> n;
    if(n >= 30) cout << "Yes" << endl;
    else    cout << "No" << endl;
    return;
}

int main()
{
    IOS;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll cases;
    cases = 1;
    for(ll i=1;i<=cases;i++)
    {
        solve(i);
    }
    return 0;
}

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

bool bit[10];
void make_bit(int n){
    for(int i=0; i<N-1; i++){
        bit[i]=n%2;
        n /=2;
    }
}

int main(){
    string S;
    cin >> S;
    N = S.size();
    for(int i=0; i<S.size(); i++){
        S.at(i) -='0';
    }
    long long sum=0;
    for(int i=0; i<pow(2,N-1); i++){
        make_bit(i);
        sum +=S.at(N-1);
        int cnt =1;
        for(int k=0; k<N-1; k++){
            if(bit[k]==0){
                sum += pow(10,cnt)*S.at(N-k-2);
                cnt++;
            }
            if(bit[k]==1){
                sum += S.at(N-k-2);
                cnt =1;
            }
//            cout << sum << endl;
        }
//        cout << sum << endl;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int k,n; cin >> k >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  ll sum=0;
  rep(i,n){
    sum+=a[i];
  }
  sum-=a[n-1];
  if(a[n-1]<=sum+1){
    cout << 0 << endl;
    return 0;
  }
  cout << a[n-1]-sum-1 << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	long long int D,N,ans=0;
	long long int X[1000001], Y[1000001];
	cin >> N >> D;
	for (int i = 0; i < N; i++) {
		cin >> X[i] >> Y[i];
	}
	for (int i = 0; i < N; i++) {
		if (X[i] * X[i] + Y[i] * Y[i] <= D * D)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6768
//46
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
#include<vector>
#include<sstream>

using namespace std;

typedef pair<string,int> psi;

bool cmp(psi a,psi b){
  return a.second>b.second;
}

int main(){
  for(int n;cin>>n,n;){
    map<string,int> m[128];
    cin.ignore();
    while(n--){
      string s;
      getline(cin,s);
      stringstream ss(s);
      for(string t;ss>>t;){
	m[t[0]][t]++;
      }
    }
    char c;
    cin>>c;
    vector<psi> v(m[c].begin(),m[c].end());
    stable_sort(v.begin(),v.end(),cmp);
    if(v.empty()){
      cout<<"NA"<<endl;
    }else{
      int l=min((int)v.size(),5);
      for(int i=0;i<l;i++){
	cout<<v[i].first<<((i==l-1)?'\n':' ');
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
string color_hantei(int a){
    if(a>0&& a<400) return "hai";
    else if(a>=400 && a<800) return "cha";
    else if(a>=800 && a<1200) return "midori";
    else if(a>=1200 && a<1600) return "mizu";
    else if(a>=1600 && a<2000) return "ao";
    else if(a>=2000 && a<2400) return "ki";
    else if(a>=2400 && a<2800) return "dai";
    else if(a>=2800 && a<3200) return "aka";
    else return "zzz";
}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int ans=0;
    int z_cnt=0;
    rep(i,n) cin >> a[i];
    map<string,int> rate;
    rep(i,n){
        rate[color_hantei(a[i])] ++;
    }
    for(auto c:rate){
        if(c.first == "zzz") z_cnt += c.second;
        if(c.first != "zzz")ans ++;
    }
   if(ans == 0) cout << 1 << " " ;
   else cout << ans << " " ;
 cout << z_cnt + ans <<endl;
}
    

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    private static Consumer<List<String>> solve() {
        return args -> {
            List<Integer> numList = Arrays.stream(args.get(1).split(" "))
                    .map(Integer::valueOf)
                    .sorted()
                    .collect(Collectors.toList());
            int mid = (numList.size() - 1) / 2;
            System.out.println(numList.get(mid + 1) - numList.get(mid));
        };
    }

}


Measured memory_bytes: 49940
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

vector<Int> divisor(Int n) {
    vector<Int> ret;
    for (Int i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

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

    vector<Int> n_div(divisor(n)), niti_div(divisor(n - 1));
    n_div.push_back(n);
    niti_div.push_back(n - 1);

    Int ans = (Int)niti_div.size();
    Int ro = (Int)n_div.size();
    for (Int i = 0; i < ro; i++) {
        Int nn = n;
        while (nn % n_div[i] == 0 && nn != 0) {
            nn = nn / n_div[i];
        }

        if (nn % n_div[i] == 1) {
            ans++;
        }
    }

    if (n == 2) {
        ans--;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
from math import ceil
n=int(input())
k=ceil((2*n)**0.5)
if k*(k-1)//2!= n:
  print('No')
  exit()

S=[[] for _ in range(k)]
a=1
for i in range(k):
  for j in range(i+1, k):
    S[i].append(a)
    S[j].append(a)
    a+=1

print('Yes')
print(k)
for i in range(k):
  print(len(S[i]),*S[i])

Measured memory_bytes: 14424
#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int grid[10][10];

struct STATE
{
	int done, x, y;
	
	bool operator < (const STATE& t) const{
		if (done == t.done){
			if (x == t.x){
				return y < t.y;
			}
			return x < t.x;
		}
		return done < t.done;
	}
};

int main()
{
	int m, n;
	while (scanf("%d %d", &m, &n), m){
		int num = 0;
		int sx, sy;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				scanf("%d", &grid[i][j]);
				if (grid[i][j] == 0){
					grid[i][j] = -1;
				}
				else if (grid[i][j] == 1){
					grid[i][j] = num++;
				}
				else {
					grid[i][j] = -2;
					sx = i;
					sy = j;
				}
			}
		}
		
		map<STATE, int> dp;
		map<STATE, int> dp2;
		STATE tmp = {0, sx, sy};
		dp[tmp] = 1;
		int res = 0;
		while (true){
			STATE tmp = {(1 << num) - 1, sx, sy};
			if (dp.count(tmp)){
				res = dp[tmp];
				break;
			}
			
			for (map<STATE, int>::iterator ite = dp.begin(); ite != dp.end(); ++ite){
				STATE st = (*ite).first;
				
				//printf("%d %d %d %d\n", st.done, st.x, st.y, dp[st]);
				
				for (int dir = 0; dir < 4; dir++){
					int i = 1;
					while (true){
						int tx = st.x + dx[dir] * i;
						int ty = st.y + dy[dir] * i;
						if (tx < 0 || tx >= n || ty < 0 || ty >= m) break;
						if (grid[tx][ty] == -2){
							if (st.done == (1 << num) - 1){
								STATE tmp = {st.done, tx, ty};
								dp2[tmp] += dp[st];
								break;
							}
						}
						else if ((grid[tx][ty] != -1) && (~st.done & (1 << grid[tx][ty]))){
							STATE tmp = {st.done | (1 << grid[tx][ty]), tx, ty};
							dp2[tmp] += dp[st];
							break;
						}
						i++;
					}
				}
			}
			
			dp.clear();
			dp = dp2;
			dp2.clear();
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 24768
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    u32 A, B;
    cin  >> A >> B;
    cout << A * B << endl;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <iomanip>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    
    int n;
    cin>>n;
    vector<double> v(n);
    REP(i,n){
        cin>>v[i];
    }
    sort(v.begin(),v.end());
    double sum=v[0];
    FOR(i,1,n){
        sum=(sum+v[i])/2;
    }
    cout<< std::setprecision(10)<<sum<<endl;

    return 0;

    return 0;
}


Measured memory_bytes: 888
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

# a = N % A
# b = N % B
def divisor(n): #nの約数を全て求める
    i = 1
    table = []
    while i * i <= n:
        if n%i == 0:
            table.append(i)
            table.append(n//i)
        i += 1
    table = list(set(table))
    return table
ans = 0

memo = [0] * N
A = N - 1
ans = 0
for i in range(1, N):
    ans += A // i
print(ans)
    # memo[i]



# for c in range(1, N):
#     # c = 0 ~ N - 1
#     s = N - c
#     d = divisor(s)
#     print(d)
#     ans += len(d)
# print(ans)




Measured memory_bytes: 17936
#include <bits/stdc++.h>
using namespace std;
const int MAX = 100010;
vector<pair<int, long long>> tree[MAX];
vector<long long> dist(MAX);
void dfs(int crr, int par, long long d) {
	dist[crr] = d;
	for(int i = 0; i < tree[crr].size(); i++) {
		if(tree[crr][i].first == par) {
			continue;
		}
		dfs(tree[crr][i].first, crr, d + tree[crr][i].second);
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--;
		b--;
		tree[a].emplace_back(b, c);
		tree[b].emplace_back(a, c);
	}
	int q, k;
	cin >> q >> k;
	k--;
	dfs(k, -1, 0);

	for(int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		cout << dist[x] + dist[y] << endl;
	}
	return 0;	
}


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

using ll = long long;

int N;
int H[105];
ll mo=1000000007;

ll modpow(ll a, ll n = mo-2) {
	ll r=1;a%=mo;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}

pair<ll,ll> hoge(int L,int R,int v) {
	ll dp1=1,dp2=1;
	int i;
	
	if(L>R) return {0,0};
	
	int mi=1<<30;
	for(i=L;i<=R;i++) mi=min(mi,H[i]);
	int W=R-L+1;
	for(i=L;i<=R;i++) if(mi!=H[i]) W--;
	
	int pre=L-1;
	for(i=L;i<=R;i++) {
		if(mi==H[i]) {
			auto r=hoge(pre+1,i-1,mi);
			if(r.first>0) {
				(dp1*=r.first)%=mo;
				(dp2*=r.first+r.second)%=mo;
			}
			
			pre=i;
		}
	}
	auto r=hoge(pre+1,R,mi);
	if(r.first > 0) {
		(dp1*=r.first)%=mo;
		(dp2*=r.first+r.second)%=mo;
	}
	(dp2=dp2*modpow(2,W)+(modpow(2,mi-v)+mo-2)*dp1)%=mo;
	(dp1*=modpow(2,mi-v))%=mo;
	
	return {dp1,dp2};
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	for(i=1;i<=N;i++) cin>>H[i];
	cout<<hoge(1,N,0).second<<endl;
}

int main()
{
        solve();
}

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

/*int digit(long long n)
{
    int digit=0;
    while(n){
        digit++;
        n = n/10;
    }
    return digit;
}*/

long long keta(long long n)
{
    long long keta_min = 29;
    //int res = (1<<29); // 十分大きい値で初期化
    for (long long i = 1; i * i <= n; i++) //intは×
    {
        if (n % i == 0)
        {
            string A = to_string(i); //to_string(i);
            string B = to_string(n/i);//to_string(n/i);
            long long A_size = A.size();//A.size();
            long long B_size = B.size();//B.size();
            keta_min = min(keta_min,max(A_size,B_size));
        }
        
    }
    return keta_min;
}

void solve(long long N){
    const auto min = keta(N);
    cout << min << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int a, b, c, x; 
    int ans = 0;
    cin >> a >> b >> c >> x;
    rep(i, a+1) rep(j, b+1) rep(k, c+1) {
        if(i*500+j*100+k*50 == x) ans++;
    } 
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search  
#define le length()
const ll max_i=1e8;
#define np(s) next_permutation(s.begin(),s.end())
//it gives the lexicographically next string

int main()
{
    ld r;
    cin>>r;
    ld p=(22.0/7.0);
    ld p1=p*2.0*r;
    cout<<fixed<<setprecision(10)<<p1;
    return 0;
}


Measured memory_bytes: 3704
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<deque>
using namespace std;

int main() {

    int n;
    while(cin >> n && n) {
        
        int sum = 0;
        int tmp;
        for(int i = 0; i < n/4 ; i++) {
            cin >> tmp;
            sum += tmp;
        }
        cout << sum << endl;

    }
     
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int H, W;
    cin >> H >> W;

    vector<vector<char>> map(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> map[i][j];
        }
    }

    // debug
    for (int i = 0; i < H; i++)
    {
        int counter = 0;
        while (counter < 2)
        {
            for (int j = 0; j < W; j++)
            {
                cout << map[i][j];
            }
            printf("\n");
            counter++;
        }
    }

    return (0);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int A,B,C,D;
	cin >> A >> B >> C >> D;
	int E = C/B + (C%B != 0);
	int F = A/D + (A%D != 0);
	if(E <= F) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3588
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl;
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl;
/// Debug End

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

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

signed main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    Ciniii(N,A,B);
    cout << min(N*A,B) << nn;
    return 0;
}

Measured memory_bytes: 256