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

int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<"7";
  else if(s=="MON") cout<<"6";
  else if(s=="TUE") cout<<"5";
  else if(s=="WED") cout<<"4";
  else if(s=="THU") cout<<"3";
  else if(s=="FRI") cout<<"2";
  else cout<<"1";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >>N;
    vector<int> C(N),D(N);
    int summ=0,a,b;
    for(int i=0;i<N;i++){
        cin >> C.at(i);
    }
    for(int i=0;i<N;i++){
        cin >> D.at(i);
    }
    for(int i=0;i<N;i++){
        if(C.at(i)-D.at(i)>0) summ+=C.at(i)-D.at(i);
    }
    cout << summ << endl;

}

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

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,n,a) for (int i=n-1;i>=a;i--)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define SZ(x) ((x).size())
#define i0(x) memset(x,0,sizeof(x))
#define i1(x) memset(x,-1,sizeof(x))
#define el cout<<endl
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007
#define N 100000
#define M 500000

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
typedef long double lld;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

ll powmod(ll a,ll b) {ll res=1;a%=MOD; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll cnt[n+1]={0};
    rep(i,0,n-1)
    {
        ll x;
        cin>>x;
        cnt[x]++;
    }
    rep(i,1,n+1)
    cout<<cnt[i],el;
    return 0;
}

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

typedef long long ll;
const int mod = 1000000007;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, m;
    cin >> n >> m;
    vector<int> x(n), y(m);
    for(int i = 0; i < n; ++i){
        cin >> x[i];
    }
    for(int i = 0; i < m; ++i){
        cin >> y[i];
    }
    
    ll x_sum = 0, y_sum = 0;
    for(int k = 0; k < n; ++k){
        x_sum = (x_sum + (ll)k * x[k] - (ll)(n - k - 1) * x[k]) % mod;
    }
    for(int k = 0; k < m; ++k){
        y_sum = (y_sum + (ll)k * y[k] - (ll)(m - k - 1) * y[k]) % mod;
    }

    ll ans = x_sum * y_sum % mod;
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n, W;
int w[100], v[100];
int dp[101][10100];
//dp[i+1][j]:i???????????§???????????§?????????j??\??????????????¨?????????????????????????????§???

int main() {
	cin >> n >> W;
	for (int i = 0; i < n; i++)cin >> v[i] >> w[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {
			if (j < w[i]) {
				dp[i + 1][j] = dp[i][j];
			}
			else {
				dp[i + 1][j] = max(dp[i][j], dp[i][j - w[i]] + v[i]);
			}
		}
	}
	//rep(i, n + 1) {
	//	rep(j, W + 1) {
	//		printf("%3d", dp[i][j]);
	//	}
	//	cout << endl;
	//}
	cout << dp[n][W] << endl;
}

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

#define int long long

int32_t main()
{
	int r,d,x2; cin>>r>>d>>x2;
	for(int i=1;i<=10;i++)
	{
		int temp=(r*x2)-d;
		cout<<temp<<endl;
		x2=temp;
	}	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

using namespace std;

int main(void) {

	int g[13] = {}, x, y;

	cin >> x >> y;

	for (int k = 1; k <= 12; k++) {
		if (x == k)g[k]++;
		if (y == k)g[k]++;
	}

	if (g[2] == 2 || (g[4] + g[6] + g[9] + g[11]) == 2 || (g[1] + g[3] + g[5] + g[7] + g[8] + g[10] + g[12]) == 2) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}

	return 0;
}

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

using namespace std;
typedef long long LL;

LL gcd(LL a, LL b){
    if(b == 0) return a;
    if(a < b) swap(a, b);
    return gcd(b, a % b);
}

int main(){
    LL N, K;
    LL max_v = 0;
    cin >> N >> K;
    vector<LL> a(N);
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    LL c = -1;
    for(int i = 0; i < N; ++i){
        max_v = max(max_v, a[i]);
        if(a[i] == 0) continue;
        if(c == -1){
            c = a[i];
        }else{
            c = gcd(c, a[i]);
        }
    //cerr << "c= "<< c << endl;
    }
    if(K == 0 || (c != -1 && K % c == 0 && K <= max_v)){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,M;
  double count = 0;
  double sum = 0;
  cin >> N >> M;

  vector<double> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
    sum += A.at(i);
  }

  for(int i = 0; i < N; i++){
    if(sum/(double)(4*M) <= A.at(i)) count++;
  }

  string answer = "No";
  if(count >= M) answer = "Yes";

  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
/*----------------------------------------------------------------*/

// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

    int n,k;
    cin >> n >> k;
    vll a(n);
    rep(i,n)cin >> a[i];

    int ans = INF;
    for(int bit = 0;bit <(1LL<<n);bit++){
        int maxi = 0;
        int cost = 0;
        int cnt = 0;
        rep(i,n){
            if(maxi < a[i]){
                cnt++;
                maxi = a[i];
            }else if(bit&(1LL<<i)){
                cnt++;
                maxi = maxi+1;
                cost += maxi-a[i];
            }
            if(cnt >= k)break;
        }
        if(cnt >= k)ans = min(ans,cost);
    }

    cout << ans << endl;
    
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://s8pc-4.contest.atcoder.jp/tasks/s8pc_4_b

Measured memory_bytes: 256
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int a[101];
  for (int i = 0; i < 101; i++) {
    a[i] = 0;
  }

  int n;
  while (cin >> n) {
    a[n]++;
  }

  int mx = 0;
  for (int i = 1; i < 101; i++) {
    mx = max(mx, a[i]);
  }

  for (int i = 1; i < 101; i++) {
    if (a[i] == mx)
      cout << i << endl;
  }
}

Measured memory_bytes: 1160
import sys

def solve():
    input = sys.stdin.readline
    N, M, K = map(int, input().split())
    possible = False
    for i in range(N + 1):
        for j in range(M + 1):
            black = (N - i) * j + i * (M - j)
            if black == K:
                print("Yes")
                possible = True
                break
        if possible: break
    else: print("No")

    return 0

if __name__ == "__main__":
    solve()

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

#define MAXN (110)
#define ll long long

int n, W, w1, sum;
ll dp[MAXN][MAXN * 3];

int main(){
	scanf("%d%d", &n, &W);
	for(int i = 1; i <= n; ++ i){
		int w, v;
		scanf("%d%d", &w, &v);
		if(i == 1) w1 = w;
		w -= w1;
		
		for(int j = i - 1; j >= 0; -- j){
			for(int k = sum; k >= 0; -- k){
				dp[j + 1][k + w] = std::max(dp[j + 1][k + w], dp[j][k] + v);
			}
		}
		
		sum += w;
	}
	ll ans = 0;
	for(int i = 0; i <= n; ++ i){
		for(int j = 0; j <= sum; ++ j){
			if(1ll * i * w1 + j <= W){
				ans = std::max(ans, dp[i][j]);
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


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

  int r = 0;
  int w = 0;

  REP(i,n){
    if(s[i] == 'R') r++;
    else w++;
  }

  ll cnt = 0;
  REP(i,r){
    if(s[i] == 'W') cnt++;
  }

 
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3720
{-# OPTIONS_GHC -O2 #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import Data.Array.Unboxed
import Data.Array.ST
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Data.STRef 
import Data.List
import Data.Char
import qualified Data.Map.Strict as M

main :: IO ()
main = do
    [r,c] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    css <- V.replicateM r $ VU.unfoldrN c BS.uncons <$> BS.getLine
    let all = runST $ do
        all <- newSTRef 0
        forM_ [0..r-1] $ \i -> do
            forM_ [0..c-1]$ \j -> do
                when ('.' == (css V.! i) VU.! j) $ modifySTRef all (+1)
        readSTRef all
    let solve = runST $ do
            arrived <- newArray ((0,0),(r-1,c-1)) (-1)
            go 0 [(0,0)] [] arrived
            where go :: Int -> [(Int,Int)] -> [(Int,Int)] -> STUArray s (Int,Int) Int -> ST s Int
                  go _ [] [] _ = return (-1)
                  go count [] ys arrived = go (count+1) ys [] arrived
                  go count ((v,w):xs) ys arrived = 
                    if not (0 <= v && v <= r-1 && 0 <= w && w <= c-1 && ('.' == (css V.! v) VU.! w)) then go count xs ys arrived 
                    else if (v,w) == (r-1,c-1) then return count
                    else do
                        xx <- readArray arrived (v,w)
                        if xx == -1 then writeArray arrived (v,w) count >> go count xs ((v+1,w):(v-1,w):(v,w+1):(v,w-1):ys) arrived
                        else go count xs ys arrived
    print $ if solve == -1 then -1 else all-solve-1

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

using ll = long long;

#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                     \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define check(s) cerr << s << endl

#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(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};

const ll LINF = 2e18;
const int INF = 1e9;

ll f(ll n) {
  ll cnt = 0;
  for (int x = 1; x < n; x++) {
    if (x * x > n) break;
    for (int y = 1; y < n; y++) {
      if (x * x + y * y + x * y > n) break;
      ll d = -3 * x * x - 3 * y * y - 2 * x * y + 4 * n;
      if (d < 0) break;
      ll z = 0.5 * (-(x + y) + sqrt(d));
      if (z < 1) break;
      ll f = x * x + y * y + z * z + x * y + y * z + z * x;
      if (f == n) cnt++;
    }
  }
  return cnt;
}

void solve(ll N) {
  rep(i, N) { cout << f(i + 1) << endl; }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  ll N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


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

ans = [a-i-1 for i,a in enumerate(A) ]
sorted_ans = sorted(ans)

def final_ans(ans_list , b):
    count = [abs(a-i-1-b) for i,a in enumerate(A) ]
    return(sum(count))

    

if len(sorted_ans) %2 == 1:
    mediam_place = len(sorted_ans)//2
    b = sorted_ans[mediam_place]
    print(final_ans(A , b))
else:
    mediam_place = len(sorted_ans)//2
    b = sorted_ans[mediam_place]
    val1 = final_ans(A , b)

    mediam_place = len(sorted_ans)//2 + 1
    b = sorted_ans[mediam_place]
    val2 = final_ans(A , b)
    print(min(val1 , val2))

Measured memory_bytes: 29064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n;
    cin >> n;
    vector<string> w(n);
    for(int i = 0; i < n; i++){
        cin >> w[i];
    }
    for(int i = 1; i < n; i++){
        char last = w[i-1][w[i-1].size()-1];
        char start = w[i][0];
        if(last != start){
            cout << "No" << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            if(w[i] == w[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
//
// Created by 徳備彩人 on 2020/04/02.
//

#include <iostream>
#include <queue>
using namespace std;

int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    priority_queue<long long> a, b, c;
    priority_queue<long long, vector<long long>, greater<>> ab;
    long long ans;
    for (int i = 0; i < A; i++) {
        long long p;
        cin >> p;
        a.push(p);
    }
    for (int i = 0; i < B; i++) {
        long long p;
        cin >> p;
        b.push(p);
    }
    for (int i = 0; i < C; i++) {
        long long p;
        cin >> p;
        c.push(p);
    }
    long long result = 0;
    for (int i = 0; i < X; i++) {
        c.push(a.top());
        a.pop();
    }
    for (int i = 0; i < Y; i++) {
        c.push(b.top());
        b.pop();
    }
    for (int i = 0; i < X + Y; i++) {
        result += c.top();
        c.pop();
    }
    cout << result << endl;
}

Measured memory_bytes: 8048
n = int(input())
A = list(map(int,input().split()))
A.sort()
import collections
co = collections.Counter(A)

ma = 10**6+1
div = [0]*ma #div[i] == 1::iを割り切るものが存在
cnt = 0
prev = -1
for a in A:
    if div[a] == 1:
        continue
    if co[a]==1:
        cnt+=1
    for i in range(a,ma,a):
        div[i] = 1

print(cnt)


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

int64_t req (int64_t to, int n, vector < int > &a, vector < int > &f) {
	int64_t res = 0;
	for (int i = 0; i < n; ++i) {
		if (int64_t(a[i]) * int64_t(f[i]) > to) 
			res += int64_t(a[i]) - (to / int64_t(f[i]));
	}
	return res;
}

signed main () {
	int n;
	int64_t k;
	cin >> n >> k;
	vector < int > a(n), f(n);
	for (int i = 0; i < n; ++i)	
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> f[i];
	sort(a.begin(), a.end());
	sort(f.rbegin(), f.rend());
	int64_t l = 0, r = 1e12;
	while (r - l > 1) {
		int64_t m = (l + r) / 2;
		if (req(m, n, a, f) <= k)
			r = m;
		else 
			l = m;
	}
	if (req(l, n, a, f) <= k)
		cout << l << '\n';
	else
		cout << r << '\n';
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vi x(N),y(M);
  rep(i,N) {
    cin >> x[i];
  }
  rep(i,M) {
    cin >> y[i];
  }
  x.push_back(X);
  y.push_back(Y);
  rep(i,N+1) {
    rep(j,M+1) {
      if(x[i] >= y[j]) {
        cout << "War" << endl;
        return 0;
      }
    }
  }
  cout << "No War" << endl;
  return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    return divisors

N = int(input())
ans = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        if len(make_divisors(i)) == 8:
            ans += 1
print(ans)


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

xl, yl, n = map(int, input().split())
xr = 0
yr = 0

for n in range(n):
    x, y, a = map(int, input().split())

    if a == 1:
        if xl < x:
            xl = x

        if xr < x:
            xr = x

    elif a == 2:
        if xl > x:
            xl = x

        if xr > x:
            xr = x

    elif a == 3:
        if yl < y:
            yl = y

        if yr < y:
            yr = y

    elif a == 4:
        if yl > y:
            yl = y

        if yr > y:
            yr = y

if (xl - xr) <= 0 or (yl - yr) <= 0:
    print('0')
else:
    print((xl - xr) * (yl - yr))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, k; cin >> n >> k;
	vi h(n);
	rep(i, n) cin >> h[i];
	sort(all(h));
	cout << accumulate(h.begin(), h.begin() + max(0, n - k), 0ll) << endl;
	
	return 0;
}

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

int gcd(ll a,ll b){
  ll x = max(a,b);
  ll y = min(a,b);

  ll r;
  do{
    r = x % y;
    x = y;
    y = r;
  }while(r!= 0);

  return x;
}
int main()
{
  ll a,b;
  cin >> a >> b;
  int g = gcd(a,b);
  cout << a * b / g << endl;

}

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() {
  string s;
  cin >> s;
  if(s[0] == s[1] || s[2] == s[3] || s[1] == s[2]) {
    cout << "Bad" << endl;
  }else {
    cout << "Good" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lson root<<1,l,midd
#define rson root<<1|1,midd+1,r
#define pb push_back
#define ull unsigned long long
#define pii pair<int,int>
#define MP make_pair
typedef long long ll;
const ll INF=1e18;
const int inf=0x3f3f3f3f;
const int M=1e6+6;
const int mod=1e9+7;
int f[M],sz[M];
int Find(int x){
    return x==f[x]?x:f[x]=Find(f[x]);
}
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
        f[i]=i,sz[i]=1;
    while(m--){
        int u,v;
        cin>>u>>v;
        u=Find(u),v=Find(v);
        if(u==v)
            continue;
        f[v]=u;
        sz[u]+=sz[v];
    }
    int ans=1;
    for(int i=1;i<=n;i++)
        if(f[i]==i)
            ans=max(ans,sz[i]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5156
from queue import Queue

directions = [(-1, 0), (0, -1), (1, 0), (0, 1)]

H, W = [int(_) for _ in input().split()]
S = [[1 if s == "#" else 0 for s in list(input())] for i in range(H)]

black_num = sum([sum(S[i]) for i in range(H)])


def solve():
    visited = [[0] * W for i in range(H)]

    q = Queue()
    q.put((0, 0))

    while not q.empty():
        i, j = q.get()

        for di, dj in directions:
            i_, j_ = i + di, j + dj

            if not (0 <= i_ < H and 0 <= j_ < W):
                continue

            if S[i_][j_] != 0 or visited[i_][j_] != 0:
                continue

            visited[i_][j_] = visited[i][j] + 1
            q.put((i_, j_))

            if i_ == H - 1 and j_ == W - 1:
                print(H * W - black_num - visited[H - 1][W - 1] - 1)
                return

    print(-1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3952
#!/usr/bin/env python3
import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    X = LI()

    ans = 10 ** 9

    for i in range(1, 101):
        sum_temp = 0
        for x in X:
            sum_temp += (x - i) ** 2

        if sum_temp <= ans:
            ans = sum_temp
    print(ans)


main()


Measured memory_bytes: 66428
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<utility>

using namespace std;

int main(){
	int n, ans = 0;
	cin >> n;
	vector<long long> x(n), y(n), h(n);
	for(int i = 0; i < n; i++){
		cin >> x[i] >> y[i] >> h[i];
	}
	long long a = 0, b = 0, c = -1;
	if(h[0] == 0){
		int t = 1;
		while(h[t] == 0){
			t++;
		}
		swap(x[0], x[t]);
		swap(y[0], y[t]);
		swap(h[0], h[t]);
	}
	for(long long i = 0; i <= 100; i++){
		for(long long j = 0; j <= 100; j++){
			bool f = true;
			long long t = h[0] + abs(i - x[0]) + abs(j - y[0]);
			for(int k = 1; k < n; k++){
				long long t2 = h[k] + abs(i - x[k]) + abs(j - y[k]);
				if(h[k] == 0){
					if(t2 < t){
						f = false;
						break;
					}
				}else if(t2 != t){
					f = false;
					break;
				}
			}
			if(f){
				if(c < t){
					a = i; b = j; c = t;
				}
			}
		}
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int count=0;
    for(int i=1;i<=n;i++){
        if(i%2!=0)
            count++;
    }
    double n1=n;
    double p=count/n1;
    printf("%f\n",p);
    return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<vector<int> > vvi;
typedef vector<int> vi;
typedef vector<string> vs;
struct node {
	int parent, left, right;
};
typedef vector<node> vn;
void pre(int u, vn& A) {
	if (u == -1) {
		return;
	}
	cout <<" "<<u ;
	pre(A[u].left,A);
	pre(A[u].right,A);
}
void in(int u, vn& A) {
	if (u == -1)return;
	in(A[u].left, A);
	cout <<" "<< u ;
	in(A[u].right, A);
}
void post(int u, vn& A) {
	if (u == -1)return;
	post(A[u].left, A);
	post(A[u].right, A);
	cout<<" " << u ;
}
int main() {
	int N;
	cin >> N;
	vector<node> A(N);
	for (int i = 0; i < N; i++)A[i].parent = A[i].left = A[i].right = -1;
	for (int i = 0; i < N; i++)
	{
		int id;
		cin >> id;
		cin >> A[id].left;
		cin >> A[id].right;
		if (A[id].left != -1)A[A[id].left].parent = id;
		if (A[id].right != -1)A[A[id].right].parent = id;
	}
	int root = 0;
	for (int i = 0; i < N; i++)
	{
		if (A[i].parent == -1)root = i;
	}
	cout << "Preorder" << endl;
	pre(root,A);
	cout << endl;
	cout << "Inorder" << endl;
	in(root,A);
	cout << endl;
	cout << "Postorder" << endl;
	post(root,A);
	cout << endl;
};





Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    long long n;cin>>n;
    long long min = 100000000000000;
    long long temp;
    for (long long i=1;i<=sqrt(n);i++){
        if (n % i == 0){
            temp = (i - 1) + ((n / i) - 1);
            if (min >= temp){
                min = temp;
            }
        }
    }
    cout << min << endl;
    return 0;
}


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

int main() {
    ll a,b;
    cin >> a >> b;
    ll aa=a,bb=b;
    vector<ll> pa;
    vector<ll> pb;
    for (int i=2;i<=sqrt(a)+1;i++) {
        if (aa%i==0) pa.push_back(i);
        while (aa%i==0) aa/=i;
    }
    if (aa!=1) pa.push_back(aa);
    for (int i=2;i<=sqrt(b)+1;i++) {
        if (bb%i==0) pb.push_back(i);
        while (bb%i==0) bb/=i;
    }
    if (bb!=1) pb.push_back(bb);
    int ans=1;
    for(int j=0;j<pa.size();j++) {
        if (count(pb.begin(),pb.end(),pa.at(j))) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  set<string> s;
  bool c=1;
  vector<string> w(n);
  rep(i,n) cin>>w[i];

  s.insert(w[0]);
  for(int i=1;i<=n-1;i++){
    if(s.count(w[i])||w[i-1][w[i-1].size()-1]!=w[i][0])
    c=0;
    s.insert(w[i]);
  }
  if(c)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;


  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
	public static void main(String args[])throws Exception{
 
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replaceAll("eraser","");
		S = S.replaceAll("erase","");
		S = S.replaceAll("dreamer","");
		S = S.replaceAll("dream","");
		if(S.equals("")) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}

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

using namespace std;

#define ll long long
#define ini(arr, val) memset(arr, (val), sizeof(arr))
#define loop(i,n)  for(ll i=0; i<n; i++)

#define all(a)      (a).begin(),(a).end()
#define exist(s,e)  (s.find(e)!=s.end())
#define dbg(x)  cout << #x << " is " << x << endl;
#define pt(x) cout<<x<<"\n"
#define pts(x) cout<<x<<" "

#define mp make_pair
#define pb push_back
#define f first
#define s second


#define inf (int)1e9
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007


#define fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test   int t; cin>>t; while(t--)

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef map<int,int> mii;
typedef set<int> si;

typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<pll> vpll;
typedef vector<vl> vvl;
typedef map<ll,ll> mll;
typedef set<ll> sl;


//////////////////////////////////////////////////////////////////////////////////////////
//                      main starts
//////////////////////////////////////////////////////////////////////////////////////////
int const lmt=1e5+5;



int main(){

 //    #ifndef ONLINE_JUDGE
 //    freopen("../input.txt", "r", stdin);
 //    freopen("../output.txt", "w", stdout);
	// #endif
 //    fast

   ll s,w;
   cin>>s>>w;
   if(w>=s) pt("unsafe");
   else pt("safe");
}


/*

// 

*/

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 2002

ll n,m;
ll a[MAX],b[MAX];
ll dp[MAX][MAX];

ll f(ll i,ll j){
	if(i==n || j==m) return 1;
	if(dp[i][j]!=-1) return dp[i][j];

	ll ans=0;

	ll x = f(i+1,j+1);
	ll y = f(i+1,j);
	ll z = f(i,j+1);
	if(a[i]==b[j]){
		ans = (y+z)%Mod;
	}else{
		ll t = (y+z)%Mod;
		ans = (t-x+Mod)%Mod;
	}
	dp[i][j]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	memset(dp,-1,sizeof(dp));
	cin>>n>>m;
	For(i,0,n) cin>>a[i];
	For(i,0,m) cin>>b[i];
	
	cout<<f(0,0)<<endl;










	
}

Measured memory_bytes: 31744
# include <bits/stdc++.h>
// https://atcoder.jp/contests/agc046/tasks/agc046_b
using namespace std;
# define rep(i, a, b) for(int i = a; i < (b); ++i)
# define trav(a, x) for(auto& a : x)
# define all(x) begin(x), end(x)
# define sz(x) (int)(x).size()
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;
# define MOD 998244353

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    // Ways to build a i by j grid with exactly 1 black in the top row
    vector<vi> ways1Top = vector<vi>(c + 1, vi(d + 1, 0));
    // Ways to build a i by j grid with 0 or many blacks in the top row.
    vector<vi> waysOther = vector<vi>(c + 1, vi(d + 1, 0));
    waysOther[a][b] = 1;
    vi aPow = vi(3001, 1);
    vi amPow = vi(3001, 1);
    for (int i = 1; i < aPow.size(); i++) {
        aPow[i] = (aPow[i - 1] * a) % MOD;
        amPow[i] = (amPow[i - 1] * (a - 1)) % MOD;
    }
    for (int j = b + 1; j <= d; j++) {
        ll locs = j - b;
        ways1Top[a][j] = (amPow[locs - 1] * locs) % MOD;
        waysOther[a][j] = (aPow[locs] - ways1Top[a][j]) % MOD;
    }
    for (int i = a + 1; i <= c; i++) {
        for (int j = b; j <= d; j++) {
            // If we add a new row on top of a [i-1][j] grid, coloring any of the
            // j columns, then the top row has exactly 1 black. This suffices to create
            // all configurations with exactly 1 black, since removing the top row when
            // there is exactly 1 black results in a valid configuraiton.
            ways1Top[i][j] += (j * (ways1Top[i - 1][j] + waysOther[i - 1][j])) % MOD;
            // If we add a new column to the right of a [i][j-1] grid, and color
            // one of the bottom i-1 rows, then we don't change if there is
            // exactly 1 black.
            waysOther[i][j] += ((i - 1) * waysOther[i][j - 1]) % MOD;
            // If we color the top row, though, it will ensure there are more than 1 blacks
            // on the top row.
            waysOther[i][j] += (ways1Top[i][j - 1] + waysOther[i][j - 1]) % MOD;
            ways1Top[i][j] %= MOD;
            waysOther[i][j] %= MOD;
        }
    }
    cout << (waysOther[c][d] + ways1Top[c][d] + 2 * MOD)%MOD << endl;
    return 0;
}

Measured memory_bytes: 144116
#include <stdio.h>
#include <stdlib.h>
 
int asc(const void *a, const void *b){
    long *A = (long *)a;
    long *B = (long *)b;
    if(*A > *B)
        return 1;
    if(*A < *B)
        return -1;
    return 0;
}
 
int main(){
    int N, i, cnt=0, tag=0, ans=0;
    long int a[100000];
 
    scanf("%d", &N);
    for(i=0; i<N; i++){
        scanf("%ld", &a[i]);
    }
 
    qsort(a, N, sizeof(long int), asc);
 
    for(i=0; i<N; i++){
        if(a[i] == a[i+1]){
            cnt++;
        }
        else{
            if(cnt % 2 == 0 || cnt == 0)
                ans++;
            cnt = 0;
        }
    }
 
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <string>
#include <bits/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;

static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
using pint = pair<int,int>;


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

  ll res = n * n * n;

  cout << res <<  endl;

  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

void solve() {
    int N;
    cin >> N;
    const int X = N + (N % 2 == 0);
    vector<pii> ans;
    for (int i = 1; i <= N; ++i) {
        for (int j = i + 1; j <= N; ++j) {
            if (i + j != X) {
                ans.emplace_back(i, j);
            }
        }
    }

    cout << sz(ans) << endl;
    each(e, ans)cout << e.first << ' ' << e.second << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
// using System.Linq;
using System.Diagnostics;

class Program
{
    static void Main(string[] args)
    {
        //////////////////////////
        //　最長共通部分列LCS　 //
        //　                    //
        //　Traceback approach　//
        //////////////////////////

        const long MOD = 1000000007;
        var sc = new Scanner();
        string s = sc.next();
        string t = sc.next();

        // １．長さを求めてdpテーブルに記録
        var dp = new int[s.Length + 1, t.Length + 1];
        for (int i = 1; i <= s.Length; i++)
        {
            for (int j = 1; j <= t.Length; j++)
            {
                if (s[i - 1] == t[j - 1]) dp[i, j] = dp[i - 1, j - 1] + 1;
                else dp[i, j] = Math.Max(dp[i - 1, j], dp[i, j - 1]);
            }
        }

        // ２．dpテーブルを逆向きに辿って答えを求める
        string ans = "";

        // for文で実装しようとするとキツい
        // while分でcnt使ってやる
        int cnt = 0;
        int a = s.Length;
        int b = t.Length;

        while (cnt < dp[s.Length, t.Length])
        {
            if (dp[a, b] == dp[a - 1, b]) a--;
            else if (dp[a, b] == dp[a, b - 1]) b--;
            else
            {
                // 逆向きに辿ってるから頭に追加してく
                ans = s[a - 1] + ans;
                a--;
                b--;
                cnt++;
            }
        }

        Console.SetOut(new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        Console.WriteLine(ans);
        Console.Out.Flush();
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 50104
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 1
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	x1 := getNextFloat64(scanner)
	y1 := getNextFloat64(scanner)
	x2 := getNextFloat64(scanner)
	y2 := getNextFloat64(scanner)

	v := complex(x2-x1, y2-y1)
	r, th := cmplx.Polar(v)
	q := getNextInt(scanner)
	eps := 1e-10
	for i := 0; i < q; i++ {
		x := getNextFloat64(scanner) - x1
		y := getNextFloat64(scanner) - y1
		vv := rotate(complex(x, y), -th)
		if imag(vv) > eps {
			fmt.Fprintln(writer, "COUNTER_CLOCKWISE")
			continue
		}
		if imag(vv) < -eps {
			fmt.Fprintln(writer, "CLOCKWISE")
			continue
		}
		r2, th2 := cmplx.Polar(vv)
		if math.Abs(th2) > eps {
			fmt.Fprintln(writer, "ONLINE_BACK")
			continue
		}
		if r2 > r+eps {
			fmt.Fprintln(writer, "ONLINE_FRONT")
			continue
		}
		fmt.Fprintln(writer, "ON_SEGMENT")
	}
}

func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}



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

#define f0(i,a,b) for(int i= a; i<= b; ++i)
#define f1(i,a,b) for(int i= a; i>= b; --i)
#define DEBUG(x) cerr << #x << " = " << x << endl
#define X first
#define Y second
using namespace std;
const long long base=1e9+7;
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii> iii;
const long long MAX_N = 100011;
ll dp[MAX_N];
int Solves() {
    ll n;
    cin >> n;
    ll h[n + 1];
    for(int i = 1; i <= n;i++) {
        cin >> h[i];
        dp[i] = base*1000;
    }
    dp[1] = 0;
    dp[2] = abs(h[2] - h[1]);
    for(int i = 3; i <= n;i++) {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i]);
        dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i]);
    }
    cout << dp[n];
}

int main() {
    Solves();
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

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

template<class T>
void dcomb(T n,T m, string s){
    if(n==0) cout << s << endl;
    else {
        for(T i=0; i<m; ++i){
            dcomb(n-1,m,s+to_string(i));
        }
    }
}

ll INF = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    vector<int> dp(n,INF);
    dp[0] = 0;
    rep(i,n-1){
        chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        if(i<n-2) chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
*/

int main() {
	lint N;
	cin >> N;
	vector<string>S(N);
	rep(i, N) {
		cin >> S[i];
	}
	sort(S);
	lint cnt = 0;
	string march = "MARCH";
	vector<lint>m(5);
	rep(i, N) {
		rep(j, 5) {
			if (S[i][0] == march[j]) {
				m[j]++;
			}
		}
	}
	rep(i, 5) {
		rep(j, 5) {
			rep(k, 5) {
				if (i < j && j < k) {
					cnt += m[i] * m[j] * m[k];
				}
			}
		}
	}
	cout << cnt << endl;
}




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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e5+3;
const int M=1000000007;

ll modexp(ll a,ll b){
	if(b==0)
		return 1;
	if(b%2==0)
		return modexp((a*a)%M,b/2);
	else
		return (a*modexp((a*a)%M,b/2))%M;
}

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

void solve(){
	int n;
	sfi(n)

	map<pair<ll,ll>,ll> mp;

	ll cnt0=0,cnt1=0,cnt2=0;

	f(i,0,n){
		ll x,y;
		sfl(x) sfl(y)

		if(x==0 && y==0){
			++cnt0;
		}

		else if(x==0){
			++cnt1;
		}

		else if(y==0){
			++cnt2;
		}

		else{
			ll x1=abs(x);
			ll y1=abs(y);
			ll g=gcd(x1,y1);
			x1=x1/g;
			y1=y1/g;

			x=x/g;
			y=y/g;

			if((x1/x)!=(y1/y)){
				x1=-1ll*x1;
			}
			//cout<<x1<<" "<<y1<<endl;
			mp[{x1,y1}]++;
		}

	}

	ll ans=1;

	for(auto it=mp.begin();it!=mp.end();++it){
		pair<ll,ll> p1=it->first;
		ll cnt=it->second;

		if(cnt==0)
			 continue;

		

		pair<ll,ll> p2;

		if(p1.first>0 && p2.first>0){
			p2.first=-1ll*p1.second;
			p2.second=p1.first;
		}
		else{
			p2.first=p1.second;
			p2.second=-1ll*p1.first;
		}

		auto it1=mp.find(p2);

		ll cnt1=0;

		if(it1!=mp.end()){
			//cout<<"**";
			cnt1=(it1->second);
			mp[p2]=0;
		}
		//cout<<cnt1<<" "<<cnt<<endl;
		ll way=modexp(2ll,cnt);
		if(cnt1!=0){
			way+=modexp(2ll,cnt1);
			way%=M;
			way=(way-1+M)%M;
		}
		//cout<<way<<endl;
		ans=(ans*(way))%M;
	}


	
	ll way=modexp(2,cnt1)+modexp(2,cnt2);

	way=(way-1+M)%M;

	//cout<<way<<endl;

	ans=(ans*way)%M;


	ans=(ans-1+M)%M;
	

	if(cnt0!=0){
		ans=(ans+cnt0)%M;
	}

	pfln(ans)
}	

int main(){	

	solve();

	return 0;	
}

Measured memory_bytes: 16248