akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string S; cin >> S;
    set<char> ATGC = {'A', 'T', 'G', 'C'};
    int i = 0;
    int ans_len = 0;
    while (i < S.size()) {
        if (ATGC.count(S[i])) {
            int max_len = 1;
            while (true) {
                i++;
                if (ATGC.count(S[i])) {
                    max_len++;
                } else {
                    break;
                }
            }
            if (ans_len < max_len) ans_len = max_len;
            continue;
        }
        i++;
    }
    cout << ans_len << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pa;

const ll MAX = 1e9 + 7;
int n;
bool visited[100001];
vector <int> tree[100001];

pa dpfs(int d)
{
    visited[d] = true;

    ll wsum = 1;
    ll bsum = 1;
    for(auto e: tree[d])
    {
        if(!visited[e])
        {
            pa t = dpfs(e);
            ll w = t.first;
            ll b = t.second;

            wsum *= w + b;
            wsum %= MAX;
            bsum *= w;
            bsum %= MAX;
        }
    }

    return pa(wsum, bsum);
}

int main() {
    cin >> n;
    for(int i = 0; i < n-1; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    pa ans = dpfs(1);

    cout << (ans.first + ans.second)%MAX << endl;
    return 0;
}

Measured memory_bytes: 14512
A, B, C, D, E, F = map(int, input().split())

ans = [0, 0]
max_conc = -1
for a in range(F // 100 + 1):
    left = F - 100 * a * A
    for b in range(left // 100 + 1):
        w = 100 * a * A + 100 * b * B

        s_max = min(F - w, w * E // 100)
        if s_max >= 0:
            for c in range(s_max // C + 1):
                d = (s_max - c * C) // D

                if d >= 0:
                    # suger
                    s = c * C + d * D
                    if s + w > 0:
                        conc = s / (s + w)
                        if conc > max_conc:
                            ans = [s, w]
                            max_conc = conc


print(str(ans[0] + ans[1]) + ' ' + str(ans[0]))


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int h,w,i,j;
  scanf("%d",&h);
  scanf("%d",&w);
  int a[h][w];
  for(i=0;i<h;i++) {
    for(j=0;j<w;j++) {
      scanf("%d",&a[i][j]);
    }
  }
  int x[h*w][4];
  int n = 0;
  for(i=0;i<h;i++) {
    for(j=0;j<w-1;j++) {
      if(a[i][j]>0 && a[i][j]%2==1) {
        a[i][j]--;
        a[i][j+1]++;
        x[n][0] = i;
        x[n][1] = j;
        x[n][2] = i;
        x[n][3] = j+1;
        n++;
      }
    }
  }
  for(i=0;i<h-1;i++) {
    if(a[i][j]>0 && a[i][w-1]%2==1) {
      a[i][w-1]--;
      a[i+1][w-1]++;
      x[n][0] = i;
      x[n][1] = w-1;
      x[n][2] = i+1;
      x[n][3] = w-1;
      n++;
    }
  }
  printf("%d\n",n);
  if(n>0) {
    for(i=0;i<n;i++) {
      printf("%d %d %d %d\n",x[i][0]+1,x[i][1]+1,x[i][2]+1,x[i][3]+1);
    }
  }
  return 0;
}


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

int main(){
	string S;
	cin >> S;
	bool b;
	int Y = stoi(S.substr(0, 4));
	int M = stoi(S.substr(5, 2));
	int D = stoi(S.substr(8, 2));
	if (Y < 2019) {
		b = true;
	}
	else if (Y > 2019) {
		b = false;
	}
	else if (M <= 4) {
		b = true;
	}
	else if (M > 4) {
		b = false;
	}
	if (b == true) {
		cout << "Heisei";
	}
	else {
		cout << "TBD";
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
#include<queue>
#include <functional>
using namespace std;

int main(){
  
  int n,m,ans=0;
  int p[10000];
  
  while(1){
    ans=0;
    cin >> n >> m;
    if(n==0 && m==0)break;
    for(int i=0;i<n;i++){
      cin >> p[i];
    }
    sort(p,p+n,greater<int>());
    
    if(n < m){
      for(int i=0;i<n;i++){
	ans+=p[i];
      }
      cout << ans << endl;
    }
    else{
      for(int i=1;i<n+1;i++){
	if(i % m == 0){
	  ans+=0;
	}
	else{
	  ans+=p[i-1];
	}
      }
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn fact(n: i64) -> i64 {
    let mut ret = 1;
    for i in 1..n + 1 {
        ret *= i;
        ret %= MOD;
    }
    ret
}

fn main() {
    let (n, m) = scan!(i64, i64);
    if (n - m).abs() > 1 {
        println!("0");
        return;
    }

    if n == m {
        println!("{}", (2 * (fact(n) * fact(m)) % MOD) % MOD)
    } else {
        println!("{}", (fact(n) * fact(m)) % MOD)
    }
}


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

long long A, B, C;

int main() {
  cin >> A >> B >> C;
  if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) cout << 0 << endl;
  else {
    cout << min({A * B, B * C, C * A}) << endl;
  }
  return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

ll f(ll n) { return n * (n+1) / 2; }

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    rep1(i, n) ans += f(n/i) * i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
  lint A,B,ans;
  cin >> A >> B;
  lint save=A%2?A:0;
  A=A%2?A+1:A;
  lint save2=B%2?0:B;
  B=B%2?B:B-1;
  lint onecount=(B-A+1)/2;
  if(onecount%2==0) ans=save^save2;
  else ans=save^save2^1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}

/*最小公倍数*/
template<typename T>
T lcm(T x, T y) {
	T tmp = gcd(x, y);

	return x / tmp * y;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);


	int n;
	cin >> n;
	vector<int> a(n);
	vector<string> s(n);
	for (int i = 0; i < n; i++)
	{
		cin >> s[i] >> a[i];
	}

	string t;
	cin >> t;

	bool flag = false;
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		if (s[i] == t) {
			flag = true;
			continue;
		}
		if (flag) {
			ans += a[i];
		}
	}
	cout << ans << endl;





	return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

namespace QuestionB
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
            var result = long.MinValue;
            
            for(var i = 0; i < 2; i++)
            {
                for(var j = 2; j < 4; j++)
                {
                    var temp = inputs[i] * inputs[j];
                    if(temp > result)
                    {
                        result = temp;
                    }
                }
            }
            Console.WriteLine(result);
        }
    }
}


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

#define int long long
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);


main(){
	FIO
    int n,i,j,k;
    cin>>n;
    int arr[n];
    set<int>s;
    int count=0;
    bool a[1000005]={0};
    for(i=0;i<n;i++){
    	cin>>arr[i];
    	if(s.find(arr[i])==s.end())
    		s.insert(arr[i]);
    	else{
    		a[arr[i]] = 1;
    	}
    }
    //sort(arr,arr+n);
    for(i=0;i<n;i++){
    	if(s.find(arr[i])!=s.end())
    	{
    		vector<int>v;
    		for(j=2*arr[i];j<1000006;j+=arr[i]){
	    		if(s.find(j)!=s.end()){
	    			v.pb(j);
	    		}
	    	}
	    	for(j=0;j<v.size();j++){
	    		s.erase(v[j]);
	    	}
    	}
    	if(a[arr[i]]){
    		s.erase(arr[i]);
    	}
    }
    cout<<s.size();
}


Measured memory_bytes: 15900
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
vector<ll> vis[10];
bool used[10];
ll ans, n, m, a, b;
void dfs(ll x, ll y) {
	if (used[y])return;
	if (x == n) {
		ans++;
		return;
	}
	used[y] = 1;
	for (int i = 0; i < vis[y].size(); i++) dfs(x + 1, vis[y][i]);
	used[y] = 0;
}
int main() {
	cin >> n >> m;
	for (int i = 0; i <= n; i++)used[i] = 0;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		vis[a].push_back(b);
		vis[b].push_back(a);
	}
	dfs(1, 1);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        int n = 1;
        Scanner sc = new Scanner(System.in);
        while(true){
            int x = sc.nextInt();
            if(x==0)break;
            System.out.println("Case "+n+": "+x);
            n++;
        }
        sc.close();
    }
}


Measured memory_bytes: 44612
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
	int n;
	double yen = 0, bit = 0;
	cin >> n;

	vector<double> x(n);
	vector<string> u(n);

	for (int i = 0; i < n; i++){
		cin >> x.at(i);
		cin >> u.at(i);
	}

	for (int i = 0; i < n; i++){
		if (u.at(i) == "JPY"){
			yen += x.at(i);
		}
		else{
			bit += x.at(i);
		}
	}

	cout << yen + bit*380000.0 << endl;

	return 0;
}

Measured memory_bytes: 256
def main():
  N = int(input())
  A = [int(_)//400 for _ in input().split()]
  U = [a for a in A if a < 8]
  O = N - len(U)
  print(max(1, len(set(U))), len(set(U)) + O)
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		int W = cin.nextInt();
		int H = cin.nextInt();
		int[] p = new int[W];
		int[] q = new int[H];
		for (int i = 0; i < W; i++)
		{
			p[i] = cin.nextInt();
		}
		for (int i = 0; i < H; i++)
		{
			q[i] = cin.nextInt();
		}
		Array.Sort(p);
		Array.Sort(q);
		long ans = 0;
		int pid = 0, qid = 0;
		while (true)
		{
			if (pid >= W)
			{
				if (qid >= H)
				{
					break;
				}
				ans += (long)q[qid] * (W + 1 - pid);
				qid++;
			}
			else if (qid >= H)
			{
				ans += (long)p[pid] * (H + 1 - qid);
				pid++;
			}
			else
			{
				if (p[pid] < q[qid])
				{
					ans += (long)p[pid] * (H + 1 - qid);
					pid++;
				}
				else
				{
					ans += (long)q[qid] * (W + 1 - pid);
					qid++;
				}
			}
		}
		Console.WriteLine(ans);
	}

}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 7848
X, Y, Z, K = gets.split.map(&:to_i)
a_list = gets.split.take(X).map(&:to_i).sort_by { |n| -n }
b_list = gets.split.take(X).map(&:to_i).sort_by { |n| -n }
c_list = gets.split.take(X).map(&:to_i).sort_by { |n| -n }

ret = []
a_list.each.with_index do |a, a_i|
  b_list.each.with_index do |b, b_i|
    c_list.each.with_index do |c, c_i|
      break if (a_i + 1) * (b_i + 1) * (c_i + 1) > K
      ret.push(a + b + c)
    end
  end
end
ret = ret.sort_by { |n| -n }
K.times do |i|
  puts ret[i]
end


Measured memory_bytes: 8184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include<cstdio>
#include<iomanip>
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define REP(i, n) for(int i = 0; i < n; i++)
#define max(v) *max_element(v.begin(), v.end())
#define min(v) *min_element(v.begin(), v.end())
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
using namespace std;
 
int main(void){
  int n, k, toku;
  cin>>n>>k;
  double p, q, ans;
  int cnt;
  for(int i = 1; i <= n; ++i){
    toku=i;
    cnt = 0;
    while(toku<k){
      toku*=2;
      cnt+=1;
//      cout<<cnt<<endl;
    }
	p=(1/double(n))*pow(0.5, double(cnt));
//    cout<<p<<endl;
    ans+=p;
  }
  cout<<setprecision(12)<<ans<<endl;
  return 0;
}

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

using namespace std;

#define MAX_X 1000500
#define MAX_Y 1000500
#define MAX_Z 1000500
#define MAX_N 52
#define MAX_C MAX_N * 2

int N, K;

int X[MAX_X], Y[MAX_X], D[MAX_X];

int SX[MAX_C], SY[MAX_C], SD[MAX_C];
int LX[MAX_C], LY[MAX_C], LD[MAX_C];
int KX[MAX_C], KY[MAX_C], KD[MAX_C];

int X1[MAX_N], Y1[MAX_N], D1[MAX_N], X2[MAX_N], Y2[MAX_N], D2[MAX_N];

int main()
{
	memset(X, 0, sizeof(X));
	memset(Y, 0, sizeof(Y));
	memset(D, 0, sizeof(D));

	cin >> N >> K;

	for (int i = 0; i < N; i++)
	{
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];

		for (int j = X1[i]; j < X2[i]; j++)
		{
			X[j] += 1;
		}

		for (int j = Y1[i]; j < Y2[i]; j++)
		{
			Y[j] += 1;
		}

		for (int j = D1[i]; j < D2[i]; j++)
		{
			D[j] += 1;
		}
	}


	int start;
	int countx = 0, county = 0, countd = 0;

	start = 0;

	for (int i = 1; i < MAX_X; i++)
	{
		if (X[i - 1] != X[i])
		{
			SX[countx] = start;
			LX[countx] = i - start;
			KX[countx] = X[i - 1];

			start = i;
			countx += 1;
		}
	}

	start = 0;

	for (int i = 1; i < MAX_X; i++)
	{
		if (Y[i - 1] != Y[i])
		{
			SY[county] = start;
			LY[county] = i - start;
			KY[county] = Y[i - 1];

			start = i;
			county += 1;
		}
	}

	start = 0;

	for (int i = 1; i < MAX_X; i++)
	{
		if (D[i - 1] != D[i])
		{
			SD[countd] = start;
			LD[countd] = i - start;
			KD[countd] = D[i - 1];

			start = i;
			countd += 1;
		}
	}

	long long Ans = 0;

	for (int x = 0; x <= countx; x++)
	{
		for (int y = 0; y <= county; y++)
		{
			for (int d = 0; d <= countd; d++)
			{
				int cnt = 0;

				for (int i = 0; i < N; i++)
				{
					if (X1[i] <= SX[x] && SX[x] < X2[i] && Y1[i] <= SY[y] && SY[y] < Y2[i] && D1[i] <= SD[d] && SD[d] < D2[i])
					{
						cnt++;
					}
				}

				if (cnt >= K)
				{
					Ans += 1LL * LX[x] * LY[y] * LD[d];
				}
			}
		}
	}

	cout << Ans << endl;

	return 0;
}

// Time : O ( 3 * MAX_X + 8 * MAX_N ^ 4 )

Measured memory_bytes: 14808
import sys
import collections
input = sys.stdin.readline


def main():
    N = int(input())
    S = list(input().strip() for _ in range(N))
    assert N == len(S)
    count = collections.Counter(S)
    answer = []
    frequency = 0
    for word in count:
        if count[word] > frequency:
            answer = []
            answer.append(word)
            frequency = count[word]
        elif count[word] == frequency:
            answer.append(word)
    answer.sort()
    for s in answer:
        print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 35572
open Printf
open Scanf


let rec ch str chr idx =
  if idx < String.length str then
    (if (String.get str idx = chr) then true else ch str chr (idx + 1))
  else false
    
let _ =
  let s = scanf "%s\n" (fun x -> x) in
  match List.map (fun x -> (ch s x 0)) ['N'; 'E'; 'S'; 'W'] with
  | [true; false; true; false] | [false; true; false; true] | [true; true; true; true] -> printf "Yes\n"
  | _ -> printf "No\n"


Measured memory_bytes: 384
def resolve():
    n = int(input())
    v = list(map(int, input().split()))
    ol = {}
    el = {}
    for i in range(len(v)):
        if i % 2 == 0:
            if v[i] in ol:
                ol[v[i]] += 1
            else:
                ol[v[i]] = 1
        else:
            if v[i] in el:
                el[v[i]] += 1
            else:
                el[v[i]] = 1
    ol = sorted(ol.items(), key=lambda x: x[1], reverse=True)
    el = sorted(el.items(), key=lambda x: x[1], reverse=True)

    # ol 1st
    if ol[0][0] != el[0][0]:
        print(len(v)-ol[0][1]-el[0][1])
    else:
        ofix = ol[0][0]
        if len(el) == 1:
            ans1 = len(v)-ol[0][1]
        else:
            ans1 = len(v)-ol[0][1]-el[1][1]
        efix = el[0][0]
        if len(ol) == 1:
            ans2 = len(v)-el[0][1]
        else:
            ans2 = len(v)-el[0][1]-ol[1][1]
        print(min(ans1, ans2))
resolve()

Measured memory_bytes: 63340
import os, sys, re, math

N = int(input())
honest = []
liar = []

for i in range(N):
    a = int(input())
    h = []
    l = []
    for j in range(a):
        (x, y) = [int(n) for n in input().split()]
        if y == 1:
            h.append(x)
        else:
            l.append(x)
    honest.append(h)
    liar.append(l)

answer = 0
for i in range(2 ** N - 1, -1, -1):
    b = ('{:0%db}' % N).format(i)
    truth = True
    for j in range(N):
        if b[j] == '1':
            for h in honest[j]:
                if b[h - 1] != '1':
                    truth = False
                    break
            if not truth:
                break
            for l in liar[j]:
                if b[l - 1] != '0':
                    truth = False
                    break
        if not truth:
            break
    if truth:
        answer = max(answer, len(b.replace('0', '')))

print(answer)


Measured memory_bytes: 9960
N, M = map(int, input().split())
Pref = [1 for i in range(N)]
City = []
Ans = ["" for i in range(M)]
for i in range(M):
    p, y = map(int, input().split())
    City.append((y, p-1, i))
City.sort()
for i in range(M):
    Ans[City[i][2]] =  "{0:06d}".format(City[i][1]+1) + "{0:06d}".format(Pref[City[i][1]])
    Pref[City[i][1]] += 1

for i in range(M):
    print(Ans[i])

Measured memory_bytes: 29808
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int cnt[3];
int main(){
    string s;
    cin>>s;
    rep(i,s.size()){
        ++cnt[s[i]-'a'];
    }
    int mx=*max_element(cnt,cnt+3);
    int mn=*min_element(cnt,cnt+3);
    if(mx-mn<=1) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 512
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!long).array;

    long ans = A.map!(a => abs(a)).sum;

    if (A.map!(a => a < 0).sum % 2 == 1) {
        ans -= A.map!(a => abs(a)).reduce!min * 2;
    } 

    ans.writeln;
}


Measured memory_bytes: 4476
#155 c
n=int(input())
s=dict()
for i in range(n):
    x=input()
    if x not in s:
        s[x]=1
    else:
        s[x]+=1


max_value=max(s.values())
ans=sorted(s.items(),key=lambda x:x[0])

for i in ans:
    if max_value==i[1]:
        print(i[0])

Measured memory_bytes: 46556
n = input()

if n.find("1") == -1:
    print(1)
if n.find("2") == -1:
    print(2)
if n.find("3") == -1:
    print(3)
if n.find("4") == -1:
    print(4)
if n.find("5") == -1:
    print(5)

Measured memory_bytes: 9112
def inpl(): return [int(i) for i in input().split()]
import numpy as np
N = int(input())
F = np.zeros((N, 10), dtype = int)
P = np.zeros((N, 11), dtype = int)
ans = -10**11
for i in range(N):
    F[i] = np.array(inpl())
for i in range(N):
    P[i] = np.array(inpl())
for ctr in range(1,1024):
    tmpans = 0
    ctr = list(map(int, bin(ctr)[2:]))
    ctr = np.array([0]*(10-len(ctr)) + ctr)
    for j in range(N):
        tmpans += P[j][np.dot(ctr,F[j])]
    ans = max(ans, tmpans)
print(ans)

Measured memory_bytes: 14548
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Array

main :: IO ()
main = do
  n <- getl read
  solve n <$> replicateM n getLine >>= putStrLn

solve :: Int -> [String] -> String
solve n ss = fra $ foldl1 coma (map toa ss)

toa :: String -> Array Char Int
toa xs = accumArray (+) 0 ('a', 'z') [(c,1)| c <- xs]

coma :: Array Char Int -> Array Char Int -> Array Char Int
coma aa ba = array ('a','z') [(c, min (aa ! c) (ba ! c)) | c <- ['a'..'z']]

fra :: Array Char Int -> String
fra aa = f . filter (\x -> snd x /= 0) . assocs $ aa
  where
    f [] = ""
    f ((x,i):xs) = replicate i x ++ f xs

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 892
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi x(n);
  rep (i, n) {
    scanf("%d", &x[i]);
  }
  auto y = x;
  sort(all(y));
  int m = n/2;
  int ans;
  rep (i, n) {
    if (x[i] <= y[m-1]) {
      ans = y[m];
    } else {
      ans = y[m-1];
    }
    printf("%d\n", ans);
  }
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int x;
  cin >> x;

  if (x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
//Author - Rahil Malhotra
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    int n,m,k;
    cin>>n>>m>>k;
    string arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans[n][m]={};
    int ct=0;
    for(int j=0;j<m;j++)
    {
        for(int i=0;i<n;i++)
        {
            if(arr[i][j]=='#')
            {
                ans[i][j]=++ct;
                for(int k=i-1;k>=0;k--)
                {
                    if(ans[k][j]==0&&arr[k][j]!='#')
                        ans[k][j]=ct;
                    else
                        break;
                }
                for(int k=i+1;k<n;k++)
                {
                    if(ans[k][j]==0&&arr[k][j]!='#')
                        ans[k][j]=ct;
                    else
                        break;
                } 
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(ans[i][j]!=0)
            {
                int val=ans[i][j];
                for(int k=j-1;k>=0;k--)
                {
                    if(ans[i][k]==0&&arr[i][k]!='#')
                        ans[i][k]=val;
                    else
                        break;
                }
                for(int k=j+1;k<m;k++)
                {
                    if(ans[i][k]==0&&arr[i][k]!='#')
                        ans[i][k]=val;
                    else
                        break;
                }
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
            cout<<ans[i][j]<<" ";
        cout<<endl; 
    }
}




Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int mod=1e9+7;
inline void add(int &x,int y){
	x+=y;
	x=(x>=mod?x-mod:x);
}
int dp[55][105][105],a[105];
int main(){
	int n=read(),m=2*n-1;
	REP(i,1,m) a[i]=read();
	sort(a+1,a+m+1);
	dp[n][0][0]=1;
	int ans=0;
	DREP(i,n,2) REP(j,0,m) REP(k,0,m) if(dp[i][j][k]){
		int L=(a[i]!=a[i-1]),R=(a[m-i+1]!=a[m-i+2]);
		REP(l,1,j+L) add(dp[i-1][l-1][k+1+R],dp[i][j][k]);
		REP(l,1,k+R) add(dp[i-1][j+1+L][l-1],dp[i][j][k]);
		add(dp[i-1][j+L][k+R],dp[i][j][k]);
	}
	REP(i,0,m) REP(j,0,m) add(ans,dp[1][i][j]);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <array>
#include <iomanip>
#include <set>
using namespace std;

typedef long long ll;
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define SORT(s) sort((s).begin(),(s).end())

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

    string ans = "No";
    REP(i,100){
        REP(j,100){
            ll x = i*4 + j*7;
            if(x == N){
                ans = "Yes";
            }
        }
    }
    cout << ans << endl;
}


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

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i < n; i++) {
		ans += (n - 1) / i;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
//=======================//
// coder: Andy - Tohrumi //
//=======================//

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pb emplace_back
#define mp make_pair
#define rep(i, a, b) for(__typeof(b) i = a; i < b; ++i)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; --i)

typedef vector<int> vi;
const int mod = 1e9+7;

int dp[1001][1001], a[1001][1001];

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, m;	cin >> n >> m;
	dp[1][1] = 1;
	for (int i = 0; i < n; i++)
	{
		string str;	cin >> str;
		for (int j = 0; j < str.length(); j++)
		{
			if (str[j] == '.')	a[i+1][j+1] = 0;
			else a[i+1][j+1] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= m; j++)
		{
			if (a[i][j] == 0)
			{
				dp[i][j] += (dp[i-1][j] + dp[i][j-1]);
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n][m];
}

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

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int64_t powmod(int64_t x, int64_t n, int64_t mod) {
	int64_t ret = 1;
	while (n > 0) {
		if (n & 1) (ret *= x) %= mod;
		(x *= x) %= mod;
		n >>= 1;
	}
	return ret;
}



int main() {

	int n; cin >> n;

	vector<LL> a(n);
	vector<LL> d(n);

	LL mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];

		mx = max(mx, a[i]);
		d[a[i]]++;
	}

	if (a[0] != 0 || d[0]>1) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 0; i < mx + 1; i++) {
		if (d[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	LL ans = 1;

	for (int i = 1; i < mx+1; i++) {
		for (int j = 0; j < d[i]; j++) {
			ans = (ans*d[i - 1]);
			ans %= 998244353;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include <stdio.h>
using namespace std;

int main(){
    int H,W;
    int i,j;
           
    for (;;){
        cin >> H >> W;
        if (H==0 && W==0)break;
        for (i=0;i<H;i++){
            for (j=0;j<W;j++){
                if (j !=W-1){
                    cout << "#";
                } else {
                    cout << "#" << endl;
                }
            }
        }
        cout << endl;
    }
    
    return 0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 3010;
const ll MOD = 1000000007;

inline void add(ll &x, ll y) { x += y; if (x >= MOD) x -= MOD; }

ll comb[MN][MN];
ll dp[MN][MN];
int tr[MN];
int num[MN];

int main() {
	rep(i, 3010) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % MOD;
		}
	}

	int N, M;
	string s;

	scanf("%d %d", &N, &M);
	cin >> s;

	rep(i, N) tr[i] = i;
	rep(i, N) num[i+1] = num[i] + (s[i] == '0');

	rep(i, M) {
		int l, r;
		scanf("%d %d", &l, &r);
		--l; --r;

		for (int k = l; k <= r; ++k) {
			tr[k] = max(tr[k], r);
		}
	}

	dp[0][0] = 1;

	int la = -1;

	rep(i, N) {
		rep(j, MN) if (dp[i][j] != 0) {
			int z = j + num[tr[i]+1] - num[la+1];
			if (z) add(dp[i+1][z-1], dp[i][j]);
			if (z < tr[i] - i + 1) add(dp[i+1][z], dp[i][j]);
		}
		la = tr[i];
	}

	cout << dp[N][0] << endl;

	return 0;
}

Measured memory_bytes: 140160
var
	N,i,ans,now:Longint;
	A:Array[1..100001]of Longint;
function f(i,j:Longint):Longint;
begin
	if A[i]<A[j] then f:=1 else if A[i]>A[j] then f:=-1 else f:=0;
end;
begin
	read(N);
	for i:=1 to N do read(A[i]);
	ans:=1;
	i:=3;
	now:=f(1,2);
	while i<=N do begin
		if(f(i-1,i)<>0)and(now<>f(i-1,i))then begin
			if now<>0 then begin
				inc(ans);
				inc(i);
			end;
			now:=f(i-1,i);
		end;
		inc(i);
	end;
	writeln(ans);
end.


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

int main()
{
	int N,sum=0;
	while(cin>>N)
	{
		int B[N-1],A[N];
		memset(A,0,sizeof(A));
		for(int i=0;i<N-1;i++)
			cin>>B[i];
		A[0]=B[0];
		A[N-1]=B[N-2];
		for(int i=0;i<N-2;i++)
		{
			if(B[i]<=B[i+1])
				A[i+1]=B[i];
			else
				A[i+1]=B[i+1];
		}
		for(int i=0;i<N;i++)
			sum+=A[i];
		cout<<sum<<"\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

int main(){
    string S; cin >> S;
    int p = 700;
    if(S[0] == 'o') p += 100;
    if(S[1] == 'o') p += 100;
    if(S[2] == 'o') p += 100;
    cout << p << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include <cstring>
#include <vector>
#include <queue>
#include <iomanip>
#include <stack>

using namespace std;
typedef long long ll;

ll ans, mx, sum, mn = 1e14, cnt;


ll arr[1000001];
int main(){
	ll n;
	cin>>n;
	queue<long long> q; 

    for (ll i = 1; i <= 9; i++) 
        q.push(i); 
    for (ll i = 1; i <= n; i++) { 
        arr[i] = q.front(); 
        q.pop(); 
        if (arr[i] % 10 != 0) 
            q.push(arr[i] * 10 + arr[i] % 10 - 1);
        q.push(arr[i] * 10 + arr[i] % 10); 
        if (arr[i] % 10 != 9) 
            q.push(arr[i] * 10 + arr[i] % 10 + 1); 

    }
    cout<<arr[n];
      

}

Measured memory_bytes: 5940
#include <bits/stdc++.h>
using namespace std;
int main() {
  string n;
  cin >> n;
  string ans = "No";
  for(int i=0;i<n.size();i++) {
    if(n[i] == '7') ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <math.h>

int calc(int x,int y, int z){
  int ans;
  ans = x*x + y*y + z*z + x*y + x*z + y*z;
  return ans;
}

int main(){
  int n;
  int index;
  int i,j,k;
  int index_break;
  int ans;
  double tmp;
  scanf("%d",&n);
  int cnt[n+1];
  for(i=1;i<=n;i++){
    cnt[i]=0;
  }
  i=1;
  while(1){
     ans = 1+1+i*i+1+i+i;
     i++;
     if(ans > n){
       index_break=i;
       break;
     }
  }

  for(i=1;i<=index_break;i++){
    for(j=1;j<=index_break;j++){
      for(k=1;k<=index_break;k++){
        index=calc(i,j,k);
        if(index<=n){
        cnt[index]+=1;
      }
      }
    }
  }

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

  return 0;
}


Measured memory_bytes: 1728
// A C++ program to find maximal Bipartite matching.
#include <iostream>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;

const int MX=103;
// A DFS based recursive function that returns true if a
// matching for vertex u is possible
bool bpm(bool bpGraph[MX][MX], int u, bool seen[], int matchR[])
{
    // Try every job one by one
    for (int v = 0; v < MX; v++)
    {
        // If applicant u is interested in job v and v is
        // not visited
        if (bpGraph[u][v] && !seen[v])
        {
            seen[v] = true; // Mark v as visited

            // If job 'v' is not assigned to an applicant OR
            // previously assigned applicant for job v (which is matchR[v])
            // has an alternate job available.
            // Since v is marked as visited in the above line, matchR[v]
            // in the following recursive call will not get job 'v' again
            if (matchR[v] < 0 || bpm(bpGraph, matchR[v], seen, matchR))
            {
                matchR[v] = u;
                return true;
            }
        }
    }
    return false;
}

// Returns maximum number of matching from M to N
int maxBPM(bool bpGraph[MX][MX])
{
    // An array to keep track of the applicants assigned to
    // jobs. The value of matchR[i] is the applicant number
    // assigned to job i, the value -1 indicates nobody is
    // assigned.
    int matchR[MX];

    // Initially all jobs are available
    memset(matchR, -1, sizeof(matchR));

    int result = 0; // Count of jobs assigned to applicants
    for (int u = 0; u < MX; u++)
    {
        // Mark all jobs as not seen for next applicant.
        bool seen[MX];
        memset(seen, 0, sizeof(seen));

        // Find if the applicant 'u' can get a job
        if (bpm(bpGraph, u, seen, matchR))
            result++;
    }
    return result;
}
bool bp[MX][MX];
pair<int,int>a[MX],b[MX];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i].first,&a[i].second);
    for(int i=0;i<n;i++)scanf("%d%d",&b[i].first,&b[i].second);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(a[i].first<b[j].first&&a[i].second<b[j].second){
                bp[i][j]=1;
            }
        }
    }
    cout<<maxBPM(bp)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int beki(int x, int y) {
  int ret = 1;
  rep(i,y) ret *= x;
  return ret;
}

int ans(int x) {
  int ret = 1;
  rep(i,x) {
    for(int j = 2; j < x; j++) {
      int a = beki(i,j);
      if(a <= x) ret = max(ret,a);
    }
  }
  return ret;
}
      

int main() {
  int n;
  cin >> n;
  cout << ans(n) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int result;
		
		if(a >= b && a >= c) {
			result = result(a,b,c);
		}else if(b >= a && b >= c) {
			result = result(b,c,a);
		}else {
			result = result(c,a,b);
		}
		
		System.out.println(result);
	}

	private static int result(int a, int b, int c) {
		return a*10+b+c;
	}
}


Measured memory_bytes: 22868
<?php
  fscanf(STDIN, "%d %d", $n, $q);
  fscanf(STDIN, "%s", $s);

  $csum = [0];
  for ($i=1; $i<$n; $i++) {
    $csum[$i+1] = $csum[$i];
    if ($s[$i-1]=='A' && $s[$i]=='C') {
      $csum[$i+1]++;
    }
  }
  // print_r($csum);

  for ($i=0; $i<$q; $i++) {
    fscanf(STDIN, "%d %d", $l, $r);
	echo ($csum[$r] - $csum[$l]) . "\n";
  }

Measured memory_bytes: 21256
from bisect import bisect_left
import random
import time
import math


#入力
D = int(input())
C = [int(c) for c in input().split()]
S = []
for _ in range(D):
    s = [int(x) for x in input().split()]
    S.append(s)
#初期解
T = []
for _ in range(D):
    t = random.randrange(26)
    T.append(t)


last_day = [[-1] for _ in range(26)]
for d in range(D):
    test = T[d]
    last_day[test].append(d)
for i in range(26):
    last_day[i].append(D)


T0 = 10000
time_start = time.perf_counter()
while True:
    time_now = time.perf_counter()
    if time_now - time_start > 1.82:
        break
    #時間を正規化して温度を設定
    time_n = (time_now - time_start) / 1.82
    T1 = T0 ** (1 - time_n)
    #ランダムな日のテストをランダムに入れ替え
    d = random.randrange(365)
    q = random.randrange(26)
    old = T[d]
    T[d] = q
    #日程dでの元のテストold
    l = last_day[old]
    ind_old = l.index(d)
    dd_left = l[ind_old] - l[ind_old-1] - 1
    dd_right = l[ind_old+1] - l[ind_old] - 1
    dd = l[ind_old+1] - l[ind_old-1] - 1
    dif_old = C[old] * (((dd_left * (dd_left + 1)) // 2) + ((dd_right * (dd_right + 1)) // 2) - ((dd * (dd + 1)) // 2))
    #日程dでのテストq
    l = last_day[q]
    ind_q = bisect_left(last_day[q],d)
    dd_left = d - l[ind_q-1] - 1
    dd_right = l[ind_q] - d - 1
    dd = l[ind_q] - l[ind_q-1] - 1
    dif_q = C[q] * (((dd * (dd + 1)) // 2) - ((dd_left * (dd_left + 1)) // 2) - ((dd_right * (dd_right + 1)) // 2))
    #変更による差
    dif_s = dif_old + dif_q - S[d][old] + S[d][q]
    if (dif_s > 0) or (math.exp(dif_s / T1) > random.random()):
        del last_day[old][ind_old]
        last_day[q].insert(ind_q,d)
    else:
        T[d] = old
for d in range(365):
    print(T[d] + 1)



Measured memory_bytes: 87900
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
#-----

count_A_dic={}
for size in A_list:
    count_A_dic.setdefault(size,0)
    count_A_dic[size] += 1

length = sorted(set(A_list),reverse=True)

side=[]
for l in length:
    if count_A_dic[l] >= 4 and len(side) == 0:
        side = [l,l]
        break

    elif count_A_dic[l] >= 2 and len(side) < 2:
        side.append(l)
    
    if len(side) == 2:
        break

print( side[0] * side[1] if len(side)==2 else 0 )


Measured memory_bytes: 20260
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  ll n,k; cin>>n>>k;
  map<int,ll> mp;
  rep(i,n){
    int a,b; cin>>a>>b;
    mp[a]+=(ll)b;
  }
  ll B=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    B+=itr->sc;
    if(B>=k){
      cout<<itr->fs<<endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int calcNumOfCombination(int n, int r){
    int num = 1;
    for(int i = 1; i <= r; i++){
        num = num * (n - i + 1) / i;
    }
    return num;
}
int main() {
    int l;
    cin>>l;
    double ans=0.0;
    double hoge=0.0;
    hoge = l/3.0;
    ans = hoge*hoge*hoge;
    printf("%lf\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
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 main():
    mod=10**9+7
    N=I()
    T=LI()
    M=I()
    P=[0]*M
    X=[0]*M
    for i in range(M):
        P[i],X[i]=MI()
    S=sum(T)
    for i in range(M):
        print(S-T[P[i]-1]+X[i])
    

main()


Measured memory_bytes: 38256