akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;




int main(){
    int N;
    cin>>N;
    string s;
    cin>>s;
    F0R(i,s.length()){
        s[i]='A'+(s[i]-'A'+N)%26;
    }
    cout<<s<<endl;
    return 0;

    return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc147/tasks/abc147_b
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int len = s.length(), cnt = 0;
    REP(i, len / 2) {
        if (s[i] != s[len - i - 1])
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 105
#define M 40005
using namespace std;

int n, a[M], t[M], v[N];
double s;
int main()
{
	int i, j;
	cin >> n;
	for (i = 1; i <= n; i++) scanf("%d", &t[i]), t[i] *= 2, t[i] += t[i - 1];
	for (i = 1; i <= t[n]; i++) a[i] = 1e9;
	t[n + 1] = t[n];
	for (i = 1; i <= n; i++) scanf("%d", &v[i]), v[i] *= 2;
	a[t[n]] = 0;
	for (i = j = 1; i <= n; i++)
		for (; j <= t[i]; j++) a[j] = min(a[j], min(v[i], a[j - 1] + 1));
	for (i = n + 1, j = t[n] - 1; i > 0; i--)
		for (; j >= t[i - 1]; j--) a[j] = min(a[j], min(v[i], a[j + 1] + 1));
	for (i = 0; i <= t[n]; i++) s += a[i];
	printf("%.6f", s / 4);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int val(int x){
  if(x==1) return 300000;
  if(x==2) return 200000;
  if(x==3) return 100000;
  return 0;
}

int main(){
  int x,y;
  scanf("%d%d",&x,&y);
  int s=val(x)+val(y);
  if(x==1 && y==1){
    s+=400000;}
  printf("%d\n",s);
  return 0;
}

Measured memory_bytes: 128
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

void solve(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
}



int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


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

struct Node {
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
    Node *y = NIL;
    Node *x = root;
    Node *z;

    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NIL) {
        root = z;
    } else {
        if ( z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

void inorder(Node *u) {
    if (u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node * u) {
    if (u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(void) {
    int n, i, x;
    string com;

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        cin >> com;
        if (com == "insert") {
            scanf("%d", &x);
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26724
#include<stdio.h>
int min(int x,int y,int z){
    int ans;
    if(x>y){
        ans=y;
    }else{
        ans=x;
    }
    if(ans>z){
        ans=z;
    }
    return ans;
}
int max(int x,int y,int z){
    int ans;
    if(x<y){
        ans=y;
    }else{
        ans=x;
    }
    if(ans<z){
        ans=z;
    }
    return ans;
}
int main(void){
    int a,b,c;
    int min1,max1;
    scanf("%d %d %d",&a,&b,&c);
    min1=min(a,b,c);
    max1=max(a,b,c);
    printf("%d %d\n",min1,max1);
    return 0;
}


Measured memory_bytes: 2104
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dijkstra();

int n,M[MAX][MAX];

int main(){
  int c,i,j,k,u,v;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }
    dijkstra();
    return 0;
  }

  
void dijkstra(){
  int i,u=-1,v,minv;
  int d[MAX],color[MAX];
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }

  d[0]=0;
  color[0]=GRAY;
  while(1){
    minv=INFTY;
    int u=-1;

    for(i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1)break;
    color[u]=BLACK;
    for(v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v]=d[u]+M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++){
    printf("%d %d\n",i,(d[i]==INFTY ? -1 : d[i]));
   
  }
}

	



Measured memory_bytes: 2104
N = int(input())
W = [input() for _ in range(N)]
for i in range(N):
    for j in range(N):
        if i != j:
            if W[i] == W[j]:
                print("No")
                exit()
for k in range(N-1):
    if W[k][-1] != W[k+1][0]:
        print("No")
        exit()
print("Yes")

Measured memory_bytes: 9192
from math import log, ceil
def main():
    n = int(input())
    s = [chr(i) for i in range(ord('a'), ord('z')+1)]
    # print(s)
    ans = ""
    m = ceil(log(25*n/26+1, 26))
    while(m>0 and n>0):
        m-=1
        if n%26==0:
            ans+=s[-1]
            n = n//26-1
        else:
            ans+=s[n%26-1]
            n = n//26
    print(ans[::-1])

    # for t in range(int(input())):
        # n = int(input())
        

# "Ashishgup" if he wins, and "FastestFinger"

# for #!/usr/bin/env python
# import os
# import sys
# from io import BytesIO, IOBase


# # region fastio

# BUFSIZE = 8192


# class FastIO(IOBase):
#     newlines = 0

#     def __init__(self, file):
#         self._fd = file.fileno()
#         self.buffer = BytesIO()
#         self.writable = "x" in file.mode or "r" not in file.mode
#         self.write = self.buffer.write if self.writable else None

#     def read(self):
#         while True:
#             b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
#             if not b:
#                 break
#             ptr = self.buffer.tell()
#             self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
#         self.newlines = 0
#         return self.buffer.read()

#     def readline(self):
#         while self.newlines == 0:
#             b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
#             self.newlines = b.count(b"\n") + (not b)
#             ptr = self.buffer.tell()
#             self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
#         self.newlines -= 1
#         return self.buffer.readline()

#     def flush(self):
#         if self.writable:
#             os.write(self._fd, self.buffer.getvalue())
#             self.buffer.truncate(0), self.buffer.seek(0)


# class IOWrapper(IOBase):
#     def __init__(self, file):
#         self.buffer = FastIO(file)
#         self.flush = self.buffer.flush
#         self.writable = self.buffer.writable
#         self.write = lambda s: self.buffer.write(s.encode("ascii"))
#         self.read = lambda: self.buffer.read().decode("ascii")
#         self.readline = lambda: self.buffer.readline().decode("ascii")


# sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
# input = lambda: sys.stdin.readline().rstrip("\r\n")

# # endregion

if __name__ == "__main__":
    main()



Measured memory_bytes: 62332
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)

bool D[10];
bool use[100000];
int main(){
    REP(i,10){
        D[i]=false;
    }
    REP(i,100000){
        use[i]=false;
    }
    int N,K;
    cin>>N>>K;
    REP(i,K){
        int a;
        cin>>a;
        D[a]=true;
    }
    REP(i,100000){
        int a=i;
        while(a!=0){
              int b=a%10;
              a=a/10;
              if(D[b]==true){
                  use[i]=true;
                  break;
              }
        }
    }
    while(1){
        if(use[N]==false){
            break;
        }
        N++;
    }
    cout<<N<<endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <climits>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

int main() {
  int A, B, K; std::cin >> A >> B >> K;
  for (int i = 0; i < K; ++i) {
    if (i%2 == 0) { // A
      if (A%2 == 1) --A;
      A /= 2;
      B += A;
    } else { // B
      if (B%2 == 1) --B;
      B /= 2;
      A += B;
    }
  }
  std::cout << A << " " << B << std::endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
const ll inf=1LL<<60;

int main(){
  ll i,j,N,M,a,b,c,ch;
  cin>>N>>M;
  N=pow(2,N);
  mat dp(M+1,vec(N,inf));
  dp[0][0]=0;
  rep1(i,M+1){
    cin>>a>>b;
    ch=0;
    while(b--){
      cin>>c;
      ch+=1<<(c-1);
    }
    rep(j,N){
      dp[i][j|ch]=min({dp[i-1][j|ch],dp[i-1][j]+a,dp[i][j|ch]});
      dp[i][j]=min(dp[i][j],dp[i-1][j]);
    }
  }

  if(dp[M][N-1]==inf){
    cout<<-1<<endl;
  }else{
    cout<<dp[M][N-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 32384
import numpy as np
N = input()
K = int(input())
keta = len(N)
dp = np.zeros((keta + 1, 2, K + 1), dtype=np.int64)

dp[0][0][0] = 1

for i in range(1, keta + 1):
    n = int(N[i - 1])
    for j in range(K + 1):
        dp[i][1][j] += dp[i - 1][1][j]
        if j > 0:
            dp[i][1][j] += dp[i - 1][1][j - 1] * 9
        if n == 0:
            dp[i][0][j] += dp[i - 1][0][j]
        else:
            dp[i][1][j] += dp[i - 1][0][j]
            if j > 0:
                dp[i][1][j] += dp[i - 1][0][j - 1] * (n - 1)
                dp[i][0][j] += dp[i - 1][0][j - 1]

print(dp[keta][1][K] + dp[keta][0][K])

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;

struct RMQ {
    static const int N = 131072;
    int data[2 * N];

    void init() {
        rep(i, 2 * N) {
            data[i] = INF;
        }
    }

    int query(int a, int b, int l = 0, int r = N, int k = 0) {
        if (b <= l || r <= a)return INF;
        if (a <= l && r <= b)return data[k];
        int lch = query(a, b, l, (l + r) / 2, 2 * k + 1);
        int rch = query(a, b, (l + r) / 2, r, 2 * k + 2);
        return min(lch, rch);
    }

    void update(int a, int x) {
        int a2 = a + N - 1;
        data[a2] = min(data[a2], x);
        while (a2) {
            a2 = (a2 - 1) / 2;
            data[a2] = min(data[2 * a2 + 1], data[2 * a2 + 2]);
        }
    }
};

struct Edge {
    int l, r, c;

    Edge() {}

    Edge(int l, int r, int c) : l(l), r(r), c(c) {}

    bool operator<(Edge other) {
        return r < other.r;
    }
};

int N, M;
Edge edges[100100];
RMQ rmq;

signed main() {
    rmq.init();
    cin >> N >> M;
    rep(i, M) {
        int l, r, c;
        cin >> l >> r >> c;
        --l, --r;
        edges[i] = Edge(l, r, c);
    }
    sort(edges, edges + M);
    rmq.update(0, 0);
    rep(i, M) {
        int l = edges[i].l;
        int r = edges[i].r;
        int minv = rmq.query(l, r);
        if (minv == INF)continue;
        rmq.update(r, minv + edges[i].c);
    }
    if (rmq.query(N - 1, N) == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << rmq.query(N - 1, N) << endl;
    return 0;
}


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

int main(){
    string S;cin>>S;
    ll K;cin>>K;
    ll N=S.size();
    if(N==1){
        cout<<ll(K/2)<<endl;
        return 0;
    }
    if(N==2){
        if(S.at(0)!=S.at(1))cout<<0<<endl;
        else cout<<K<<endl;
        return 0;
    }

    vector<ll> c;
    char a=S.at(0);ll count=0;
    for(int i=0;i<N;i++){
        if(a==S.at(i)){
            count++;
            if(i==N-1){
                c.push_back(count);
                break;
            }
        }
        else{
            c.push_back(count);
            count=0;
            a=S.at(i);
            i--;
        }
    }
    if(c.size()==1){
        cout<<ll(N*K/2)<<endl;
        return 0;
    }
    if(S.at(0)!=S.at(N-1)){
        ll ans=0;
        for(int i=0;i<c.size();i++){
            ans+=c.at(i)/2;
        }
        ans*=K;
        cout<<ans<<endl;
    }
    else{
        ll p=c.at(c.size()-1);
        c.at(c.size()-1)+=c.at(0);
        ll ans=0;
        for(int i=1;i<c.size();i++){
            ans+=c.at(i)/2;
        }
        ans*=K-1;
        for(int i=0;i<c.size()-1;i++){
            ans+=c.at(i)/2;
        }
        ans+=p/2;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
#define sqr(x) ((x)*(x))
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

LL cnt[10][10];

int div(int x) {
    while(x/10) x/= 10;
    return x;
}

void run_case() {
    int n; cin >> n;
    for(int i = 1; i <= n; ++i) cnt[i%10][div(i)]++;
    LL ans = 0;
    for(int i = 0; i <= 9; ++i) 
        for(int j = 0; j <= 9; ++j)
            ans += cnt[i][j]*cnt[j][i];
    cout << ans;
}


int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cout.flags(ios::fixed);cout.precision(9);
    //int t; cin >> t;
    //while(t--)
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 256
const N: usize = 100000;

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut edges = vec![vec![]; 2 * N];
	for _ in 0..n {
		let x = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let y = s.next().unwrap().parse::<usize>().unwrap() - 1 + N;
		edges[x].push(y);
		edges[y].push(x);
	}
	let mut visit = vec![false; 2 * N];
	let mut ans = 0;
	for i in 0..N {
		if visit[i] || edges[i].len() == 0 {
			continue;
		}
		let mut q = vec![i];
		let mut cnt = [0; 2];
		while let Some(v) = q.pop() {
			if visit[v] {
				continue;
			}
			visit[v] = true;
			cnt[v / N] += 1;
			for &to in edges[v].iter() {
				if !visit[to] {
					q.push(to);
				}
			}
		}
		ans += cnt[0] * cnt[1];
	}
	ans -= n;
	println!("{}", ans);
}


Measured memory_bytes: 11808
def Fib(n):
    a, b = 0, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b

def solve():
    n, m = map(int, input().split())
    a = [int(input()) for _ in range(m)]

    if m > 1:
        for i in range(m-1):
            if a[i+1]-a[i] <= 1:
                return 0
    elif m == 0:
        return Fib(n+2)%1000000007

    
    a = a + [n]
    l = [a[0]]
    for i in range(1, m):
        l.append(a[i]-a[i-1]-1)
    l = l + [a[-1]-a[-2]]
    ans = 1
    for i in l:
        ans *= Fib(i+1)

    return ans%1000000007


print(solve())

Measured memory_bytes: 12748
import sys
#from fractions import gcd
from math import gcd
from itertools import combinations
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

K = int(read())
ans = 0

for a in range(1, K + 1):
    for b in range(1, K + 1):
        acc = gcd(a, b)
        for c in range(1, K + 1):
            acc_ = gcd(acc, c)
            ans += acc_
print(ans)


Measured memory_bytes: 9188
#include <stdio.h>

void print_frame(int h, int w){
    int i, j;
    for(j = 0; j < h; j++){
        if(j == 0 || j == h - 1){
            for(i = 0; i < w; i++)
                printf("#");
        }else{
            for(i = 0; i < w; i++){
                if(i == 0 || i == w - 1)
                    printf("#");
                else
                    printf(".");
            }
            
        }
        printf("\n");
    }
    printf("\n");
}

int main(void){
    int h, w;

    scanf("%d %d", &h, &w);
    while(h != 0 && w != 0){
        print_frame(h, w);
        scanf("%d %d", &h, &w);
    }

    return 0;
}



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

int main(void){
	int a, b;
	char op;
	while(1){
		scanf("%d %c %d", &a, &op, &b);
		if(op == '+'){
			printf("%d\n", a + b);
		}else if(op == '-'){
			printf("%d\n", a - b);
		}else if(op == '*'){
			printf("%d\n", a * b);
		}else if(op == '/'){
			printf("%d\n", a / b);
		}else if(op == '?'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

unsigned long long dp[110][100010];

int main(){
    int N, W;
    std::cin >> N >> W;
    int wv[110][2];
    for(int i= 0; i < N; i++){
        std::cin >> wv[i][0] >> wv[i][1];
    }
    for (int i = 1; i < N+1; ++i) {
        for (int j = 1; j < W+1; ++j) {
            if(j >= wv[i-1][0]){
                dp[i][j] = dp[i-1][j-wv[i-1][0]]+wv[i-1][1];
            }
            dp[i][j] = std::max(dp[i][j], dp[i-1][j]);
        }
    }
    unsigned long long m = 0;
    for(int i =0;i <= W;i++){
        m = std::max(dp[N][i], m);
    }
    std::cout << m <<std::endl;

}


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

int main(void){
  int abc[3];
  for(int i = 0; i < 3; i++)
    cin >> abc[i];
  sort(begin(abc), end(abc));
  cout << abc[0] + abc[1] << "\n";
  return 0;
}


Measured memory_bytes: 3636
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

char u[100001];
int main(void){
	int n, i;
	scanf("%d", &n);
	int m=0;
	for(i=0; i<n; i++){
		int a;
		scanf("%d", &a);
		if(u[a]==0){
			u[a]=1;
			m++;
		}
	}
	printf("%d\n", m&1?m:m-1);
}


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

int main(){
  int result = 0;

  int n, d;
  cin >> n >> d;

  vector<long long> x(n);
  vector<long long> y(n);
  for(int i=0; i<n; ++i){
    cin >> x[i] >> y[i];
    if(sqrt(x[i] * x[i] + y[i] * y[i]) <= d){
      result++;
    }
  }
  
  cout << result;
  return 0;
}

Measured memory_bytes: 6484
program main
  implicit none
  integer :: n, i, largest, second
  integer, allocatable :: a(:)
  read (*, *) n
  allocate (a(n))
  read (*, *) (a(i), i = 1, n)
  largest = 0
  second = 0
  do i = 1, n
    if (a(i) > second) then
      second = a(i)
      if (second > largest) call swap(second, largest)
    end if
  end do

  do i = 1, n
    if (a(i) == largest) then
      write (*, "(i0)") second
    else
      write (*, "(i0)") largest
    end if
  end do
  contains
  subroutine swap(a, b)
    integer, intent(inout) :: a, b
    integer :: c
    c = a
    a = b
    b = c
  end subroutine swap
end program main


Measured memory_bytes: 2944
lst = [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]
K = int(input())
print(lst[K-1])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long int n,k;
    cin>>n>>k;
    long long int tmp=n%k;
    if (abs(tmp-k)>tmp) {
        cout<<tmp<<endl;
    } else {
        cout<<abs(tmp-k)<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> T1 pow_(T1 a, T2 b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int k;
  cin >> k;
  int a, b;
  cin >> a >> b;
  for (int i = 0; i <= b; i += k) {
    if (i >= a) {
      cout << "OK" << endl;
      return;
    }
  }
  cout << "NG" << endl;
}


Measured memory_bytes: 3652
# coding: utf-8

n = int(input()) 
t = sorted([int(input()) for i in range(n)])

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a
	
def lcm(a, b):
  return a * b // gcd(a, b)
	
def nlcm(list):
  if len(list) > 2:
    lcm_num = lcm(list[0], list[1])
    for i in range(2, len(list)):
      lcm_num = lcm(lcm_num, list[i])
    
    print(lcm_num)
  elif len(list) == 2:
    print(lcm(list[0], list[1]))
  else:
  	print(list[-1])

nlcm(t)


Measured memory_bytes: 3064
import numpy as np
N, W = map(int, input().split())
wv = np.array([list(map(int, input().split())) for _ in range(N)])
dp = np.zeros(W + 1, dtype="int64")

for w, v in wv:
    dp[w:W+1] = np.maximum(dp[w:W+1], dp[:W-w+1] + v)
    
print(dp[-1])

Measured memory_bytes: 15492
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;



int main()
{
	int H, W;

	while (true) {
		cin >> H >> W;
		if (H == 0 && W == 0) break;
		rep(i, H) {
			rep(j, W) cout << '#';
			cout << endl;
		}
		cout << endl;
	}




	return 0;
}



Measured memory_bytes: 3116
n=int(input())
a=[]
t=0
while n>0:
    b=n%26
    if b==0:
        b=26
        t=1
    c=lambda b:chr(b+64)
    a.append(c(b))
    n//=26
    if t==1:
        n-=1
        t=0
d=len(a)
e=[]
for i in range(d):
    e.append(a[-1-i])
ans=''.join(e)
ans=ans.lower()
print(ans)

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

int main() {
	long long  n,a,b,c,d,e;
	cin >> n >> a >> b >> c >> d >> e;
	long long m;
	m = min({a,b,c,d,e});
	cout << (n+m-1)/m+4 << endl;
	return 0;
}

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

using namespace std;

string CubeInfo[8];
pair<int, int*> Selected[8];
bool Used[8];
//top front right left back bottom
int RotateBase[24][6] = {
	{ 0,1,2,3,4,5 },{},{},{},
	{ 1,5,2,3,0,4 },{},{},{},
	{ 2,1,5,0,4,3 },{},{},{},
	{ 3,1,0,5,4,2 },{},{},{},
	{ 4,0,2,3,5,1 },{},{},{},
	{ 5,4,2,3,1,0 },{},{},{},
};


void fullRotateBase() {
	int tmp[6], num;

	for (int i = 0; i < 21; i += 4) {
		for (int j = 0; j < 6; ++j) {
			tmp[j] = RotateBase[i][j];
		}
		for (int k = 1; k < 4; ++k) {
			num = tmp[1];
			tmp[1] = tmp[3];
			tmp[3] = tmp[4];
			tmp[4] = tmp[2];
			tmp[2] = num;
			for (int j = 0; j < 6; ++j) {
				RotateBase[i + k][j] = tmp[j];
			}
		}
	}
}

bool checkSame(int dice1, int pos1, int dice2, int id, int pos2) {
	char c1, c2;

	c1 = CubeInfo[Selected[dice1].first][Selected[dice1].second[pos1]];
	c2 = CubeInfo[dice2][RotateBase[id][pos2]];

	if (abs(c1 - c2) == 32) {
		return true;
	}
	return false;
}

int solve(int currentId) {
	bool flag;

	if (currentId == 8) {
		return true;
	}

	for (int i = 0; i < 8; ++i) {
		if (Used[i]) {
			continue;
		}
		Used[i] = true;
		for (int id = 0; id < 24; ++id) {
			flag = false;
			//cout << "pos:" << currentId << " =(now_" << i + 1 << ")_pattern:" << setw(2) << id+1 << " = " << StrTmp[currentId] << endl;
			switch (currentId)
			{
			case 0:flag = true; break;
			case 1:
				if (checkSame(0, 2, i, id, 3)) {
					flag = true;
				}
				break;
			case 2:
				if (checkSame(0, 1, i, id, 4)) {
					flag = true;
				}
				break;
			case 3:
				if (checkSame(1, 1, i, id, 4) && checkSame(2, 2, i, id, 3)) {
					flag = true;
				}
				break;
			case 4:
				if (checkSame(0, 5, i, id, 0)) {
					flag = true;
				}
				break;
			case 5:
				if (checkSame(1, 5, i, id, 0) && checkSame(4, 2, i, id, 3)) {
					flag = true;
				}
				break;
			case 6:
				if (checkSame(2, 5, i, id, 0) && checkSame(4, 1, i, id, 4)) {
					flag = true;
				}
				break;
			case 7:
				if (checkSame(3, 5, i, id, 0) && checkSame(5, 1, i, id, 4) && checkSame(6, 2, i, id, 3)) {
					flag = true;
				}
				break;
			default:
				break;
			}
			Selected[currentId] = make_pair(i, RotateBase[id]);
			if (flag && solve(currentId + 1)) {
				return true;
			}
		}
		Used[i] = false;
	}
	return false;
}

int main() {
	int cnt;
	string str;

	fullRotateBase();
	cnt = 0;
	while (cin >> str, str[0] != '0') {
		CubeInfo[cnt] = str;
		++cnt;
		while (cnt != 8) {
			cin >> str;
			CubeInfo[cnt] = str;
			++cnt;
		}
		//show:
		/*for (int i = 0; i < cnt; ++i) {
		cout << CubeInfo[i] << endl;
		}*/
		memset(Used, false, sizeof(Used));
		memset(Selected, 0, sizeof(Selected));
		if (solve(0)) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
		cnt = 0;
	}

	return 0;
}


Measured memory_bytes: 3140
n = int(input())
l = []
for i in range(1, n+1):
    name, score = input().split()
    l.append({'id': i, 'name': name, 'score': int(score)*(-1)})

l = sorted(l, key = lambda x: (x['name'], x['score']))
for i in l:
    print(i['id'])

Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <string>

using namespace std;

using i32 = int;
using i64 = long long;
using u32 = unsigned;
using u64 = unsigned long long;

using pii = pair<i32, i32>;

#define rep(i, n) for (i32 i = 0; i < (n); ++i)
#define repr(i, n) for (i32 i = ((n)-1); i >= 0; --i)
#define urep(i, n) for (u32 i = 0; i < (n); ++i)
#define urepr(i, n) for (u32 i = ((n)-1); i >= 0 && i < (n); --i)
#define all(v) v.begin(), v.end()

int main()
{
	int r;
	cin >> r;
	printf("%d\n", 3 * r * r);
	return 0;
}


Measured memory_bytes: 256
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    lli ct=0,ans;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .
const lli logN=60;
lli gt(lli x)
{
    lli i;
    fo(i,logN)
    {
        if(x&(1LL<<i))
            return (2LL<<i)-1;
    }
    assert(false);
}

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    
    map<lli,lli> mm;
    fo(i,n)
    {
        cin>>in;
        ct^=in;
        a.pb(gt(in));
    }

    dbg(a)
    sort(all(a));
    reverse(all(a));
    dbg(ct,a);
    
    for(auto x:a)
    {
        dbg(ct,ct^x,x)
        if(ct<=(ct^x))
            continue;
        ans++;
        ct^=x;
    }

    if(ct)
        ans=-1;
    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 4340
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  int A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if (A > B) {
    swap(A, B);
  }

  if (T * (V - W) >= B - A)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
using namespace std;

const int B=999999937;
const int P=1000000007;

vector<long long> gen_hash(const string &s){
	vector<long long> hash(s.size());
	long long c=0;
	for(int i=0;i<s.size();i++){
		c=(c*B+s[i])%P;
		hash[i]=c;
	}
	return hash;
}
long long pow_binary_mod(long long x,long long y,long long mod){
	long long z=1;
	for(;y;y>>=1){
		if((y&1)!=0)z=z*x%mod;
		x=x*x%mod;
	}
	return z;
}

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

	string s;
	cin>>s;
	vector<long long> v=gen_hash(s);

	//int T;
	//for(cin>>T;T--;){
		string q;
		cin>>q;
		long long hash=gen_hash(q)[q.size()-1];
		long long Brev=pow_binary_mod(B,q.size(),P);
		vector<int> r;
		int i=q.size()-1;
		for(;i<s.size();i++){
			if(v[i]==((i==q.size()-1?0:v[i-q.size()])*Brev+hash)%P){
				r.push_back(i-q.size()+1);
			}
		}
		if(!r.empty()){
			for(int i=0;i<r.size();i++)printf("%d\n",r[i]);
			//puts("1");
		}else{
			//puts("0");
		}
	//}
}

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

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	string ans = "";
	for(int i = sy; i < ty; i++) ans.push_back('U');
	for(int i = sx; i < tx; i++) ans.push_back('R');
	for(int i = sy; i < ty; i++) ans.push_back('D');
	for(int i = sx; i < tx; i++) ans.push_back('L');
	ans.push_back('L');
	for(int i = sy; i < ty + 1; i++) ans.push_back('U');
	for(int i = sx; i < tx + 1; i++) ans.push_back('R');
	ans.push_back('D');
	ans.push_back('R');
	for(int i = sy; i < ty + 1; i++) ans.push_back('D');
	for(int i = sx; i < tx + 1; i++) ans.push_back('L');
	ans.push_back('U');
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define mod 2019
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
ll dp[2025]={};
int main()
{
	ios;
	string s;
	ll len,i,ans=0,d,j,res;
	cin>>s;
	len=s.length();
	dp[s[0]-48]=1;
	for(i=1;i<len;i++)
	{
		ll cnt[2025]={};
		d=s[i]-48;
		cnt[d]=1;
		for(j=0;j<=2018;j++)
		{
			res=(j*10+d)%mod;
			if(res==0)
				ans+=dp[j];
			cnt[res]+=dp[j];
		}
		for(j=0;j<=2018;j++)
			dp[j]=cnt[j];
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3712
#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>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
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)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;

#define ALL(a) (a).begin(),(a).end()
#define INF 1e+9
#define MAX_V 300

struct edge {
    int to;
    int cost;
};
using P = pair<ll, ll>;

int main(){
  int N;cin>>N;
  int ac,wa,tle,re;
  ac=wa=tle=re=0;
  REP(i,N){
    string tmp;cin>>tmp;
    if(tmp=="AC"){
      ac++;
    }
    if(tmp=="WA"){
      wa++;
    }
    if(tmp=="TLE"){
      tle++;
    }
    if(tmp=="RE"){
      re++;
    }
  }
  cout<<"AC"<<" x "<<ac<<endl;
  cout<<"WA"<<" x "<<wa<<endl;
  cout<<"TLE"<<" x "<<tle<<endl;
  cout<<"RE"<<" x "<<re<<endl;
}


Measured memory_bytes: 3244
def partition(a, p, r):
	x = a[r]
	i = p - 1
	for j in range(r):
		if a[j] <= x:
			i += 1
			swap(a, i, j)
	swap(a, i + 1, r)
	return i + 1

def swap(a, i, j):
	tmp = a[i]
	a[i] = a[j]
	a[j] = tmp

n = int(input())
a = list(map(int, input().split()))
idx = partition(a, 0, len(a) - 1)
if idx == 0:
	print('[' + str(a[0]) + ']', end='')
else:
	print(a[0], end='')
for i in range(1, n):
	print(' ', end='')
	if idx == i:
		print('[' + str(a[i]) + ']', end='')
	else:
		print(a[i], end='')
print()



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

int main() {
    int n, k; cin >> n >> k;
    vector<long long> num(k, 0);
    for (int i = 1; i <= n; ++i) num[i%k]++; // num[x] = kで割ってxあまる数が1以上N以下に何個あるか
    long long res = 0;
    for (int a = 0; a < k; ++a) {
        int b = (k-a) % k;
        int c = (k-a) % k;
        if ((b+c) % k != 0) continue;
        res += num[a] * num[b] * num[c];
    }
    cout << res << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n; cin >> n;
	vector<string>s(n);
	rep(i, n)cin >> s[i];

	vector<ll>p(5);
	rep(i, n) {
		if (s[i].at(0) == 'M')p[0]++;
		if (s[i].at(0) == 'A')p[1]++;
		if (s[i].at(0) == 'R')p[2]++;
		if (s[i].at(0) == 'C')p[3]++;
		if (s[i].at(0) == 'H')p[4]++;
		}

	ll ans = 0;
	for (int i = 0; i <= 2; i++) {
		for (int j = i + 1; j <= 3; j++) {
			for (int k = j + 1; k <= 4; k++) {
				ans += p[i] * p[j] * p[k];
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e5)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) { 
        os << v[i]; 
        if (i != (int)v.size() - 1) 
            os << " "; 
    } 
    return os; 
} 

int main()
{
    ll N;
    cin >> N;
    vector<ll> B(N-1);
    rep(i, N) { 
        cin >> B[i];
    }
    ll cnt = B[0] + B[N-2];
    rep(i, N - 2) {
        cnt += min(B[i], B[i+1]);
    }
    print(cnt);
    return 0;
}

Measured memory_bytes: 256
N=int(input())
BA=[[0,0] for _ in range(N)]

for i in range(N):
    BA[i][1],BA[i][0]=map(int,input().split())
BA.sort()

t=0
ans="Yes"
for i in range(N):
    t+=BA[i][1]
    if t>BA[i][0]:
        ans="No"
        break
print(ans)

Measured memory_bytes: 67020
import math
S = input()
ans = ['0'] * len(S)
# pre_s = 'R'
is_R = True
border = 0
cnt_R = 1
cnt_L = 0
for i, s in enumerate(S[1:], 1):
    if is_R:
        if s == 'R':
            cnt_R += 1
        else:
            is_R = False
            border = i
            cnt_L += 1
    elif not is_R:
        if s == 'L':
            cnt_L += 1
        else:
            is_R = True
            cntRL = cnt_R + cnt_L
            if cntRL % 2 == 0:
                ans[border-1] = str(cntRL // 2)
                ans[border] = str(cntRL // 2)
            elif max(cnt_L-1, cnt_R-1) % 2 == 0:
                if cnt_R > cnt_L:
                    ans[border-1] = str(math.ceil(cntRL/2))
                    ans[border] = str(cntRL//2)
                else:
                    ans[border] = str(math.ceil(cntRL/2))
                    ans[border-1] = str(cntRL//2)
            else:
                if cnt_R > cnt_L:
                    ans[border] = str(math.ceil(cntRL/2))
                    ans[border-1] = str(cntRL//2)
                else:
                    ans[border-1] = str(math.ceil(cntRL/2))
                    ans[border] = str(cntRL//2)
            cnt_R = 1
            cnt_L = 0
cntRL = cnt_R + cnt_L
if cntRL % 2 == 0:
    ans[border-1] = str(cntRL // 2)
    ans[border] = str(cntRL // 2)
elif max(cnt_L-1, cnt_R-1) % 2 == 0:
    if cnt_R > cnt_L:
        ans[border-1] = str(math.ceil(cntRL/2))
        ans[border] = str(cntRL//2)
    else:
        ans[border] = str(math.ceil(cntRL/2))
        ans[border-1] = str(cntRL//2)
else:
    if cnt_R > cnt_L:
        ans[border] = str(math.ceil(cntRL/2))
        ans[border-1] = str(cntRL//2)
    else:
        ans[border-1] = str(math.ceil(cntRL/2))
        ans[border] = str(cntRL//2)
print(' '.join(ans))

Measured memory_bytes: 45660
from collections import deque
N = int(input())
INF = 10**12
# tree = [[INF for _ in range(N)]for __ in range(N)]
tree = [[]for __ in range(N)]

for i in range(N-1):
    u, v, w = [int(n) for n in input().split()]
    u -= 1
    v -= 1
    tree[u].append((v, w))
    tree[v].append((u, w))

color = [INF for __ in range(N)]
treedist = [INF for __ in range(N)]


def bfs(s):
    q = deque()
    q.append(s)
    color[s[0]] = 0
    treedist[s[0]] = 0
    while(len(q) != 0):
        u = q.pop()
        for near in tree[u[0]]:
            if treedist[near[0]] != INF:
                continue
            treedist[near[0]] = treedist[u[0]] + near[1]
            if treedist[near[0]] % 2 == 0:
                color[near[0]] = 0
            else:
                color[near[0]] = 1
            q.append(near)

# print(tree)

bfs((u, v))
# print(u, v)
# print(treedist)
for i in range(len(color)):
    print(color[i])


Measured memory_bytes: 73028
// Code by Nguyen Huu Lam
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long LL;
typedef long double LD;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Silent_voice
#define endl "\n"

template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e6;

LL n, a[MaxN], k;

LL Check(LL val){
    LL cnt = 0;
    for(int i = 0 ; i < n ; ++i){
        if(a[i] == 0)
            if(val > 0) cnt += n;
        if(a[i] > 0){
            cnt += lower_bound(a, a + n, LD(val) / a[i]) - a;
        }
        if(a[i] < 0) {
            cnt += n - (upper_bound(a, a + n, LD(val) / a[i]) - a);
        }
        if(a[i] * a[i] < val) cnt--;
    }
    if(cnt / 2 < k) return 1;
    return 0;
}

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for(int i = 0 ; i < n ; ++i) cin >> a[i];
    sort(a, a + n);
    LL l = -2e18, r = 2e18;
    while(l < r - 1){
        LL tg = (l + r) / 2;
        if(Check(tg)) l = tg;
        else r = tg;
    }
    if(Check(l)) cout << l << endl;
    else cout << r << endl;

    return 0;
}

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

import sys
def input(): return sys.stdin.readline().strip()
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

from collections import Counter

N = int(input())
aN = list(map(int, input().split()))

dups = Counter(aN)
for k, v in dups.items():
    dups[k] -= 1
aN = sorted(set(aN))

if sum(dups.values()) % 2 == 0:
    print(len(aN))
else:
    print(len(aN)-1)


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

int x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>x;
    int s=0;
    s+=(x/500)*1000;
    x-=s/2;
    s+=(x/5)*5;
    cout<<s;

    return 0;
}


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

    int main (){
        int a,b;
        cin >> a >> b;
        int i=0;
        int sum = 1;
  while(sum<b){
      sum--;
      sum+=a;
    i++;
  }
        cout << i << endl;
        return 0;
    }

Measured memory_bytes: 3616
import bisect

def find_smallest(LLL,ind):
    ret=bisect.bisect_left(LLL,ind)
    if ret==len(LLL):    return -1
    return ret


[A,B]=map(int, raw_input().split())
P=map(int, raw_input().split())
Q=map(int, raw_input().split())

K=[[] for i in range(1001)]
M=[[] for i in range(1001)]
L=[[] for i in range(B)]
for i in range(A):
    M[P[i]].append(i)
for i in range(B):
    K[Q[i]].append(i)


for i in range(B):
    L[i]=M[Q[i]][:]
    
ans=0

for i in range(B):
    tmp=0
    LL=L[:]
    ind=-1
    for j in range(i,B):
        id = find_smallest(LL[j],ind)
        if id==-1:
            break
        ind=LL[j][id]
        for k in K[Q[j]]:
            LL[k]=LL[k][id+1:]
        tmp+=1
    ans=max(ans,tmp)

print ans

Measured memory_bytes: 8820
import java.util.Scanner;

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

		//????????£?????????????????§????????????????????????
		//????????\???
		Scanner sc = new Scanner(System.in);
		//int???????????????a
	     int a = sc.nextInt();
	     //int???????????????b
	     int b = sc.nextInt();

	     //?????¶??? a????????????????????§??????
	     if (a<b){
	    	 System.out.println('a' + " < " + 'b');
	    //?????¶???a???????????????????°???????
	     } else if(a>b){
	    	 System.out.println('a' + " > " + 'b');
	    //?????¶???a??¨???????????????
	     }else if(b == a){
	    	 System.out.println('a' + " == " + 'b');
	     }
	}
}

Measured memory_bytes: 26060