akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int		main(void)
{
	// int sunuke[101];
	int Aarray[10010];
	int i, j, N, K, d, ar_idx, tmp;
	int num_ct = 0;

	ar_idx = 0;
	scanf("%d %d", &N, &K);
	for (i = 0; i < K * 2; i++)
	{
		if (i % 2 == 0)
		{
			scanf ("%d", &d);
		}
		else
		{
			for (j = 0; j < d; j++)
			{
				scanf("%d", &Aarray[ar_idx + j]);
			}
			ar_idx += j;
		}
	}

	for (i=0; i<ar_idx; ++i) {
	    for (j=i+1; j<ar_idx; ++j) {
	      if (Aarray[i] > Aarray[j]) {
	        tmp =  Aarray[i];
	        Aarray[i] = Aarray[j];
	        Aarray[j] = tmp;
	      }
	    }
	}

	tmp = Aarray[0];
	num_ct++;
	// sunuke[num_ct] = Aarray[0];
	for (i = 1; i < ar_idx; i++)
	{
		if (tmp != Aarray[i])
		{
			num_ct++;
			// sunuke[num_ct] = Aarray[i];
		}
		tmp = Aarray[i];
	}
	printf("%d",N - num_ct);
	// for (i = 0; i < ar_idx; i++)
	// {
	// 	printf("%d", Aarray[i]);
	// }

	return (0);
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int A,B,C,X,Y; cin >> A >> B>> C >> X >> Y;
    int Z;
    int ans = 0;
    if(X > Y) Z = Y; else Z = X;
    if(C*2 > (A+B)) ans+= X*A+Y*B;
    else {
        if(A>C*2) A = C*2;
        if(B>C*2) B = C*2;
        ans+=Z*(C*2) + (X-Z)*A + (Y-Z)*B;
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC67();
}

void ABC67(){
    int n,k,i,sum=0;
    cin>>n>>k;
    vector<int> vec(n);
    for(i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    for(i=0;i<k;i++){
        sum+=vec[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import math

A,B,H,M = map(int,input().split())

H_ang = (H*60 + M)*0.5
M_ang = M*6

ang = M_ang - H_ang

ans = A**2 + B**2 - 2*A*B*math.cos(math.radians(ang))

print(math.sqrt(ans))


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

int main() {
	int n;
	cin >> n;
	rep(i, n+1) {
		int rest = n - i * 100;
		if (0 <= rest && rest <= 5 * i) {
			puts("1");
			return 0;
		}
		if (rest < 0)break;
	}
	puts("0");
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


A = read_matrix(3)

import numpy as np
A = np.array(A)
idx_dict = {}
for i in range(3):
    for j in range(3):
        idx_dict[A[i, j]] = (i, j)
N = read_a_int()
B = read_col(N, 1)[0]

for b in B:
    if b not in idx_dict.keys():
        continue
    i, j = idx_dict[b]
    A[i, j] = -1

# print(A)
cnt = 0
for i in range(3):
    if (A[:, i] == -1).sum() == 3:
        print('Yes')
        exit()
    if (A[i, :] == -1).sum() == 3:
        print('Yes')
        exit()
    cnt += A[i, i] == -1

if cnt == 3:
    print('Yes')
    exit()

if A[0, 1] == -1 and A[1, 1] == -1 and A[2, 0] == -1:
    print('Yes')
    exit()

print('No')


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    vector<int>cnt(4);

    rep(i,n){
        string S;
        cin>>S;

        if(S=="AC")cnt[0]++;
        else if(S=="WA")cnt[1]++;
        else if(S=="TLE")cnt[2]++;
        else if(S=="RE")cnt[3]++;
    }

    cout<<"AC x "<<cnt[0]<<endl;
    cout<<"WA x "<<cnt[1]<<endl;
    cout<<"TLE x "<<cnt[2]<<endl;
    cout<<"RE x "<<cnt[3]<<endl;
}


Measured memory_bytes: 3624
import itertools
from collections import defaultdict
import collections
mod = 1000000007
n, k = map(int, input().split())

s = [i for i in range(n + 1)]
cumsum = itertools.accumulate(s)
cumsum = list(cumsum)

ans = 0
for i in range(k, n + 1):
    a = cumsum[i - 1] - cumsum[0]
    b = cumsum[n] - cumsum[n - i]
    ans += (b - a + 1) % mod

print((ans + 1) % mod)

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

    #define int long long

    #define REP(i,n) for(int i=0;i<n;i++)
    #define FOR(i,m,n) for(int i=m;i<n;i++)
    #define FORR(i,m,n) for(int i=m;i>=n;i--)
    #define pb(x) push_back(x) 
    #define SORT(x) sort((x).begin(),(x).end())
    #define INF 99999999999

    using namespace std;

    int srch(int n){
        if(n<0) return INF;
        if(n==0) return 0;

        int p=6;
        while(n>=p){
            p*=6;
        }
        p/=6;
        int q=9;
        while(n>=q){
            q*=9;
        }
        q/=9;

        return min(srch(n-p), srch(n-q)) + 1;
    }

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

        int ans=srch(n);

        cout << ans << endl;
    }

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;cin >> N;

    vector<ll> a(N),b(N);
    rep(i,N){
      cin >> a[i];
      b[i] = a[i];
    }

    sort(ALL(a));

    map<ll,ll> mp;
    rep(i,N){
      mp[a[i]]++;
    }

    ll ans = 0;

    for(auto i: mp){
      ans += i.second * (i.second-1) / 2;
    }

    rep(i,N){
      ll t = b[i];

      ll tmp = ans;

      ll y = mp[b[i]];  
      
      tmp -= y * (y-1) / 2;
      tmp += (y-1) * (y-2) / 2;

      cout << tmp << endl;
    }

    
  

}


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

int main(){
  int n, y; cin >> n >> y;
  for(int i = 0; i <= n; i++){
  for(int j = 0; i+j <= n; j++){
  
  	if(10000*i+5000*j+1000*(n-i-j) == y){
    	cout << i << " " << j << " " << n-i-j << endl;
    	return 0;
    }
  }
  }
  
  cout << -1 << " " << -1 << " " << -1 << endl;
}

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

int freq[100][30];

int main(void)
{
	int n;
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
	{
		string S;
		cin >> S;
		for(int j = 0;j < int(S.size());j++) freq[i][int(S[j]-'a')]++;
	}

	for(int i = 0;i < 26;i++)
	{
		int res = 100;
		for(int j = 0;j < n;j++) res = min(res, freq[j][i]);

		for(int j = 0;j < res;j++) cout << char('a'+i);
	}
	cout << "\n";
}

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

int main() {

	int n, m, X, Y; cin >> n >> m >> X >> Y;
	vector<int> x(n), y(m);
	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> y[i];
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	bool war = true;
	for (int z = X + 1; z <= Y; z++) {
		if (x[n - 1] < z && z <= y[0]) war = false;
	}
	if (war) cout << "War" << endl;
	else cout << "No War" << endl;
	return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <climits>
using namespace std;
const int MAX_N=1<<17;
const int INF=INT_MAX;
int n,seg[2*MAX_N-1];
void init(int n_){
  n=1;
  for(;n<n_;) n*=2;
  fill(seg,seg+2*n-1,INT_MAX);
}
void update(int k,int a){
  k+=n-1;
  seg[k]=a;
  for(;k>0;){
    k=(k-1)/2;
    seg[k]=min(seg[k*2+1],seg[k*2+2]);
  }
}
int query(int a,int b,int k=0,int l=0,int r=n){
  if(r<=a||b<=l) return INF;
  if(a<=l&&r<=b) return seg[k];
  int vl=query(a,b,2*k+1,l,(l+r)/2);
  int vr=query(a,b,2*k+2,(l+r)/2,r);
  return min(vl,vr);
}
signed main(){
  int q;
  cin>>n>>q;
  init(n);
  for(int i=0;i<q;i++){
    int a,b,c;
    cin>>a>>b>>c;
    if(a) cout<<query(b,c+1)<<endl;
    else update(b,c);
  }
  return 0;
}


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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int a, b;
    cin >> a >> b;
    cout << max({a+b, a-b, a*b}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define	INF	0x3f3f3f3f
#define	LL	long long
#define	MAXN	100010
using namespace std;
LL minn, tot;
int n, size[MAXN], fa[MAXN], F[MAXN];
struct info{LL w; int id;}a[MAXN];

bool operator < (info a, info b){
	return a.w < b.w;
}

template <typename T> void chkmin(T &x, T y){x = min(x, y);}
template <typename T> void chkmax(T &x, T y){x = max(x, y);}
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

int find(int x){
	if (fa[x] == x) return fa[x];
	else return (fa[x] = find(fa[x]));
}

int merge(int x, int y){
	int fx = find(x), fy = find(y);
	if (fx == fy) return 0;
	fa[fx] = fy;
	return 1;
}

int main(){
	read(n);
	minn = 1ll * INF * INF;
	for (int i = 1; i <= n; ++i){
		read(a[i].w), a[i].id = i;
		chkmin(minn, a[i].w);
	}
	for (int i = 1; i <= n; ++i)
		size[i] = 1, fa[i] = i;
	sort(a + 1, a + 1 + n);
	for (int i = n; i > 1; --i){
		int cur = a[i].id;
		LL vf = a[i].w + 2 * size[cur] - n;
		//printf("%d %lld\n", cur, vf);
		if (vf <= 0) {printf("-1\n"); return 0;}
		int f = lower_bound(a + 1, a + 1 + n, (info){vf, 0}) - a;
		if (a[f].w != vf) {printf("-1\n"); return 0;}
		f = a[f].id;
		//printf("%d\n", f);
		int fla = merge(cur, f);
		if (!fla) {printf("-1\n"); return 0;}
		F[cur] = f;
		size[f] += size[cur];
		tot += size[cur];
	}
	if (tot != a[1].w) {printf("-1\n"); return 0;}
	for (int i = 2; i <= n; ++i)
		printf("%d %d\n", a[i].id, F[a[i].id]);
	return 0;
}

Measured memory_bytes: 4096
require 'pp'

n = gets.chomp!.to_i
v_n = gets.chomp!.split(" ").map(&:to_i)
c_n = gets.chomp!.split(" ").map(&:to_i)

puts n.times.inject(0) {|sum, i| sum += [v_n[i] - c_n[i], 0].max }


Measured memory_bytes: 2172
/*
TASK: <Task>
LANG: C++
*/
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define EPS 1e-9
#define ALL(x) (x).begin(),(x).end()
#define mp(x,y) make_pair((x),(y))
#define pb(x) push_back((x))
#define FOR(i,st,ed) for(int (i)=(st);(i)<(ed);(i)++)
typedef pair<int,int> PII;
typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long LL;

int N,M,T;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("xxx.in","r",stdin);
    //freopen("xxx.out","w",stdout);
    int i,j,k;
    int x,a,b;
    cin >> x >> a >> b;
    if(abs(x-a)<abs(x-b))
        cout << "A\n";
    else
        cout << "B\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int n,m,used[101010],cmp[101010];
vector<int> v[101010],rv[101010],vs;

void dfs(int x){
   used[x]=true;
   for(auto to:v[x])if(!used[to])dfs(to);
   vs.push_back(x);
}

void rdfs(int x,int k){
   used[x]=true;
   cmp[x]=k;
   for(auto to:rv[x])if(!used[to])rdfs(to,k);
}

int scc(){
   rep(i,n)if(!used[i])dfs(i);
   rep(i,n)used[i]=0;
   reverse(vs.begin(),vs.end());
   int k=0;
   for(auto x:vs)if(!used[x])rdfs(x,k++);
   return k;
}
int main(){
    cin>>n>>m;
    rep(i,m){
        int s,t;
        cin>>s>>t;
        v[s].push_back(t);
        rv[t].push_back(s);
    }
    scc();
    int q;
    cin>>q;
    rep(i,q){
        int s,t;
        cin>>s>>t;
        cout<<(cmp[s]==cmp[t])<<endl;
    }
    return 0;
}


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=200010;
int n,m,a[N];
ll k;
bool st[N];
int main()
{
	cin>>n>>k;
	k++;
	for(int i=1;i<=n;i++) cin>>a[i];
	vector<int> ve;
	int pos=1;
	while(!st[pos])
	{
		ve.push_back(pos);
		st[pos]=1;
		pos=a[pos];
	}
//	for(int i=0;i<ve.size();i++) cout<<ve[i]<<' ';
//	cout<<endl;
	int l,len;
	for(int i=0;i<ve.size();i++)
		if(ve[i]==pos)
		{
			l=i;
			break;
		}
	len=ve.size()-l;
	if(k>ve.size())
	{
		k-=ve.size();
		k%=len;
		if(k==0) cout<<ve[ve.size()-1];
		else
			cout<<ve[k+l-1];
	}
	else cout<<ve[k-1];
	return 0;
}


Measured memory_bytes: 5228
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n;i++)
ll d[300][300],v, n, c, e, u, k, sum = 0,ans;
int main(void) {
    ll a, b, c, sum = 0;
    cin >> c >> a >> b;
    if ((a + b) % 2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define FOR(i,n) for(int i=0;i<(int)N;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

inline lli getint(){
    lli n;
    scanf("%lld",&n);
    return n;
}

inline vector<lli> getints(int n){
    vector<lli> a(n);
    for(int i=0;i<n;i++)scanf("%lld",&a[i]);
    return a;
}

void dumpints(vector<lli> a){
  cout<<"[";
  for(int i=0;i<a.size()-1;i++){
    cout<<a[i]<<",";
  }
  cout<<a[a.size()-1]<<"]"<<endl;
}

template<class T> bool ifinclude(vector<T> a,T x){
    auto itr=find(a.begin(),a.end(),x);
    return distance(a.begin(),itr)!=a.size();
}

int main(void){
  lli N=getint();
  vector<lli> digits;
  while(N>0){
    digits.push_back(N%10);
    N/=10;
  }
  bool flag=true;
  for(int i=digits.size()-2;i>=0;i--){
    if(digits[i]!=9)flag=false;
  }
  cout<<digits[digits.size()-1]+9*(digits.size()-1)-(flag?0:1)<<endl;
  return 0;
}


Measured memory_bytes: 256
/*
2020-04-20
atcoder ABC
C - Sum of gcd of Tuples (Easy)
*/

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

int main() {
    //変数定義, 入力処理
    // vector<vector<int>> data(3, vector<int>(4)); //二次元配列
    int N;
    long long all_sum = 0;
    cin >> N;
    map<int , long long> ball_num_counts;
    vector<int> a_array(N);
    
    

    rep(i, N) {
        int A;
        cin >> A;
        a_array.at(i) = A;
        ball_num_counts[A] = ball_num_counts[A] + 1;
    }

    for (pair<int, long long> p : ball_num_counts) {
        all_sum += (p.second - 1 ) * p.second / 2;
    }

    rep(i, N) {
        long long sum_ans = 0;
        sum_ans = all_sum - ball_num_counts.at(a_array.at(i)) + 1;
        cout << sum_ans << endl;
    }
    return 0;
}


Measured memory_bytes: 10240
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <list>

using namespace std;

#define fi first
#define se second
#define long long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

long n, p = 1e9+7;
long dp[5003][5003];
long sum[5003];
long f(long x, long y)
{
	if(x == y) return 1;
	else if(x < y || x == 0 || y == 0) return 0;
	else if(dp[x][y]) return dp[x][y];
	else return dp[x][y] = (y*f(x-1, y) + f(x-1,y-1))%p;
}

long xxx[5003][5003];
long C(long x, long y)
{
	if(x == 0 && y == 0) return 1;
	else if(x < y || y < 0) return 0;
	else if(xxx[x][y]) return xxx[x][y];
	else return xxx[x][y] = (C(x-1,y)+C(x-1,y-1))%p;
}

long pw(long x, long y, long mod)
{
	if(y == 0) return 1;
	else if(y&1) return (pw(x,y-1,mod)*x)%mod;
	else
	{
		long temp = pw(x,y/2,mod);
		return (temp*temp)%mod;
	}
}

long s(long x, long y)
{
	long res = 0;
	for(int i = y; i <= x; i++)
	{
		res += (C(x,i)*f(i,y))%p;
		res %= p;
	}
	return res;
}
void print()
{
	for(int i = 0; i <= 10; i++)
	{
		for(int j = 0; j <= i; j++)
			printf("%lld " , s(i,j));
		printf("\n");
	}
}

int main()
{
    // ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);
	// print();
	scanf("%lld %lld", &n, &p);
	long res = 0;
	for(int i = 0; i <= n; i++)
	{
		long temp = (C(n,i)*pw(2,pw(2,n-i,p-1),p))%p;
		long temp2 = 0;
		for(int j = 0; j <= i; j++)
		{
			temp2 += ((f(i+1,j+1))*pw(2, j*(n-i),p))%p;
			temp2 %= p;
		}
		temp = (temp*temp2)%p;
		// printf("%lld %lld\n", temp2, temp);
		if(i&1) res -= temp;
		else res += temp;
		res %= p;
	}
	printf("%lld\n", (res+p)%p);
}


Measured memory_bytes: 236160
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int k;
    cin >> k;
    ll res = 0;
    rep(a, 1, k+1)
        rep(b, 1, k+1)
            rep(c, 1, k+1)
                res += __gcd(a, __gcd(b,c));
    cout << res;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int nax = 1e5 + 10;

int main() {
  long long ary[3][nax];
  int n;

  cin >> n;
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < n; j++) {
      cin >> ary[i][j];
    }
  }

  sort(ary[0], ary[0] + n);
  sort(ary[2], ary[2] + n);
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long a = lower_bound(ary[0], ary[0] + n, ary[1][i]) - ary[0];
    long long b = (ary[2] + n) - upper_bound(ary[2], ary[2] + n, ary[1][i]);
    sum += a * b;
  }


  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
map<P,int> ma;

signed main(){
  int h,w,n;
  cin>>h>>w>>n;
  int ans[10]={},sum=0;
  for(int cn=0;cn<n;cn++){
    int a,b;
    cin>>a>>b;
    for(int i=-1;i<2;i++){
      for(int j=-1;j<2;j++){
	int x=a+i,y=b+j;
	if(x<2||h-1<x)continue;
	if(y<2||w-1<y)continue;
	ma[P(x,y)]++;
      }
    }
  }
  for(map<P,int>::iterator it=ma.begin();it!=ma.end();it++){
    ans[(*it).second]++;
    sum++;
  }
  cout<<(w-2)*(h-2)-sum<<endl;
  for(int i=1;i<10;i++)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 58496
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define Rep(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define SORT(v) sort(all(v))
#define RSORT(v) sort(rall(v))
#define SUM(v) accumulate(all(v),0)
#define tget(tp,idx) get<idx>(tp)
#define TF(flag) (flag)?1:0
#define yn(f) cout<<(f?"yes":"no")<<endl
#define Yn(f) cout<<(f?"Yes":"No")<<endl
#define YN(f) cout<<(f?"YES":"NO")<<endl
#define COUT(x) cout<<(x)<<endl
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

constexpr int MOD=1e9+7;

int main(void){
  int a,b,c,d; cin>>a>>b>>c>>d; Yn((abs(a-b)<=d&&abs(b-c)<=d)||(abs(a-c)<=d));
}













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

int main(){
  int N;
  cin >> N;
  
  double T,A;
  cin >> T >> A;
  
  vector<double> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  
  double dis=0;
  double min_d=1000000;
  int point=1;
  for(int i=0; i<N; i++){
    double ave = T - H.at(i)*0.006;
    /*if(A<0 && ave>=0){
      dis = abs(A + ave);
    }else{*/
      dis = abs(A - ave);
    //}
    if(dis < min_d){
      min_d=dis;
      point = i+1;
    }
  }
  cout << point << endl;  
  return 0;
}


Measured memory_bytes: 256
m,a[9][2],S[9999];
D(d,s){
	if(d==m){S[s]++;return;}
	int i=0;for(;i<=a[d][1];i++)D(d+1,s+i*a[d][0]);
}
main(i){for(;scanf("%d",&m),m;){
	for(i=0;i<m;i++)scanf("%d%d",a[i],a[i]+1);
	memset(S,0,sizeof(S));D(0,0);
	for(scanf("%d",&i);i;i--)scanf("%d",&m),printf("%d\n",S[m]);
}exit(0);}

Measured memory_bytes: 640
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;

inline void add(int&x,int y){x+=y;while(x>=mod)x-=mod;}
inline void add(int&x,LL y){x=(x+y)%mod;}

int n,a[444],b[444],f[444][155],num[444][444],dp[155][444][444];

bool have[444];
int main()
{
	get1(n);
	for(int i=1;i<=n;i++)get1(a[i]);
	for(int i=1;i<=n;i++)get1(b[i]);
	f[1][1]=1;
	for(int i=1;i<n;i++)for(int j=1;j<=n/3;j++)
	{
		if(j<n/3)add(f[i+1][j+1],f[i][j]);
		if(i<j*3)add(f[i+1][j],1ll*f[i][j]*(j*3-i));
	}
	for(int i=0;i<=n;i++)
	{
		memset(have,0,sizeof(have));
		for(int j=1;j<=i;j++)have[a[j]]=1;
		num[i][0]=i;
		for(int j=1;j<=n;j++)
		{
			num[i][j]=num[i][j-1];
			if(!have[b[j]])num[i][j]++;
		}
	}
	for(int i=1;i<=n;i++)for(int j=1;j<=n;j++)dp[1][i][j]=(a[1]!=b[1]);
	for(int i=2;i<=n/3;i++)
	{
		for(int ta=i;ta<=i*3;ta++)for(int tb=i;tb<=i*3;tb++)
		{
			if(num[ta][tb]!=num[ta-1][tb-1]+2)continue;
			dp[i][ta][tb]=1ll*dp[i-1][ta-1][tb-1]*(3*i-num[ta][tb])%mod;
		}
		for(int ta=i;ta<=n;ta++)for(int tb=i;tb<=n;tb++)
		{
			add(dp[i][ta][tb],dp[i][ta][tb-1]);
			add(dp[i][ta][tb],dp[i][ta-1][tb]);
			add(dp[i][ta][tb],mod-dp[i][ta-1][tb-1]);
		}
	}
	printendl(1ll*dp[n/3][n][n]*f[n][n/3]%mod);
	return 0;
}

Measured memory_bytes: 104832
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
string s[60];
bool black[60][60];
bool ans=true;
int main(){
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++){
 cin>>s[i];
 for(int j=0;j<k;j++){
  if(s[i][j]=='.')
   black[i][j]=false;
  else
   black[i][j]=true;
 }
}
for(int i=0;i<n;i++)
 for(int j=0;j<k;j++){
  int cnt=0;
  if(black[i][j]==1){
   if(black[i+1][j]==0 && i+1<n && j<k)
    cnt++;
   if(black[i][j+1]==0 && i<n && j+1<k)
    cnt++;
   if(black[i-1][j]==0 && i>=0 && j-1>=0)
    cnt++;
   if(black[i][j-1]==0 && i-1>=0 && j>=0)
    cnt++;
  }
  if(cnt==4)
   ans=false;
 }
if(ans)
cout<<"Yes";
else
cout<<"No";
system("pause");
return 0;
}

Measured memory_bytes: 504
use std::ascii::AsciiExt;
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let s: String = line
        .trim()
        .split_whitespace()
        .map(|x| x.chars().nth(0).unwrap().to_ascii_uppercase())
        .collect();
    println!("{}", s);
}


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

int main(){
  int n; cin >> n;
  int w[n];
  for(int i=0; i<n; ++i) cin >> w[i];
  
  int s1 = 0, s2 = 0;
  for(int i=0; i<n; ++i) s2 += w[i];
  
  int ms = s2;
  for(int i=0; i<n; ++i){
    s1 += w[i];
    s2 -= w[i];
    if(ms > abs(s1 - s2)) ms = abs(s1 - s2);
  }
  
  cout << ms << endl;
  return 0;
}

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

void solve(){
	
	int n ;
	cin>>n ;

	vector<int> v(n) ;

	rep(i,n){
		cin>>v[i] ;
	}

	stack<int> st ;

	int answer=0 ;

	rep(i,n){

		if(i==0)
		{	st.push(v[i]) ;
		 	continue ;
		}

		if(v[i]<=st.top()){
			st.push(v[i]) ;
		}
		else{

			answer=max((int)st.size(),answer) ;

			while(!st.empty()){
				st.pop() ;
			}

			st.push(v[i]) ;

		}
	}

	answer=max((int)st.size(),answer) ;

	cout<<answer-1 ;

}


int main(){

	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

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

using namespace std;

int n, q;

int linear_search(int *S, int *T, int num);

int main() {

   
    cin >> n;

    int S[n+1];
    for(int i = 0; i<n; i++){
        cin >> S[i];
    }
    cin >> q;
    //cout <<"q: " << q << endl;
    
    int T[q];
    for(int i = 0; i < q; i++){
        cin >> T[i];
        //cout << T[i];
    }

    int num = -1;

    num = linear_search(S,T, num);
    
    //cout << "num:" << num << endl;
    cout << num << endl;

    return 0;
}

int linear_search(int *S, int *T, int num){
    num = 0;
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(T[i] == S[j]){
                //printf("(j, S[j]) =  (%d, %d)  ", j, S[j]);
                //printf("(i, T[i]) =  (%d, %d) ", i, T[i]);
                //cout << endl;
                num = num + 1;
                break;
            }
        }
    }
    return num;
}


Measured memory_bytes: 3112
#include<stdio.h>

int main(){
  int x,i;
  int max,min;
  long sum=0;
  scanf("%d",&x);
  int a[x];
  for(i=0;i<x;i++){
    scanf("%d ",&a[i]);
    sum = sum+a[i];
    if(i==0){
      max=a[i];
      min=a[i];
    }
    if(max<a[i]){
      max=a[i];
    }
    if(min>a[i]){
      min=a[i];
    }
  }
  printf("%d %d %ld\n",min,max,sum);
  return 0;
}

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

double N;

int main() {
  ios_base::sync_with_stdio(0);
  cin >> N;
  cout << fixed;
  cout << setprecision(10) << (N / 3.0) * (N / 3.0) * (N / 3.0) << "\n";
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  string a, b; readV(a, b);

  auto n = (a ~ b).to!int;
  writeln(n.nsqrt^^2 == n ? "Yes" : "No");
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = 1 << (n.bsr/2+1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc159_c
{
    class Program
    {
        static void Main(string[] args)
        {
            var L = CIn.ReadInt();
            var i = (double)L / 3;
            var ans = Math.Pow(i, 3);
            Console.WriteLine(ans);
        }
    }
}
class CIn
{
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
        if (fieldBuffer.Count == 0)
        {
            foreach (var field in Console.ReadLine().Split())
            {
                fieldBuffer.Enqueue(field);
            }
        }

        return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(long n)
    {
        var array = new string[n];

        for (var i = 0; i < n; i++)
        {
            array[i] = Read();
        }

        return array;
    }

    public static int[] ReadIntArray(long n)
    {
        var array = new int[n];

        for (var i = 0; i < n; i++)
        {
            array[i] = ReadInt();
        }

        return array;
    }

    public static long[] ReadLongArray(long n)
    {
        var array = new long[n];

        for (var i = 0; i < n; i++)
        {
            array[i] = ReadLong();
        }

        return array;
    }
    public static double[] ReadDoubleArray(long n)
    {
        var array = new double[n];

        for (var i = 0; i < n; i++)
        {
            array[i] = ReadDouble();
        }

        return array;
    }
}



Measured memory_bytes: 11220
sx,sy,tx,ty=map(int,input().split())
s=[]
dis_x=abs(tx-sx)
dis_y=abs(ty-sy)
for i in range(dis_x):
  s.append('R')
for i in range(dis_y):
  s.append('U')
for i in range(dis_x):
  s.append('L')
for i in range(dis_y):
  s.append('D')
s.append('L')
for i in range(dis_y+1):
  s.append('U')
for i in range(dis_x+1):
  s.append('R')
s.append('D')
s.append('R')
for i in range(dis_y+1):
  s.append('D')
for i in range(dis_x+1):
  s.append('L')
s.append('U')

print(''.join(s))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include <cstdio>   
#define pb          push_back 
#define endl        "\n"
#define mostrar(x,y) cout<<x<<" "<<y<<endl;
#define f           first
#define s           second
#define mod         1000000007
#define EPS         1e-9
using namespace std;
typedef pair<int,int> ii;
typedef pair<pair<int,int>,int> iii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;

 
int main(){
    ofstream out("output.txt");


    double w,h,x,y;
    cin>>w>>h>>x>>y;

    double mitad = (w*h)/2;
    cout<<setprecision(6)<<fixed<<mitad<<" ";

    if((w/2) == x && (h/2) == y) cout<<1<<endl;
    else                        cout<<0<<endl;

    return 0;
}


Measured memory_bytes: 256
from math import gcd
 
N = int(input())
mod = 10 ** 9 + 7 # 1000000007
 
d = dict()
zeros = 0
for _ in range(N):
  a, b = map(int, input().split()) # Ai, Bi
  # どちらか一方でも0であれば特殊なケースとなる
  # 下記のd[p]でd[(0, 0)]のような形になるため分ける(zeros)
  # d[(0, 0)]同士では組み合わせが作れないため、単純に+1していく
  if not any((a,b)):
    zeros += 1
    continue
  if all((a, b)):
    g = gcd(a, b) * (a//abs(a)) # //は切り捨て除算
  elif a:
    g = a
  else:
    g = b
  p = a//g, b//g # p is (tuple)
  d[p] = d.get(p, 0) + 1 # count

ans = 1 # 掛け算するため0ではなく1としておき、最後の出力時に1を引くようにする
done = set()
for (a,b), val in d.items():
  if (-b, a) in done or (b, -a) in done: # if already counted, then continue
    continue
  done.add((a, b))
  w = d.get((-b, a), 0) + d.get((b, -a), 0)
  # (a, b)とそれに垂直な(-b, a), (b, -a)のそれぞれの組み合わせを足す
  # そして何も選ばなかったときの場合を引くため、最後に-1とする
  ans *= (pow(2, val) + pow(2, w) -1)
  ans %= mod

print((ans + zeros -1) % mod)

Measured memory_bytes: 72176
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cctype>

using namespace std;

int main(){
    int N;
    cin >> N;
    long a[N];
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a,a+N);

    int result = 0;
    int now = a[0];
    int count = 0;
    for(int i = 0; i < N; i++){
        if(now == a[i]){
            count++;
        }else{
            if(count > now){
                result += (count-now);
            }else if(count < now){
                result += count;
            }
            now = a[i];
            count = 1;
        }
    }

    if(count > now){
        result += (count-now);
    }else if(count < now){
        result += count;
    }

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

int ans;
int c[4][4];


int main(void) {
    rep(i, 1, 4) rep(j, 1, 4) scanf("%d", &c[i][j]);
    
    rep(i, 0, c[1][1]+1) {
      int a[4], b[4];
      a[1] = i;
      rep(j, 1, 4) b[j] = c[1][j] - a[1];
      a[2] = c[2][1] - b[1];
      a[3] = c[3][1] - b[1];
      
      bool ok = true;
      rep(j, 2, 4) rep(k, 2, 4) {
        if (c[j][k] != a[j] + b[k]) ok = false;
      }
      if (ok) {
        puts("Yes");
        return 0;
      }
      
    }

    puts("No");
    return 0;
}


Measured memory_bytes: 256
s = input()
f = False
c = 0
cand = [0]
for item in s + "*":
    if not f and item in ["A", "T", "G", "C"]:
        f = True
        c = 1
        continue
    if f:
        if item in ["A", "T", "G", "C"]:
            c += 1
        else:
            cand.append(c)
            c = 0
            f = False
print(max(cand))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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



	int N,M;
	cin >> N >> M;


	int kotae = 2 * M - N;
	co(kotae);

	Would you please return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int main(void){
char S[200];
bool a=true;  
scanf("%s", S);
for(int i=0;i<strlen(S);i++){
    if((i%2==0) && (S[i]!='R' && S[i]!='U' && S[i]!='D') ){
        a=false;
    }else if((i%2==1) && (S[i]!='L' && S[i]!='U' && S[i]!='D') ){
        a=false;
    }
}
if(a==true){
    printf("Yes\n");
}else{
    printf("No\n");
}
return 0;
}

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

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

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>

#define MAX_N 200'001
#define INF 1'000'000'000'000'000'000

typedef long long ll;

using namespace std;

ll A[MAX_N];
ll _A[MAX_N];

int main() {
  int N;
  cin >> N;
  ll L = 0;
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    L += A[i];
  }
  ll res = INF;
  _A[0] = 0;
  for (int i = 0; i < N - 1; ++i) {
    _A[i + 1] = _A[i] + A[i];
    res = min(res, abs(_A[i + 1] - L + _A[i + 1]));
  }
  printf("%lld\n", res);
}

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

int main(){
    string l = "qwertasdfgzxcvb";
    string s;
    while(cin >> s && s != "#"){
        bool left = count(l.begin(), l.end(), s[0]);
        int cnt = 0;
        for(int i = 1; i < s.length(); i++){
            if(count(l.begin(), l.end(), s[i]) != left){
                cnt++;
                left = !left;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
from operator import itemgetter, attrgetter
N, *A = map(int, open(0).read().split())
*A, = zip(*[iter(A)]*2)

if N % 2 == 0:
    A.sort()
    mid_l = A[N//2-1][0]+A[N//2][0]
    A.sort(key=itemgetter(1))
    mid_r = A[N//2-1][1]+A[N//2][1]
    print(mid_r - mid_l+1)
else:
    A.sort()
    mid_l = A[N//2][0]
    A.sort(key=itemgetter(1))

    mid_r = A[N//2][1]
    print(mid_r - mid_l+1)


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

 int main() {
   int a, b, c; cin  >> a >> b >> c;
   string res = "Yes";
   if ((a == b && b == c) || (a != b && a != c && b != c)) {
     res = "No";
   }
   cout << res << "\n";
 }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const string NAME = "Choncap";
const int N = 202020;
#define ll long long
ll n, m, k, a[N];

//dem xem co bao nhieu cap a[i]*a[j] <= X
ll dem(ll X)
{
    ll cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (a[i] < 0)
        {
            int d = 1, c = n, vt = n + 1, mid;
            while (d <= c)
            {
                mid = (d + c) >> 1;
                if (a[i] * a[mid] <= X)
                    vt = mid, c = mid - 1;
                else
                    d = mid + 1;
            }
            cnt += n - vt + 1;
        }
        else
        {
            int d = 1, c = n, vt = 0, mid;
            while (d <= c)
            {
                mid = (d + c) >> 1;
                if (a[i] * a[mid] <= X)
                    vt = mid, d = mid + 1;
                else
                    c = mid - 1;
            }
            cnt += vt;
        }
        if (a[i] * a[i] <= X)
            cnt--;
    }
    cnt /= 2; //chia 2 vi cac cap deu duoc tinh hai lan
    return cnt;
}
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    sort(a + 1, a + 1 + n);
    ll d = -1e18, c = 1e18, ans, mid;
    while (d <= c)
    {
        mid = (d + c) / 2;
        if (dem(mid) >= k)
            ans = mid, c = mid - 1;
        else
            d = mid + 1;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1920
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,k,a[MAXN];
vector<int> G[MAXN];
int deg[MAXN];
vector<int> leaf;
int res[MAXN];
vector<int> v;
bool used[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v); G[v].push_back(u);
        deg[u]++; deg[v]++;
    }
    memset(used,false,sizeof(used));
    for(int i=1;i<=n;i++) if(deg[i]==1) leaf.push_back(i);
    for(int i=1;i<=n;i++)
    {
        int x; scanf("%d",&x);
        v.push_back(x);
    }
    int ans=0;
    sort(v.begin(),v.end(),greater<int>());
    for(int i=1;i<=n;i++)
    {
        assert(leaf.size());
        int u=leaf.back();
        if(i!=n) ans+=v.back();
        res[leaf.back()]=v.back();
        leaf.pop_back(); v.pop_back();
        used[u]=true;
        for(auto to:G[u])
        {
            deg[to]--;
            if(deg[to]==1) leaf.push_back(to);
        }
    }
    printf("%d\n",ans);
    for(int i=1;i<=n;i++) printf("%d ",res[i]);
    return 0;
}



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

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

    const int v = 1000000000;

    int x = (v-s%v)%v;
    int y = (s+x)/v;

    cout << "0 0 1000000000 1 " << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n == 0: break
    a = [int(input()) for _ in range(n)]
    k = int(input())
    l, r, c = 0, n-1, 0
    while l <= r:
        c += 1
        m = (l+r) >> 1
        if k == a[m]:
            break
        elif k < a[m]:
            r = m-1
        else:
            l = m+1
    print(c)
    
    


Measured memory_bytes: 5604
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans=0;
  cin>>a>>b;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])  ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
if n>=2 and m>=2:#中心部
	ans = (n-2)*(m-2)
else:
	ans = 0

if m==1:#外周
	ans += (n-2)
if n==1:
	ans += (m-2)
	
if n*m==3:
	print('2')
elif n*m==2:
	print('0')
elif n*m==1:
	print('1')
else:
	print(ans)

Measured memory_bytes: 3064
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])
dp = [0]*(n+1)
dp[0] = 1
dp[1] = (0 if 1 in a else 1)
for i in range(2,n+1):
    if i in a:continue
    dp[i] = (dp[i-1]+dp[i-2])%1000000007
print(dp[n])

Measured memory_bytes: 13192
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=300150;
///
int mod=1000000007;


int main()
{
//    SPEED;
//    mem(dp,-1);
    int t,tc=1;
//    sf(t);
    t=1;

    while(t--)
    {
        int n;
        sf(n);
        string s;
        cin>>s;
        int ans=0;
        int c=0;
        int i=0;
        while(i<n && s[i]=='R')
        {
            i++;
        }
        while(i<n)
        {
            if(s[i]=='R')
                c++;
            i++;
        }
        ans=c;
        c=0;
        i=n-1;
        while(i>=0 && s[i]=='W')
        {
            i--;
        }
        while(i>=0)
        {
            if(s[i]=='W')
                c++;
            i--;
        }
        c=0;
        int r=0,w=0;
        for(int j=0;j<n;j++)
        {
            if(s[j]=='W')
                w++;
            else
                r++;
        }
//        cout<<r<<" and "<<w<<endl;
        for(int i=0;i<r;i++)
        {
            if(s[i]=='W')
                c++;
        }

        ans=min(ans,c);
        cout<<ans<<endl;

    }


    return 0;
}



Measured memory_bytes: 3812