akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
// const int INF = 10000;

//最大公約数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

const int MAX = 1e6+1;
const int MOD = 1e9+7;

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

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

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


//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}

long long modpow(long long res,long long a, long long n, long long mod) {
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//sieve(MAX);でベクトルIsPrimeに「MAXまでの数値の素数の真偽」を格納する。
vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}
// ここから開始

int main(){
    string s;
    cin>>s;
    string t[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i = 0; i < 7; i++){
        if(s==t[i]){
            cout<<7-i<<endl;
            return 0;
        }
    }

    return 0;
}



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

int main(){
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  
  long double rad = PI*2 *(
   (long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);


  long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) * cosl(rad);

cout << fixed << setprecision(20)<<sqrt(rsq) <<endl; 

return 0;
}

Measured memory_bytes: 4092
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef complex<ld> PT;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;
const ld EPS = 1e-12;

istream& operator>> (istream& is, complex<ld>& p){
	ld val;
	is >> val;
	p.real(val);
	is >> val;
	p.imag(val);
	return is;
}

PT proj(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + b*real(c/b);
}

PT reflect(PT a, PT b, PT c){
	b -= a, c -= a;
	return a + conj(c/b)*b;
}

string pos(PT a, PT b, PT c){
	b -= a, c -= a;
	c /= b;
	if (c.imag() > EPS)
		return "COUNTER_CLOCKWISE";
	if (c.imag() + EPS < 0)
		return "CLOCKWISE";
	if (c.real() + EPS < 0)
		return "ONLINE_BACK";
	if (c.real() > 1 + EPS)
		return "ONLINE_FRONT";
	return "ON_SEGMENT";
}

int main(){	
	PT a, b;
	cin >> a >> b;
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		PT p;
		cin >> p;
		cout << pos(a, b, p) << '\n';
	}
	return 0;
}


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

int main() {
  std::string s;
  std::cin >> s;
  for (auto &i : s) {
    if (i == '1') {
      i = '9';
    } else {
      i = '1';
    }
  }

  std::cout << s << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define sz(v) (v).size()
#define all(v) (v).begin(),(v).end()
#define mp make_pair
#define fi first
#define se second
#define inf 1000000000
#define mod 1000000007
using namespace std;
template <class T> void chmax(T &x,T y){x=x>y?x:y;return;}
template <class T> void chmin(T &x,T y){x=x<y?x:y;return;}
typedef long long ll;
typedef unsigned long long ull;

int h,w,k,ans=inf,a[15],s[15][1005],sum[15];

void getans()
{
	//for(int i=1;i<=h-1;i++)
	//	cout<<a[i]<<" ";
	//puts("txt: ");
	
	
	memset(sum,0,sizeof(sum));
	int ind=0,tot=0,ret=0,tmp=0;
	for(int i=1;i<=h-1;i++)
		tmp+=a[i];
	if(tmp>=ans) return;
	for(int i=1;i<=w;i++)
	{
		int cnt=0;
		for(int j=1;j<=h;j++)
		{
			cnt+=s[j][i];
			if(a[j])
			{
				
				//cout<<cnt<<" ";
				
				if(cnt>k) return;
				ind++;
				sum[ind]+=cnt;
				cnt=0;
			}
		}
		
		//cout<<cnt<<endl;
		
		if(cnt>k) return;
		ind++;
		sum[ind]+=cnt;
		cnt=0;
		for(int j=1;j<=ind;j++)
			if(sum[j]>k)
			{
				memset(sum,0,sizeof(sum));
				if(ret+tmp>=ans) return;
				ret++,i--;
				break;
			}
		ind=0;
	}
	//cout<<"res is "<<ret<<" "<<tmp<<" "<<ret+tmp<<endl;
	chmin(ans,ret+tmp);
	return;
}

void dfs(int p)
{
	if(p>=h)
	{
		getans();
		return;
	}
	a[p]=0;
	dfs(p+1);
	a[p]=1;
	dfs(p+1);
	return;
}

string str;

int main()
{
	scanf("%d%d%d",&h,&w,&k);
	for(int i=1;i<=h;i++)
	{
		cin>>str;
		for(int j=1;j<=w;j++)
			s[i][j]=str[j-1]!='0';
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3740
$data = []
ans = []
def culc ope, level
	case ope
	when '+'
		result = 0
	when '*'
		result = 1
	end
	loop{
		if $data.empty? || $data.first.length < level 
			return result
		else
			tmp = $data.first.split("").last.to_s
			if tmp == '*' || tmp == '+'
				ans = culc $data.shift.split("").last.to_s, level + 1
			else
				ans = $data.shift.split("").last.to_i
			end
		end

		case ope
		when '+'
			result += ans
		when '*'
			result *= ans
		end
	}
end

loop{
	num = gets.to_i
	break if num == 0
	num.times do
		$data << gets.chomp 
	end
	if num == 1
		ans << $data.shift
	else
		ans << culc($data.shift ,2)
	end
}

ans.each do |a|
	puts a
end

Measured memory_bytes: 9732
#include <stdio.h>

#define MAX 2000001
#define VMAX 10000

void CountingSort();

int A[MAX],B[MAX];
int C[VMAX+1];


int main(){

  int n, i;


  scanf("%d", &n);

  for ( i = 1; i <= n; i++ )
    scanf("%d",&A[i]);


    CountingSort(VMAX,n);

    for(i = 1; i<=n; i++){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}


void CountingSort(int k,int n){
  
  int i,j;

  for ( i = 0; i <= k; i++ ) 
    C[i] = 0;
  
  //C[i]に iの出現数を記録する
  for ( j = 1; j <= n; j++ ){
    C[A[j]]++;
  }

  //C[i]に i以下の数の出現数を記録する
  for ( i = 1; i <= k; i++ )
    C[i] = C[i] + C[i - 1];

  for ( j = n ; j >0; j-- ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}

Measured memory_bytes: 16268
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
		long h = long.Parse(input[0]);
		long w = long.Parse(input[1]);
    long[,] dp = new long[h+1,w+1];//右下を角とする最大の正方形の長さ
    long answer = 0;

    for(long hh = 1; hh <= h; hh++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      for(long ww = 1; ww <= w; ww++)
      {
        if(nums[ww-1] == 1) dp[hh,ww] = 0;
        else
        {
          dp[hh,ww] = dp[hh-1,ww-1] + 1;
          dp[hh,ww] = Math.Min(dp[hh,ww], dp[hh,ww-1] + 1);
          dp[hh,ww] = Math.Min(dp[hh,ww], dp[hh-1,ww] + 1);
          answer = Math.Max(answer, dp[hh,ww]);
        }
      }
    }
    
		Console.WriteLine(answer*answer);
	}
}


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

int main() {
    string s,t;
    cin >> s;
    cin >> t;
    string check = t.substr(0,t.length() - 1);
    //cout << check << endl;
    if (s == check) {
        cout <<"Yes\n";
    }
    else {
        cout << "No\n";
    }
}

Measured memory_bytes: 3624
def binary_search(S, key):
    S_len = len(S)

    if S_len == 0:
        return -1

    mid = S_len // 2

    if S[mid] == key:
        return 1

    if S[mid] >= key:
        return binary_search(S[:mid], key)
    else:
        return binary_search(S[mid + 1:], key)

n = int(input())
S = [int(i) for i in input().split(' ')]

q = int(input())
T = [int(i) for i in input().split(' ')]

result = 0

for t in T:
    left, right = 0, n
    while left < right:
        mid = (right + left) // 2
        if S[mid] == t:
            result += 1
            break

        if S[mid] > t:
            right = mid
        else:
            left = mid + 1

print(result)


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

vector<int> in;

int input(){
  string s;
  if(!(cin>>s))return false;
  in.clear();in.resize(15);
  for(int i=0;i<s.size();i++){
    in[s[i]-'0']++;
  }
  return true;
}

bool dfs(vector<int> &list){
  if(list[0]==4){
    for(int i=0;i<10;i++){
      if(list[i]==2)return true;
    }
    return false;
  }
  for(int i=1;i<10;i++){
    if(list[i]>=3){
      vector<int> tmp = list;
      tmp[i]-=3;
      tmp[0]++;
      if(dfs(tmp))return true;
    }
  }
  for(int i=1;i<10-2;i++){
    if(list[i]>0&&list[i+1]>0&&list[i+2]>0){
      vector<int> tmp = list;
      tmp[i]--;tmp[i+1]--;tmp[i+2]--;
      tmp[0]++;
      if(dfs(tmp))return true;
    }
  }
  return false;
}

bool judge(int n){
  vector<int> list = in;
  list[n]++;
  return dfs(list);
}

vector<int> solve(){
  vector<int> res;
  for(int i=1;i<10;i++){
    if(in[i]==4)continue;
    if(judge(i)){
      res.push_back(i);
    }
  }
  return res;
}

int main(){
  while(input()){
    vector<int> ans;
    ans = solve();
    if(ans.empty()){
      cout<<0<<endl;
    }else{
      for(int i=0;i<ans.size()-1;i++){
        cout<<ans[i]<<" ";
      }cout<<ans[ans.size()-1]<<endl;
    }
  }
}

Measured memory_bytes: 1208
// 5/28
// 2-5-4 ベルマンフォード
// 類題
#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>;
const ll INF = LONG_MAX;

struct Edge {
    int from;
    int to;
    ll cost;
    Edge(int f, int t, ll c) : from(f), to(t), cost(c) { }
    bool operator<(const Edge& o) const {
        return cost < o.cost;
    }
};
using Graph = vector<Edge>;

vector<bool> negative;

vector<ll> bellman_ford(int N, Graph& es, int s) {
    // 初期化
    vector<ll> d(N, INF);
    d[s] = 0;
    
    // vector<bool> negative(N, false);
    negative.assign(N, false);
    // bool have_negative_loop = false;

    // 辺の緩和を反復
    rep(i, N) {
        for (auto e : es) {
            if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == N - 1) {
                    // have_negative_loop = true;
                    negative[e.to] = true;
                    // break;
                }
            }
            if (negative[e.from]) {
                // negative[e.to] = true;
            }
        }
    }

    // ネガティブループが存在する場合は全ての値を-1にする。
    // スタート地点の値でチェックする。
    // if (have_negative_loop) d.assign(N, -1);
    return d;
}

int main() {
    int N;  // 与えられた有向グラフの頂点の数
    int M;  // 同辺の数（辺の重みは負の場合がある）
    cin >> N >> M;

    vector<Edge> es;
    rep(i, M) {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        a--; b--;
        es.push_back(Edge(a, b, -c));
    }

    vector<ll> d;
    d = bellman_ford(N, es, 0);

    // if (d[0] == -1) cout << "inf" << endl;
    if (negative[N - 1]) cout << "inf" << endl;
    else cout << -d[N - 1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <functional>

template<typename T, typename E, typename F, typename G, typename H> class lazy_segment_tree {
	int N;
	std::vector<T> value;
	std::vector<E> lazy;
	std::vector<bool> flag;

	void lazy_eval(const int& i, const int& l, const int& r) {
		if (lazy[i] == id_lz) return;
		value[i] = lz_to_val(value[i], lazy[i], r - l);
		if (r - l > 1) {
			lazy[i * 2] = op_lz(lazy[i * 2], lazy[i]);
			lazy[i * 2 + 1] = op_lz(lazy[i * 2 + 1], lazy[i]);
		}
		lazy[i] = id_lz;
	}

public :
	const F op_val;
	const G op_lz;
	const H lz_to_val;
	const T id_val;
	const E id_lz;

	lazy_segment_tree(const std::vector<T>& a, const F& f, const G& g, const H& h, const T& t, const E& e)
	: op_val(f), op_lz(g), lz_to_val(h), id_val(t), id_lz(e) {
		int n = a.size(), m = 1;
		while (m < n) m *= 2;
		N = m;
		value.resize(N * 2, id_val);
		lazy.resize(N * 2, id_lz);
		flag.resize(N * 2, false);
		for (int i = 0; i < n; i++) value[N + i] = a[i];
		for (int i = N - 1; i > 0; i--) value[i] = op_val(value[i * 2], value[i * 2 + 1]);
	}

	lazy_segment_tree(const int& n, const F& f, const G& g, const H& h, const T& t, const E& e)
	: op_val(f), op_lz(g), lz_to_val(h), id_val(t), id_lz(e) {
		int m = 1;
		while (m < n) m *= 2;
		N = m;
		value.resize(N * 2, id_val);
		lazy.resize(N * 2, id_lz);
		flag.resize(N * 2, false);
	}

	void range_update(const int& L, const int& R, const E& e, const int& i = 1, const int& l = 0, int r = -1) {
		if (r == -1) r = N;
		if (r <= L || R <= l) return;
		if (L <= l && r <= R) {
			lazy[i] = op_lz(lazy[i], e);
			return;
		}
		lazy_eval(i, l, r);
		flag[i] = true;
		range_update(L, R, e, i * 2, l, (l + r) / 2);
		range_update(L, R, e, i * 2 + 1, (l + r) / 2, r);
	}

	T range_fold(const int& L, const int& R, const int& i = 1, const int& l = 0, int r = -1) {
		if (r == -1) r = N;
		if (r <= L || R <= l) return id_val;
		lazy_eval(i, l, r);
		if (L <= l && r <= R && !flag[i]) return value[i];
		if (L <= l && r <= R) flag[i] = false;
		T ret = op_val(
			range_fold(L, R, i * 2, l, (l + r) / 2),
			range_fold(L, R, i * 2 + 1, (l + r) / 2, r)
		);
		if (L <= l && r <= R) value[i] = ret;
		return ret;
	}

	inline const T& operator[](const int& i) {
		range_fold(i, i + 1);
		return value[N + i];
	}
};

int main() {
	int n, q;
	std::cin >> n >> q;
	long long ans = (n - 2ll) * (n - 2ll);

	auto f = [] (int a, int b) {return std::min(a, b);};
	auto g = [] (int a, int b) {return std::min(a, b);};
	auto h = [] (int a, int b, int w) {return std::min(a, b);};
	lazy_segment_tree<int, int, decltype(f), decltype(g), decltype(h)> highest(n, f, g, h, n - 1, n - 1);
	lazy_segment_tree<int, int, decltype(f), decltype(g), decltype(h)> leftest(n, f, g, h, n - 1, n - 1);

	while (q--) {
		int op, x;
		std::cin >> op >> x;
		x--;
		if (op == 1) {
			int m = highest[x];
			ans -= m - 1;
			leftest.range_update(1, m, x);
		} else {
			int m = leftest[x];
			ans -= m - 1;
			highest.range_update(1, m, x);
		}
	}

	std::cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 11712
// Problem : E - Meaningful Mean
// Contest : AtCoder Regular Contest 075
// URL : https://atcoder.jp/contests/arc075/tasks/arc075_c
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using ll = long long;
using namespace std;

// begin of indexed_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<ll, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> indexed_multiset;
// end of indexed_set

#define size(x) (int)x.size()

const int N = 1e6 + 1, mod = 1e9 + 7;

int n, k;
ll ans = 0, a[N];
indexed_multiset im;

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i - 1];
	}
	im.insert({a[n] - 1ll * k * n, n});
	for (int i = n - 1; i >= 0; i--) {
		ans += size(im) - im.order_of_key({a[i] - 1ll * k * i, 0});
		im.insert({a[i] - 1ll * k * i, i});
	}
	cout << ans;
}


Measured memory_bytes: 14336
using System;

class Program{
	static void Main(){
		int a = int.Parse(Console.ReadLine());
		while(0<a--){
			int[] n = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
			Array.Sort(n);
			Console.WriteLine(((n[0]*n[0] + n[1]*n[1] == n[2]*n[2]) ? "YES" : "NO"));
		}
	}
}

Measured memory_bytes: 9040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
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();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class BVotingJudges {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll N, M, V, P;
	    in >> N >> M >> V >> P;
	    vector<ll> A(N);
	    REP(i,0,N) in >> A[i];
	    sort(all(A), greater<ll>());
	    int left = P-1, right = N;
	    while (right - left > 1) {
	        int middle = (right + left) / 2;
	        if (A[P-1] > A[middle] + M) {
	            right = middle;
	            continue;
	        }
	        ll votes = 0;
	        votes += (P-1) * M;
	        votes += (N-middle) * M;
	        REP(i,P-1,middle) {
	            votes += A[middle] + M - A[i];
	        }
	        if (votes >= V * M) {
	            left = middle;
	        } else {
	            right = middle;
	        }
	    }
	    out << left+1 << "\n";
	}
};


int main() {
    BVotingJudges solver;
    std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 1024
h,w = map(int,input().split())
a_inputs = [list(input()) for i in range(h)]

ans_map = [['#']*(w+2)]
for a in a_inputs:
    ans_map.append(['#']+a+['#'])
ans_map.append(['#']*(w+2))

for ans in ans_map:
    print(''.join(ans))

Measured memory_bytes: 3188
#include<stdio.h>
#include<math.h>
#include <limits.h>
#include<stdlib.h>


int main() {
	char *s = (char*)malloc(200000);
	char *t = (char*)malloc(200000);
	int i = 0;
	int count = 0;
	scanf("%s", s);
	scanf("%s", t);
	while (s[i] != '\0') {
		if (s[i] != t[i]) {
			count++;
		}
		i++;
	}
	printf("%d\n", count);
	return 0;
}

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

int main() {
	int n, x; cin >> n >> x;
	int d, l, cnt;
    d=0;
    cnt=1;

    do{
        cin >> l;
        d += l;
        if(d<=x) ++cnt;
    } while (d<x && cnt < n+1);

    cout << cnt << endl;
}
//g++ -o b.exe b.cpp

Measured memory_bytes: 256
from collections import defaultdict
import sys


sys.setrecursionlimit(10 ** 6)


def main():
    N = int(input())
    V = 100005
    to = defaultdict(list)
    for _ in range(N):
        X, Y = map(int, input().split())
        Y += V
        to[X].append(Y)
        to[Y].append(X)
    visited = [0] * (2 * V)
    cnt = [0] * 2  # cnt = [cnt of X, cnt of Y]

    def dfs(v):
        if visited[v] == 1:
            return
        visited[v] = 1
        cnt[v // V] += 1
        for nv in to[v]:
            dfs(nv)

    ans = 0
    for v in range(2 * V):
        if visited[v] == 1:
            continue
        cnt = [0] * 2
        dfs(v)
        ans += cnt[0] * cnt[1]
    ans -= N

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 102916
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#define rep(i,n) for (int i= 0;i<(n);++i)
using namespace std;
typedef long long ll;
const ll maxSum = 50*50+1;
int main() {
    string s ;
    cin >> s ;
    ll ans = 0 ;
    ll d = 0 ;
    for(int i = 0 ; i < 3 ;i++){
        if(s[i] == 'R'){
            d++ ;
        }else{
            if(ans < d){
                ans = d ;
            }
            d = 0 ;
        }
    }
    if(ans < d){
                ans = d ;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
import math
a,b,h,m = map(int,input().split())

hkaku = 2*math.pi*(h*60+m)/(12*60)
mkaku = 2*math.pi*(m)/60

tmp = a*a+b*b - 2*a*b*math.cos(hkaku-mkaku)
print(math.sqrt(tmp))


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x; cin >> x;
    int big = x / 500;
    x %= 500;
    int small = x / 5;
    cout << big * 1000 + small * 5 << '\n';
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
	static final long MOD = 1000000007L;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] arr = new char[h][];
		for (int i = 0; i < h; i++) {
			arr[i] = sc.next().toCharArray();
		}
		long[][] ans = new long[h][w];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (i == 0 && j == 0) {
					ans[i][j] = 1;
					continue;
				}
				if (arr[i][j] == '#') {
					continue;
				}
				if (i != 0) {
					ans[i][j] += ans[i - 1][j];
				}
				if (j != 0) {
					ans[i][j] += ans[i][j - 1];
				}
				ans[i][j] %= MOD;
			}
		}
		System.out.println(ans[h - 1][w - 1]);
	}
}


Measured memory_bytes: 41044
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
#include <queue>
#include <set>
#include <climits>
#define INF 1000000000000000
#define ll long long
using namespace std;
int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if((A%2)*(B%2)*(C%2)==0){
        cout << 0 << endl;
        return 0;
    }
    cout << min(A*B,min(B*C,C*A)) << endl;
}

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

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

	if (S[0] != 'A'){
		cout << "WA" << endl;
		return 0;
	}

	int temp1 = 0;
	for (int i=2; i < (int)(S.size())-1; i++){
		if (S[i] == 'C'){
			temp1++;
		}
	}
	if (temp1 != 1){
		cout << "WA" << endl;
		return 0;
	}

	for (int i=1; i < (int)(S.size()); i++){
		if (S[i] != 'C'){
			if (S[i] < 'a' || 'z' < S[i]){
				cout << "WA" << endl;
				return 0;
			}
		}
	}

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

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i,a[3],tmp;
  char s[3];
  a[0]=1;
  a[1]=0;
  a[2]=0;
  while(scanf("%s",s)!= EOF){
    tmp=a[s[0]-'A'];
    a[s[0]-'A']=a[s[2]-'A'];
    a[s[2]-'A']=tmp;
  }
  if(a[0]==1)printf("A\n");
  if(a[1]==1)printf("B\n");
  if(a[2]==1)printf("C\n");
  return 0;
}

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

string tmp;
int a[11][1111], cnt[11], k, h;

bool check(int col, int num)
{
	int i, gr = 0;

	for (i = 0; i < h; i++)
	{
		if (a[i][col])
			cnt[gr]++;

		if (cnt[gr] > k)
			return false;

		if (num >> i & 1)
			gr++;
	}

	return true;
}

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

	int w, i, j, p, ans = 1e9;

	cin >> h >> w >> k;
	for (i = 0; i < h; i++)
	{
		cin >> tmp;
		for (j = 0; j < w; j++)
			a[i][j] = tmp[j] - '0';
	}

	for (i = 0; i < (1 << (h - 1)); i++)
	{
		int hrz = 0, vrt = 0;

		for (j = 0; j < h; j++)
			cnt[j] = 0;

		hrz = __builtin_popcount(i);

		bool ret = true;
		for (j = 0; j < w; j++)
			if (!check(j, i))
			{
				vrt++;
				for (p = 0; p < h; p++)
					cnt[p] = 0;

				ret = check(j, i);

				if (!ret)
					break;
//				if(!check(j, i)) {ret = false; break;}
			}

		if (ret)
			ans = min(ans, hrz + vrt);

//		cout << hrz << vrt << "\n";
	}

	cout << ans;
	return 0;
}


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

int main(void) {
    int n;
    cin >> n;
    int a[n];
    vector< int > count(10*10*10*10*10);
    long long int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        count[a[i]]++;
        sum += a[i];
    }
    int q;
    cin >> q;
    int b[q], c[q];
    for (int i = 0; i < q; i++) {
        cin >> b[i] >> c[i];
    }
    int bb;
    for (int i = 0; i < q; i++) {
        bb = count[b[i]];
        count[b[i]] = 0;
        count[c[i]] += bb;
        sum = sum + (-b[i] + c[i]) * bb;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4788
#include<stdio.h>
 
int main(void){
    int h,x,i,j;
     
    while(1){
        scanf("%d" "%d",&h,&x);
        if(h==0&&x==0){
            break;
        }else{
            for(i=0;i<h;i++){
                for(j=0;j<x;j++){
                    if((i+j)%2==0){
                        putchar('#');
                    }else{
                        putchar('.');
                    }
                }
                putchar('\n');
            }
        }
        putchar('\n');
    }
}


Measured memory_bytes: 2140
#include<iostream>
using namespace std;
int main(){
  int n,q,i,c[111111],ans,l,r;
  char s[111111];
  cin>>n>>q>>s;
  c[0]=0;
  for(i=1;i<n;i++){
    c[i]=c[i-1];
    if(s[i]=='C'&&s[i-1]=='A')
      c[i]++;
  }
  for(i=0;i<q;i++){
    cin>>l>>r;
    ans=c[r-1]-c[l-1];
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 1280
// abc172_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    ll ans = 0;
    REPN(k, 1, N+1){

        int n = 0;
        while (n + k <= N){
            n += k;
            ans += n;
        }
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n+1, 0), b(n+1, 0);
    for (ll i=1; i<=(n); i++) cin >> a[i];
    for (ll i=n; i>0; i--){
        ll sum = 0;
        for (ll j=i; j<=n; j+=i){
            sum += b[j];
        }
        sum = sum % 2;
        if (sum!=a[i]) b[i]++;
    }
    vector<ll> ans;
    rep1(i, n+1) if (b[i]==1) ans.push_back(i);
    cout << ans.size() << endl;
    if (ans.size()>0) rep1(i, ans.size()){
        if (i==ans.size()-1) cout << ans[i] << endl;
        else cout << ans[i] << " ";
    }
    //printf("%.12f", ans);
}

Measured memory_bytes: 7380
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static long long
solve(long long H)
{
  long long ret = 0;
  long long n = 1;
  while (0 < H)
  {
    ret += n;
    n *= 2;
    H /= 2;
  }
  return ret;
}

int
main()
{
  long long H;
  cin >> H;
  cout << solve(H) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define dd double
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define ll long long
#define ull unsigned long long
#define ld long double
#define mx 200005
#define mod 1000000007
#define fr first
#define cti(a) (a-48)
#define itc(a) char(a+48)
#define se second
#define End cout<<"\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define memo(Array,val) memset(Array, val, sizeof Array)
#define PI acos(-1)
bool check(ll n, ll pos){ return (n&(1<<pos)); }
bool Set(ll n, ll pos) {  return (n | (1<<pos)); }
ld LOG(ld b, ld e){ return log(b)/log(e); }



void solve()
{
   ld s,baki;
   cin >> s;
   ld length = s / 3;

    s -= length;
    ld breadth = s / 2;

    ld height = s - breadth;

    cout << setprecision(14) << length * breadth * height;


}

int main()
{
    fast;
	int t;
	t=1;
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long int ll;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

const int MAX_N = 1 << 19;

// セグメント木を持つグローバル配列
int nn;
ll dat[2 * MAX_N - 1];

// 初期化
void init(int n_){
    // n_が小さいときの変な挙動を防ぐ
    if(n_ < 10)n_ = 10;
    // 簡単のため要素数を2のべき乗に
    nn = 1;
    while(nn < n_)nn *= 2;

    // 全ての値をINT_MAXに
    for(int i = 0; i < 2 * nn - 1; i++)dat[i] = 0;
}

// k番目の値(0-indexed)をaに変更
void update(int k, ll a){
    // 葉の接点
    k += nn - 1;
    dat[k] = a;
    // 登りながら更新
    while(k > 0){
        k = (k - 1) / 2;
        dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
}

// [a,b)の最小値を求める
// 後ろのほうの引数は、計算の簡単のための引数。
// kは節点の番号、l, rはその節点が[l, r)に対応づいていることを表す。
// したがって、外からはquery(a, b, 0, 0, nn)として呼ぶ。
ll query(int a, int b, int k, int l, int r){
    // [a, b)と[l, r)が交差しなければ、INT_MAX
    if (r <= a || b <= l)return INT_MAX;

    // [a, b)が[l, r)を完全に含んでいれば、この節点の値
    if (a <= l && r <= b)return dat[k];
    else {
        // そうでなければ、2つの子の最小値
        ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }
}


int main(){
    int n;
    cin >> n;
    init(n + 1);

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

    ll a[n];
    rep(i,n)cin >> a[i];

    rep(i,n){
        ll tmp = - query(0,h[i],0,0,nn);
        tmp += a[i];
        update(h[i], -tmp);
    }

    ll ans = - query(0,n+1,0,0,nn);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n;cin>>n;
  int a[4],b[4];
  rep(i,3)cin>>a[i];
  rep(i,3)cin>>b[i];
  a[3]=b[3]=1;
  ll dp[n+1];
  dp[0]=0;
  rep(i,1,n+1){
    dp[i]=dp[i-1];
    rep(j,4){
      if(n>=a[j]&&i>=a[j]){
        chmax(dp[i],dp[i-a[j]]+b[j]);
      }
    }
  }
  ll newn=dp[n];
  ll dp2[newn+1];
  dp2[0]=0;
  rep(i,1,newn+1){
    dp2[i]=dp2[i-1];
    rep(j,4){
      if(newn>=b[j]&&i>=b[j]){
        chmax(dp2[i],dp2[i-b[j]]+a[j]);
      }
    }
  }
  cout<<dp2[newn]<<endl;
}
  
  


Measured memory_bytes: 195584
// A - ι⊥l

#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() {
	int a, b, c;
	cin >> a >> b >> c;

	string ans;

	if (b - a == c - b) ans = "YES";
	else ans = "NO";

	cout << ans << endl;

	return 0;
}

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

int main(){
    using namespace std;
    size_t N;
    cin >> N;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    sort(A.begin(), A.end());
    A.erase(unique(A.begin(), A.end()), A.end());
    cout << A.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define N 4100
#define inf 1e9+7
#define ll long long
#define mo 924844033
using namespace std;
inline int read()
{
    int x=0,flag=1;
    char ch=0;
    while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
    while(isdigit(ch)) {x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
    return x*flag;
}
ll fac[N];
int flag[N],dp[N][N][2];
int main()
{
	int n,k,i,j,o,cnt=0;
	ll g,ans=1;
	n=read();
	k=read();
	fac[0]=1;
	for(i=1;i<=n;i++)
	fac[i]=(fac[i-1]*i)%mo;
	ans=fac[n];
	for(i=1;i<=k;i++)
	{
		for(o=1;o<=2;o++)//加减各加一遍
		  for(j=i;j<=n;j+=k)
		  {
			  cnt++;
			  if(i!=j)flag[cnt]=1;
		  }
	}
	dp[0][0][0]=1;
	for(i=1;i<=2*n;i++)
	{
		for(j=0;j<=n;j++)
		{
			dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mo;
			if(flag[i]&&j)dp[i][j][1]=dp[i-1][j-1][0];
		}
	}
	for(i=1;i<=n;i++)
	{
		g=( (dp[2*n][i][0]+dp[2*n][i][1])%mo * fac[n-i] )%mo;
		if(i%2)  ans=(ans-g+mo)%mo;
		else  ans=(ans+g)%mo;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 128512
#include<stdio.h>
#include<stdbool.h>

int main(void){

  int N, M, X, Y;
  scanf("%d %d %d %d", &N , &M , &X , &Y);
  bool war = false;                             //trueなら戦争が起こる



  //xの最大値がyの最小値より小さければよい
  
  int x;
  int x_max = X;
  for(int i = 0 ; i < N ; i++){
    scanf("%d",&x);

    if(x_max < x)     x_max = x;
  }


  int y;
  int y_min = Y;
  for(int i = 0 ; i < M ; i++){
    scanf("%d", &y);

    if(y < y_min)     y_min = y;
  }

  if(y_min <= x_max)  war = true;


  if(war){
    puts("War");
  }else{
    puts("No War");
  }
  

 

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if((b + c) - a < 0) {
        cout << 0 << endl;
        return 0;
    }

    cout << (b + c) - a << endl;
    return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=998244353;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//18:08~
int main(void){
	cout<<fixed<<setprecision(20);
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;cin>>s>>t;
	int ans=0;
	for(int i=0;i<s.size();i++){
		if(s[i]==t[i]){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;

template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;
    cin>>n>>m;
    vector<ll> fac=divisor(m);
    ll ans=1;
    for(auto itr:fac){
      if(ans<itr && n<=m/itr){
        ans=itr;
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  ll n, L, sum = 0;
  cin >> n >> L;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
  }

  bool flag = true;
  int t = 0;

  rep(i, n-1) {
    if (a[i] + a[i+1] >= L) {
      t = i + 1;
      flag = false;      
    }
  }

  if (flag) {
    cout << "Impossible" << endl;
    return 0;
  }

  cout << "Possible" << endl;
  for (int i = 1; i < t; ++i) {
    cout << i << endl;
  }

  for (int i = n-1; i > t; --i) {
    cout << i << endl;
  }

  cout << t << endl;
}


Measured memory_bytes: 1664
N=int(input())
ans=[0]*(N+1)
to=int((N)**(1/2))+2
for x in range(1,to):
    for y in range(1,to):
        for z in range(1,to):
            temp=x*x+y*y+z*z+x*y+y*z+z*x
            if temp<=N:
                ans[temp]+=1
for i in range(1,N+1):
    print(ans[i])

Measured memory_bytes: 9556
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n;
double a[55];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lf",&a[i]);
	sort(a+1,a+1+n);
	for(int i=1;i<n;i++)a[i+1]=(a[i]+a[i+1])/2;
	printf("%lf\n",a[n]);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define pb push_back
#define mp make_pair
#define ff first
#define se second
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	ll n=s.size();
	if(n==2){
	    cout<<s;
	}
	else{
	    reverse(s.begin(),s.end());
	    cout<<s;
	}
}

Measured memory_bytes: 764
n = int(input())
bn = list(map(int,input().split()))

ans = []

while bn:
  lst = []
  for i in range(len(bn)):
    if i+1 == bn[i]:
      lst.append(i)
  if not lst:
    print(-1)
    exit(0)
  ans.append(bn.pop(lst[-1]))
[print(i) for i in ans[::-1]]


Measured memory_bytes: 3060
import java.util.*;

public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long[] a = new long[5];
        long p = sc.nextLong();
        for (int i = 0; i<5; i++) {
            a[i] = sc.nextLong();
        }

        long min = a[0];
        for (int i = 0; i<5; i++) {
            if (min > a[i]) {
                min = a[i];
            }
        }

        long result = 4 + roundUp(p, min);

        System.out.println(result);
        sc.close();
    }

    public static long roundUp(long num, long divisor) {
    return (num + divisor - 1) / divisor;
}
}

Measured memory_bytes: 25172
#include<iostream>
#include<string>
#include<algorithm>

using namespace  std;
 int main(){
     int h,a;
     cin >> h >> a;
    for(int i=0;i<10001;i++){
        if(h<=0){
             cout << i << endl;
             break;
        }
        h -= a;
    }
    return 0;
 }



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int l, r, d; cin >> l >> r >> d;
    int cnt = 0;
    FOR(i, l, r+1) {
        if (i%d==0) cnt++;
    }
    cout << cnt << endl;
}

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

int main(){
  long long int a,b,c,k;
  cin >> a >> b >> c >> k;
  long long count = 0;
  
  while(0 < k){
    if(a < k){count += a;k -= a;}
    else {count += k;k = 0;}
    
    if(k == 0)break;
    
    if(b < k){k -= b;}
    else {k = 0;}
    
    if(k == 0)break;
    
    if(c < k){count -= c;k -= c;}
    else {count -= k;k = 0;}
  }
  
  cout << count << endl;
}

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

using namespace std;

const int N = 3e5+1;
const int O = 3e4+1;

#define ll long long
#define pb push_back
#define ppb pop_back
#define pu push
#define fr front
#define fi first
#define se second
#define setprecision
#define re return 0
#define fast ios_base::sync_with_stdio(false)

ll n, m, a[N], b[N], c[N], x, y, z, l, r, q, k, cnt, ans;

//vector<int> v;
//set<int> st[N];
//queue<int> q;

int main ()
{
    fast;

    cin >> n >> m;

    cnt = n*m;
    cout << cnt / (__gcd(n,m));
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int i, K, T, a[101];
	scanf("%d %d", &K, &T);
	for (i = 1; i <= T; i++) scanf("%d", &(a[i]));
	
	int max = 0;
	for (i = 1; i <= T; i++) if (a[i] > max) max = a[i];
	
	if (max * 2 <= K + 1) printf("0\n");
	else printf("%d\n", max * 2 - K - 1);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 1)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int moder) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%moder;
		x = x * x%moder;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	if (x == y)return 1;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m;
pair<int, int> a[100010];
priority_queue<int> que;
int ans;

signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a, a + n);
	int j = 0;
	for (int i = 1; i <= m; i++) {
		while (j < n&&a[j].first == i) {
			que.push(a[j].second);
			j++;
		}
		int b = 0;
		if (que.size()) {
			b = que.top();
			que.pop();
		}
		ans += b;
	}
	cout << ans << endl;
}

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

using namespace std;

const int N = 5050, mod = 1e9 + 7;

long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

int dp[N], dp2[N][2], cnt[N], ujung[N];

int a, b;

void upd(int & var, int val) {
  var += val;
  if (var >= mod)
    var -= mod;
}

int main() {
  memset(dp, 0, sizeof dp);
  int n;
  scanf("%d %d %d", &n, &a, &b);
  if (a > b)
    swap(a, b);
  dp[0] = 2;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j <= n && j - i < b; ++j) {
      upd(dp[j], dp[i]);
    }
  }
  long long ans = (powmod(2, n) - dp[n]) % mod;
  if (a < b) {
    for (int i = 1; i < b; ++i) {
      upd(cnt[i], 1);
    }
    for (int i = 1; i < b; ++i) {
      for (int j = i+a+1; j < b; ++j) {
        int add = j - i;
        upd(cnt[j], 1LL * (add - a) * cnt[i] % mod);
      }
    }
    for (int i = a+1; i < b; ++i) {
      for (int j = a; j < i; ++j)
        upd(ujung[i], cnt[i-j]);
    }
    for (int i = 1; i < b; ++i) {
      upd(ujung[i], cnt[i]);
    }
    dp2[0][0] = dp2[0][1] = 1;
    for (int i = 0; i < n; ++i) {
      for (int j = i+1; j <= n && j - i < a; ++j) {
        upd(dp2[j][1], dp2[i][0]);
      }
      for (int j = i+1; j <= n && j - i < b; ++j) {
        int cost = (j == n || i == 0) ? ujung[j-i] : cnt[j-i];
        upd(dp2[j][0], 1LL * cost *  dp2[i][1] % mod);
      }
    }
    ans = (ans + dp[n] - dp2[n][1] - dp2[n][0]) % mod;
  }
  ans %= mod;
  if (ans < 0)
    ans += mod;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3932
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)

int main() {
	ll N, C;
	cin >> N >> C;
	struct Sushi{
		ll x;
		ll v;
	};
	vector<Sushi> sushis(N);
	rep(i,0,N) {
		cin >> sushis[i].x >> sushis[i].v;
	}
	ll ans = 0;
	rep(step,0,2) {
		if (step == 1) {
			reverse(sushis.begin(), sushis.end());
			rep(i,0,N) {
				sushis[i].x = C - sushis[i].x;
			}
		}
		vector<ll> cal_max(N+1, 0);
		{
			ll sum = 0;
			rep(n,1,N+1) {
				sum += sushis[n-1].v;
				cal_max[n] = max(cal_max[n-1], sum - sushis[n-1].x);
			}
		}
		ans = max(ans, cal_max[N]);
		ll sum = 0;
		rep(n,1,N+1) {
			sum += sushis[N-1-(n-1)].v;
			ll dist = C - sushis[N-1-(n-1)].x;
			ans = max(ans, sum - 2 * dist + cal_max[N-n]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2560
require 'bigdecimal'
foods = []
5.times do
  foods << gets.chomp.to_i
end
sum = 0
min = 10
foods.each do |food|
    sum += BigDecimal(food.to_s).ceil(-1).to_i
    if food%10 != 0 && food%10 < min
        min = food%10
    end
end
if min == 10 then puts sum
else puts sum - 10+min end

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

int main()
{
  int n, x;
  int a, b, c;
  int sum = 0;
  cin >> n >> x;
  while (n != 0 || x != 0)
  {
    for (int i = 0; i < n; i++)
    {
      for (int j = 0; j < n; j++)
      {
        for (int k = 0; k < n; k++)
        {
          if ((i + 1 + j + 1 + k + 1) == x)
          {
            if (i != j && i != k && j != k)
            {
              sum++;
            }
          }
        }
      }
    }
    cout << sum / 6 << endl;  // 合計は3!*個数分多いので割る
    sum = 0;
    cin >> n >> x;
  }
}


Measured memory_bytes: 3084