akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

def main():
    H, W = map(int, input().split())
    S = [input() for _ in range(H)]

    # L[i][j]: このマスが光る時に左方向に照らされるマスの個数
    L = [[0]*W for _ in range(H)]
    R = [[0]*W for _ in range(H)]

    for i in range(H):
        for j in range(1,W):
            if S[i][j] == '.':
                if S[i][j-1] == '.': 
                    L[i][j] = L[i][j-1] + 1
            if S[i][W-j-1] == '.':
                if S[i][W-j] == '.': 
                    R[i][W-j-1] = R[i][W-j] + 1
    
    # U[i][j]: このマスが光る時に上方向に照らされるマスの個数
    U = [[0]*W for _ in range(H)]
    D = [[0]*W for _ in range(H)]

    for j in range(W):
        for i in range(1,H):
            if S[i][j] == '.':
                if S[i-1][j] == '.': 
                    U[i][j] = U[i-1][j] + 1
            if S[H-i-1][j] == '.':
                if S[H-i][j] == '.': 
                    D[H-i-1][j] = D[H-i][j] + 1
    ans = 0
    
    for i in range(H):
        for j in range(W):
            tmp = 1
            tmp += L[i][j] + R[i][j] + U[i][j] + D[i][j]
            ans = max(tmp,ans)
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 206112
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n,m;
	cin>>n>>m;
	int l=1,r=n;
	FOR(i,0,m){
		int a,s;
		cin>>a>>s;
		l=max(l,a);
		r=min(r,s);
	}
	if(l>r)cout<<0<<endl;
	else cout<<r-l+1<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++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(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

VL primes;

ll ababba(ll x){
    REP(i,primes.size()){
        ll y = primes[i]*primes[i]*primes[i];
        if (y > x) break;
        while (x % y == 0){
            x /= y;
        }
    }
    return x;
}

void initp(ll n){
    n = sqrt(n) + 2;
    VI x(n,1);
    x[0] = x[1] = 0;
    FOR(i,2,n-1){
        if (x[i] == 0) continue;
        primes.push_back(i);
        for (int j = 1; i*j < n; j++)
            x[i*j] = 0;
    }
}

int main() {
    initp(1e10);
    int n;
    cin >> n;
    VL a;
    int ans = 0;
    REP(i,n){
        ll x;
        scanf("%lld", &x);
        x = ababba(x);
        if (x == 1) ans = 1;
        else a.push_back(x);
    }
    n = a.size();
    map<ll, int> mp;
    for (ll x : a) mp[x]++;
    set<ll> st;
    map<ll, ll> p2;
    for (ll p : primes) p2[p * p] = p;
    for (auto tmp : mp){
        ll x = tmp.first;
        int c = tmp.second;
        if (st.count(x)) continue;
        // cout << x << endl;
        ll y = 1;
        for (ll p : primes){
            if (p > 3000) break;
            if (x % (p * p) == 0){
                y *= p;
                x /= p * p;
            }else if (x % p == 0){
                y *= p * p;
                x /= p;
            }
        }
        if (x > 1){
            if (p2.count(x)) y *= p2[x];
            else y *= x * x;
        }
        if (mp.count(y)){
            ans += max(c, mp[y]);
            st.insert(y);
        }else{
            ans += c;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7924
#include <bits/stdc++.h>
using namespace std;
 
int main(){
   int a[1011];
   int n,m;
   cin>>n>>m;
   double sum=0;
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   	sum=sum+a[i];
	}
	sum=sum/(4*m);
	int sum1=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]>=sum)
		{
			sum1++;
		}
	 }
	 //cout<<sum<<endl;
	 //cout<<sum1<<endl;
	 if(sum1<m)
	 {
	 	cout<<"No"<<endl;
	  }
	  else
	  {
	  	cout<<"Yes"<<endl;
	   } 
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;

public class Main {

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

        long N = sc.nextLong()-1;

        List<Integer> list = new ArrayList<>();

        list.add(Long.valueOf(N%26).intValue());
        N /= 26;
        while (N > 0) {
            N -= 1;
            list.add(Long.valueOf(N%26).intValue());
            N /= 26;
        }

        Collections.reverse(list);

        char[] alphabet = "abcdefghijklmnopqrstuvwxyz".toCharArray();

        list.stream().map(i -> alphabet[i]).forEach(System.out::print);
    }
}


Measured memory_bytes: 35864
#include <bits/stdc++.h>
using namespace std;
void solution(){
    long long n, s=0;
    cin>>n;
    vector<int>a(n);
    map<int,int>cnt;
    for(int i=0; i<n; i++) cin>>a[i], cnt[a[i]]++, s+=a[i];
    long long q;
    cin>>q;
    for(int i=0; i<q; i++){
        long long a, b;
        cin>>a>>b;
        s-=a*cnt[a];
        s+=b*cnt[a];
        cnt[b]+=cnt[a];
        cnt[a]=0;
        cout<<s<<'\n';
    }

}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(); cout.tie();
    int t;
    t=1;
    while(t--) solution();
    return 0;
}


Measured memory_bytes: 8268
package main

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcdInt64(m, n int64) int64 {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcmInt64(m, n int64) int64 {
	return m / gcdInt64(m, n) * n
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------
var n, vmax int
var w int64
var items []item
var dp [][]int64

type item struct {
	w int64
	v int
}

func main() {
	n = readInt()
	w = readInt64()
	vmax = n * 1e3
	items = make([]item, n)
	for i := range items {
		items[i] = item{
			w: readInt64(),
			v: readInt(),
		}
	}
	dp = make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, vmax+1)
		for j := range dp[i] {
			dp[i][j] = math.MaxInt64
		}
	}
	dp[0][0] = 0

	for i := 1; i <= n; i++ {
		for j := 0; j <= vmax; j++ {
			if j-items[i-1].v >= 0 && dp[i-1][j-items[i-1].v] != math.MaxInt64 {
				dp[i][j] = minInt64(dp[i-1][j], dp[i-1][j-items[i-1].v]+items[i-1].w)
			} else {
				dp[i][j] = dp[i-1][j]
			}
		}
	}

	var ans int
	for i := range dp[0] {
		if dp[n][i] <= w {
			ans = i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 82432
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int[] a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        int ans=0;
        int flag=1;
        while(flag==1){
            flag=0;
            for(int j=n-1;j>0;j--){
                if(a[j]<a[j-1]){
                    ans++;
                    flag=1;
                    int tmp=a[j];
                    a[j]=a[j-1];
                    a[j-1]=tmp;
                }
            }
        }
        for(int i=0;i<n;i++){
            System.out.print(a[i]);
            if(i!=n-1) System.out.printf(" ");
        }
        System.out.printf("\n");
        System.out.println(ans);
    }
}


Measured memory_bytes: 26264
S = input()
S_length = len(S)
S_list = list(S)
T = input()
compare_S = ''

for _ in range(S_length):
    for i in range(S_length):
        compare_S+=S_list[i]
    if compare_S == T:
        print('Yes')
        exit()
    compare_S = ''
    pop_S_list = S_list.pop()
    S_list.insert(0, pop_S_list)
print('No')


Measured memory_bytes: 3060
#include <stdio.h>

int judge(int x)
{
	int i;
	if(x < 2)
      return 0;
	else if(x == 2)
	  return 1;
	if(x%2 == 0)
	  return 0;
	for(i = 3; i*i <= x; i+=2){
		if(x%i == 0)
		  return 0;
	}
	return 1;
}

int main()
{
  int n, i, x, count=0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d",&x);
  	if(judge(x))
  	  count++;
  }
  	  
  printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 1844
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
main()
{
    timesave;
    ll a;
    cin>>a;
    cout<<(a)+(a*a)+(a*a*a)<<endl;
}




Measured memory_bytes: 3652
#coding: utf-8
import sys

msprime = []
i = 6
MAX = 300000
isprime = [1]*300001
while i*i <= MAX: #?????????????´???°?????????????±???????
    for p in msprime:
        if i % p == 0:
            break
    else:
        msprime.append(i)
        j = i * 2
        while j <= MAX:
            isprime[j] = 0
            j += i
    if i % 7 == 6:
        i += 2
    else:
        i += 5
else:
    tmp = i

for i in range(tmp,MAX):
    if isprime[i] == 1 and i % 7 in (1,6):
        msprime.append(i)

while True:
    n = int(raw_input())
    if n == 1: break
    fact = []
    for i in msprime:
        if n % i == 0:
            fact.append(i)
    sys.stdout.write(str(n)+":")
    for i in fact:
        sys.stdout.write(" "+str(i))
    print ""

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

int main(void){
    int n,sum=0;
    cin >> n;
    int a[n],b[n],c[n-1];
    for(int i=0; i < n; i++) cin >> a[i];
    for(int i=0; i < n; i++) cin >> b[i];
    for(int i=0; i < n-1; i++) cin >> c[i];

    for(int j=0; j < n; j++){
        sum = sum + b[a[j]-1];
        if(a[j] + 1 == a[j+1]) sum = sum + c[a[j]-1];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  priority_queue<ll> q;
  ll s1 = 0, s2 = 0;
  ll ans = 0;
  rep(i, n) {
    ll b;
    cin >> b;
    a[i] -= b;
    if(a[i] > 0) {
      q.push(a[i]);
      s2 += a[i];
    } else if(a[i] < 0) {
      s1 -= a[i];
      ans++;
    }
  }
  if(s1 > s2) {
    cout << -1 << endl;
    return 0;
  }
  while(s1 > 0) {
    ll now = q.top();
    q.pop();
    s1 -= now;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4624
class UF():
  def __init__(self, N):
    self.parents = [-1] * N

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

  def union(self, u,v):
    p1,p2 = self.find(u),self.find(v)
    if p1==p2: return
    if p1 > p2:
      p1,p2 = p2,p1
    self.parents[p1] += self.parents[p2]
    self.parents[p2] = p1

  def same(self, u,v):
    return self.find(u) == self.find(v)

n,q = map(int,input().split())
uf = UF(n)
for _ in range(q):
  i,u,v = map(int,input().split())
  if i==0:
    uf.union(u,v)
  else:
    if uf.same(u,v):
      print(1)
    else:
      print(0)


Measured memory_bytes: 5772
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per0(i, st, ed) for (int i = (st); i > ed; --i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
#define chmin(a, b) (a = a > b ? b : a)
#define chmax(a, b) (a = a < b ? b : a)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
template<class T> void _out(const T &x) { cout << x; }
void _out(const int &x) { printf("%d", x); }
void _out(const ll &x) { printf("%lld", x); }
void _out(const double &x) { printf("%.16f", x); }
void _out(const char &x) { putchar(x); }
void _out(const char *x) { printf("%s", x); }
template<class T,class U> void _out(const pair<T,U> &x) {_out(x.F); putchar(' '); _out(x.S);}
template<class T> void _out(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _out(*i++)) if (i != x.cbegin()) putchar(' '); }
void out() {}
template<class T, class... U> void out(const T &head, const U &... tail) { _out(head); putchar(sizeof...(tail) ? ' ' : '\n'); out(tail...); }
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int vec[] = {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 n = read();
    out(vec[n - 1]);
    return 0;
}

Measured memory_bytes: 256
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()


s = v()
rev=s[::-1]
can='YES'
while(len(rev)!=0):
    if(rev[:3]=='rem'):
        if(rev[:7]=='remaerd'):
            rev=rev[7:]

        else:
            can='NO'
            break
    
    elif(rev[:3]=='res'):
        if(rev[:6]=='resare'):
            rev=rev[6:]

        else:
            can='NO'
            break
    
    elif(rev[0]=='e'):
        if(rev[:5]=='esare'):
            rev=rev[5:]

        else:
            can='NO'
            break
    elif(rev[0]=='m'):
        if(rev[:5]=='maerd'):
            rev=rev[5:]

        else:
            can='NO'
            break
    else:
        can='NO'
        break

print(can)



Measured memory_bytes: 10492
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i, N) { cin >> a[i]; }

    vector<ll> b(N, 0);
    // rep(i, N) {
    //     b.push_back(a[i]);
    //     reverse(begin(b), end(b));
    // }

    if (N % 2 == 0) {
        ll left = N / 2 - 1;
        ll right = N / 2;
        for (ll i = 1; i <= N; i++) {
            if (i % 2 == 1) {
                b[right] = a[i - 1];
                right++;
            } else {
                b[left] = a[i - 1];
                left--;
            }
        }
    } else {
        ll left = N / 2;
        ll right = N / 2 + 1;
        for (ll i = 1; i <= N; i++) {
            if (i % 2 == 1) {
                b[left] = a[i - 1];
                left--;
            } else {
                b[right] = a[i - 1];
                right++;
            }
        }
    }
    repv(b) { cout << *it << " "; }
    cout << endl;
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

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

	vector<vector<char>> memo(10);
	vector<string> curr;
	int sum = 0;
	for (int i = 0; i < 10; ++i) {
		if (i > 0) {
			char c = i + '0';
			curr.push_back(string(1, c));
			++sum;
			memo[i].push_back((char)((i - 1) + '0'));
		}
		memo[i].push_back((char)(i + '0'));
		if (i < 9) {
			memo[i].push_back((char)((i + 1) + '0'));
		}
	}

	if (sum >= K) {
		cout << curr[K - 1] << endl;
		return 0;
	}

	while (sum < K) {
		vector<string> nxt;
		for (auto s : curr) {
			int x = s.back() - '0';
			for (auto c : memo[x]) {
				string t = s + c;
				nxt.push_back(t);
				++sum;
				if (sum >= K) {
					cout << t << endl;
					return 0;
				}
			}
		}
		curr = nxt;
	}

	return 0;
}


Measured memory_bytes: 5664
n,m;main(i){char x[99],y[99],t;for(;scanf("%d",&n),n;puts("")){for(i=0;i<n;i++)scanf(" %c %c",&x[i],&y[i]);for(scanf("%d",&m);m--;putchar(t))for(scanf(" %c",&t),i=0;i<n;i++)if(x[i]==t)t=y[i],i=n;}exit(0);}

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

using i64 = int64_t;

int main() {
    i64 n, w;
    cin >> n >> w;
    
    vector<i64> ws(n), vs(n);
    
    for (int i = 0; i < n; i++) {
        cin >> ws[i] >> vs[i];
    }
    
    vector<vector<i64>> dp(n + 1, vector<i64>(w + 1));
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
            if (j + ws[i] <= w) {
                dp[i + 1][j + ws[i]] = max(dp[i + 1][j + ws[i]], dp[i][j] + vs[i]);   
            }
            
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
        }
    }
    
    cout << dp[n][w] << endl;
}


Measured memory_bytes: 80256
X, K, D = [abs(int(_)) for _ in input().split()]

if X > K * D:
    print(X - K * D)
else:
    v = X % (D * 2)
    if K % 2 == 0:
        print(min(v, abs(v - 2 * D)))
    else:
        print(min(abs(v + D), abs(v - D)))


Measured memory_bytes: 9184
#include <stdio.h>

int hantei(int a){
    int i;
    if(a<2) return 0;
    else if(a==2) return 1;
    if(a%2==0) return 0;
    for(i=3;i*i<=a;i+=2){
        if(a%i==0)return 0;
    }
    return 1;
}

int main(){
    int i,n,a,c=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a);
        if(hantei(a)) c++;
    }
       printf("%d\n",c);
   return 0;
}


Measured memory_bytes: 2080
if __name__ == '__main__':
    N = int(input())
    s_list = [str(input()) for i in range(N)]
    M = int(input())
    t_list = [str(input()) for i in range(M)]

    D = {}

    for s in s_list:
        if s in D.keys():
            D[s] = D[s] + 1
        else:
            D[s] = 1

    for t in t_list:
        if t in D.keys():
            D[t] = D[t] - 1
        else:
            D[t] = -1

    answer = max(0, max(D.values()))
    print(answer)

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    char[] s = sc.next().toCharArray();
    char[] signs = new char[3];
    int sum = 0;
    int sign = 1;
    for(int i=0;i<8;i++){
      sum = 0;
      sign = 1;
      for(int j=0;j<3;j++){
        if(((i>>(2-j)) & 1)==1){
          sum+=(s[j] -'0')*sign;
          sign = 1;
          signs[j] = '+';
        }else{
          sum+=(s[j]-'0')*sign;
          sign = -1;
          signs[j] = '-';
        }
      }
      sum+=(s[3]-'0')*sign;
      if(sum == 7){
        for(int k=0;k<3;k++){
          System.out.print(s[k]+""+signs[k]);
        }
        System.out.print(s[3]+"=7");
        System.out.flush();
       	break;
      }
    }
  }
}

Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {
	
	
	public static void main(String[] args) {

		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();

		int score[] = new int[N];

		for (int i = 0; i < N; i++) {
			score[i] = scan.nextInt();
		}
		
		int count[] = new int [8];
		
		int var = 0;
		
		for(int i = 0; i < N; i++){
			
			
		if(score[i] <= 399){
			count[0]++;
		} else if(score[i] <= 799){
			count[1]++;
		} else if(score[i] <= 1199){
			count[2]++;
		} else if(score[i] <= 1599){
			count[3]++;
		} else if(score[i] <= 1999){
			count[4]++;
		} else if(score[i] <= 2399){
			count[5]++;
		} else if(score[i] <= 2799){
			count[6]++;
		} else if(score[i] <= 3199){
			count[7]++;
		} else if(score[i] >= 3200){
			var++;
		}

		}
		
		
		int min = 0;
		for (int i = 0; i < count.length; i++) {
			if (count[i] > 0) {
				min++;
			}
		}
		
		int max = min + var;
		if (min == 0) {
			min = 1;
		}
		
		System.out.print(min + " ");
		System.out.println(max);
		//System.out.println(Arrays.toString(count));
		//System.out.println(counter);
		//System.out.println(all);
	}

}



Measured memory_bytes: 21972
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

template<class T> T maxt(T x,T y) {if (x>y) return x;else return y;}
template<class T> T mint(T x,T y) {if (x>y) return y;else return x;}
//sort(v.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


//小数出力
double print_double(double d){printf("%.11f", d);}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


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


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int sx,sy,tx,ty;
  cin >> sx >> sy >> tx >> ty;
  int x = tx-sx,y=ty-sy;
  rep(i,x)cout << 'R';
  rep(i,y)cout << 'U';
  rep(i,x)cout << 'L';
  rep(i,y)cout << 'D';
  cout << 'D';
  rep(i,x+1)cout << 'R';
  rep(i,y+1)cout << 'U';
  cout << 'L';
  cout << 'U';
  rep(i,x+1)cout << 'L';
  rep(i,y+1)cout << 'D';
  cout << 'R';
  cout << endl;
}

Measured memory_bytes: 256
k,n = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
ds = [0] * n # iとi+1の距離
for i in range(n-1):
    ds[i] = a[i+1] - a[i]
ds[n-1] = (k - a[n-1]) + a[0]
m = max(ds)
print(k - m)

Measured memory_bytes: 26624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Calendar;

/*????????\???
2004 ??´ 1 ??? 1 ??\?????? 12 ??? 31 ??\?????§?????\????????\?????????????????\????????\???????????????????????°?????????????????????????????????
?????????2004 ??´ 1 ??? 1 ??\?????¨?????\??§???????????????2004 ??´??????????????´??§????????§ 2 ???29 ??\??????????????¨?????¨?????????????????????

Input
?????°????????????????????????????????????????????°??????????????????
???????????????????????????????????¨??\??????????????????????????§?????????????????????????????????????????????
?????? 0 ??¨?????£?????¨?????\??????????????¨????????????????????´??????????????????????????§????????°??????????????????????????????
???????????????????????°??? 50 ????¶????????????????

Output
??????????????????????????¨????????\?????±?????§?????????????????????????????????*/

public class Main{
	public static void main(String[] args){
		InputStreamReader inputStreamReader = new InputStreamReader(System.in);
		BufferedReader bufferedReader= new BufferedReader(inputStreamReader);
		StringBuilder stringBuilder = new StringBuilder();
		String[] week_name = {"Sunday", "Monday", "Tuesday", "Wednesday", 
                "Thursday", "Friday", "Saturday"};
		try{
			String dataSet;
			while((dataSet=bufferedReader.readLine()) != null){
				String[] dataList = dataSet.split(" ");
				Calendar calender = Calendar.getInstance();
				int month =  Integer.parseInt(dataList[0]);
				int day = Integer.parseInt(dataList[1]);
				if((month == 0)&&(day==0)) break;
				calender.set(2004, month-1, day);
				int week = calender.get(Calendar.DAY_OF_WEEK) -1;
				stringBuilder.append(week_name[week] + "\n");
			}
			System.out.print(stringBuilder);
		}catch(IOException e){
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 25728
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
	long long n,x,a[100100],ans = 0;
	cin >> n >> x >> a[0]; 
	for(int i=1;i<n;i++) 
	{
		cin >> a[i];
		long long sum = a[i] + a[i-1];
		if(sum>x) 
		{
			ans+=sum - x;
			a[i]-=sum-x;
			if(a[i]<0) a[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int f(int n,int k){
	if(n == 1) return 0;
	return (f(n-1,k) + k) % n;
}
int main(){
	int n,m,k;
	while(cin >> n >> k >> m , n){
		m = (m-k+1+n)%n;
		cout << (f(n,k)+m-1+n)%n+1 << endl;
	}
}

Measured memory_bytes: 0
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p[] = new int[n];
    for(int i=0;i<n;i++){
      p[i]=sc.nextInt();
    }
    int answer =0;
    for(int i=1;i<n-1;i++){
      if((p[i-1]<p[i]&&p[i]<p[i+1])||(p[i-1]>p[i]&&p[i]>p[i+1])){
        answer+=1;
      }
    }
    System.out.println(answer);
         
    
  }
  
  //最大公約数・最小公倍数（セットで使う）
static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
static int lcm (int a, int b) {return a*b/gcd(a,b);}


//素数判定
static boolean isPrime (int n) {
	if (n==2) return true;
	if (n<2 || n%2==0) return false;
	double d = Math.sqrt(n);
	for (int i=3; i<=d; i+=2) if(n%i==0){return false;}
	return true;
}


//倍数判定（10進数以外のときに有用）
static boolean isMultiple (String s, int base, int m) {
	int temp = 0;
	for (int i=0; i<s.length(); i++) {
		temp = (temp*base+Character.getNumericValue(s.charAt(i)))%m;
	}
	if (temp==0) {return true;}
	return false;
}


//階乗
static long factorial (int i) {
	if (i==1) {return 1;}
	else {return i*factorial(i-1);}
}


//進数変換
static String toNbase (String sm, int m, int n) {
	return Long.toString(Long.parseLong(sm,m),n);
}
  
}

Measured memory_bytes: 21844
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    List = [x for x in range(1, min(a,b)+1)]
    List.sort(reverse=True)

    cnt = 0
    for y in List:
        if a % y == 0 and b % y == 0:
            cnt += 1
            if cnt == k:
                print(y)
                break
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  ll a, b; cin >> a >> b;
  cout << a * b << endl;
}

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

int main (){
  int X;
  cin >> X;
  
  if (X==2){
    cout << 2 << endl;
    return 0;
  }
  
  X--;
  
  for (int i=0;1;i++){
   X ++;
   int a = sqrt(X)+1;
   int q=0;
   for (int j=2;j<a+1;j++){
     if (X%j==0){
       q++;
       break;
     }
   }
    if (q==0){
      cout << X << endl;
      break;
    }
    
  }
}

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

using namespace std;
typedef pair<int, int>P;
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 1010;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll dp[101010];

//union-find木について
ll par[101010];
ll rank2[101010];

void init(ll n) {
	rep(i, n) {
		par[i] = i;
		rank2[i] = 0;
	}
}

ll find(ll x) {
	if (par[x] == x) {
		return x;
	}
	else {
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rank2[x] < rank2[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rank2[x] == rank2[y]) {
			rank2[x]++;
		}
	}
}

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

char c[2010][2010];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n;
	cin >> n;
	vector<ll>s(n);
	rep(i, n) {
		cin >> s[i];
	}
	ll q;
	cin >> q;
	vector<ll>t(q);
	ll ans = 0;
	rep(i, q) {
		cin >> t[i];
		ll left = -1;
		ll right = n;
		while (right - left > 1) {
			ll mid = (right + left) / 2;
			if (s[mid] > t[i])right = mid;
			else if (s[mid] < t[i])left = mid;
			else {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3808
(* Vicfred
 * https://atcoder.jp/contests/abc148/tasks/abc148_b
 * string manipulation
 * *)
open Printf
open Scanf

let main =
    scanf"%d %s %s" (fun n s t ->
    for i = 0 to n-1 do
        printf "%c%c" s.[i] t.[i]
    done
    )
    


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
const int INF = 1000000000;
const ll LINF = 1000000000000000000; //1e18
const double EPS = 1e-10;

int main(void)
{
    int n, d;
    cin >> n >> d;

    vector<vector<int>> map(n, vector<int>(d));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
        {
            cin >> map[i][j];
        }
    }

    // int sum;
    // int ans = 0;
    // int num;
    // for (int i = 0; i < n - 1; i++)
    // {
    //     sum = 0;
    //     for (int j = 0; j < d; j++)
    //     {
    //         sum += pow(abs((map[i][j]) - map[i + 1][j]), 2);
    //     }
    //     num = sqrt(sum);
    //     if (num * num == sum)
    //     {
    //         ans++;
    //     }
    // }

    // sum = 0;
    // for (int i = 0; i < d; i++)
    // {
    //     sum += pow(abs(map[n - 1][i] - map[0][i]), 2);
    // }
    // num = sqrt(sum);
    // if (num * num == sum)
    // {
    //     ans++;
    // }

    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = i + 1; j < n; ++j)
        {
            int norm = 0;
            for (int k = 0; k < d; ++k)
            {
                int diff = abs(map[i][k] - map[j][k]);
                norm += diff * diff;
            }
            bool flag = false;
            for (int k = 0; k <= norm; ++k)
            {
                if (k * k == norm)
                {
                    flag = true;
                }
            }
            if (flag)
                ++ans;
        }
    }
    cout << ans << endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)
using namespace std;
 
/*--------------------template--------------------*/

int main(){
    REP1(i,10){
        REP1(j,10){
            cout << i << 'x' << j << '=' << i*j << '\n';
        }
    }
}

Measured memory_bytes: 3096
#include<stdio.h>
int main(void){
	
	int n,num[100],i;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	
	for(i=n-1;i>=0;i--){
		printf("%d",num[i]);
		if(i!=0){
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
vl v;
int main(){
	std::ios::sync_with_stdio(false);
	ll n,i,j,k,res=0,c1=0,c2=0,c3=0,c4=0,c5=0;
	string c[100005];
	cin>>n;
	rep(i,n){
		cin>>c[i];
		if(c[i][0]=='M'){
			c1++;
			//return 0;
		}
		if(c[i][0]=='A'){
			c2++;
		}
		if(c[i][0]=='R'){
			c3++;

		}
		if(c[i][0]=='C'){
			c4++;
		}
		if(c[i][0]=='H'){
			c5++;
		}
	}
	v.pb(c1);
	v.pb(c2);
	v.pb(c3);v.pb(c4);
	v.pb(c5);
	rep(i,v.size()){
		f(j,i+1,v.size()){
			f(k,j+1,v.size()){
				res+=v[i]*v[j]*v[k];
			}
		}
	}
	cout<<res<<endl;
} 
	

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	
	ll N; cin >> N;

	ll ans = 0;
	FOR(i,1,N+1){
		if(i%3 == 0 and i%5 == 0) continue;
		else if(i%3 == 0) continue;
		else if(i%5 == 0) continue;
		else ans += i;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n,D;
    cin>>n>>D;
    long long int count=0;
    long long int x,y;
    long long int dsquared=D*D;
    for(int i=0;i<n;i++)
    {
        cin>>x>>y;
        if(x*x+y*y <= dsquared)
            count++;
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<vector>
#include<utility>
#include<cstring>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define ms(a,b)            memset(a, b, sizeof(a))
#define loop(i,a)          for(int i=1;i<=a;i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
using namespace std ;
typedef long long ll ;
const int maxx = 8e4+10;
//typedef pair < int , pii > node ;
//node tree[4*maxx],lazy[4*maxx];
int tree[4*maxx],lazy[4*maxx] ;
int main()
{
  long long sum=0,n;
  cin >> n ;
  for(int i=1;i<=n;i++)
  {
      if(i%3!=0 && i%5!=0)
      {
          sum+=i;
      }
  }
  cout << sum << endl;
  return 0 ;
}


Measured memory_bytes: 3636
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/
void swap(int &a, int &b)
{
	a = a ^ b;
	b = a ^ b;
	a = a ^ b;
}
bool can_reach(int start, int end, string s)
{
	for (int i = start; i <= end - 1; i++)
	{
		if ((s[i] == '#') && (s[i+1] == '#'))
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);

	int N, A, B, C, D;
	
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;
	string s;
	cin >> s;
	/*
	if (A > C)
	{
		swap(A,C);
	}
	if (B > D)
	{
		swap(B, D);
	}
	if (A > B)
	{
		swap(A, B);
		swap(C, D);
	}
	*/
	int nn = 0;
	bool y = false;
	int c = 0;
	int d = 0;
	if ( !can_reach(A,C, s) || !can_reach(B,D, s))
	{
		cout << "No" << endl;
		return 0;
	}
	if (D < C)
	{
		for (int i = B-1; i <= D-1; i++)
		{
			/*
			if (s[i] == '.')
			{
				c++;
				if (c >= 3)
				{
					y = true;
					break;
				}
			}
			else
			{
				c=0;
			}	
			*/
			if ((s[i] == '.') && (s[i+1] == '.') && (s[i+2] == '.'))
			{
				y = true;
				break;
			}
			
		}
		if (!y)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	
	
	return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	typedef tuple<int, int, int> Data;

	cin.sync_with_stdio(false);
	int T, P, R;
	while (cin >> T >> P >> R, T)
	{
		vector<vi> wa(T, vi(P));
		vi ac(T), penalty(T);
		REP(i, R)
		{
			int tid, pid, time; string mes;
			cin >> tid >> pid >> time >> mes;
			tid--; pid--;
			if (mes == "CORRECT")
			{
				ac[tid]++;
				penalty[tid] += wa[tid][pid] * 1200 + time;
			}
			else
			{
				wa[tid][pid]++;
			}
		}
		vector<Data> v;
		REP(i, T) v.emplace_back(-ac[i], penalty[i], i + 1);
		sort(ALL(v));
		REP(i, T) cout << get<2>(v[i]) << " " << -get<0>(v[i]) << " " << get<1>(v[i]) << endl;
	}
	return 0;
}

Measured memory_bytes: 3180
x=int(input())
a=0
w=0
t=0
r=0
for i in range(x):
    s=input()
    if s=="AC":
        a+=1
    elif s=="WA":
        w+=1
    elif s=="TLE":
        t+=1
    else:
        r+=1
print("AC x",a)
print("WA x",w)
print("TLE x",t)
print("RE x",r)

Measured memory_bytes: 69976
def f(r, g, b, n):
    cnt = 0
    for rn in range(n // r + 1):
        for gn in range((n - r * rn) // g + 1):
            if (n - r * rn - g * gn) % b == 0:
                cnt += 1
    print(cnt)

r, g, b, n = map(int, input().split())
f(r, g, b, n)


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

int main()
{
    int a, b, cnt = 0;
    cin >> a >> b;
    for (int i = a; i <= b; i++)
    {
        string x = to_string(i);
        if (x[0] == x[4] && x[1] == x[3])
            cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    int b = ((double)a / 1.08);
    for (int i = b - 1; i <= b + 500000; ++i)
        if (int(i * 1.08) == a) {
            cout << i << '\n';
            return 0;
        }
    cout << ":(\n";
    return 0;
}

Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n,m=n1()
A=n2(m)
A.append(n+1)
b=0
d=[0]*(n+1)
d[0]=1
d[1]=1
for i in range(2,n+1):
    d[i]=d[i-1]+d[i-2]

ans=1
for a in A:
    c=a-1-b
    if a==b:
        print(0)
        break
    else:
        ans*=d[c]
        b=a+1
else:
    print(ans%(10**9+7))

Measured memory_bytes: 464036
def main():
    N = int(input())
    ans = [0 for i in range(N + 1)]

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                s = x**2 + y**2 + z**2 + x*y + y*z + z*x

                if 1 <= s <= N:
                    ans[s] += 1

    for i in range(1, N + 1):
        print(ans[i])

if __name__ == "__main__":
    main()

Measured memory_bytes: 9304