akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

#define TRUE 1
#define FALSE 0

int solve(int,int);

int n,a[2000],j=0;

int main(){
  int m[2000],q,re,i;

  scanf("%d",&n);
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i = 0;i < q;i++){
    scanf("%d",&m[i]);
  }

  for(i = 0;i < q;i++){

    re = solve(j,m[i]);

    if(re == TRUE){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }

  return 0;

}

int solve(int j,int m){

  if(m == 0){
    return TRUE;
  }
  if(j >= n){
    return FALSE;
  }

  if(solve(j+1,m) == TRUE || solve(j+1,m-a[j]) == TRUE){
    return TRUE;
  }
  j = j + 1;

}

Measured memory_bytes: 588
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

typedef long long ll;

const int MAXN = 201000;
int n,m,rt,deg[MAXN];
vector<pair<int,int> > adj[MAXN];
bool f = true,vis[MAXN][2];
ll val[MAXN][2];

void dfs(int s, int c, int cur){
	if(vis[s][c]){
		if(val[s][c]!=cur){
			printf("0\n");
			exit(0);
		}
		return;
	}
	vis[s][c]=1;
	val[s][c]=cur;
	for(auto t:adj[s]){
		dfs(t.first,c^1,t.second-cur);
	}
}

int main(){

	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int x,y,c;
		scanf("%d%d%d",&x,&y,&c);
		adj[x].push_back(make_pair(y,c));
		adj[y].push_back(make_pair(x,c));
	}
	dfs(1,0,0);
	if(vis[1][1]){
		ll t = val[1][1]/2;
		bool f = (val[1][1]%2)^1;
		for(int i=1;i<=n;i++){
			ll a = val[i][0];
			ll b = val[i][1];
			if((b-a)/2!=t)f = false;
			if(t+a<=0)f=false;
		}
		if(f){
			printf("1\n");
		}
		else printf("0\n");
	}
	else 
	{
		ll l = 1, r = 1e12;
		for(int i=1;i<=n;i++){
			if(vis[i][0]){
				l = max(l,1-val[i][0]);
			}
			if(vis[i][1]){
				r = min(r,val[i][1]-1);
			}
		}
		cout << max(r-l+1,0LL) << endl;
	}


	return 0;
}





Measured memory_bytes: 18304
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

const int N = 2501;
vii g[N],revg[N];
vector<pair<ii, ll>> edlist;
ll n,m,p,a,b,c;
bool canvisit[N];
ll dist[N];

void dfs(int curr) {
	for(auto itr : revg[curr]) {
		int nxt = itr.ff;
		if(!canvisit[nxt]) {
			canvisit[nxt] = true;
			dfs(nxt);
		}
	}
}

bool found[N];

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>n>>m>>p;
    FOR(i, 0, m) {
    	cin>>a>>b>>c; a--; b--; c -= p; c *= -1;
    	edlist.push_back({{a, b}, c});
    	revg[b].push_back({a, c});
    }
    memset(canvisit, false, sizeof(canvisit));    
    canvisit[n-1] = true;
    dfs(n-1);
    FOR(i, 0, n) {
    	dist[i] = INF;
    }

    memset(found, false, sizeof(found));
    dist[0] = 0; found[0]=true;
    FOR(times, 0, n-1) {
		for(auto curr : edlist) {
			tie(a,b) = curr.ff; c = curr.ss;
			if (dist[a] == INF) continue;
			if(dist[b] > dist[a] + c) {
				dist[b] = dist[a] + c;
				found[b] = true;
			}			
		}
    }
    for(auto curr : edlist) {
		tie(a,b) = curr.ff; c = curr.ss;
		if(dist[a] == INF || dist[b] == INF) continue;		
		if((dist[b] > dist[a] + c) && canvisit[b] && found[a]) {
			cout<<-1;
			return 0;
		}
	}
	cout<<max(0LL, -1LL*dist[n-1]);
    return 0;
}

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

int main(){
	string a,b;
	cin >> a >> b;

	if(a.size()>b.size())
		puts("GREATER");
	else if(a.size()<b.size())
		puts("LESS");
	if(a.size()==b.size()){
		for(int i=0;i<a.size();i++){
			if(a[i]>b[i]){
				puts("GREATER");
				return 0;
			}else if(a[i]<b[i]){
				puts("LESS");
				return 0;
			}
		}
		puts("EQUAL");
	}
	return 0;
}	



Measured memory_bytes: 256
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 1

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

for i in range(5):
    if s[i] == 0:
        print(i + 1)


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

const int inf = 1 << 28;

class UnionFind {
public:
  vector<int> rank, p;
  UnionFind(int size)
  {
    rank.resize(size, -inf);
    p.resize(size, -inf);
  }
  void make(int a)
  {
    rank[a] = 0;
    p[a] = a;
  }
  void unite(int a, int b)
  {
    link(find(a), find(b));
  }
  int find(int a)
  {
    return (a == p[a]) ? a : p[a] = find(p[a]);
  }
  bool isSameSet(int a, int b)
  {
    return find(a) == find(b);
  }
  void link (int a, int b)
  {
    if (rank[a] > rank[b]) {
      p[b] = a;
    } else {
      p[a] = b;
      if(rank[a] == rank[b]) rank[b]++;
    }
  }
};

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

  int n, m;
  while (cin >> n >> m) {
    vector<int> v(n);
    each (i, v) {
      cin >> i;
      --i;
    }

    vector<pair<int, int>> e(m);
    each (i, e) {
      cin >> i.first >> i.second;
      --i.first;
      --i.second;
    }
    
    UnionFind uf(n);
    each (i, v) uf.make(i);

    each (i, e) {
      uf.unite(i.first, i.second);
    }
    for (int i = 0; i < n; ++i) {
      uf.find(i); 
    }

    // {
    //   set<int> s;
    //   for (int i = 0; i < n; ++i) {
    //     s.insert(uf.find(i));
    //   }
    //   cout << s.size() << endl;
    // }
    
    set<int> p[n];
    for (int i = 0; i < n; ++i) {
      p[uf.find(i)].insert(v[i]);
    }

    vector<int> idx[n];
    for (int i = 0; i < n; ++i) {
      idx[uf.find(i)].push_back(i);
    }

    // for (int i = 0; i < n; ++i) {
    //   if (p[i].size()) {
    //     cout << "# ";
    //     each (j, p[i]) cout << j + 1 << ' '; cout << endl;
    //   }
    // }

    // for (int i = 0; i < n; ++i) {
    //   if (idx[i].size()) {
    //     cout << "> ";
    //     each (j, idx[i]) cout << j+1 << ' '; cout << endl;
    //   }
    // }

    int sum = 0;
    for (int i = 0; i < n; ++i) {
      each (j, idx[i]) {
        sum += p[i].count(j);
      }
    }
    cout << sum << endl;
    // cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 17024
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define int long long
#define INF 1<<40
#define N 100
using namespace std;
signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a + 2 * sqrtl(a) * sqrtl(b) + b < c) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $a, $b);

$d = $b - $a;
$sum = 0;

for ($i = 1; $i < 499500; $i++) {
    $sum += $i;

    if ($i === $d) {
        echo $sum - $b . PHP_EOL;
        exit();
    }
}

Measured memory_bytes: 4604
l = input().split()

if l[0] > l[1]:
    a = l[0]; l[0] = l[1]; l[1] = a

if l[1] > l[2]:
    a = l[1]; l[1] = l[2]; l[2] = a
if l[0] > l[1]:
    a = l[0]; l[0] = l[1]; l[1] = a

print(l[0], l[1], l[2])



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

//int _; 

int n,ans=0,a[3];
string s;
 
int main()
{
	//for(scanf("%d",&_);_;_--)
	long long n,k;
	long long ans=0;
	cin >> n >> k;
	for(long long i=k;i <= n+1;i++)
	{
		ans += (n-i+1)*i+1;
	}
	
	cout << ans%(long long)(10e8+7) << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int atime(int x){
    return (x+9)/10*10;
}

int btime(int x){
    return atime(x)-x;
}

int main(){
    int a,b,c,d,e,sum=0,ans=0;
    cin >> a >> b >> c >> d >> e;
    sum=atime(a)+atime(b)+atime(c)+atime(d)+atime(e);
    ans=sum-max({btime(a),btime(b),btime(c),btime(d),btime(e)});
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define N 100010
ll n,q;
vector<ll> a;
ll BN(ll key){
	ll l=0,r=a.size(),m;
	while(l<r-1){
		m=(l+r)/2;
		if(a[m]<key)l=m;
		else r=m;
	}
	return l;
}
ll cntn[N],cntm[N];
void upd(ll i){
	ll x=a[i];
	while(true){
		if(x<a[0]){
			cntn[x]+=cntm[i];
			break;
		}
		ll t=BN(x);
		cntm[t]+=x/a[t]*cntm[i];
		x%=a[t];
	}
}
ll ans[N];
int main(){
	cin>>n>>q;
	a.push_back(n);
	for(int i=0;i<q;i++){
		ll x;cin>>x;
		while(a.size()>0){
			if(a[a.size()-1]<x)break;
			a.pop_back();
		}
		a.push_back(x);
	}
	for(int i=0;i<N;i++)cntn[i]=cntm[i]=0; cntm[a.size()-1]=1;
	for(int i=a.size()-1;i;i--)upd(i);
	cntn[a[0]]=cntm[0];
	ll sum=0;
	for(int i=n;i;i--){
		sum+=cntn[i];
		ans[i]=sum;
	}
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 4980
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

const ll MOD = 1000000007;

int main() {
	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	ll dw = k * (k-1) / 2;
	ll up = n * (n+1) / 2 - (n-k) * (n-k+1) / 2;
	ans += up - dw + 1;
	ans %= MOD;
	
	for (int i = k + 1; i <= n + 1; i++) {
		up += n - i + 1;
		dw += i - 1;
		ans += up - dw + 1;
		ans %= MOD;
	}

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

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

class BIT{
private:
	vector<int64> bit;
	int32 n;
public:
	BIT(){}
	BIT(int32 n):n(n+1){
		bit.resize(this->n, 0);
	}

	void add(int32 k, int32 x){
		k++;
		while(k <= n){
			bit[k] += x;
			k += k&-k;
		}
	}

	int64 sum(int32 k){
		k++;
		int64 res = 0;
		while(k){
			res += bit[k];
			k -= k&-k;
		}
		return res;
	}
};

int main(void){
	int32 n;
	int64 K;
	vector<int64> a;
	cin >> n >> K;
	a.resize(n);
	REP(i, n){
		cin >> a[i];
		a[i] -= K;
		if(i)
			a[i] += a[i-1];
	}
	vector<int64> b = a;
	b.push_back(0);
	sort(all(b));
	b.erase(unique(all(b)), b.end());
	map<int64, int64> zip, unzip;
	REP(i, b.size()){
		zip[b[i]] = i;
		unzip[i] = b[i];
	}
	BIT bit(n+1);
	bit.add(zip[0], 1);
	int64 res = 0;
	REP(i, n){
		res += bit.sum(zip[a[i]]);
		bit.add(zip[a[i]], 1);
	}
	cout << res << endl;
}

Measured memory_bytes: 31460
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$x = $key->A[0];
$y = $key->A[1];

printf("%d\n",($x-1)*($y-1));


Measured memory_bytes: 3700
N=int(input())
H=[0]+list(map(int,input().split()))
a='Yes'
for i in range(1,N):
    if H[i] - 1 <= H[i+1] and H[i-1] <= H[i] - 1:
        H[i] -= 1
    elif H[i] <= H[i+1]:
        continue
    else:
        a='No'
        break
print(a)


Measured memory_bytes: 63856
n, x = map(int,input().split())
l = list(map(int,input().split()))

li = [0]
for i in range(n):
    li.append(l[i]+li[i])

flag = True
for i in range(n+1):
    if li[i]>x:
        ans = i
        flag = False
        break

if flag:
    print(n+1)
else:
    print(ans)


Measured memory_bytes: 3060
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
using pii = pair<int, int>;
const int N = 100005;

int n;
pii a[N];


int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].ff,
        a[i].ss = i + 1;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i)
        cout << a[i].ss << " \n"[i + 1 == n];
}

Measured memory_bytes: 1664
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

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

  const int MAXP = 130000*2+1;
  bool prime[MAXP];
  fill(prime, prime+MAXP, true);
  prime[0] = prime[1] = false;
  for(int i=2;i<MAXP;++i)
	if(prime[i])
	  for(int j=i+i;j<MAXP;j+=i) prime[j] = false;

  int dp[MAXP];
  fill(dp, dp+MAXP, 0);
  for(int i=2;i<MAXP;++i)
	dp[i] = dp[i-1] + (prime[i]? 1: 0);
	
  while(true){
	int N; cin >> N; if(!N) break;
	cout << dp[N*2] - dp[N] << endl;
  }
  
  return 0;
}

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

int main(){
  int fx,fy,tx,ty;cin>>fx>>fy>>tx>>ty;
  
  // 1st
  cout<<string(ty-fy,'U')<<string(tx-fx,'R')<<string(ty-fy,'D')<<string(tx-fx,'L');
  // 2nd
  cout<<"L"<<string(ty-fy+1,'U')<<string(tx-fx+1,'R')<<"DR"<<string(ty-fy+1,'D')<<string(tx-fx+1,'L')<<"U"<<endl;
  return 0;
}

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

 
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	
	int n, a, b;
	
	cin >> n >> a >> b;
	
	cout << min(n*a, b) << "\n";
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		String t = sc.next();
		int a = 0;
		if (s.charAt(0) == (t.charAt(0))) {
			a += 1;
		}
		if (s.charAt(1) == (t.charAt(1))) {
			a += 1;
		}
		if (s.charAt(2) == (t.charAt(2))) {
			a += 1;
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 10;
ll a, b, c;
bool np[maxn];
vector<int> p;

void solve() {
	cin >> a >> b;
	c = __gcd(a, b);
	for (int i = 2; i < maxn; ++i) {
		if (!np[i]) {
			p.push_back(i);
		}
		for (int j = 0; j < p.size() && i * p[j] < maxn; ++i) {
			np[i * p[j]] = 1;
			if (i % p[j] == 0)break;
		}
	}
	int ans = 0;
	for (int i = 0; i < p.size(); ++i) {
		if (1ll*p[i]*p[i] > c) {
			break;
		}
		if (c % p[i] == 0) {
			while (c % p[i] == 0) {
				c /= p[i];
			}
			++ans;
		}
	}
	if (c != 1)++ans;
	cout << ans + 1 << endl;
}
int main() {
	solve();

	return 0;
}

Measured memory_bytes: 3444
rate = int(input())


if 400 <= rate < 600:
  print('8')
elif 600 <= rate < 800:
  print('7')
elif 800 <= rate < 1000:
  print('6')
elif 1000 <= rate < 1200:
  print('5')
elif 1200 <= rate < 1400:
  print('4')
elif 1400 <= rate < 1600:
  print('3')
elif 1600 <= rate < 1800:
  print('2')
else:
  print('1')

Measured memory_bytes: 9180
from collections import Counter
N, C = map(int,input().split())

D = [list(map(int,input().split())) for i in range(C)]
c = [list(map(int,input().split())) for i in range(N)]

ls = [Counter ([c[i][j] for i in range(N) for j in range(N) if (i+j)%3 == k]) for k in range(3)]

result = float("inf")
for i in range(C):
    for j in range(C):
        if i==j:
            continue
        for k in range(C):
            if i==k or j==k:
                continue
            tt = 0
            for l in range(1,C+1):
                tt += ls[0][l] * D[l-1][i]
                tt += ls[1][l] * D[l-1][j]
                tt += ls[2][l] * D[l-1][k]
            result = min(tt, result)
 
print(result)


Measured memory_bytes: 6672
N = int(input())
INF = 10**6
dp = [INF] * (max(9, N)+1)
dp[0] = 0
for i in range(N):
  n = m = 0
  while i+9**n <= N:
    dp[i+9**n] = min(dp[i+9**n], dp[i] + 1)
    n += 1
  while i+6**m <= N:
    dp[i+6**m] = min(dp[i+6**m], dp[i] + 1)
    m += 1
print(dp[N])


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

using namespace std;

struct teme {
	int num;
	int caPro;
	int sumtime;
	int pro[11];
};

void temeset(teme* t, int yoso) {
	for (int i = 1; i <= yoso; i++) {
		t[i].num = i;
		t[i].caPro = 0;
		t[i].sumtime = 0;
		for (int j = 1; j <= 10; j++) {
			t[i].pro[j] = 0;
		}
	}
}

int comp(const void*  A,const void* B) {
	const teme* a = (const teme*)A;
	const teme* b = (const teme*)B;

	if (b->caPro == a->caPro)
	{
		if (b->sumtime == a->sumtime) {
			return b->num - a->num;
		}
		return a->sumtime - b->sumtime;
	}
	return b->caPro - a->caPro;
}

int main() {
	int w, t, p, r;
	vector<string>v;
	while (cin >> w >> t >> p >> r, w || t || p || r) {
		teme te[51];
		temeset(te, t);
		for (int i = 0; i < r; i++) {
			int mk, tk, pk, jk;
			cin >> mk >> tk >> pk >> jk;
			if (jk == 0) {
				te[tk].caPro++;
				te[tk].sumtime += mk + te[tk].pro[pk];
			}
			else {
				te[tk].pro[pk] += 20;
			}
		}
		qsort(te+1, t, sizeof(teme), comp);
		string s = "";
		for (int i = 1; i <= t; i++) {
			//cout << te[i].num << "???:" << te[i].caPro << " " << te[i].sumtime << endl;
			s += to_string(te[i].num);
			if (i != t) {
				if (te[i].caPro == te[i + 1].caPro && te[i].sumtime == te[i + 1].sumtime) {
					s += "=";
				}
				else {
					s += ",";
				}
			}
		}
		v.push_back(s);
	}

	for (int i = 0; i < v.size(); i++) {
		cout << v[i] << endl;
	}
}

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

#define MAX 100000
#define NIL -1

struct Node {int p, l, r;};

Node T[MAX];
int n;
int D[MAX]; // 各ノードの深さ

void print(int u) {
    int i, c;

    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) {
        cout << "root, ";
    } else if (T[u].l == NIL) {
        cout << "leaf, ";
    } else {
        cout << "internal node, ";
    }

    cout << "[";

    // iはカンマの調整のため
    for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

void setDepth(int u, int d) {
    D[u] = d;
    if (T[u].r != NIL) setDepth(T[u].r, d);
    if (T[u].l != NIL) setDepth(T[u].l, d + 1);
}

int main() {
    int i, j, id, degree, c, l, root;
    cin >> n;
    for (i = 0; i < n; i++) {
        T[i].p = NIL;
        T[i].l = NIL;
        T[i].r = NIL;
    }

    for (i = 0; i < n; i++) {
        cin >> id >> degree;
        for (j = 0; j < degree; j++) {
            cin >> c;
            T[c].p = id;
            if (j == 0) T[id].l = c;
            else T[l].r = c;
            l = c;
        }
    }

    // rootを探す
    for (i = 0; i < n; i++) {
        if (T[i].p == NIL) root = i;
    }

    setDepth(root, 0);

    for (i = 0; i < n; i++) print(i);

    return 0;
}



Measured memory_bytes: 7744
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n, m;
    int a[50+5], b[50+5];
    int c[50+5], d[50+5];
    scanf("%d %d", &n, &m);
    for(int i=0; i<n; i++)scanf("%d %d", &a[i], &b[i]);
    for(int i=0; i<m; i++)scanf("%d %d", &c[i], &d[i]);
    
    for(int i=0; i<n; i++){
        int min=200000001;
        int mini;
        for(int j=0; j<m; j++){
            int l=abs(a[i]-c[j])+abs(b[i]-d[j]);
            if(min>l){
                min=l;
                mini=j;
            }
        }
        printf("%d\n", mini+1);
    }
    return 0;
}


Measured memory_bytes: 1704
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

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

    vector<ll> b0(61, 0), b1(61, 0);
    for(int i=0; i<N; i++){
        for(int j=0; j<61; j++){
            if((A[i]>>j)%2 == 0) b0[j]++;
            else b1[j]++;
        }
    }

    ll ans = 0;
    const ll MOD = 1e9+7;
    for(int i=0; i<61; i++){
        ans += (b0[i]*b1[i]%MOD)*(((ll)1<<i)%MOD);
        ans %= MOD;
    }

    // for(int i=0; i<60; i++) cout << b0[i] << " "; cout << endl;
    // for(int i=0; i<60; i++) cout << b1[i] << " "; cout << endl;
    cout << ans << endl;
}

Measured memory_bytes: 2560
# Problem B - Multiplication 2

# input
N = int(input())
a_nums = list(map(int, input().split()))

# initialization
sum = 1

# calc
if 0 in a_nums:
    print(0)
else:
    for a in a_nums:
        sum *= a
        if sum>10**18:
            sum = -1
            break

    # output
    print(sum)


Measured memory_bytes: 21600
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) {
        cin>>a[i];
        --a[i];
    }
    vec ord(N);
    rep(i,N) ord[i] = i;
    sort(ord.begin(), ord.end(), [&](ll x, ll y){
        return a[x] < a[y];
    });
    rep(i,N) {
        cout<<ord[i] + 1;
        if(i != N -1 ) cout<<' ';
    }
    cout<<endl;
}

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

int main(void){
    ll ans=0,n,m;cin>>n;
    for(ll i=1;i*i<n;i++){
        if(n%i==0){
            m=n/i;
            if(n%(m-1)!=0)ans+=m-1;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


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

int main() {
  int x;
  cin >> x;
  if(x == 3){
    
    cout << "YES" <<endl;
  }
  else if(x == 5){
    cout << "YES" <<endl;
  }
  else if(x == 7){
    cout << "YES"<<endl;
  }
  else{
    cout << "NO" <<endl;
  }
}

Measured memory_bytes: 256
from collections import deque, Counter

def BFS(st,c):

  dist=[-1 for i in range(n)]
  dist[st]=0

  que=deque()
  que.append(st)

  while que:
    x=que.popleft()
    for i in tree[x]:
      if dist[i]==-1:
        dist[i]=dist[x]+1
        que.append(i)

  c+=dist

n,x,y=map(int,input().split())

tree=[[] for i in range(n)]
for i in range(n-1):
  tree[i].append(i+1)
  tree[i+1].append(i)

x-=1
y-=1
tree[x].append(y)
tree[y].append(x)

c=[]

for i in range(n):
  BFS(i,c)

count=Counter(c)

for i in range(1,n):
  print(count[i]//2)

Measured memory_bytes: 133092
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main () {
  ll n, k; cin>>n>>k;
  vector <ll> a (n);
  for (auto &i : a) cin>>i;
  ll dp[n]; dp[0]=0;
  for (ll i=1;i<n;++i) {
    ll temp=1e18;
    for (ll j=1;i-j>=0 && j<=k;++j) {
      temp=min(temp, dp[i-j]+abs(a[i]-a[i-j]));
    }
    dp[i]=temp;
  }
  cout<<dp[n-1];
  return 0;
}

Measured memory_bytes: 1792
/*Bismillahir Rahmanir Rahim*///{
#include <bits/stdc++.h>
using namespace std;
using ll = long long; using ull = unsigned long long; using ld = long double;
const ll llinf = (1ll<<61)-1;
const double eps = 1e-6, ldeps = 1e-9;
struct Dbg {
static constexpr auto &os = cout;   // replace by cerr in interactive.
template<class C> static auto dud(C *x)->decltype(os << *x, 0);
template<class C> static char dud(...);
template<class C> typename enable_if<sizeof dud<C>(0)!=1, Dbg&>::type operator<<(const C &x) { os << x; return *this; }
template<class C> Dbg &dump(C b, C e) {
    *this << "\n[";
    int cur = 0;
    for (C i = b; i!=e and cur<26; i++, cur++) *this << ", "+2*(i==b) << *i;
    return *this << ']';
}
template<class C> typename enable_if<sizeof dud<C>(0)==1, Dbg&>::type operator<<(const C &x) {
    return dump(begin(x), end(x));
}
template<class C, size_t X> typename enable_if<sizeof(C)!=1, Dbg&>::type operator <<(C (&x)[X]) {
    return dump(begin(x), end(x));
}
template<class B, class C> Dbg &operator <<(const pair<B, C> &x) {
    return *this << '{' << x.first << ", " << x.second << '}';
}
template<class C, size_t Y> struct TP {
    void operator()(Dbg& os, const C &t) { TP<C, Y-1>()(os, t); os << ", " << get<Y-1>(t); }
};
template<class C> struct TP<C, 1> { void operator()(Dbg& os, const C &t) { os << get<0>(t); } };
template<class... C> Dbg& operator<<(const tuple<C...> &t) {
    os << '{', TP<decltype(t), sizeof...(C)>()(*this, t); return *this << '}';
}
Dbg &operator<<(ostream&(*x)(std::ostream&)) { os << x; return *this; }
} dbg;
void err(istringstream *iss) { delete iss; }
template<class C, class... Args> void err(istringstream *iss, const C &val, const Args &... args) {
    string name; *iss >> name; if (name.back()==',') name.pop_back();
    dbg << name << " = " << val << "; ", err(iss, args ...);
}
#define bug(args...) dbg << __LINE__ << ": ", err(new istringstream(string(#args)), args), dbg << endl
#define sl(a) int(strlen(a))
#define sz(a) int(a.size())
int T, Q, cn;//}
const int inf = 1000000007, mxn = 105, mxw = 305;

int n, W, w[mxn], v[mxn], w1, memo[mxn][mxn][mxw];
bitset<mxw> vstd[mxn][mxn];
int dp(int at, int cntTaken, int weightTaken) {
    int actualWeightTaken = cntTaken*w1+weightTaken;
    if (actualWeightTaken>W) return -inf;
    if (at==n+1) return 0;
    auto &ret = memo[at][cntTaken][weightTaken];
    if (vstd[at][cntTaken][weightTaken]) return ret;
    vstd[at][cntTaken][weightTaken] = 1;
    ret = max(v[at]+dp(at+1, cntTaken+1, weightTaken+w[at]), dp(at+1, cntTaken, weightTaken));
    return ret;
}

signed main() { ios::sync_with_stdio(0); cin.tie(NULL); cout.precision(11);
/*
Every element has at least w[1] weight, so we can subtract w[1] from each w[i] and express W as sum(w[i])+w[1]*cntTaken.
 ==> dp[at][cntTaken][weightTaken].
*/
    cin >> n >> W;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> v[i];
        if (i==1) w1 = w[i];
        w[i] -= w1;
    }
    cout << dp(1, 0, 0) << '\n';
}

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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[100005];

template<typename T>
struct SegmentTree {
    using F = function<T(T, T)>;

    SegmentTree(F func, T id)
            : merge(func), identity(id) {}

    void init(ll n) {
        offset = 1;
        while (offset < n)
            offset <<= 1;
        node.assign(offset << 1, identity);
    }

    void build(const vector<T> &v) {
        int n = static_cast<int>(v.size());
        init(n);
        for (int i = 0; i < n; ++i) {
            node[offset + i] = v[i];
        }
        for (int i = offset - 1; i >= 0; --i) {
            node[i] = merge(node[(i << 1) | 0], node[(i << 1) | 1]);
        }
    }

    void set(int index, T value) {
        index += offset;
        node[index] = value;
        while (index >>= 1) {
            node[index] = merge(node[(index << 1) | 0], node[(index << 1) | 1]);
        }
    }

    //! [left, right]
    T get(int left, int right) {
        left += offset;
        right += offset + 1;

        T val = identity;
        while (left < right) {
            if (left & 1)
                val = merge(val, node[left++]);
            if (right & 1)
                val = merge(val, node[--right]);

            left >>= 1;
            right >>= 1;
        }
        return val;
    }

    T identity;
    F merge;
    vector<T> node;
    int offset;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    string S;
    cin >> N >> M;
    cin >> S;
    SegmentTree<ll> seg([](ll a, ll b) { return std::min(a, b); }, INF);
    seg.init(N + 1);
    seg.set(N, 0);
    for (ll i = N; i >= 0; --i) {
        if (S[i] == '1')
            continue;
        seg.set(i, 1 + seg.get(i, std::min(i + M, N)));
        dp[i] = seg.get(i, i);
    }

    if (dp[0] == INF) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> v;
    ll num = dp[0] - 1;
    ll index = 0;
    REP(i, N + 1) {
        if (num != dp[i])
            continue;
        v.push_back(i - index);
        num--;
        index = i;
    }

    REP(i, v.size()) {
        cout << v[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 4296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);

long long modpow(long long a, long long n, long long MOD) {//a^n(MOD)を求める
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}

ll dp[410][410]={};

signed main(){
    int n,c;cin>>n>>c;

    vector<ll> a(n),b(n);
    rep(i,0,n)cin>>a[i];
    rep(i,0,n)cin>>b[i];

    vector<vector<ll>> sum(410,vector<ll>(410,0));

    rep(i,0,410){
        rep(j,1,410){
            sum[i][j]=sum[i][j-1]+modpow(j,i,mod);
            sum[i][j]%=mod;
        }
    }

    dp[0][0]=1;

    rep(i,0,n)rep(j,0,c+1)rep(k,0,c-j+1){
        dp[i+1][j+k]+=dp[i][j]*(sum.at(k).at(b[i])+mod-sum.at(k).at(a[i]-1));
        dp[i+1][j+k]%=mod;
    }

    cout<<dp[n][c]<<endl;
}

Measured memory_bytes: 2816
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()
ans = 0
print(N*(N-1)//2)


Measured memory_bytes: 4076
#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() {
  ll n, m, ans;
  cin >> n >> m;
  if (n == 1 && m == 1)
    ans = 1;
  else if (n == 1)
    ans = m - 2;
  else if (m == 1)
    ans = n - 2;
  else if (n == 2 || m == 2)
    ans = 0;
  else
    ans = (n - 2) * (m - 2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#関数リスト
import sys
import math
input = sys.stdin.readline

 
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def num_divisors_table(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table
n = I()
table = num_divisors_table(n)

result = 0
for i, k in enumerate(table):
    result += i * k

print(result)

Measured memory_bytes: 146092
//#include <bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
//----------program from here----------




int main(){
    
    int n,m;
    string s[110],t[110];

    cin>>n;
    REP(i,n){
        cin>>s[i];
    }
    s[n]="takahasityokudaisanhatotemoikemendayo";
    n++;

    cin>>m;
    REP(i,m){
        cin>>t[i];
    }

    int sum=0;
    int mx=-10000000;
    REP(i,n){
        sum=0;
        REP(j,n){
            if(s[i]==s[j])sum++;
        }
        REP(j,m){
            if(s[i]==t[j])sum--;
        }
        if(i==n-1)sum--;
        mx=max(mx,sum);

    }
    
    cout<<mx;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 55
 
int H,W,D,N,r[10],X,Y;
char field[MAX][MAX];
bool visited[MAX][MAX];
bool treasure[MAX][MAX];
bool possible[MAX][MAX];
const int dx[] = {-1,0,0,1};
const int dy[] = {0,-1,1,0};
typedef pair<int,int> P;
 
bool inField(int y,int x){
    return 0 <= y && y < H && 0 <= x && x < W;
}
 
bool check(int y,int x,int r){
    int x1 = x - r, x2 = x + r;
    int y1 = y - r, y2 = y + r;
    return x1 <= X && X <= x2 && y1 <= Y && Y <= y2;
}
 
void search(int y,int x,int s){
    if(visited[y][x]) return;
    visited[y][x] = true;
 
    if(s == 0){
	if(check(y,x,r[0]) && field[y][x] != '#'){
	    treasure[y][x] &= true;
	}else{
	    treasure[y][x] &= false;
	}
    }else if(s == D){
	if(!check(y,x,r[D-1]) && field[y][x] != '#'){
	    treasure[y][x] &= true;
	}else{
	    treasure[y][x] &= false;
	}
    }else{
	if(!check(y,x,r[s-1]) && check(y,x,r[s]) && field[y][x] != '#'){
	    treasure[y][x] &= true;
	}else{
	    treasure[y][x] &= false;
	}
    }
 
    for(int i = 0 ; i < 4 ; i++){
	int nx = x + dx[i];
	int ny = y + dy[i];
	if(!inField(ny,nx)) continue;    
	search(ny,nx,s);
    }
}
 
void bfs(int y,int x){
    memset(possible,false,sizeof(possible));
    queue<P> Q; Q.push(P(y,x));
    while(!Q.empty()){
	P now = Q.front(); Q.pop();
	x = now.second; y = now.first;
	if(possible[y][x]) continue;
	possible[y][x] = true;
	for(int i = 0 ; i < 4 ; i++){
	    int nx = x + dx[i];
	    int ny = y + dy[i];
	    if(!inField(ny,nx) || field[ny][nx] == '#') continue;
	    Q.push(P(ny,nx));
	}
    }
}
 
int main(){
    cin >> H >> W >> D >> N;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    cin >> field[i][j];
	    if(field[i][j] == 'D'){
		X = j; Y = i;
	    }
	    treasure[i][j] = true;
	}
    }
    bfs(Y,X);
    for(int i = 0 ; i < D ; i++){
	cin >> r[i];
    }
    for(int i = 0 ; i < N ; i++){
	int x,y,s;
	cin >> x >> y >> s; 
	memset(visited,false,sizeof(visited));
	X = x, Y = y; 
	search(y,x,s);
    }
    bool broken = true, c1 = false, c2 = false;
    for(int i = 0 ; i < H ; i++){
	for(int j = 0 ; j < W ; j++){
	    if(treasure[i][j]) broken = false;
	    if(possible[i][j] && treasure[i][j]) c1 = true;
	    if(!possible[i][j] && treasure[i][j]) c2 = true;
	}
    }
 
    if(broken){
	cout << "Broken" << endl;
    }else if(c1 && c2){
	cout << "Unknown" << endl;
    }else{
	cout << (c1 ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 3220
//

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main(){
	double R;
	cin >> R;

	double ans = M_PI * R * 2.0;

	cout << fixed << setprecision(10);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3784
import java.util.*;
import java.io.*;

public class Main implements Runnable{
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException{
        new Thread(null, new Main(), "", 32 * 1024 * 1024).start();
        Thread.setDefaultUncaughtExceptionHandler((t,e)->System.exit(1));
        out.flush();
    }

    public void run(){
        int N = Integer.parseInt(sc.next());
        if(N%2 != 0){
            N = N+1;
        }
        out.println(N/2);
        out.flush();
    }

}

Measured memory_bytes: 27008
#include<stdio.h>
int main(void){
    int N,A[100],i,j,flag=1,count=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    while(flag){
        flag=0;
        for(i=0;i<N-1;i++){
            if(A[i]>A[i+1]){
                j=A[i];
                A[i]=A[i+1];
                A[i+1]=j;
                flag=1;
                count++;
            }
        }
    }
    for(i=0;i<N;i++){
        if(i!=0){
            printf(" ");
        }
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2000
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=100010;
const ll mod=1e9+7;
#define bit(n,k) ((n>>k)&1) //*n no k bit me 1 or 0*/


int main(){

  int n,m;
  cin >> n >> m;
  if(m%n==0){ cout << m/n << endl; return 0; }
  
  int ans=m/n+1;
  while(ans>0){
    if(m%ans==0){break;}
    ans--;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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>
using namespace std;
#define int long long
#define all(arr) arr.begin(),arr.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vstr vector<string>
#define vbool vector<bool>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define vpair vector<pii > 
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) {cout<<a[i]<<' ';}cout<<'\n'
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,a,b) for (int i = a; i < b; i++)
#define loope(i,a,b) for (int i = a; i <= b; i++)
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::fixed );std::cout.precision(9)
#define PI 3.14159265
#define S second
#define F first
#define CHECK cout<<"CHEDEDWB"<<endl
#define br '\n'
/*int mod = 1e9+7;
int inf = 1e18;
int m_inf = INT_MIN;
int MOD = 100001;*/

void solve()
{
	int n;
	cin>>n;
	vi arr(n);
	cout<<n*n*n<<endl;
}

int32_t main()
{
	FastIO; PRECISION;
	int t = 1;
	//cin>>t;
	while(t--)
		solve();
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>

using namespace std;

int main(){
	string s;
	cin >> s;

	if (s == "Sunny"){
		cout << "Cloudy" << endl;
	}else if (s == "Cloudy"){
		cout << "Rainy" << endl;
	}else if (s == "Rainy"){
		cout << "Sunny" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			int points[] = new int[n];
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < 5; j++)
				{
					points[i] += sc.nextInt();
				}
			}
			Arrays.sort(points);
			System.out.printf("%d %d\n", points[n-1], points[0]);
		}
	}
}

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

int main() {
    int n;
    cin >> n;
    int mark,input;
    cin >> mark;
    rep(i,n-1){
        cin >> input;
        if(input<mark){
            if(mark - input >= 2){
                cout << "No"<<endl;
                return 0;
            }
        }else if(input>=mark){
            mark = input;
        }
    }
    cout << "Yes"<<endl;
}

Measured memory_bytes: 3552
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
a = list(li())

zer_rew = [0]*40
one_rew = [0]*40

for idx in range(39,-1,-1):
    bit = 1<<idx
    
    for ai in a:
        if ai & bit:
            zer_rew[39-idx] += bit
        else:
            one_rew[39-idx] += bit
            
INF = float('inf')
dp = [[-INF, 0] for _ in range(41)]
for digit in range(40):
    if k & (1<<(39-digit)):
        dp[digit+1][1] = dp[digit][1] + one_rew[digit]
        
        dp[digit+1][0] = max(dp[digit][1] + zer_rew[digit],
                             dp[digit][0] + zer_rew[digit],
                             dp[digit][0] + one_rew[digit])
        
    else:
        dp[digit+1][1] = dp[digit][1] + zer_rew[digit]
        
        dp[digit+1][0] = max(dp[digit][0] + zer_rew[digit],
                             dp[digit][0] + one_rew[digit])
        
print(max(dp[-1]))

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

int main(){

    int N;
    cin >> N;

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

    vector<int> q;
    copy(p.begin(),p.end(),back_inserter(q));

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

    int count = 0;
    for(int i=0;i<N;i++){
        if(p[i]!=q[i])count++;
        if(count>2){
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" <<endl;
    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"                                                  
#define HOUR 3600
#define MINUTE 60
int main(void){
int S;
int h,m,s;
scanf("%d",&S);
h=S/HOUR;
m=S%HOUR/MINUTE;
s=S%HOUR%MINUTE;
printf("%d:%d:%d\n",h,m,s);
return 0;
}

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

int gcd(int x, int y){
    int r;
    while((r = x % y) != 0){
        x = y;
        y = r;
    }
    return y;
}

int main(){
    int N, X, max = 0;
    cin >> N >> X;
    int x[100000], min = 1000000001;
    for(int i=0;i<N;i++)
        cin >> x[i];
    //sort(x, x + N);
    if(N > 2){
        int s[100000];
        for(int i=0;i<N;i++){
            s[i] = abs(X - x[i]);
        }
        for(int i=0;i<N;i++){
            max = gcd(max, s[i]);
        }
        cout << max << endl;
    }else if(N == 2){
        int s1, s2;
        s1 = abs(X - x[0]);
        s2 = abs(X - x[1]);
        max = gcd(s1, s2);
        cout << max << endl;
    }else{
        cout << abs(X - x[0]) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
a = Array.new(4){Array.new(3){Array.new(10,0)}}
(gets.to_i).times do
  c = gets.split.map(&:to_i)
  a[c[0]-1][c[1]-1][c[2]-1] += c[3]
end
4.times do |i|
  3.times do |j|
    print " ", a[i][j].join(" "),"\n"
  end
  if (i < 3) then
    puts "#"*20
  end
end

Measured memory_bytes: 6112
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int k = scn.nextInt();
      	int ans = n-k;
      	if(k==1) ans = 0;
      	System.out.println(ans);
	}
}


Measured memory_bytes: 35700
#include<stdio.h>
#include<string.h>
int main(){
  int dice[7],a,b,ans,len;
  char couse[101];
  for(a=1;a<=6;a++){
    scanf("%d",&dice[a]);
  }
  scanf("%s",couse);
  len=strlen(couse);
  for(a=0;a<len;a++){
    if(couse[a]=='S'){
      b=dice[1];
      dice[1]=dice[5];
      dice[5]=dice[6];
      dice[6]=dice[2];
      dice[2]=b;
      
    }
    if(couse[a]=='W'){
      b=dice[1];
      dice[1]=dice[3];
      dice[3]=dice[6];
      dice[6]=dice[4];
      dice[4]=b;
    }
    if(couse[a]=='N'){
      b=dice[1];
      dice[1]=dice[2];
      dice[2]=dice[6];
      dice[6]=dice[5];
      dice[5]=b;
    }
    if(couse[a]=='E'){
      b=dice[1];
      dice[1]=dice[4];
      dice[4]=dice[6];
      dice[6]=dice[3];
      dice[3]=b;
    }
  }
  printf("%d\n",dice[1]);
  return 0;
}

Measured memory_bytes: 596
s = list(map(int , input()))
l =len(s)

import copy
s1 = copy.copy(s)
s2 = copy.copy(s)

cnt1,cnt2 = 1, 0

if s1[0] == 0:
    s1[0] = 1
else:
    s1[0] = 0
for i in range(1,l):
    if s1[i - 1] == s1[i]:
        cnt1 += 1
        if s1[i - 1] == 1:
            s1[i] = 0
        else:
            s1[i] = 1

for j in range(1,l):
    if s2[j - 1] == s2[j]:
        cnt2 += 1
        if s2[j - 1] == 1:
            s2[j] = 0
        else:
            s2[j] = 1

print(min(cnt1,cnt2))

Measured memory_bytes: 5792
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
        
    t = [int(input()) for i in range(n)]
    h = [int(input()) for i in range(m)]

    t_sum = sum(t)
    h_sum = sum(h)

    ans_sum = 10e9
    ans = [0, 0]
    for ti in t:
        for hi in h:
            if t_sum - ti + hi == h_sum - hi + ti and ti + hi < ans_sum:
                ans_sum = ti + hi
                ans = [ti, hi]

    if ans == [0, 0]:
        print(-1)
    else:
        print(ans[0], ans[1])



Measured memory_bytes: 5624