akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

VS decomp(string s){
  int h = 1, w = 0;
  int n = SZ(s);
  for(int i=0;i<n;++i) if(s[i] == '/') ++h;
  for(int i=0;i<n&&s[i]!='/';++i){
	if(s[i] == 'b') ++w;
	else w += s[i] - '0';
  }

  VS res(h, string(w, '.'));
  int y = 0, x = 0;
  for(int i=0;i<n;++i){
	if(s[i] == '/'){
	  ++y;
	  x = 0;
	}
	else if(s[i] == 'b'){
	  res[y][x++] = 'b';
	}
	else{
	  x += s[i] - '0';
	}
  }
  return res;
}
string comp(VS& vs){
  int h = SZ(vs);
  int w = SZ(vs[0]);
  string res;
  for(int y=0;y<h;++y){
	int acc = 0;
	for(int x=0;x<w;++x){
	  if(vs[y][x] == '.') ++acc;
	  else{
		if(acc) res += to_string(acc);
		res += "b";
		acc = 0;
	  }
	}
	if(acc)
	  res += to_string(acc);
	if(y < h-1) res += "/";
  }
  return res;
}

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

  string S;
  while(cin>>S,S!="#"){
	int sx, sy, tx, ty;
	cin >> sy >> sx >> ty >> tx;
	--sy;
	--sx;
	--ty;
	--tx;
	VS vs = decomp(S);
	vs[sy][sx] = '.';
	vs[ty][tx] = 'b';
	cout << comp(vs) << endl;
  }

  return 0;
}

Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define lson rt<<1, l, mid
#define rson rt<<1|1, mid+1, r
#define lowbit(x) x & (-x)
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
template<class T>
void read(T &res) {
  int f = 1; res = 0;
  char c = getchar();
  while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); }
  while(c >= '0' && c <= '9') { res = res * 10 + c - '0'; c = getchar(); }
  res *= f;
}
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b + c >= 22) cout << "bust" << endl;
  else cout << "win" << endl; 
}

Measured memory_bytes: 256
#define DEBUG 1
#include <bits/stdc++.h>
#define loop(n) for (lint ngtkana_is_a_genius = 0; ngtkana_is_a_genius < lint(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (lint i = lint(begin); (i) < lint(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto&& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto&& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#if DEBUG
#define debug(...)\
    do {\
        std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        std::cerr << std::noboolalpha;\
    } while (false)
#else
#define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(0); std::cin.sync_with_stdio(false);
    lint n, k; std::cin >> n >> k;
    std::vector<lint>a(n);
    std::cin>>a;
    a.insert(a.begin(),0);
    std::partial_sum(all(a),a.begin());
    lint max=0;
    for(lint i=0;i<=n-k;i++){
        cmx(max,a.at(i+k)-a.at(i));
    }
    std::cout << std::setprecision(10) << (double)(max+k)/2 << std::endl;
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m; cin >> n >> m;
  vii jobs(n);

  rep(i,n) {

    int a,b; cin >> a >> b;
    jobs[i] = ii(a,b);
  }
  sort(jobs.begin(), jobs.end(), [](ii a, ii b) {return a.first < b.first;});

  priority_queue<int> candidates;
  int idx = 0;
  ll money = 0;
  for (int day = 1; day <= m; day++) {
    while (idx < n && jobs[idx].first <= day) {
      candidates.push(jobs[idx++].second);
    }
    if (candidates.size()) {
      money += candidates.top(); candidates.pop(); 
    }
  }
  cout << money << endl;
  return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;

ll MAX = 1e18;//10^18

int  main()
{
	int n; cin >> n;
	vector<ll>  a(n);
	cpp_int sum = 1;
	rep(i, n)
	{
		cin >> a[i];
		if (a[i] == 0)
		{
			cout << 0 << endl;
			return 0;
		}
	}
	rep(i, n)
	{
		sum *= a[i];
		if ( sum > 1000000000000000000)
		{
			cout << -1 << endl;;
			return 0;
		}
		
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 4108
#include<stdio.h>
int main(){
int a[3000];
int b[3000];
int c=0,d=0,e,f=0;
while(f==0){
scanf("%d %d\n",&a[c],&b[d]);
if(a[c]==0 && b[d]==0){
c=c-1;
d=d-1;
break;
}
else if(a[c]>b[d]){
e=a[c];
a[c]=b[d];
b[d]=e;
c++;
d++;
}
else{
c++;
d++;
}
}
while(f<=c){
printf("%d %d\n",a[f],b[f]);
f++;
}
return 0;
}


Measured memory_bytes: 2064
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int A = sc.nextInt();
      
      if(X<A){
        System.out.println(0);
      }else{
        System.out.println(10);
      }
    }
}

Measured memory_bytes: 23764
#include <iostream>
    #include <algorithm>
    #include <vector>
    #include <cstdio>
    #include <bits/stdc++.h>
    #include <unordered_map>
    #include <unordered_set>
    #include <queue>
     
    #define pb push_back
         
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<ll, ll> pll;
         
    bool debug = false;
         
     
    struct state
    {
        ll a,b,c;
     
        state(ll a, ll b, ll c) : a(a), b(b), c(c)
        {
     
        }
     
      bool operator==(const state &other) const
      { return (a == other.a
                && b == other.b
                && c == other.c);
      }
    };
     
     
    struct KeyHasher
    {
        size_t operator()(const state& k) const
      {
        //using std::size_t;
        //using std::hash;
        //using std::string;
     
        return ((hash<ll>()(k.a)
                   ^ (hash<ll>()(k.b) << 1)) >> 1)
                   ^ (hash<ll>()(k.c) << 1);
      }
    };  
     
     
    void solve(ll casen)
    {
        ll res = 0;
        
        cout << "Case #" << casen << ": " << res << endl;
    }
     
    ll findN(ll x)
    {
        ll q = 1;
     
        while ( (q*(1+q))/2 <= x ) q++;
        q--;
        return q;
    }
     
    double median(ll n, vector<ll> &x)
    {
        // assuming x is sorted
     
        if (n % 2 == 1)
        {
            return (double)x[(n+1)/2];
        }
     
        return ((double)x[n/2] + x[(n/2) + 1])/2.0;
    }
     
    int main()
    {
        // $ g++ -std=c++14 -Wshadow -Wall -o c C.cpp
     
        // !!! Here, unordered map was too slow!!!
        std::ios::sync_with_stdio(false);
        cin.tie(NULL);
        
       ll n;
       ll res;
       cin >> n;
     
       vector<ll> a(n+1, 0);
       vector<ll> b(n+1, 0);
     
       for (int i = 0; i < n; i++)
       {
            cin >> a[i] >> b[i];
       }
     
       sort(a.begin(), a.end());
       sort(b.begin(), b.end());
     
       double medianA = median(n, a);
       double medianB = median(n, b);
     
       
       if (n % 2 == 1)
       {
            res = (medianB - medianA) + 1;     
       }
       else
       {
            res = ((medianB - medianA) / 0.5) + 1;
       }
       
     
       
     
     
     
     
        cout << res << endl;
     
     
     
      
     
        return 0;
    }

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,ans = 0,a[200000];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		a[i] -= i;
	}
	sort(a,a + n);
	for(int i = 0;i < n;i++){
		ans += abs(a[i] - a[n / 2]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
  int a, b, i, ans;
  char op;

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



  return 0;
}



Measured memory_bytes: 2080
def main():
    N = int(input())
    H = [int(h) for h in input().split()]
    max_h = 0
    count = 0
    for i in range(N):
        if H[i] >= max_h:
            count += 1
        max_h = max(max_h, H[i])
    return count

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll dp[10001][10];
ll f(ll n,ll k)
{   
    //cout<<n<<" "<<k<<endl;
    if(k==-1 || k==10)
    return 0;
    else if(dp[n][k]!=-1)
    return dp[n][k];
    else if(n==0)
    return dp[n][k]=0;
    else if(n==1 && k!=0)
    {
        return dp[n][k]=1;
    }
    else if(n==1 && k==0)
    {
       return dp[n][k]=1;
    }
    
    else
    {
        dp[n][k]=f(n-1,k)+f(n-1,k+1)+f(n-1,k-1);
        return dp[n][k];
    }
}
ll cnt=0;
void  f1(ll cur,ll n,ll d,vector<ll> &ans)
{
  //  cout<<"cur "<<cur<<" "<<n<<" digit "<<n<<endl;
    cur=cur+d;
    if(n==1)
    {
        ans.pb(cur);
        cnt++;
    }
    else
    {
        if(d>=1 && d<=8)
        {
            f1(cur*10,n-1,d,ans);
        f1(cur*10,n-1,d+1,ans);
        f1(cur*10,n-1,d-1,ans);
        }
        else if(d==0)
        {
            f1(cur*10,n-1,d,ans);
            f1(cur*10,n-1,d+1,ans);
        }
        else if(d==9)
        {
            f1(cur*10,n-1,d,ans);
            f1(cur*10,n-1,d-1,ans);
        }
    }

}

int main()
{
    ll k;
    cin>>k;
 
vector<ll> ans;
 
 for(ll i=1;i<=11;i++)
 {
     for(ll j=1;j<=9;j++)
     f1(0,i,j,ans);
 }
 sort(ans.begin(),ans.end());
//for(ll i=0;i<36;i++)
//cout<<ans[i]<<endl;
cout<<ans[k-1]<<endl;

 return 0;
}

Measured memory_bytes: 10476
# 2019-11-18 17:34:23(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# import re
# import heapq
# import array
# from scipy.misc import comb # (default: exact=False)
# import numpy as np 


def main():
    n, s = sys.stdin.read().split()
    n = int(n)

    ans = 0
    i, j = 0, 1
    while j < n:
        t = s[i:j]
        if t in s[j:]:
            ans = max(ans, j - i)
            j += 1
        else:
            i += 1
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int keisan(int i){
  int wa = 0;
  while(i>0){
    wa += i%10;
    i /=10;
  }
  return wa;
}
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int sum = 0;
  for(int i=1;i<=n;i++){
   int wa = keisan(i);
    if(a<= wa && wa <=b) sum += i;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
fn func(input_str: &str) {
    let mut iter = input_str.split_whitespace();
    let s = iter.next().unwrap().chars();
    let k: u64 = iter.next().unwrap().parse().unwrap();
    let mut cnt = k;
    for c in s {
        if c == '1' {
            cnt -= 1;
        } else {
            cnt = 0;
        }
        if cnt == 0 {
            println!("{}", c);
            return;
        }
    }
}

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    func(&buf[..]);
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, m;

int dfs(int b, int x, vector<pair<int, int>>a, vector<int>&table) {
	table[x - 1] = 1;
	for (int i = 0;i < m;i++) {
		if (b == i) {
			continue;
		}
		if (a[i].first == x && table[a[i].second - 1] == 0) {
			dfs(b, a[i].second, a, table);
		}
		if (a[i].second == x && table[a[i].first - 1] == 0) {
			dfs(b, a[i].first, a, table);
		}
	}
	return 0;
}

int main() {
	cin >> n >> m;
	vector<pair<int, int>>a(m);
	for (int i = 0;i < m;i++) {
		cin >> a[i].first >> a[i].second;
	}
	int ans = 0;
	for (int i = 0;i < m;i++) {
		vector<int>table(n, 0);
		dfs(i, 1, a, table);
		for (int i = 0;i < n;i++) {
			if (table[i] == 0) {
				ans++;
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main(int argc, char const *argv[]) {
  int N, D, X;
  scanf("%d", &N);
  scanf("%d %d", &D, &X);
  int A[N];
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    X += (D - 1) / A[i] + 1;
  }
  printf("%d\n", X);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a[101][101];
	int p[101];
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>p[i-1]>>p[i];
	}
	for(int i=1;i<=n;i++)a[i][i]=0;
	for(int l=2;l<=n;l++){
		for(int i=1;i<=n-l+1;i++){
			int j=i+l-1;
			a[i][j]=(1<<21);
			for(int k=i;k<=j-1;k++){
				a[i][j]=min(a[i][j],a[i][k]+a[k+1][j]+p[i-1]*p[k]*p[j]);
			}
		}
	}
	cout<<a[1][n]<<endl;
	return 0;
} 


Measured memory_bytes: 3128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

const int N=2005;
const int MOD=998244353;

int n,jc[N],ny[N],f[N][N],s0[N],s1[N];
char str[N];

int C(int n,int m)
{
	return (LL)jc[n]*ny[m]%MOD*ny[n-m]%MOD;
}

int main()
{
	scanf("%s",str+1);
	n=strlen(str+1);
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
	for (int i=2;i<=n;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
	for (int i=1;i<=n;i++)
		if (str[i]=='0') s0[i]+=2;
		else if (str[i]=='1') s0[i]++,s1[i]++;
		else s1[i]+=2;
	for (int i=1;i<=n;i++) s0[i]+=s0[i-1],s1[i]+=s1[i-1];
	f[0][0]=1;
	for (int i=1;i<=n;i++)
		for (int j=0;j<=i;j++)
		{
			if (j>s0[i]||i-j>s1[i]) continue;
			f[i][j]=f[i-1][j];
			if (j) (f[i][j]+=f[i-1][j-1])%=MOD;
		}
	int ans=0;
	for (int i=0;i<=n;i++) (ans+=(LL)f[n][i]*C(n,s0[n]-i)%MOD)%=MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 15104
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#pragma endregion
#pragma endregion


int main() {
	int n; cin >> n;
	vector<int> a(n), b(n), c(n);
	for (int i = 0; i < n; i++) 
		cin >> a[i];
	for (int i = 0; i < n; i++) 
		cin >> b[i];
	for (int i = 0; i < n; i++) 
		cin >> c[i];
	vector<int> d(n);
	vector<int> e(n);
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());
	lint Finalans = 0;
	for (int i = 0; i < n; i++) {
		Finalans += (lower_bound(a.begin(), a.end(), b[i]) - a.begin()) * (n - (upper_bound(c.begin(),c.end(),b[i])-c.begin()));
	}
	printf("%lld\n", Finalans);

	return 0;
}

Measured memory_bytes: 5432
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

int main(){
	dhoom;
	int n;
	cin >> n;
	//string s[n];
	map< string , int > mp;
	for(int i = 0 ; i < n ;i++){
		string s;
		cin >> s;
		mp[s]++;
	}
	int ans = 0;
	set< string > st;
	for(auto it : mp){
		ans = max(ans, it.second);
	}
	for(auto it : mp ){
		if(it.second == ans)
			st.insert(it.first);
	}
	for(auto it : st)
		cout << it << endl;
	return 0;
}


Measured memory_bytes: 33280
#include <stdio.h>
void call(int n)
{
    int i = 1;
    int x;
 
    do {
        x = i;
        if (x % 3 == 0) {
            printf(" %d", i);
        }
        else {
            do {
                if (x % 10 == 3) {
                    printf(" %d", i);
                    x = 0;
                }
                else x /= 10;
            } while (x);
        }
    } while (++i <= n);
    putchar('\n');
}
 

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



Measured memory_bytes: 2044
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var S = new long[N + 1];
            for (int i = 0; i < N; i++) S[i + 1] = S[i] + A[i];
            var ans = 0L;
            Array.Sort(S);
            var idx = 0;
            while (idx < N + 1)
            {
                var cnt = 0;
                var num = S[idx];
                idx++;
                while (idx < N + 1 && num == S[idx])
                {
                    cnt++;
                    idx++;
                }
                while (cnt > 0)
                {
                    ans += cnt;
                    cnt--;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 34272
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define endl "\n"
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define th(n) cout<<n<<endl
#define gc getchar_unlocked
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
#define upper(s) transform(s.begin(),s.end(),s.begin(),::toupper)
#define lower(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define print(arr) for(auto el: arr) cout<<el<<" ";cout<<endl
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
#define formatrix(i,n) for(ll i=0;i<n;i++, cout<<"\n")
#define eof (scanf("%d" ,&n))!=EOF
// declaration shortcuts
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>> 
#define pll pair<ll,ll>
#define ppl pair<ll,pp>
#define ull unsigned long long
#define ll long long
#define mll map< ll, ll > 
#define sll set< ll > 
#define uni(v) 	v.erase(unique(v.begin(),v.end()),v.end());
#define ini(a, v)       memset(a, v, sizeof(a))
using namespace std;
int main(){
    
    ll n,m;
    cin>>n>>m;
    ll a[n][m];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
         cin>>a[i][j];
         
    }
    ll dist=0,ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++)
        {  dist=0;
            for(int k=0;k<m;k++)
            {
                dist+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
            }
    ll s=sqrt(dist);
    if(s*s==dist)
    ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
    int h, w, h0, w0;
    cin >> h >> w >> h0 >> w0;
    cout << (h-h0)*(w-w0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        char[] b = sc.next().toCharArray();
        char[] c = sc.next().toCharArray();

        boolean ab[] = new boolean[100000];
        boolean ac[] = new boolean[100000];
        boolean bc[] = new boolean[100000];

        for (int i = 0; i < 100000; i++) {
            ab[i] = true;
            ac[i] = true;
            bc[i] = true;
        }

        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < b.length; j++) {
                if (!match(a[i], b[j])) {
                    ab[i - j + 50000] = false;
                }
            }
        }
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < c.length; j++) {
                if (!match(a[i], c[j])) {
                    ac[i - j + 50000] = false;
                }
            }
        }
        for (int i = 0; i < b.length; i++) {
            for (int j = 0; j < c.length; j++) {
                if (!match(b[i], c[j])) {
                    bc[i - j + 50000] = false;
                }
            }
        }

        int min = 10000;
        for (int i = -4000; i < 4000; i++) {
            for (int j = -4000; j < 4000; j++) {
                if (ab[50000 + i] && ac[50000 + j] && bc[j-i+ 50000]) {
                    int L = Math.min(0, Math.min(i, j));
                    int R = Math.max(a.length, Math.max(i + b.length, j + c.length));
                    min = Math.min(min, R - L);
                }
            }
        }

        System.out.println(min);
    }

    static boolean match(char c1, char c2) {
        return (c1 == '?') || (c2 == '?') || (c1 == c2);
    }
}


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

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

typedef long long ll;

const int mod = 1e9 + 7;

using namespace std;



int main(void) {
	int N; cin >> N;
	int R = 0;
	vector<char> C(N);
	rep(i, N) {
		cin >> C[i];
		if (C[i] == 'R')R++;
	}

	int ans = 0;

	rep(i, N) {
		if (C[i] == 'R') {
			R--;
			continue;
		}

		for (int j = N - 1; j > i; j--) {
			if (C[j] == 'R') {
				C[j] = 'W';
				R--;
				ans++;
				break;
		}
			}
		if (R == 0)break;
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  // ll N, K; cin >> N >> K;
  // ll x, y, z; cin >> x >> y >> z;
  ll a, b; cin >> a >> b;
  // string s; cin >> s;
  vector<ll> p(N); rep(i, N) cin >> p[i];
  
  ll ans = 0;
  // bool ok = false;

  ll c1 = 0, c2 = 0, c3 = 0;
  rep(i, N) {
    if(p[i] <= a) c1++;
    else if(p[i] <= b) c2++;
    else c3++;
  }
  ans = min(min(c1,c2),c3);
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

// https://onlinejudge.u-aizu.ac.jp/problems/0005
// 正の整数 a,b を入力し、a と b の最大公約数と最小公倍数を出力するプログラムを作成して下さい。

// aとbの最大公約数を返す
int64_t euclid(int64_t a, int64_t b);

int main(){
	// 0 < a,b ≤ 2,000,000,000
	// a と b の最小公倍数は 2,000,000,000 を超えない。
	int64_t a, b;
	
	// 複数のデータセットが与えられる(入力の最後まで処理)
	while(cin>>a>>b){
		// 最大公約数（greatest common divisor）
		int64_t gcd = euclid(a,b);
		
		// 最小公倍数（least common multiple）
		// 　a×b/(aとbの最大公約数)で求まる。
		//  ただしa×bを先に計算するとオーバーフローする可能性があるので注意
		int64_t lcm = a/gcd * b;
		
		cout << gcd <<" "<< lcm <<endl;;
	}
}


// ユークリッドの互除法で最大公約数を求める
int64_t euclid(const int64_t a, const int64_t b){
	return a%b == 0 ? b : euclid(b, a%b);
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
// #include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
// using namespace atcoder;
void Main()
{
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];

    ll res = 0;
    rep(i, n) {
        if (p[i] == i + 1) {
            res++;
            if (0 <= i-1 && p[i-1] == i) {
                swap(p[i-1], p[i]);
                continue;
            }
            if (p[i+1] == i + 2) {
                swap(p[i+1], p[i]);
                continue;
            }
            if (0 <= i - 1) {
                swap(p[i-1], p[i]);
                continue;
            }
            swap(p[i+1], p[i]);
            continue;
        }
    }

    put(res);
}
signed main(){ Main();return 0;}

Measured memory_bytes: 3932
#include<stdio.h>

int srt(int a[],int n )
{
    int i,j ;
    for( i =0 ; i<n ; i++)
      {for(j=i+1 ; j<n ; j++)
    {
        if(a[j]<a[i])
        {
            int temp=a[j] ;
            a[j]=a[i] ;
            a[i]=temp ;
        }

    }
}




}


int main()
{
    int n,a,b,ara[565],i,j,k ;
    scanf("%d",&n) ;
  for(i=0 ; i<n ; i++)
    scanf("%d",&ara[i]) ;

  srt(ara,n) ;
 int count=0 ,p,r=1;

 if(n<3)count=0 ;
 else
 {
for(p=0 ; p<n-2 ; p++)
{
    for(r=1 ; r<n-1 ; r++)
    {
        for(k=1 ; p+r+k <n ; k++)
        {
             if(ara[p]!=ara[p+r] && ara[p+r]!=ara[p+r+k] && ara[p]+ara[p+r]>ara[p+r+k])
              count++ ;
        }

    }

}


 }


  printf("%d",count) ;

    return 0 ;
}


Measured memory_bytes: 1704
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mo=998244353,N=1e5+5;
int n,m,a,b,c,i,j,f[N][2],ans;
ll s;
unordered_map<int,int>mp[N];
inline int poww(int x,ll y){
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)ans=1ll*ans*x%mo;
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	s=1ll*(n-2)*(n-3)/2;
	for(i=1;i<=m;++i){
		scanf("%d%d%d",&a,&b,&c);
		if(abs(a-b)>2 && mp[b].count(a) && mp[b][a]!=c)break;
		mp[a][b]=c;s-=abs(a-b)>2 && !mp[b].count(a);
	}
	if(i<=m)return puts("0"),0;
	for(i=0;i<16;++i){
		if(mp[1].count(1) && mp[1][1]!=(i>>3&1))continue;
		if(mp[1].count(2) && mp[1][2]!=(i>>2&1))continue;
		if(mp[2].count(1) && mp[2][1]!=(i>>1&1))continue;
		if(mp[2].count(2) && mp[2][2]!=(i>>0&1))continue;
		for(j=a=0;j<4;++j)a^=i>>j&1;
		if(a)continue;
		f[2][i&1]++;
	}
	for(i=3;i<=n;++i)for(j=0;j<8;++j){
		if(mp[i-2].count(i) && mp[i].count(i-2) && (mp[i][i-2]^mp[i-2][i])!=(j>>2&1))continue;
		if(mp[i-1].count(i) && mp[i].count(i-1) && (mp[i][i-1]^mp[i-1][i])!=(j>>1&1))continue;
		if(mp[i].count(i) && mp[i][i]!=(j>>0&1))continue;
		int x=(j>>2&1)^(j>>1&1)^(j&1),y=(j>>1&1)^(j&1);
		if(x)continue;
		f[i][j&1]=(f[i][j&1]+1ll*f[i-1][y]*poww(2,(!mp[i-2].count(i)
			&& !mp[i].count(i-2))+(!mp[i-1].count(i) && !mp[i].count(i-1))))%mo;
	}
	//for(i=0;poww(2,s+i)!=342016343;++i);printf("%d\n",i);
	ans=1ll*(f[n][0]+f[n][1])*poww(2,s)%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define pii pair<int , int>
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const int INF = 1000 * 1000 * 1000 + 7;
const ll LINF = INF * (ll)INF;
const int mod = INF;
const int MAX = 1 << 25;

int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	if(sz(s) % 2)
	{
		cout << "No";
		return 0;
	}
	for(int i = 0; i < sz(s); i += 2)
	{
		if(s[i] != 'h' || s[i + 1] != 'i')
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, k;
	cin >> n >> k;

	vector<vector<int>> g(n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;

		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	int ans = 0;
	for (int i = 0; i < n; i++) {
		queue<pair<int, int>> que;
		que.emplace(i, 0);
		if (k & 1) {
			que.emplace(g[i][0], 0);
		}

		vector<bool> used(n);
		int score = 0;
		while (!que.empty()) {
			int now = que.front().first;
			int cost = que.front().second;
			que.pop();

			if (used[now] || cost > k / 2) {
				continue;
			}

			used[now] = true;
			score++;

			for (auto next : g[now]) {
				que.emplace(next, cost + 1);
			}
		}
		ans = max(ans, score);
	}
	ans = n - ans;

	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
  int n;
  cin>>n;
  vector<vector<int>> arr(n,vector<int>(3));
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>arr[i][j];
    }
  }
  vector<vector<int>> dp(n,vector<int>(3));
  int pmax=0,smax=0;
  for(int i=n-1;i>=0;i--){
    for(int j=2;j>=0;j--){
      if(i==n-1){
        dp[i][j]=arr[i][j];
      }
      else{
        if(dp[i+1][j]!=pmax) dp[i][j]=arr[i][j]+pmax;
        else dp[i][j]=arr[i][j]+smax;
      }
    }
      for(int k=0;k<3;k++){
        if(dp[i][k]>pmax){
          smax=pmax;
          pmax=dp[i][k];
        }
        else if(dp[i][k]>smax){
          smax=dp[i][k];
        }
      }
  }
  int ans=0;
  for(int i=0;i<3;i++){
    if(dp[0][i]>ans){
    	ans=dp[0][i];
    }
  }
  cout<<ans<<"\n";
}


Measured memory_bytes: 11136
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)
T=[]
for i in range(D):
    T.append(int(input()))

last=[-1]*26
v=0
for d in range(D):
    v+=s[d][T[d]-1]
    last[T[d]-1]=d
    for i in range(26):
        v-=c[i]*(d-last[i])
    print(v)

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

// one-based numbering
struct UnionFind {
    vector<int> data;
    // i: (data[i] < 0) -> group size, (data[i] > 0) -> parent;
    UnionFind(int n) {
        data.resize(n+1, -1);
    }
    int find(int x) {
        if(data[x] < 0) return x;
        else return data[x] = find(data[x]);
    }
    int size(int x) {
        return -data[find(x)];
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if(x == y) return false;
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return true;
    }
    bool same(int x, int y) {
        x = find(x); y = find(y);
        return x == y;
    }
};

bool V[9100000][2];

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

    int N, M; cin >> N >> M;
    vector<long long> A(N), B(N), C(N), D(M), E(M), F(M);
    vector<long long> X, Y;

    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i] >> C[i];
        X.emplace_back(A[i]);
        X.emplace_back(B[i]);
        Y.emplace_back(C[i]);
    }
    for (int i = 0; i < M; i++) {
        cin >> D[i] >> E[i] >> F[i];
        X.emplace_back(D[i]);
        Y.emplace_back(E[i]);
        Y.emplace_back(F[i]);
    }

    sort(X.begin(), X.end());
    X.erase(unique(X.begin(), X.end()), X.end());
    sort(Y.begin(), Y.end());
    Y.erase(unique(Y.begin(), Y.end()), Y.end());

    int Xs = X.size(), Ys = Y.size();
    auto encode = [&](int i, int j) { return i * (Ys+1) + j + 1; }; 

    for (int i = 0; i < N; i++) {
        int a = A[i], b = B[i], c = C[i];
        int xl = lower_bound(X.begin(), X.end(), a) - X.begin();
        int xr = lower_bound(X.begin(), X.end(), b) - X.begin();
        int y = lower_bound(Y.begin(), Y.end(), c) - Y.begin();
        for (int x = xl+1; x <= xr; x++) {
            V[encode(x, y)][0] = true;
        }
    }
    for (int i = 0; i < M; i++) {
        int d = D[i], e = E[i], f = F[i];
        int x = lower_bound(X.begin(), X.end(), d) - X.begin();
        int yl = lower_bound(Y.begin(), Y.end(), e) - Y.begin();
        int yr = lower_bound(Y.begin(), Y.end(), f) - Y.begin();
        for (int y = yl+1; y <= yr; y++) {
            V[encode(x, y)][1] = true;
        }
    }

    UnionFind uf((Xs+1)*(Ys+1));

    for (int i = 0; i < Xs; i++) {
        for (int j = 0; j < Ys; j++) {
            int cur = encode(i, j);
            int s = encode(i+1, j);
            int t = encode(i, j+1);
            if (!V[cur][0]) uf.unite(cur, t);
            if (!V[cur][1]) uf.unite(cur, s);
        }
    }

    int xz = lower_bound(X.begin(), X.end(), 0LL) - X.begin();
    int yz = lower_bound(Y.begin(), Y.end(), 0LL) - Y.begin();
    int Z = encode(xz, yz);

    long long ans = 0;
    for (int i = 0; i <= Xs; i++) {
        for (int j = 0; j <= Ys; j++) {
            int cur = encode(i, j);
            if (!uf.same(cur, Z)) continue;
            if (i == 0 || j == 0 || i == Xs || j == Ys) {
                cout << "INF\n";
                return 0;
            }
            ans += (X[i] - X[i-1]) * (Y[j] - Y[j-1]);
        }
    }

    cout << ans << "\n";

    return 0;
}

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

#define lli long long int
#define ld long double
#define DEFO(n) lli n = 0;
#define MAX_L lli max = 9000000000000000000;
#define MIN_L lli min = 9000000000000000000;
#define MAX_D ld max = 4500;
#define MIN_D ld min = -4500;
#define LLI(n) \
  lli n;       \
  cin >> n;
#define LD(n) \
  ld n;       \
  cin > n;
#define LLIV(a, n)            \
  vector<lli> a(n);           \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define LLIV2(a, b, n)         \
  vector<lli> a(n), b(n);      \
  for (lli i = 0; i < n; i++)  \
  {                            \
    cin >> a.at(i) >> b.at(i); \
  };
#define LDV(a, n)             \
  vector<ld> a(n);            \
  for (lli i = 0; i < n; i++) \
  {                           \
    cin >> a.at(i);           \
  };
#define STR(n) \
  string n;    \
  cin >> n;
#define SUM(n) accumulate(n.begin(), n.end(), 0);
#define SORT(n) sort(n.begin(), n.end());
#define REVE(n) reverse(n.begin(), n.end());
#define yes              \
  cout << "Yes" << endl; \
  return 0;
#define no              \
  cout << "No" << endl; \
  return 0;
#define none            \
  cout << "None" << endl; \
  return 0;
#define C45(n) (n + 1) / 2
#define OUT(n) cout << n << endl;
#define SRC(n, c)                    \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    if (s.at(i) == c)                \
    {                                \
      n++;                           \
    }                                \
  };
//こぴー
/*#define ZISYO(s, S)                  \
  for (lli i = 0; i < s.size(); i++) \
  {                                  \
    S.at(i) = s.at(i);               \
  }                                  \
  Sort(S) Reve(S) for (lli i = 0; i < s.size(); i++) { s.at(i) = S.at(i); };
*/

//素数
bool IsPrime(lli num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  long double sqrtNum = sqrt(num);
  for (lli i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}
//各桁の和
lli KSum(lli n)
{
  lli sum = 0;
  if (n < 0)
    return 0;
  while (n > 0)
  {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

//数値反転
bool KReve(lli n)
{
  int reverse = 0;
  int remaind;
  int tmp = n;
  while (tmp != 0)
  {
    remaind = tmp % 10;
    reverse = reverse * 10 + remaind;
    tmp /= 10;
  }
  if (reverse == n)
    return true;
  else
    return false;
}

int main(void)
{
  ios::sync_with_stdio(false);
  STR(s) map<char, int> word;
  for(lli i  = 0;i < s.size();i++) {
    if(word.count(s[i])) {}
    else {
      word[s[i]] = 1;
    }
  }
  for(lli i = 'a';i <= 'z';i++) {
    if (word.count(i)) {}
    else {
      OUT((char)i)
      return 0;
    }
  }
  none
}


Measured memory_bytes: 512
#include <stdio.h>

#define LENGTH 25000

int mennseki(char *A,int l,int p,int q) {
	int h = 0,i;
	double a =0;

	for(i = p; i < q; i++) {
		if(A[i] == '/') {
			a += (double)h - 0.5;
			h--;
		} else if (A[i] == '\\') {
			a +=(double)h + 0.5;
			h++;
		} else if(A[i] =='_') {
			a += h;
		}
	}
	return a;
  }

int main() {
	char A[LENGTH];
	int i,l,dis;
	int sum=0,num=0,alt=0,j=0;
    int height[LENGTH] = {0};
	int width[LENGTH] = {0};
	scanf("%s",A);

	for(l = 0; ; l++) {
		height[l] = alt;
		if(A[l] =='/') {
			alt++;
		} else if(A[l] == '\\') {
			alt--;
		} else if(A[l] == '\0') {
			break;
		}
	}


	while(num < l) {
		while(A[num] != '\\' && num < l) {
			num++;
		}
		dis= num + 1;
		while(dis <= l && height[dis] != height[num]) {
			dis++;
		}
    if(dis <= l) {
			width[j++] = mennseki(A,l,num,dis);
			num = dis;
		} else {
			num++;
		}
	}

	for(i = 0; i <j; i++) {
		sum += width[i];
	}


	printf("%d\n%d", sum, j);

  for(i = 0; i < j; i++){
    printf(" %d", width[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define deb(x) cout<<#x<<" " <<x<<"\n";
#define pi 3.1415926535897932384626433832795
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define cr7 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define forr(i, n) for(ll i = 0;i < n; ++i)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define test ll testcase; cin>>testcase; while(testcase--)
#define time printf("\n\nTime taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC)
int main()
{
	//clock_t tStart = clock();
	cr7
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif
	string t;
	cin >> t;
	forr(i, t.length()) {
		if (t[i] == '?')
			t[i] = 'D';
	}
	cout << t << "\n";
	return 0;
}


Measured memory_bytes: 3752
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		char[] s=sc.next().toCharArray();
		long k=sc.nextLong();
		long count=0;
		int cc=0;
		boolean t=false;
		for(int i=0; i<s.length; i++){
			if(s[i]==s[0]){
				cc++;
			}else{
				break;
			}
		}
		for(int i=0; i<s.length-1; i++){
			if(s[i]==s[i+1]){
				count++;
				s[i+1]='1';
			}
		}
		long ii=0;
		if(s[s.length-1]==s[0]){
			ii++;
			if(cc>0 && cc%2==0){
				ii--;
			}
		}
		if(s.length==1){
			System.out.println(k/2);
			return;
		}
		if(cc==s.length){
			System.out.println((k*s.length)/2);
			return;
		}
		System.out.println(count*k+(ii)*(k-1));
	}
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main(){
    int n, t;
    cin >> n >> t;
    vector<int> a(n);
    long long ans = 0;
    for(int i = 1; i <= n; i++) {
        cin >> a[i];
        if(a[i] - a[i-1] > t){
            ans += t;
        }
        else{
            ans += (long long) a[i] - a[i-1];
        }
    }
    ans += t;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import floyd_warshall
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M, V, P = MAP()
P -= 1
A = LIST()
A.sort(reverse=True)

def judge(x):
    if x <= P:
        return True
    elif A[x]+M < A[P]:
        return False
    cap = 0
    for i in range(N):
        if i < P or i >= x+1:
            cap += M
        else:
            cap += A[x]+M-A[i]
    return cap >= M*V

l = 0
r = N

while l+1 != r:
    m = (l+r)//2

    if judge(m):
        l = m
    else:
        r = m
print(l+1)


Measured memory_bytes: 26160
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    A, B, H, M = map(int, input().split())
    
    theta_a = math.radians(360) * (H / 12 + M / (12 * 60))
    theta_b = math.radians(360) * (M / 60)

    theta = abs(theta_a - theta_b)
    theta = min(theta, 2 * math.pi - theta)
    C = math.sqrt(A * A + B * B - (2 * A * B * math.cos(theta)))
    print(C)


if __name__ == '__main__':
    main()

Measured memory_bytes: 73256
#include <iostream>
using namespace std;
#define int long long int
int twos(int a)
{
    int ans = 0;
    ;
    while (a % 2 == 0)
    {
        ans++;
        a /= 2;
    }
    return ans;
}
signed main()
{
    int n, a, ans = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a;
        ans += twos(a);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3188