akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  cin >> N;
  int H[N];
  rep(i,N) {
    cin >> H[i];
  }
  int ans = 1;
  srep(i,1,N) {
    bool flag = true;
    srep2(j,0,i) {
      if(H[i] < H[j]) {
        flag = false;
      }
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

bool pairCompare(const LP& firstElof, const LP& secondElof){
    return firstElof.first < secondElof.first;
}

int main(){	
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N, M;
	cin >> N >> M;
	vector< LP > v;
	llong a, b;
	REP(i, N){
		cin >> a >> b;
		v.push_back(LP(a, b));
	}
	sort(v.begin(), v.end(), pairCompare);
	llong cost = 0;
	LP tmp;
	REP(i, N){
		tmp = v[i];
		if(tmp.second <= M){
			cost += tmp.first * tmp.second;
			M -= tmp.second;
		} else {
			cost += tmp.first * M;
			break;
		}
	}
	
	cout << cost << '\n';

	return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
ll pwr[210], mod=998244353;
void pre(){
  pwr[0]=1;
  for(int i=1; i<=200; ++i){
    pwr[i]=(pwr[i-1]*2)%mod;
  }
}
ll x[210], y[210];
map<pair<ll,ll>, ll> mp;
int main(){
  int n;
  pre();
  while(cin>>n){
    for(int i=0; i<n; ++i){
      scanf("%lld%lld",&x[i],&y[i]);
    }
    ll ans=pwr[n]-n-1, tmp1, tmp2, tmp;
    for(int i=0; i<n; ++i){
      mp.clear();
      for(int j=i+1; j<n; ++j){
        tmp1=(y[i]-y[j]);
        tmp2=(x[i]-x[j]);
        tmp=__gcd(tmp1, tmp2);
        tmp1/=tmp;
        tmp2/=tmp;
        ++mp[mk(tmp1, tmp2)];
      }
      for(map<pair<ll,ll>, ll>::iterator it=mp.begin(); it!=mp.end(); ++it){
        ans-=(pwr[it->second])-1;
        ans%=mod;
      }
    }
    ans%=mod;
    if(ans<0)
      ans+=mod;
    printf("%lld\n",ans);
  }
  return 0;
}




Measured memory_bytes: 384
#include<bits/stdc++.h>
#define sc(v) v.size()
#define eb push_back
#define pb pop_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define TC() int t;cin>>t;while(t--)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define fi first
#define se second
#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

int main()
{
	int n, d;
	cin>>n>>d;
	int i = 0, ans = 0;
	while (i < n) {
		i += 2*d + 1;
		ans++;
	}
	cout<<ans;
    return 0;
}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



i64 n;
void solve(){
	cin >> n;
	
	int ans = 0;
	for(i64 i = 10; i <= n*10; i*=10){
		ans += n%i*10/i;
	}
	cout << (n % ans == 0 ? "Yes":"No") << endl; 
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		System.out.println(s.substring(0, 1) + String.valueOf(s.length() - 2) + s.substring(s.length() - 1));
	}
}

Measured memory_bytes: 21716
#include<stdio.h>

int LinearSearch(int *,int);
int n,q;

int main(){
  int C[10000];
  int T[500];
  int i,j,a,c=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d ",&C[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  for(j=0;j<q;j++){
    a = LinearSearch(&C[0],T[j]);
    c += a;
  }

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

  return 0;
}

int LinearSearch(int * A, int key){
  int i;

  for(i=0;i<n;i++){
    if(A[i]==key) return 1;
  }
    return 0;
}
  

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    ll N; cin >> N;

    ll ans = 0;

    for (int i = 1; i <= N; ++i) {
        if (i >= 1 && i <= 9) {
            ++ans;
        }

        if (i >= 100 && i <= 999) {
            ++ans;
        }

        if (i >= 10000 && i <= 99999) {
            ++ans;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
let id x = x

let s = 1000000007
let inv2 = 500000004

let repeat f =
  let rec aux accu = function
    | 0 -> accu
    | n -> aux (f () :: accu) (n - 1) in
  aux []

let pow k =
  let rec aux accu k = function
  | 0 -> accu
  | n when n mod 2 == 0 -> aux accu (k*k mod s) (n/2)
  | n -> aux (accu*k mod s) (k*k mod s) (n/2) in
  aux 1 k

let inv k = pow k (s-2)

let () =
  let n = Scanf.scanf "%d\n" id in
  let l = repeat (fun () -> Scanf.scanf "%d %d\n" (fun a b -> (a,b))) n in
  let (maxa, maxb) = List.fold_left (fun (c,d) (a,b) -> (max a c, max d b)) (0, 0) l in
  let factbl = Array.make (2*maxa+2*maxb+1) 1 in
    for i = 1 to 2*maxa+2*maxb do Array.unsafe_set factbl i ((Array.unsafe_get factbl (i-1)) * i mod s) done;
  let ifactbl = Array.make (2*maxa+2*maxb+1) 0 in
    ifactbl.(2*maxa+2*maxb) <- inv factbl.(2*maxa+2*maxb);
    for i = 2*maxa+2*maxb-1 downto 0 do Array.unsafe_set ifactbl i ((Array.unsafe_get ifactbl (i+1)) * (i+1) mod s) done;
  let bc n k = ((factbl.(n)*ifactbl.(k) mod s) * ifactbl.(n-k) mod s) in
  let sal = List.sort (fun (a,b) (c,d) -> compare c a) l in
  let dp = Array.make (1 + 2 * maxb) 0 in
  let update () = for i = 1 to 2 * maxb do Array.unsafe_set dp i ((Array.unsafe_get dp i + Array.unsafe_get dp (i-1)) mod s) done in
  let rec solve sl m =
    if m > maxa then ()
      else match sl with
           | (a, b) :: tl when a = maxa-m -> dp.(maxb-b) <- ((dp.(maxb-b) +1) mod s); solve tl m
           | _ -> update (); solve sl (m+1) in
  solve sal 0;
  let rec accum accu = function
    | 0 -> accu + dp.(0)*dp.(2*maxb) mod s
    | k -> accum ((accu + ((s+dp.(k)-dp.(k-1)) mod s)*dp.(2*maxb-k) mod s) mod s) (k-1) in
  let sum = accum 0 (2*maxb) in
  let x = List.fold_left (fun x (a,b) -> (x + bc (2*a+2*b) (2*a)) mod s) 0 l in
    print_int ((s+sum - x)*inv2 mod s)

Measured memory_bytes: 30080
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <queue>
#include <map>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define INF 1e10
typedef long long ll;
typedef long double ld;
int main(){
    string x;
    cin>>x;
    string head, tail;
    ll n=SIZE(x);
    if(n<3){
        cout<<0<<endl;
    }else{
        head=x.substr(0,n-2), tail=x.substr(n-2,2);
        ll head_num=stoll(head), tail_num=stoll(tail);
        cout<<((head_num*5>=tail_num)?1:0)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <functional>
#include <array>

using namespace std;

int dp[100001];

int Func(int n){
    if(dp[n] > 0){
        return dp[n];
    }
    int res = n;
    for(int i = 6; i <= n; i *= 6){
        res = min(res, 1 + Func(n - i));
    }
    for(int i = 9; i <= n; i *= 9){
        res = min(res, 1 + Func(n - i));
    }
    return dp[n] = res;
}


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

    dp[0] = 0;
    dp[1] = 1;
    for(int i = 6; i <= 100000; i *= 6){
        dp[i] = 1;
    }
    for(int i = 9; i <= 100000; i *= 9){
        dp[i] = 1;
    }

    cout << Func(N) << endl;
}

Measured memory_bytes: 1152
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val s = sc.next()

  val keys = mutableSetOf<String>()
  val firsts = mutableSetOf<Char>()
  val seconds = mutableSetOf<Char>()
  val thrids = mutableSetOf<Char>()
  for (first in 0..s.length - 3) {
    val digit1 = s[first]
    if (firsts.size == 10) {
      break
    }
    if (firsts.contains(digit1)) {
      continue
    }
    firsts.add(digit1)
    seconds.clear()
    for (second in first + 1..s.length - 2) {
      val digit2 = s[second]
      if (seconds.size == 10) {
        break
      }
      if (seconds.contains(digit2)) {
        continue
      }
      seconds.add(digit2)
      thrids.clear()
      for (third in second + 1 until s.length) {
        val digit3 = s[third]
        if (thrids.size == 10) {
          break
        }
        if (thrids.contains(digit3)) {
          continue
        }
        thrids.add(digit3)
        val key = "$digit1$digit2$digit3"
        keys.add(key)
      }
    }
  }
  println(keys.size)
}

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

constexpr int INF = 1e9;

int main() {
    int n, m;
    while(cin >> n >> m, n) {
        vector<vector<vector<int>>> d(2, vector<vector<int>>(m, vector<int>(m, INF)));
        for(int i=0; i<m; ++i) {
            d[0][i][i] = d[1][i][i] = 0;
        }
        for(int i=0; i<n; ++i) {
            int a, b, cost, time;
            cin >> a >> b >> cost >> time;
            a--; b--;
            d[0][a][b] = d[0][b][a] = cost;
            d[1][a][b] = d[1][b][a] = time;
        }

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

        int k;
        cin >> k;
        for(int i=0; i<k; ++i) {
            int p, q, r;
            cin >> p >> q >> r;
            p--; q--;
            cout << d[r][p][q] << endl;
        }
    }
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define sc(x) scanf("%d", &x)
#define pr(x) printf("%d\n", x)
#define lowbit(x) (x & -x)
#define ll long long
#define N 100010
using namespace std;
int n, m, col[N], tot = 0, head[N], maxx[N], q;
struct Xiao
{
	int next, to;
}e[N * 2];
struct Wang
{
	int v, d, c;
}qvq[N];
inline void add(int x, int y)
{
	e[++tot].next = head[x];
	e[tot].to = y;
	head[x] = tot;
}
inline void dfs(int d, int sc, int x, int fa)
{
	if (d <= maxx[x]) return;
	maxx[x] = d;
	if (col[x] == 0) col[x] = sc;
	for (int i = head[x]; i; i = e[i].next)
	{
		int y = e[i].to;
		if (y == fa) continue;
		dfs(d - 1, sc, y, x);
	}
}
int main()
{
	sc(n);
	sc(m);
	for (int i = 1; i <= m; i++)
	{
		int a, b;
		sc(a);
		sc(b);
		add(a, b);
		add(b, a);
	}
	sc(q);
	for (int i = 1; i <= q; i++)
	{
		sc(qvq[i].v);
		sc(qvq[i].d);
		sc(qvq[i].c);
	}
	memset(maxx, -1, sizeof maxx);
	for (int i = q; i >= 1; i--)
	dfs(qvq[i].d, qvq[i].c, qvq[i].v, 0);
	for (int i = 1; i <= n; i++)
	printf("%d\n", col[i]);
	return 0;
}


Measured memory_bytes: 4608
use std::io;

fn main() {
	let vec = read_vec::<i32>();
	let h_vec = read_vec::<i32>();

	let k: i32 = vec[1];

	let count = h_vec.into_iter().filter(|&a| a >= k).count();

	println!("{}", count);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	let mut line = String::new();
	io::stdin().read_line(&mut line)
		.ok()
		.expect("Faild to read Vec");
	line.trim().split_whitespace()
		.map(|i| i.parse().ok().unwrap()).collect()
}

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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e6 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 82
// mbeginer 162
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/


int main()
{
    ll x, y;
    cin >> x >> y;
    ll k =y/x;
    ll dem = 0;
    while(k > 0)
    {
        k /= 2;
        dem ++;
    }
    cout << dem ;
}
/*

*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,a;
  cin>>N;
  a=0;
  if(N/100>0&&N/100<13)a=1;
  if(N%100>0&&N%100<13)a=a+10;
  if(a==0){
  cout<<"NA"<<endl;
  }else if(a==1){
  cout<<"MMYY"<<endl;
  }else if(a==10){
  cout<<"YYMM"<<endl;
  }else if(a==11){
  cout<<"AMBIGUOUS"<<endl;
  }
  
}

Measured memory_bytes: 256
n = int(input())
a = []
max_value = 0
max_count = 0

for i in range(n):
  value = int(input())  
  max_value = max(max_value, value)
  a.append(value)
  
for i in range(n):
  if a[i] == max_value:
    max_count += 1
  
if max_count > 1:
  for i in range(n):
    print(max_value)
else:
  max_index = a.index(max_value)
  a.pop(max_index)
  second_max = max(a)
  
  for i in range(n):
    if i != max_index:
      print(max_value)
    else:
      print(second_max)

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){  
        sum=sum+(s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
}


Measured memory_bytes: 3676
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int n = scanner.nextInt();
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = scanner.nextInt();
			}
			int count = 0;
		
			for (int i = 0; i < n; i++) {
					if (i+1 == arr[arr[i]-1]) {
						count++;
					}
			}
			System.out.println(count/2);	
		}
		
	}
}

Measured memory_bytes: 32512
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
//#define DEBUG
#ifdef DEBUG
#define DEBUG_PRINT(fm, ...) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout << "DEBUG PRINT ";std::printf(fm, __VA_ARGS__);}while(0)
#define DEBUG_VAL(a, b) do{std::printf("%s:%d(%s)", __FILE__, __LINE__, __func__);std::cout <<"DEBUG VAL " << a << ":" << b << endl;}while(0)
#else
#define DEBUG_PRINT(...)do{}while(0);
#define DEBUG_VAL(a, b)do{}while(0);
#endif

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

int main(){
    int n;
    cin >> n;
    map<string, int> D;
    ll ans = 0;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        DEBUG_VAL("s", s);
        if(D.find(s) != D.end()){
            ans += D[s];
            D[s]++;
        }else D.insert(make_pair(s, 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 11388
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>a(n);
  vector<double>b(n);
  rep(i,n) cin>>a[i];
  rep(i,n) b[i]=1.0/a[i];
  double sum=0.0;
  rep(i,n) sum+=b[i];
  cout<<fixed<<setprecision(10)<<1/sum<<endl;
}


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

const int N = 1e5+5;
int A, B, M;
int a[N], b[N], c[N], x[N], y[N];
int ans = 0x3f3f3f3f;

int main() {
    //freopen("B.in", "r", stdin);
    scanf("%d%d%d", &A, &B, &M);
    for (int i = 1; i <= A; i++) {
        scanf("%d", a+i);
    }
    int ma = *min_element(a+1, a+A+1);
    for (int i = 1; i <= B; i++) {
        scanf("%d", b+i);
    }
    int mb = *min_element(b+1, b+B+1);
    for (int i = 1; i <= M; i++) {
        scanf("%d%d%d", x+i, y+i, c+i);
        ans = min(ans, a[x[i]] + b[y[i]] - c[i]);
    }
    ans = min(ans, ma+mb);

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


    return 0;
}

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


int main(){
    int n;
    string s;
    cin >> n;
    cin >> s;
    bool a,b,c;
    int count = 0;

    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                a = false;
                b = false;
                c = false;

                for(int l = 0; l < n; l++){
                    if(!a){
                        if(s[l] - '0' == i) a = true;
                    }else{
                        if(!b){
                            if(s[l] - '0' == j) b = true;
                        }else{
                            if(s[l] - '0' == k){
                                c = true;
                                count++;
                                break;
                            } 
                        }
                    }
                        
                }
            }
        }
    }
    cout << count << endl;

}

Measured memory_bytes: 512
X = gets.to_i
h = {}
h[1] = true
(2..X).each do |b|
  (2..X).each do |p|
    h[b**p] = true
    break if b**p > X
  end
end
X.downto(0) do |x|
  if h[x]
    puts x
    break
  end
end

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    set<ll> m;
    for(int i=0;i<n;++i){
        ll a;cin>>a;
        if(m.find(a) != m.end()){
            m.erase(a);
        }else m.insert(a);
    }
    cout << m.size() << endl;
    return 0;
}

Measured memory_bytes: 8188
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <set>
using namespace std;
int n,t[1000010],m;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&t[i]);
	scanf("%d",&m);
	while(m--)
	{
		int a,b,ans=0;
		scanf("%d%d",&a,&b);
		for(int i=1;i<=n;i++)
		{
			if(i==a)
			ans+=b;
			else
			ans+=t[i];
		}
		cout<<ans<<"\n";
	}
	return 0;
} 

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

using namespace std;

#define FOR(i,n)	for(int i=0;i<(int)n;i++)
#define FOB(i,n)	for(int i=n;i>=1;i--)
#define MP(x,y)	make_pair((x),(y))
#define ii pair<int, int>
#define lli long long int
#define ld long double
#define ulli unsigned long long int
#define lili pair<lli, lli>
#ifdef EBUG
#define DBG	if(1)
#else
#define DBG	if(0)
#endif
#define SIZE(x) int(x.size())
const int infinity = 2000000999 / 2;
const long long int inff = 4000000000000000999;

typedef complex<long double> point;

template<class T>
T get() {
    T a;
    cin >> a;
    return a;
}

template <class T, class U>
ostream& operator<<(ostream& out, const pair<T, U> &par) {
    out << "[" << par.first << ";" << par.second << "]";
    return out;
}

template <class T>
ostream& operator<<(ostream& out, const set<T> &cont) {
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}";
    return out;
}

template <class T, class U>
ostream& operator<<(ostream& out, const map<T,U> &cont) {
    out << "{";
    for (const auto &x:cont) out << x << ", ";
    out << "}"; return out;
}

template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  FOR(i, v.size()){
    if(i) out << " ";
    out << v[i];
  }
  out << endl;
  return out;
}

bool ccw(point p, point a, point b) {
  if((conj(a - p) * (b - p)).imag() <= 0) return false;
  else return true;
}

int main() {
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    int n = get<int>();
    int m = get<int>();
    string s = get<string>();
    vector<int> As(n, 0), Bs(n, 0);
    vector<vector<int> > hrany(n);
    FOR(i, m) {
        int a = get<int>() - 1;
        int b = get<int>() - 1;
        if(s[a] == 'A') As[b] ++;
        else Bs[b] ++;
        if(s[b] == 'A') As[a] ++;
        else Bs[a] ++;
        hrany[a].push_back(b);
        hrany[b].push_back(a);
    }
    
    vector<bool> in(n, 1);
    queue<int> out;
    FOR(i, n) {
        if(!(As[i] && Bs[i])) {
            out.push(i);
            in[i] = 0;
        }
    }
    
    while(out.size()) {
        int v = out.front();
        out.pop();
        
        for(int w : hrany[v]) {
            if(in[w]) {
                if(s[v] == 'A') As[w] --;
                else Bs[w] --;
                if(!(As[w] && Bs[w])) {
                    in[w] = 0;
                    out.push(w);
                }
            }
        }
    }
    
    int cnt = 0;
    FOR(i, n) cnt += (in[i] ? 1 : 0);
    if(cnt > 1) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


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

int main() {
    ll n, k, a = 0, ans;
    bool ss = false;
    cin >> n >> k;
    ans = n - k + 1;
    vector<ll> p(n);
    vector<bool> s(n - k + 1, true);
    for (ll i = 0; i < n; i++) cin >> p[i];

    for (ll i = 0; i < n - 1; i++) {
        if (p[i] < p[i + 1])
            a++;
        else
            a = 0;

        if (a >= k - 1) {
            s[i - k + 2] = false;
            if (ss)
                ans--;
            else
                ss = true;
        }
    }

    set<ll> window;
    for (ll i = 1; i < n - 1; i++) {
        window.insert(p[i]);
        if ((ll)window.size() == k - 1) {
            if (s[i - k + 1] || s[i - k + 2]) {
                auto itr = window.begin();
                auto itr2 = window.end();
                itr2--;
                if (p[i - k + 1] < *itr && p[i + 1] > *itr2) ans--;
            }
            window.erase(window.lower_bound(p[i - k + 2]));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(i64, S);

    i64 Xa, Ya, Xb, Yb, Xc, Yc;
    Xc = 0;
    Yc = 0;

    Xa = 1e9;
    Ya = 1;

    Yb = (S + Xa - 1) / Xa;
    Xb = Xa * Yb - S;

    print(Xa, Ya, Xb, Yb, Xc, Yc);

    return 0;
}


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

using ll = long long;

std::vector<int> PrimeFactoring(int N){
    std::vector<int> ans;
    while(N != 1){
        for(int a = 2;a <= sqrt(N);a++){
            if(N % a == 0){
                N /= a;
                ans.push_back(a);
                break;
            }
        }
        if(N != 1){
            ans.push_back(N);
            N = 1;
        }
    }
    return ans;
}

void solve(long long N, std::vector<long long> A){
    set<int> se;
    bool f = false;
    for(int i = 0;i < N;i++){
        vector<int> w = PrimeFactoring(A[i]);
        for(auto a : w){
            if(se.find(a) != se.end()){
                f = true;
            }
        }
        for(auto a : w){
            se.insert(a);
        }
    }
    if(f == false){
        cout<<"pairwise coprime"<<endl;
        return;
    }
    ll cure = A.front();
    for(int i = 0;i < N;i++){
        cure = __gcd(A[i], cure);
    }
    if(cure == 1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 36112
#!/usr/bin/ruby
EPS=1e-9
def cross(a,b) (a.conj*b).imag end
def dot(a,b) (a.conj*b).real end
def projection(l,p)
	t=dot(p-l[0],l[0]-l[1])/(l[0]-l[1]).abs2
	l[0]+t*(l[0]-l[1])
end
def intersectSP(s,p)
	(s[0]-p).abs+(s[1]-p).abs-(s[1]-s[0]).abs < EPS # triangle inequality
end
def distanceSP(s,p)
	r=projection(s,p)
	return (r-p).abs if intersectSP(s,r)
	[(s[0]-p).abs,(s[1]-p).abs].min
end
def distanceSS(s,t)
	return 0 if intersectSS(s,t)
	[s.map{|e|distanceSP(t,e)}.min,t.map{|e|distanceSP(s,e)}.min].min
end
def intersectSS(l,m)
	a=cross(l[1]-l[0],m[1]-m[0])
	b=cross(l[1]-l[0],l[1]-m[0])
	pt=a.abs<EPS ? b.abs<EPS ? [l[0],l[1],m[0],m[1]] : [] : [m[0]+b/a*(m[1]-m[0])]
	pt.any?{|e|
		dot(l[0]-e,l[1]-e)<EPS && dot(m[0]-e,m[1]-e)<EPS
	}
end
while(n=gets.to_i)>0
	sx,sy,ex,ey=gets.split.map(&:to_f)
	s=[Complex(sx,sy),Complex(ex,ey)]
	p n.times.map{
		f=0
		x1,y1,x2,y2,h=gets.split.map(&:to_f)
		a=[x1,x2].product([y1,y2]).map{|x,y|Complex(x,y)}
		a[2],a[3]=a[3],a[2]
		d=4.times.map{|i|
			f+=cross(a[i]-s[0],a[(i+1)%4]-s[0])<EPS ? 1 : 0
			distanceSS(s,[a[i],a[(i+1)%4]])
		}.min
		if f==4 #inside
			0
		elsif d>h
			(h*h+d*d)/h/2
		else
			d
		end
	}.min
end

Measured memory_bytes: 6172
#include <bits/stdc++.h>
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define int long long
using namespace std;

const int N = 60;

int n;
long double x[N];
long double y[N];
long double center_x = 0.0;
long double center_y = 0.0;
long double sum_x = 0.0;
long double sum_y = 0.0;

inline long double dist (long double x, long double y, long double xx, long double yy) {
  return (x - xx) * (x - xx) + (y - yy) * (y - yy);
}

signed main () {
  boost();
  auto start_time = chrono::high_resolution_clock::now();  
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sum_x += x[i];
    sum_y += y[i];
  }
  center_x = sum_x / (long double)n;
  center_y = sum_y / (long double)n;
  long double res = 1e9;
  long double step = 0.1;
  while (true) {
    int ind = -1;
    long double cur = -1.0;
    for (int i = 0; i < n; i++) {
      if (cur < dist(center_x, center_y, x[i], y[i])) {
        cur = dist(center_x, center_y, x[i], y[i]);
        ind = i;
      }
    }
    res = min (res, cur);
    center_x += (x[ind] - center_x) * step;
    center_y += (y[ind] - center_y) * step;
    step *= 0.999;
    // if (step > 0) cout << step << endl;
    auto end_time = chrono::high_resolution_clock::now();
    chrono::duration<double, std::milli> elapsed_time = end_time - start_time;
    if (elapsed_time.count() >= 1950) break;
  }
  cout << sqrt(res) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    int n;
    cin>>n;
    vector<int> t(n),v(n);
    rep(i,n)cin>>t[i];
    rep(i,n)cin>>v[i];
    
    int sigmaT = 0;
    rep(i,n)sigmaT+=t[i];

    vector<int> vn(sigmaT,INF);
    int pos = 0;
    rep(i,n){
        rep(j,t[i]){
            vn[pos++] = v[i];
        }
    }
    
    static int dp[20010][110];
    rep(i,20010)rep(j,110)dp[i][j] = -INF;
    
    dp[0][0] = 0;
    
    for(int i=1;i<=sigmaT;i++){
        rep(j,110){
            if(vn[i-1]<j || vn[i]<j)continue;
            if(vn[i-1]>=j+1){
                dp[i][j] = max<double>(dp[i][j],dp[i-1][j]+100*j+25);
            }
            else dp[i][j] = max<double>(dp[i][j],dp[i-1][j]+100*j);
            if(j-1>=0)dp[i][j] = max<double>(dp[i][j],dp[i-1][j-1]+100*j-50);
            if(j+1<110)dp[i][j] = max<double>(dp[i][j],dp[i-1][j+1]+100*j+50);
        }
    }
    printf("%.20lf\n",dp[sigmaT][0]/100.0);
}


Measured memory_bytes: 8960
'use strict'

const main = (input) => {
    input = input.split('\n').slice(0, 5)
    let tmpIndex = 0;
    let tmp = 9;
    input.forEach((item, index) => {
      const num = Number(item.slice(-1))
      if (num < tmp && num !== 0) {
        tmp = num
        tmpIndex = index
      }
    })

    // console.log(tmpIndex)
    // console.log(tmp)

    let sum = 0
    input.forEach((item, index) => {
      if (tmpIndex === index) {
        sum += Number(item)
      } else { 
        sum += Math.ceil(Number(item) / 10) * 10
      }
    })
    console.log(sum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 7372
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include <cassert>

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

constexpr int kMOD = 1000000007;
constexpr uint64_t kINF = 0xFFFFFFFFFFFFFFFF;

int main() {
    int N, P;
    cin >> N >> P;
    int count[2] = {0, 0};

    int tmp;
    rep(i, N) {
        cin >> tmp;
        count[tmp % 2]++;
    }

    uint64_t odds  = 0;
    uint64_t evens = 0;
    evens = 1ull << count[0];
    if(P == 0) {
        if(count[1] == 0) {
            odds = 1;
        } else {
            odds = 1ull << (uint64_t)(count[1]-1);
        }
    } else {
        // P = 1;
        
        if(count[1] < 2) {
            odds = 0;
        } else {
            odds = 1ull << (uint64_t)(count[1]-1);
        }
    }

    // cout << count[0] << " " << count[1] << endl;
    cout << (uint64_t)(odds) * (uint64_t)evens << endl;
    return 0;
}



Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[100];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(a[j]<a[j-1]){
	int tmp = a[j-1];
	a[j-1]=a[j];
	a[j]= tmp;
      }
    }
  }
  int ans=0;
  for(int i=n;1;i--){
    for(int j=0;j<n;j++){
      if(a[j]>=i && n-j>=i){
	ans=i;
	break;
      }
    }
    if(ans!=0) break;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
int in,a,b,c,d,ill[4];

void solve(int kekka,int count){
	
	if(count==1){
		int karians=0;
		int k[4]={kekka/1000,(kekka/100)%10,(kekka/10)%10,kekka%10};
		karians=ill[0];
		for(int i=1;i<4;i++){
			if(k[i-1])karians+=ill[i];
			else karians-=ill[i];
		}
		if(karians==7){
			for(int i=0;i<3;i++){cout<<ill[i];if(k[i])cout<<'+';else cout<<'-';}
			cout<<ill[3]<<"=7"<<endl;
			exit(0);
		}
		
	}
	else {solve(kekka*10+1,count-1);solve(kekka*10,count-1);}
	
}
int main(){
	cin>>in;
	ill[0]=in/1000;ill[1]=(in/100)%10;ill[2]=(in/10)%10;ill[3]=in%10;
	solve(1,4);
	solve(0,4);
	
}


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

int main() {
  int N, K, a=1;
  cin >> N >> K;
  
  for (int i=0; i<N; i++) {
    if (2*a <= (a+K)) {
      a = 2*a;
    }
    else {
      a = a+K;
    }
  }

  cout << a << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	long long int n;
	cin >> n;

	vector<long long int> a(n);
	long long int MAX = 0;
	for (long long int i = 0; i < n; i++) {
		cin >> a[i];
		MAX = max(MAX, a[i]);
	}
	long long int MAX2 = 0;
	for (long long int i = 0; i < n; i++) {
		if (a[i] != MAX) {
			long long int aa = MAX2;
			if (aa > MAX / 2) {
				aa = MAX - aa;
			}
			long long int bb = a[i];
			if (bb > MAX / 2) {
				bb = MAX - bb;
			}
			if (bb > aa) {
				MAX2 = a[i];
			}
		}
	}
	cout << MAX << ' ' << MAX2 << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int t;
string st;
int main()
{
	cin>>st;
	for (int i=0;i<st.size();i++)
	  {
	  	if (t==1&&st[i]=='F') {cout<<"Yes"; return 0;}
	  	  if (st[i]=='C') t=1;
	  }
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <sstream>
#include <string>

int main()
{
    std::stack<int> Stack;
    // while(std::cin.eof() == false){
    // while(std::cin){
    while(true){
        std::string in;
        std::cin >> in;
        if(!std::cin.good()){
            break;
        }
        switch(in[0]){
        case '+':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b + a);
            break;
        }
        case '-':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b - a);
            break;
        }
        case '*':{
            int a = Stack.top();
            Stack.pop();
            int b = Stack.top();
            Stack.pop();
            Stack.push(b * a);
            break;
        }
        default:{
            int Num;
            std::stringstream ss;
            ss << in;
            ss >> Num;
            Stack.push(Num);
            break;
        }
        }
    }
    std::cout << Stack.top() << std::endl;
    return 0;
}

Measured memory_bytes: 1228
s=list(input())
k=int(input())
al=list('abcdefghijklmnopqrstuvwxyz')
n=0
while k>0:
    if n==len(s)-1:k=k%26
    if 26-al.index(s[n])<=k and s[n]!='a':
        k-=26-al.index(s[n])
        s[n]='a'
        n=min(len(s)-1,n+1)
    else:
        if n<len(s)-1:n+=1
        else:
            s[n]=al[al.index(s[n])+k]
            k=0
print(''.join(s))

Measured memory_bytes: 4152
a, b, c , x = 4.times.map { gets.to_i }

count = 0

(0..a).each do |ai|
  (0..b).each do |bi|
    (0..c).each do |ci|
      if x == 500*ai + 100*bi + 50*ci
        count += 1
      end
    end
  end
end

puts count 

Measured memory_bytes: 1788
import java.util.Scanner

object Main {
  val sc = new Scanner(System.in)
  def main(args: Array[String]): Unit = {
    val b = sc.next
    val res = b.split("(?<=.)").map{ str =>
      str match{
        case "A" => "T"
        case "C" => "G"
        case "G" => "C"
        case "T" => "A"
      }
    }
    res.foreach(print)
    println

  }

}

Measured memory_bytes: 25668
n, a, b, c, d  = map(int, input().split())
s = input()
ans = 'Yes'
if '##' in s[a-1:max(c,d)]:
    ans = 'No'
else:
    if c > d and '...' not in s[b-2:d+1]:
        ans = 'No'
print(ans)

Measured memory_bytes: 3572
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        String S = sc.next();
        for (int i = 0; i < S.length(); i++) {
            System.out.print( S.substring( i, i+1 ).equals("1") ? "9" : "1" );
        }
        sc.close();
    }
}

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

string hand[15] = {"Rock", "Fire", "Scissors", "Snake",
                   "Human", "Tree", "Wolf", "Sponge", "Paper", "Air",
                   "Water", "Dragon", "Devil", "Lightning", "Gun" };

int main() {
    int n;
    string s;
    while(cin>>n, n) {
        vector<string> h;
        for(int i=0; i<n; ++i) {
            cin>>s;
            h.push_back(s);
        }

        string winner = "Draw";
        vector<int> idxs;
        for(int i=0; i<n; ++i) {
            string hh = h[i];
            int idx = 0;
            for(int j=0; j<15; ++j)
                if(hand[j] == hh) idx = j;

            idxs.push_back(idx);
        }

        vector<int> wins(n,0),lose(n,0);
        for(int i=0; i<n; ++i) {
            for(int j=i+1; j<n; ++j) {
                int ii = idxs[i],ij = idxs[j];
                if(ii == ij) continue;
                for(int k=1; k<=7; ++k)
                    if((ii+k)%15 == ij) {
                        wins[i]++;
                        lose[j]++;
                        goto NEXT;
                    }
                wins[j]++;
                lose[i]++;
            NEXT:;
            }
        }

        for(int i=0; i<n; ++i)
            if(lose[i] == 0 && wins[i] > 0) winner = h[i];
        cout<<winner<<endl;
    }
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    int n;
    cin>>n;
    vector<ll> s(5);
    rep(i,0,n){
        string str;
        cin>>str;
        if(str[0]=='M')s[0]++;
        else if(str[0]=='A')s[1]++;
        else if(str[0]=='R')s[2]++;
        else if(str[0]=='C')s[3]++;
        else if(str[0]=='H')s[4]++;
    }
    
    ll ans=0;
    rep(i,0,5){
        rep(j,i+1,5){
            rep(k,j+1,5){
                ans+=s[i]*s[j]*s[k];
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 9223372036854775807
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=1e5 ;
int main()
{
    fast ;
    ll n,m,k ; cin>>n>>m>>k ;
    vector<ll>a(n+1),b(m+1) ;

    a[0]=0 ;
    b[0]=0 ;

    for(ll i=1;i<=n;i++) {  cin>>a[i] ; a[i]+=a[i-1] ; }

    for(ll i=1;i<=m;i++) { cin>>b[i] ; b[i]+=b[i-1] ; }

    ll ans=0 ;

    for(ll i=0;i<=n;i++)
    {
        if(a[i]>k) break ;

        ll cur=i ;

        auto it=upper_bound(all(b),k-a[i]) ;
        it-- ;

        ans=max(ans,cur+(ll)(it-b.begin()))  ;
    }
    cout<<ans ;








}




Measured memory_bytes: 6372
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll


int main(){
    
   int n,m;
   int p[111111],y[111111];
   pair<int,int> p1[111111];
   map<int,int> p2;
   
   cin>>n>>m;
   for(int i=0;i<m;i++){
       cin>>p[i]>>y[i];
       p1[i].first=p[i];
       p1[i].second=y[i];
   }
   sort(p1,p1+m);
   int rank=0;
   for(int i=0;i<m;i++){
       rank++;
       p2[p1[i].second]=rank;
       if(p1[i].first!=p1[i+1].first)rank=0;
   }
   for(int i=0;i<m;i++){
       printf("%06d%06d\n",p[i],p2[y[i]]);
   }

}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;

int main()
{
    ll N;
    cin >> N;
    vll A(N), B;
    map<ll, ll> count;
    rep(i, N)
    {
        cin >> A[i];
        count[A[i]]++;
    }
    rep(i, N)
    {
        if (count[A[i]] >= 2)
        {
            B.push_back(A[i]);
            count[A[i]] -= 2;
        }
    }
    if (B.size() < 2)
    {
        cout << 0;
        return 0;
    }
    sort(all(B), greater<ll>());
    cout << B[0] * B[1];
    return 0;
}

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

void solve(std::string S, std::string T){
    ll ans = 0;
    for(ll i = 0; i < S.size(); ++i){
        if(S[i] != T[i]) ans++;
    }
    cout << ans << endl;
    return;
}

int main(){
    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    solve(S, T);
    return 0;
}


Measured memory_bytes: 4048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long LL;
int du[100010];
char map[810][810];
int x,y;
struct Node{
	int x,y;
	Node(int x_=0,int y_=0):x(x_),y(y_){}
};queue<Node> q;
int dis[810][810]={0};
int xx[] = {0,1,-1,0,0};
int yy[] = {0,0,0,1,-1};
bool vis[810][810]={0};
int main(){
	int N,M,K,ans = 0;
	scanf("%d%d%d",&N,&M,&K);
	for(int i = 1;i <= N;i++)scanf("%s",map[i]+1);
	for(int i = 1;i <= N;i++){
		for(int j = 1;j <= M;j++)if(map[i][j] == 'S'){
			if(i == N||j == M)ans = 0;
			else ans = 1;
			x = i;
			y = j;
			break;
		}
	}
	memset(dis,0x3f,sizeof dis);
	q.push(Node(x,y));dis[x][y] = 0;
	while(!q.empty()){
		Node D = q.front();q.pop();
		for(int i = 1;i <= 4;i++){
			x = D.x+xx[i];y = D.y+yy[i];
			if(x>N||y>M||x<1||y<1||map[x][y] == '#')continue;
			if(dis[x][y] != 0x3f3f3f3f)continue;
			dis[x][y] = dis[D.x][D.y]+1;
			q.push(Node(x,y));
		}
	}
	int rr = 0,rrr = 0,rrrr = 0x3f3f3f3f;
	for(int i = 1;i <= N;i++){
		for(int j = 1;j <= M;j++){
			if(dis[i][j] > K)continue;
			int tmp = i-1;
			tmp = min(j-1,tmp);
			tmp = min(N-i,tmp);
			tmp = min(M-j,tmp);
			rrrr = min(tmp,rrrr);
		}
	}
	if(rrrr % K == 0)ans += rrrr/K;
	else ans += rrrr/K+1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3712
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n, 0);
    ll tmp;
    ll ans = 0;
    for(int i=0;i<n;++i)
    {
        cin >> a[i];
    }

    for(int i=40;i>=0;--i){
        //dump(i)
        ll mask = 1ll << i;
        int bit = 0;
        if(mask > k)
        {
            // can't use k
            bit = 0;
            int count_ones = 0;
            for(int j=0;j<n;++j)
            {
                if ((a[j] & (1ll << i)) != 0)
                {
                    count_ones++;
                }
            }
            ans += count_ones * (1ll << i);
        }
        else
        {
            int count_zeros = 0;
            int count_ones = 0;
            for(int j=0;j<n;++j)
            {
                if ((a[j] & (1ll << i)) != 0)
                {
                    count_ones++;
                }
                else
                {
                    count_zeros++;
                }
            }
            if(count_ones > count_zeros)
            {
                bit = 0;
                ans += count_ones * (1ll << i);
            }
            else
            {
                bit = 1;
                ans += count_zeros * (1ll << i);
            }
            
            if (bit == 1)
            {
                k -= (1ll << i);
                //dump(k);
            }
        }
        //dump(ans);
    }
    cout << ans << endl;
}

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

void writeBorder(int w){
 for (int i = w+1; i >= 0; i--)
    {
        cout <<"#";
    }
    cout <<endl;
}
int main(){

    int h,w;
    cin >> h >> w;

    vector<string> vec(100);

    for (int i = 0; i < h; i++)
    {
        cin >> vec.at(i);
    }
    writeBorder(w);
    for (int i =  0; i <h ; i++)
    {
        cout << "#"<<vec.at(i)<<"#"<<endl;
    }
    
    writeBorder(w);
    
        

    
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val left = n / 100
    val right = n % 100
    if (left in 1..12 && right in 1..12){
        println("AMBIGUOUS")
    }
    else if (left in 1 .. 12){
        println("MMYY")
    }
    else if (right in 1 .. 12){
        println("YYMM")
    }
    else{
        println("NA")
    }
}


Measured memory_bytes: 31616