akhauriyash/Code-Regression huggingface dataset:
#include<string>
#include<iostream>
using namespace std;

int main() {
	int s;
	cin >> s;
	
	int a=0;

	s >= 100 ? a += 1 : a += 0;
	s-100 >= 10 ? a += 1 : a += 0;
	s >= 10 && s <= 11 ? a += 1 : a += 0;
	s - 110 == 1 ? a += 1 : a += 0;
	s - 100 == 1 ? a += 1 : a += 0;
	s - 10 == 1 ? a += 1 : a += 0;
	s == 1 ? a += 1 : a += 0;
	cout << a << endl;

}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
//#include <cassert>
#include <vector>
//#include <array>
//#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//#include <stack>
//#include <queue>
using ll = long long;
using namespace std;

template<typename Tint>
Tint gcd(Tint a, Tint b) {
	// O(log max(a,b))
	return b != 0 ? gcd(b, a % b) : a;
}

template<typename Tint>
Tint lcm(Tint a, Tint b) {
	return a / gcd(a, b) * b;
}

int main() {
	int n;
	cin >> n;
	ll ans = 1;
	for (int i = 0; i < n; i++)
	{
		ll t;
		cin >> t;
		ans = lcm(ans, t);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  for (int x = 0; x <= N; ++x) {
    for (int y = 0; y <= N - x; ++y) {
      auto z = N - x - y;
      if (Y == x * 10000 + y * 5000 + z * 1000) {
        cout << x << " " << y << " " << z << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}


Measured memory_bytes: 3564
#include<stdio.h>
int main(){
    int r,g,b,n;
    scanf("%d %d %d",&r,&g,&b);
    n=r*100+g*10+b;
    if(n%4==0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
int a[MAXN],n,L,go[19][MAXN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	scanf("%d",&L);
	for(int i=1;i<=n;++i){
		int p=upper_bound(a+1,a+n+1,a[i]+L)-a;
		go[0][i]=p-1;
	}
	for(int i=1;i<=18;++i)
		for(int j=1;j<=n;++j)
			go[i][j]=go[i-1][go[i-1][j]];
	int q;
	scanf("%d",&q);
	while(q--){
		int x,y,ans=0;
		scanf("%d%d",&x,&y);
		if(x>y)swap(x,y);
		for(int i=18;i>=0;--i)
			if(a[go[i][x]]<a[y])
				x=go[i][x],ans+=(1<<i);
		printf("%d\n",ans+1);
	}
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>

using namespace std;

int main(void)
{
    u_int n, m, l;
    cin >> n >> m >> l;

    u_int a[n][m], b[m][l];
    unsigned long long c[n][l];

    for (u_int i = 0; i < n; i++)
        for (u_int j = 0; j < m; j++)
            cin >> a[i][j];

    for (u_int i = 0; i < m; i++)
        for (u_int j = 0; j < l; j++)
            cin >> b[i][j];

    for (u_int i = 0; i < n; i++)
        for (u_int j = 0; j < l; j++)
            c[i][j] = 0;

    for (u_int i = 0; i < n; i++) {
        for (u_int j = 0; j < l; j++)
            for (u_int k = 0; k < m; k++)
                c[i][j] += a[i][k] * b[k][j];
    }

    for (u_int i = 0; i < n; i++) {
        for (u_int j = 0; j < l - 1; j++)
            printf("%llu ", c[i][j]);
        printf("%llu\n", c[i][l - 1]);
    }
    
    return 0;
}

Measured memory_bytes: 1296
a,b,m=map(int,input().split())
a_prices=[int(i) for i in input().split()]
b_prices=[int(i) for i in input().split()]
a_min=min(a_prices)
b_min=min(b_prices)
a_add_b=a_min+b_min
for i in range(m):
    x,y,c=map(int,input().split())
    if a_prices[x-1]+b_prices[y-1]-c<a_add_b:
        a_add_b=a_prices[x-1]+b_prices[y-1]-c
print(a_add_b)

Measured memory_bytes: 18488
/*input
16 22
12 1
3 1
4 16
7 12
6 2
2 15
5 16
14 16
10 11
3 10
3 13
8 6
16 8
9 12
4 3
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
typedef long long int ll;
#define ld long double
#define pii pair<int,int>
#define f first
#define s second
#define pb emplace_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define sz(_a) (ll)(_a.size())
#define FILL(n) memset(n,0,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
ll mypow(ll a,ll b){
    ll res=1LL;
    while(b){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}
ll arr[maxn];
bool vis[maxn];
vector<int> v[maxn];
void dfs(int u){
    vis[u]=true;
    int k=1;
    for(auto x:v[u]){
        if(!vis[x]){
            for(auto z:v[x]){
                if(!vis[z]) arr[z]++;
            }
            arr[x]+=k;
            ++k;
            dfs(x);
        }
    }
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
    cin>>n>>k;
    FILL(arr);
    FILL(vis);
    REP(i,n-1){
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(0);
    ll ans=1;
    REP(i,n){
     //   cout<<arr[i]<<'\n';
        ans=(ans*(k-arr[i]))%MOD;
    }
    cout<<ans;
}

Measured memory_bytes: 8960
N = int(input())
As, Bs, Cs = [
  sorted(map(int, input().split()))
  for _ in range(3)
]

from bisect import *

def sums():
  for b in Bs:
  	yield bisect_left(As, b) * (N - bisect_right(Cs, b))

print(sum(sums()))

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);

     int cnt=0,a,b,ans=0;
     cin>>a>>b;
     if(b==1){
        cout<<"0"<<endl;
        return 0;
     }
     cnt=a;
     ans=1;
     while(cnt<b){
        cnt+=a;
        cnt--;
        ans++;
     }
     cout<<ans<<endl;
     return 0;
}


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

#define   ll             long long int
#define   pb             push_back
#define   mp             make_pair
#define   fast           ios_base::sync_with_stdio(false);cin.tie(NULL);
#define   ff             first
#define   ss             second
#define   nil           -10e+9
#define   initial         0
#define   waiting         1
#define   visit           2
#define   inf            10e+9
#define   mx             200005
#define   mxx            1000005
#define   mod            1000000007
#define   pr             pair<ll,ll>
#define   pp_queue       priority_queue<pr,vector<pr>, greater<pr> >
#define   dp_queue       priority_queue<int,vector<int>, greater<int> >
#define   sp_queue       priority_queue<int>
#define   fr(i,p,q)      for(int i=p;i<q;++i)
#define   frr(i,p,q)     for(int i=p;i<=q;++i)
#define   mem(a,b)       memset(a,b,sizeof(a))
#define   len(a)         (int)a.size()
#define   input          freopen("input.txt", "r", stdin);
#define   output         freopen("output.txt", "w", stdout);
#define   debug(arr,j,n) fr(i,j,n) cout<<arr[i]<<" ";

ll power(ll a,ll b){ll aa=1;while(b){if(b&1){aa=aa*a;aa%=mod;}a=a*a;a%=mod;b/=2;}return aa;}

using namespace std;

int main()
{
  ll n;

  cin>>n;

  ll sum=(n*(n+1))/2-n;
  cout<<sum<<"\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;


int main(){
    int a, b, c, d, k;
    cin >> a >> b >> c >> d >> k;
    int A = 60 * a + b;
    int B = 60 * c + d;
    int res = B - A - k;
  res = max(res, 0);
    cout << res << endl;
}

Measured memory_bytes: 3184
D[13][3]={{1,0,0},{0,1,0},{0,0,1},{1,1,0},{1,0,1},{0,1,1},{1,-1,0},{1,0,-1},{0,1,-1},{1,1,1},{-1,1,1},{1,-1,1},{1,1,-1}};
M[9][9][9],q[2];main(n,m,p,I,x,y,z,j,c,d,J){for(;scanf("%d%d%d",&n,&m,&p),n;){
	for(memset(M,I=0,sizeof(M)),c=1;I++<p;c*=-1){
		for(scanf("%d%d",&x,&y),z=1;;z++)if(!M[x][y][z]){M[x][y][z]=c;break;}
		for(d=0;d<13;d++){
			for(j=0;j<2;j++)for(J=2*j-1,q[j]=J;;q[j]+=J)if(M[x+D[d][0]*q[j]][y+D[d][1]*q[j]][z+D[d][2]*q[j]]!=c)break;
			if(q[1]-q[0]-1>=m){printf("%s %d\n",c==1?"Black":"White",I);goto next;}
		}
	}
	puts("Draw");
next:
	for(;I++<p;)scanf("%d%d",&x,&y);
}exit(0);}

Measured memory_bytes: 612
open System

let N = stdin.ReadLine() |> int
let A = stdin.ReadLine().Split(' ') |> Array.map int
// 180504 加筆：canDiv2は 0入力で無限ループするので注意
//（今回は問題の制約で0が入力されない事が保証されている）
let rec canDiv2 = fun v -> if v % 2 = 1 then 0 else (1 + canDiv2(v / 2))

A
|> Array.map canDiv2
|> Array.min
|> printfn "%d"

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int usable[12] = {1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049};

int main()
{
	int n;
	cin >> n;
	bool withdrawable[n+1][2];
	FOR(i,0,n+1)withdrawable[i][0] = false;
	FOR(i,1,n+1)withdrawable[i][1] = false;
	withdrawable[0][1] = true;
	FOR(i,1,n+1){
		FOR(j,0,12){
			FORR(k, n - usable[j], 0){
				if(withdrawable[k][i % 2])withdrawable[k + usable[j]][(i+1)%2] = true;
			}
		}
		if(withdrawable[n][(i+1)%2]){
			ANS(i);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#define N 10000

int main(void){

  int n, q, c=0, i, j;
  int s[N], t[N];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }

  scanf("%d",&q);

  for(j=0;j<q;j++){
    scanf("%d",&t[j]);
  }

  for(j=0;j<q;j++){
    for(i=0;i<n;i++){

      if(s[i] == t[j]){
        c++;
        break;
      }
    }
  }

  printf("%d\n", c);

  return 0;
}


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

using namespace std;

struct info{

};
int take[27];
int main() {
  int n , k ; cin>>n>>k;
  for(int i = 0 ; i < n; ++i){
    string s ; cin>>s;
    take[s[0] - 'A']++;
  }
  int L = 0 , R = n;
  while(L <= R){
    int mid = (L + R) >> 1;
    int now = 0;
    for(int i = 0;  i < 26; ++i){
      now += min(mid , take[i]);
    }
    if(now >= k * mid){
      L = mid + 1;

    }else R = mid - 1;
  }
  cout<<((L + R)>>1)<<endl;

}

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

#define rep(i,a,n)     for(int i=a;i<n;i++)
#define rep3(n)        for(int i=0;i<n;i++)
#define ll             long long
#define int            long long
#define pb             push_back
#define all(v)         v.begin(),v.end()
#define endl           "\n"
#define eb             emplace_back
#define x              first
#define y              second
#define gcd(a,b)       __gcd(a,b)
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pres(a,x)      a.find(x)!=a.end()
#define sz(a)          (int)a.size()
#define pii            pair<int,int>
#define hell           1000000007
#define elasped_time   1.0 * clock() / CLOCKS_PER_SEC
using namespace std;


template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.x>>a.y;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.x<<" "<<a.y;return out;}
template<typename T,typename T1>T maxs(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T mins(T &a,T1 b){if(b<a)a=b;return a;}

int expo(int x,int y,int p){
    int a=1;
    x%=p;
    while(y){
        if(y&1)a=(a*x)%p;
        x=(x*x)%p;
        y/=2;
    }
    return a;
}



int solve(){
 	int n;cin>>n;
 	vector<int>a(n+1),f(n+1);
 	int cnt=0;
 	rep(i,1,n+1){
 		char c;cin>>c;
 		a[i]=c-48;
 		cnt+=a[i];
 	}
 	auto func=[&](int x){
 		int cnt=0;
 		while(x){
 			int z=__builtin_popcount(x);
 			x=x%z;
 			cnt++;
 		}
 		return cnt;
 	};
 	if(cnt<=1){
 		rep(i,1,n+1){
 			if(a[i])f[i]=0;
 		}
 	}
 	else{
 		int k=cnt-1;
 		int rem=0;
 		rep(i,1,n+1){
 			rem+=a[i]*expo(2,n-i,k);
 			rem%=k;
 		}
 		rep(i,1,n+1){
 			if(a[i]==0)continue;
 			int temp=(rem-expo(2,n-i,k)+k)%k;
 			f[i]=1+func(temp);
 		}
 	}
 	int k=cnt+1;
 	int rem=0;
 	rep(i,1,n+1){
 		rem+=a[i]*expo(2,n-i,k);
 		rem%=k;
 	}
 	rep(i,1,n+1){
 		if(a[i])continue;
 		int temp=(rem+expo(2,n-i,k))%k;
 		f[i]=1+func(temp);
 	}
 	rep(i,1,n+1)cout<<f[i]<<endl;
 return 0;
}
signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef SIEVE
    sieve();
    #endif
    #ifdef NCR
    init();
    #endif
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
 

Measured memory_bytes: 6364
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n,m;
  cin>>n>>m;
  vector<vector<string>> a(n+1);
  int ac=0,wa=0;
  rep(i,m){
    int p;
    string s;
    cin>>p>>s;
    a[p].push_back(s);
    
  }
  for(int i=1 ;i<=n;i++){
    bool ok=false;
    rep(j,a[i].size()){
      if(a[i][j]=="AC") ok=true;
    }
    if(ok){
      rep(k,a[i].size()){
        if(a[i][k]=="WA") wa++;
        else break;
      }
      ac ++;
    }
    
  }
  cout <<ac<<" "<<wa<<endl;
}




Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1;i <= n;i++){
        if(i % 3 != 0 && i % 5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}




Measured memory_bytes: 3628
#include<stdio.h>

int main(void){
  long long int N;
  long long int i,j,dig,min_dig=11,tar;
  scanf("%lld",&N);
  for(i=1;i*i<=N;i++){
    //min_dig=10;
    if(N%i==0){
      j=0;
      tar=1;
      while(N/i >= tar){
        tar*=10;
        j++;
      }
      dig=j;
      //printf("%lld\n",dig);
    }
    if(min_dig > dig){
      min_dig = dig;
    }
  }
  printf("%lld\n",min_dig);
  return 0;
}

Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

const int N = 510;

//head

int n;
string s[N];
int cnti[N], cntj[N];
vi chu;
int ans;
bool jf = false;

int mmi(vi::iterator it1, vi::iterator it2) {
  if(it1 == it2) return n;
  else return *min_element(it1, it2);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> s[i];

  rep(i, n) rep(j, n) {
    if(s[i][j] == '#') {
      cnti[i]++;
      cntj[j]++;
      jf = true;
    }
  }

  rep(i, n) {
    if(cntj[i]) chu.emplace_back(n-cnti[i]);
    if(cntj[i] != n) ans++;
  }
  cout << (jf?ans+min(1+n-*max_element(cnti, cnti+n), mmi(all(chu))):-1) << endl;
}

Measured memory_bytes: 3904
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n, A, B, C, D; cin >> n >> A >> B >> C >> D; A--, B--, C--, D--;
    string S; cin >> S;

    bool fg= true;
    for(int i=min(A,B); i<max(C,D); i++){
        if(S[i] == '#' && S[i+1] == '#'){
            fg = false; break;
        }
    }
    if(C>D){
        bool fg2 = false;
        for(int i=B; i<=D; i++){
            if(S[i] != '#' && S[i-1] != '#' && S[i+1] != '#'){
                fg2 = true; break;
            }
        }
        if(!fg2) fg = false;
    }

    if(fg) cout << "Yes" << ln;
    else cout << "No" << ln;
}

Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range (0, N-1):
    min = i
    for j in range(i+1, N):
        if A[j] < A[min]:
            min = j
    if min == i:
        continue
    else:
        tmp = A[min]
        A[min] = A[i]
        A[i] = tmp
        cnt += 1

print(" ".join(map(str, A)))
print(cnt)


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int K = max(A, B);
  K = max(K, C);
  int J = min(A, B);
  J = min(J, C);
  cout << K - J << endl;
}
  

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
#define fi first
#define se second
#define pb push_back

int main() {
  ios::sync_with_stdio(false);
  double x;
  cin>>x;cout<<fixed<<setprecision(10);
  cout<<(x/3)*(x/3)*(x/3);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 100
#define INF   1000000

int n;
int k[N_MAX];
int direction[N_MAX][N_MAX];
int cost[N_MAX][N_MAX];
int distance[N_MAX];

void Dijkstra(int p,int c){
  int i;
  distance[p] = c;
  for( i=0; i<k[p]; i++){
    if(distance[direction[p][i]] > c + cost[p][i]){
      Dijkstra(direction[p][i], c + cost[p][i]);
    }
  }
}

int main(){
  int i;
  int j;
  scanf("%d",&n);
  for( i=0; i<n; i++){
    int u;
    scanf("%d", &u);
    scanf("%d", &k[u]);
    for( j=0; j<k[u]; j++){
      scanf("%d", &direction[u][j]);
      scanf("%d", &cost[u][j]);
    }
  }
  
  for( i=0; i<n; i++){
    distance[i] = INF;
  }
  
  Dijkstra(0,0);
  
  for(i=0;i<n;i++){
    printf("%d %d\n", i, distance[i]);
  }
}




Measured memory_bytes: 2100
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int counter = 1;
		int profit = 0;
		int min = sc.nextInt();
		for(int i = 0; i < n - 1; i++) {
			int a = sc.nextInt();
			if(a < min)
				min = a;
			else if(a - min > profit) {
				profit = a - min;
				counter = 1;
			}
			else if(a - min == profit)
				counter++;
		}
		System.out.println(String.valueOf(counter));
	}
}

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

using namespace std;

int a[105];
int b[105];
int c[105];
int d[105];
vector<int> g[205];
int n;
int match[205];
bool used[205];
bool dfs(int v) {
  used[v] = true;

  for(int i = 0; i < g[v].size(); i++) {
    int u = g[v][i];
    int w = match[u];
    if(w == -1 || !used[w] && dfs(w)) {
      match[v] = u;
      match[u] = v;
      return true;
    }
  }

  return false;
}
  

int matching() {
  int res = 0;
  memset(match, -1, sizeof match);
  
  for(int i = 0; i < n; i++) {
    if(match[i] < 0) {
      memset(used,0,sizeof used);
      if(dfs(i)) {
	res++;
      }
    }
  }
  return res;
}
  
int main() {

  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < n; i++) {
    cin >> c[i] >> d[i];
  }

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < n; j++) {
      if(a[i] < c[j] && b[i] < d[j]) {
	g[i].push_back(j + n);
	g[j + n].push_back(i);
      }
    }
  }

  cout << matching() << endl;
}


Measured memory_bytes: 256
while True:   
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):    
            if (i+j)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7000
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

ans = True
for a in A:
    if a % 2 == 0:
        if a % 3 != 0 and a % 5 != 0:
            ans = False

print('APPROVED' if ans else 'DENIED')


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  int N;
  cin>>N;
  VI A(N);
  rep(i,N) cin>>A[i];
  int X=0;
  rep(i,N) X^=A[i];
  rep(i,N) cout<<(X^A[i])<<" ";
  cout<<endl;
}


Measured memory_bytes: 4048
#include <iostream>
#include <vector>

using namespace std;

int main(){
  long long int A, B, K;
  cin >> A >> B >> K;
  if(B - A + 1 > 2*K){
    for(long long int i = A; i <= A + K - 1; i++) cout << i << " ";
    for(long long int i = B - K + 1; i <= B; i++) cout << i << " ";
  }else{
    for(long long int i = A; i <= B; i++) cout << i << " ";  
  }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int ms = 1e5 + 10;
int lowbit(int x)
{
    return x & (-x);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, t;
    cin >> n;
    multiset<int> s, g;
    for (int i = 1; i <= 1 << n; ++i)
    {
        cin >> t;
        s.insert(t);
    }
    g.insert(*s.rbegin());
    s.erase(*s.rbegin());
    for (int i = 1; i <= n; ++i)
    {
        vector<int> v;
        for (int j : g)
        {
            auto it = s.lower_bound(j);
            if (it == s.begin())
            {
                printf("No");
                return 0;
            }
            --it;
            v.push_back(*it);
            s.erase(it);
        }
        for (int j : v)
        {
            g.insert(j);
        }
    }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 13304
#include<stdio.h>
int main(){
 long long n,a,b;
 char s[100];
 while(scanf("%lld %lld %lld",&n,&a,&b),n){
  a--;
  b--;
  s[n]=0;
  while(n--){
   s[n]=(a%2==b%2)?'L':'R';
   a=(a<(1LL<<n))?(1LL<<n)-a-1:a-(1LL<<n);
   b/=2;
  }
  printf("%s\n",s);
 }
 return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin >> n;
    long long int min = LLONG_MAX;
    for(long double i = 1.0;i <= sqrt(n);i++)
    {
        if(ceil(n / i) == floor(n / i))
        {
            long long int a = n / i;
            long long int b = n / a;
            if((a + b) < min)
            {
                min = a + b - 2;
            }
        }
    }
    cout << min;

    return 0;
}

Measured memory_bytes: 256
from itertools import product
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 10**18
for bit in product(range(2), repeat=n):#k+1個以上の建物の高さを増やす必要はない
    ma = 0
    cost = 0
    see = 0
    for i in range(n):
        ai = a[i]
        if ai>ma:
            see += 1
            ma = ai
        elif bit[i]:
            ma = ma + 1
            see += 1
            co = ma - ai
            cost += co
    if see>=k:
        ans = min(ans, cost)
            
print(ans)

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

int u, v, d[4];

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	for (int i = 0; i < 3; i++)
		cin >> u >> v, d[--u]++, d[--v]++;
	sort(d, d + 4);
	cout << (d[0] == 1 && d[1] == 1 && d[2] == 2 && d[3] == 2? "YES": "NO");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll x;
  cin >> x;
  ll ans = x / 500 * 1000;
  x %= 500;
  ans += x / 5 * 5;
  cout << ans << endl;
}

Measured memory_bytes: 256
/*
First, solve the problem.Then write the code. - John Johnson
@author: returnAC
*/
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define need_for_speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); // Thanks Joshua :)
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c)) 
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);

signed main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	need_for_speed;
	int a,b,c;
	cin>>a>>b>>c;
	int res = 0;
	for(int i=100;i>=1&&c;i--)
		if(a%i==0&&b%i==0)
			--c,res=i;
	cout<<res<<endl;
}

Measured memory_bytes: 256
import Control.Monad
import Control.Monad.ST
import qualified Data.Array as A
import qualified Data.Array.ST as ST
import qualified Data.Array.Unboxed as AU
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.Int
import qualified Data.IntMap as IM
import Data.List
import qualified Data.Map as M
import Data.Maybe
import Data.Ord
import qualified Data.Set as S
import Data.Time
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

main = do
  [a, b, h] <- concat <$> readInts 3
  let ans = ((a + b) * h) `div` 2
   in print ans

Measured memory_bytes: 380
s = input()
li = list(s)
k = int(input())
tmp = []
for i,l in enumerate(li):
    for kk in range(k):
        #print(i,l,kk)
        if i+kk <= len(li):
            tmp.append(''.join(li[i:i+1+kk]))
#print(tmp)
print(sorted(set(tmp))[k-1])

Measured memory_bytes: 5084
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

int n;
int x[10], y[10];

double getlen(int x1, int y1, int x2, int y2)
{
	int tmp1 = x2 - x1;
	int tmp2 = y2 - y1;
	// cout << x1 << " " << y1 << " " << x2 << " " <<y2 << sqrt(tmp1 * tmp1 + tmp2 * tmp2) << endl;
	return sqrt(tmp1 * tmp1 + tmp2 * tmp2);
}

double solve(int now, vector<bool> ischecked)
{
	double cnt = 0.0;
	double res = 0.0;
	for(int i = 0; i < n; i++){
		if(ischecked[i]) continue;
		ischecked[i] = true;
		res += solve(i, ischecked) + getlen(x[now], y[now], x[i], y[i]);
		cnt += 1.0;
		ischecked[i] = false;
	}
	if(cnt == 0.0) return 0;
	return res / cnt;
}

int main()
{
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	long long int fact[10] = {};
	fact[0] = 1;
	for(int i = 1; i <= n; i++){
		fact[i] = fact[i - 1] * i;
	}
	double ans = 0.0;
	vector<bool> ischecked(10, false);
	for(int i = 0; i < n; i++){
		ischecked[i] = true;
		ans += solve(i, ischecked);
		ischecked[i] = false;
	}
	ans /= (double)n;
	printf("%.10f\n", ans);
}

Measured memory_bytes: 256
# 二分探索法を利用する場合
from bisect import bisect_left, bisect_right

N = int(input())
A = list(int(i) for i in input().split())  
B = list(int(i) for i in input().split())  
C = list(int(i) for i in input().split())

# sortの計算量はO(nlogn)
A.sort()
B.sort()
C.sort()

ans = 0
for i in range(N):
    x = bisect_left(A,B[i])
    y = bisect_right(C,B[i])
    ans += x*(N-y)
print(ans)


Measured memory_bytes: 23360
H, W = (int(i) for i in input().split())
L = []
L.append(["."]*(W + 2))
for i in range(H):
    D = [str(i) for i in input()]
    L.append(["."] + D + ["."])
L.append(["."]*(W + 2))

res = "Yes"

for i in range(1,H + 1):
    for j in range(1,W + 1):
        if L[i+1][j] == "." and L[i-1][j] == "." and L[i][j+1] == "." and L[i][j-1] == "." and L[i][j] == "#":
            res = "No"

print(res)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<set>
using namespace std;

int main () {
  char c;
  cin >> c;
  set<char> vowel = {'a', 'i', 'u', 'e', 'o'}; 
  
  cout << (vowel.count(c) > 0 ? "vowel" : "consonant") << endl;
}

Measured memory_bytes: 3032
#define ffor(i,a,b) for (int i=(a);i<(b);i++)
#define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<queue>
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

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

	int A,B;
	cin >> A >> B;

	if(A+B < 24) cout << A+B << endl;
	else if(A+B >= 24) cout << A+B-24 << endl;

	return 0;
}


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

int A[101][101], B[101][101];
bool dp[101][101][101010];

int main() {
    int H, W;
    cin >> H >> W;

    rep(i, H) rep(j, W) cin >> A[i][j];
    rep(i, H) rep(j, W) cin >> B[i][j];

    dp[0][0][abs(A[0][0]-B[0][0])] = true;
    rep(i, H) rep(j, W) rep(k, 10000) {
        if (dp[i][j][k]) {
            if (i+1 < H) {
                dp[i+1][j][abs(k - A[i+1][j] + B[i+1][j])] = true;
                dp[i+1][j][abs(k - B[i+1][j] + A[i+1][j])] = true;
            }
            if (j+1 < W) {
                dp[i][j+1][abs(k - A[i][j+1] + B[i][j+1])] = true;
                dp[i][j+1][abs(k - B[i][j+1] + A[i][j+1])] = true;
            }
        }
    }

    int ans = 1e8;
    rep(i, 10000) {
        if (dp[H-1][W-1][i]) {
            cout << i << endl;
            break;
        }
    }
}


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

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

  int answer = 0;

  for (int i = 0; i < 3; i++) {
    if (N[i] == '1') {
      answer++;
    }
  }
  
  cout << answer << endl;

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define dbg(x) cerr << #x << ": " << x << endl
int main() {
  vector<vector<int>> A(3, vector<int>(3));
  rep(i, 3) rep(j, 3) cin >> A[i][j];
  int n;
  cin >> n;

  rep(k, n) {
    int b;
    cin >> b;
    rep(i, 3) rep(j, 3) if(A[i][j] == b) A[i][j] = 0;
  }
  string ans = "No";
  rep(i, 3) {
    int x = 0;
    rep(j, 3) x |= A[i][j];
    if(x == 0) ans = "Yes";
  }
  rep(j, 3) {
    int x = 0;
    rep(i, 3) x |= A[i][j];
    if(x == 0) ans = "Yes";
  }
  {
    int x = 0;
    rep(i, 3) x |= A[i][i];
    if(x == 0) ans = "Yes";
  }
  {
    int x = 0;
    rep(i, 3) x |= A[i][2 - i];
    if(x == 0) ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}

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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;
bool OK(string s)
{
string t = s;
reverse(ALL(t));
return t == s;
}

int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        //int n; cin>>n; int arr[n]; for(int i = 0; i<n; i++) cin>>arr[i];
		string s ; cin>>s;
		int n = s.size();
		string a = s.substr(0,(n-1)/2);
		string b = s.substr((n+3)/2 - 1);
		
		//cout<<a<<endl;
		//cout<<b<<endl;
		
		
		if(!OK(b)) return cout<<"No",0;
		if(!OK(a)) return cout<<"No",0;
		if(!OK(s)) return cout<<"No",0;
		
		cout<<"Yes";
		cout<<endl;
    }
    return 0;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let v = read_vec::<i64>();
    let total =
        (0..n - 1).map(|i| (v[i + 1] - v[i]).abs()).sum::<i64>() + v[0].abs() + v[n - 1].abs();
    debug!(total);
    let ans = total - v[0].abs() + v[1].abs() - (v[0] - v[1]).abs();
    println!("{}", ans);
    for i in 1..n - 1 {
        let ans =
            total + (v[i - 1] - v[i + 1]).abs() - (v[i - 1] - v[i]).abs() - (v[i + 1] - v[i]).abs();
        println!("{}", ans);
    }
    let ans = total - v[n - 1].abs() + v[n - 2].abs() - (v[n - 1] - v[n - 2]).abs();
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 7036
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>

using namespace std;
 
int main() {
    string S;
    string str[4] = {"dream", "dreamer", "erase", "eraser"};

    cin >> S;

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(str[i].begin(), str[i].end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; ++j) {
            string d = str[j];

            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;


	return 0;
}

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

int main(){

    int n;
    cin >> n;

    vector<int> h(n);

    rep(i,n) cin >> h[i];

    vector<int> c(n);

    c[0]=0;
    c[1]=abs(h[0]-h[1]);

    for(int i=2;i<n;i++){
        c[i]=min(c[i-1]+abs(h[i-1]-h[i]),c[i-2]+abs(h[i-2]-h[i]));
    }


    cout << c[n-1] <<endl;

    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,avx,avx2,popcnt,tune=native")
#pragma GCC optimize(2)
#include <immintrin.h>
#include <emmintrin.h>
using namespace std;
template<class code>inline code read(const code &a){
    code x=0;short w=0;char ch=0;
    while(!isdigit(ch)){w|=ch=='-';ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return w?-x:x;
}
void pr(register int x){
	if(x<0){putchar('-');x=-x;}
	if(x>=10)pr(x/10);
	putchar(x%10+48);
}
int n,a;
long long sum;
int main(){
	ios::sync_with_stdio(false);
	n=read(n);
	for(register int i=1;i<=n;++i)a=read(a),sum+=a;
	if(sum%2)printf("NO");
	else printf("YES");
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

P = [0]*N
P[1] = abs(A[1]-A[0])

for i in range(2,N):
  P[i] = min(abs(A[i]-A[i-1])+P[i-1], abs(A[i]-A[i-2])+P[i-2])
  
print(P[N-1])

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const int INF = 1e9;

int main(void){

	
	ll N; cin >> N;
	N--;
	ll ans = N*(N+1)/2;
	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>


int main()
{
	int h = 0, w = 0, n = 0, ans = 0;
	int point[1000][2] = {};
	std::cin >> h >> w >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> point[i][0] >> point[i][1];
	}
	for (int i = 0; i < n - 1; i++) {
		if ((point[i + 1][1] - point[i][1] < 0 && point[i + 1][0] - point[i][0] > 0)|| (point[i + 1][0] - point[i][0] < 0 && point[i + 1][1] - point[i][1] > 0)) {
			ans += std::abs(point[i + 1][0] - point[i][0]) + std::abs(point[i + 1][1] - point[i][1]);
		}
		else {
			ans += std::max(std::abs(point[i + 1][0] - point[i][0]), std::abs(point[i + 1][1] - point[i][1]));
		}
	
	}
	std::cout << ans << std::endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++)
  {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k)
{
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}

int main()
{
  int n;
  int x[200000];
  int y[200000];
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> x[i] >> y[i];
  }
  int z[200000];
  int w[200000];
  for (int i = 0; i < n; i++)
  {
    z[i] = x[i] + y[i];
    w[i] = x[i] - y[i];
  }
  int max_z = z[0];
  int min_z = z[0];
  int max_w = w[0];
  int min_w = w[0];
  for (int i = 0; i < n; i++)
  {
    if (z[i] > max_z)
      max_z = z[i];
    if (z[i] < min_z)
      min_z = z[i];
    if (w[i] > max_w)
      max_w = w[i];
    if (w[i] < min_w)
      min_w = w[i];
  }
  cout << max(max_z - min_z, max_w - min_w) << endl;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    ll L, R;

    cin >> L >> R;
    
    if( (R-L) >= 2019){
        cout << 0 << endl;
     }else{
         ll ans = 3000;
         for(ll i = L; i < R; i++){
             for(ll j = i+1; j <= R; j++){
                chmin(ans, ((i * j) % 2019));
             }
         }
         cout << ans << endl;
     }



    return 0;
}



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

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

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

ll dp[110][100100] = {0};

int main() {
  int N,W;
  ll w[N],v[N];
  cin >> N >> W;
  rep(i,N) cin >> w[i] >> v[i];

  rep(i, N) {
    for (int sum_w = 0; sum_w <= W; sum_w++) {
      if(sum_w-w[i] >= 0) {
        chmax(dp[i+1][sum_w], dp[i][sum_w- w[i]] + v[i]);
      }
      chmax(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }
  
  cout << dp[N][W]<< endl;
}


Measured memory_bytes: 81408
// Copyright 2019 yaito3014
#include "bits/stdc++.h"
using namespace std;
using namespace literals;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (auto& v : P)cin >> v;
  for (auto& v : Q)cin >> v;
  int a = -1, b = -1;
  vector<int> arr(N);
  iota(begin(arr), end(arr), 1);
  int count = 0;
  do {
    ++count;
    if (equal(begin(arr), end(arr), begin(P), end(P)))a = count;
    if (equal(begin(arr), end(arr), begin(Q), end(Q)))b = count;
    if (a != -1 && b != -1)break;
  } while (next_permutation(begin(arr), end(arr)));
  cout << abs(a - b) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

int Roundup(int a,int b){
    return (a+b-1)/b;
}

signed main(){
    int N=5;
    int a[5];
    REP(i,N){cin >> a[i];}
    int i=0;
    REP(j,N){
        if((a[j]+9)%10<(a[i]+9)%10){
            i=j;
        }
    }
    int Ans=0;
    REP(j,N){
        if(j!=i){
            if(a[j]%10!=0){
                a[j]/=10;
                a[j]++;
                a[j]*=10;
            }
            Ans+=a[j];
        }
    }
    cout << Ans+a[i] << endl;
    
    return 0;
}


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

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

    int N, K;
    cin >> N >> K;

    double sum = 0.0;
    for (int i = 1; i <= N; i++) {
        int t = 0;
        int tmp1 = i;
        while (tmp1 < K) {
            t++;
            tmp1 *= 2;
        }

        double tmp = 1.0 / N * 1.0 / pow(2.0, t);
        sum += tmp;
    }

    cout << fixed << setprecision(20) << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define MaxN 55
typedef long long LL;
int a[MaxN];
int b[MaxN];
int f[MaxN][MaxN];
int d[MaxN][MaxN];
int N;
LL my_pow(LL ds,LL cf)
{
    LL sum=1;
    while( cf > 0 )
    {
        if( cf & 1 == 1 )
            sum*=ds;
        ds*=ds;
        cf>>=1;
    }
    return sum;
}
void floyd()
{
    for(int zhan=0;zhan<MaxN;zhan++)
        for(int star=0;star<MaxN;star++)
            for(int end=0;end<MaxN;end++)
                if(d[star][zhan] && d[zhan][end])
                    d[star][end]=1;
}
void copy()
{
    for(int i=0;i<MaxN;i++)
        for(int k=0;k<MaxN;k++)
            d[i][k]=f[i][k];
}
bool check(int x)
{
    copy();
    for(int i=1;i<=x;i++)
        for(int k=i;k<=50;k++)
            d[k][k%i]=1;
    floyd();
    int i;
    for(i=0;i<N;i++)
        if(d[a[i]][b[i]]==0)
            break;
    if(i!=N)
        return false;
    else
        return true;
}
int main()
{
    scanf("%d",&N);
    for(int i=0;i<N;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<N;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<=50;i++)
        for(int k=0;k<=50;k++)
            if(i==k)
                f[i][k]=1;
            else
                f[i][k]=0;
    LL sum=0;
    for(int i=51;i>=1;i--)
    {
        if(!check(i-1))
        {
            if(i==51)
            {
                printf("-1");
                return 0;
            }
            else
            {
                sum+=my_pow(2, i);
                for(int k=i;k<=50;k++)
                    f[k][k%i]=1;
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}


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

int a[100003]={0};

int main ()
{
	int n,i,j,t1,t2,bj=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>t1>>t2;
		for(j=t1;j<=t2;j++)
			a[j]=1;
	}
	for(i=0;i<=100000;i++)
	{
		if(a[i]==1)
			bj++;
	}
	cout<<bj<<endl;
	return 0;
 } 

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int N, M;

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

  long long int res = 1800 * M + 100 * N;
  for (int i = 0; i < M; i++)
    res *= 2;
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 3556
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static class Point {
    	int point, x, y;
    	Point(int p) {
    		point =p ; 
    	}
    }
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
                int n = sc.nextInt();
                Point[] pairs = IntStream.range(0, n).mapToObj(p -> new Point(p+1)).toArray(Point[]::new);
                
                IntStream.range(0, n).forEach(input -> {
                    int X = sc.nextInt();
                    int Y = sc.nextInt();
                    pairs[input].x = X;
                    pairs[input].y = Y;
                });//準備
                
                Arrays.sort(pairs, (p1, p2)->{
                    if(p1.x == p2.x) {
                        return p1.y - p2.y;
                    }
                    return p1.x - p2.x;
                });//x昇順→y昇順
                
                for(int i = 0; i < n; i++) {
                    System.out.println(pairs[i].x+" "+pairs[i].y);
                }
                
        }
    }
}


Measured memory_bytes: 110552