akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string r,a;
	while(1){
		cin>>r>>a;
		if(r.size()==1 && a.size()==1)break;
		int hit=0,blow=0;
		rep(i,4){
			rep(j,4){
				if(r[i]==a[j]){
					if(i==j)hit++;
					else blow++;
				}
			}
		}
		cout<<hit<<" "<<blow<<endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<cstdio>

using namespace std;

int main(){
	char s[5]; scanf("%s", s);
	int t[4];
	for(int i = 0; i < 4; i++) t[i] = s[i] - '0';
	for(int S = 0; S < (1 << 3); S++){
		char op[3];
		int ret = t[0];
		for(int i = 0; i < 3; i++){
			if(S & (1 << i)){ op[i] = '-'; ret -= t[i + 1]; }
			else{ op[i] = '+'; ret += t[i + 1]; }
		}
		if(ret == 7){
			printf("%d%c%d%c%d%c%d=7\n", t[0], op[0], t[1], op[1], t[2], op[2], t[3]);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ
 
    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]
 
    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
 
    def is_same(self, x, y):  # x, y が同じ集合に属するか判定する
        return self.find(x) == self.find(y)
 
    def group_size(self, x):  # x が属する集合の大きさを返す
        return self.size[self.find(x)]
 

n,m,k=map(int,input().split())
friend=[[]for i in range(n)]
block=[[]for i in range(n)]
group=[[]for i in range(n)]
uf=UnionFind(n)

for i in range(m):
    a,b=map(int,input().split())
    friend[a-1].append(b-1)
    friend[b-1].append(a-1)
    uf.unite(a-1,b-1)

for i in range(k):
    c,d=map(int,input().split())
    if uf.is_same(c-1,d-1):
        block[c-1].append(d-1)
        block[d-1].append(c-1)

for i in range(n):
    ans=uf.group_size(i)-1-len(friend[i])-len(block[i])
    print(ans)


Measured memory_bytes: 53232
n = gets.chomp.to_i
l = []
n.times do |num|
  l << gets.chomp.to_i
end
m = 100000000000
d = -100000000000
l.each do |i|
  n = i.to_i
  a = n - m 
  d = a if a > d
  m = n if m > n 
end
p d

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

def main():
    n, m = map(int, input().split())
    g = [[] for i in range(n)]
    ind = [0]*n
    for i in range(n+m-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        g[a].append(b)
        ind[b] += 1

    from collections import deque
    q = deque([])
    order = []
    par = [0]*n
    for i in range(n):
        if ind[i] == 0:
            q.append(i)
    while q:
        v = q.popleft()
        order.append(v)
        for u in g[v]:
            ind[u] -= 1
            if ind[u] == 0:
                par[u] = v+1
                q.append(u)
    print(*par, sep='\n')

if __name__ == '__main__':
    main()


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

#define ipr pair<int, int>
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k; i--)
#define ll unsigned long long
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define mp make_pair
#define cnt_ones(x) __builtin_popcountll(x)

#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

const int Maxn = (int)1e6;
const ld pi = acos(-1);
const int mod = (int)1e9 + 7;
const int inf = (int)1e18;

template <class T>
ostream &operator<<(ostream &out, vector<T> &A) {
    fr(i, 1, (int)A.size()) out << A[i]+1 << " ";
    return out;
}

// GRAPH ALGORITHMS

int n, e;
//int cycle_start, cycle_end;
vector<vector<int> > g;
vector<bool> vis;
vector<int> dis;
vector<int> par;

//--> Take input of given graph
void graph_inp() {
    cin >> n;
    cin >> e;
    // e = n - 1;  for a tree
    g.resize(n);
    vis.resize(n, false);
    par.resize(n, -1);
    dis.resize(n, inf);

    fr(i, 0, e) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].pb(v);
        g[v].pb(u);
    }
}

//void graph_print() { fr(i, 0, n) cout << g[i] << '\n'; }

void bfs(int root) {
    queue<int> q;
    q.push(root);
    dis[root] = 0;
    while (!q.empty()) {
        int node = q.front();
        q.pop();
        for (auto child : g[node])
            if (dis[child] == inf) {
                dis[child] = dis[node] + 1;
                par[child] = node;
                q.push(child);
            }
    }
    bool flag = true;
    for(auto x : dis){
        if(x == inf){
            flag = false;
            break;
        }
    }
    if(flag){
        cout << "Yes" << '\n' << par << endl;
    }else{
        cout << "No" << endl;
    }
}

int32_t main() {
    IOS graph_inp();
    bfs(0);
    return 0;
}

Measured memory_bytes: 13720
#include <iostream>
#include <string>

using namespace std;

const int maxi = 64;

string s[maxi], x;
int t[maxi];
int N;

int main() {
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> s[i] >> t[i];
    cin >> x;
    int ans = 0;
    bool f = 0;
    for (int i = 0; i < N; ++i) {
        ans += f * t[i];
        if (s[i] == x) f = 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::process;
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: u64, 
        k: u64,
        h: [u64; n],
    }   
    let mut c = 0;
    for i in h {
        if k <= i {
            c += 1;
        }
    }

    println!("{}", c);
}


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


typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main(){
    ll n;cin>>n;
    ll h[n];
    for(ll i=0;i<n;i++){
        cin>>h[i];
    }
    ll ans[n];
    ans[n-1]=0;
    ll maxi=0;
    for(ll i=n-2;i>=0;i--){
        if(h[i]<h[i+1]){
            ans[i]=0;
        }else{
            ans[i]=ans[i+1]+1;
            maxi=max(maxi,ans[i]);
        }
    }
    cout<<maxi<<endl;
    return 0;
}


Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String []args){
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1,in,out);
        out.close();
    }
    static class Task{
        public void solve(int testNumber,Scanner in,PrintWriter out){
            int n = in.nextInt();
            long [] L = new long[n + 1];
            L[0] = 2;
            L[1] = 1;
            for(int i = 2 ; i <= n ; i++){
                L[i] = L[i - 1] + L[i - 2];
            }
            out.println(L[n]);
        }
    }
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

int n;
vector<string> answer;

void rec(int rest, vector<int> &v) {
  if (rest == 0) {
    // dmp(v);
    string ans(n, ' ');
    for (int i = 0; i < v.size(); i++) {
      for (int j = 0; j < n; j++) {
        if ((v[i] >> j) & 1) ans[j] = (char)('a' + i);
      }
    }
    answer.push_back(ans);
    return;
  }
  int must = rest & (-rest);
  for (int i = 1; i < (1 << n); i++) {
    if ((must & i) != must) continue;
    if ((i & rest) != i) continue;
    v.push_back(i);
    rec((rest ^ i), v);
    v.pop_back();
  }
  return;
}
void solve() {
  cin >> n;
  vector<int> v;
  rec((1 << n) - 1, v);
  sort(all(answer));
  for (auto &ans : answer) cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 7796
#include <bits/stdc++.h>
using namespace std;
const int N = 3010;
int n;
double p[N], f[N][N]={1.0}; //f[i][j]表示前i个硬币中j个正面向上的概率

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lf", &p[i]);
        f[i][0] = f[i - 1][0] * (1.0 - p[i]);
        for (int j = 1; j <= i; j++)
            f[i][j] = f[i - 1][j - 1] * p[i] + f[i - 1][j] * (1.0 - p[i]);
    }

    double ans = 0.0;
    for (int i = (n >> 1) + 1; i <= n; i++)
        ans += f[n][i];
    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 46464
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int r = scan.nextInt();
    if(n < 10){
      System.out.println(r + 100 * (10 - n));
    }else{
      System.out.println(r);
    }
  }
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    int mx = 0;
    rep(i, n) mx = max(mx, a[i]);
    double l = 0.0, r = (double)mx+0.5;
    while (fabs(r-l)>=0.000001) {
        double c = (l+r)/2.0;
        ll tk = 0;
        rep(i, n) tk += ceil(a[i]/c)-0.5;
        if (tk > k) l = c;
        else r = c;
    }
    cout << (int)(ceil(l)+0.5) << endl;
    return 0;
}


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

int h[100001];
int dp[100001];

int main() {
    int N, K;
    cin >> N >> K;

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

    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);

    for (int i = 3; i <= N; ++i) {
        int k_max = min(i - 1, K);
        dp[i] = 1000000000;

        for (int k = 1; k <= k_max; ++k) {
            dp[i] = min(abs(h[i] - h[i - k]) + dp[i - k], dp[i]);
        }
    }

    cout << dp[N] << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i) 



int main() {
	int N;
	cin >> N;
	double a = (N / 2 + 1) ;
	double b = a / N;

	if (N % 2 == 0) {
		cout << 0.5 << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

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

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 h, w;
    cin >> h >> w;
    if (h == 1 || w == 1)
    {
        cout << 1 << endl;
        return;
    }
    i64 ans = w * (h / 2) + (h & 1) * (w + 1) / 2;
    cout << ans << endl;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int n;
	int sum=100000;
	int t;
	scanf("%d",&n);
	for (int i = 1;i <= n;i++) {
		sum = sum*1.05;
		t = sum % 1000;
		if(t!=0)
			sum = sum - t + 1000;
		
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define PI 3.1415926535897932384626433832795028
#define INF (1<<29)
#define LINF (1LL<<60)
using namespace std;
using INT = long long;
using P = pair<int,int> ;

int main(){
    int n;
    int ans=0;
    cin >> n;
    vector<int> l;
    rep(i,n){
        int a;
        cin >> a;
        l.emplace_back(a);
    }
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]!=l[k]&&l[i]!=l[j]&&l[k]!=l[j]){
                    if(l[i]+l[j]>l[k]&&l[j]+l[k]>l[i]&&l[i]+l[k]>l[j])
                        ans++;
                }
            }
        }
    }
    cout << ans;
	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,i,b,n,j;
    set<ll>s;
    cin>>a>>b;
    for(i=0;i<b;i++)
    {
        cin>>n;
        ll c[n];
        for(j=0;j<n;j++)
        {
            cin>>c[j];
            s.insert(c[j]);
        }
    }
    cout<<a-s.size()<<endl;
}


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

int main() {
    int N; cin >> N;
    int A[N]; ll S = 0;
    for (int i = 0; i < N; i++) {cin >> A[i]; S += A[i];}
    ll X = S;
    for (int i = 1; i < N; i+=2) X -= A[i] * 2;
    printf("%d ", X);
    for (int i = 0; i < N-1; i++) {
        X = A[i] * 2 - X;
        printf("%d ", X);
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n, k; cin >> n >> k;
	if( k > (n-1)*(n-2)/2 ){
		cout << -1 << endl;
		return 0;
	}
	cout << n*(n-1)/2 - k << endl;
	vector<int> ng;
	int p = 0;
	for( int q = 0; q < n-1; ++q ){
		for( int r = q+1; r < n-1; ++r ){
			if( p >= k ) break;
			ng.push_back(q*1000+r);
			++p;
		}
	}
	sort( ng.begin(), ng.end() );
	for( int q = 0; q <= n-1; ++q ){
		for( int r = q+1; r <= n-1; ++r ){
			if( !binary_search( ng.begin(), ng.end(), q*1000+r ) ){
				cout << q+1 << ' ' << r+1 << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
// max

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    cout << v[0] * 10 + v[1] + v[2] << endl;
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

const int N=3010,MOD=998244353;

int ppow(int x,int y)
{
    int res=1;
    while(y)
    {
        if(y&1)
            res=res*x%MOD;
        y>>=1;
        x=x*x%MOD;
    }
    return res;
}

int a[N];
int dp[N][N];

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

    int n,s;
    cin>>n>>s;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int r2=ppow(2,MOD-2);
    dp[0][0]=ppow(2,n);
    for(int i=0;i<=n-1;i++)
        for(int j=0;j<=s;j++)
        {
            dp[i+1][j]=(dp[i+1][j]+dp[i][j])%MOD;
            if(j+a[i+1]<=s)
                dp[i+1][j+a[i+1]]=(dp[i+1][j+a[i+1]]+dp[i][j]*r2)%MOD;
        }
    cout<<dp[n][s];
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    while(1){
        int H; cin >> H;

        if(H==0){
            return 0;
        }
        vector<vector<int>> board(H+1, vector<int>(5));
        FOR(i,1,H+1){
            REP(j,5){
                cin >> board[i][j];
            }
        }

        int ans = 0;
        int ans_before = 0;
        while(1){
            FOR(i,1,H+1){
                int num = 0;
                int count = 0;
                REP(j,5){
                    if(num == board[i][j]){
                        count++;
                        if(count >= 3 && j==4){
                            ans += count * num;
                            for(int k= j; k>=j-count+1; k--){
                                board[i][k] = 0;
                            }
                        }
                    }else{
                        if(count >= 3){
                            ans += count * num;
                            for(int k= j-1; k>=j-count; k--){
                                board[i][k] = 0;
                            }
                        }
                        num = board[i][j];
                        count = 1;
                    }
                }  
            }
            REP(n,H){
                for(int i=H; i>=1; i--){
                    REP(j,5){
                        if(board[i][j]==0){
                            board[i][j]=board[i-1][j];
                            board[i-1][j]=0;
                        }
                    }
                }
            }

            if(ans == ans_before){
                cout << ans << endl;
                break;
            }
            ans_before = ans;

            // FOR(i,1,H+1){
            //     REP(j,5){
            //         cout << board[i][j] << " ";
            //     }
            //     cout << endl;
            // }

        }

    }
    return 0;
}


Measured memory_bytes: 3160
#include <stdio.h>
#define MAX 10000

int linearSearch(int,int);
int S[MAX];

int main(){

  int i,n,q,T,kosu=0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&T);
    if(linearSearch(T,n)==1) kosu++;
     }
  printf("%d\n",kosu);

  return 0;
}

int linearSearch(int key,int n){

  int i=0;
  S[n]=key;
  while(S[i]!=key){
    i++;
    if(i==n) return 0;
  }
  return 1;
}



Measured memory_bytes: 2108
from collections import deque

n = int(input())
color = [-1] * n
g = [[] for _ in range(n)]
l = [[] for _ in range(n)]

que = deque()
que.append(0)
color[0] = 1

for i in range(n-1):
    u,v,w = map(int,input().split()) 
    g[u-1].append(v-1)
    g[v-1].append(u-1)
    l[u-1].append(w)
    l[v-1].append(w)
    
while que:
    s = que.pop()
    for i in range(len(g[s])):
        x = g[s][i]
        y = l[s][i]
        
        if color[x] != -1:
            continue
        elif y % 2 == 0:
            color[x] = color[s]
        else:
            color[x] = (color[s]+1) % 2
            
        que.append(g[s][i])
        
for i in range(n):
    print(color[i])

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

int main(){
    long a, b, x;
    cin >> a >> b >> x;
    long ans;
    ans = b/x - a/x;
    if(a%x!=0){
        cout << setprecision(18) << ans << "\n";
    }else{
        cout << setprecision(18) << ans+1 << "\n";
    }
    return 0;
}

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

using namespace std;

int main()
{
  int N;
  vector<int> a;

  cin >> N;
  int n = N * 3;
  for (int i = 0; i < n; i++)
  {
    int temp;
    cin >> temp;
    a.push_back(temp);
  }

  sort(a.begin(), a.end());

  int itr2 = n - 2;
  //int itr3 = 0;

  unsigned long long sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += a[itr2];
    itr2 -= 2;
  }


  std::cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 2420
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<functional>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define INF 1000000007
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define CLR(a) memset((a), 0, sizeof(a))

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

ll gcd(ll a, ll b){
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    return b ? gcd(b, a % b) : a;
}

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

bool cmp_second(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void){

    char a[4];
    cin >> a[0] >> a[1] >> a[2] >> a[3];

    bool ans = false;

    if(a[0]==a[1] && a[2]==a[3] && a[0]!=a[2])ans = true;
    else if(a[0]==a[2] && a[1]==a[3] && a[0]!=a[1])ans = true;
    else if(a[0]==a[3] && a[1]==a[2] && a[0]!=a[1])ans = true;

    if(ans)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;

struct item
{
	int w, v;
};

ll knapsack(vector <item> &v, int n, int w)
{
	ll dp[n+1][w+1];
	memset(dp,0,sizeof(dp));
	dp[0][v[0].w]=v[0].v;
	forr(i,1,n)
	{
		forn(j,w+1)
		{
			dp[i][j]=dp[i-1][j];
			if(j-v[i].w < 0) continue;
			dp[i][j]=max(dp[i][j],dp[i-1][j-v[i].w] + v[i].v);
		}
	}
	ll ans = 0;
	forn(i,w+1) ans=max(ans,dp[n-1][i]);
	return ans;
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("test1.txt", "r", stdin);
	#endif

	int n, w;
	cin >> n >> w;
	vector <item> v(n);
	forn(i,n) cin >> v[i].w >> v[i].v;
	cout << knapsack(v,n,w) << endl;
    return 0;
}


Measured memory_bytes: 82508
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD =  1000000007 ;
const int INF = 2000000000;


    int A[3];

int main(){
    REP(i,3)cin>>A[i];
    sort(A,A+3);
    cout<<(A[0]==A[1]?A[2]:A[0]);
    return 0;

}


Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
a = []
b = []
for i in range(m):
    tmp = list(int(i) for i in input().split())
    a.append(tmp[0])
    b.append(tmp[1])
next = list([] for i in range(n))
for i in range(1,n+1):
    for j in range(m):
        if a[j]==i:
            next[i-1].append(b[j])
        elif b[j]==i:
            next[i-1].append(a[j])
cut = True
while cut:
    cut = False
    for i in range(n):
        if len(next[i])==1:
            if i+1 in next[next[i][0]-1]:
                next[next[i][0]-1].remove(i+1)
                cut = True
count = 0
for i in range(n):
    if len(next[i])==1:
        count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#define MAX_i 100000

typedef struct process{
    char name[11];
    int time;
}pr;
void enqueue(pr x);
pr dequeue();
pr p[MAX_i];
int head,tail;

int main(void){
    int n,q,i,sum=0;
    pr x;
    
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s %d",p[i].name,&p[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
        x=dequeue();
        if(x.time<=q){
            sum+=x.time;
            printf("%s %d\n",x.name,sum);
        }else{
            sum+=q;
            x.time-=q;
            enqueue(x);
        }
    }
    return 0;
}

void enqueue(pr x){
    p[tail]=x;
    if(tail+1==MAX_i){
        tail=0;
    }else{
        tail++;
    }
}

pr dequeue(){
    if(head+1==MAX_i){
        head=0;
        return p[MAX_i-1];
    }else{
        head++;
        return p[head-1];
    }
}



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

int kaibun(string S){
  int k=S.size();
  if(k==1) return 1;
  for(int i=0;i<k/2;i++){
    if(S[i]!=S[k-1-i]){
      return 0;
    }
  }
  return 1;
}

int main(){
  string s; cin >> s;
  int K=s.size();
  string f, b;
  f=s.substr(0,(K-1)/2);
  b=s.substr((K+1)/2,(K-1)/2);
  if(kaibun(f)+kaibun(s)+kaibun(b)==3){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}
  
    

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

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

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a(n);
    REP(i,0,n){
        cin>>a[i];
    }
    int ans=0;
    int temp=0;
    for(int i=1;i<n;i++){
        if(a[i]<=a[i-1]){
            temp++;
        }
        else{
            ans=max(temp,ans);
            temp=0;
        }
    }    
    ans=max(temp,ans);
    cout<<ans<<"\n";



    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
	while(1){
	int n,x,y;
	int z=0;
	int i,j,k;

		cin >> n >> x;
		if((n == 0)&&(x == 0)) break;

		for(i=1; i<=n; i++){
			for(j=1; j<i; j++){
				for(k=1; k<j; k++){

					y = i + j + k;
					if(y == x) z++;

				}
			}
		}

		cout << z << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
import java.util.*;
import java.io.*;


public class Main{
    public static void main(String[] args) throws Exception{
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = sc.nextInt();
        long[] X = new long[N];
        long[] L = new long[N];
        long[][] interval = new long[N][2];
        for(int i=0;i<N;i++){
            X[i] = sc.nextLong();
            L[i] = sc.nextLong();
            interval[i][0] = X[i] + L[i];
            interval[i][1] = X[i] - L[i];
        }
        Arrays.sort(interval,((u,v)->u[0]>v[0] ? 1 : u[0]<v[0] ? -1 : 0));
        int result = 0;
        long right = -1_000_000_000;
        for(int i=0; i<N;i++){
            long left = interval[i][1];
            if(left >= right){
                result++;
                right = interval[i][0];
            }
        }
        



        out.println(result);

        out.flush();
    }
        
}



class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

    int res = INT_MAX;    
    rep (i, 0, str.size() - 2) {
	int tmp = abs(stoi("753") - stoi(str.substr(i, 3)));
	res = min(res, tmp);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	map<char, int> m;
	rep(i, n){
		m[s[i]]++;
	}
	ll ans = 1;
	for(auto p : m){
		p.second++;
		ans *= p.second;
		ans %= 1000000007;
	}
	ans = (ans - 1) % 1000000007;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

double memo[2000][2001];
double prob(int k, int t, const string& s){
  if(memo[k][t] >= 0) return memo[k][t];
  double& res = memo[k][t];
  if(t == 0 && s[k] == 'R') return res = 1;
  if(t == 0 && s[k] == 'B') return res = 0;
  const int N = s.size();
  res = 0;
  for(int d = 1; d <= 6; d++){
    res += prob((k + d) % N, t - 1, s) / 6.0;
  }
  return res;
}

int main(){
  int N, T;
  while(cin >> N >> T && N){
    // REP(i, N)REP(j, T + 1) memo[i][j] = -1;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    /*
    double ans = 0;
    REP(i, N){
      ans = max(ans, prob(i, T, s));
    }
    */
    static double dp[2001][2000] = {};
    REP(i, T + 1)REP(j, N) dp[i][j] = 0;
    REP(i, N) dp[0][i] = (s[i] == 'R') ? 1.0 : 0.0;
    for(int t = 0; t < T; t++){
      for(int i = 0; i < N; i++){
        int curr = i;
        for(int d = 1; d <= 6; d++){
          curr++;
          if(curr == N) curr = 0;
          dp[t + 1][curr] += dp[t][i] / 6.0;
        }
      }
    }
    double ans = 0;
    REP(i, N) ans = max(ans, dp[T][i]);
    printf("%.16lf\n", ans);
  }
  return 0;
}

Measured memory_bytes: 33076
a,b = map(int,input().split())
if a*4 >=b and a*2 <=b:
    if b%4== 2:
        print('Yes')
    if b%4== 0:
        print('Yes')
    if b%4== 1:
        print('No')
    if b%4 ==3:
        print('No')
else:
    print('No')

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

template <typename T> T gcd(T m, T n) {
  T temp = 0;
  while(m % n != 0) {
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> as;

  int temp = 0;
  int max = 0;
  for(int i = 0; i < N; ++i) {
    cin >> temp;
    as.push_back(temp);
    chmax(max, temp);
  }

  int g = as[0];
  for(auto a : as) {
    g = gcd(g, a);
  }
  if(K > max || K % g != 0) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << "POSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 892
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N, M; cin >> N >> M;
	vector<int>targets(M);
	for (int i = 0; i < M; ++i) {
		int a; cin >> a; a--;
		targets[i] = a;
	}
	vector<int>scores(N);
	for (int i = 0; i < M; ++i) {
		int miss = 0;
		for (int j = 0; j < N; ++j) {
			int a; cin >> a; a--;
			if (a == targets[i])scores[j]++;
			else miss++;
		}
		scores[targets[i]] += miss;
	}
	for (auto s : scores) {
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
import sys
from collections import *
import heapq
import math
import bisect
import copy
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]

h,w=map(int,input().split())
a=[input() for i in range(h)]

while 1:
    flag=1
    lst=[]
    for i in range(h):
        tmp=a[i][0]
        if tmp=="#":
            continue
        for j in range(w):
            if tmp==a[i][j]:
                continue
            else:
                break
        else:
            lst.append(i)
            flag=0
    for i in range(len(lst)):
        del a[lst[-1-i]]
        h-=1

    lst=[]
    for i in range(w):
        tmp=a[0][i]
        if tmp=="#":
            continue
        for j in range(h):
            if tmp==a[j][i]:
                continue
            else:
                break
        else:
            lst.append(i)
            flag=0
    # print(lst)
    # print(a)
    for i in range(len(lst)):
        for j in range(h):
            a[j]=a[j][:lst[-1-i]] + a[j][lst[-1-i]+1:]
    w-=len(lst)
    if flag:
        break
for i in a:
    print(i)

Measured memory_bytes: 64748
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    set<string> s;
    int n;
    cin>>n;
    ll ans=0;
    while(n--){
	string t;
	cin>>t;
	if(t=="E869120")ans++;
    }
    cout<<ans<<endl;
}





Measured memory_bytes: 3220
def main():
    h, w = map(int, input().split())
    grid = ["#"*(w+2)]+["#"+input()+"#" for _ in [0]*h]+["#"*(w+2)]
    #grid = [[i == "." for i in j] for j in grid]
    ans_list = []
    for i in range(1, h+1):
        for j in range(1, w+1):
            if grid[i][j] == ".":
                ans_list.append((i, j))
    m = 0
    for i, j in ans_list:
        q = [(i, j)]
        dist = [[-1]*(w+2) for _ in [0]*(h+2)]
        cnt = 0
        dist[i][j] = 0
        while q:
            qq = []
            cnt += 1
            while q:
                x, y = q.pop()
                if dist[x-1][y] == -1:
                    if grid[x-1][y] == ".":
                        dist[x-1][y] = cnt
                        qq.append((x-1, y))
                if dist[x+1][y] == -1:
                    if grid[x+1][y] == ".":
                        dist[x+1][y] = cnt
                        qq.append((x+1, y))
                if dist[x][y-1] == -1:
                    if grid[x][y-1] == ".":
                        dist[x][y-1] = cnt
                        qq.append((x, y-1))
                if dist[x][y+1] == -1:
                    if grid[x][y+1] == ".":
                        dist[x][y+1] = cnt
                        qq.append((x, y+1))
            q = qq
        m = max(m, max([max([l for l in k]) for k in dist]))
    print(m)


main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
const int MAX=1e5+10;

ll N;
void input(){
    cin>>N;
    cout<<(N-1)*N/2<<endl;
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int NN(int n){
  if(n==0)return 1;
  else return n*NN(n-1);
}
double solve(int N,vector<double>X,vector<double>Y){
  if(N==1)return 0.0;
  double a=0.0;
  REP(i,N-1){
    a+=pow((X[N-1]-X[i])*(X[N-1]-X[i])+(Y[N-1]-Y[i])*(Y[N-1]-Y[i]),0.5);
  }
  
  return a+solve(N-1,X,Y);
}


//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
int main(){
  int N;
  double ans;
  cin>>N;
  vector<double>X(N);
  vector<double>Y(N);
  REP(i,N){
    cin>>X[i]>>Y[i];
  }

  ans=solve(N,X,Y)*2/N;
    
  cout<<setprecision(8)<<ans<<endl;
}


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

using namespace std;

const int k = 50;

char g[2 * k + 2][2 * k + 2];

int main() {
    int a, b; cin >> a >> b;
    for (int i = 0; i < k; i++) {
        for (int j = 0; j < 2 * k; j++) {
            g[i][j] = '#';
        }
    }

    for (int i = k; i < 2 * k; i++) {
        for (int j = 0; j < 2 * k; j++) {
            g[i][j] = '.';
        }
    }

    for (int i = 0 + 1; i < k and a > 1; i += 2) {
        for (int j = 0; j < 2 * k and a > 1; j += 2, a--) {
            g[i][j] = '.';
        }
    }

    for (int i = k + 1; i < 2 * k and b > 1; i += 2) {
        for (int j = 0; j < 2 * k and b > 1; j += 2, b--) {
            g[i][j] = '#';
        }
    }

    cout << 100 << " " << 100 << endl;
    for (int i = 0; i < 2 * k; i++) {
        for (int j = 0; j < 2 * k; j++) {
            printf("%c", g[i][j]);
        }
        puts("");
    }
}

Measured memory_bytes: 3592
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in [0]*H]
B = [list(map(int,input().split())) for _ in [0]*H]


C = [[abs(b-a) for a,b in zip(a_row,b_row)] for a_row,b_row in zip(A,B)]

dm = [[0]*W for _ in [0]*H]
dm[-1][-1] = 80
for i in range(H-1,-1,-1):
    for j in range(W-1,-1,-1):
        c = C[i][j]
        if i-1>=0:
            dm[i-1][j] = max(dm[i-1][j],dm[i][j] + c)
        if j-1>=0:
            dm[i][j-1] = max(dm[i][j-1],dm[i][j] + c)

d = [[set() for _ in [0]*W] for _ in [0]*H]
d[0][0] = {C[0][0]}

for i in range(H):
    for j in range(W):
        for n in d[i][j]:
            if i+1<H:
                c = C[i+1][j]
                if n+c <= dm[i][j]:
                    d[i+1][j].add(n+c)
                if n-c <= dm[i][j]:
                    d[i+1][j].add(abs(n-c))
            if j+1<W:
                c = C[i][j+1]
                if n+c <= dm[i][j]:
                    d[i][j+1].add(n+c)
                if n-c <= dm[i][j]:
                    d[i][j+1].add(abs(n-c))
ans = min(abs(o) for o in d[-1][-1])
print(ans)

Measured memory_bytes: 722180
#include <iostream>
#include <algorithm>
using namespace std;
int main(void)
{
	int n;
	int date[8] = {0,10,20,30,40,50,60,1000};
	while(cin>>n){
		int freq[7]={0};
		if(!n) break;
		while(n--){
			int year;
			cin >> year;
			freq[min(year/10,6)]++;
		}
		for(int i = 0; i < 7; i++){
			cout << freq[i] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

vector<int> divisor(int n) {
	vector<int> res;
	for (int i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			res.emplace_back(i);
			if (i != n / i) res.emplace_back(n / i);
		}
	}
	return res;
}

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

	auto a = divisor(n);
	a.emplace_back(1);
	int ans = 1e18;
	rep(i, a.size()) {
		//cout << a[i] << ' ' << n / a[i] << endl;
		ans = min(ans, a[i] + n / a[i]);
	}
	cout << ans - 2 << endl;
}


Measured memory_bytes: 384
/*
 * Matheus Oliveira
 * 09:07:45 17/05/2020
 * c.cpp
*/

#include <bits/stdc++.h>
using namespace std;

#define EPS
#define INF
#define MAXN
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define sc(x) scanf("%d", &x);
#define sc2(x, y) scanf("%d %d", &x, &y);
#define sc3(x, y, z) scanf("%d %d %d", &x, &y, &z);
#define debug(x) printf("%s: %d\n", #x, x);
#define debugarr(x, bg, ed) printf("%s: ", #x); for(int i = bg; i < ed; i++) printf("%d%c", x[i], (i == ed-1) ? '\n' : ' ');

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main() {
	int a, b, h, m;
	scanf("%d %d %d %d", &a, &b, &h, &m);
	
	double ans, ha, ma, dif, da, db;
	
	ha = 0.5 * (60.0 * ((double) h) + m);
	ma = 6.0 * ((double) m);

	da = a;
	db = b;

	dif = fabs(ha - ma);
	ans = sqrt( da*da + db*db - 2.0 * da * db * cos(dif * acos(-1)/180.0) );

	printf("%.17f\n", ans);
	return 0;
}

Measured memory_bytes: 4228