akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();


bool cmp(pair<int,int>p,pair<int,int>q) {
    // return p.first>q.first;//descending by first
    // return p.first<q.first;//ascending by first
    // return p.second>q.second;//descending by second
    return p.second<q.second;//ascending by second
}

// bool cmp(int p,int q) {
    // return p>q;//descending
    // return p<q;//ascending
// }

int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    lli x;
    cin>>x;
    lli count=(x/500)*1000;
    x%=500;
    count+=(x/5)*5;

    cout<<count<<endl;

    // (det)?cout<<"Yes"<<endl:cout<<"No"<<endl;
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define loop(k) rep(author_is_masa,k)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18;

/*--------------------------------------------------------------------*/

signed main(){
	int n;cin>>n;
	string s;cin>>s;
	int ans=0;

	int l=0,r=n-1;
	while(l<r){
		if(s[l]=='R') l++;
		else if(s[r]=='W') r--;
		else if(s[l]=='W'&&s[r]=='R'){
			l++;r--;
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3760
import sys
input = sys.stdin.readline

S=input().strip()


ANS=0
NOW=""
i=0

while i<len(S):
    if S[i]==NOW:
        i+=2
        ANS+=1
        NOW=""
    else:
        NOW=S[i]
        i+=1
        ANS+=1

    #print(i,NOW,ANS)
        
if i==len(S)+1:
    ANS-=1

print(ANS)


Measured memory_bytes: 3500
bingo = []
bingo[0] = gets.chomp.split(' ').map(&:to_i)
bingo[1] = gets.chomp.split(' ').map(&:to_i)
bingo[2] = gets.chomp.split(' ').map(&:to_i)
n = gets.chomp.to_i

numbers = []
for i in 1..n do
  numbers.push(gets.chomp.to_i)
end

result = "No"
for row in bingo do
  if (row - numbers).empty? then
    result = "Yes"
  end
end

for col in 0..2 do
  column = []
  for row in 0..2 do
    column.push(bingo[row][col])
  end
  if (column - numbers).empty? then
    result = "Yes"
  end
end
  
slash = [bingo[0][0], bingo[1][1], bingo[2][2]]
if (slash - numbers).empty? then
    result = "Yes"
end

rslash = [bingo[2][0], bingo[1][1], bingo[0][2]]
if (rslash - numbers).empty? then
    result = "Yes"
end

print result

Measured memory_bytes: 1788
#include<stdio.h>
#include<math.h>

int main() {

	int i, a, b;
	scanf("%d%d", &a, &b);

	for (i = 1; i < 4; i++) {
		if (a*b*i % 2 == 1) {
			printf("Yes\n");
			return 0;
		}
	}
	
	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
class Dice:
    def __init__(self):
        self.dice = [
                    [0, 1, 2, 3, 4, 5],
                    [0, 2, 4, 1, 3, 5],
                    [0, 4, 3, 2, 1, 5],
                    [0, 3, 1, 4, 2, 5],
                    [1, 5, 2, 3, 0, 4],
                    [1, 2, 0, 5, 3, 4],
                    [1, 0, 3, 2, 5, 4],
                    [1, 3, 5, 0, 2, 4],
                    [2, 1, 5, 0, 4, 3],
                    [2, 5, 4, 1, 0, 3],
                    [2, 4, 0, 5, 1, 3],
                    [2, 0, 1, 4, 5, 3],
                    [3, 1, 0, 5, 4, 2],
                    [3, 0, 4, 1, 5, 2],
                    [3, 4, 5, 0, 1, 2],
                    [3, 5, 1, 4, 0, 2],
                    [4, 0, 2, 3, 5, 1],
                    [4, 2, 5, 0, 3, 1],
                    [4, 5, 3, 2, 0, 1],
                    [4, 3, 0, 5, 2, 1],
                    [5, 1, 3, 2, 4, 0],
                    [5, 2, 1, 4, 3, 0],
                    [5, 4, 2, 3, 1, 0],
                    [5, 3, 4, 1, 2, 0]]

    def math(self, dice_p1, dice_p2):
        dice_t = []
        not_match = "Yes"
        for dice_p in self.dice:
            for i in range(6):
                dice_t.append(dice_p1[dice_p[i]])
            if dice_t == dice_p2:
                not_match = "No"
            dice_t = []
        return not_match

n = int(input())
dice_p = []
for j in range(n):
    dice_p.append([int(dice_p) for dice_p in input().split()])

d = Dice()
for j in range(n-1):
    k = j + 1
    for k in range(k, n):
        dice_p1 = dice_p[j]
        dice_p2 = dice_p[k]
        not_match = d.math(dice_p1, dice_p2)
        if not_match == "No":
            print("No")
            break
    if not_match == "No":
            break
if not_match == "Yes":
    print("Yes")

Measured memory_bytes: 7900
#include <iostream>

using namespace std;
int main(void){
    bool a[1000001];
    for(int i = 4;i <= 1000000;i += 2){
        a[i] = true;
    }
    for(int i = 3;i * i <= 1000000;i++){
        if(!a[i]){
            for(int j = 2;i * j <= 1000000;j++){
                a[i * j] = true;
            }
        }
    }
    int n;
    cin >> n;
    for(int i = n;i <= 1000000;i++){
        if(!a[i]){
            cout << i << endl;
            break;
        }
    }

}


Measured memory_bytes: 1280
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))

    def find(self, a):
        acopy = a
        while a != self.parent[a]:
            a = self.parent[a]
        while acopy != a:
            self.parent[acopy], acopy = a, self.parent[acopy]
        return a

    def union(self, a, b):
        self.parent[self.find(b)] = self.find(a)


########################################
n , m = map(int , input().split())
g = defaultdict(list)
uf = UnionFind(n)
for i in range(m):
	u,v = map(int , input().split())
	u-=1
	v-=1
	uf.union(u,v)
check = set()
for i in range(n):
	check.add(uf.find(i))
print(len(check) - 1)







'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''


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

int main() {
  int h, w, i, j;
  cin >> h >> w;
  
  vector<vector<char>> a(h + 2, vector<char>(w + 2, '#'));
  for(i = 1; i <= h; i++){
    for(j = 1; j <= w; j++){
      cin >> a.at(i).at(j);
    }
  }
  
  for(i = 0; i <= h + 1; i++){
    for(j = 0; j <= w + 1; j++){
      cout << a.at(i).at(j);
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def make_divisors(n):
    divisors = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
import bisect
def main():
    n,m=map(int,input().split())
    div=make_divisors(m)
    print(div[bisect.bisect(div,m//n)-1])
    

if __name__=='__main__':
    main()

Measured memory_bytes: 38640
read N Y
for (( x = 0; x <= N; x++ )); do
    Y0=$(( Y - x * 10000 - (N - x) * 1000 ))
    y=$(( Y0 / 4000 ))
    z=$(( N - x - y ))
    if (( y >= 0 && z >= 0 && Y0 % 4000 == 0 )); then
        echo ${x} ${y} ${z}
        exit
    fi
done
echo -1 -1 -1


Measured memory_bytes: 504
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void A();

int main()
{
	A();
	fflush(stdout);
	return 0;
}

static void A()
{
	std::string orgs;
	std::cin >> orgs;

	char c = orgs[0];

	if ('a' <= c && c <= 'z') {
		printf("a\n");
	}
	else {
		printf("A\n");
	}
}


Measured memory_bytes: 3588
n,k,*l=map(int,open(0).read().split())
v,m=0,min(n,k)+1
from bisect import*
for i in range(m):
  for j in range(m-i): s=sorted(l[:i]+l[n-j:]); v=max(v,sum(s[min(bisect(s,-1),k-i-j):]))
print(v)

Measured memory_bytes: 3060
import numpy as np
h,w = list(map(int,input().split()))
S = [[x for x in input()] for _ in range(h)]

s = np.zeros((h,w), dtype='int')
for i in range(h):
  for j in range(w):
    if S[i][j] == '.':
      s[i,j] = h*w

def rev():
  for i in range(1,h):
    s[i,:] = np.minimum(s[i,:], s[i-1,:]+1)
  for i in range(h-1)[::-1]:
    s[i,:] = np.minimum(s[i,:], s[i+1,:]+1)
  for i in range(1,w):
    s[:,i] = np.minimum(s[:,i], s[:,i-1]+1)
  for i in range(w-1)[::-1]:
    s[:,i] = np.minimum(s[:,i], s[:,i+1]+1)

rev()
print(np.max(s))


Measured memory_bytes: 29032
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n,k;
    cin >> n >> k;
    string pat[n+2];
    for (int i=0; i<k+2; i++)
    {pat[0]+="#"; pat[n+1]+="#";}
    for (int i=1; i<=n; i++)
    {
        cin >> pat[i];
        pat[i]="#"+pat[i]+"#";
    }
    for (int i=0; i<n+2; i++)
    {
        cout << pat[i] << '\n';
    }

}


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

using namespace std;
#ifdef ONLINE_JUDGE
#define cerr if(false)cerr
#endif
#define int long long
#define ld1 long double
#define watch(x) cerr << (#x) << " is " << (x) << endl
#define faster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL),cout<<setprecision(14);
#define cint int t;cin>>t;while(t--)
#define vint vector<int>
#define all(v) (v).begin(), (v).end()
#define pii pair<int,int>
#define pb push_back
#define mm0(X) memset((X), 0, sizeof((X)))
#define mm1(X) memset((X), -1, sizeof((X)))
#define N (int)1e5+7
#define MAXN (int)5004
#define INF (int)1e9
#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
#define endl '\n'
#define vcc vector<char>

const int mod=1000000007;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
    string s;
    string t;
    cin>>s>>t;

    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return;
        }
    }
    cout<<"Yes"<<endl;
    return;
}


int32_t main() {
    faster;

#ifndef ONLINE_JUDGE
    READ("inp.txt");
    WRITE("out.txt");
    double beg=clock();
#endif

    int t=1;
//    cin>>t;

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

#ifndef ONLINE_JUDGE
    double end=clock();
    cout<<endl;
    cerr<<"*** Total time = "<<(end-beg)/CLOCKS_PER_SEC;
#endif
}


Measured memory_bytes: 3640
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main(void) {
  while(1) {
    string s;
    cin >> s;
    if(s == "-")
      break;
    int m;
    cin >> m;
    for(int i = 0; i < m; i++) {
      int h;
      cin >> h;
      int sl = s.length();
      s += s.substr(0, h);
      s = s.substr(h, sl);
    }
    cout << s << endl;
  }

  return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

void solve()
{
    int N;
    cin >> N;
    vector<string> S(N);
    set<string> A;
    REP(i, N)
    {
        cin >> S[i];
        A.insert(S[i]);
    }
    cout << A.size();
}

signed main()
{

    solve();

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin>>a;
    int n=a.size();
    a="x"+a;
    if(a[1]=='A') {
        int cnt=0;
        bool ok=1;
        for(int i=3;i<n;i++) {
            if(a[i]=='C') {
                cnt++;
            }
            else {
                if('A'<=a[i] && a[i]<='Z') {
                    ok=0;
                }
            }
        }
        if('A'<=a[2] && a[2]<='Z') {
            ok=0;
        }
        if('A'<=a[n] && a[n]<='Z') {
            ok=0;
        }
        if(cnt==1 && ok==1) {
            cout<<"AC\n";
        return 0;
        }
    }
    cout<<"WA\n";
    return 0;
}
/**

**/


Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end
  
N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
dp = Hash.new {|h,k| h[k] = [] }
dp[0] << 0

A.each.with_index(1).inject(0) do |sum, (a, i)|
  dp[(sum + a - i) % K] << i
  sum + a
end

ans = dp.inject(0) do |sum, (mod, mods)|
  count = 0
  mods.each_index.inject(0) do |l, r|
    (l .. r).find{|l_| mods[r] - mods[l_] < K }.tap{|l_| count += (r - l_) }
  end
  sum + count
end
puts ans

Measured memory_bytes: 66536
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }


int main(){
	ll n ; cin >> n ;
	ll k ; cin >> k ;
	vll a(n) ;
	for(auto &i:a) cin >> i ;
	sort(all(a)) ;
	ll ans = 0 ;
	for(int i=0;i<k;i++) ans += a.at(i) ;
	cout << ans << endl ;
}




Measured memory_bytes: 3624
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();

    token.parse().ok().expect("failed to parse token")
}



fn main() {
    let n: u64 = read();
    let m: u64 = read();
    let mut count: u64 = 0;

    for i in 0..n {
        for _j in i+1..n{
            count += 1;
        }
    }
    
    for i in 0..m {
        for _j in i+1..m{
            count += 1;
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main(){
  char b;cin >> b;
  if(b=='A') cout<<'T'<<endl;
  else if(b=='T') cout<<'A'<<endl;
  else if(b=='C') cout<<'G'<<endl;
  else cout<<'C'<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque

nn = 200200
mod = 10**9+7

fa = [1] * (nn+1)
fainv = [1] * (nn+1)
inv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % mod
fainv[-1] = pow(fa[-1], mod-2, mod)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % mod
for i in range(1, nn)[::-1]:
    inv[i] = fainv[i] * fa[i-1]

C = lambda a, b: fa[a] * fainv[b] % mod * fainv[a-b] % mod if 0 <= b <= a else 0

N = int(input())
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    X[x-1].append(y-1)
    X[y-1].append(x-1)

P = [-1] * N
Q = deque([0])
R = []
while Q:
    i = deque.popleft(Q)
    R.append(i)
    for a in X[i]:
        if a != P[i]:
            P[a] = i
            X[a].remove(i)
            deque.append(Q, a)

unit = 1
f = lambda a, b: a * b % mod
g_bu = lambda a, i=-1: a * inv[SI[i]] % mod
g_td = lambda a, i=-1: a * inv[N - SI[i]] % mod

SI = [1] * N
for i in R[::-1]:
    for j in X[i]:
        SI[i] += SI[j]

BU = [unit] * N
TD = [unit] * N
for i in R[::-1]:
    a = 1
    for j in X[i]:
        a = f(a, BU[j])
    BU[i] = g_bu(a, i)

AX = [1] * N
for i in R:
    c = len(X[i])
    ac = unit
    for k, j in enumerate(X[i]):
        AX[j] = ac
        ac = f(ac, BU[j])
    ac = unit
    for k in range(c-1, -1, -1):
        j = X[i][k]
        AX[j] = f(AX[j], ac)
        ac = f(ac, BU[j])
    for k, j in enumerate(X[i]):
        TD[j] = g_td(f(TD[i], AX[j]), j)

print(*[BU[i] * SI[i] % mod * TD[i] % mod * fa[N - 1] % mod for i in range(N)], sep = "\n")

Measured memory_bytes: 139484
//ALDS1_8A
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

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

Node *root,*NIL;
void insert(int k){
 Node *y=NIL;
 Node *x=root;
 Node *z;
 z=(Node *)malloc(sizeof(Node));
 z->key=k;
 z->left=NIL;
 z->right=NIL;
 while(x!=NIL){
  y=x;
  if(z->key<x->key){
   x=x->left;
  }else{
   x=x->right;
  }
 }
 z->parent=y;
 if(y==NIL){
  root=z;
 }else{
  if(z->key<y->key){
   y->left=z;
  }else{
   y->right=z;
  }
 }
}

void inorder(Node *u){
 if(u==NIL) return;
 inorder(u->left);
 cout<<" "<<u->key;
 inorder(u->right);
}

void preorder(Node *u){
 if(u==NIL) return;
 cout<<" "<<u->key;
 preorder(u->left);
 preorder(u->right);
}

int main(){
 int n,x;
 string com;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>com;
  if(com=="insert"){
   cin>>x;
   insert(x);
  }else if(com=="print"){
   inorder(root);
   cout<<endl;
   preorder(root);
   cout<<endl;
  }
 }
 return 0;
}

Measured memory_bytes: 24648
using System;
using System.Diagnostics;
using System.Linq;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var source = Console.ReadLine();

            var hugCount = 0;
            var x = (int)Math.Floor((decimal)(source.Length / 2));
            for (int i = 0; i < x; i++)
            {
                if (source[i] != source[source.Length - 1 - i])
                {
                    hugCount++;
                }
            }

            Debug.WriteLine(hugCount);
            Console.WriteLine(hugCount);
        }
    }
}


Measured memory_bytes: 13140
N = int(input())
A = list(input())
B = list(input())
C = list(input())

count = 0 

for i in range(N):
	if A[i] == B[i] and A[i] == C[i]:
		continue
	elif A[i] == B[i] or A[i] == C[i] or B[i] == C[i]:
		count +=1
	else:
		count +=2
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <unordered_map>

using namespace std;
int n , q;
long long sum = 0;
unordered_map <long long,int> mp;
int main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        long long x;
        cin >> x;
        mp[x]++;
        sum = sum + x;
    }
    cin >> q;
    for (int i = 1; i <= q; i++){
        long long x,y;
        cin >> x >> y;
        if (x != y){
            sum = sum - x*mp[x];
            sum = sum + y*mp[x];
            mp[y] += mp[x];
            mp[x] = 0;
        }
        cout << sum << "\n";
    }   
    return 0;
}

Measured memory_bytes: 6960
#include <stdio.h>
#include <string.h>
#include <math.h>

#define SQ(x) ((x) * (x))
#define INF (100000000)
#define EPS (1e-9)

int len, cake[12];
double dp[1 << 12][12];
int n;

double min(double a, double b)
{
    return (b > a ? a : b);
}

double tsp(int bit, int now)
{
    int i;
    double res;
    
    if (dp[bit][now] >= 0 && now >= 0){
        return (dp[bit][now]);
    }
    
    if (bit == (1 << n) - 1){
        return (cake[now]);
    }
    
    res = INF;
    for (i = 0; i < n; i++){
        if (!(bit >> i & 1)){
            res = min(res, tsp(bit | 1 << i, i) + (now >= 0 ? sqrt(SQ(cake[i] + cake[now]) - SQ(cake[i] - cake[now])) : cake[i]));
        }
    }
    
    return (now >= 0 ? dp[bit][now] = res : res);
}

int main(void)
{
    int i, j;
    char str[512];
    int flag;
    
    while (fgets(str, 512, stdin) != NULL){
        i = flag = len = n = 0;
        memset(cake, 0, sizeof(cake));
        while (str[i] != '\0'){
            if (flag == 0){
                while (str[i] != ' ' && str[i] != '\n'){
                    len = len * 10 + str[i++] - '0';
                }
                i++;
                flag = 1;
            }
            else {
                while (str[i] != ' ' && str[i] != '\n'){
                    cake[n] = cake[n] * 10 + str[i++] - '0';
                }
                n++;
                i++;
            }
        }
        
        for (i = 0; i < (1 << 12); i++){
            for (j = 0; j < 12; j++){
                dp[i][j] = -1 * INF;
            }
        }
        
        if (tsp(0, -1) < len + EPS){
            printf("OK\n");
        }
        else {
            printf("NA\n");
        }
    }
    
    return (0);
}

Measured memory_bytes: 720
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef vector<int>V;
void I(V&v)
{
	v.push_back(0);
	sort(v.begin(),v.end());
	v.erase(unique(v.begin(),v.end()),v.end());
}
V::const_iterator F(const V&v,int m)
{
	return upper_bound(v.begin(),v.end(),m)-1;
}
int main()
{
	int n,m,i,j,r;
	V v,w;
	v.reserve(1001);
	w.reserve(502000);
	while(scanf("%d%d",&n,&m),n)
	{
		v.clear();
		w.clear();
		for(i=0;i<n;++i)
		{
			scanf("%d",&r);
			v.push_back(r);
		}
		I(v);
		for(i=1;i<v.size();++i)for(j=i;j<v.size();++j)w.push_back(v[i]+v[j]);
		I(w);
		r=*F(v,m);
		r=max(r,*F(w,m));
		for(i=1;i<v.size();++i)
			if(m-v[i]>=0)r=max(r,v[i]+*F(w,m-v[i]));
		for(i=j=F(w,m/2)-w.begin();0<=i&&j<w.size();)
		{
			if(w[i]+w[j]>m)--i;
			else r=max(r,w[i]+w[j]),++j;
		}
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repf(i, a, b) for(ll i = (a); i < (b) ; i++ )
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;

int main()
{
ll n,a;
cin >> n>>a;
if(n<a)cout << 0 << endl;
else cout << 10 << endl;
return 0;


}

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

int now[27];
int dp[100005] = {0};
int n;
string s, dummy;

int solve();

int main() {
  int i;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> dummy;
    s += dummy[0];
  }
  for(i = 0; i < 26; ++i) now[i] = -1000000000;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int i, j, nown;
  for(i = 0; i < n; ++i) {
    nown = s[i] - 'a';
    now[nown] = max(now[nown], dp[max(i - 1, 0)]);
    if(i != 0) dp[i] = max(dp[i - 1], now[nown]);
    for(j = 0; j < 26; ++j) ++now[j];
  }
  return n - dp[n - 1];
}


Measured memory_bytes: 3720
from enum import Enum
import sys
import math
 
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
 
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():
 
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]
        self.order = 'NNNNWNNNWNNNENNNENNNWNNN'
 
    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5
 
 
    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]
 
        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])
 
 
    def equals(self,another):
 
        ret = False;
 
        for i in range(len(self.order)):
            self.roll(self.order[i])
            FLG = True
            for k in range(6):
                if self.number[k] != another.number[k]:
                    FLG = False
                    break
            if FLG == True:
                return True
 
        return ret
 
diceA = Dice()
diceB = Dice()
 
table = list(map(int,input().split()))
diceA.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
table = list(map(int,input().split()))
diceB.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])
 
if diceA.equals(diceB):
    print("Yes")
else:
    print("No")


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

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

void code() {
    int n;
    cin>>n;
    int ans=0;
    vector<int> A(n+1);
    for(int i=1; i<=n; i++) {
        cin>>A[i];
    }
    for(int i=1; i<=n; i+=2) {
        if((A[i]+1)%2==0)
            ans++;
    }


    cout << ans << "\n";
}

signed main() {
    std::ios_base::sync_with_stdio(false);
    int t=1;
    // cin>>t;
    for(int i=0; i<t; i++) {
        code();
    }
}


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
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)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int main(){
    int a,b;
    cin>>a>>b;
    int ans = 0;
    if(a<=3)ans += (4-a)*100000;
    if(b<=3)ans += (4-b)*100000;
    if(a==1 && b==1)ans += 400000;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
s=[0]
for i in range(n):
    s.append(s[-1]+A[i])
s.sort()
ans=0
cnt=1
for i in range(1,n+1):
    if s[i-1]==s[i]:
        cnt+=1
    else:
        if 2<=cnt:
            ans+=(cnt*(cnt-1))//2
            cnt=1
        else:
            cnt=1
if 2<=cnt:
    ans+=(cnt*(cnt-1))//2
print(ans)

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

namespace
{
const int MAX_N	= 100000;
int V[ MAX_N + 5 ];

}

int main( int argc, char *argv[] )
{
int i;
int a;
int N;
int iMax;
int iMaxX;
int iSum;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

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

	if( N == 1 )
	{
		cout << 1 << endl;

		return 0;
	}

	iSum = V[ 0 ] + V[ 1 ] + V[ 2 ];
	iMax = iSum;
	iMaxX = 1;
	for( i = 3; i <= MAX_N; i++ )
	{
		iSum -= V[ i - 3 ];
		iSum += V[ i ];
		if( iMax < iSum )
		{
			iMax = iSum;
			iMaxX = i - 1;
		}
	}

	cout << iMax << endl;

	return 0;
}




Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define v vector
#define mp make_pair
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define rep(i,n) for(ll i=0;i<n;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int M = 1e9+7;
int ll_max=1e6;
int main() {
	// your code goes here
	IOS;
	int64_t n,x;
	
	ll i,j,m,k;
	int64_t sum=0;
      cin>>n;
      ll a[n];
      ll xorr=0;
      rep(i,n){
            cin>>a[i];
            xorr^=a[i];
      }
      rep(i,n){
            x=xorr^a[i];
            cout<<x<<" ";
      }
	return 0;
}

Measured memory_bytes: 5148
/**
*   Bismillahir Rahmanir Rahim.
*   Imtiaz_rafi
*   PCIU, CHITTAGONG
**/
#include<bits/stdc++.h>
using namespace std;
#define speed() ios::sync_with_stdio(0);cin.tie(0);
#define file() freopen ("input.txt", "r", stdin);freopen ("output.txt", "w", stdout);
#define rep(i,a) for(ll i=0;i<a;i++)
#define rep1(i,begin,end) for(ll i=begin;i<=end;i++)
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define all(v)   v.begin(),v.end()
#define rall(v)   v.rbegin(),v.rend()
#define pb push_back
#define pf push_front
#define mp make_pair
#define pi acos(-1)
// bitshift (1LL<<(3)) *2^3
typedef long long int ll;
typedef vector<ll>vi;
typedef map<ll,ll>mi;
typedef pair<ll,ll>pll;
typedef vector<pll> vll;
typedef set<ll>st;
typedef set<char>sc;
ll dx[] = {-1,+1,0,0,+1,-1,+1,-1};
ll dy[] = {0,0,-1,+1,+1,+1,-1,-1};
const ll mx = 1e5+123;
const ll MOD = 1e9+7;

template <class T> T power(T a,T b){a%=MOD;if(!a) return 0;T p=1;while(b>0){if(b&1){p*=a;p%=MOD;}a*=a;a%=MOD;b=b>>1;}return p;}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class T> T gcd(T a, T b){return (b!=0?gcd<T>(b,a%b):a);}
template <class T> T lcm(T a, T b){return (a/gcd<T>(a,b)*b);}

ll BS(ll l,ll r,ll a[],ll k){ll mid,i=-1;while(l<=r){mid=(l+r)>>1;if(a[mid]==k){return i=mid;/*r=mid-1;*/}if(a[mid]<k) l=mid+1;if(a[mid]>k) r=mid-1;}return i;}

ll n,b[mx][4],dp[mx][4];
ll solve(ll i,ll j)
{
    if(i>=n)
        return 0;
    if(dp[i][j]!=-1)
        return dp[i][j];
    ll x = 0;
    for(ll k=0;k<4;k++)
    {
        if(j!=k)
        {
            //cout<<b[i][k]<<" "<<x<<endl;
            x = max(x,(b[i][k])+solve(i+1,k));
        }


    }
    return dp[i][j] = x;
}

int main()
{
    speed();
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>b[i][0]>>b[i][1]>>b[i][2];
    }
    mem(dp,-1);
    cout<<solve(0,4)<<endl;
}



Measured memory_bytes: 17640
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=40005;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string s;
	cin>>s;
	int q;
	cin>>q;
	vector<char> oof1;
	vector<char> oof2;
	int k=0;
	while(q--)
	{
		int t;
		cin>>t;
		if(t==1)
		{
			k++;
		}
		else{
			int f;
			cin>>f;
			char c;
			cin>>c;
			if(f==1)
			{
				if(k%2==0)
				{
					oof1.pb(c);
				}
				else oof2.pb(c);
			}
			else{
				if(k%2==0)
				{
					oof2.pb(c);
				}
				else oof1.pb(c);
			}
		}
	}
	reverse(all(oof1));
	string ans="";
	for(auto x:oof1) ans+=x;
	ans+=s;
	for(auto x:oof2) ans+=x;
	if(k%2==0)
	{
		cout<<ans;
	}
	else{
		reverse(all(ans));
		cout<<ans;
	}
}
// 0.08*x = a
// 
// When you want to succeed as bad as you want to breathe, only then you’ll Be Successful!
// No Matter,How Fast You Are Driving If You Are Driving in a Wrong Direction You Will Never Reach Your Destination
// When failures hit you, you hit the failures back with Bounce Back!
// When you face failures, Don’t change your goal, Change your strategy!

Measured memory_bytes: 1448
#!/usr/bin/env python3
import sys

MOD = 1000000007  # type: int

def mpow(x: int, k: int, MOD=1000000007) -> int:
    """
    x^kのmodを返します
    """
    res = 1
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res

def mfact(MAX=200000, MOD=1000000007) -> 'List[int]':
    """
    MAXまでの階乗のmodの配列を返します
    """
    f = [1]
    for i in range(1, MAX):
        f.append(f[-1] * i % MOD)
    return f

def inv(x: int, MOD=1000000007) -> 'List[int]':
    """
    フェルマーの小定理に基づく逆元を返します
    """
    return mpow(x, MOD - 2, MOD)

def mcomb(n: int, k: int, f: 'List[int]', MOD=1000000007) -> int:
    """
    nCkのmodを返します
    """
    a = f[n]
    b = f[n-k]
    c = f[k]
    bc = (b * c) % MOD
    return (a * inv(bc)) % MOD

def solve(X: int, Y: int):
    if (2*Y-X) % 3 != 0 or (2*X-Y) % 3 != 0:
        print(0)
        return
    if 2*Y - X < 0 or 2 * X - Y < 0:
        print(0)
        return
    x = (2*Y-X) // 3
    y = (2*X-Y) // 3
    f = mfact(2000000)
    print(mcomb(x+y, x, f))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 82220
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>
#include <bitset>

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

#define EPS (1e-7) 
#define ALL(x) begin(x), end(x)

bool starts_with(const string& s, char c) {
	return s[0] == c;
}
bool ends_with(const string& s, char c) {
	return s[s.length() - 1] == c;
}

int main() {
	size_t N;
	cin >> N;

	vector<string> S(N);
	for (size_t i = 0; i < N; i++) {
		cin >> S[i];
	}

	// 単独のABを見つける
	ull ans = 0;
	ull a_count = 0;
	ull b_count = 0;
	ull a_b_count = 0;
	for (const auto s : S) {
		auto pos = s.find("AB");
		while (pos != std::string::npos) {
			ans++;
			pos = s.find("AB", pos + 2);
		}

		// A終わり件数とB始まりの件数が二つあれば追加できるのでこのループでついでに見る
		if (starts_with(s, 'B') && ends_with(s, 'A')) {
			a_b_count++;
		} else if (starts_with(s, 'B')) {
			b_count++;
		} else if (ends_with(s, 'A')) {
			a_count++;
		}

	}

	if (a_count == 0 && b_count == 0 && a_b_count > 0) {
		ans += a_b_count - 1;
	} else {
		ans += min(a_count + a_b_count, b_count + a_b_count);
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
    int n, l;
    cin>>n>>l;
    int wa=0;
    for(int i=1;i<=n;i++) wa+=l+i-1; 
    if(l<=0&&l+n-1>=0) cout<<wa<<endl;
    else if(l>0) cout<<wa-l<<endl;
    else if(l+n-1<0) cout<<wa-(l+n-1)<<endl;
}

Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        PrintWriter out=new PrintWriter(System.out);
        FastReader in=new FastReader(); 
        Solver s=new Solver();
        int t=1;
        while(t-- > 0) s.solve(in, out);
        out.close();
    }

    static class Solver {
        public void solve(FastReader in, PrintWriter out) throws IOException {
            // solve
            int n=in.nextInt();
            int[] a=new int[n];
            int[] b=new int[n];
            int[] c=new int[n];
            for(int i=0;i<n;i++){
                a[i]=in.nextInt();
                b[i]=in.nextInt();
                c[i]=in.nextInt();
            }
            int[] dp=new int[] {a[0],b[0],c[0]};
            //everyday toro has 3 choices
            for(int i=1;i<n;i++){
                int x=a[i]+Math.max(dp[1],dp[2]);
                int y=b[i]+Math.max(dp[0],dp[2]);
                int z=c[i]+Math.max(dp[0],dp[1]);
                dp[0]=x;
                dp[1]=y;
                dp[2]=z;
            }
            int ans=0;
            for(int i:dp) ans=Math.max(ans,i);
            out.println(ans);
        } 
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br=new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {
            while (st==null||!st.hasMoreElements()) {
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() {
            String str="";
            try {
                str=br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}

Measured memory_bytes: 44132
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


def main():
    # sys.stdin = open("Sample.txt")
    N = Scanner.int()
    print(N * (N - 1) // 2)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(int i=a;i<=b;i++)
inline ll r() {
	ll x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	if(c=='-')f=-1,c=getchar();
	while(isdigit(c))x=x*10+c-'0',c=getchar();
	return x*f;
}
#define d r()
ll n,k;
int main(){
	n=d;
	k=n;
	ll ans=0;
	while(1){
		ans++;
		k=(k+n)%360;
		if(k==n){
			cout<<ans;
			return 0;
		}
	}
	return 0;
}


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

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	string a;
	int i,b[26]={0},t;
	bool q=false;
	cin>>a;
	for (i=0;i<a.size();i++){
		t=a[i]-'0';
		t-=49;
		b[t]++;
	}
	for (i=0;i<26;i++){
		if (b[i]>1){
			q=true;
			cout<<"no";
			break;
		}
	}
	if (q==false){
		cout<<"yes";
	}
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let l = read!(f64);
	let ans = l*l*l/27.0;
	println!("{}", ans);
}

fn run() {
    solve();
}


Measured memory_bytes: 8572
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n,x,y;cin>>n>>x>>y;
	int ans=(n-x+1)*(n-y+1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256