akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double A[] = new double[N];
		for(int i = 0 ; i < N ; ++i){
			A[i] = sc.nextDouble();
		}
		Arrays.sort(A);
		for(int i = 0 ; i < N - 1 ; ++i){
			double next = (A[i] + A[i + 1]) / 2.0;
			A[i + 1] = next;
		}
		System.out.println(A[N - 1]);
	}
}


Measured memory_bytes: 23380
import math
n = sorted(list(map(int,input().split())))
n[1] %= (10**9 + 7)
n[0] %= (10**9 + 7)
if n[1] - n[0] >= 2:
    ans = 0
elif n[1] - n[0] == 0:
    ans = math.factorial(n[1]) **2 * 2
else:
    ans = n[1] * math.factorial(n[0])**2
print(ans % (10**9 + 7) )

Measured memory_bytes: 4736
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define ll long long
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define SIZE 1000000007
using namespace std;
typedef vector<ll> vl;
int gcd(int a, int b){return (a == 0) ? b : gcd(b%a, a);}
/*ios_base::sync_with_stdio(false);cin.tie(0);*/



int main (){
    ios_base::sync_with_stdio(false);cin.tie(0);
    ll n;
    cin >> n;
    vl vec;
    while(n--){
        ll k;
        cin>>k;
        vec.pb(k);

    }
    ll count = 0;
    for(ll i = 0 ; i < vec.size()-2;i++){
        if((vec[i]>vec[i+1] && vec[i+1]>vec[i+2])||(vec[i]<vec[i+1] && vec[i+1]<vec[i+2])){count++;}
    }
    cout<<count;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	// input
	var tmp string
	fmt.Scan(&tmp)

	// configuration
	count := 0
	ans := 0

	// check
	for i := 0; i < len(tmp); i++ {
		if string(tmp[i]) == "R" {
			count++
			ans = count
		} else {
			ans = max(ans, count)
			count = 0
		}
	}

	// output
	fmt.Println(ans)

}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}


Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define wi(t) int t;cin>>t;while(t--)
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
ll int gcd(ll int a, ll int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
int tc=1;
void solve()
    { 
        double d,s,t;
        cin>>d>>t>>s;
        if((double)d/s<=(double)t)
        {
            cout<<"Yes";
        }
        else
        {
            cout<<"No";
        }
        
    }

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    //wi(t)
    {
      solve();
    }

    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}







Measured memory_bytes: 10780
#include <stdio.h>
#include<string.h>
int main(){
  
   char str[100] ;
   scanf("%s",&str);
    char str2[100];
   scanf("%s",&str2);
   int temp = 0 , temp2 = 0 ,count = 0  ,i ,j ;
   if(strlen(str) !=strlen(str2)){
       printf("No");
   }else{
       for(i = 0 ; i<strlen(str) ; i++){
           if(strcmp(str,str2) != 0){
               for(j = 0 ; j<strlen(str);j++){
                   temp2 = temp ;
                   temp = str[j];
                   if(j == 0){
                       
                       str[j] = str[strlen(str)-1];
                   }else{
                       str[j] = temp2 ;
                   }
               }
               //printf("%s\n",str);
           }else{
               count++;
           }
       }
       if(count!=0){
           printf("Yes");
           
       }else{
           printf("No");
       }
   }
}

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

int main(){
int n;
cin >> n;
if (n%2==0){cout << "0.5";}
else cout << (n+1.0)/2.0/(n+0.0);
}

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<int> A(N);
    int M = 0;
    for(int i = 0; i < N; i++){
        A.at(i) = L + (i + 1) - 1;
        M += A.at(i);
    }
    int d, j;
    for(int i = 0; i < N; i++){
        if(i == 0){
            if(A.at(i) < 0){
                d = A.at(i) * -1;
                j = 0;
                continue;
            }
            else{
                d = A.at(i);
                j = 1;
                continue;
            }
        }
        if(A.at(i) < 0){
            d = min(d, A.at(i) * -1);
            j = 0;
        }
        else{
            d = min(d, A.at(i));
            j = 1;
        }
    }
    if(j == 0){
        cout << M - (d * -1);
    }
    else{
        cout << M - d;
    }
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    if m > n * 2 {
        let rem = m - n * 2;
        println!("{}", n + rem / 4);
    } else {
        println!("{}", m / 2);
    }
}


Measured memory_bytes: 4352
#include <climits>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <cassert>

#define dprintf(...)

using namespace std;

long long solve(long long n, long long m, vector<pair<long long, long long> > &abs) {
    sort(abs.begin(), abs.end());
    long long ans = 0;
    int bought = 0;

    for (auto l : abs) {
        dprintf("%lld %lld\n", l.first, l.second);
    }

    while (true) {
        if (abs[bought].second < m) {
            ans += abs[bought].first * abs[bought].second;
            m -= abs[bought].second;
        } else {
            ans += abs[bought].first * m;
            return ans;
        }
        bought++;
    }
}


int main() {
    int n, m;
    vector<pair<long long, long long> > abs;
    scanf(" %d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        int ai, bi;
        scanf(" %d %d", &ai, &bi);
        abs.push_back(pair<long long, long long>(ai, bi));
    }
    printf("%lld\n", solve(n, m, abs));
    return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return b;
    }
    return gcd(b, a % b);
}

int main()
{
    ll a, b;
    cin >> a >> b;

    bool even = (a * b) % 2 == 0;

    cout << (even ? "Even" : "Odd") << endl;
}

Measured memory_bytes: 256
/*
 * A087.cpp
 *
 *  Created on: Mar 3, 2018
 *      Author: tetsu
 */
#include <iostream>
using namespace std;

int main(void) {
	int x, a, b;
	cin >> x >> a >> b;
	x -= a;
	cout << x-b*(x/b) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a;
    cin >> a;
    if(a%2 == 0){
        cout << 0.5;
    }
    else
    {
        cout << double(a/2+1)/a; 
    }
    
    
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
tree = [{'parent': -1, 'left': -1, 'right': -1, 'sibling': -1} for _ in range(N)]
parent = set(n for n in range(N))

for _ in range(N):
    inp = [int(n) for n in input().split()]
    tree[inp[0]]['left'] = inp[1]
    tree[inp[0]]['right'] = inp[2]
    tree[inp[0]]['degree'] = sum([inp[1]!= -1, inp[2] != -1])

    if inp[1] != -1:
        tree[inp[1]]['parent'] = inp[0]
        tree[inp[1]]['sibling'] = inp[2]
    if inp[2] != -1:
        tree[inp[2]]['parent'] = inp[0]
        tree[inp[2]]['sibling'] = inp[1]

    parent = parent.difference(inp[1:])

def set_depth(n, depth):
    tree[n]['depth'] = depth

    if tree[n]['left'] != -1:
        set_depth(tree[n]['left'], depth+1)
    if tree[n]['right'] != -1:
        set_depth(tree[n]['right'], depth+1)

root = parent.pop()
set_depth(root, 0)

def set_height(n):
    h1 = 0
    h2 = 0
    if tree[n]['right'] != -1:
        h1 = set_height(tree[n]['right']) + 1
    if tree[n]['left'] != -1:
        h2 = set_height(tree[n]['left']) + 1
    
    tree[n]['height'] = max(h1, h2)
    return max(h1, h2)

set_height(root)

for n in range(N):
    if tree[n]['parent'] == -1:
        tree[n]['type'] = 'root'
    elif tree[n]['degree'] == 0:
        tree[n]['type'] = 'leaf'
    else:
        tree[n]['type'] = 'internal node'

    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}"\
        .format(n, tree[n]['parent'], tree[n]['sibling'], tree[n]['degree'], tree[n]['depth'], tree[n]['height'], tree[n]['type']))






# sibling がおかしい


Measured memory_bytes: 5628
# -*- coding: utf-8 -*-
# mathモジュールをインポート
import math
# 整数の入力
radius = int(input())
# スペース区切りの整数の入力
# b, c = map(int, input().split())
# 文字列の入力
# s = input()

result = radius * math.pi *2

# 出力
print(result)

Measured memory_bytes: 9156
import itertools


def main():
    n = input()
    b = input().split()
    c = input().split()

    b_comb = sorted(list(itertools.permutations(b)))
    c_comb = sorted(list(itertools.permutations(c)))
    for i in range(len(b_comb)):
        if b_comb[i] == tuple(b):
            p = i + 1
            break
    for i in range(len(c_comb)):
        if c_comb[i] == tuple(c):
            q = i + 1
            break 
    print(abs(p - q))


if __name__ == "__main__":
    main()


Measured memory_bytes: 13112
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define u128 __int128
#define pb push_back

#define N 100010
#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
   cout.precision(10);

   int n;
   cin >> n;
   double a[n];
   for (int i = 0; i < n; ++i)
   {
      cin >> a[i];
   }
   double sum = 0;
   for (int i = 0; i < n; ++i)
   {
      sum += (1 / a[i]);
   }
   cout << fixed << 1 / sum;
   return 0;	
}

      // while(b)
      // {
      //    if(b & 1)
      //    {
      //       an = (an * a);
            
      //       if(an > 1e18) 
      //          an /= 1e18;
      //    }
      //    a = (a * a);
      //    if(a > 1e18)
      //       a /= 1e18;
      //    b >>= 1;
      // }


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
  double a, b, C;
  cin >> a >> b >> C;
  C = C/360.0*2*M_PI;
  cout << fixed << setprecision(10) << a * b * sin(C) / 2 << endl;
  double c = sqrt(a*a+b*b-2*a*b*cos(C));
  cout << a + b + c << endl;
  cout << b * sin(C) << endl;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>

using namespace std;

int main(){

	int N;

	cin >> N;

	std::vector<int> V(N+1);
	std::vector<int> C(N+1);
	for (int i = 0; i < N; i++)
	 {
	 	cin >> V[i];
	 } 

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

	 std::vector<int> dif(N);

	 for (int i = 0; i < N; i++)
	 {
	 	dif[i] = V[i]-C[i];
	 }

	 int ans=0;

	 for (int i = 0; i < N; i++)
	 {
	 	if (dif[i] > 0)
	 	{
	 		ans += dif[i]; 
	 	}
	 }

	 cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
from collections import Counter

s = str(input())

c = Counter(s)
c_keys = c.keys()
c_value = c.values()

if (c['S'] > 0 and c['N'] > 0) or (c['S'] == 0 and c['N'] == 0):
    if (c['W'] > 0 and c['E'] > 0) or (c['W'] == 0 and c['E'] == 0):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 38256
#include <iostream>

using namespace std;

int main()
{
	int d;
	int area;
	
	while (cin >> d) {
		area = 0;
		for (int i=0; i<(600/d); i++) {
			area += i * i * d * d * d;
		}
		cout << area << endl;
	}
	
	return 0;
}

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


using namespace std ; 

const int N =3e3 + 7 , mod = 998244353; 

int n ,s ; 
int a[N] ; 
int dp[N][N] ;

int solve(int i , int r ){
        if(r > s) return 0 ;
        if(i == n){
                return (r ==s) ; 
        }
        if(dp[i][r] != -1) 
                return dp[i][r] ;
        int ret = 0 ; 
        ret = (ret + solve(i+1 , r+a[i] ) )%mod ; 
        ret = (ret + 2LL  * solve(i+1 , r)) %mod  ;
        return dp[i][r] = ret ; 
}

int main(){
        ios_base::sync_with_stdio(0) ; 
        cin.tie(0) ;
        memset(dp , -1 , sizeof dp) ; 
       // freopen("in.in" , "r" , stdin) ; 
        cin>>n>>s ; 
        for(int i = 0 ;i < n;i++){
                cin>>a[i] ; 
        }
        cout<< solve(0 , 0) ; 
        return 0 ; 
}

Measured memory_bytes: 39120
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

vector<vector<ll>> adj;
vector<ll> col;
vector<bool> used;

ll dfs(ll pos, bool& flag) {
	used[pos]=true;
	ll cnt=1;
	REP(i,adj[pos].size()) {
		if(used[adj[pos][i]]) {
			if(col[adj[pos][i]]==col[pos]) flag=true;
			continue;
		}
		col[adj[pos][i]]=!col[pos];
		cnt+=dfs(adj[pos][i],flag);
	}
	return cnt;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;
	cin>>n>>m;
	adj.resize(n);
	col.resize(n);
	used.resize(n);
	REP(i,n) col[i]=-1;
	REP(i,n) used[i]=false;
	REP(i,m) {
		ll u,v;
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	ll ans=0;
	ll gr1=0; // 二部でない
	ll gr2=0; // 二部
	ll gr3=0; // 孤立
	REP(i,n) {
		if(!used[i]) {
			bool d=false;
			col[i]=0;
			ll tmp=dfs(i,d);
			if(tmp==1) {
				gr3++;
			} else {
				if(d) gr1++;
				else gr2++;
			}
		}
	}
	ans+=gr3*n+n*gr3-gr3*gr3;
	ans+=gr1*(gr1+gr2)+(gr1+gr2)*gr1-gr1*gr1;
	ans+=2*gr2*gr2;
	cout<<ans<<endl;
}


Measured memory_bytes: 13312
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, s, n) for(int i = s; i < n; i++)
using namespace std;

int main(){
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> count(n+1, 0);
  char prev = '?';
  rep(i, n){
    int x = 0;
    if (prev == 'A' && s[i] == 'C') x = 1;
    count[i+1] = count[i] + x;
    prev = s[i];
  }
  
  rep(i, q){
    int l, r;
    cin >> l >> r;
    cout << count[r] - count[l] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+7;
int n,m,f[N],g[N],ans[N]; char s[N],t[N];
inline void write(int u){
	if(u>9) write(u/10); putchar(u%10+'0');
}
int main(){
	cin>>n; int a=1,b=1;
	for(int i=1;i<=n/2;i++) a=a*3;
	for(int i=n/2+1;i<=n;i++) b=b*3;
	for(int i=0;i<a*b;i++){
		f[i]=f[i/3]*3,g[i]=(g[i]+1)%(a*b);
		if(i%3==1) f[i]+=2; else if(i%3==2) f[i]++;
	}
	scanf("%s",s+1),m=strlen(s+1);
	for(int i=0;i<a;i++){
		int u=i; int len=0;
		for(int z=1;z<=m;z++)
			if(s[z]=='S'){
				u=f[u];
				if(t[len]=='S') len--; else t[++len]='S';
			}
			else if(s[z]=='R'){
				if(u+1==a) t[++len]='R',u=0;
				else u++;
			}
		int v=u;
		for(int x=0;x<b;x++){
			int u=x;
			for(int z=1;z<=len;z++)
			if(t[z]=='S') u=f[u];
			else if(t[z]=='R'){
				if(u+1==b) u=0;
				else u++;
			}
			ans[i+x*a]=u*a+v;
		}
	}
	for(int i=0;i<a*b;i++) write(ans[i]),putchar(' ');
}
//ac

Measured memory_bytes: 10404
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);	
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n;
int main(){
//	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	cout << n * n * n << endl;		
	return 0;
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool isprime(int x){
	for(int i = 2; i<x; i++){
		if(x%i==0){
			return false;
		}
	}
	return true;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int sum = 0;
	for(int i = 1; i<=n; i++){
		sum += i;
	}
	int div = 2;
	while(sum%div!=0){
		div++;
	}
	bool used[n+1];
	for(int i = 1; i<=n; i++){
		used[i] = false;
	}
	vector<int> li[div];
	for(int i = 0; i<div; i++){
		int cur = sum/div;
		int pnt = min(cur,n);
		while(pnt>0 && cur>0){
			if(!used[pnt]){
				used[pnt] = true;
				cur -= pnt;
				li[i].push_back(pnt);
			}
			pnt = min(pnt-1,cur);
		}
	}
	bool pr[n+1][n+1];

	for(int i = 1; i<=n; i++){
		if(!used[i]){
			assert(false);
		}
		for(int j = 1; j<=n; j++){
			pr[i][j] = j>i;
		}
	}
	for(int i = 0; i<div; i++){
		for(int a=0; a<li[i].size(); a++){
			for(int b = 0; b<li[i].size(); b++){
				pr[li[i][a]][li[i][b]] = false;
			}
		}
	}
	int tot = 0;
	for(int i = 1; i<=n; i++){
		for(int j = i+1; j<=n; j++){
			if(pr[i][j]){
				tot++;
			}
		}
	}
	cout << tot << endl;
	for(int i = 1; i<=n; i++){
		for(int j = i+1; j<=n; j++){
			if(pr[i][j]){
				cout << i << " " << j << endl;
			}
		}
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <vector>

using namespace std;

#define MAX_N 10010

int P[10010];
int F[1001];
int FF[1001];
int v;
int d;

void init(int N) { // 初期化 はじめは全ての頂点はバラバラ
	for (int i=0; i<N; ++i) P[i] = i;
}

int root(int a) { // a の root(代表元) を求める
	if (P[a] == a) return a; // aはroot
	return (P[a] = root(P[a])); // a の親の root を求め,a の親とする
	
}

bool is_same_set(int a, int b) { // a と b が同じグループに属するか?
	return root(a) == root(b);
}

void unite(int a, int b) { // a と b を同一グループにまとめる
	P[root(a)] = root(b);
}

int main()
{
	v = 0; d = 0;
	F[0] = 1; F[1] = 2;
	for(int i=2; i<1001; ++i){ F[i] = F[i-1] + F[i-2]; F[i] = F[i]%1001;}
	
	int count;
	
	while(cin >> v >> d){
		count =0;
		init(1001);
		for(int i=1; i<=v; ++i)
		{
			for(int j=i+1; j<=v; ++j)
			{
				if( abs(F[i]-F[j]) < d )
				{
					if(!is_same_set(i,j)){ unite(i,j); }
				}
			}
		}
		
		for(int i=1; i<=v; ++i){
			if(root(i) == i){ ++count; }
		}
		cout << count << endl;
	}

}

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

int main() {
  cin >> N;
  vector<int> d(N+1);
  for(int i=0; i<N; i++){
    cin >> d[i];
  }
  vector<int> max(200);
  
  for(int i=1; i<N; i++){
    if(d[i]>d[i-1]){
      int tmp = d[i];
      int j = 0;
      while(d[j]>d[i]){
        j++;
      }
      for(int k=i-1;k>=j;k--){
        d[k+1] = d[k];
      }
      d[j] = tmp;
    }
  }
    
    
  int ans = 1;
  for(int k=0;k<N;k++){
    if(d[k+1]!=d[k] && d[k+1]!=0){ans++;}
  }
   
  cout << ans;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        final Scanner sc = new Scanner(System.in);
        // 整数の入力
        // final int a = sc.nextInt();
        // 文字列の入力
        // final String s1 = sc.next();
        int varA = Integer.parseInt(sc.next());
        int result = varA + varA * varA + varA * varA * varA;
        sc.close();
        System.out.println(result);
    }
}

Measured memory_bytes: 35592
import java.util.*;
import java.io.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String x = sc.next();
		
		// 計算
		String result = "a";
		if(Character.isUpperCase(x.charAt(0))) result = "A";
		
		// 出力
		System.out.println(result);
	}
	
	public static class Scanner {
		private BufferedReader br; private StringTokenizer tok;
		public Scanner(InputStream is) throws IOException { br = new BufferedReader(new InputStreamReader(is));}
		private void getLine() throws IOException { while(!hasNext()) tok = new StringTokenizer(br.readLine());}
		private boolean hasNext() { return tok != null && tok.hasMoreTokens();}
		public String next() throws IOException { getLine(); return tok.nextToken();}
		public int nextInt() throws IOException { return Integer.parseInt(next());}
		public long nextLong() throws IOException { return Long.parseLong(next());}
		public double nextDouble() throws IOException { return Double.parseDouble(next());}
	}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define repit2(x) for (__typeof((x).begin()) it2 = (x).begin(); it2 != (x).end(); it2++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define Sort(v) sort(All(v))
#define SortR(v) sort(All(v), std::greater<__typeof(v[0])>())
#define SoArrt(a, n) sort(a, a + n);
#define SoArrtR(a, n) sort(a, a + n, std::greater<__typeof(a[0])>())

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    ll x;

	cin >> x;

	ll sum = 0LL;

	ll i;

	repi(i, LLONG_MAX, 1) {
		sum += i;

		if (x <= sum) {
			Out(i);

			return 0;
		}
	}
	
	return 0;
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ll a,b,c,x,ans=0;
    cin >> a >> b >> c >> x;
    rep(i,a+1){
        rep(j,b+1){
            rep(k,c+1){
                if(500*i + 100*j + 50*k == x)ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];
	if(n==1) {
		print("YES");
		return 0;
	}
	int sum=0;
	rep(i,n) sum+=a[i];
	int dd=n*(n+1)/2;
	if(sum%dd) {
		print("NO");
		return 0;
	}
	int k=sum/dd;
	std::vector<int> b(n);
	rep(i,n) {
		b[i]=a[(i+1)%n]-a[i];
		// b[i]=k-x-(n-1)*x
		if(k<b[i] || (k-b[i])%n) {
			print("NO");
			return 0;
		}
	}
	print("YES");
	return 0;
}


Measured memory_bytes: 1920
#include<math.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
int main()
{
	int n,i;
	scanf("%d",&n);
	
	for(i=1;i<=n;i++)
		if(i%10==3 || i%100/10==3 || i%1000/100==3 || i/1000==3 || i%3==0)
			printf(" %d",i);
	printf("\n");
	return 0;
}


Measured memory_bytes: 2120
day=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]
while true
	m,d=gets.chomp.split(" ").map{|s| s.to_i}
	break if m==0&&d==0
	count=2
	for i in (1..m-1) do
		if(i==2) then 
			count+=29
		elsif (i==4||i==6||i==9||i==11) then
			count+=30
		else
			count+=31
		end	
	end
	count+=d
	count%=7
	puts day[count]
end


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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll INF = 1LL << 40;
int N, M;
int a[2010], b[2010], c[2010];
ll dis[1010];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--, b[i]--;
    c[i] = -c[i];
  }
  fill(dis, dis + N, INF);
  dis[0] = 0;
  for (int i = 0; i < 2 * N; i++) {
    for (int j = 0; j < M; j++) {
      if (dis[b[j]] > dis[a[j]] + c[j]) {
        dis[b[j]] = dis[a[j]] + c[j];
        if (i >= N - 1 && b[j] == N - 1) {
          cout << "inf" << endl;
          return 0;
        }
      }
    }
  }
  cout << -dis[N - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))

n = int(input())
List = [input() for i in range(n)]
sort = sorted(List)
ans = 1
for i in range(1,n):
    if sort[i] != sort[i - 1]:
        ans += 1
print(ans)
#print(sort)


Measured memory_bytes: 25388
#include <stdio.h>
int main(void){
  int i=0,t;
  char s[201];
  scanf("%s",s);
  while (s[i]) i++;
  t=i/2-1;
  while (1){
    for (i=0;i<t;i++){
      if (s[i]!=s[i+t]) break;
    }
    if (i==t) break;
    t--;
  }
  printf("%d\n",t*2);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rrep(i, n) for(ll i = n - 1; i > -1; i--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define fi first
#define se second
#define debug(V) rep(i, V.size()) cout << V[i] << " ";
const ll INF = (1LL << 61) - 1;
const ll MOD = /*1000000007 */ 998244353;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, h, x, y, z, p, q, n, t, r, k, w, l, ans, i, j, u, v;
string S, T;
vl A, B;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

  public:
    u64 a;
    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
        a += rhs.a;
        if(a >= Modulus) {
            a -= Modulus;
        }
        return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
        if(a < rhs.a) {
            a += Modulus;
        }
        a -= rhs.a;
        return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
        a = a * rhs.a % Modulus;
        return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
        u64 exp = Modulus - 2;
        while(exp) {
            if(exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
};
using mint = modint<MOD>;
mint dp[301][90001], dp2[301][90001];
void input() {
    cin >> n;
    rep(i, n) {
        cin >> x;
        A.pb(x);
        a += x;
    }
    b = (a + 1) / 2;
}
void solve() {
    mint ans = 1;
    rep(i, n) { ans *= 3; }
    rep(i, n) {
        rep(j, 90001) {
            dp[i][j] = 0;
            dp2[i][j] = 0;
        }
    }
    dp[0][0] = 1;
    dp2[0][0] = 1;
    rep(i, n) {
        rep(j, 90001) {
            dp[i + 1][j] = dp[i][j] * 2;
            dp2[i + 1][j] = dp2[i][j];
            if(A[i] <= j) {
                dp[i + 1][j] += dp[i][j - A[i]];
                dp2[i + 1][j] += dp2[i][j - A[i]];
            }
            // cout << i << " " << j << " " << dp[i + 1][j].a << endl;
        }
    }
    // cout << a << endl;
    for(i = b; i < 90001; i++) {
        ans -= (dp[n][i]) * 3;
    }
    if(a % 2 == 0) {
        ans += (dp2[n][b]) * 3;
    }

    cout << ans.a << endl;
}
int main() {
    // cout<<fixed<<setprecision(15);
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}


Measured memory_bytes: 423552
local day = io.read("*n")
local c = {}
for i = 1, 26 do
  c[i] = io.read("*n")
end
local s = {}
for id = 1, day do
  s[id] = {}
  for i = 1, 26 do
    s[id][i] = io.read("*n")
  end
end

local function solve(t, debug)
  local cur = 0
  local lastday = {}
  for i = 1, 26 do lastday[i] = 0 end
  for id = 1, day do
    local pid = t[id]
    cur = cur + s[id][pid]
    lastday[pid] = id
    for i = 1, 26 do
      cur = cur - c[i] * (id - lastday[i])
    end
    if debug then print(cur) end
  end
  return cur
end
local t = {}
for id = 1, day do
  t[id] = 1 + (id % 26)
end
local score = solve(t)
math.randomseed(1)
local iter = 1
local random = math.random
while os.clock() < 1.85 do
  iter = iter + 1
  local changeday = random(1, 365)
  local changeto = random(1, 26)
  local changefrom = t[changeday]
  t[changeday] = changeto
  local tmp = solve(t)
  if score < tmp then
    score = tmp
  else
    t[changeday] = changefrom
  end
end
-- print(iter)
print(table.concat(t, "\n"))


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

void fnInput(vector<int>& rvnMaxHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMaxHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnMaxHeap[i];
}

void fnMaxHeapify(vector<int>& rvnMaxHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLrge = nx;

  if (nLeft < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLrge] < rvnMaxHeap[nLeft])  
    nLrge = nLeft;
  if (nRigt < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLrge] < rvnMaxHeap[nRigt])
    nLrge = nRigt;

  swap(rvnMaxHeap[nx], rvnMaxHeap[nLrge]);
  if (nx != nLrge)
    fnMaxHeapify(rvnMaxHeap, nLrge);
}

void fnMaximumHeap(vector<int>& rvnMaxHeap)
{
  for (int i = (rvnMaxHeap.size() - 1) / 2; i > 0; --i)
    fnMaxHeapify(rvnMaxHeap, i);
}

void fnResult(const vector<int>& cnrvnMaxHeap)
{
  for (int i = 1; i < cnrvnMaxHeap.size(); ++i)
    cout << " " << cnrvnMaxHeap[i];

  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnMaxHeap; 

  fnInput(vnMaxHeap);
  fnMaximumHeap(vnMaxHeap);
  fnResult(vnMaxHeap);
  return 0;
}

Measured memory_bytes: 4912
#include <iostream>
#include <climits>
using namespace std;
#define ll long long int
ll knapsac(ll w[], ll v[], ll n, ll weight, ll **dp){
    if(n==0 || weight==0){
        return 0;
    }
    if(dp[n][weight] !=-1){
        return dp[n][weight];
    }
    if(w[n-1] > weight){
        dp[n][weight] = knapsac(w, v, n-1, weight, dp);
        return dp[n][weight];
    }
    else{
        dp[n][weight] = max(v[n-1]+knapsac(w, v, n-1, weight-w[n-1], dp), knapsac(w, v, n-1, weight, dp));
        return dp[n][weight];
    }
}

int main() {
  int n,w;
  cin >> n >> w;
  
  ll *wei = new ll[n];
  ll *val = new ll[n];
  //ll maxw = INT_MIN;
  for(int i=0;i<n;i++){
  	cin >> wei[i];
    //maxw = max(maxw,wei[i]);
    cin >> val[i];
  }
  ll **dp = new ll*[n+1];
  for(int i=0;i<n+1;i++){
      dp[i] = new ll[w+1];
      for(int j=0;j<w+1;j++){
          dp[i][j] = -1;
      }
  }
  cout <<knapsac(wei, val, n, w, dp) << endl;
}


Measured memory_bytes: 79488
#include<bits/stdc++.h>
using namespace std;
int main()
{
	short a,b,c;
	cin>>a>>b>>c;
	if(c-b==b-a)
	{
		cout<<"YES";
		return 0;
	}
	else
	{
		cout<<"NO"; 
	}
	return 0;
}

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc077
// status: [solve][review]
// tag: [sort][binary_search]

#define SUBMIT
//#define DEBUG

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <queue>
#include <numeric>
#include <limits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_N = 100000;
int N;
int A[MAX_N], B[MAX_N], C[MAX_N];

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    auto program_input = std::string(R"(6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288
)");
    stringstream stream(program_input);
#endif
    stream >> N;
    for (int i = 0; i < N; ++i) stream >> A[i];
    for (int i = 0; i < N; ++i) stream >> B[i];
    for (int i = 0; i < N; ++i) stream >> C[i];

    sort(A, A + N);
    sort(B, B + N);
    sort(C, C + N);

    ui64 ans = 0;
    for (auto i = 0; i < N; ++i) {
        auto na = distance(A, lower_bound(A, A + N, B[i]));
        auto nc = N - distance(C, upper_bound(C, C + N, B[i]));
        ans += na * nc;
    }

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

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e18+10,mod=1e9+7,M2=1e6+10,M3=3e3+10;
int dp[M],d[M],d2[M],dp2[M];
bool mark[M];
vector<int>adj[M],edg[M];
set<pii>dij;
main()
{
	int n,m,s,e,a,b,w;
	cin>>n>>m;
	cin>>s>>e;
	for(int i=1;i<=m;i++)cin>>a>>b>>w,adj[a].pb(b),adj[b].pb(a),edg[a].pb(w),edg[b].pb(w);
	dij.insert(mp(0,s));
	for(int i=1;i<=n;i++)d[i]=inf;
	d[s]=0;
	dp[s]=1;
	while(dij.size())
	{
		pii now=*dij.begin();
		int v=now.S;
		//cout<<v<<"*****";
		mark[v]=1;
		dij.erase(now);
		for(int i=0;i<adj[v].size();i++)
		{
			int u=adj[v][i];
			if(mark[u])continue;
			dij.erase(mp(d[u],u));
			if(d[u]>d[v]+edg[v][i])dp[u]=dp[v],d[u]=d[v]+edg[v][i];
			else if(d[u]==d[v]+edg[v][i])dp[u]+=dp[v],dp[u]%=mod;
			dij.insert(mp(d[u],u));
		}
	}
	dij.clear();
	dij.insert(mp(0,e));
	for(int i=1;i<=n;i++)d2[i]=inf,mark[i]=0;
	d2[e]=0;
	dp2[e]=1;
	while(dij.size())
	{
		pii now=*dij.begin();
		int v=now.S;
		mark[v]=1;
		dij.erase(now);
		for(int i=0;i<adj[v].size();i++)
		{
			int u=adj[v][i];
			if(mark[u])continue;
			dij.erase(mp(d2[u],u));
			if(d2[u]>d2[v]+edg[v][i])dp2[u]=dp2[v],d2[u]=d2[v]+edg[v][i];
			else if(d2[u]==d2[v]+edg[v][i])dp2[u]+=dp2[v],dp2[u]%=mod;
			dij.insert(mp(d2[u],u));
		}
	}
	int ans=dp[e]*dp2[s];
	//cout<<dp[e]<<" "<<dp2[s]<<" ";
	ans%=mod;
	//cout<<ans<<" ";
	for(int i=1;i<=n;i++)
	{
		int v=i;
		if(d[i]+d2[i]==d[e] && d[i]==d2[i]){
			int tmp=dp[i]*dp2[i];
			//cout<<i<<" ";
			tmp%=mod;
			tmp*=tmp;
			tmp%=mod;
			ans-=tmp;
			ans+=mod;
			ans%=mod;
			continue;
		}
		//cout<<d[e]<<endl;
		for(int j=0;j<adj[i].size();j++)
		{
			int u=adj[i][j];
			w=edg[i][j];
			if(d[v]>d[u])continue;
			if(abs(d[v]-d2[u])<w && d[v]+d2[u]+w==d[e])
			{
				//cout<<v<<" ";
				int tmp=dp[v]*dp2[u];
				tmp%=mod;
				tmp*=tmp;
				tmp%=mod;
				ans-=tmp;
				ans+=mod;
				ans%=mod;
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 33000
n = int(input())
s = [int(input()) for i in range(n)]
st = sorted(s)
ans = [0]

sm1 = sum(s)
for i in range(len(st)):
    if sm1 % 10 != 0:
        ans.append(sm1)
        break
    else:
        sm1 -= st[i]
sm2 = sum(s)
for i in range(len(st)):
    if st[i] % 10 != 0:
        ans.append(sm2 - st[i])
        break
print(max(ans))

Measured memory_bytes: 9008
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
int a, b, c, d;
int main() {
	cin >> a >> b >> c >> d;
	for (int i = 0; a > 0 && c > 0; i ^= 1) {
		if (i== 0)c -= b;
		else a -= d;
	}
	if (a > 0)puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

string S; cin >> S;

if (S == "ABC") cout << "ARC\n";
else cout <<  "ABC\n";

return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3640
#include <stdio.h>

int A[100000];

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

int main(){
  int getnm, i, q;
  scanf("%d", &getnm);
  for(i = 0; i < getnm; i++) scanf("%d",&A[i]);
  q = partition(0, getnm-1);
  for(i = 0; i < getnm-1; i++){
    if(i == q) printf("[%d] ", A[i]);
    else printf("%d ", A[i]);
  }
  printf("%d\n", A[i]);

  return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);

  /* */
  int n;
  cin >> n;

  ll t, a;
  cin >> t >> a;
  for (int i = 1; i < n; ++i) {
    ll ti, ai;
    cin >> ti >> ai;

    auto n = std::max((a - 1) / ai, (t - 1) / ti) + 1;
    a = n * ai;
    t = n * ti;
  }
  cout << a + t << endl;
  /* */

  return EXIT_SUCCESS;
}


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

typedef long long ll;

ll r, D, x;
ll y[11];

int main() {
    cin >> r >> D >> y[0];
    for(int i = 1; i <= 10; i++) {
        y[i] = y[i-1] * r - D;
        cout << y[i] << endl;
    }
}

Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/problems/1160

A = []
w = 0
h = 0


def walk(i, j):
    global A
    stack = [(i, j)]
    while True:
        i, j = stack.pop()
        A[i][j] = 0
        for ii in range(i-1, i+2):
            for jj in range(j-1, j+2):
                if ii < 0 or h <= ii:
                    continue
                if jj < 0 or w <= jj:
                    continue
                if A[ii][jj] == 0:
                    continue
                else:
                    stack.append((ii, jj))

        if len(stack) == 0:
            break


if __name__ == "__main__":
    while True:
        w, h = map(int, input().split())
        if w == 0 and h == 0:
            break

        A = []
        for i in range(h):
            row = list(map(int, input().split()))
            A.append(row)

        cnt = 0
        for i in range(h):
            for j in range(w):
                if A[i][j] == 1:
                    cnt += 1
                    walk(i, j)

        print(cnt)



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

const int dx[]={-1,1,0,0};
const int dy[]={0,0,1,-1};
const int MAX_N =1002;
int H, W;
string g[MAX_N];
bool vis[MAX_N][MAX_N];

void solve()
{
	queue<pair<pair<int,int>,int>> que;
	for(int i=0;i<H;++i)for(int j=0;j<W;++j){
		if(g[i][j] == '#'){
			que.emplace(make_pair(i,j), 0);
			vis[i][j]=true;
		}
	}
	int ans = 0;
	while(!que.empty()){
		auto cur=que.front(); que.pop();
		int x = cur.first.first, y = cur.first.second;
		int z = cur.second;
		ans = max(ans, z);
		for(int i=0;i<4;++i){
			int nx=x+dx[i],ny=y+dy[i];
			if(nx>=0&&nx<H&&ny>=0&&ny<W&&!vis[nx][ny]){
			    vis[nx][ny]=true;
				que.emplace(make_pair(nx,ny), z+1);
			}
		}
	}
	cout << ans << '\n';
}

int main()
{	
	cin >> H >> W;
	for(int i=0;i<H;++i){
		cin >> g[i];
	}
	solve();
	return 0;
}

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

using namespace std;

int main(){
vector<int> a(5);
int x,y;cin>>x>>y;
	if(y%2==0 && x>=ceil(y*1.0/4) && x<=y/2)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}




Measured memory_bytes: 3620
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <random>
#include <utility>
#include <cmath>
#include <set>
#include <map>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
ll i,j,k;
ll n,m;
ll a[100005];
bool color[100005];
ll sum=0;
bool muri=false;
char s[5];
ll kazu=0;
ll h,w;
 
int main(){
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>s;
		for(j=0;j<w;j++){
			if(s[j]=='#')kazu++;
		}
	}
	if(kazu==h+w-1){
		cout<<"Possible"<<endl;
	}else{
		cout<<"Impossible"<<endl;
	}
	return 0;
}

Measured memory_bytes: 4992