akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define INF 1000000007
using namespace std;

int n,a[200010],cnt;
pair<int,int> q[200010];

inline bool check(int x)
{
	if(x==1){
		bool flag=false;
		for(int i=1;i<n;i++) if(a[i]>=a[i+1]){
			flag=true;
			break;
		}
		if(!flag) return true;
		return false;
	}
	int pre=0;
	map<int,int> mp;
	mp.clear();
	for(int i=1;i<=n;i++){
		if(a[i]<=pre){
			pre=a[i];
			while(pre>=1){
				if(mp[pre]+1<x) break;
				mp[pre]=0;
				pre--;
			}
			if(pre==0) return false;
			mp[pre]++;
		}
		else pre=a[i];
		mp.erase(mp.upper_bound(pre),mp.end());
	}
	return true;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int l=1,r=INF,ans=0;
	while(l<=r){
		int mid=(l+r)/2;
		if(check(mid)){
			ans=mid;
			r=mid-1;	
		}
		else l=mid+1;
	}
	cout<<ans<<endl; 
	return 0;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());

    node graph[] = new node[N + 1];
    for (int i = 0; i < N + 1; i++) {
      graph[i] = new node();
    }

    for (int i = 0; i < N - 1 + M; i++) {
      int ai = Integer.parseInt(sc.next());
      int bi = Integer.parseInt(sc.next());

      graph[bi].addParent(ai);
    }

    for (int i = 1; i < N + 1; i++) {
      graph[i].getLank(graph);
    }

    for (int i = 1; i < N + 1; i++) {
      graph[i].setParent(graph);
    }

    for (int i = 1; i < N + 1; i++) {
      System.out.println(graph[i].parent);
    }

  }
}

class node {
  ArrayList<Integer> pList;
  int parent;
  int lank;

  public node() {
    pList = new ArrayList<>();
    parent = -1;
    lank = -1;
  }

  public void addParent(int p) {
    pList.add(p);
  }

  public int getLank(node[] graph) {
    if (lank >= 0) {
      return lank;
    } else if (pList.isEmpty()) {
      parent = 0;
      lank = 0;
      return lank;
    } else if (pList.size() == 1) {
      parent = pList.get(0);
      lank = graph[parent].getLank(graph) + 1;
      return lank;
    } else {
      for (int i = 0; i < pList.size(); i++) {
        lank = Math.max(graph[pList.get(i)].getLank(graph) + 1, lank);
      }
      return lank;
    }
  }

  public void setParent(node[] graph) {
    if (parent >= 0) {
      return;
    } else {
      for (int i = 0; i < pList.size(); i++) {
        if (graph[pList.get(i)].parent < 0) {
          graph[pList.get(i)].setParent(graph);
        }
        if (graph[pList.get(i)].getLank(graph) == lank - 1) {
          parent = pList.get(i);
          return;
        }
      }
    }
  }

}

Measured memory_bytes: 93496
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, k;
  cin >> k;
  cin >> a >> b;
  for(int i = a; i <= b; i++) {
    if (i%k == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}
  


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define whole(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define ins insert
#define maxn int (1e6 + 1)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
//----------------------------------------------------------
int n, k, m;
int cnt[maxn] = {};
void Input ()
{
	cin >> n;
}
void factorize (int i)
{
	int di = 2;
	while (i != 1)
	{
		while (i % di == 0) cnt[di]++, i /= di;
		di++;
	}
}
void Solve ()
{
	for (int i = 1; i <= n; ++i)
	{
		factorize (i);
	}
	int mod = 1e9 + 7;
	ll res = 1;
	for (int i = 1; i <= n; ++i)
	{
		res = (res * (cnt[i] + 1)) % mod;
	}
	cout << res;
}
int main()
{
	// freopen ("factors_of_factorial.inp", "r", stdin);
	// freopen ("factors_of_factorial.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie (NULL);
	cout.tie (NULL);
	Input ();
	Solve ();
}

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

int main(){
	int n; cin >> n;
	int sum = 0;
	int digit = n;
	while(digit){
		sum += digit % 10;
		digit /= 10;
	}
	if(n % sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

int main() {
	int N,H,W;
	cin >> N >> H >> W;
	int cnt=0;
	for (int i=0; i<N; i++) {
		int A,B;
		cin >> A >> B;
		if (A<H || B<W) continue;
		else cnt++;
	}
	cout << cnt << endl;

	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,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
char cc[]={'m','c','x','i'};
int ci[]={1000,100,10,1};
int change(string s){
    int ans=0;
    int now=0;
    bool ok=0;
    for(int i=0;i<s.size();i++){
        ok=0;
        for(int j=0;j<4;j++){
            if(s[i]==cc[j]){
                ok=1;
                if(now==0) ans+=ci[j];
                else ans+=now*ci[j];
                now=0;
            }
        }
        if(!ok) now=now*10+s[i]-'0';
    }
    return ans;
}
void change2(int n){
    if(n>=1000){
        if(n/1000==1) cout<<"m";
        else cout<<n/1000<<"m";
        n%=1000;
    }
    if(n>=100){
        if(n/100==1) cout<<"c";
        else cout<<n/100<<"c";
        n%=100;
    }
    if(n>=10){
        if(n/10==1) cout<<"x";
        else cout<<n/10<<"x";
        n%=10;
    }
    if(n>=1){
        if(n==1) cout<<"i";
        else cout<<n<<"i";
    }
    cout<<endl;
}
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        string s,t;
        cin>>s>>t;
        change2(change(s)+change(t));
    }
    return 0;
}


Measured memory_bytes: 3100
import string
a=string.ascii_lowercase
while True:
    try:
        s=input()
    except:
        break
    for i in range(1, 27):
        t = s[:-1].translate(str.maketrans(a, a[i:]+a[:i]))
        if 'the'in t or'that'in t or'this'in t:
            print(t+".")
            break

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

int main() {
    int a[3][3] ;
    rep(i,3)rep(j,3)cin >> a[i][j];
    int n;
    cin >> n;
    int f[3][3];
    rep(i,3)rep(j,3)f[i][j] = 0;
    int c[3] = {};
    int d[3] = {};
    rep(i,n){
        int b; cin >> b;
        rep(j,3){
            rep(k,3){
                if(a[j][k] == b){
                    f[j][k] = 1;
                    c[j]++;
                    d[k]++;
                }
            }
        }
    }
    int flag = 0;
    if(c[0]==3||c[1]==3||c[2]==3||d[0]==3||d[1]==3||d[2]==3)flag = 1;
    if(f[0][0]&&f[1][1]&&f[2][2])flag = 1;
    if(f[2][0]&&f[1][1]&&f[0][2])flag = 1;
    if(flag)yn;
    return 0;
}
 
 


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean test = false;

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int[] c = new int[n];
		int[][] a = new int[n][m];
		int[] srtc = new int[n];
		int[][] srta = new int[n][m];
		long res = -1;

		int[] a_ideal = new int[m]; //各理解度の理論合計値
		for(int jj = 0; jj < m; jj++) {
			a_ideal[jj] = 0;
		}


		for(int i = 0; i < n; i++) {
			c[i] = sc.nextInt();
			for(int jj = 0; jj < m; jj++) {
				a[i][jj] = sc.nextInt();
				a_ideal[jj] += a[i][jj];
			}
		}

		if(test){//print
			System.out.printf("%d %d %d\n", n,m,x);
			for(int i = 0; i < n; i++) {
				System.out.printf("%d", c[i]);
				for(int jj = 0; jj < m; jj++) {
					System.out.printf(" %d", a[i][jj]);
				}
				System.out.println();
			}
			System.out.printf("total: ");
			for(int jj = 0; jj < m; jj++) {
				System.out.printf(" %d", a_ideal[jj]);
			}
			System.out.println();
		}

		//すべての参考書を購入しても理解度が足りないアルゴリズムがあれば終了
		for(int jj = 0; jj < m; jj++) {
			if(a_ideal[jj] < x) {
				System.out.printf("-1");
				return;
			}
		}

		//ソート
		//まず値段をソート
		System.arraycopy(c, 0, srtc, 0, n);
		Arrays.sort(srtc);
		if(test){//print
		}
		//テーブルをソート
		for(int i = 0; i < n; i++) {
			for(int jj = 0; jj < n; jj++) {
				if(srtc[i] == c[jj]) {
					System.arraycopy(a[jj], 0, srta[i], 0, m);
					//重複防止
					c[jj] = 0;
					break;
				}
			}
		}
		if(test){//print
			System.out.println();
			for(int i = 0; i < n; i++) {
				System.out.printf("%d", srtc[i]);
				for(int jj = 0; jj < m; jj++) {
					System.out.printf(" %d", srta[i][jj]);
				}
				System.out.println();
			}
		}


		//総当たり?
		boolean setting[] = new boolean[n];
		int pattern = (int)Math.pow(2, n);
		long currentRes;
		for(int i=0; i<pattern; i++) {
			int tmp = i;
			for(int jj=0; jj<n; jj++) {
				if(tmp%2 == 1) setting[jj] = true;
				else setting[jj] = false;
				tmp /= 2;
			}
			currentRes = createAndJudgeAndCulcPrice(setting, srtc, srta, m, n, x);
			if(test) System.out.printf("%d/%d %d %d\n", i, pattern, currentRes, res);

			if((res == -1 && currentRes != -1) ||
					(res != -1 && currentRes != -1 && currentRes < res)){
				res = currentRes;
			}
		}
		System.out.printf("%d", res);

	}

	private static long createAndJudgeAndCulcPrice(boolean[] setting, int price[], int table[][], int m, int n, int x) {
		int skill[] = new int[m];
		for(int i = 0; i < m; i++) {
			skill[i] = 0;
		}

		long totalPrice = 0;
		for(int i = 0; i < n; i++) {
			if (setting[i]) {
				totalPrice += price[i];
				for(int jj = 0; jj < m; jj++) {
					skill[jj] += table[i][jj];
				}
			}
		}
		if(judge(skill, m, x)) {
			return totalPrice;
		} else {
			return -1;
		}
	}

	private static boolean judge(int[] skill, int count, int require) {
		for(int idx = 0; idx < count; idx++) {
			if(skill[idx] < require) return false;
		}
		return true;
	}
}


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

using ll = long long;
using pii = pair<int, int>;

int X = 1e5;
const int mxn = 10;
int d[mxn][mxn] = { };

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

  // int n; cin >> n;
  // for(int i=0; i<n; i++) {
  //   string s; cin >> s;
  //   for(int j=0; j<i; j++) {
  //     if(s[j] == '0') d[i][j] = 0;
  //     else if(s[j] == '1') d[i][j] = 1;
  //     else if(s[j] == 'X') d[i][j] = X;
  //     d[j][i] = d[i][j];
  //   }
  // }

  int n, k; cin >> n >> k;
  if(k > (n-2)*(n-1)/2) {
    cout << -1 << endl;
    exit(0);
  }

  vector<string> e(n, string(n, '0'));
  for(int i=1; i<n; i++) {
    e[i][0] = '1';
    for(int j=1; j<i; j++) {
      if(k > 0) {
        e[i][j] = 'X';
        k--;
      }
      else {
        e[i][j] = '1';
      }
    }
  }

  // for(int i=0; i<n; i++) cout << e[i] << endl;
  int m = 0;
  for(int i=0; i<n; i++) m += count(e[i].begin(), e[i].end(), '1');
  cout << m << endl;
  for(int i=0; i<n; i++) {
    for(int j=0; j<i; j++) {
      if(e[i][j] == '1') cout << i+1 << ' ' << j+1 << '\n';
    }
  }

  // for(int k=0; k<n; k++) for(int i=0; i<n; i++) for(int j=0; j<n; j++) {
  //   d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  // }

  // int res = 0;
  // for(int i=0; i<n; i++) for(int j=0; j<i; j++) {
  //   res += d[i][j] == 2;
  // }

  return 0;
}

Measured memory_bytes: 256
# solution

nim,mike = map(int,input().split())
data = input()
t = [0]*(nim+1)
for i in range(nim):
    t[i+1] = t[i]+(1 if data[i:i+2] =="AC"else 0)
for i in range(mike):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])

Measured memory_bytes: 7748
#include <bits/stdc++.h>
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
*/#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")    
using namespace std;
/*namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;
*/#define lli long long int
#define uli unsigned long long int
#define INF 999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
vector<lli> divisor(lli N){
  vector<lli>res;
  for(lli i=1;i*i<=N;i++){
    if(N%i==0){
      res.push_back(i);
      if(i!=N/i)res.push_back(N/i);
    }
  }
  Sort(res);
  return res;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,H,W,M,K,L,R,N,num=0,sum=0,flag=0;string S,T;
  cin >> N;
  Vec(P,lli,N,0);
  map<lli,lli>mp;
  rep(i,0,N){
    cin >> P[i];
    mp[P[i]]++;
  }
  rep(i,0,N){
    flag=1;
    for(auto v:divisor(P[i]))if(mp.find(v)!=mp.end()){
      if(v==P[i]&&mp[v]>1)flag=0;
      else if(v!=P[i]&&mp[v])flag=0;
    }
    if(flag)sum++;
  }
  Out(sum);
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N, X, T;
    cin >> N >> X >> T;
    cout << T * ((N + X - 1) / X)  << '\n';

}

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


Measured memory_bytes: 3652
a = list(map(int,input().split()))
ans = 0
a.sort()
while a[0]+2 <= a[2]:
  a[0] = a[0] + 2
  a.sort()
  ans += 1

if a[0] == a[1] and a[1] ==a[2]:
  print(ans)  
elif a[0] == a[1] and not a[1] == a[2]:
  print(ans+1)
else:
  print(ans+2)
    

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

int main() {

	std::vector<int> v(3);
	for (int& x : v) {
		std::cin >> x;
	}

	std::sort(v.begin(), v.end());



	std::cout <<v[0]+v[1]+v[2]*10<< std::endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1'000'000'007;
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

int main() {
    int n;
    cin >> n;
    vi a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    map<int, int> colors;
    for (int i = 0; i < n; ++i) {
        if (a[i] >= 3200)
            a[i] = 3200;
        colors[a[i] / 400]++;
    }
    int min = colors.size();
    int max = min;
    if (colors[8] != 0) {
        min = colors.size() == 1 ? 1 : min - 1;
        max = max + colors[8] - 1;
    }
    cout << min << " " << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();

		long r = n / (a + b);
		long k = 0;
		long ans = 0;
		ans = r * a;
		k = r * (a + b);

		if (k + a < n) {
			ans += a;
		}else {
			ans += n - k;
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 35688
n=int(input())
dic={"M":0,"A":0,"R":0,"C":0,"H":0}
check=["M","A","R","C","H"]

for i in range(n):
  s=input()
  if s[0] in check:
    dic[s[0]]+=1

ans=0
for i in range(3):
  for j in range(i+1,4):
    for k in range(j+1,5):
      ans+=dic[check[i]]*dic[check[j]]*dic[check[k]]
      
print(ans)



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

int n, dp[100100][3];

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

    cin >> n;
    ll sum = 0;
    for (int i = 1; i <= n; i++){
        int a, b, c;
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});

}


Measured memory_bytes: 1408
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;
const int MAX = 100010;
ll v[MAX];

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

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

    for (int i = 1; i <= MAX; ++i){
    if (K <= v[i]) {
        cout << i << endl;
        break;
    }
    K -= v[i];
    }

    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ARC088C
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var X = NN;
            var Y = NN;
            var ans = 0;
            while (X <= Y)
            {
                ++ans;
                X *= 2;
            }
            Console.WriteLine(ans);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 14688
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int X,h = 0;
    cin >> X;

    if(X >= 500){
        h = X / 500 * 1000;
        X = X % 500;
    }

    if(X >= 5){
        h += X / 5 * 5;
    }

    cout << h << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include <cstdlib>

using namespace std;
int main()
{

    int n;
    cin >> n;

    int x=0, y=0, time=0;
    int nt, nx, ny;
    bool can = true;

    int diff, difft;

    for(int i=0;i<n;i++){
        cin >> nt >> nx >> ny;
        diff = abs( (nx-x) + (ny-y));
        difft = nt - time;
        if(diff%2 == difft%2 && diff<=difft){
            time = nt;
            x = nx;
            y = ny;
        }
        else{
            can = false;
            break;
        }
    }

    if(can) cout << "Yes";
    else cout << "No";

    return 0;
}

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

int main() {
	int a[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < 3; i++) {
		a[1][i] -= a[0][i];
		a[2][i] -= a[0][i];
		a[0][i] = 0;
	}
	for (int i = 0; i < 3; i++) {
		a[i][1] -= a[i][0];
		a[i][2] -= a[i][0];
		a[i][0] = 0;
	}
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++)
		{
			if (a[i][j] != 0) {
				cout << "No" << endl;
				return 0;
			}
		} 
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main(){
    double a,b,C;
    double PI=acos(-1);
    cin>>a >> b >> C;
    double rad=(PI*C/180);
    double S=a*b*sin(rad)/2;
    double L=a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
    double H=b*sin(rad);
    printf("%.5f\n",S);
    printf("%.5f\n",L);
    printf("%.5f\n",H);
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <utility>

using namespace std;

vector<int> v;
vector<vector<pair<int, int> > > p;
vector<bool> b;

void dfs(int now, int d){
    //cout << "now=" << now << endl;
    if(b[now]==true)return;
    b[now]=true;
    v[now]=d;
    for(vector<pair<int,int> >::const_iterator it = p[now].begin(), e=p[now].end(); it !=e ; ++it){
        //cout << (*it).first << " " <<(*it).second << endl;
        dfs((*it).first, (d+(*it).second)%2);
    }
}

int main()
{
    int n;
    cin >> n;
    v.resize(n,0);
    p.resize(n, vector<pair<int, int> >(0));
    b.resize(n,false);

    for(int i=0; i<n-1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        p[u].push_back(make_pair(v,w));
        p[v].push_back(make_pair(u,w));
    }
    dfs(0, 0);

    for(vector<int>::const_iterator it = v.begin(), e=v.end();it!=e;++it){
        cout << *it << endl;
    }
    return 0;
}


Measured memory_bytes: 7424
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main(){
  int N; cin >> N;
  vector<int>A(N);
  rep(i,N) cin >> A[i];
  set<int>s;
  rep(i,N) s.insert(A[i]);
  if (s.size() == N) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> ans(N, 0);
  
  rep(x, sqrt(N)+1) rep(y, sqrt(N)+1) rep(z, sqrt(N)+1) {
    if(x == 0 || y == 0 || z == 0) continue;
    if(x*x+y*y+z*z+x*y+y*z+z*x <= N) ans[x*x+y*y+z*z+x*y+y*z+z*x-1]++;
  }
  
  rep(i, N) cout << ans[i] << endl;

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
using namespace std;
int get(int x){
  return (x*(x-1))/2;
}
signed main(){
  int n,d,ans;
  cin>>n>>d;
  if(d==1)ans=get(n);
  else if(d==2)ans=get(n)-1;
  else if(d==3)ans=get(n-2)+2;
  else ans=get(n-(d+1)+2)+(d-1);
  
  if(d>=3&&(n-1)!=d)ans+=(n-(d+1));
  
  cout<<ans<<endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    string s;
    cin >> s;
    int sz=s.size();
    int n=sz/2;
    int ans=0;
    REP(i,n){
        if(s[i]!=s[sz-i-1]) ans++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3600
h, w = gets.split.map(&:to_i)
w += 1
s = $<.map(&:bytes)
a = Array.new(h+2) { Array.new(w+2,0) }
hh=Array.new(w+2) { Array.new }

h.times do |i|
	l = 0
	w.times.select { |j| s[i][j] != 46 }.each do |r|
		hh[r] << i
		l.upto(r-1) { |j| a[i][j] = r-l }
		l = r + 1 
	end
end
w.times { |k| hh[k] << h }


hh.each_with_index do |x,i|
	u = 0
	x.each do |d| 
		u.upto(d-1) { |j| a[j][i] += d-u }
		u = d + 1 
	end
end

p a.map(&:max).push(1).max-1


Measured memory_bytes: 122108
#include<stdio.h>

static const int N = 1000;

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

int main(){
  int n, i, j, key, l, m;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  //trace(A, n);
  for ( l=1;l<=n;l++) {
    key=A[l];
    m = l-1;
    while(m>=0 and A[m]>key) {
        A[m+1] = A[m];
        m--;
    }
    A[m+1]=key;
    trace(A, n);  
  }
  
  return 0;
}

Measured memory_bytes: 1032
#include<stdio.h>
int main()
{
  long long n,i,m,A[1000],c=0,s=0;
  double b;
  scanf("%lld %lld",&n,&m);
  for(i=0;i<n;i++)
  {
    scanf("%lld",&A[i]);
    s=s+A[i];
  }
   b=s*1.00/4/m;
  for(i=0;i<n;i++)
  {
    if(A[i]>=b)
      c++;
  }
  if(c>=m)
  {
      printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define bit(n) (1LL<<(n))
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
#pragma endregion library

int main(){
    int n, x;  cin >> n >> x;
    vi a(n); rep(i,n) cin >> a[i];
    ll ans = 0;
    int tot = a[0];
    repi(i,1,n){
        if(i-2>=0) tot -= a[i-2];
        tot += a[i];
        if(tot>x){
            int dec=min(a[i],tot-x);
            tot -= dec, a[i] -= dec;
            ans += dec;
            if(tot>x){
                a[i-1] -= tot - x;
                ans += tot - x;
                tot = x;
            }
        }
    }
    cout << ans << '\n';
    
}

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

int main ()
{
	int n;
	cin>>n;
	
   long long 	int dup=n;
	long long int sum=0;
	while (dup>0)
	{
		if (dup>9)
		{
		long long int temp=dup%10;
		sum+=temp;
		}
		else
		{
			sum+=dup;
		}
		dup/=10;
	}
	
	if (n%sum==0)
	cout<<"Yes";
	else 
	cout<<"No";
	
	
	
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long   ll;
typedef long double ld;

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f
const string YES = "Yes";
const string NO = "No";

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

bool solve(ll A, ll B, ll C, ll K) {
  rep(i, K) {
    if (!(A<B)) B *= 2;
    else if (!(B<C)) C *= 2;
    else return true;
  }
  if (A<B && B<C) return true;
  else return false;
}

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

  ll A, B, C, K;
  cin >> A >> B >> C >> K;

  auto ans = solve(A, B, C, K);
  cout << (ans ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 3132
n, m, x = gets.split.map(&:to_i)
pri = []
ary = []
n.times do
  t = gets.split.map(&:to_i)
  pri << t[0]#値段
  ary << t[1..m]#アルゴリズムの理解度
end
lis = []
[1,0].repeated_permutation(n) do |i|
  num = 0
  ans = Array.new(m,0)
  i.each_with_index do |k, l|
    if k == 1
      num+=pri[l]#l要素の値段
      ans = [ans, ary[l]].transpose.map{|a| a.inject(:+) }
      #ansとaryの縦の列の合計
    end
  end
  lis << num if ans.all? { |a| a >= x }#全部x以上か
end
puts lis.empty? ? "-1" : lis.min


Measured memory_bytes: 14348
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;

int gcd(int a, int b) {
  return (b == 0 ? a : gcd(b, a % b));
}
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  function <int(vector <int>)> get = [&] (vector <int> v) {
    ll sum = 0;
    for (int i = 0; i < n; ++i) sum += v[i] - 1;
    if (sum % 2 == 1) return 0;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      if (v[i] % 2 == 1) {
        if (v[i] == 1) {
          cnt += 2;
        } else {
          ++cnt;
        }
      }
    }
    if (cnt != 1) {
      return 1;
    } else {
      int g = 0;
      for (int i = 0; i < n; ++i) {
        if (v[i] % 2 == 1) {
          --v[i];
        }
        g = gcd(g, v[i]);
      }
      for (int i = 0; i < n; ++i) v[i] /= g;
      return 1 ^ get(v);
    }
  };
  if (get(a) == 0) {
    cout << "First\n";
  } else {
    cout << "Second\n";
  }
}


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

int main()
{
    int X, A, B;
    cin >> X >> A >> B;
    if (B <= A)
    {
        cout << "delicious" << endl;
    }
    else if (A < B && B <= A + X)
    {
        cout << "safe" << endl;
    }
    else
    {
        cout << "dangerous" << endl;
    }

    return 0;
}

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

int main() {
  int a, b, sum, d;
  while (1) {
    cin >> a >> b;
    if (cin.eof()) break;
    sum = a+b;
    d = 0;
    while (sum) {
      sum /= 10;
      d++;
    }
    cout << d << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(int *arr, int size) {
    int i;
    for(i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    return 0;
}

#define NUM_MAX 100000

void swap(int *a1, int *a2) {
    int tmp = *a1;
    *a1 = *a2;
    *a2 = tmp;
}

int main(void) {
    int num = get_int();
    static int arr[NUM_MAX+1];
    fget_array(&arr[1], num);

    int i;
    int ans = 0;
    for(i = 1; i <= num-1; i++) {
        if(arr[i] == i) {
            swap(&arr[i], &arr[i+1]);
            ans++;
        }
    }
    // swap anyway
    if(arr[num] == num) ans++;
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  long long N,A,B;
  cin >> N >> A >> B;
  if(A>B){
    cout << 0 << endl;
    return 0;
  }
  if(N == 1 && A-B != 0){
    cout << 0 << endl;
    return 0;
  }
  if(N == 1){
    cout << 1 << endl;
    return 0;
  }
  cout << (N-1)*(B-A)+A-B+1 << endl;
    
}


Measured memory_bytes: 3572
from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(x, y):
    return (x * y) // gcd(x, y)


def gcd_list(numbers):
    return reduce(gcd, numbers)


def lcm_list(numbers):
    return reduce(lcm, numbers)


n = int(input())
a = list(map(int, input().split()))

print(gcd_list(a))

Measured memory_bytes: 62704
//投影
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const double EPS=1e-6;
bool is_Zero(double &a){
	return a<EPS&&a>-EPS;
}
const int INFTY=1<<29;
struct Point{
	double x,y;
	Point(double x,double y):x(x),y(y){}
	Point(){}
	Point(const Point&a){x=a.x;y=a.y;}
	Point operator+(const Point&a){
		return Point(x+a.x,y+a.y);
	}
	Point operator-(const Point&a){
		return Point(x-a.x,y-a.y);
	}
	Point operator*(double k){
		return Point(k*x,k*y);
	}
	Point operator/(double k){
		return Point(x/k,y/k);
	} 
};
typedef Point Vector;
Point operator*(double k,const Point&a){
	return Point(k*a.x,k*a.y);
}
double norm(const Point&a){
	return a.x*a.x+a.y*a.y;
}
double abs(const Point&a){
	return sqrt(norm(a));
}
double dot_product(const Point&a,const Point&b){
	return a.x*b.x+a.y*b.y;
}
double cross_product(const Point&a,const Point&b){
	return a.x*b.y-a.y*b.x;
}
Point projection_Point(Point&p1,Point&p2,Point&p){
	Vector base=p2-p1;
	double r=dot_product(base,p-p1)/norm(base);
	return p1+base*r;
}

int main(){
	Point p1,p2;
	Point temp;
	scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lf%lf",&temp.x,&temp.y);
		Point a=projection_Point(p1,p2,temp);
		printf("%.10lf %.10lf\n",a.x,a.y);
	}
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    int ans = (b - a + 1) * (b - a) / 2 - b;
    cout << ans << endl;

    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll A, B, C;
    ll K;
    cin >> A >> B >> C;
    cin >> K;

    for(ll i=0; i<=K; i++){
        for(ll j=0; j<=K; j++){
            for(ll k=0; k<=K; k++){
                if(i+j+k > K) continue;
                if((A*pow(2,i) < B*pow(2,j)) && (B*pow(2,j) < C*pow(2,k))){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3944
#include<iostream>
using namespace std;
int main(void){
  int a=0,b,c;
  string s;
  string t = "CODEFESTIVAL2016";
 cin >> s;
  for(int i = 0;i < s.size();i++){
    if(s.at(i) != t.at(i)){
      a++;
    }
  }
    cout << a;
}

Measured memory_bytes: 256
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <ctime>
#include <bitset>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=a%10, a/=10; return res;}
const int up[]={1,-1,0,0}, lf[]={0,0,1,-1};
ll gcd(ll a, ll b) {if (b==0) return a; else return gcd(b, a%b);}

int main() {
  string s; cin>>s;
  if (s.back() == 's') cout<<s+"es"<<endl;
  else cout<<s+"s"<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#pragma GCC optimize(3 , "Ofast" , "inline")
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0)
#define x first
#define y second
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
ll in()
{
  ll x = 0 , f = 1 ;
  char ch = getchar() ;
  while(!isdigit(ch)) {if(ch == '-') f = -1 ; ch = getchar() ;}
  while(isdigit(ch)) x = x * 10 + ch - 48 , ch = getchar() ;
  return x * f ;
}
int ans[N] ;
int main()
{
  int n = in() ;
  for(int x = 1; x <= n ;x ++ ) {
    if(x * x > n) break ;
    for(int y = 1; y <= n ;y ++ ) {
      if(x * x + y * y + x * y > n) break ;
      for(int z = 1; z <= n ;z ++ ) {
        if(x * x + y * y + z * z + x * y + y * z + z * x > n) break ;
        ans[x * x + y * y + z * z + x * y + y * z + z * x] ++ ;
      }
    }
  }
  for(int i = 1; i <= n ;i ++ )
   cout << ans[i] << endl ;
  return 0 ;
}
/*
*/


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(void) {
	long long n,k,i,b,j=0,v;
	cin >> n>>k;
	vector<long long> a(n+1),ans(n-k+1);
	rep(i, n) {
		cin >> b;
		
		if (i == 0) {
			a[i] = b;
		}
		else {
			a[i] = a[i - 1] + b;
		}
	}

	ans[0] = a[k-1];
	for (i = k; i < n; i++) {
		ans[i - (k-1)] = (a[i] - a[i - k]);

		if (i != k-1) {
			if (ans[i - (k - 1)] > ans[i - k]) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 6360
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main (){
    int a, b;
    cin >> a >> b;
    if (a*b%2==1) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)


//abbreviations
typedef long long ll;
#define vi vector<int>

using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string chmax(string a,string b){
  if(a=="-") return b;
  if(b=="-") return a;
  if(a.size()>b.size()) return a;
  else if (a.size()<b.size()) return b;
  else{
    if(a>b) return a;
    else return b;
  }
}

int matches[] = {0,2,5,5,4,5,6,3,7,6};
string dp[10100];

int main(){
  int N,M;
  int i=0,j=0;
  cin>>N>>M;
  vi A(M);
  rep(i,M)cin>>A[i];
  rep(i,10001)dp[i]="-";
  dp[0]="";
  rep(i,N){
    if(dp[i]=="-") continue;
    rep(j,M){
      dp[i+matches[A[j]]]=chmax(dp[i]+to_string(A[j]),dp[i+matches[A[j]]]);
    }
  }
  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 33024
#include <stdio.h>
int main(){
  int n,k,i;
  long long int x[100000],tmp,tmp1,ans=-1;
  scanf("%d%d",&n,&k);
  for(i=0;i<n;i++){
    scanf("%lld",&x[i]);
  }
  for(i=0;i<n-k+1;i++){
    tmp=abs(x[i])+abs(x[i+k-1]-x[i]);
    tmp1=abs(x[i+k-1])+abs(x[i]-x[i+k-1]);
    if(tmp>tmp1)
      tmp=tmp1;
    if(ans>tmp || ans==-1)
      ans=tmp;
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 896
package main

import (
        "fmt"
)

func solution(n string) string {

        sum := 0

        for i := range n {
                sum += int(n[i] - '0')
        }

        if sum%9 == 0 {
                return "Yes"
        }
        return "No"
}

func main() {
        var n string
        fmt.Scan(&n)
        fmt.Println(solution(n))
}

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

class Abc126B
{
    static bool IsPossiblyMonth(int a) => 1 <= a && a <= 12;
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var L = int.Parse(S.Substring(0, 2));
        var R = int.Parse(S.Substring(2, 2));
        var answer = string.Empty;
        if(!IsPossiblyMonth(L) && !IsPossiblyMonth(R)) answer = "NA";
        if(IsPossiblyMonth(L) && !IsPossiblyMonth(R)) answer = "MMYY";
        if(!IsPossiblyMonth(L) && IsPossiblyMonth(R)) answer = "YYMM";
        if(IsPossiblyMonth(L) && IsPossiblyMonth(R)) answer = "AMBIGUOUS";
        Console.WriteLine(answer);
    }
}


Measured memory_bytes: 11092
#include <cstdio>
#include <stack>
#include <utility>
#include <vector>


int main()
{  
  // stack of slope index and char
  std::stack< std::pair<int, char> > slope_stack;
  // stack of pond volumes (index, volume)
  std::stack< std::pair<int, int> > volumes; 

  char slope; // type of slope
  int index = 0; // distance index
  
  while (scanf("%c", &slope) != EOF) {
    if (slope == '\\') {
      slope_stack.push(std::make_pair(index, slope));
    } else if (slope == '/') {
      if (!slope_stack.empty() && slope_stack.top().second == '\\') {
	int prev_index = slope_stack.top().first;
	int volume = index - prev_index; // volume of current horizontal
	slope_stack.pop();
	
	while (!volumes.empty() && volumes.top().first > prev_index) {
	  volume += volumes.top().second; // combine volumes
	  volumes.pop();
	}
	volumes.push(std::make_pair(index, volume));
      }
    }
    ++index;
  }

  std::vector < int > volumes2; // for printing in correct order
  int sum = 0; // sum of volumes
  
  while (!volumes.empty()) {
    int volume = volumes.top().second;
    sum += volume;
    volumes2.push_back(volume);
    volumes.pop();
  }

  printf("%d\n", sum);

  printf("%lu", volumes2.size());
  
  for (auto it = volumes2.rbegin(); it != volumes2.rend(); ++it) {
    printf(" %d", *it);
  }

  printf("\n");

}

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

using namespace std;

#define  N 222

const double PI = 3.14159265359;
typedef long long ll;

void solve() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef qwerty
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif


    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.6lf\n",a);
#define SIZE

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define N (int)(1e5+10)


using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;

int main() {
    ll n ,r ;
    cin >>n>>r;
    if ( n < 10 )
    {
        ll a =100 * (10 - n) +r;
        cout << a;
    }else{
        cout << r;
    }
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;
#define N 998244353

long long int ncr[1000000];
int main(){
    long long int n, a, b;
    long long int k;
    long long int sum = 0;
    pair<long long int, long long int> p;
    vector<pair<long long int, long long int> > v;
    cin >> n >> a >> b >> k;
    if(k == 0){
        cout << 1 << endl;
        return 0;
    }
    if((k-sum)%b == 0 && (k-sum)/b <= n){
        p = make_pair(0, (k-sum)/b);
        v.push_back(p);
    }
    for(long long int i = 0; i < n; i++){
        sum += a;
        if(sum > k) break;
        if((k-sum)%b == 0 && (k-sum)/b <= n){
            p = make_pair(i+1, (k-sum)/b);
            v.push_back(p);
        }
    }
    long long int sums = 0;
    long long int r = 1;
    ncr[0] = 1;
    for(long long int i = 0; i < n/2; i++){
        ncr[i+1] = (ncr[i]*(n-i))%N;
        for(int j = 0; j < 30; j++){
            if(j == 0){
                r = i+1;
                ncr[i+1] = (ncr[i+1]*r)%N;
                continue;
            }
            r = (r*r)%N;
            if(j != 23 && j != 26){
                ncr[i+1] = (ncr[i+1]*r)%N;
            }
        }
        if(ncr[i+1] < 0) ncr[i+1] = ncr[i+1] + N;
    }
    long long int a1, b1, s1, s2;
    pair<long long int, long long int> p1;
    if(v.size() == 0){
        cout << 1 << endl;
        return 0;
    }
    else{
        long long int si = v.size();
        for(long long int i = 0; i < si; i++){
            p1 = v[v.size()-1];
            a1 = p1.first;
            if(a1 > n/2) a1 = n-a1;
            b1 = p1.second;
            if(b1 > n/2) b1 = n-b1;
            s1 = ncr[a1];
            s2 = ncr[b1];
            sums = (sums + (s1*s2)%N)%N;
            v.pop_back();
            }
        }
    cout << sums << endl;
    return 0;
    }

Measured memory_bytes: 6000