akhauriyash/Code-Regression huggingface dataset:
while line = gets
	n, x = line.split( " " ).map { | val | val.to_i }
	break if 0 == n && 0 == x

	cnt = 0
	for i in ( 1 .. n-2 )
		if	x <= i
			break
		end
		for j in ( i+1 .. n-1 )
			if	x <= ( i+j )
				break
			end
			for k in ( j+1 .. n )
				s = ( i + j + k )
				if x == s
					cnt += 1
					break
				elsif	x < s
					break
				end
			end
		end
	end
	
	puts( cnt )
end

Measured memory_bytes: 6108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    string s;
    cin >> s;
    if(s == "RRR"){
        cout << 3 << endl;
    }else if(s == "RRS" || s == "SRR"){
        cout << 2 << endl;
    }else if(s == "SSS"){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}


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

#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(long long i=0;i<(n);i++)
#define FOR(i,a,b) for(long long i=(a);i<=(b);i++)

int main() {
  char b;
  cin >> b;
  if(b == 'A') {
    cout << 'T' << endl;
  } else if(b == 'T') {
    cout << 'A' << endl;
  } else if(b == 'C') {
    cout << 'G' << endl;
  } else {
    cout << 'C' << endl;
  }
  return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main() {
    char a[8], b[4];
    scanf("%s%s",a, b);

    int num = atoi(strcat(a, b));
    for  (int i = 1; i < num; i++) {
        if (i * i == num) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools





def main():

    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]
    count_dic = defaultdict(int)

    for i in range(high):
        for j in range(width):
            count_dic[data[i][j]] += 1

    odd, even = 0, 0
    if high % 2 and width % 2:
        odd += 1
    if high % 2:
        even += width // 2
    if width % 2:
        even += high // 2

    for key, value in count_dic.items():
        value %= 4
        # print(even, odd, value)
        if value % 2:
            odd -= 1
            value -= 1
        if value == 2:
            even -= 1
        if even < 0 or odd < 0:
            break

    if even < 0 or odd < 0:
        print('No')
    else:
        print('Yes')





if __name__ == '__main__':
    main()



Measured memory_bytes: 38896
#include <iostream>
#define llint long long

using namespace std;

llint n, mod;
llint S[3005][3005];
llint beki[3005][3005], beki2[3005];

const int FACT_MAX = 6005;
llint fact[FACT_MAX], fact_inv[FACT_MAX];

llint modpow(llint a, llint n, llint m = mod)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%m) * (modpow(a, n-1, m)%m)) % m;
	}
	else{
		return modpow((a*a)%m, n/2, m) % m;
	}
}

void make_fact()
{
	llint val = 1;
	fact[0] = 1;
	for(int i = 1; i < FACT_MAX; i++){
		val *= i;
		val %= mod;
		fact[i] = val;
	}
	fact_inv[FACT_MAX-1] = modpow(fact[FACT_MAX-1], mod-2);
	for(int i = FACT_MAX-2; i >= 0; i--){
		fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
	}
}

llint comb(llint n, llint k)
{
	llint ret = 1;
	ret *= fact[n];
	ret *= fact_inv[k], ret %= mod;
	ret *= fact_inv[n-k], ret %= mod;
	return ret;
}

int main(void)
{
	cin >> n >> mod;
	make_fact();
	
	for(int i = 0; i <= n; i++) S[i][0] = 1;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n; j++){
			S[i][j] = (j+1) * S[i-1][j] % mod + S[i-1][j-1];
			S[i][j] %= mod;
		}
	}
	beki[1][0] = beki2[0] = 1;
	for(int i = 1; i <= n; i++){
		beki[1][i] = beki[1][i-1] * 2, beki[1][i] %= mod;
		beki2[i] = beki2[i-1] * 2, beki2[i] %= mod-1;
	}
	for(int i = 0; i <= n; i++){
		beki[0][i] = 1;
		for(int j = 2; j <= n; j++){
			beki[j][i] = beki[j-1][i] * beki[1][i] % mod;
		}
	}
	for(int i = 0; i <= n; i++) beki2[i] = modpow(2, beki2[i]);
	
	llint ans = beki2[n];
	for(int i = 1; i <= n; i++){
		llint sum = 0;
		for(int j = 0; j <= i; j++){
			llint tmp = S[i][j]; tmp %= mod;
			tmp *= beki[j][n-i], tmp %= mod;
			tmp *= beki2[n-i], tmp %= mod;
			sum += tmp, sum %= mod;
		}
		sum *= comb(n, i), sum %= mod;
		
		if(i % 2) ans += mod - sum, ans %= mod;
		else ans += sum, ans %= mod;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 141312
from itertools import combinations
L,R=map(int,input().split())
ans=L*R%2019
if R-L>=2018:
    print(0)
else:
    for i in combinations(range(L,R+1),2):
        if ans>=i[0]*i[1]%2019:
            ans=i[0]*i[1]%2019
    print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int seki(int a){
    if(a/10==1||a%10==1){return -3;}
    return (a/10)*(a%10);
}
int main(){
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            if(i==seki(j)){ans++;}
        }
    }
    cout<<ans;
}

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

int board[3][3] = {0};

int main()
{
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> board[i][j];
        }
        
    }

    int N;
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        for (int j = 0; j < 3; j++)
        {
            for (int k = 0; k < 3; k++)
            {
                if (temp == board[j][k])
                {
                    board[j][k] = 0;
                }
            }
            
        }
        
    }

    bool flag = false;
    for (int i = 0; i < 3; i++)
    {
        if (board[i][0] + board[i][1] + board[i][2] == 0)
        {
            flag = true;
        }
        if (board[0][i] + board[1][i] + board[2][i] == 0)
            flag = true;
    }
    if (board[0][0] + board[1][1] + board[2][2] == 0)
        flag = true;
    if (board[0][2] + board[1][1] + board[2][0] == 0)
        flag = true;

    cout << (flag ? "Yes" : "No");
    // system("pause");
}

Measured memory_bytes: 888
import java.util.Scanner
object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val pages: Int = sc.nextInt
   
    val rs = pages match{
        case pages if pages%2==0 => pages/2
        case pages if pages%2!=0 => pages/2 + 1
    }
 
    println(rs)
    
  }
}

Measured memory_bytes: 25524
#include<cstdio>
#include<algorithm>
#define maxn 55
using namespace std;
int n,a[maxn],ans;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<n;i++)
	for (int j=i+1;j<=n;j++) ans+=a[i]*a[j];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  string S;
  cin>>S;
  int G=0,P=0;
  FOR(i,0,(int)S.size()){
    if(S[i]=='g'){
      G++;
    }else{
      P++;
    }
  }
  if(P==G){
    cout<<0<<endl;
  }else if(P<G){
    G-=P;
    cout<<G/2<<endl;
  }else if(P>G){
    P-=G;
    cout<<-(P+1)/2<<endl;
  }
  return 0;
}


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

#define PB push_back
#define MP make_pair
#define MOD 1000000000
#define FOR(i,a,b) for(int i=(a);(i)<(b);(i)++)

typedef unsigned int UI;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<char, int> PCI;
const int mod = 1000000000 + 7;
int n , m;
map<int , int> cnt;
int main()
{
	string s;
	cin >> s;
	for(int i = 0; i < s.size() - 8; i++)
		cout << s[i];
}






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

  public static void main(String[] args) {
  
  	try {
    
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String strLine = br.readLine();
      String costsLine = br.readLine();
      int n = Integer.parseInt(strLine);
      String[] costs = costsLine.split(" ");
	  int[] dp = new int[n];
      dp[0] = 0;
      dp[1] = Math.abs(Integer.parseInt(costs[1]) - Integer.parseInt(costs[0]));
      for(int i = 2; i < n ; i++) {
      	
        dp[i] = Math.min(dp[i-2] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-2])), 
                         dp[i-1] + Math.abs(Integer.parseInt(costs[i]) - Integer.parseInt(costs[i-1])));
        
      } 
    
      System.out.println(dp[n-1]);
		                         
    } catch(Exception ex) {
    
    }
  
  }

}

Measured memory_bytes: 37892
#include<iostream>
#include<algorithm>
#define MAX_N 101
using namespace std;

int a_seq[MAX_N];

int main() {
    int N, x;
    cin >> N >> x;
    for (int i = 0; i < N; i++) cin >> a_seq[i];
    sort(a_seq, a_seq + N);
    int max_count = 0;
    for (int i = 0; i < N; i++) {
        if (x >= a_seq[i]) {
            if (i == N - 1 && x != a_seq[i]) break;
            x -= a_seq[i];
            max_count++;
        }
        else break;
    }
    cout << max_count << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
if n<=3:print(max(a));exit()
if n&1:
  dp=[3*[-(10**20)]for _ in range(n)]
  dp[0][0]=a[0]
  for i in range(1,n):
    if i%2==0:
      dp[i][0]=dp[i-2][0]+a[i]
      if i>=3:dp[i][2]=max(dp[i-2][2]+a[i],dp[i-3][1]+a[i])
      else:dp[i][2]=a[i]
    else:
      if i>=3:dp[i][1]=max(dp[i-2][1]+a[i],dp[i-3][0]+a[i])
      else:dp[i][1]=a[i]
  print(max(dp[-1][2],dp[-2][1],dp[-3][0]))
else:
  b=[a[0]]
  c=[a[1]]
  for i in range(2,n):
    if i%2==0:b.append(b[-1]+a[i])
    else:c.append(c[-1]+a[i])
  ans=max(b[-1],c[-1])
  for i in range(n//2-1):
    ans=max(ans,b[i]+c[-1]-c[i])
  print(ans)

Measured memory_bytes: 114412
N,K=map(int, input().split())
A=list(map(int, input().split()))

loopcount=0
tmpPoint=1
vis={1:0}
for i in range(N):
    Next=A[tmpPoint-1]
    if Next in vis:
        startat=i
        #print(startat)
        #print(tmpPoint)
        #print(vis)
        #print(Next)
        #print(vis[Next]+1)
        loopcount=i - vis[Next]+1
        break
    vis[Next]=i+1
    tmpPoint=Next

if loopcount==0:
    print(tmpPoint)
    exit()
if startat+loopcount < K:
    nokori=(K-startat) % loopcount
    K=startat+nokori

tmpPoint=1
for i in range(K):
    Next=A[tmpPoint-1]
    tmpPoint=Next
print(tmpPoint)

Measured memory_bytes: 38652
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
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;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

map<ll,ll> prime_factor(ll n){
    map<ll,ll> mp;
    for(ll i=2; i*i<=n; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n != 1) mp[n] = 1;
    return mp;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll h,ans=0;
    cin >> h;
    ll x=1;
    while(x<=h){
        x*=2;
    }
    while(x>=1){
        x/=2;
        ans+=x;
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

void mainSolve()
{
  get(n);
  map<ll, ll> m;
  for (ll x = 1; x <= 100; x++)
    for (ll y = 1; y <= 100; y++)
      for (ll z = 1; z <= 100; z++)
      {
        ll term = (x * x) + (y * y) + (z * z) + (x * y) + (y * z) + (z * x);
        ++m[term];
      }
  for (int i = 1; i <= n; i++)
    p1(m[i]);
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  // get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 6116
n=int(input())
v=list(map(int,input().split()))

l=[v[i] for i in range(n) if i%2==0]
r=[v[i] for i in range(n) if i%2]

l.sort()
r.sort()

count=1
countl1=0
countl2=0

for i in range(1,len(l)):
    if l[i]==l[i-1]: count+=1
    else:
        if count>=countl1:
            countl1,countl2=count,countl1
            charl=l[i-1]
        elif count>countl2:
            countl2=count
        count=1
        
if count>=countl1:
    countl1,countl2=count,countl1
    charl=l[-1]
elif count>countl2:
    countl2=count 


count=1
countr1=0
countr2=0

for i in range(1,len(r)):
    if r[i]==r[i-1]: count+=1
    else:
        if count>=countr1:
            countr1,countr2=count,countr1
            charr=r[i-1]
        elif count>countr2:
            countr2=count
        count=1

if count>=countr1:
    countr1,countr2=count,countr1
    charr=r[-1]
elif count>countr2:
    countr2=count 
        
if charl==charr:
    print(n-max(countl1+countr2,countl2+countr1))
else: print(n-countl1-countr1)

Measured memory_bytes: 13992
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random


def I(): return int(input())


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


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['Yes', 'No']
MOD = 10**9+7
inf = float('inf')
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)


show_flg = False
# show_flg = True


def main():
    M1, D1 = MI()
    M2, D2 = MI()

    if M1 != M2:
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 66156
#include <iostream>
#include <vector>
using namespace std;
const char* solve() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (auto& i : H) cin >> i;
    for (int i = N - 2; i >= 0; i--) {
        if (H[i] > H[i + 1] + 1) return "No";
        if (H[i] == H[i + 1] + 1) H[i]--;
    }
    return "Yes";
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    double v[n];
    REP(i,n)cin >> v[i];
    //sort(v[0],v[n-1]);
    double ans=0;
    for (int i=0; i<n; ++i) {
    for (int j=i+1; j<n; ++j) {
      if (v[i] > v[j]) {
        int tmp;
        tmp =  v[i];
        v[i] = v[j];
        v[j] = tmp;
      }
    }
  }

    ans=((double)v[0]+(double)v[1])/2;
    for(int i=2;i < n;i++){
        ans = (ans+(double)v[i])/2;
    }
    printf("%.6f\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, n, a, ans = 0;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) scanf("%d", &a), ans += a, ans &= 1;
  printf("%s", ans ? "NO" : "YES");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
ll c=0;
void solve()
{
    ll n,m;  cin>>n>>m;
    string str;
    vector<vector<char>> arr(n,vector<char>(m));
    rep(i,0,n)
    {
        cin>>str;
        rep(j,0,m) arr[i][j]=str[j];

    }
    vector<vector<ll>> dp(n,vector<ll>(m,0));
    dp[0][0]=1;
    rep(i,0,n)
    {
        rep(j,0,m)
        {
            if(arr[i][j]=='#') {  dp[i][j]=0;  continue;   }
            if(i>0 and j>0) dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
            else if(j==0 and i>0) dp[i][j]=dp[i-1][j]%mod;
            else if(i==0 and j>0) dp[i][j]=dp[i][j-1]%mod;
            dp[i][j]%=mod;
        }
    }cout<<dp[n-1][m-1]%mod;
}
int main()
{
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 12104
#include<iostream>
using namespace std;
int main()
{
	int t = 0;
	int n;
	cin >> n;
	int* A = new int[n];



	for (int i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	for (int i = 0; i < n; i++)
	{
		int minIndex = i;
		for (int j = i + 1; j < n; j++)
		{
			if (A[j] < A[minIndex])
				minIndex = j;
		}
		if (minIndex != i)
		{
			swap(A[i], A[minIndex]);
			t++;
		}
	}

	for (int i = 0; i < n; i++)
	{
		if (i == n - 1)
			cout << A[i] << endl;
		else
			cout << A[i] << " ";
	}


	cout << t << endl;












	delete[]A;
	return 0;

}


Measured memory_bytes: 3088
import sys
sys.setrecursionlimit(300000)
from math import sqrt, ceil
from collections import defaultdict

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI0(): return map(lambda s: int(s) - 1, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
def LMI0(): return list(map(lambda s: int(s) - 1, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N = I()

n = ceil(sqrt(N))
d = defaultdict(int)
for x in range(1, n + 1):
    for y in range(1, n + 1):
        for z in range(1, n + 1):
            a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if a <= N:
                d[a] += 1
for i in range(1, N + 1):
    print(d[i])

Measured memory_bytes: 75636
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a)
flag = True
for i in range(m):
    if a[i] < 1/(4*m)*s:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections


n,m = map(int, input().split())
par = [i for i in range(n)]
rank = [0]*n

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

def main():
    for _ in range(m):
        a,b = map(int, input().split())
        unite(a-1,b-1)

    count = [0]*n
    for p in par:
        count[find(p)] += 1
    print(max(count))


if __name__ == '__main__':
    main()


Measured memory_bytes: 88500
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=1010;
ll dp[N][N],pd[N][N];
ll fac[N],fnv[N];
int n,a[N],b[N],m;
ll s;
int main() {
	scanf("%d",&n);
	rep(i,0,n) scanf("%d%d",a+i,b+i),s+=a[i];
	m=s;
	s=powmod(s,mod-2);
	dp[0][0]=1;
	fac[0]=fnv[0]=1;
	rep(i,1,1001) fac[i]=fac[i-1]*i%mod,fnv[i]=powmod(fac[i],mod-2);
	rep(i,0,n) {
		ll prob=a[i]*s%mod;
		vector<pair<pair<int,int>,int>> c;
		c.pb(mp(mp(a[i],0),1));
		ll pc=1;
		rep(j,0,b[i]) {
			c.pb(mp(mp(0,j),mod-pc*fnv[j]%mod));
			pc=pc*prob%mod;
		}
		rep(p,0,501) rep(q,0,501) pd[p][q]=dp[p][q],dp[p][q]=0;
		rep(p,0,501) rep(q,0,501) if (pd[p][q]) {
			for (auto x:c) {
				int u=x.fi.fi,v=x.fi.se;
				dp[p+u][q+v]=(dp[p+u][q+v]+pd[p][q]*x.se)%mod;
			}
		}
	}
	int ans=0;
	rep(i,0,m) rep(j,0,501) if (dp[i][j]) {
		ll val=mod-dp[i][j];
		ll prob=i*s%mod;
//		
		//  e^(p x) * x^j
		ans=(ans+val*powmod(mod+1-prob,mod-2-j)%mod*fac[j])%mod;
//		%mod);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 10624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1e9 + 7;
const long long INF = 1LL << 60;

int main() 
{
    int n; cin >> n;
    if(n==2){
        int a,b;
        cin >> a >> b;
        for(int i = 1; i <= min(a,b); i++){
            if(a % i == 0 && b % i == 0){
                cout << i << endl;
            }
        }
    }else{
        int a,b,c;
        cin >> a >> b >> c;
        for(int i = 1; i <= min({a,b,c}); i++){
            if(a % i == 0 && b % i == 0 && c % i == 0){
                cout << i << endl;
            }
        }
    }
}


Measured memory_bytes: 3084
// A - αlphabet.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>

int main()
{
    char a;
    std::cin >> a;

    if (a >= 'A' && a <= 'Z') std::cout << 'A';
    else std::cout << 'a';
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;

long long int mod=1e9+7;

int main(){
  int n;
  cin>>n;
  if(n==0){
    cout<<0<<endl;
    return 0;
  }
  vector<char> ans;
  while(n!=0){
    if(n%2!=0){
      ans.push_back('1');
      n--;
    }else{
      ans.push_back('0');
    }
    n/=-2;
  }
  for(int i=ans.size()-1;i>=0;i--){
    cout<<ans[i];
  }
  cout<<endl;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
  int N;
  cin>>N;
  int C[N],V[N];
  rep(i,N)
    cin>>V[i];
  rep(i,N)
    cin>>C[i];
  int mx=0;
  rep(i,N){
    if(V[i]>C[i])
      mx+=V[i]-C[i];
  }
  cout<<mx<<endl;
  return 0;
}


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

int main(){
  int N, M, P, X, S = 0;
  cin >> N;
  
  vector<int> T(N);
  for (int i = 0; i < N; i++){
    cin >> T.at(i);
    S += T.at(i);
  }
  
  cin >> M;
  
  for (int i = 0; i < M; i++){
    cin >> P >> X;
    cout << S - T.at(P-1) + X << endl;
  }
}

Measured memory_bytes: 256
S = input()
max = 0
import re
for i in range(len(S)):
    for j in range(i+1, len(S)+1):
        if re.search("[^ATCG]", S[i:j]):
            pass
        else:
            if max < len(S[i:j]):
                max = len(S[i:j])
print(max)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
   long long int t,n,c[200001]={},a,ans=0,str;
   vector<long long int> v,v1,v2;
   cin>>n;
   for(int i=0;i<n;i++)
   {
      cin>>a;
      v.push_back(a);
      c[a]++;
   }
   for(int i=1;i<=n;i++)
   {
      if(c[i]>1)
      ans=ans+(c[i]*(c[i]-1))/2;
   }
   for(int i=0;i<n;i++)
   {
      str=ans-(c[v[i]]*(c[v[i]]-1))/2;
      cout<<str+((c[v[i]]-1)*(c[v[i]]-2))/2<<endl;
   }
   return 0;
}


Measured memory_bytes: 5872
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<vector<int>> path(n);
  for (int i = 0; i < m; ++i)
  {
    int a,b;
    cin>>a>>b;
    a--;b--;
    path[a].push_back(b);
    path[b].push_back(a);
  }
  vector<int> signpost(n,-1);
  vector<bool> seen(n,false);
  queue<int> que;
  que.push(0);
  seen[0]=true;
  signpost[0]=0;
  while(!que.empty())
  {
    int now=que.front();
    que.pop();
    for (int i = 0; i < path[now].size(); ++i)
    {
      if(!seen[path[now][i]]) 
      {
        signpost[path[now][i]]=now;
        seen[path[now][i]]=true;
        que.push(path[now][i]);
      }
    }
  }
  cout<<"Yes"<<endl;
  for (int i = 1; i < signpost.size(); ++i)
  {
    cout<<signpost[i]+1<<endl;
  }
}

Measured memory_bytes: 10120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll h, w, k;
  cin >> h >> w >> k;
  vector<string> s(h);
  REP(i, h) { cin >> s[i]; }
  vector<vector<ll>> sum(h + 1, vector<ll>(w + 1, 0));
  FOR(i, 1, h + 1) {
    REP(j, w) { sum[i][j + 1] += sum[i][j] + (s[i - 1][j] == '1'); }
  }
  REP(j, w + 1) REP(i, h) { sum[i + 1][j] += sum[i][j]; }
  // REP(i, h + 1) {
  //   REP(j, w + 1) { cout << sum[i][j] << " \n"[j == w]; }
  // }

  ll ans = 1e18;
  REP(bit, (1LL << (h - 1))) {
    ll cnt = 0;
    vector<ll> c;
    c.push_back(0);
    REP(i, h - 1) {
      if (bit & (1LL << i)) {
        c.push_back(i + 1);
        cnt++;
      }
    }
    c.push_back(h);
    ll l = 0, r = 1;
    while (r <= w) {
      bool ok = true;
      FOR(j, 1, SZ(c)) {
        ll d = c[j], u = c[j - 1];
        ll white = sum[d][r] - sum[d][l] - sum[u][r] + sum[u][l];
        // DUMP(d);
        // DUMP(u);
        // DUMP(white);
        if (white > k) {
          ok = false;
          break;
        }
      }

      // ok
      if (ok) {
        r++;
        continue;
      }
      // ng
      if (r - l == 1) {
        cnt = 1e18;
        break;
      }
      cnt++;
      l = r - 1;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
}

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

int main(){
  int n,k=0,count=0;
  cin >> n;
  vector<int> d(n);
  for(int i=0;i<n;i++)cin >> d.at(i);
  sort(d.begin(),d.end());
  for(int i=0;i<n;i++){
    if(k==d.at(i))continue;
    k=d.at(i);
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
  int a;
  cin >> a;
  if(400<=a && a<=599){
    cout << 8 << endl;
  }else if(600<=a && a<=799){
    cout << 7 << endl;
  }else if(800<=a && a<=999){
    cout << 6 << endl;
  }else if(1000<=a && a<=1199){
    cout << 5 << endl;
  }else if(1200<=a && a<=1399){
    cout << 4 << endl;
  }else if(1400<=a && a<=1599){
    cout << 3 << endl;
  }else if(1600<=a && a<=1799){
    cout << 2 << endl;
  }else if(1800<=a && a<=1999){
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

using namespace std;

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

int main(){

	char buf[10];
	ll base = 0,cicle_left = 0,cicle = 0,base_len = 0,cicle_left_len = 0,cicle_len = 0;
	ll ans_left,ans_right,common;
	bool FLG = false;
	int index;

	scanf("%s",buf);

	for(index = 0; buf[index] != '.';index++){
		base = 10*base + buf[index] - '0';
		base_len++;
	}

	index++;

	for(;buf[index] != '\0' && buf[index] != '(';index++){
		cicle_left = 10*cicle_left + buf[index] - '0';
		cicle_left_len++;
	}

	if(buf[index] == '('){
		FLG = true;
		index++;
		for(;buf[index] != ')';index++){
			cicle = 10*cicle + buf[index] - '0';
			cicle_len++;
		}
	}

	if(FLG){
		ans_left = base*pow(10,cicle_left_len+cicle_len)
				+cicle_left*pow(10,cicle_len)+cicle;

		ans_left -= base*pow(10,cicle_left_len)+cicle_left;

		ans_right = pow(10,cicle_left_len+cicle_len) - pow(10,cicle_left_len);

		if(ans_left > ans_right){
			common = calc(ans_left,ans_right);
		}else{
			common = calc(ans_right,ans_left);
		}

		printf("%lld/%lld\n",ans_left/common,ans_right/common);

	}else{
		ans_left = base*pow(10,cicle_left_len)+cicle_left;
		ans_right = pow(10,cicle_left_len);
		if(ans_left > ans_right){
			common = calc(ans_left,ans_right);
		}else{
			common = calc(ans_right,ans_left);
		}
		printf("%lld/%lld\n",ans_left/common,ans_right/common);
	}

	return 0;
}

Measured memory_bytes: 2912
#include <iostream>
#include <assert.h>
using namespace std;

bool r[8],c[8],dl[15],dr[15],T[8][8];
int k;

bool tryput(int i){
  if (r[i])return tryput(i+1);
  if (i>7) return true;
  for (int j=0;j<8;j++){
    if (c[j]||dl[i+j]||dr[i-j+7])continue;
    T[i][j]=true;
    r[i]=c[j]=dl[i+j]=dr[i-j+7]=true;
    if (tryput(i+1))return true;
    r[i]=c[j]=dl[i+j]=dr[i-j+7]=false;
    T[i][j]=false;
  }
  return false;
}

int main(){
  int x,y;
  
  cin >>k;
  for (int i=0;i<k;i++){
    cin >>y>>x;
    T[y][x]=true;
    r[y]=c[x]=dl[x+y]=dr[y-x+7]=true;
  }
  
  tryput(0);

  for (int i=0;i<8;i++){
    for (int j=0;j<8;j++){
      if (T[i][j]) cout << "Q";
      else cout << ".";
    }
    cout << endl;
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int H,W,N;

int field[1003][1003];

int sum[1003][1003];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
    cin >> H >> W >> N;
    if(H == 0) break;
    
    memset(sum,0,sizeof(sum));

    for (int i = 0;i < H;i++){
        for (int j = 0;j< W;j++){
            cin >> field[i][j];
        }
    }

    sum[0][0] = N-1;

    for (int i = 0;i < H;i++){
        for (int j = 0;j < W;j++){
            sum[i+1][j] += sum[i][j]/2;
            sum[i][j+1] += sum[i][j]/2;
            if(sum[i][j]%2 != 0){
                if(field[i][j] == 0) sum[i+1][j]++;
                else sum[i][j+1]++;
            }
        }
    }

    for (int i = 0;i < H;i++){
        for (int j = 0;j< W;j++){
            field[i][j] = (field[i][j]+sum[i][j])%2;
        }
    }

    int x = 0,y = 0;
    while(!(x == W || y == H)){
        if(field[y][x] == 0) y++;
        else x++;
    }

    cout << ++y << " " << ++x << endl;}

    return 0;

}


Measured memory_bytes: 10964
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <algorithm>

bool card[4][14];
using namespace std;
int main(){
	// S, H, C, D
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		char ch; int m;
		cin >> ch >> m;
		switch (ch){
		case 'S': { card[0][m] = true; break; }
		case 'H': { card[1][m] = true; break; }
		case 'C': { card[2][m] = true; break; }
		case 'D': { card[3][m] = true; break; }
		}
	}
	for (int i = 0; i < 4; ++i){
		for (int j = 1; j <= 13; ++j){
			if (card[i][j] == false){
				switch (i){
				case 0: { cout << 'S' << ' '; break; }
				case 1: { cout << 'H' << ' '; break; }
				case 2: { cout << 'C' << ' '; break; }
				case 3: { cout << 'D' << ' '; break; }
				}
				cout << j << '\n';
			}
		}
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<stack>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define rrep(i,a,b) for(int i=a;i>b;i-=1)
#define vi vector<int>
#define vii vector<vector<int> >
#define all(c) (c).begin(),(c).end()
#define pb push_back
int solve()
{
    ll n,q,h,s,d;
    cin>>q>>h>>s>>d>>n;
    ll ans=1000000000000000000;
    ans=min(ans,4*n*q);
    ans=min(ans,2*n*h);
    ans=min(ans,n*s);
    ans=min(ans,((n/2)*d)+((n%2)*s));
    ans=min(ans,((n/2)*d)+((n%2)*4*q));
    ans=min(ans,((n/2)*d)+((n%2)*2*h));
    cout<<ans;
    return 0;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 256
x,y=map(int,input().split())
ans=0
if x==1:
  ans=ans+300000
elif x==2:
  ans=ans+200000
elif x==3:
  ans=ans+100000

if y==1:
  ans=ans+300000
elif y==2:
  ans=ans+200000
elif y==3:
  ans=ans+100000
if x==1and y==1:
  ans=ans+400000
print(ans)

Measured memory_bytes: 38256
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <ctime>
#include <cmath>
#include <iomanip>
#include <queue>
#include <deque>
#include <fstream>
#include <bitset>
#include <cassert>
using namespace std;
 
#define int long long
#define double long double
#define mp make_pair
#define all(a) a.begin(), a.end()
#define pb push_back
#define debug(x) cerr << #x << ": " << x << '\n';
#define ppoint(p) cout << #p << ' ' << p.x << ' ' << p.y << '\n';
#define fi first
#define se second
#define FOR(i, n) for (int i = 0; i < n; ++i)
//typedef long long ll;
typedef pair<int, int> pii;
 
template<typename T1, typename T2> inline bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; };
template<typename T1, typename T2> inline bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; };
 
void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

const int N = 201;
int a[N];
int c[N][N];
int p[N];

int get(int n, int k) {
	if (k < 0) return 0;
	if (k > n) return 0;
	return c[n][k] * p[k];
}

signed main() {
	fast();
	string s;
	cin >> s;
	int k;
	cin >> k;
	int kk = k;
	int ans = 0;
	for (int i = 0; i < N; i++) c[i][0] = c[i][i] = 1;
	p[0] = 1;
	for (int i = 1; i < N; i++) p[i] = p[i - 1] * 9;
	for (int i = 2; i < N; i++) {
		for (int j = 1; j < i; j++) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
	}
	//debug(get(1, 1));
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == '0') continue;
		if (s[i] > '1') {
			ans += (s[i] - '1') * get(s.size() - i - 1, kk - 1);
		}
		if (s[i] > '0') ans += get(s.size() - i - 1, kk);
		kk--;
	}
	int cnt = 0;
	for (int i = 0; i < s.size(); i++) if (s[i] > '0') cnt++;
	if (cnt == k) ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <map>

using namespace std;

const long MOD = 1000000007;
typedef pair<int, int> P;

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

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

    map<int ,int> m;
    for(int i=0; i<N; i++){
        m[i] = 0;
    }

    for(int i=0; i<N; i++){
        if(i==0) continue;
        m[A[i]]++;
    }

    for(auto it=m.begin(); it!=m.end(); it++){
        cout << it->second << endl;
    }

    return 0;
}


Measured memory_bytes: 13784
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = (1e+9)+7;

int main(){
    int n,m,a;
    cin >> n >> m;
    vector<bool> br(n+1, false);
    vector<ll> dp(n+1,0);
    for(int i=0;i<m;i++){
        cin >> a;
        br[a] = true;
    }
    dp[0] = 1;
    for(int i=0;i<n;i++){
        if(i+1 <= n && !br[i+1]) dp[i+1] = (dp[i+1] + dp[i]) %MOD ;
        if(i+2 <= n && !br[i+2]) dp[i+2] = (dp[i+2] + dp[i]) %MOD ;
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

const int maxn = 1e5 + 10;

int n, a[maxn];

map <int, int> none, sub, add;

int get(int x) {
	return none[x] + sub[x] + add[x];
}

int solve() {
	int ans = 0;

	for(int i = 1; i <= n; ++i) 
		for(int k = -1; k <= 1; ++k)
			ans = max(ans, get(a[i] + k));

	return ans;
}

int main() {
	scanf("%d", &n);

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

		++none[a[i]];
		++add[a[i] + 1];
		++sub[a[i] - 1];
	}

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

	return 0;
}

Measured memory_bytes: 13952
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, readline().split())
    ans = 0
    for i in range(N)[::-1]:
        if (A[i]+ans)%B[i]==0:
            continue
        else:
            ans += B[i]-(A[i]+ans)%B[i]
    print(ans)


if __name__ == '__main__':
    main()

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



int main() {
 int N;
 cin >> N;
 vector<int> a(N);
 for(int i=0;i<N;i++)
   cin >> a.at(i);
 sort(a.begin(),a.end(),greater<int>());
 int count=0;
 for(int i=0; i<N-1; i++){
   
     if(a.at(i) != a.at(i+1)){
  		count++;
   }
 }
  
  	cout << count+1 << endl;
}



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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> nums = new ArrayList<>();
        for(int i=0; i<n; ++i) {
            nums.add(sc.nextInt());
        }

        boolean flag = true;
        int inversion = 0;
        int index = 0;
        while(flag) {
            flag = false;
            for(int i=n-1; i>index;--i) {
                if(nums.get(i-1) > nums.get(i)) {
                    int tmp = nums.get(i);
                    nums.set(i, nums.get(i-1));
                    nums.set(i-1, tmp);
                    inversion++;
                    flag = true;
                }
            }
            index++;
        }

        for(int i=0; i<n-1; ++i) {
            System.out.print(nums.get(i) + " ");
        }
        System.out.println(nums.get(n-1));
        System.out.println(inversion);
    }
}

Measured memory_bytes: 26552
#include"bits/stdc++.h"

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	char x; cin >> x;

	if ('A' <= x && x <= 'Z') cout << "A" << endl;
	else cout << "a" << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,A[200000],ans=0,x=0;
    map<int,int> num;
    set<int> B;
    cin>>n;
    rep(i,n) cin>>A[i],B.insert(A[i]),num[A[i]]++;
    ans=B.size();
    for(auto i:B) if(num[i]%2==0) x++;
    cout<<ans-x%2;
}

Measured memory_bytes: 9984
num, initial_taste =  gets.split(' ').map{|x| x.to_i }
tastes = num.times.map{|i| initial_taste + i}
tastes_abs = tastes.map{|i| i.abs}
abs_min = tastes_abs.sort.first
abs_min_index = tastes_abs.index(abs_min)
tastes.delete_at(abs_min_index)
puts tastes.inject{|sum, i| sum += i}


Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
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;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e9 + 7;

bool table[26];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int x,y;cin>>x>>y;
    int c[15];
    c[1]=1,c[3]=1,c[5]=1,c[7]=1,c[8]=1,c[10]=1,c[12]=1;
    c[4]=2,c[6]=2,c[9]=2,c[11]=2;
    c[2]=3;
    cout << (c[x]==c[y] ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(){
    int n, k,x = 1;
    cin >> n >> k;
    for(int i=0; i<n; ++i){
        x = min(x * 2, x + k);
    }
    cout << x << endl;
    return 0;
}


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

int main ()
{
  //initialization of variables
  int n,d,c,e=0;
  double a,b,x,y;
  //input
  cin>>n>>d;
  //loop for input of x and y and
  //check if the value is smaller than d
  for(c=1;c<=n;c++)
  {
    cin>>x>>y;
    a=(x*x)+(y*y);
    b=sqrt(a);
    //cout<<c<<"th b:"<<b<<endl;

    if(b<=d)
    {
        e=e+1;
        //cout<<c<<"th e:"<<e<<endl<<endl;
    }
  }
  //output
  cout<<e;
  return 0;
}


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

int harshad(int n){
    int ret = 0;
    for (int i = 0; i < 10; i++)
    {
        ret += n%10;
        n /= 10;
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    if(N%harshad(N) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
min_all = 1000000000000000000000000
    
N,K = [int(i) for i in input().split(" ")]
H = [int(input()) for _ in range(N)]
H.sort()
    
for i in range(N+1-K):
  min_now = H[K-1+i] - H[i]
  if min_all > min_now:
    min_all = min_now
print(min_all)

Measured memory_bytes: 7540
import java.util.*;

public class Main
{
    public static void main(String[] args)
    {
        double ans = 0.0;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Double> x=new LinkedList<>();
        for (int i = 0; i < n; ++i) { x.add(sc.nextDouble()); }
        double max=Double.MIN_VALUE;
        Collections.sort(x);


        for (int i=0;i<n-1;++i)
        {
            double res=0.0;
            int c=i+1;
            int a=n-1;
            int b=n-2;
            if (i==n-3) { b=i-1;}
            else if (i==n-2)
            {
                a=i-1;
                b=i-2;
            }
            res=(x.get(a)+x.get(b))/(x.get(c)-x.get(i));
            if (max<res) {max=res;}
        }

        System.out.println(String.format("%.7f",max));
    }
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public void Calc()
        {
            var X = long.Parse(Console.ReadLine());
            //var AB = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

            //Console.WriteLine(AB.Any(x => x % K == 0) || AB[0] / K != AB[1] / K ? "OK" : "NG");
            var now = 100.0;
            var year = 0;
            while (now < X)
            {
                year++;
                now = Math.Floor( now * 1.01);
            }
            Console.WriteLine(year);
        }
    }
}


Measured memory_bytes: 27556
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int x,a,b;
  cin >> x >> a >> b;
  x -= a;
  while(x >= b) x -= b;
  cout << x << endl;
}

Measured memory_bytes: 3576
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		String s = in.next();
		int n = s.length();
		boolean[] f = new boolean[4];
		for (int i=0; i<n; i++) {
			switch (s.charAt(i)) {
				case 'N': f[0] = true; break;
				case 'W': f[1] = true; break;
				case 'S': f[2] = true; break;
				case 'E': f[3] = true; break;
			}
		}

		out.println(f[0] == f[2] && f[1] == f[3] ? "Yes" : "No");
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 9556