akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

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


Measured memory_bytes: 3688
#include<stdio.h>
#include<string.h>

int main()
{
	char si[110], s[210], p[110];
	scanf("%s", si);
	scanf("%s", p, 110);
	strcpy(s, si);
	strcat(s, si);
	if (NULL != strstr(s, p))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MAX 100005
#define MOD 1000000007
#define INF 1e9
#define vi vector<int>
#define vl vector<ll> 
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<'\n';}
vector<string> split(const string& s, char c) { vector<string> v; stringstream ss(s); string x; while (getline(ss, x, c)){ v.emplace_back(x);} return move(v); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args) { cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...); }
//int bit[MAX], p[MAX];
//void upd(int i, int v=1) {while(i < MAX){bit[i] += v; i += i&-i;}}
//int read(int i) {int s=0; while(i > 0){s += bit[i]; i -= i&-i;} return s;}
//int fs(int i) {while(i != p[i]){p[i]=p[p[i]]; i=p[i];} return i;}
//ll modexp(ll a, ll b, ll c=MOD) { ll res=1;while(b){res=b&1?(res*a)%c:res; a=(a*a)%c; b>>=1;} return res; }
// auto f = [](int a, int b) -> int { return a+b; };

int main()
{
	int r,g;
	cin>>r>>g;
	g*=2;
	g -= r;
	cout << g << endl;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
grid = [list(input()) for i in range(h)]
black = [[1 for i in range(w)] for j in range(h)]
white = [[1 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if i%2 and j%2 == 0:
      black[i][j] = 0
    elif i%2 == 0 and j%2:
      white[i][j] = 0
for i in range(h):
  for j in range(w):
    if grid[i][j] == "#":
      black[i][j] = 1
      white[i][j] = 1
    else:
      if i%2 == 0:
        white[i][j] = 0
      else:
        black[i][j] = 0
for i in range(h):
  black[i][0] = 0
  black[i][w-1] = 1
  white[i][0] = 1
  white[i][w-1] = 0
for i in range(w):
  black[0][i] = 1
  black[h-1][i] = 0
  white[0][i] = 0
  white[h-1][i] = 1

for i in range(h):
  for j in range(w):
    if black[i][j]:
      print("#",end="")
    else:
      print(".",end="")
  print()
print()
for i in range(h):
  for j in range(w):
    if white[i][j]:
      print("#",end="")
    else:
      print(".",end="")
  print()

Measured memory_bytes: 13300
#include<stdio.h>
int main(void){
  int A,B,count=0;
  scanf("%d %d",&A,&B);
  for(int i=A;i<=B;i++){
    if((i/10000==i%10)&&((i/1000)%10==(i/10)%10)){
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

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

int main(){
 long long int A,B,K;
 cin>>A>>B>>K;
 if(A>=0&&B>=0&&K>=0&&A<=1000000000000&&B<=1000000000000&&K<=1000000000000){
 if(A>=K){
     cout<<A-K<<" "<<B;
 }
 else if(A<K){
     if(B>=(K-A)){
         cout<<0<<" "<<B-(K-A);
     }
     else{
         cout<<0<<" "<<0;
     }
 }
 }
   return 0;
   
}

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

struct Point{
  double x, y;
};

void koch(int n, Point a, Point b){
  if(n == 0) return;

  Point s, t, u;
  double th = M_PI * 60.0 / 180.0;

  s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
  s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
  t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
  t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
  u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
  u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

  koch(n - 1, a, s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n - 1, s, u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n - 1, u, t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(n - 1, t, b);
}

int main(){
  Point a, b;
  int n;

  scanf("%d",&n);

  a.x = 0;
  a.y = 0;
  b.x = 100;
  b.y = 0;

  printf("%.8f %.8f\n",a.x,a.y);
  koch(n, a, b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

Measured memory_bytes: 2732
import java.util.*;

public class Main {
  private static long dfs(String input, long sum, int index) {
    if (index >= input.length()) {
      return sum;
    }
    long total = 0;
    for (int i = index + 1; i <= input.length(); i++) {
      total += dfs(input, sum + Long.parseLong(input.substring(index, i)), i);
    }
    return total;
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String input = s.next();
    System.out.println(dfs(input, 0, 0));
  }
}


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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    int j = s.size()-1;
    int cnt =0;
    while(i<j){
        if(s[i]=='W'){
            while(i<j){
                if(s[j]=='R'){
                    s[j] = 'W';
                    s[i] = 'R';
                    cnt++;
                    break;
                }
                j--;
            }
        }
        i++;
    }

    cout << cnt << endl;
}


Measured memory_bytes: 3744
import sys

while True:
    N, M = map(int, sys.stdin.readline().split())
    
    if N == M == 0:
        break
    
    packet = []
    for i in xrange(M):
        packet.append(map(int, raw_input().split()))
    packet.sort()
    infected = set([1])
    for p in packet:
        if p[1] in infected:
            infected.add(p[2])
    print len(infected)

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
 	li k;

 	cin>>k;

 	vi cnt(k);

 	li val=7;

 	li ans=1,flag=1;

 	while(1)
 	{
 		if(val%k==0)
 		{
 			break;
 		}
 		else
 		{
 			li rem=val%k;

 			if(cnt[rem]>0)
 			{
 				flag=0;
 				break;
 			}

 			cnt[rem]++;

 			ans++;

 			val=rem*10+7;
 		}
 	}

 	if(!flag)
 	{
 		cout<<-1;
 	}
 	else
 		cout<<ans;
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 11096
b = [list(map(int, input().split())) for i in range(3)]
a = [[False for i in range(3)] for j in range(3)]

n = int(input())
for i in range(n):
    num = int(input())
    for j in range(3):
        for k in range(3):
            if b[j][k] == num:
                a[j][k] = True

flag = 0
for i in range(3):
    f = 1
    for j in range(3):
        if not a[i][j]:
            f = 0
    if f == 1:
        flag = 1

for j in range(3):
    f = 1
    for i in range(3):
        if not a[i][j]:
            f = 0
    if f == 1:
        flag = 1

if a[0][0] and a[1][1] and a[2][2]:
    flag = 1
if a[2][0] and a[1][1] and a[0][2]:
    flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=a;i<=b;i++){
		if(c%i==0){
			count++;
		}
	}
	printf("%d\n",count);
	return 0;

}


Measured memory_bytes: 2128
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<map>
#include<set>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define maxn 3010
using namespace std;

int main(){
	ll x,y;
	cin>>x>>y;
	printf("%lld",max(max(x-y,x+y),x*y));
    return 0;
}

Measured memory_bytes: 256
import sys, os

def f():
    args = list(map(int,input().split()))
    if len(args) > 1:
        return args
    return args[0]

if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    s = input()
    t = input()
    slen = len(s)
    if t[:slen] == s:
        print("Yes")
    else:
        print("No")


solve()

Measured memory_bytes: 9116
N = int(input())
a_list = [int(_c) for _c in input().split(" ")]
a_list = sorted(a_list)

res = 1
flg = False
for a in a_list:
    res = res * a
    if res > 10 ** 18:
        flg = True
        break

if flg:
    print(-1)
else:
    print(res)

Measured memory_bytes: 21652
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }
const int MAX_N = 110;
const int MAX_W = 100100;

int main() {
    int N, W;
    cin >> N >> W;
    long long dp[MAX_W] = {0};
    vector<int> weight(N), value(N);
    for (int i = 0; i < N; i++) { cin >> weight[i] >> value[i]; }
    
    for (int i = 0; i < N; i++) {
        for (int w = MAX_W; w >= 0; w--) {
            if (0 <= w-weight[i]) dp[w] = max(dp[w], dp[w-weight[i]] + value[i]);
        }
    }
    
    cout << dp[W] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

double n,k;
vector<double> p(200100),s(200100);

int main(){
    cin>>n>>k;
    rep(i,0,n){
        cin>>p[i];
        p[i]=(1+p[i])/2.0;
        s[i+1]=s[i]+p[i];
    }
    double ans=0;
    per(i,n,k) chmax(ans,s[i]-s[i-k]);

    cout<<fixed<<setprecision(10)<<ans<<"\n";
    return 0;
}


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

int s;
int s_f , s_b;


int main() {

	cin >> s;

	s_f = s / 100;
	s = s % 100;
	s_b = s / 1;	// それぞれの桁の数値を検出
	
	bool MMYY = s_f <= 12 && s_f > 0;
	bool YYMM = s_b <= 12 && s_b > 0;
	if (MMYY && YYMM) cout << "AMBIGUOUS" << endl;
	else if (MMYY) cout << "MMYY" << endl;
	else if (YYMM) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	
	return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  int ans = 0;
  rep(i, n-1){
    if(s[i] == s[i+1]) ans++;
  }
  ans += 2 * k;
  cout << min(ans, n - 1) << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e16+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main(){
    string S;
    cin >> S;
    int ans = S.size();
    for(int i = 0; i < S.size()-1; i++) {
        if(S[i] != S[i+1]) {
            ans = min(ans,max(i+1,(int)S.size()-i-1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3768
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
//cerr
using namespace std;
//(a^p)%mod
int f1(int a, int p) {
	if (p == 1)return a;
	if (p % 2)return f1(a, p - 1)*a%mod;
	else {
		return f1(a*a%mod, p / 2) % mod;
	}
}
//nCr
int cbn(int n, int r) {
	int rt = 1;
	for (int i = 1; i <= n; i++) { rt *= i; rt %= mod; }
	for (int i = 1; i <= r; i++) { rt *= f1(i, mod - 2); rt %= mod; }
	for (int i = 1; i <= n - r; i++) { rt *= f1(i, mod - 2); rt %= mod; }
	return rt;
}
signed main() {
	int n, k; cin >> n >> k;
	int ans = 0;
	int p = 1, q = 1;
	for (int i = 0; i <= min(n, k); i++) {
		//ans+=nCi*(n-1)Ci
		ans += p * q;
		p *= n - i; p %= mod; p *= f1(i + 1, mod - 2); p %= mod;
		q *= n - i - 1; q %= mod; q *= f1(i + 1, mod - 2); q %= mod;
		ans %= mod;
		//cerr << p << ' ' << q << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int len=s.size();
	for(int i=1;i<len;i++){
		if(s[i]==s[i-1]){
			printf("%d %d\n",i,i+1);
			exit(0);
		}
		if(i!=1){
			if(s[i]==s[i-2]){
				printf("%d %d\n",i-1,i+1);
				exit(0);
			}
		}
	}
	printf("-1 -1\n");
}

Measured memory_bytes: 512
import java.util.Scanner;
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 = 0;
    for(int i = 1;;i++){
      c += 2 * b + 1;
      if(a <= c){
        System.out.println(i);
        break;
      }
    }
  }
}

Measured memory_bytes: 21844
#include <cstdio>

int main() {
	int n, m, Ai, Bj, max;
	int A[1000];
	int count[1000] = {0};
	int maxcount = 0;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < n; i++) {
		scanf("%d", &Ai);
		A[i] = Ai;
	}
	for(int j = 0; j < m; j++) {
		scanf("%d", &Bj);
		for(int i = 0; i < n; i++) {
			if(A[i] <= Bj) {
				count[i]++;
				break;
			}
		}
	}
	for(int i = 0; i < n; i++) {
		if(count[i] > maxcount) {
			maxcount = count[i];
			max = i + 1;
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 1032
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  int N, M;
  cin >> N >> M;
  vec<int> counts(N + 1, 0);
  REP(i, M) {
    int a, b;
    cin >> a >> b;
    counts[a]++;
    counts[b]++;
  }
  REP1(i, N) cout << counts[i] << endl;
  return 0;
}


Measured memory_bytes: 3580
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n;
	cin>>n;
	vi a(n),b(n),p;
	for0(i,n)cin>>a[i];
	for0(i,n)cin>>b[i];
	for1(i,n)p.pb(i);
	int cnt=0,x,y;
	do{
		cnt++;
		if(p==a)x=cnt;
		if(p==b)y=cnt;
		}while(next_permutation(p.begin(),p.end()));
		
	cout<<abs(x-y)<<nw;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i < (n); i++)

int main(){
    int n;
    cin >> n;
    int ans = ceil(n / 2.0);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] ble){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double inv = 0;
		for(int i = 0; i < n; i++){
			double a = sc.nextDouble();
			inv += 1/a;
		}
		System.out.println(1/inv);
	}
}


Measured memory_bytes: 22996
#define _CRT_SECURE_NO_DEPRECATE
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
#define int long long int
#define SYNC std::ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define FRE freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
typedef long double ld;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<ii>   vii;
//typedef tree<int, null_type, less<int>, rb_tree_tag, 
//             tree_order_statistics_node_update> 
//    ost;
#define rep(i,l,r)   for (int i = (l); i < (r); i++)
#define here cout << " Hey!!\n";
#define  pb push_back
#define  F  first
#define  S  second
#define all(v) (v).begin(),(v).end()
#define sz(a) (int)((a).size())
#define sq(x) ((x)*(x))
template <typename T>
void etch(T V) {
	for (auto x : V)	cout << x << ' ' ;
	cout << '\n';
}
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifndef ONLINE_JUDGE
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
const int MOD = 1e9+7;
const int MOD1 = 998244353;
const int N = 2e5+5;
const int INF = 1000111000111000111LL;
const ld EPS = 1e-12;
const ld PI = 3.141592653589793116;

int32_t main()
{
	SYNC
	int n; cin >> n;
	vi ans(n+1, 0);
	rep(x,1,n+1) {
		if(sq(x) > n)	break;
		rep(y,1,n+1) {
			if(sq(x)+sq(y)+ x*y > n)	break;
			rep(z,1,n+1) {
				if(sq(x) + sq(y) + sq(z) + x*y + y*z + x*z > n)
					break;
				ans[sq(x) + sq(y) + sq(z) + x*y + y*z + z*x]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 3628
using System;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
using System.Linq.Expressions;

static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

class Magatro
{
    private string S;
    private void Scan()
    {
        S = Console.ReadLine();
    }

    public void Solve()
    {
        Scan();
        bool c = false;
        foreach (char item in S)
        {
            if(item == 'C')
            {
                c = true;
            }
            if(item == 'F')
            {
                if (c)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
        }
        Console.WriteLine("No");
    }
}

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

int main(){
  int n;cin >> n;
  vector<int> b(n);for(int i=0;i<n-1;i++)cin >> b[i];
  vector<int> a(n);
  int ans = 0;
  a[0] = b[0];
  ans += a[0];
  b[n-1] = 1000000;
  for(int i=1;i<n;i++){
    a[i] = min(b[i-1],b[i]);
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def lcs_hs(s1, s2):
    from bisect import bisect_left

    s2, lis, result = s2[::-1], [], 0
    find, append = s2.find, lis.append

    for c in s1:
        i = find(c)+1
        while i:
            j = bisect_left(lis, -i)
            if j >= result:
                append(-i)
                result += 1
            else:
                lis[j] = -i
            i = find(c, i)+1

    return result


print(*(lcs_hs(input(), input()) for _ in [0]*int(input())), sep="\n")


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

int main(){
vector<double> v;
	int n,z;
double n2,a,sum=0,x,box=100000;
	cin >> n;
n2=n;
for(int i=0;i<n;i++){
 cin>>a;
v.push_back(a);
sum+=a;
}
sum/=n2;

for(int i=0;i<n;i++){
if(v[i]<=sum) x=sum-v[i];
else x=v[i]-sum;

if(box>x){
box=x;
z=i;
}
}

	cout << z  << endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(lambda x:-int(x),input().split()))
import heapq  # heapqライブラリのimport
heapq.heapify(a)
for _ in range(m):
  ai=heapq.heappop(a)
  heapq.heappush(a, (ai+2-1)//2)
print(-sum(a))
#print(a)


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//size() use int
//__gcd, atan2(y,x)=y/x , __int128
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//watch out LL
//INT_MAX 127,INT_MIN 128
int n;
int a[N],b[N],t[N];
int tot=0,ans;
int main(){Accel
	cin>>n;
	FOR(i,1,n)cin>>a[i];
	FOR(i,1,n)cin>>b[i];
	for(int i=29;~i;i--){
		int T=1<<i+1;
		tot=0;
		FOR(j,1,n)t[j]=b[j]%T;
		sort(t+1,t+1+n);
		FOR(j,1,n){
			int A=a[j]%(T/2);
			int L=lower_bound(t+1,t+1+n,T-A)-lower_bound(t+1,t+1+n,T/2-A);
			tot+=a[j]&T/2?n-L:L;
			tot&=1;
		}
		ans|=tot<<i;
		
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 9216
n=int(input())
h=list(map(int,input().split()))
min_cost=[0]*n
min_cost[0]=0
min_cost[1]=abs(h[1]-h[0])
for i in range(2,n):
    min_cost[i]=min(min_cost[i-1]+abs(h[i]-h[i-1]),min_cost[i-2]+abs(h[i]-h[i-2]))
print(min_cost[-1])

Measured memory_bytes: 52208
n, x = map(int, input().split())
a = [int(x) for x in input().split()]
original_sum = sum(a)
for i in range(n-1):
    if x < a[i] + a[i+1]:
        new = x - a[i]
        if 0 <= new:
            a[i+1] = new
        else:
            a[i] += new
            a[i+1] = 0
else:
    print(original_sum - sum(a))

Measured memory_bytes: 14068
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	T, X := sc.nextFloat(), sc.nextFloat()
	fmt.Println(T / X)
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<map>
#include<set>
#define ll long long
#define dou(s) atof(s.c_str())
#define lon(s) atoll(s.c_str())
#define str(n) to_string(n)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define fion(n) fixed<<setprecision(n)
#define endl "\n"
#define OR ||
#define AND &&
#define NOT !
#define line(s) getline(cin,s)
#define MOD 1000000007ll
#define START int main(){cin.tie(0);ios::sync_with_stdio(false);
#define END }
using namespace std;
void f(vector<vector<ll> > &c, ll n, vector<ll> &d) {
	rep(i, 0, c[n].size()) {
		d[c[n][i]] = d[n] + 1;
		f(c, c[n][i], d);
	}
}
START
ll n; cin >> n;
vector<ll> p(n, -1), d(n, 0);
vector<vector<ll> > c(n);
rep(i, 0, n) {
	ll k; cin >> i >> k;
	rep(j, 0, k) {
		ll m; cin >> m;
		c[i].push_back(m);
		p[m] = i;
	}
}
ll s;
rep(i, 0, n) {
	if (p[i] == -1) {
		s = i;
		break;
	}
}
f(c, s, d);
rep(i, 0, n) {
	cout<<"node "<<i<<": parent = "<<p[i]<<", depth = "<<d[i]<<", ";
	if (p[i] == -1)cout << "root, [";
	else if (c[i].size() == 0)cout << "leaf, [";
	else cout << "internal node, [";
	rep(j, 0, c[i].size()) {
		if (j == c[i].size() - 1)cout << c[i][j];
		else cout << c[i][j] << ", ";
	}
	cout << "]" << endl;
}
END


Measured memory_bytes: 8068
while True:
    a, b = [int(x) for x in input().split()]
    if a | b == 0:
        break
 
    n = int(input())
 
    dp = [
        [0] * (b + 1)
        for x in range(a + 1)
    ]
    dp[0][1] = 1
 
    for i in range(n):
        x, y = [int(x) for x in input().split()]
        dp[x][y] = -1
 
    for i in range(1, a + 1):
        for j in range(1, b + 1):
            if dp[i][j] == -1:
                dp[i][j] = 0
            else:
                dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
 
    print(dp[a][b])


Measured memory_bytes: 5600
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    #n = int(stdin.readline().rstrip())
    #l = list(map(int, stdin.readline().rstrip().split()))
    n,q = map(int, stdin.readline().rstrip().split())
    s = str(stdin.readline().rstrip())
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    cum = [0]*(n)
    cum[0] = 0
    for i in range(1,n):
        if s[i-1:i+1] == "AC":
            cum[i] = cum[i-1] + 1
        else:
            cum[i] = cum[i-1]
    for i in range(q):
        l,r = map(int, stdin.readline().rstrip().split())
        print(cum[r-1] - cum[l-1])

main()


Measured memory_bytes: 6308
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

s = sr()
if s[-1] == 's':
    print('{}es'.format(s))
else:
    print('{}s'.format(s))

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

int main(void) {
	char tmp[1000];
	//????????¢???????¨?
	int height[300];
	int width[300];
	int cnt=0;
	//????????¢???????¨??????\???????¶???????
	while (1) {
		fgets(tmp, sizeof(tmp), stdin);
		height[cnt] = atoi(strtok(tmp," "));
		width[cnt] = atoi(strtok(NULL, " "));
		//????????¨???0????????°?????????
		if (height[cnt]==0&&height[cnt]==0)break;
		cnt++;	
	}
	//??¨??????????§???¢???????????????
	int i, j,k;
	for (i = 0; i < cnt; i++) {
		for (j = 0; j < height[i]; j++) {
			for (k = 0; k < width[i]; k++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");

	}
	return 0;
}

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



// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long H, W, K;
    cin >> H >> W >> K;
    vector<string> C(H);

    for(long long i = 0; i < H; i++){
      cin >> C[i];
    }

    long long count = 0;

    for(long long bits = 0; bits < (1<<H+W); bits++){
      long long i = bits & ((1<<H)-1);
      long long x = (bits>>H) & ((1<<W)-1);
      //cout << i << " " << x << endl;
      long long blacks = 0;
      for(long long m = 0; m < H; m++){
        for(long long n = 0; n < W; n++){
          if(((i>>m) & 0b1) || ((x>>n) & 0b1)) {
            //cout << "*";
          }
          else if(C[m][n] == '#') {
            blacks++;
            //cout << "#";
          }
          else {
            //cout << ".";
          }
        }

        //cout << endl;
      }
      //cout << endl;

      if(blacks == K) count++;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3632
N, K = [int(i) for i in input().split()]
hs = list()
for i in range(N):
    hs.append(int(input()))
hs = sorted(hs)
diffs = list()
for i in range(N - K + 1):
    diffs.append(hs[i+K-1] - hs[i])
print(min(diffs))

Measured memory_bytes: 10892
import math
A = int(input())
B = int(input())
if B < A: A,B = B,A

if A == B:
    print(1)
else:
    t = int(math.floor(math.log2(B)))
    while (A & 2**t) == (B & 2**t):
        if A & 2**t:
            A -= 2**t
            B -= 2**t
        t-=1
    ans = 2**t - A              # [A,2^t-1]
    r = t-1
    while 2**t + 2**r > B and r>=0:
        r-=1
    # [2^t,2^t+2^{r+1}-1] \cup [2^t+A,2^{t+1}-1]
    C = 2**(r+1)
    if C < A:
        ans += C + 2**t - A
    else:
        ans += 2**t
    print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const int MOD = 1000000007;

int main(){
  ll N;
  ll trans[5];
  cin >> N;
  for (int i = 0; i < 5; i++) cin >> trans[i];
  ll mini = *min_element(trans, trans + 5);
  cout << (N+mini-1)/mini+ 4 << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

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

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

    int idx = 0,
        ans = 0;
    while (idx < N) {
        if (p[idx] == idx) {
            ans++;
            idx += 1;
        }
        idx += 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
const ll INF = 1LL<<60;
const ll mod=1e9+7;
using namespace std;
ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

ll a[110000];
vector<ll> ap,am;
vector<ll>x,y;
int main(){
    ll n,t,a1,a2,cnt=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    rep(i,0,n-1){
        if(a[i]<0)am.pb(a[i]);
        else ap.pb(a[i]);
    }
    if(am.empty()){a2=ap[0];cnt++;}
    else if(ap.empty()) {a1=am[am.size()-1];a2=am[0];cnt++;}
    else a2=am[0];
    a1=a[n-1];
    while(cnt<ap.size()){
        x.pb(a2),y.pb(ap[cnt]);
        a2-=ap[cnt];
        cnt++;
    }
    x.pb(a1),y.pb(a2);
    a1-=a2;
    cnt=1;
    
    while(cnt<am.size()){
        x.pb(a1),y.pb(am[cnt]);
        a1-=am[cnt];
        cnt++;
    }
    cout<<a1<<endl;
    rep(i,0,x.size())cout<<x[i]<<" "<<y[i]<<endl;

}

Measured memory_bytes: 6004
#include<iostream>
#include<string>

using namespace std;

int main(void){

    string str1, str2;
    cin >> str1 >> str2;

    for(int i = 0;str1[i] != '\0';i++){
        char temp;
        temp = str1[str1.length()-1];
        str1.erase(str1.length()-1);
        str1 = temp + str1;

        if(str1 == str2){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;


    return 0;
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
con = [[1,0],[0,1],[-1,0],[0,-1]]
m=[]
c = 0
d = [[0]*(W+2) for _ in range(H+2)]
d[1][1]= 1
m.append("#"*(W+2))
for i in range(H):
    b = input()
    c +=b.count(".")
    a= "#"+b+"#"
    m.append(a)
q = deque()
m.append("#"*(W+2))
q.append((1,1))

while len(q)>0:
    y,x = q.popleft()
    if y == H and x == W:
        print(c-d[H][W])
        exit()
    for dx,dy in con:
        #print(y+dy,x+dx,d[y+dy][x+dx])
        if d[y+dy][x+dx] == 0 and m[y+dy][x+dx] ==".":
            q.append((y+dy,x+dx))
            d[y+dy][x+dx]+=d[y][x]+1
    #print(q)
print(-1)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <vector>
using namespace std;

#define bll long long
#define dou double
#define For(i,a,b) for (int i=(a),_##i=(b); i<=_##i; ++i)
#define Rof(i,a,b) for (int i=(a),_##i=(b); i>=_##i; --i)
#define Mem(a,b) memset(a,b,sizeof(a))
#define Cpy(a,b) memcpy(a,b,sizeof(b))

int calc(int x)
{
    int sum=0;
    while(x)
    {
        sum+=x%10;
        x/=10;
    }
    return sum;
}

int main()
{
    int n,a,b;
    for (; scanf("%d%d%d",&n,&a,&b)!=EOF; )
    {
        int ans=0;
        For(i,1,n)
        {
            int g=calc(i);
            if (a<=g && g<=b) ans+=i;
        }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int64 n, a[200200], cnt[200200];

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

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

    int64 total = 0;
    for(int i = 1; i <= n; ++i) {
        total += cnt[i] * (cnt[i] - 1) / 2;
    }

    rep(i, n) {
        int x = cnt[a[i]];
        print(total - x * (x - 1) / 2 + (x - 1) * (x - 2) / 2);
    }

    return 0;
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main()
{
    int k;cin>>k;
    cout<<a[k-1];
}


Measured memory_bytes: 256
//おまじない
//#include <bits/stdc++.h>
#include <iostream>
#include<iomanip>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define space ' '
#define pll pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    ll a;
    cin >> a;
    cout << a*a<<endl;
    
    return 0;
}


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

using int64 = long long;
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

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

   if (a * b % 2 == 1) {
      puts("Yes");
   } else {
      puts("No");
   }

   return 0;
}

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

int main()
{
  int n, k, sum = 0;
  vector<int> p;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    int tmp;
    cin >> tmp;
    p.push_back(tmp);
  }
  sort(p.begin(), p.end());
  for (int i = 0; i < k; i++)
  {
    sum += p[i];
  }
  cout << sum << endl;
}


Measured memory_bytes: 3632
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            final String s = reader.readLine();

            final String sl[] = s.split(" ");
            char a = sl[0].charAt(0);
            char b = sl[1].charAt(0);

            System.out.println(a == 'H' ? b : b == 'H' ? 'D' : 'H');
        }
    }
}


Measured memory_bytes: 21076
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <complex> 
using namespace std;
typedef complex<double> xy_t;
xy_t P[30];
int N=0;
double x,y;
int main() {
double s =0.0;
while (scanf("%lf,%lf", &x,&y) != EOF) {
	P[N] = xy_t(x,y);
	N += 1;
}
for ( int i = 0; i+2 < N;i++ ){
	xy_t a = P[i+1] - P[0], b = P[i+2]-P[0];
	s += - (a.real()*b.imag()-a.imag()*b.real())/2;
}
printf("%.6f\n", abs(s));
}

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

int main() {
	int n, t, x;
	cin >> n >> x >> t;
	if (n % x != 0) {
		cout << t * ((n / x) + 1) << "\n";
	}
	else {
		cout << t * n / x << "\n";
	}
	return 0;
}

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

int main(){
int a,b,c,x;
cin >> a>>b>>c>>x;

ll counter=0;
a++;b++;c++;
rep(i,a)
{
    rep(j,b)
    {
        rep(k,c)
        {
            if((500*i)+(100*j)+(50*k)==x)
            {counter++;}
        }
    }
}

cout<<counter<<endl;




    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define fori(i,n) for(i=0; i<n; i++)
#define ford(i,n) for(i=n-1; i>=0; i--)
#define vi vector<int> 
#define vs vector<string>
#define vll vector<ll>
#define di deque<int>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define pqi priority_queue<int>
#define pqll priority_queue<ll>
#define mod1 1000000007
#define mod2 998244353
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define gcd __gcd

#define fast_cin() ios::sync_with_stdio(false); cin.tie(nullptr)

using namespace std;

int main(int argc, char const *argv[]){
    fast_cin();
    int n;
    cin>>n;
    cout<<(int)pow(n,2)<<"\n";
    return 0;
}


Measured memory_bytes: 256