akhauriyash/Code-Regression huggingface dataset:
/* -----------------------------------------------------------------------------
	AtCoder Beginner Contest 140
	D - Face Produces Unhappiness
	g++ bc140D.cpp

----------------------------------------------------------------------------- */
#include <cstdio>
#include <algorithm>

using namespace std;

#define STR_MAX 100005


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N, K;
char s[STR_MAX];
int r;


int main () {
	int N;
	int cnt = 0;
	int run = 1;

	// 長さと回数の読込み
	scanf("%d %d", &N, &K);
	// 数列 B
	scanf("%s", s);

	
	// 初期状態の満足度
	for(int i = 0; i < N; i++) {
		if(s[i] == 'L') { cnt += i > 0 ? s[i-1] == 'L' : 0; }
		if(s[i] == 'R') { cnt += i < N - 1 ? s[i+1] == 'R' : 0; }

		if(s[i] == 'R' && s[i+1] == 'L') run++;
		if(s[i] == 'L' && s[i+1] == 'R') run++;
	}

	if(run / 2 <= K) cnt += run - 1;
	else cnt += 2 * K;
;
	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 256
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);

    auto g = a.sort!"a > b".group.array;
    long[2] stick;
    int cnt;
    foreach (x; g)
    {
        if (x[1] > 1)
        {
            stick[cnt] = x[0];
            ++cnt;

            if (cnt == 1 && x[1] > 3)
            {
                stick[cnt] = x[0];
                ++cnt;
            }
        }

        if (cnt > 1) break;
    }

    stick.reduce!((x, y) => x * y).writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }
const int Maxn = 1e5 + 5;
int D,len;
ll ans,res,d,pw[20],num[20];
int main()
{
	pw[0]=1;
	for(int i=1;i<=18;i++)
		pw[i]=pw[i-1]*10;
	rg ll tmp;
	cin>>D;
	if(D%9)
	{
		puts("0");
		return 0;
	}
	D/=9;
	tmp=D;
	while(tmp)
	{
		len++;
		tmp/=10;
	}
	for(int i=max(len,2);i<=2*len;i++)
	{
		memset(num,0,sizeof(num));
		tmp=(pw[i-1]-1)/9;
		d=D+tmp;
		num[i]=1;
		for(int j=1;j<=i/2;j++)
		{
			if(d<0)
			{
				num[i-j+1]=(-d)%10;
				d=(d+tmp*num[i-j+1])/10;
			}
			else 
			{
				num[j]=d%10;
				d=(d-tmp*num[j])/10;
			}
			tmp/=100;
		}
		if(d)
			continue;
		res=1;
		for(int j=1;j<=(i+1)/2;j++)
			res*=9-max(num[j],num[i-j+1])+min(num[j],num[i-j+1])+(j!=1);
		ans+=res;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)


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

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {
	
	int a[3];
	int sum= 0;

	rep(i, 3) {
		cin >> a[i];
		sum += a[i];
	}

	int b[3];
	b[0] = sum - a[0];
	b[1] = sum - a[1];
	b[2] = sum - a[2];

	pr(min(b[0], min(b[1], b[2])));


	return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,left;
    scanf("%d %d", &n,&m);
    int mod = n/500;
    if(n% 500 == 0)
        printf("Yes\n");
    else if(mod != 0)
    {
        left = n - (mod*500);
        if(left <= m)
            printf("Yes\n");
        else
            printf("No\n");
    }
    else if(m>=n)
        printf("Yes\n");
}


Measured memory_bytes: 1644
n = int(input())
a = 0
w = 0
t = 0
r = 0

for i in range(n):
    x = str(input())
    if x == "AC":
        a = a + 1
    elif x == "WA":
        w = w + 1
    elif x == "TLE":
        t = t + 1
    elif x == "RE":
        r = r + 1

print("AC x " +str(a))
print("WA x " +str(w))
print("TLE x " +str(t))
print("RE x " +str(r))

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

#define ll long long int 

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

    vector<int> v(3);
    for(auto &it:v)
        cin >> it;
    sort(v.begin(),v.end());
    cout << 0.5*v[0]*v[1] << '\n';

    return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n;
int e1[105][105];
int main(){
  scanf("%d",&n);
  for (int i = 0; i < n; i++) {
    int u,k;
    scanf("%d%d",&u,&k);
    u--;
    for(int j = 0; j < k; j++){
      int a;
      scanf("%d",&a);
      a--;
      e1[u][a] = 1;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      printf("%d",e1[i][j]);
      if(j!=n-1) printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 3228
import sys
readline = sys.stdin.readline
INF = 10 ** 10


def main():
    N, M = map(int, readline().rstrip().split())
    C = list(map(int, readline().rstrip().split()))
    dp = [INF] * (N + 1)
    dp[0] = 0
    for c in C:
        for i in range(c, N+1):
            dp[i] = min(dp[i], dp[i-c] + 1)
    
    print(dp[N])


if __name__ == '__main__':
    main()


Measured memory_bytes: 7516
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();
		int ans = 0;
		for (int i = line[0]; i <= line[1]; i++) {
			if (i % line[2] == 0) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 36036
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    for (int i = n; ; i++) {
        string s = to_string(i);
        if (s[0] == s[1] && s[1] == s[2]) {
            cout << i << "\n";
            return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main(args: Array<String>) {
    val n = readLong()
    val mod = 1000000007L

    var ans = ((10L.powMod(n, mod) + 8L.powMod(n, mod)) % mod - 9L.powMod(n, mod) * 2 % mod) % mod
    if (ans < 0) ans += mod
    println(ans)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)


fun Long.powMod(k: Long, mod: Long): Long {
    var r = 1L
    var n = this
    var kk = k
    while (kk > 0) {
        if (kk and 1 == 1L) {
            r = (r * n) % mod
        }
        n = (n * n) % mod
        kk = kk shr 1
    }
    return r
}

Measured memory_bytes: 34408
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n; cin >> n;
    vi a(n),b(n-1);
    rep(i,n-1) cin >> b[i];
    a[0] = b[0];
    rep(i,n-1) a[i+1] = min(b[i+1],b[i]);
    a[n-1] = b[n-2];
    cout << accumulate(all(a),0LL) << endl;
    return 0;
}


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

using namespace std;

#define     ll long long
#define     nl '\n'
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define     mod             100000000
#define     space           500005

vector<ll> pwx(61);
void cal(ll x){ pwx[0] = 1; for(ll i = 1; i < 61 ; i++)pwx[i] = x*pwx[i-1]; }

int main(){
    // boost;
    
    // cal(2);

    ll n, m, k, sum = 0, ans = 0;
    cin >> n >> m >> k;

    vector<ll> a(n), b(m);

    for(ll i = 0 ; i < n ; i++){
        cin >> a[i];
        if(i)
            a[i] += a[i-1];
    }

    for(ll i = 0 ; i < m ; i++){
        cin >> b[i];
        if(i)
            b[i] += b[i-1];
    }
    // b.push_back(2e18);
    auto tmp = upper_bound(b.begin(), b.end(), k);
    ans = tmp - b.begin();

    for(ll i = 0 ; i < n ; i++){
        if(k - a[i] < 0)
            continue;
        auto it = upper_bound(b.begin(), b.end(), k - a[i]);
        ans = max(it - b.begin() + i + 1, ans);
    }

    cout << ans << nl;

    return 0;
}

Measured memory_bytes: 6432
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>

using namespace std;

int larger(int x, int y){
	if(x > y){
		return x;
	}
	return y;
}

int main(){
	int N;
	cin >> N;
	map<string, int> blue;
	string keylist[N];
	int keyindex = 0;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		if(blue.find(s) == blue.end()){
			blue.insert(make_pair(s, 1));
			keylist[keyindex] = s;
			keyindex++;
		}
		else{
			blue[s] += 1;
		}
	}
	int M;
	cin >> M;
	map<string, int> red;
	for(int i = 0; i < M; i++){
		string s;
		cin >> s;
		if(red.find(s) == red.end()){
			red.insert(make_pair(s, 1));
		}
		else{
			red[s] += 1;
		}
	}
	int max = 0;
	for(int i = 0; i < blue.size(); i++){
		int score = blue[keylist[i]];
		if(red.find(keylist[i]) != red.end()){
			score -= red[keylist[i]];
		}
		if(max < score){
			max = score;
		}
	}
	cout << max << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 1000000007
#define INF 1000000000000000
using ppp=pair<ll,pair<int,int>>;

int main(){
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    if(i*108/100==N){
      cout<<i<<endl;
      break;
    }else if(i*108/100>N){
      cout<<":("<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N;
   cin >> N;
   string S;
   int x = 0;
   int y = 0;
   int z = 0;
   int ans = 0;
   for (int i = 0; i < N; i++) {
      cin >> S;
      // cout << S << endl;
      int len = S.size();
      if (S[0] != 'B' && S[len - 1] == 'A') x++;
      if (S[0] == 'B' && S[len - 1] == 'A') y++;
      if (S[0] == 'B' && S[len - 1] != 'A') z++;
      char tmp = S[0];
      for (int j = 1; j < len; j++) {
         if (tmp == 'A' && S[j] == 'B') ans++;
         tmp = S[j];
      }
      // cout << x << " " << y << " " << z << endl;
   }
   // cout << ans << endl;
   ans += min(x, z);
   if (x == 0 && z == 0) ans += max(0, y - 1);
   else if (x == 0 && z > 0) ans += y;
   else if (x > 0 && z == 0) ans += y;
   else if (x > 0 && z > 0) ans += y;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer[] L = new Integer[N];
        for (int i=0; i<N; i++) {
            L[i] = scanner.nextInt();
        }
        Arrays.sort(L, Comparator.reverseOrder());

        int count = 0;
        int a = 0;
        int b = 1;
        int c = 2;
        while (true) {
            if (isTriangle(L[a], L[b], L[c])) {
                count++;
            }
            if ((c + 1) < N) {
                c++;
            } else {
                if ((b + 2) < N) {
                    b++;
                    c = b + 1;
                    continue;
                } else if ((a + 3) < N) {
                    a++;
                    b = a + 1;
                    c = b + 1;
                    continue;
                }
                break;
            }
        }

        System.out.println(count);
    }

    private static boolean isTriangle(int a, int b, int c) {
        if (a >= b + c) return false;
        if (b >= a + c) return false;
        if (c >= a + b) return false;
        return true;
    }
}


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

int gcd(int a, int b) {
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  int K, p, q, r;
  long result = 0;
  cin >> K;
  for (p = 1; p <= K; p++) {
    for (q = 1; q <= K; q++) {
      for (r = 1; r <= K; r++) {
        // cout << result << endl;
        result += gcd(p, gcd(q, r));
      }
    }
  }
  cout << result << endl;
}

Measured memory_bytes: 3636
import numpy as np

N = int(input())

A_l = np.array(list(map(int, input().split())))

num_dict = {}

for num in A_l:
    if num not in num_dict:
        num_dict[num] = 1
    else:
        num_dict[num] += 1

sum_all = 0

for num in num_dict.values():
    sum_all += num*(num-1)/2


for i in range(N):
    ans = sum_all - (num_dict[A_l[i]] - 1)
    print(int(ans))


Measured memory_bytes: 34140
#include <bits/stdc++.h>
using namespace std;
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int r,d,x;
long long int xp(long long int i,long long int xi);
int main(){
  cin >> r >> d >> x;
  xp(0,x);
}

long long int xp(long long int i,long long int xi){
  int ans = r*xi-d;
  cout << ans << endl;
  if(i < 9)xp(i+1,ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

#define MAX_N 100000

struct UnionFind{
    ll par[MAX_N]; // 親
    ll rank[MAX_N]; // 木の深さ
    ll siz[MAX_N]; // 素集合のサイズ

    // n要素で初期化
    void init(ll n){
        for(ll i=0;i<n;i++){
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }

    // 木の根を求める
    ll root(ll x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }

    // xとyの属する集合を併合
    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x==y) return false; // 併合失敗
        if(rank[x] < rank[y]){
            par[x] = y;
            siz[y] += siz[x];
        }else{
            par[y] = x;
            siz[x] += siz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
        return true; // 併合成功
    }

    bool issame(ll x, ll y){
        return root(x)==root(y);
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

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

    UnionFind uf;
    uf.init(n);

    rep(i, m){
        int x, y, z;
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }  

    set<int> s;
    rep(i, n){
        s.insert(uf.root(i));
    }

    cout << s.size() << endl;
    // printf("%d\n", N);
    return 0;
}


Measured memory_bytes: 7296
import math

n,m = map(int, input().rstrip().split())

value = 0
s = [-1] * n

for i in range(m) :
    si,ci = map(int,input().rstrip().split())
    if s[si-1] == -1 :
        s[si-1] = ci
    elif s[si-1] != ci :
        value = -1
        break
    else :
        continue

if s[0] == 0 and n > 1:
    value = -1

for i in range(n) :
    if s[i] == -1 :
      if i == 0 and n > 1:
        s[i] = 1
      else :
        s[i] = 0 
if value != -1 :
    for i in range(n) :
        value = value * 10 + s[i] 
print(value)

Measured memory_bytes: 3064
//set many funcs
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define inf 1072114514
#define llinf 1145141919810364364
#define mod 1000000007

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}

int main(void){
    int n,m,f[131072]={0},c[131072],i,x,y,r=0;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++){c[i]=1;}
    f[1]=1;
    for(i=1;i<=m;i++){scanf("%d%d",&x,&y);
        c[x]--;c[y]++;
        if(f[x]){f[y]=1;}
        if(c[x] == 0){f[x]=0;}
    }
    for(i=1;i<=n;i++){
        if(c[i] && f[i]){r++;}
    }
    printf("%d\n",r);
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	fb := make([]int,n+1)
	
	for i := 0; i < n+1; i++ {
		if !(i % 3 == 0 || i % 5 == 0) {
			fb[i] = i
		}
	}

	sum := 0
	for i, _ := range fb {
			sum += fb[i]
	}
	fmt.Println(sum)
}

Measured memory_bytes: 9880
n = int(input())
al=[]
bl=[]
for i in range(n):
    a , b = map(int, input().split())
    al.append(a)
    bl.append(b)
al.sort()
bl.sort()
if n%2==1:
    mi = al[n//2]
    ma = bl[n//2]
    print(int(ma-mi)+1)
else:
    mi = (al[n//2-1]+al[n//2])/2
    ma = (bl[n//2-1]+bl[n//2])/2
    print(int((ma-mi)*2+1))


Measured memory_bytes: 25436
n = int(input())
S = input()

w_count = [0] * (n+1)
e_count = [0] * (n+1)

e = 0
w = 0
for i, s in enumerate(S):
    if s == 'E':
        e += 1
    elif s == 'W':
        w += 1

    w_count[i] = w
    e_count[i] = e

ans = 10**6
for i in range(n):
    w_on_my_left = w_count[i-1]
    e_on_my_right = e - e_count[i]
    candidate = w_on_my_left + e_on_my_right
    ans = min(ans, candidate)

print(ans)


Measured memory_bytes: 17568
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, Q;
	cin >> n >> Q;
	vector<queue<int>> q(n);
	VI print;
	rep(i, Q) {
		int cos; cin >> cos;
		if (cos == 0) {
			int t, x; cin >> t >> x;
			q[t].push(x);
		}
		else if (cos == 1) {
			int t; cin >> t;
			if (!q[t].empty())print.pb(q[t].front());
		}
		else if (cos == 2) {
			int t; cin >> t;
			if (!q[t].empty())q[t].pop();
		}
	}
	for (auto a : print) {
		cout << a << endl;
	}
}


Measured memory_bytes: 4348
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int s = sc.nextInt();
        int count = 0;

        for(int i = 0;i <= k;i++)
            for(int j = 0;j <= k;j++){
                if(i+j <= s && s-i-j <= k)
                    count++;
            }
        System.out.println(count);

    }
}

Measured memory_bytes: 21844
<?php
 
function input($func = null) {
    if ($func === null) {
        return trim(fgets(STDIN));
    } else {
        return $func(trim(fgets(STDIN)));
    }
}
function input_array($func = null) {
    if ($func === null) {
        return explode(' ', input());
    } else {
        return array_map(function($v) use ($func) {
            return $func($v);
        }, explode(' ', input()));
    }
}

list($n, $k) = input_array('intval');
for ($i = 0; $i < $n; $i++) {
    $h[] = input('intval');
}
sort($h);

$min = 10000000000;
for ($i = 0; $i < $n - $k + 1; $i++) {
    $diff = $h[$i + $k - 1] - $h[$i];
    $min = min($min, $diff);
}

echo $min . "\n";

Measured memory_bytes: 10744
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    string w; cin >> w;
    for (int i = 0; i < w.length(); ++i) {
        int cnt = 0;
        for (int j = 0; j < w.length(); ++j) {
            if (w[i] == w[j]) cnt++;
        }
        if (cnt % 2 != 0) {
            printf("%s\n", "No");
            return 0;
        }
    }
    printf("%s\n", "Yes");
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int n;
	cin >> n;
	vector<ll> v(n);
	rep(i,n) cin >> v[i];
	vector<ll> pre(n);
	vector<ll> suf(n);
	pre[0] = v[0];
	suf[n-1] = v[n-1];

	rep(i,n-1) {
		pre[i+1] = gcd(pre[i], v[i+1]);
		suf[n-1-i-1] = gcd(suf[n-1-i], v[n-1-i-1]);
	}

	ll ans = max(pre[n-2], suf[1]);
	for (int i = 1; i < n-1; i++) {
		ans = max(ans, gcd(pre[i-1], suf[i+1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 5548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	int n, k;
	string s;
	cin >> n >> k >> s;
	int l = 0, r = 0;
	char pre;
	int ans = 0;
	if(s[0]=='L'){pre='L';}
	else {pre='R';}
	int cnt = 1;
	srep(i,1,n){
		if(pre==s[i]){
			cnt++;
			continue;
		}
		else if(pre=='L'){
			ans += cnt - 1;
			l++;
			pre = 'R';
			cnt = 1;
		}
		else {
			ans += cnt - 1;
			r++;
			pre='L';
			cnt = 1;
		}
	}
	ans += cnt - 1;
	if(pre=='L')l++;else r++;
	int a = min(l, r);
	if(k >= a){
		ans = n-1;
	}else{
		ans += 2*k;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
using ll = long long;
using namespace std;

int GCD(int a, int b) {
	return b ? GCD(b, a%b) : a;
}

//sort(a, a + N, greater<int>())   // descend
//sort(a, a+N)                    //  ascend

int main() {
	int n;
	cin >> n;
	pair<pair<string, int >, int> x[110];
	rep(i,0,n) { 
		string s;  cin >> s;
		int p;  cin >> p;
		x[i] = make_pair(make_pair(s, -p), i+1);
	}
	sort(x, x+n);

	rep(i,0,n){
		cout << x[i].second<< endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long ll;
ll dp[100009];
int arr[100009];
ll sum = 0;
long long Frog1(int n){

    if(n==0) return 0;
    else if(n==1) return abs(arr[n] - arr[n-1]);
    if(dp[n]!=-1) return dp[n];
    else {
            ll x = Frog1(n-1);
            ll y = Frog1(n-2);
        dp[n] = min(abs (arr[n-1] - arr[n]) + x,abs(arr[n-2] - arr[n]) + y);
        //cout << n << " = " << dp[n] << endl;
         return dp[n];
    }
}


int main()
{
    int n;
    memset(dp,-1,sizeof(dp));
    cin >> n;
    for(int i=0;i<n;i++) cin >> arr[i];
    cout << Frog1(n-1) << endl;
}


Measured memory_bytes: 4608
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

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


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

using namespace std;

int main()
{
	double d;
	scanf("%lf", &d);

	double ans = d * sqrt(2);

	for (int x = -10; x <= 10; x++){
		if (d * d - x * x >= 0){
			double y = sqrt(max(0.0, d * d - x * x));
			ans = max(ans, fabs(x) + (x && y <= 1.0 ? 1.0 : y));
		}
	}

	printf("%.10lf\n", ans);

	return (0);
}

Measured memory_bytes: 1240
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
  
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] L = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int max = L.Max();
            int sum = L.Sum() - max;
            if(sum > max)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}




//int n = int.Parse(Console.ReadLine());
//int[] N = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

Measured memory_bytes: 13396
n,a,b,c=map(int,input().split())
l=[int(input()) for _ in range(n)]
def cal(l,a):
    return abs(sum(l)-a)+10*(len(l)-1)
def ten_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = int(X_dumy/n)
    return out
#0:A
#1:B
#2:C
#3:unused
res=[]
for i in range(4**n):
    s=str(ten_to_n(i+4**n,4))[1:]
    if s.count("0")==0 or s.count("1")==0 or s.count("2")==0:
        continue
    
    ta,tb,tc=[],[],[]
    for j in range(n):
        if s[j]=="0":
            ta.append(l[j])
        if s[j]=="1":
            tb.append(l[j])
        if s[j]=="2":
            tc.append(l[j])
    res.append(cal(ta,a)+cal(tb,b)+cal(tc,c))
print(min(res))

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

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldbl;
typedef pair<int, int> pii;
typedef pair<uint, uint> puu;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<double, double> pdd;
typedef vector<int> vi;
typedef vector<uint> vu;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;
typedef vector<puu> vpuu;
typedef vector<pll> vpll;
typedef vector<pull> vpull;
typedef vector<string> vstr;
typedef vector<double> vdbl;
typedef vector<ldbl> vldbl;
#define pb push_back
#define ppb pop_back
#define pfr push_front
#define ppfr pop_front
#define emp emplace
#define empb emplace_back
#define be begin
#define rbe rbegin
#define all(x) (x).be(), (x).end()
#define rall(x) (x).rbe(), (x).rend()
#define fir first
#define sec second
#define mkp make_pair
#define brif(cond) if (cond) break
#define ctif(cond) if (cond) continue
#define retif(cond) if (cond) return
void canhazfast() {ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);}
template<typename T> T gcd(T a, T b) {return b ? gcd(b, a%b) : a;}
template<typename T> T extgcd(T a, T b, T &x, T &y)
{
    T x0 = 1, y0 = 0, x1 = 0, y1 = 1;
    while (b) {
        T q = a/b; a %= b; swap(a, b);
        x0 -= q*x1; swap(x0, x1);
        y0 -= q*y1; swap(y0, y1);
    }
    x = x0; y = y0; return a;
}
int ctz(uint x) {return __builtin_ctz(x);}
int ctzll(ull x) {return __builtin_ctzll(x);}
int clz(uint x) {return __builtin_clz(x);}
int clzll(ull x) {return __builtin_clzll(x);}
int popcnt(uint x) {return __builtin_popcount(x);}
int popcntll(ull x) {return __builtin_popcountll(x);}
int bsr(uint x) {return 31^clz(x);}
int bsrll(ull x) {return 63^clzll(x);}

#define MX 100016

int a[MX], b[MX];

int main()
{
    canhazfast();

    int n, m, k, ans;

    cin >> n >> m >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    ans = (*min_element(a, a+n))+(*min_element(b, b+m));
    for (int i = 0; i < k; ++i) {
        int x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, a[x-1]+b[y-1]-c);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
ll cal(ll x){
    if(!(x%2)){
        if((x/2)%2) return x+1;
        else return x;
    }

    else return ((x+1)/2)%2;
}
int main()
{
    ll a,b;
    cin >> a >> b;
    ll ans = cal(b)^cal(a-1);
    cout << ans  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=100010;
int main()
{
    string s;
    while (getline(cin , s)){
        char a = s[0] , b = s[2];
        if (a < b)  puts("<");
        else if (a > b)  puts(">");
        else  puts("=");
    }
    return 0;
}


Measured memory_bytes: 256
def divisor(n):
    res = []
    
    i = 1
    while i*i <= n:
        if not n % i:
            res.append(i)
            if (i*i != n): res.append(n//i)     
        
        i += 1
        
    return res

N = int(input())
ans = 0

for d in divisor(N):
    if d == 1: continue
    n = N
    
    while not n % d:
        n //= d
        
    if n%d == 1: ans += 1
    
print(ans + len(divisor(N-1))-1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
int n;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
      string a,b,s;
      cin>>s;
      int cur=0,i;
      n=s.size();
      int ca=0,cb=0;
      fr(i,0,n)
      {
        a+=(cur+48);
        b+=((cur^1)+48);
        cur^=1;
        ca+=(s[i]!=a[i]);
        cb+=(s[i]!=b[i]);
      }
      int ans=min(ca,cb);
      cout<<ans;

       //cout<<"Case #"<<tt<<": ";
       //tt++;
    }
  return 0;
}



Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 入力
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();

		int sa12 = Math.abs(a1 - a2);
		int sa23 = Math.abs(a2 - a3);
		int sa31 = Math.abs(a3 - a1);

		int max = Math.max(Math.max(sa12, sa23), sa31);
		int cost;

		if (max == sa12){
			cost = sa23 + sa31;
		} else if (max == sa23) {
			cost = sa12 + sa31;
		} else {
			cost = sa12 + sa23;
		}

		// 出力
		System.out.println(cost);
	}
}

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

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

  int n, m; cin >> n >> m;
  int t[10][10] = {0};
  int a, b;
  for (int i = 0; i < m; i++) {
    cin >> a >> b; a--; b--;
    t[a][b] = t[b][a] = 1;
  }

	vector<int> p(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
  }

  int ans = 0;
  do {
    int flag = 1;
		if (p[0]) break;
    for (int i = 1; i < n; i++) {
      if (t[p[i]][p[i-1]] == 0) {
        flag = 0;
      }
    }
    if (flag) {
      ans++;
    }
  } while (next_permutation(p.begin(), p.end()));

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int N;
    cin>>N;
    vector<pair<ll, ll> > robots(N);
    int x, l;
    for(int i=0;i<N;++i){
        cin>>x>>l;
        robots[i] = mp(x+l, x);
    }
    sort(robots.begin(), robots.end());
    int ans = 0;
    ll tmp = robots[0].fi;
    for(int i=1;i<N;++i){
        if(tmp > 2 * robots[i].se - robots[i].fi){
            ans++;
        }
        else{
            tmp = robots[i].fi;
        }
    }
    cout<<N-ans<<endl;
}



Measured memory_bytes: 1920
n, k = [int(item) for item in input().split()]
a = [int(item) for item in input().split()]

asum = [0] * (n + 1)
aplussum = [0] * (n + 1)
for i in range(0, n):
    asum[i+1] += asum[i] + a[i]
    aplussum[i+1] += aplussum[i] + max(a[i], 0)

l = 1; r = k
ans = 0
while r <= n:
    lr = aplussum[n] - aplussum[r] + aplussum[l-1]
    mid = max(asum[r] - asum[l-1], 0)
    ans = max(ans, lr + mid)
    l += 1; r += 1 
print(ans)

Measured memory_bytes: 16900
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
bool ispalindrom(int x){
	string s=to_string(x);
	string s2=s;
	reverse(s.begin(),s.end());
	return s==s2;
}
int main() {
	// your code goes here
	int result=0;
	int x,y;
	cin>>x>>y;
	for(int i=x;i<=y;i++){
		if(ispalindrom(i)){
			++result;
		}
	}
	cout<<result;
		
	
 	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main(){
  long long n,k;cin>>n>>k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
    a[i]--;
  }
  
  if(k<n){
    long long ki=0,p=0;
    while(ki<k){
      p=a[p];
      ki++;
    }
    cout<<p+1<<endl;
    return 0;
  }

  set<int> go;
  long long ki=0,p=0;go.insert(0);
  while(ki<k){
    p=a[p];
    ki++;
    if(go.count(p)){
      break;
    }
    go.insert(p);
  }

  long long pp=p;
  ki=0;p=0;
  long long sr=0;
  if(pp!=p){
    while(ki<k){
      p=a[p];
      ki++;
      if(p==pp){
        sr=ki;
        break;
      }
    }
  }

  k-=sr;
  

  ki=0;p=pp;
  long long r=0;
  while(ki<k){
    p=a[p];
    ki++;
    if(p==pp){
      r=ki;
      break;
    }
  }

  long long er=k%r;
  ki=0;p=pp;
  while(ki<er){
    p=a[p];
    ki++;
  }

  cout<<p+1<<endl;
  return 0;
}


Measured memory_bytes: 11444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,A,B;
  cin >> X >> A >> B;
  if(A>=B){
    cout << "delicious" << endl;
  }
  else if(X>=B-A){
    cout << "safe" <<endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.function.LongSupplier;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	static final long[] fal_rnd(long[] ar,LongSupplier sp){
		int l=-1,r=ar.length;
		while(l+1!=r)
			ar[Math.random()<0.5?++l:--r]=sp.getAsLong();
		return ar;
	}
	static final IntStream REPS(int v){return IntStream.range(0, v);};
	public static void main(String[] __){
		while (true) {
			String in=s.next();
			if(in.equals("#")) return;
			int c=0;
			boolean b="yuiophjklnm".indexOf(in.charAt(0))>=0;
			for(int i=1;i<in.length();i++) {
				boolean bb="yuiophjklnm".indexOf(in.charAt(i))>=0;
				if(b^bb) c++;
				b=bb;
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 27300
import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array,
  std.functional, std.container, std.typecons;

void main() {
  int N = readln.chomp.to!int;
  int[][] G = new int[][N];
  Tuple!(int, int)[] vp = new Tuple!(int, int)[0];
  foreach(ref r; G) r = new int[0];
  foreach(i; 1..N) {
    auto inp = readln.split.to!(int[]);
    int a = inp[0] - 1, b = inp[1] -1;
    G[a] ~= b;
    G[b] ~= a;
    vp ~= tuple(a, b);
  }

  int[Tuple!(int, int)] cv;
  ulong bfs() {
    int[] cn = new int[N];
    cn[0] = 0;
    bool[] seen = new bool[N];
    seen[0] = true;
    auto que = DList!int();
    que.insertBack(0);
    ulong K = 0;

    while(!que.empty()) {
      int v = que.front; que.removeFront();
      seen[v] = true;
      K = max(K, G[v].length);

      int c = 1;
      foreach(u; G[v]) {
        if(seen[u]) continue;
        if(c == cn[v]) c++;
        cv[tuple(v, u)] = cv[tuple(v, u)] = cn[u] = c;
        c++;
        que.insertBack(u);
      }
    }
    return K;
  }

  ulong K = bfs();
  K.writeln;
  foreach(v; vp) writeln(cv[v]);
}


Measured memory_bytes: 23164
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long MOD = 1000000007;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define CLR2d(x,m,n) memset(x, -1, sizeof(x[0][0]) * m * n)
#define mp make_pair
#define PII pair<int, int>
#define pf printf
#define sf scanf
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define sz(a) int(a.size())
#define ff first
#define ss second
#define endl "\n"
#define forch(it,s) for(auto it:s)
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >


int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
ll po(ll b,ll p){
    ll res=1;
    while(p){
        res*=b;
        p--;
    }
    return res;
}
ll lg2(ll x){
    ll res=0;
    while(x>1){
        res++;
        x/=2ll;
    }
    return res;
}
void solve(){
    int n;
    cin>>n;
    cout<<po(n,3)<<endl;
}

signed main()

{
    IOS;
    /*#ifndef ONLINE_JUDGE
        freopen ("input.txt","r",stdin);
        freopen ("output.txt","w",stdout);
    #endif*/
    int t;
    t=1;
    while(t--){
        solve();
    }

     return 0;

}
///Alhamdulillah




Measured memory_bytes: 3608
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = Integer.parseInt(sc.next());
			int m = Integer.parseInt(sc.next());
			int a = Integer.parseInt(sc.next());
			if (n == 0)
				return;
			int[][] b = new int[1010][n + 1];
			for (int i = 0; i < m; i++) {
				int h = Integer.parseInt(sc.next());
				int p = Integer.parseInt(sc.next());
				int q = Integer.parseInt(sc.next());
				b[h][p] = q;
				b[h][q] = p;
			}
			for (int i = 1000; i >= 0; i--) {
				if (b[i][a] == 0) continue;
				a = b[i][a];
			}
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 70552
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a < 6)
        return !printf("0\n");
    if (a < 13)
        return !printf("%d\n", b >> 1);
    return !printf("%d\n", b);
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;

class Program
{
    static void Main(string[] args)
    {
        //var n = long.Parse(Console.ReadLine());
        var ABK = Console.ReadLine().Split().Select(long.Parse).ToArray();
        var A = ABK[0];
        var B = ABK[1];
        var K = ABK[2];
      
        if(A >= K){
          A -= K;
        }else{
          if(B  < (K-A)){
            B = 0;
          }else{
            B -= (K-A);
          }

          A = 0;
          
        }
        Console.WriteLine(A+" "+B);
      
    }
}


Measured memory_bytes: 13396
import sys
import numpy as np
import itertools
import collections
from collections import deque
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

# input
N, X, Y = [int(i) for i in readline().split()]

# graph
Graph = np.array([[0] * N for i in range(N)])
for i in range(N):
    if i-1 < 0:
        Graph[i, i+1] = 1
    elif N <= i+1:
        Graph[i, i-1] = 1
    else:
        Graph[i, i-1] = 1
        Graph[i, i+1] = 1

Graph[X-1, Y-1] = 1
Graph[Y-1, X-1] = 1

#print(Graph)

spath = shortest_path(Graph)
spathu = np.triu(spath)

#c = collections.Counter()
#for j in range(N-1):
#    c += collections.Counter(spath[j, j+1:])

def flatten_2dim(array):
    return [item for sublist in array for item in sublist]

c = collections.Counter(flatten_2dim(spathu))

#print(tmp)
#count = collections.Counter(tmp)

for i in range(1, N):
    print(c.get(i, 0))


Measured memory_bytes: 296968
#include <stdio.h>
int main(){
int n;
char s[1000];
int i;
int x=0;
int o=0;
int k[100];
int u;
int y;
int temp;
scanf("%d%s",&n,s);
for(i=0;i<n;i++){
	if(s[i]=='I'){
		++x;k[o]=x;
		o++;
	}else if(s[i]=='D'){
		--x;
		k[o]=x;
		o++;
	}
	
}
for(u=0;u<n;u++){
	for(y=n-1;y>=u;y--){
		if(k[y]<k[y-1]){
			temp=k[y-1];
			k[y-1]=k[y];
			k[y]=temp;
			
			
		}
	}
}
 /*for( i=0;i<n;++i){ 
        printf("%d,",k[i]); 
    } */

printf("%d",k[n-1]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    int ans = (n-1)*(m-1);
    cout << ans << endl;
    return 0;
}

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

s = INT()
a = [s]
i = 0
p = len(set(a))-1

while p+1 == len(set(a)):
	p = len(set(a))
	if a[i]%2 == 0:
		a.append(a[i]//2)
	else:
		a.append(a[i] * 3 +1)
	i += 1

print(i+1)

Measured memory_bytes: 5196
import java.util.*;
 
class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int sum = 0;
        if(a > b){
            sum += a;
            a -= 1;
        }else if(a<=b){
            sum += b;
            b -= 1;
        }
              if(a > b){
            sum += a;
            a -= 1;
        }else if(a<=b){
            sum += b;
            b -= 1;
        }
System.out.println(sum);
    }
 
}

Measured memory_bytes: 22484