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

struct UnionFind {
  vector<int> par;
  vector<int> sizes;

  UnionFind(int N) : par(N), sizes(N, 1) {
    for (int i = 0; i < N; i++) par.at(i) = i;
  }

  int find(int x) {
    if (par.at(x) == x) return x;
    return par.at(x) = find(par.at(x));
  }

  void unite(int x, int y) {
    int rx = find(x);
    int ry = find(y);
    if (rx == ry) return;
    if (sizes.at(rx) < sizes.at(ry)) swap(rx, ry);
    par.at(ry) = rx;
    sizes.at(rx) += sizes.at(ry);
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sizes.at(find(x)); }

  int num_of_connected_components() {
    int ret = 0;
    for (int i = 0; i < par.size(); i++) {
      if (find(i) == i) ret++;
    }
    return ret;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> x(n), y(n);
  REP(i, n) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
  }
  ll m = 2e5;
  UnionFind uf(m);
  map<ll, ll> cntEdge, cntX;
  REP(i, n) {
    uf.unite(x[i], y[i] + 1e5);
    ll p = uf.find(x[i]);
    cntEdge[p]++;
  }

  ll ans = 0;
  REP(i, 1e5) { cntX[uf.find(i)]++; }
  for (auto& pa : cntEdge) {
    ll p = pa.first, c = pa.second;
    ans += cntX[p] * (uf.size(p) - cntX[p]) - c;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

int main(int argc, char const *argv[]) {
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll ans = 0ll;
    for (int l = 0; l <= k; ++l) {
        for (int r = 0; r <= k-l; ++r) {
            if (l+r > n) continue;
            int d = max(0,k-l-r);
            ll now = 0ll;
            vector<ll> tmp;
            for (int i = 0; i < l; ++i) {
                now += a[i];
                tmp.push_back(a[i]);
            }
            for (int i = n-r; i < n; ++i) {
                now += a[i];
                tmp.push_back(a[i]);
            }
            sort(tmp.begin(), tmp.end());
            for (int i = 0; i < d; ++i) {
                if (i >= tmp.size()) break;
                if (tmp[i] > 0) break;
                now -= tmp[i];
            }
            ans = max(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
mod = 10**9+7
h,w = map(int,input().split())
grid = [[l == "#" for l in list(input())] for _ in range(h)]
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for s in range(1,h+w):
  for i in range(max(0,s-w+1),min(h,s+1)):
    j = s-i
    if grid[i][j]:
      continue
    if i == 0:
      dp[i][j] = dp[i][j-1]
    elif j == 0:
      dp[i][j] = dp[i-1][j]
    else:
      dp[i][j] = (dp[i][j-1]+dp[i-1][j])%mod
print(dp[-1][-1]%mod)

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	int count = 0;
	for (int i = 100;; i--) {
		if (a % i == 0 && b % i == 0) {
			count++;
			if (count == k) {
				cout << i << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define start() ll z;scanf("%d",&z);while(z--)
#define fo(var, start, end) for(var = start; var < end; var++)
#define foo(var, start, end) for(var = start; var < = end; var++)
#define fi(var, end, start) for(var = end; var >=start ; var--)
using namespace std;
void solve(){
}
int main() {
//    start(){
//        solve();
//    }
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    while (true)
    {
        c-=b;
        if(c<=0)
        {
            printf("Yes");
            break;
        }
        a-=d;
        if(a<=0)
        {
            printf("No");
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3192
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int iinf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 3; i++)
		if (s[i] == '1')
			sum++;
	cout << sum << endl;
	getchar(); getchar();
}

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

using namespace std;

#define DEBUG(...) fprintf(stderr,__VA_ARGS__)

#define rep(i , l , r) for(int i = (l) , ___ = (r) ; i <= ___ ; ++i )
#define per(i , r , l) for(int i = (r) , ___ = (l) ; i >= ___ ; --i )

// using LL = long long;
// using uLL = unsigned long long;
typedef long long LL;
typedef unsigned long long uLL;

const int Mod = 998244353; 

template<typename T>inline bool chkmin(T &x , const T &y) { return x > y ? (x = y , 1) : 0; }
template<typename T>inline bool chkmax(T &x , const T &y) { return x < y ? (x = y , 1) : 0; }

template<typename T>inline T sq(const T &x) { return x * x; }
template<typename T>inline T add(T x , const T &y) { x += y; return x > Mod ? x - Mod : x; }
template<typename T>inline T sub(T x , const T &y) { x -= y; return x < 0 ? x + Mod : x;}
template<typename T>inline T mul(const T &x , const T &y) { return 1ll * x * y % Mod; }

template<typename T>inline T read(T &f)
{
    f = 0; int x = 1 ; char c = getchar();
    while(!isdigit(c)) x = (c == '-' ? -1 : 1) , c = getchar();
    while(isdigit(c)) (f *= 10) += c & 15 , c = getchar();
    return f = x * f;
}
// template<typename T , typename ... Args>inline void read(T &x , Args&& ... y) { read(x) , read(y...); }

const int N = 100000 + 5;

int n , L , T , A[N] , W[N] , v[N];

int main()
{
    read(n) , read(L) , read(T);
    rep(i , 0 , n-1) read(A[i]) , read(W[i]);
    rep(i , 0 , n-1)
    {
        if(W[i] == 1) v[i] = (A[i] + T) % L;
        if(W[i] == 2) v[i] = (A[i] - T) % L , v[i] = (v[i] + L) % L;
    }
    int x = v[0] , p;
    sort(v , v + n);
    if(W[0] == 1)
    {
        rep(i , 0 , n-1) if(v[i] == x)
        {
            p = i ; break ;
        }
    }
    else
    {
        per(i , n-1 , 0) if(v[i] == x)
        {
            p = i ; break ;
        }
    }
    int R1 = 0 , R2 = 0;
    rep(i , 1 , n-1)
    {
        if(W[i] == W[0]) continue ;
        R1 += 2;
        int dis = A[i] - A[0];
        if(W[0] == 2) dis = L - dis;
        if(dis < T % L * 2) R2++;
        if(dis < T % L * 2 - L) R2++;
    }
    int t = R1 * (T / L) + R2; t %= n;
    if(W[0] == 2) t = (n - t) % n;
    rep(i , 0 , n-1) printf("%d\n" , v[(i + p - t + n) % n]);
    return 0;
}


Measured memory_bytes: 2304
import Data.List
main = getLine >> getLine >>= print . solve . fmap read . words

solve :: [Int] -> Int
solve = count (1, mempty)
    where
        count (n, b) (x : y : zs)
            | b /= mempty && c /= mempty && b /= c = count (n + 1, mempty) (y : zs)
            | otherwise = count (n, b `mappend` c) (y : zs)
            where
                c = compare x y
        count (n, _) _ = n


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
long long n,k,i,j,a[100001],f[100001];
int main()
    {
        cin>>n>>k;
        for (i=1;i<=n;i++)
        {
            cin>>a[i];
            f[i]=10E9;
        }
        f[2]=abs(a[1]-a[2]);
        for (i=1;i<=n;i++)
            for (j=1;j<=k;j++)
            {
                if (i-j<=0) break;
                if (f[i-j]==10E9) f[i-j]=0;
                f[i]=min(f[i-j]+abs(a[i]-a[i-j]),f[i]);
            }
        cout<<f[n];
        return 0;
    }


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;



signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    int ans = 0;
    ForE(i, k, n + 1){
        int mn = (i - 1) * i / 2, mx = (2 * n - i + 1) * i / 2;
        ans += mx - mn + 1;
        ans %= mod;
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3608
a = int(input())
b = int(input())
c = int(input())

x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            temp = i * 500 + j * 100 + k * 50
            if temp == x:
                ans += 1

print(ans)


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

int main() {
  int n;
  while(cin >> n) {
    int num = (n-1) % 39 + 1;
    if(num < 10) cout << "3C0" << num << endl;
    else         cout << "3C" <<  num << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
#define EPS (1e-10)
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int h,w; cin>>h>>w;
	rep(i,h)rep(j,w){
		string s; cin>>s;
		if(s=="snuke"){
			char c='A'+j;
			// char r='1'+i;
			cout<<c<<i+1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc131/tasks/abc131_b
import math
inp = input().split()

n = int(inp[0])
l = int(inp[1])

min_abs = abs(l)
min_num = 0
for i in range(n):
    if abs(l+i) < min_abs:
        min_abs = abs(l+i)
        min_num = i


print(math.ceil(0.5*n*n + n*l - 0.5*n - l - min_num ))





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

int main(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> S(M, vector<int>(N,0));
    for (int i=0; i<M; i++){
        int k;
        cin >> k;
        for(int j=0; j<k; j++){
            int s;
            cin >> s;
            S.at(i).at(s-1) = 1;
        }
    }
    vector<int> p(M);
    for(int i=0; i<M; i++){
        cin >> p.at(i);
    }
    int ans=0;
    for(int bit=0; bit<(1<<N); bit++){
        vector<int> switches(N,0);
        for(int i=0; i<N; i++){
            if(bit & (1<<i)){
                switches.at(i) = 1;
            }
        }
        bool lights_on = true;
        for(int i=0; i<M; i++){
            // i番目の電球
            int check = 0;
            for(int j=0; j<N; j++){
                // j番目のスイッチ
                check += S.at(i).at(j) * switches.at(j);
            }
            if(check%2 != p.at(i)){
                lights_on = false;
                break;
            }
        }
        if(lights_on){
            ans++;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3648
S = [int(x) if x != '?' else - 1 for x in input()]
le=len(S)

dp = [[0]*13 for i in range(le+1)]
dp[0][0] = 1

i=0
for k in S:
    if k==-1:
        for s in range(10):
            for j in range(13):
                dp[i + 1][(s + j*10) % 13] += dp[i][j]%(10**9+7)

    else:
        k=int(k)
        for j in range(13):
            dp[i + 1][(j *10 + k) % 13] += dp[i][j]%(10**9+7)
        
    i += 1


print(dp[le][5]%(10**9+7))


Measured memory_bytes: 63776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a%=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}

//#define sz(x) int((x).size())                                           
// lcm = a*(b/gcd) least common multiple                                  
// gcd: greatest common divisor                                           
//
map< ll, ll> prime_factor(ll n) {
  map< ll, ll > ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


ll gcd(ll a, ll b) {
  if(a < b) gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  map<ll,ll> tot;
  set<ll> st;
  rep(i,n){
    auto tmap = prime_factor(a[i]);
    for(auto j:tmap){
      st.insert(j.first);
      if(tot[j.first] < j.second) tot[j.first] = j.second;
    }
  }
  ll lcm_=1;
  for(auto j:st){
    //cout << j.first << endl;
    //cout << j << " "<< tot[j] << endl;
    lcm_ = mu(lcm_,pw(j,tot[j]));
    //    lcm_ = lcm_*pow(j,tot[j]);  
    //  cout << lcm_ << endl;
  }
  ll ans=0;
  rep(i,n){
    ans = ad(ans, dv(lcm_,a[i]));
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 1408
using System;

class Program {
  static void Main() {
    string str = Console.ReadLine();
    int t = -1, cnt = 1;
    foreach (var c in str) {
      int n = int.Parse(c.ToString());
      if (n == t) {
        cnt++;
        if (cnt >= 3) {
          Console.WriteLine("Yes");
          return;
        }
      } else {
        t = n;
        cnt = 1;
      }
    }
    Console.WriteLine("No");
  }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    map<int,int> mp;
    REP(i,N){
        int a;cin>>a;
        if(mp[a]++){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


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

vector <pair <string , int> > v;

int main() {
	// your code goes here
    int t;
    cin >> t;
    while(t--)
    {
        string s;
        int x;
        cin >> s >> x;
        v.push_back(make_pair(s, x));
    }
    string xx;
    cin >> xx;
    int duration = 0;
    //cout << v[0].first << v[0].second;
    for(int i = 0; i < v.size(); i++)
    {
        if(v[i].first == xx)
        {
            for(int j = i + 1; j < v.size(); j++)
            {
                duration += v[j].second;
            }
        }
    }
    cout << duration << endl;
	return 0;
}


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

bool check(vector<int> a, int k) {
    for (auto &x: a) x *= 9;
    a[0] += 9*k;
    for (int i=0; i<(int)a.size(); ++i) {
        if (a[i] > 9) {
            if (i+1 == (int)a.size()) a.push_back(0);
            a[i+1] += a[i] / 10;
            a[i] %= 10;
        }
    }
    return accumulate(a.begin(), a.end(), 0) <= 9*k;
}

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vector<int> a(n);
    for (int i=0; i<n; ++i) a[i] = s[n-1-i] - '0';
    int low = 1, high = n;
    while (low < high) {
        int mid = low + high >> 1;
        if (check(a, mid)) high = mid;
        else low = mid+1;
    }
    cout << high << '\n';
    return 0;
}


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

void solve() {
	int n, k; cin >> n >> k;
	vector<int> vec(n), dp(n, INT_MAX);
	for (int i = 0; i < n; ++i) {
		cin >> vec[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; ++i) {
		for (int j = max(0, i - k); j < i; ++j) {
			dp[i] = min(dp[i], abs(vec[i] - vec[j]) + dp[j]);
		}
	}
	cout << dp[n - 1];
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
	// #ifndef ONLINE_JUDGE
	//     freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	// #endif
	solve();
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<map>
#include<queue>
#include<set>

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

const int NUM = 10001;
bool prime[NUM];

//ツ素ツ青板青カツ青ャ
void primegen(){
	prime[0] = false;
	prime[1] = false;
	for(int i=2;i<NUM;i++)
		prime[i] = true;
	for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;
}

int main(){
	primegen();
	int n,cnt;
	while(cin>>n){
		cnt = 0;
		for(int i=0;i<n;i++){
			if(prime[i+1]&&prime[n-i])
				cnt++;
		}
		cout<<cnt<<endl;
	}
  return 0;
}

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

long long ans,n,m,mod=998244353ll,fact[5000005],invfact[5000005],tmp;

long long fastp(long long base,long long exp){
    if(exp==0)return 1ll;
    long long tmp2=fastp(base,exp/2ll);
    tmp2=(tmp2*tmp2)%mod;
    if(exp%2==1)tmp2*=base;
    return tmp2%mod;
}

long long binom(long long a,long long b){
    if(b>a)return 0ll;

    return ((fact[a]*invfact[b])%mod*invfact[a-b])%mod;
}

int main(){

	cin>>n>>m;
	
	fact[0]=1;
	for(long long i=1;i<5000005;i++)fact[i]=(fact[i-1]*i)%mod;
	invfact[5000004]=fastp(fact[5000004],mod-2ll);
    for(long long i=5000003;i>=0;i--)invfact[i]=(invfact[i+1]*(i+1ll))%mod;


    
    ans=binom(n+3ll*m-1ll,n-1ll);
    
 //cout<<ans<<endl;
    
    for(int i=0;i<m;i++){
        ans-=(binom(n+i-1,i)*binom(n,m*3-2*i))%mod;
        ans=(ans%mod+mod)%mod;
    }
    

    for(int i=2*m+1;i<=(3*m);i++){
        tmp+=binom(n-2+3*m-i,n-2);
        tmp%=mod;
    }
//cout<<tmp<<endl;
    
    ans-=(n*tmp)%mod;
    ans=(ans%mod+mod)%mod;
    
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 78336
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Main {

	/**
	 * 引数で与えられた10の山の高さのうち、高い順に3つ出力する。
	 *
	 * @param args
	 *            利用しない
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {

		// 入力値を受け取る
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> heightsOfMountain = new ArrayList<Integer>();
		String line = null;
		while ((line = br.readLine()) != null) {
			heightsOfMountain.add(Integer.valueOf(line));
		}

		// ソート→逆順に並べ替え
		 Collections.sort(heightsOfMountain);
		 Collections.reverse(heightsOfMountain);

		 // 答えを出力する
		 System.out.println(heightsOfMountain.get(0));
		 System.out.println(heightsOfMountain.get(1));
		 System.out.println(heightsOfMountain.get(2));
	}
}

Measured memory_bytes: 17056
N, M, K = map(int, input().split())

MAX = 2 * 10 ** 5 + 1
MOD = 998244353

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1
for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    
# Inverse factorial
finv = [0] * (MAX + 1)
finv[MAX] = pow(fac[MAX], MOD - 2, MOD)
for i in reversed(range(1, MAX + 1)):
    finv[i - 1] = finv[i] * i % MOD

def comb(n, k):
    if n < k:
        return 0
    return fac[n] * finv[n - k] * finv[k]

ans = 0
for x in range(K + 1):
    tmp = M * pow(M - 1, N - x - 1, MOD) * comb(N - 1, x) % MOD
    ans = (ans + tmp) % MOD
print(ans)


Measured memory_bytes: 73668
#include <iostream>
#include <set>

using namespace std;

typedef long long ll;

const int MAX = 100001;

struct UnionFind {
  int par[MAX];
  int rank[MAX];
  UnionFind() {
    for (int x = 0; x < MAX; ++x) {
      par[x] = x;
      rank[x] = 0;
    }
  }

  int find(int x) {
    if (par[x] != x) {
      par[x] = find(par[x]);
    }
    return par[x];
  }

  void unite(int x, int y) {
    int px = find(x);
    int py = find(y);
    if (px != py) {
      if (rank[px] > rank[py]) {
        par[py] = px;
      }
      par[px] = py;
      if (rank[px] == rank[py]) {
        ++rank[px];
      }
    }
  }
};


int main() {
  UnionFind uf;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }
  int ans = 0;
  set<int> group;
  for (int i = 1; i <= n; ++i) {
    int id = uf.find(i);
    if (group.find(id) == group.end()) {
      ++ans;
      group.insert(id);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5760
n=int(input())
red=[tuple(map(int,input().split())) for i in range(n)]
blue=[tuple(map(int,input().split())) for i in range(n)]
red=sorted(red,key=lambda x:-x[1])
blue=sorted(blue)
count=0
i=0
while i<len(blue):
    for j in range(len(red)):
        if red[j][0]<blue[i][0] and red[j][1]<blue[i][1]:
            count+=1
            del red[j]
            del blue[i]
            break
    else:
        i+=1
print(count)

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

using namespace std;
using ll = long long;

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

int main() {
  int n;
  string s;
  cin >> n >> s;

  if (n % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }

  if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] a, count;
    int i, j, n;

    count = new int[7];
    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      a = new int[n];
      for(i = 0;i < n;i++)a[i] = sc.nextInt();
      for(i = 0;i < 7;i++)count[i] = 0;
      for(i = 0;i < n;i++){
        for(j = 10;j < 70;j+=10)if(a[i] < j){
          count[j / 10 - 1]++; break;
        }
        if(j == 70)count[j / 10 - 1]++;
      }
      for(i = 0;i < 7;i++)out.println(count[i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 280564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable PossibleNullReferenceException
// ReSharper disable AssignNullToNotNullAttribute

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var b = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            long sum = b[0];
            for (int i = 0; i < b.Length-1; ++i)
            {
                sum += Math.Min(b[i], b[i + 1]);
            }
            sum += b[b.Length - 1];
            Console.WriteLine(sum);
        }
    }
}


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

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

    bool cards[4][13] = {};
    char mark;
    int number;
    for (int i = 0; i < n; i++) {
        cin >> mark >> number;

        if (mark == 'S') {
           cards[0][number - 1] = true;
        } else if (mark == 'H') {
           cards[1][number - 1] = true;
        } else if (mark == 'C') {
           cards[2][number - 1] = true;
        } else if (mark == 'D') {
           cards[3][number - 1] = true;
        }
    }

    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (cards[i][j]) {
                continue;
            }

            if (i == 0) {
                cout << 'S';
            } else if (i == 1) {
                cout << 'H';
            } else if (i == 2) {
                cout << 'C';
            } else {
                cout << 'D';
            }

            cout << " " << j + 1 << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;
char s[105],t[105];
bool cmp1(char x,char y)
{
	return x<y;
}
bool cmp2(char x,char y)
{
	return x>y;
}
int main()
{
	int i,n,m;
	scanf("%s%s",s,t);
	n=strlen(s),m=strlen(t);
	sort(s,s+n,cmp1);
	sort(t,t+m,cmp2);
	for(i=0;i<n;i++)
		if(s[i]<t[i])
		{
			printf("Yes\n");
			return 0;
		}
		else if(s[i]>t[i])
		{
			printf("No\n");
			return 0;
		}
	if(n<m)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
  int N, M;
  long long int ans = 1;
  int MOD = 1000000007;
  
  cin >> N >> M;
  
  if(abs(N - M) > 1){
    cout << 0 << endl;
    return 0;
  }
  
  for(int i = 0;i < N;i++) ans = (ans % MOD) * ((i + 1) % MOD);
  for(int i = 0;i < M;i++) ans = (ans % MOD) * ((i + 1) % MOD);
  
  if(abs(N - M)) cout << ans % MOD << endl;
  else cout << (2 * (ans % MOD)) % MOD << endl;
  
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  ll r,d,x;
  cin>>r>>d>>x;
  for (int i=0; i<10; i++) {
    x = r*x-d;
    cout << x << endl;
  }
}

int main()
{
  solve();
  return 0;
}


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

bool ban[10] = {};
int n, k;

bool ok(int x) {
  while (x) {
    if (ban[x % 10])
      return false;
    x /= 10;
  }
  return true;
}

int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0, t; i < k; ++i) {
    scanf("%d", &t);
    ban[t] = true;
  }
  while (!ok(n))
    n++;
  printf("%d\n", n);
  return 0;
}


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

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

Node *root, *NIL;

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

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

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

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

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

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

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

    scanf("%d", &n);

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

    return 0;

}

Measured memory_bytes: 24688
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

long long f(int a, int b, int c, int d, int e, int f) {
  vector <long long> vec;
  vec.push_back(1ll * a * b);
  vec.push_back(1ll * c * d);
  vec.push_back(1ll * e * f);
  sort(vec.begin(), vec.end());
  return vec[2] - vec[0];
}

int main() {
  int n, m;
  cin >> n >> m;
  long long ans = 2e18;
  for (int i = 1; i < n; i++) {
    int maxy = max(i, n - i), miny = n - maxy;
    ans = min(ans, f(miny, m, maxy, m / 2, maxy, m - m / 2));
    ans = min(ans, f(miny, m, maxy / 2, m, maxy - maxy / 2, m));
  }
  for (int i = 1; i < m; i++) {
    int maxy = max(i, m - i), miny = m - maxy;
    ans = min(ans, f(n, miny, n / 2, maxy, n - n / 2, maxy));
    ans = min(ans, f(n, miny, n, maxy / 2, n, maxy - maxy / 2));
  }
  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 SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef vector<int> vi;


int const INF = 1001001001;
int const MAX_N = 200005;

vector<int> a, ans;
vector<int> G[MAX_N];
int dp[MAX_N];

void dfs(int v, int p = -1) {
    int i = lower_bound(dp, dp+MAX_N, a[v]) - dp;
    int old = dp[i];
    dp[i] = a[v];
    ans[v] = (int)(lower_bound(dp, dp+MAX_N, INF) - dp) - 1;
    for(auto nv : G[v]) {
        if(nv == p) continue;
        dfs(nv,v);
    }
    dp[i] = old;
}



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

int n;
cin >> n;
a = ans = vi(n);
rep(i,n) cin >> a[i];
rep(i,n-1) {
    int u,v;
    cin >> u >> v;
    --u; --v;
    G[u].push_back(v);
    G[v].push_back(u);
}
rep(i,MAX_N) dp[i] = INF;
dp[0] = -INF;
dfs(0);
rep(i,n) cout << ans[i] << endl;
return 0;
}

Measured memory_bytes: 30752
#include <stdio.h>


int BubbleSort(int A[], int n)
{
  int i,j,t;
  int count=0;
  for(i=0;i<n;i++){
    for(j=n-1;i<j;j--){
      if (A[j]<A[j-1]){
        t=A[j];
        A[j]=A[j-1];
        A[j-1]=t;
        count++;
      }
    }
  }
  return count;
}

int main()
{
  int n,i;
  int data[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }

  int count=BubbleSort(data,n);

  for(i=0;i<n-1;i++){
    printf("%d ",data[i]);
  }
  printf("%d\n%d\n",data[n-1],count);
  return 0;
}



Measured memory_bytes: 2732
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
ll M=1e9 + 7;
// Returns nCr % p 
ll C[2005];
ll C1[2005];
ll nCr(ll n, ll r) 
{ 
    // The array C is going to store last row of 
    // pascal triangle at the end. And last entry 
    // of last row is nCr 
    //ll C[r+1]; 
    //memset(C, 0, sizeof(C)); 
  
    C[0] = 1; // Top row of Pascal Triangle 
  
    // One by constructs remaining rows of Pascal 
    // Triangle from top to bottom 
    for (ll i = 1; i <= n; i++) 
    { 
        // Fill entries of current row using previous 
        // row values 
        for (ll j = min(i, r); j > 0; j--) 
  
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%M; 
    } 
    return C[r]%M; 
} 
ll nCr1(ll n, ll r) 
{ 
    // The array C is going to store last row of 
    // pascal triangle at the end. And last entry 
    // of last row is nCr 
    //ll C[r+1]; 
    //memset(C, 0, sizeof(C)); 
  
    C1[0] = 1; // Top row of Pascal Triangle 
  
    // One by constructs remaining rows of Pascal 
    // Triangle from top to bottom 
    for (ll i = 1; i <= n; i++) 
    { 
        // Fill entries of current row using previous 
        // row values 
        for (ll j = min(i, r); j > 0; j--) 
  
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C1[j] = (C1[j] + C1[j-1])%M; 
    } 
    return C1[r]%M; 
} 



int main() {
	// your code goes here
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    //nCr(5,5);
    //for(int i=0;i<=5;i++) cout<<C[i];
	ll n,k; cin>>n>>k;
	nCr(k-1,k-1);
	nCr1(n-k+1,k);
	//for(int i=0;i<=k;i++) cout<<C[i];
	
	for(ll i=1;i<=k;i++)
	{
	    //ll t1=k-i;
	    ll p1=C[i-1];
	    //ll t2=n-k-i+1;
	    ll p2=C1[i];
	    ll ans=(p1*p2)%M;
	    cout<<ans<<'\n';
	    
	    
	    
	    
	}
	
	return 0;
}


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

int main(){
    int h1, h2, m1, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = h1*60 + m1;
    int t2 = h2*60 + m2;
    int d = t2 - t1;
    d -= k;
    int ans = d;
    cout << ans << endl;
}

Measured memory_bytes: 3596
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
elif s == 'SAT':
    print(1)    

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            char[] n = in.next().toCharArray();
            for (int i = 0; i < 3; i++) {
                if (n[i] == '1') {
                    n[i] = '9';
                } else if (n[i] == '9') {
                    n[i] = '1';
                }
            }
            out.println(Integer.parseInt(new String(n)));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n == 0) return 1;

    ll res = modpow(x, n/2);
    if(n%2 == 0) return res*res%mod;
    else return res*res%mod*x%mod;
}

ll power(ll x, ll n){
    if(n == 0) return 1;

    ll res = power(x, n/2);
    if(n%2 == 0) return res*res;
    else return res*res*x;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */


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

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; ++i) cin >> a[i];

    ll ans = 0;
    ll l=0, r=0;
    vector<bool> bit_stand(21, 0);

    for(l=0; l<n; ++l){
        while(r<n){
            bool flg = true;
            for(int d=0; d<20; ++d) if(bit_stand[d] && a[r]&1<<d) flg = false;
            if(!flg) break;

            for(int d=0; d<20; ++d) if(a[r]&1<<d) bit_stand[d] = true;
            ++r;
        }

        ans += r-l;
        for(int d=0; d<20; ++d) if(a[l]&1<<d) bit_stand[d] = false;
    }

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


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

int main()
{
  int a, b, c, d, r;
  double f;

  cin >> a >> b;

  d = a/b;
  r = a%b;
  f =(double)a/b;

  printf("%d %d %.5lf", d, r, f);

  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int increase = Integer.parseInt(sc.next()) -1;
		int want = Integer.parseInt(sc.next());
		int total = 1;
		int addCount = 0;

		while (total < want) {
			total += increase;
			addCount++;
		}

		System.out.println(addCount);
	}
}


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

int main()

{

    int a,b,c;

    map<string,int> MAP;
    map<string,int>::iterator it;
    scanf("%d ",&a);
    string s;

    for(int k=0;k<a;k++){
    scanf("%d",&b);
    if (b==0 ){

            cin >> s >> c;
			MAP[s] = c;

            }
    else if (b==1){

            cin >> s;
			printf("%d\n",MAP[s]);



    }
    }


    return 0;



}


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

struct edge
{
    int l, r, c;
};

int main()
{
    int l;
    cin >> l;
    l--;
    vector<edge> v;
    int k = 1;
    int i = 0;
    while(k * 2 - 1 <= l){
        v.push_back(edge{i, i + 1, 0});
        v.push_back(edge{i, i + 1, k});
        k *= 2;
        i++;
    }
    int t = l - (k - 1);
    int s = k;
    for(int j = 18; j >= 0; j--){
        if((t >> j) & 1){
            v.push_back(edge{j, i, s});
            t -= (1 << j);
            s += (1 << j);
        }
    }
    cout << i + 1 << " " << (int)v.size() << endl;
    for(edge e : v){
        cout << e.l + 1 << " " << e.r + 1 << " " << e.c << endl;
    }
}


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

using namespace std;

const int N = 2e5;

int n, a[N];
long long ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> n;
	for (int i = 0; i < n; ++i)
		scanf("%d", a + i);

	sort(a, a + n);

	ans = a[n - 1];
	for (int i = 0; i < (n - 1) / 2; ++i)
		ans += 2 * a[n - i - 2];

	if (n % 2 == 1)
		ans -= a[n - (n / 2) - 1];

	cout << ans << endl;
}


Measured memory_bytes: 4540
from collections import Counter
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
d_ans = dict(Counter(d))
t_ans = dict(Counter(t))
flag = True
for i in t_ans:
    if i not in d_ans:
        flag = False
        
    else:
        if t_ans[i] > d_ans[i]:
            flag = False
print('YES' if flag==True else 'NO')


Measured memory_bytes: 132296
#include <stdio.h>

int main(void) {

	int n,i,max=-1000000,min=1000000;

	int a[10000];

	long long int sum=0;

	scanf("%d",&n);

	for(i=0;i<n;i++){

		scanf("%d",&a[i]);

		if(a[i]>max)

			max=a[i];
		if(a[i]<min)

			min=a[i];

		sum+=a[i];

	}
 
	printf("%d %d %lld\n",min,max,sum);



	return 0;

}



Measured memory_bytes: 2100
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

struct RollingHash {
  static const ll base1 = 1007, base2 = 2009;
  static const ll mod1 = 1000000007, mod2 = 1000000009;
  vector<ll> hash1, hash2, power1, power2;

  // construct
  RollingHash(const string& S) {
    ll n = (ll)S.size();
    hash1.assign(n + 1, 0);
    hash2.assign(n + 1, 0);
    power1.assign(n + 1, 1);
    power2.assign(n + 1, 1);
    for (ll i = 0; i < n; ++i) {
      hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
      hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
      power1[i + 1] = (power1[i] * base1) % mod1;
      power2[i + 1] = (power2[i] * base2) % mod2;
    }
  }

  // get hash of s[l..r-1]
  inline P get(ll l, ll r) const {
    long long res1 = hash1[r] - hash1[l] * power1[r - l] % mod1;
    if (res1 < 0) res1 += mod1;
    long long res2 = hash2[r] - hash2[l] * power2[r - l] % mod2;
    if (res2 < 0) res2 += mod2;
    return {res1, res2};
  }

  // get lcp of s[a..] and s[b..]
  inline ll getLCP(ll a, ll b) const {
    ll len = min((ll)hash1.size() - a, (ll)hash1.size() - b);
    ll low = 0, high = len;
    while (high - low > 1) {
      ll mid = (low + high) >> 1;
      if (get(a, a + mid) != get(b, b + mid))
        high = mid;
      else
        low = mid;
    }
    return low;
  }
};

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);
 
  ll n;
  string s;
  cin >> n >> s;
  RollingHash rhl(s);
  ll ans = 0;
  repLRE(i, 0, n - 2) {
    repLRE(j, i + 1, n - 1) {
      ll tmp = rhl.getLCP(i, j);
      chmin(tmp, j - i);
      chmax(ans, tmp);
    }
  }
 
  cout << ans << endl;
 
  return 0;
}


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

#define F(i, a, b) for(int i=a; i<b; i++)
#define mem(arr, val) memset(arr, val, sizeof(arr))

#define MOD 1000000007
#define INF 1000000001
#define epsilon 1e-15

typedef long long int ll;
typedef unsigned long long int ull;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    int N, K;
    cin >> N >> K;
    int h[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }

    ll dp[N];
    dp[N-1] = 0;
    for(int i=0; i<N-1; i++)
        dp[i] = LLONG_MAX;
    for(int i=N-2; i>=0; i--){
        for(int k=1; k<=K && i+k <N; k++)
            dp[i] = min(dp[i], dp[i+k] + abs(h[i+k] - h[i]));
    }


    cout << dp[0] << '\n';

    return 0;
   
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#define ll long long
#define pp push_back
#define fr first
#define sc second

using namespace std;


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0) ,cout.tie(0);
    string s; cin >> s;
    if(s == "ARC")cout << "ABC";
    else          cout << "ARC";


    return 0;
}


Measured memory_bytes: 3616