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

int main()
{
    typedef int ll;
    ll a,b;
    cin>>a>>b;
    ll s=a+b;
    ll bs=a-b;
    ll m=a*b;

    ll ans=max(s,max(bs,m));

    cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 1
using namespace std;

int main()
{
    int i,j;
    int N;

    scanf("%d", &N);
    double M = N;
    M /= 1.08;
    if( M!=(int)(M) )
        M = (int)(M+1);

    if( (int)( M * 1.08) == N)
        printf("%d\n", (int)M);
    else
        printf(":(\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	long long int n, t;
	cin >> n >> t;
	vector<long long int> d(n);
	for (long long int i = 0; i < n; i++) {
		cin >> d[i];
	}
	long long int sum = 0;
	long long int st, ed;
	st = ed = 0;
	for (long long int i = 0; i < n; i++) {
		if (ed < d[i]) {
			sum += ed-st;
			st = d[i];
			ed = st + t;
		}
		else {
			ed = d[i] + t;
		}
	}
	sum += ed - st;
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<iterator>
using namespace std;

void dfs(int vertex,vector <vector <int>>& adj, vector <int>& colour, int present_colour, int& count, vector <int> &visited)
{
	if (present_colour != colour[vertex])
	{
		count++;
		present_colour = colour[vertex];
	}
	for (int i = 0; i < adj[vertex].size(); i++)
	{
		int child = adj[vertex][i];
		if (visited[child] == 0)
		{
			visited[child] = 1;
			dfs(child, adj, colour, present_colour, count, visited);
		}
	}
}

int main() {

	int n;
	cin >> n;
	vector <long long> arr(n+5);
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	vector <long long> sum(n+5);
	long long mod = 1000000007;
	sum[n - 1] = arr[n - 1];
	for (int i = n - 2; i >= 0; i--)
	{
		sum[i] = (sum[i + 1] + arr[i])%mod;
	}
	
	long long ans = 0;
	for (int i = 0; i < n - 1; i++)
	{
		ans = (ans+ (arr[i] * (sum[i + 1])) % mod)%mod;
	}
	cout << ans;

	return 0;
}




Measured memory_bytes: 6400
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000000
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pi 3.14159
ll power(ll a,int n){
  if(n==0)
    return 1;
  if((n%2)==0)
    return power(a*a,n/2);
  else
    return a*power(a*a,n/2);    
}
vector<bool> mark;
void seive(ll N){
    mark.resize(N+1);
  for(ll i=2;i*i<=N;i++){
    if(!mark[i]){
       for(ll j=i*i;j<=N;j+=i){
         mark[j]=1;
       }
      }
  }
}
int main(){
FASTIO
int k;
cin>>k;
int a,b;
cin>>a>>b;
bool is=false;
for(int i=a;i<=b;i++)
{
  if((i%k)==0)
  {
    is=true;
    break;
  }
}
if(is){
  cout<<"OK";
}
else{
  cout<<"NG";
}
return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cstring>
#define MAX_N 100001

bool IsPrime[MAX_N];

// 愚直な素数列挙
void get_primes() {
    IsPrime[0] = false; IsPrime[1] = false;
 
    for (int i = 2; i < MAX_N; i++) {
        for (int j = 2; j*j <= i; j++) {
            if (i % j == 0) { IsPrime[i] = false; }
        }
    }
}

int main() {
    int Q, l, r;
    int cnt[MAX_N] = {0};

    memset(IsPrime, 1, sizeof(IsPrime));
    get_primes();

    for (int i = 3; i <= MAX_N; i += 2) {
        if (IsPrime[i] && IsPrime[(i+1)/2]) { cnt[i]++; }
    }
    // 2017 に似てる数の累積和をとっている
    for (int i = 1; i <= MAX_N; i++) {
        cnt[i] += cnt[i-1];
    }

    scanf("%d", &Q);

    while (Q--) {
        scanf("%d %d", &l, &r);
        printf("%d\n", cnt[r] - cnt[l-1]);
    }

    return 0;
}

Measured memory_bytes: 1024
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = readLine()!!.split(' ').map { it.toInt() }.toIntArray()
    val ys = IntArray(n)

    var size = 0
    val ans = IntArray(n)

    for (i in n - 1 downTo 0) {
        val b = i + 1
        var s = 0
        for (j in i until n step b) {
            s += ys[j]
        }
        if (s % 2 != xs[i]) {
            ys[i]++
            ans[size++] = i + 1
        }
    }
    println(size)
    ans.take(size).joinToString(" ").let { println(it) }
}


Measured memory_bytes: 77696
#include <stdio.h>

int main(void){
    int n,ary[100],i,j,buf;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&ary[i]);
    for(i=n-1;i>=0;i--){
        printf("%d",ary[i]);
        if (i>0) printf(" ");
        else printf("\n");
    }
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  
  if((a*b)%2==1) cout << "Odd" << endl;
  if((a*b)%2==0) cout << "Even" << endl;
  
}


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

int main(){
    int N; cin >> N;
    vector<int> A(N);
    for(int i= 0; i < N; i++) cin >> A[i];

    map<int,int> MP;
    for(int i = 0; i < N; i++){
        MP[A[i]]++;
    }
    auto it = MP.rbegin();
    int max1, max2;
    if(it->second >= 2) max1 = max2 = it->first;
    else{
        max1 = it->first;
        it++;
        max2 = it->first;
    }
    for(int i = 0; i < N; i++){
        if(A[i] == max1) cout << max2 << endl;
        else cout << max1 << endl;
    }
}

Measured memory_bytes: 7936
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int A = in.nextInt();
            int B = in.nextInt();
            int T = in.nextInt();

            System.out.println(T / A * B);
        }
    }
}


Measured memory_bytes: 21716
#include <iostream>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	bool ok = true;
	if (s[0] != '1' || s.size() < 2) ok = false;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] != '0') ok = false;
	}
	if (ok) {
		cout << 10 << endl;
		exit(0);
	}
	int ans = 0;
	for (int i = 0; i < s.size(); ++i) {
		ans += s[i] - '0';
	}
	cout << ans << endl;
	return 0;
}

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

int bubbleSort(int A[],int N){
  int sw=0,temp;
  bool flag=1;
  for(int i=0;flag;i++){
    flag=0;
    for(int j=N-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	sw++;
      }
    }
  }
  return sw;
}

int main(){
  int A[100],N,sw;
  cin>>N;
  for(int i=0;i<N;i++) cin>>A[i];
  sw=bubbleSort(A,N);
  for(int i=0;i<N;i++){
    if(i)cout<<" ";
    cout << A[i];
  }
  cout << endl;
  cout << sw << endl;
  return 0;
}



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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
template<class T> inline T isqrt(T k) {T r = sqrt(k) + 1; while (r * r > k) r--; return r;}
template<class T> inline T icbrt(T k) {T r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}

const int maxn = 20000 + 10;
int n;
int p[maxn];
int a[maxn];
int b[maxn];

struct Fenwick {
	int fen[maxn];
	void upd(int p, int val) {
		p++;
		for (; p < maxn; p += p & -p) {
			fen[p] += val;
		}
	}
	int query(int p) {
		p++;
		int res = 0;
		for (; p > 0; p -= p & -p) {
			res += fen[p];
		}
		return res;
	}
	void upd(int l, int r, int val) {
		upd(l, val);
		upd(r + 1, -val);
	}
} fa, fb;

void solve() {
	cin >> n;
	FOR(i, 0, n) cin >> p[i], p[i]--;
	FOR(i, 0, n) a[i] = i + 1;
	FOR(i, 0, n) b[i] = n - i;
	int cur = 0;
	FOR(i, 0, n) {
		int ix = p[i];
		int tot = a[ix] + b[ix] + fa.query(ix) + fb.query(ix);
		if (tot <= cur) {
			int t = cur - tot + 1;
			fa.upd(ix, n - 1, t);
			fb.upd(0, ix, t);
		}
		cur = a[ix] + b[ix] + fa.query(ix) + fb.query(ix);
	}
	FOR(i, 0, n) cout << a[i] + fa.query(i) << " \n"[i == n - 1];
	FOR(i, 0, n) cout << b[i] + fb.query(i) << " \n"[i == n - 1];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL_
	freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout);
#endif
	solve();
#ifdef _LOCAL_
	//printf("\nTime elapsed: %dms", 1000 * clock() / CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define SORTR(v,n) sort(v, v+n, greater<int>());
// #define int long long    // %d=>%lld
#define pb push_back
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> piii;
typedef pair<ll, pll> plll;

int h;
int w;


char buf1[100+1];
string s[100+1];


signed main(){
    scanf("%d", &h);
    scanf("%d", &w);
    for(int i = 0;i < h;i++){
        cin >> s[i];
    }

    for(int i = 0;i < w+2;i++){
        cout << '#';
    }
    cout << '\n';
    for(int i = 0;i < h;i++){
        cout<< '#'<< s[i]<< '#'<< '\n';
    }
    for(int i = 0;i < w+2;i++){
        cout << '#';
    }
    cout << '\n';
    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;
int main(void){
   int A,B,C;
   cin>>A>>B>>C;
   
   if(A+B>=C){
       cout<<"Yes"<<endl;
   }
   else {
       cout<<"No"<<endl;
   }
   
   
  
}

Measured memory_bytes: 3588
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MAX 20000000
#define MOD 1000000007

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll f(ll h,ll w){
  return COM(h+w,w);
}
ll g(ll h,ll w){
  ll res = 0;
  for(ll i=1;i<=h+1;i++){
    res += f(i,w);
    res %= MOD;
  }
  return res;
}
signed main(){
  init_io();
  COMinit();
  ll r1,r2,c1,c2;
  cin >> r1 >> c1 >> r2 >> c2;
  ll x = (g(r2,c2) + g(r1-1,c1-1))%MOD;
  ll y = (g(r2,c1-1)+g(r1-1,c2))%MOD;
  ll ans = x - y;
  while(ans<0) ans += MOD;
  ans %= MOD;
  cout << ans << endl;
}


Measured memory_bytes: 468992
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  ll x;
  cin>>x;
  ll ret = 0;
  for(int i =1;(i*(ll)i<=x);i++){
    if(x%i==0){
      ll m = (x/i-1);
      if(m>=1&&x%m==x/m)
      ret+=m;
    //  cout<<x/i-1<<endl;
    }
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
 
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
 
using namespace std;

// int findMinSwap(vector<int> arr , int n) 
// { 
//     // Declare a vector of pair      
//     vector< pair<int,int> > vec(n); 
      
//     for(int i=0;i<n;i++) 
//     { 
//         vec[i].first=arr[i]; 
//         vec[i].second=i; 
//     } 
  
//     // Sort the vector w.r.t the first 
//     // element of pair 
//     sort(vec.begin(),vec.end()); 
  
//     int ans=0,c=0,j; 
  
//     for(int i=0;i<n;i++) 
//     {    
//         // If the element is already placed 
//         // correct, then continue 
//         if(vec[i].second==i)  
//             continue; 
//         else
//         { 
//             // swap with its respective index  
//             swap(vec[i].first,vec[vec[i].second].first); 
//             swap(vec[i].second,vec[vec[i].second].second);  
//         }  
          
//         // swap until the correct  
//         // index matches 
//         if(i!=vec[i].second) 
//             --i; 
          
//         // each swap makes one element 
//         // move to its correct index,  
//         // so increment answer 
//         ans++; 
//     } 
  
//     return ans; 
// } 

int factorial( int n ) 
{ 
    int res = 1, i; 
    for (i = 2; i <= n; i++) 
        res *= i; 
    return res; 
}
 
signed main()
{
    fast;
    int n;
    cin>>n;

    vector<int> a(n);
    vector<int> b(n);

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        cin>>a[i];
    }

    for ( int i = 0 ; i < b.size() ; i++ )
    {
        cin>>b[i];
    }

    vector<int> ans1;
    vector<int> ans2;

    for ( int i = 0 ; i < a.size() ; i++ )
    {
        int count = 0;
        for ( int j = i+1 ; j < a.size() ; j++ )
        {
            if ( a[i] > a[j] )
            {
                count++;
            }
        }
        ans1.push_back(count);
    }

    for ( int i = 0 ; i < b.size() ; i++ )
    {
        int count = 0;
        for ( int j = i+1 ; j < b.size() ; j++ )
        {
            if ( b[i] > b[j] )
            {
                count++;
            }
        }
        ans2.push_back(count);
    }

    int sum1 = 0;
    int sum2 = 0;

    for ( int i = 0 ; i < ans1.size() ; i++ )
    {
        sum1 += factorial(ans1.size()-1-i)*ans1[i];
        sum2 += factorial(ans2.size()-1-i)*ans2[i];
    }

    cout<<abs(sum1-sum2)<<endl;

    return 0;
}

Measured memory_bytes: 256
naive_solver::Integer->Integer->Int
naive_solver x y = let pow_2 = x:(map (2*) pow_2) in
                   length (takeWhile (y>=) pow_2)

main::IO()
main=do
  xyc<-getLine
  let x:y:[]=map read (words xyc)
  print (naive_solver x y)

Measured memory_bytes: 508
//////AGC039-B//////
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,m,k,ans=-100;
void Main(){
    cin>>n>>m>>k;
    For(i,0,k){
        if(i%2==0){
            m+=n/2;
            n/=2;
        }
        else{
            n+=m/2;
            m/=2;
        }
    }
    cout<<n<<" "<<m<<endl;
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    ll R,G,B,N;
    cin >> R >> G >> B >> N;
    ll tmp;
    ll ans = 0;
    for(int r=0; r<= 3000; r++){
        for(int g=0; g<= 3000; g++){
            tmp = N - (R*r + G*g);
            if(tmp < 0)break;
            if(0 == tmp%B)ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<double> dvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        for(int i = 0; i < N; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int n,m,ans=0;
    cin>>n>>m;
    vec p(n);
    rep(i,n){
        cin>>p[i];
        p[i]--;
    }
    UnionFind tree(n);
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        tree.unite(p[x],p[y]);
    }
    rep(i,n){
        if(tree.same(i,p[i])) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
N = 5

def main(argv)
  a = [0] * N
  N.times{|i| a[i] = gets.chomp.to_i}
  k = gets.chomp.to_i
  
  f = true
  N.times do |i|
    N.times do |j|
      f &= (a[j] - a[i]).abs <= k
    end
  end
  
  puts f ? 'Yay!' : ':('
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 3836
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <bitset>
#include <iomanip>

using namespace std;

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

    vector<int> indexR;
    vector<int> indexG;
    //vector<int> indexB;
    for (size_t i = 0; i < S.size(); ++i) {
        if (S[i] == 'R') {
            indexR.push_back(i);
        }
        else if (S[i] == 'G') {
            indexG.push_back(i);
        }
        //else {
        //    indexB.push_back(i);
        //}
    }
    vector<long long> accumNumOfB;
    long long currAccum = 0;
    for (int i = 0; i < N; ++i) {
        if (S[i] == 'B') {
            ++currAccum;
        }
        accumNumOfB.push_back(currAccum);
    }

    long long count = 0;
    for (size_t i = 0; i < indexR.size(); ++i) {
        int r = indexR[i];
        for (size_t j = 0; j < indexG.size(); ++j) {
            int g = indexG[j];
            //for (size_t k = 0; k < indexB.size(); ++k) {
            //    int b = indexB[k];
            //    int maxIndex = max(max(r, g), b);
            //    int minIndex = min(min(r, g), b);
            //    int midIndex = (maxIndex == r) ? max(g, b) : ((maxIndex == g) ? max(r, b) : max(r, g));

            //    if ((maxIndex - midIndex) != (midIndex - minIndex)) {
            //        ++count;
            //    }
            //}
            int maxRG = max(r, g);
            int minRG = min(r, g);

            // left
            count += accumNumOfB[minRG];
            int prohibit = minRG - (maxRG - minRG);
            if (prohibit >= 0 && S[prohibit] == 'B') {
                --count;
            }

            // right
            count += accumNumOfB.back() - accumNumOfB[maxRG];
            prohibit = maxRG + (maxRG - minRG);
            if (prohibit < N && S[prohibit] == 'B') {
                --count;
            }

            // mid
            if ((maxRG - minRG) % 2 == 0) {
                count += accumNumOfB[maxRG] - accumNumOfB[minRG];
                int midpoint = minRG + (maxRG - minRG) / 2;
                if (S[midpoint] == 'B') {
                    --count;
                }
            }
            else {
                count += accumNumOfB[maxRG] - accumNumOfB[minRG];
            }
        }
    }

    cout << count << endl;
    //cout << setprecision(15) << endl;
    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Linq;

namespace ALDS1_12_A
{
    class Program
    {
        const int N = 100;
        const int INFTY = 1145141919;
        const int white = 0;
        const int gray = 1;
        const int black = 2;
        static int n;
        static int[,] M = new int[N,N];

        static int prim()
        {
            var d = Enumerable.Repeat(INFTY, n).ToArray();
            var p = Enumerable.Repeat(-1, n).ToArray();
            var color = Enumerable.Repeat(white, n).ToArray();
            int sum = 0;

            d[0] = 0;

            while (true)
            {
                int minv = INFTY;
                int u = -1;
                for (int i = 0; i < n; i++)
                {
                    if (minv > d[i] && color[i] != black)
                    {
                        u = i;
                        minv = d[i];
                    }
                }
                if (u == -1) break;
                color[u] = black;
                for (int v = 0; v < n; v++)
                {
                    if (color[v] != black && M[u, v] != INFTY)
                    {
                        if (d[v] > M[u, v])
                        {
                            d[v] = M[u, v];
                            p[v] = u;
                            color[v] = gray;
                        }
                    }
                }
            }
                for (int i = 0; i < n; i++)
                    if (p[i] != -1) sum += M[i,p[i]];
                                           
            return sum; 
        }
        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                var t = scan();
                for (int j = 0; j < n; j++)
                {
                    M[i, j] = (t[j] == -1) ? INFTY : t[j];
                }
            }
            Console.WriteLine(prim());
        }

        static int[] scan()
        {
            return Console.ReadLine().Remove(0, 1).Split(' ').Select(i => int.Parse(i)).ToArray();
        }
    }
}

Measured memory_bytes: 9796
#include <stdio.h>
#include <stdlib.h>

#define ll long long
#define MOD 998244353

int main(){
    int k;
    char s[100] = {};
    scanf("%d %s", &k, s);

    for(int i=0;i<100;i++){
        if(s[i]=='\0') break;
        if(i>=k){
            printf("...\n");
            break;
        }
        putchar(s[i]);
    }

    return 0;
}

Measured memory_bytes: 1656
#S=input()
N=int(input())
#H,W=map(int,input().split())
num=0
for i in range(1,N+1):
    kazu=0
    if i%2==0:
        continue
    for j in range(1,i+1):
        if i%j==0:
            kazu+=1
    if kazu==8 :
        num+=1
print(num)

Measured memory_bytes: 38640
#define MAX 100000
#include <stdio.h>

int partition(int *,int,int);
int main(int argc, char const *argv[]) {
  int a[MAX],n,res,i;

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

  res = partition(a,0,n-1);

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

  return 0;
}

int partition(int *a,int p,int r) {
  int x = a[r];
  int i = p-1;
  int j;
  int swap;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i=i+1;
      swap = a[i];
      a[i] = a[j];
      a[j] = swap;
    }
  }
  swap = a[i+1];
  a[i+1] = a[r];
  a[r] = swap;

  return i+1;
}

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

void fail(){
	cout << "No" << '\n';
	exit(0);
}

void done(vector<int> ret){
	cout << "Yes" << '\n';
	for(int a : ret) cout << a + 1 << ' ';
	cout << '\n';
	exit(0);
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	n *= 2;
	string s;
	cin >> s;
	s = "1" + s;
	int c0 = 0;
	for(int i = 0; i < n; i++) if(s[i] == '0') c0++;
	vector<int> ret(n, -1);
	int cur = 0;
	int used = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '0' && s[i+1] == '0'){
			ret[i] = cur;
			used++;
			if(used == 2){
				used = 0;
				cur++;
			}
		}
	}
	if(used == 1) fail();
	if(c0 == 0){
		// single cycle of length n
		if(n % 4 != 0) fail();
		for(int i = 0; i < n; i++){
			if(s[i] == '1' && s[(i+1)%n] == '1'){
				ret[i] = cur + (used & 1);
				used++;
				if(used == 4){
					used = 0;
					cur += 2;
				}
			}
		}
		done(ret);
	}
	int npaths = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '0' && s[(i+1)%n] == '1' && s[(i+2)%n] != '0'){
			npaths++;
		}
	}
	int c11 = 0;
	for(int i = 0; i < n; i++) if(s[i] == '1' && s[(i+1) % n] == '1') c11++;
	// single path of length
	if(npaths <= 1){
		if(c11 % 4 != 0) fail();
		for(int i = 0; i < n; i++){
			if(s[i] == '1' && s[(i+1)%n] == '1'){
				ret[i] = cur + (used & 1);
				used++;
				if(used == 4){
					used = 0;
					cur += 2;
				}
			}
		}
		for(int i = 0; i < n; i++){
			if(s[i] != s[(i+1)%n]){
				ret[i] = cur;
				used++;
				if(used == 2){
					used = 0;
					cur++;
				}
			}
		}
		done(ret);
	}
	if(c11 % 4 != 0){
		int i = 0;
		while(s[i] != '0' || s[(i+1)%n] != '1' || s[(i+2)%n] != '1') i = (i+1)%n;
		ret[i] = cur;
		while(s[(i+1)%n] != '0') i = (i+1)%n;
		ret[i] = cur;
		cur++;
		i = (i+n-1)%n;
		ret[i] = cur;
		while(s[(i+n-1)%n] != '1' || s[i] != '1' || s[(i+1)%n] != '0') i = (i+n-1)%n;
		i = (i+n-1)%n;
		ret[i] = cur;
		cur++;
	}
	for(int i = 0; i < n; i++){
		if(ret[i] == -1 && s[i] == '1' && s[(i+1)%n] == '1'){
			ret[i] = cur + (used & 1);
			used++;
			if(used == 4){
				used = 0;
				cur += 2;
			}
		}
	}
	for(int i = 0; i < n; i++){
		if(ret[i] == -1 && s[i] != s[(i+1)%n]){
			ret[i] = cur;
			used++;
			if(used == 2){
				used = 0;
				cur++;
			}
		}
	}
	done(ret);
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    vector<ll> dp(n+1,0);
    rep2(i,1,n+1){
        ll m = dp[i-1]+1;
        for(int j=6;j<=i;j*=6)m=min(m,dp[i-j]+1);
        for(int j=9;j<=i;j*=9)m=min(m,dp[i-j]+1);
        dp[i]=m;
    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 1024
import collections
import math

MOD = 10**9 + 7


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


n, m = map(int, input().split())
mm = math.ceil(math.sqrt(m))
sieve = eratosthenes(mm)
primes = [i for i in range(mm) if sieve[i]]
counter = collections.Counter()
for p in primes:
    while m % p == 0:
        counter[p] += 1
        m //= p
    if m == 1:
        break
else:
    if m != 1:
        counter[m] += 1

me = max(counter.values()) if len(counter.values()) > 0 else 0
factorials = [1]
for i in range(1, me + 1):
    factorials.append(factorials[-1] * i)

res = 1
for p, e in counter.items():
    for i in range(e):
        res *= e + n - 1 - i
    res //= factorials[e]
    res %= MOD
print(res)

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

int main(){
    vector<int> a(3);
    for (int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    cout << a[0] << " " << a[1] << " " << a[2] << endl;
    return 0;

}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;

#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const long long mod = 1000000007;
template <int mod>
struct ModInt
{
    int x;
 
    ModInt() : x(0) {}
    ModInt(long long y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
 
    ModInt &operator+=(const ModInt &p)
    {
        if ((x += p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p)
    {
        if ((x += mod - p.x) >= mod)
            x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p)
    {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p)
    {
        *this *= p.inverse();
        return *this;
    }
 
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
 
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
 
    ModInt inverse() const
    {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0)
        {
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return ModInt(u);
    }
 
    ModInt pow(int e)
    {
        long long a = 1, p = x;
        while (e > 0)
        {
            if (e % 2 == 0)
            {
                p = (p * p) % mod;
                e /= 2;
            }
            else
            {
                a = (a * p) % mod;
                e--;
            }
        }
        return ModInt(a);
    }
 
    friend ostream &operator<<(ostream &os, const ModInt<mod> &p)
    {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt<mod> &a)
    {
        long long x;
        is >> x;
        a = ModInt<mod>(x);
        return (is);
    }
};
 
using modint = ModInt<mod>;
signed main(){
    long long n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    modint res=0;
    for(int i=0;i<60;i++){
        long long cnt=0;
        for(int j=0;j<n;j++){
            if(a[j]&(1ll<<i)){
                cnt++;
            }
        }
        res+=(1ll<<i)%mod*cnt%mod*(n-cnt);
    }
    cout<<res<<endl;
}


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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 2e5+5;
int n, bef[MAXN];

int main() {
	gi(n);
	int ans = 0;
	for (int i=1; i<=n; i++) {
		int x; gi(x);
		bef[x] = bef[x-1]+1;
		ans = max(ans, bef[x]);
	}
	printf ("%d\n", n-ans);
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, p = 0, n = 0, c = 0, M = 0;
    cin >> N;
    rep(i, N) {
        cin >> n;
        if(n <= p)
            c++;
        else {
            M = max(M, c);
            c = 0;
        }
        p = n;
    }
    M = max(M, c);
    cout << M << endl;
}


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

class Program
{
    public static void Main(string[] args)
    {
        string s = Console.ReadLine();

        bool flag = false;

        for (int i = 0; i < s.Length; i++)
        {
            if(i%2 != 0)
            {
                if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D') { }
                else
                {
                    flag = true;
                }
            }
            else
            {
                if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D') { }
                else
                {
                    flag = true;
                }
            }
        }

        if (flag)
            Console.WriteLine("No");
        else
            Console.WriteLine("Yes");

    }
}


Measured memory_bytes: 11092
from copy import deepcopy
from math import factorial as fact
def combi(n, r):
    return fact(n)//(fact(n-r)*fact(r))

n, a, b = list(map(int, input().split()))
v = list(map(int, input().split()))
v_num = {}
for i in range(n):
    if v[i] not in v_num.keys():
        v_num[v[i]] = 1
    else:
        v_num[v[i]] += 1

v = sorted(v)
ans1 = v[-a:]
print(sum(ans1)/a)

answers = [ans1]
for i in range(a+1, b+1):
    if sum(v[-i:])/i == sum(ans1)/a:
        answers.append(v[-i:])
    else:
        break
# print(answers)

ans2 = 0
for ans in answers:
    ans_num = {}
    for i in range(len(ans)):
        if ans[i] not in ans_num.keys():
            ans_num[ans[i]] = 1
        else:
            ans_num[ans[i]] += 1
        
    a2 = 1
    for k in ans_num.keys():
        a2 *= combi(v_num[k], ans_num[k])
    ans2 += a2
    
print(ans2)

Measured memory_bytes: 3444
import sys
def input(): return sys.stdin.readline().rstrip()
import fractions
def main():
    n,m=map(int,input().split())
    s=input()
    t=input()
    ans=-1
    if n==m:
        if s==t:
            ans=n
    else:
        gcd_nm=fractions.gcd(n,m)
        for i in range(gcd_nm):
            if s[n//gcd_nm*i]!=t[m//gcd_nm*i]:
                break
        else:
            ans=n*m//gcd_nm
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 5432
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#define _USE_MATH_DEFINES
#define ln long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
using namespace std;

int max(int *ary) {
	int max = 0;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int nmax(int *ary) {
	int max = 0, num;
	for (int i = 0; i < sizeof(ary) / sizeof(ary[0]); i++)
		if (max < ary[i]) {
			max = ary[i];
			num = i;
		}
	return max, num;
}

int main() {
	int w, h, n, x, y, a, v[100][100] = {}, ans = 0;
	cin >> w >> h >> n;

	for (int i = 0; i < n; i++) {
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			for (int j = 0; j < h; j++)
				for (int k = 0; k < x; k++)
					v[j][k] = 1;
			break;
		case 2:
			for (int j = 0; j < h; j++)
				for (int k = x; k < w; k++)
					v[j][k] = 1;
			break;
		case 3:
			for (int j = 0; j < y; j++)
				for (int k = 0; k < w; k++)
					v[j][k] = 1;
			break;
		case 4:
			for (int j = y; j < h; j++)
				for (int k = 0; k < w; k++)
					v[j][k] = 1;
			break;
		}
	}

	for (int j = 0; j < h; j++)
		for (int k = 0; k < w; k++)
			if (v[j][k] != 1)
				ans++;

	cout << ans << endl;

	return 0;
}

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

// 1重階乗n!を素数pで何回割れるか
ll g(ll n, int p) {
    if (n < p) return 0;
    else if (n == p) return 1;
    return ll(n/p) + g(ll(n/p), p);
}

int main() {
    ll n;
    cin >> n;
    if (n%2 == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll cntTwo = g(n/2, 2) + n/2;
    ll cntFive = g(n/2, 5);
    ll ans = min(cntTwo, cntFive);
    cout << ans << endl;;
    return 0;
}

Measured memory_bytes: 256
S = str(input())
f = []
l = []
ans = 'Yes'
for i in range(int((len(S)-1)/2)):
    f.append(S[i])
    l.append(S[-i-1])
for i in range(len(f)):
    if f[i] != l[-i-1]:
        ans = 'No'
print(ans)

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

struct Card {char suit; int val; };

const int MAX = 100000, SENTINEL = 2100000000;
Card L[MAX / 2 + 2], R[MAX / 2 + 2];
int cnt;

void merge(Card A[], int n, int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1].val = R[n2].val = SENTINEL;
    int i = 0, j = 0;
    for (int k = left; k < right; k++) {
        cnt++;
        if (L[i].val <= R[j].val) {
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void msort(Card A[], int n, int left, int right) {
    if (left + 1 < right) {
        int mid = (left + right) / 2;
        msort(A, n, left, mid);
        msort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(Card A[], int p, int r) {
    Card x = A[r];
    int i = p - 1;
    for (int j  = p; j < r; j++) {
        if (A[j].val <= x.val) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void qsort(Card A[], int n, int p, int r) {
    if (p < r) {
        int q = partition(A, p, r);
        qsort(A, n, p, q - 1);
        qsort(A, n, q + 1, r);
    }
}

int main(void) {
    int n;
    Card A[MAX], B[MAX];
    cin >> n;
    string s;
    int v;
    for (int i = 0; i < n; i++) {
        cin >> s >> v;
        A[i].suit = B[i].suit = s[0];
        A[i].val = B[i].val = v;
    }

    msort(A, n, 0, n);
    qsort(B, n, 0, n - 1);

    int stable = 1;
    for (int i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) stable = 0;
    }

    cout << (stable ? "Stable" : "Not stable") << endl;
    for (int i = 0; i < n; i++) {
        cout << B[i].suit << " " << B[i].val << endl;
    }

    return 0;
}


Measured memory_bytes: 5424
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		int S = sc.nextInt();

		int count = 0;
		for (int x = 0; x <= K; x++) {
			for (int y = 0; y <= K; y++) {
				if (x + y > S) {
					break;
				}

				if (S - (x + y) <= K) {
					count++;
					// debug(x, y);
				}
			}
		}

		System.out.println(count);
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 8528
#include <iostream>
#include <set>
#include <string>
#include <vector>
#include <algorithm>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;

int facto(int x) {
	int ans = 1;
	rep(i, 2, x + 1)ans *= i;
	return ans;
}

int main(void)
{
	int N; cin >> N;
	vector<int> P(N), Q(N);
	rep(i, 0, N)cin >> P[i];
	rep(i, 0, N)cin >> Q[i];
	int judge = 0;
	int count = 0;

	while (true) {
		if (P != Q) {
			if (next_permutation(P.begin(), P.end()) == false)judge++;
			count++;
		}
		else break;
	}
	int co = facto(N) - count;
	//cout << co << endl;
	//cout << judge << endl;
	int ans = min(count, co);
	ans = judge==0 ? count : co;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define prq priority_queue
#define foreach(it,c) for(__typeof((c).begin()) it=c.begin();it!=c.end();it++)
//#define KEY_DOWN(VK_NONAME) ((GetAsyncKeyState(VK_NONAME) & 0x8000) ? 1:0)
using namespace std;
inline ll read(){
	ll x=0;
	int f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-')f=-f;
	for(;isdigit(c);c=getchar())x=x*10+(c-'0');
	return x*f;
}
inline void out(int x){
	if(x>=10)out(x/10);
	putchar(x%10+'0');
}
int n,m,k,a[101010],b[101010],x,y,c;
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>n>>m>>k;
	fo(i,0,n)cin>>a[i];
	fo(i,0,m)cin>>b[i];
	int ans=1e9;
	fo(i,0,k){
		cin>>x>>y>>c;
		ans=min(ans,a[x-1]+b[y-1]-c);
	}
	sort(a,a+n);
	sort(b,b+m);
	cout<<min(ans,a[0]+b[0])<<endl;
	return 0;
}

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

int a[3];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 0; i < 2; ++i) {
        int now;
        cin >> now;
        a[now - 1]++;
    }
    for (int i = 0; i < 3; ++i) {
        if (!a[i]) {
            cout << i + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Mon May 13 21:30:18 2019

@author: avina
"""

s = input().strip()
a = int(s[:4]); b = int(s[5:7]);c = int(s[8:])
f = 2019 - a + (4 - b)//100 + (30 - c)//10000
if f >=0:
  print('Heisei')
else:
  print('TBD')

Measured memory_bytes: 3060
# after listening explanation
dp = []
105.times{
  arr = []
  4.times{ arr << Array.new(2, 0) }
  dp << arr
}
s = gets.chomp.chars.map(&:to_i)
n = s.length
K = gets.to_i
dp[0][0][0] = 1
n.times{|i| 4.times{|j| 2.times{|k|
  nd = s[i]
  10.times{|d|
    ni = i+1
    nj = j
    nk = k
    nj+=1 if d != 0
    next if nj > K
    if k == 0
      next if d > nd
      nk = 1 if d < nd
    end
    dp[ni][nj][nk] += dp[i][j][k]
  }
}}}
ans = dp[n][K][0] + dp[n][K][1]
p ans


Measured memory_bytes: 1788
import fractions
a,b,c,d=map(int,input().split())
count=0
e=(c*d)//fractions.gcd(c,d)
D=[c,d,e]
f=[]

for i in D:
  f.append((b//i)-((a-1)//i))
print(b-a+1-f[0]-f[1]+f[2])

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

using namespace std;

int main() 
{
    string s;
    cin>>s;
    int n=s.length(),i;
    string s1="",s2="";
    for(i=0;i<(n-1)/2;i++)
        s1+=s[i];
    for(i=(n+3)/2-1;i<n;i++)
        s2+=s[i];
    
    string t=s,t1=s1,t2=s2;
    
    reverse(t1.begin(),t1.end());
    reverse(t2.begin(),t2.end());
    reverse(t.begin(),t.end());
    
    if(s==t && s1==t1 && s2==t2)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

  cout << (a/2) * ((a+1)/2) << endl;

  


}

Measured memory_bytes: 256
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N = lread();
    auto A = aryread();
    long[long] cnt;
    foreach (a; A)
    {
        cnt[a] = cnt.get(a, 0) + 1;
    }
    long s;
    foreach (key, value; cnt)
    {
        s += value * (value - 1) / 2;
    }
    // writeln(cnt);
    foreach (a; A)
    {
        writeln(s - (cnt[a] * (cnt[a] - 1) / 2) + ((cnt[a] - 1) * (cnt[a] - 2) / 2));
    }
}


Measured memory_bytes: 19392