akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  
  vector<int> w(n);
  rep(i, 0, n) cin >> w.at(i);
  
  ll min = 1e5;
  rep(i, 0, n) {
    int s1 = 0;
    int s2 = 0;
    rep(j, 0, i+1)
      s1 +=w.at(j);
    rep(k, i+1, n)
      s2 += w.at(k);
    if (abs(s1 - s2) < min)
      min = abs(s1 - s2);
  }
  
  cout << min << "\n";

}


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

int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    int x = n*2;
    for(int i = 0; i < n; i++){
        if(s.substr(n-i-1,i+1) == t.substr(0,i+1)){
            int y = t.substr(0,i+1).size();
            x = min(x,2*n-y);
        }
    }
    cout << x << endl;
    return 0;
}

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

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


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
  int n;cin>>n;
  vector<int>a(n);
  cin>>a[0];
  cin>>a[1];
  int ma1,ma2;
  if(a[0]<a[1]){
    ma1=1,ma2=0;
  }
  else{
    ma1=0,ma2=1;
  }
  REP(i,2,n){
    int x;cin>>x;
    if(a[ma1]<=x){
      ma2=ma1;
      ma1=i;
    }
    else if(a[ma2]<=x)ma2=i;
    a[i]=x;
  }
  rep(i,n){
    if(i==ma1)cout<<a[ma2]<<endl;
    else cout<<a[ma1]<<endl;
  }
}

Measured memory_bytes: 2432
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

class Program{
    public static void Main(){
        int N = int.Parse(ReadLine());
        int[] dp = Enumerable.Repeat(int.MaxValue, N+1).ToArray();
        dp[0] = 0;
        int[] money = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};

        for(int i = 0; i <= N; i++){
            for(int j = 0; j < money.Length; j++){
                if(i >= money[j]){
                    dp[i] = Min(dp[i], dp[i-money[j]]+1);
                }
            }
        }
        WriteLine(dp[N]);
    } 
}

Measured memory_bytes: 13316
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main(){
    int n;
    cin >> n;
    vector<ll> a(3*n);
    rep(i, 3*n) cin >> a[i];

    vector<ll> v(3*n-1), u(3*n-1);

    ll lsum = 0;
    priority_queue<ll, vector<ll>, greater<ll>> lq;
    rep(i, n){
        lsum += a[i];
        lq.push(a[i]);
    }
    v[n-1] = lsum;
    for(int i=n; i<2*n; i++){
        ll t = lq.top();
        if(t < a[i]){
            lsum += (a[i] - t);
            lq.pop();
            lq.push(a[i]);
        }
        v[i] = lsum;
    }

//    rep(i, 3*n-1) cout << v[i] << ", ";
//    cout << endl;

    ll rsum = 0;
    priority_queue<ll> rq;
    reverse(all(a));
    rep(i, n){
        rsum += a[i];
        rq.push(a[i]);
    }
    u[n-1] = rsum;
    for(int i=n; i<2*n; i++){
        ll t = rq.top();
        if(t > a[i]){
            rsum += (a[i] - t);
            rq.pop();
            rq.push(a[i]);
        }
        u[i] = rsum;
    }
    reverse(all(u));

//    rep(i, 3*n-1) cout << u[i] << ", ";
//    cout << endl;

    ll ans = - 1e18;
    for(int i=n-1; i<2*n; i++){
        chmax(ans, v[i]-u[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 9588
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================








int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================


	string S;
	cin >> S;

	ll Q;
	cin >> Q;

	vll F(Q);
	vector<char> C(Q);

	for (int i = 0; i < Q; i++) {
		F[i] = -1;
		C[i] = 'A';
	}

	for (int i = 0; i < Q; i++) {
		int aa;
		cin >> aa;

		if (aa == 1) {
			continue;
		}
		else {
			cin >> F[i] >> C[i];
		}

	}

	int muki = 1;

	string start = "";
	string end = "";


	for (int i = 0; i < Q; i++) {

		if (i == 2) {
			int sa = 3;
		}

		if (F[i] == -1) {
			muki *= -1;
		}
		else if (F[i] == 1) {

			if (muki == 1) {
				start += C[i];
			}
			else {
				end += C[i];
			}

		}
		else {

			if (muki == 1) {
				end += C[i];
			}
			else {
				start += C[i];
			}

		}
	}


	if (muki == 1) {

		reverse(start.begin(), start.end());
		cout << start << S << end;
	}
	else {
		reverse(S.begin(), S.end());
		
		reverse(end.begin(), end.end());

		cout << end << S << start;
	}


}


Measured memory_bytes: 2832
import java.util.*;

class Main{
    void solve(){
        Scanner sc = new Scanner(System.in);
        int t, n;
        int[] V = {0, 6000, 4000, 3000, 2000};

        for ( int i = 0; i < 4; i++ ){
            t = sc.nextInt();
            n = sc.nextInt();
            System.out.println(V[t]*n);
        }
    }
    public static void main(String[] args){ new Main().solve(); }
}




Measured memory_bytes: 26232
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>

#define p(a, b) pair<a, b>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin >> a >> b;
    cout << 2*b - a;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

using namespace std;
using ll=long long;
using Vec = vector<ll>;
using P = pair<ll, ll>;
using VecP = vector<P>;
#define rep(i, n, s) for (int i = s; i < (int)(n); i++)

//static const ll MOD = 1000000007;
//static const ll INF = 1000000000000000000;
//#define PI 3.14159265358979323846
//
//int gcd(int x, int y) { return (x % y) ? gcd(y, x % y) : y; }
//
//int findSumDigits(int s) {
//    int num = 0;
//    int temp = 0;
//    while (s) {
//        temp = s % 10;
//        num += temp;
//        s = s / 10;
//    }
//    return num;
//}
//
//int countDivisorNum(int n) {
//    int count = 0;
//    for (int i = 1; i <= n; i++) {
//        if (n % i == 0) {
//            count++;
//        }
//    }
//    return count;
//}

int main() {
    string n;
    cin >> n;
    ll sum = 0;

    rep(i, n.length(), 0) {
        sum += n[i] - '0';
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

using namespace std;

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}


int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, k;
    string s;

    cin >> n >> k >> s;

    cout << s.substr(0, k - 1) << (char) tolower(s[k - 1]) << s.substr(k, s.size());

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
 
n = int(input())
a = list(map(int, input().split()))
q = int(input())
 
cnt = Counter(a)
 
s = sum(a)
 
for i in range(q):
	b, c = map(int, input().split())
	s = s - b*cnt[b]
	s = s + c*cnt[b]
	cnt[c] += cnt[b]
	cnt[b] = 0
	print(s)

Measured memory_bytes: 24016
A = []

for i in range(3):
    A.append(input().split())

N = int(input())

for n in range(N):
    b = input()
    for i, row in enumerate(A):
        for j, col in enumerate(row):
            if b == col:
                A[i][j] = True

res = False
for i in range(3):
    if A[i][0] == True and A[i][1] == True and A[i][2] == True:
        res = True
    if A[0][i] == True and A[1][i] == True and A[2][i] == True:
        res = True
if A[0][0] == True and A[1][1] == True and A[2][2] == True:
    res = True
if A[2][0] == True and A[1][1] == True and A[0][2] == True:
    res = True

print('Yes') if res else print('No')


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

int main(){
	int N;
	char S[101];
	int x=0,max=0;
	int i;
	
	scanf("%d",&N);
	scanf("%s",S);
	
	for(i=0;i<N;i++){
		if(S[i]=='I') x++;
		if(S[i]=='D') x--;
		if(x>max) max=x;
	}
	printf("%d\n",max);
	
	return 0;
}


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

using namespace std;
typedef long long ll;
const int maxN = 1e5 + 5;
ll a[maxN], b[maxN], f[maxN];
bool vis[maxN];
int N, M, root[maxN], l[maxN], e, idx[maxN];
struct edge{
	int v, las;
}G[maxN << 1];
void add(int u, int v) {
	G[e].v = v; G[e].las = l[u]; l[u] = e++;
}
int getrt(int v) {
	if(root[v] != 0) {
		int rt = getrt(root[v]);
		root[v] = rt; v = rt;
	}
	return v;
}
bool cmp(ll x, ll y) {return a[x] < a[y];}
int main() {
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= N; ++i) 
	scanf("%lld%lld", &a[i], &b[i]), a[i] = max(0ll, a[i] - b[i]), l[i] = -1, idx[i] = i;
	for(int i = 1; i <= M; ++i) {
		int u, v; scanf("%d%d", &u, &v); add(u, v); add(v, u);
	}
	sort(idx + 1, idx + 1 + N, cmp);
	for(int i = 1; i <= N; ++i) {
		int k = idx[i]; f[k] = a[k]; vis[k] = 1;
		for(int j = l[k]; j != -1; j = G[j].las) {
			if(vis[G[j].v]) {
				int v = G[j].v;
				int rt = getrt(v);
				if(rt == k) continue;
				root[rt] = k;
				b[k] += b[rt];
				f[k] = min(f[k], max(f[rt], a[k] - b[rt]));
			}
		}
	}
	cout << b[idx[N]] + f[idx[N]] << endl;
	return 0;
}

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

int main(){
  int n, r, t, ten[10];

  cin>>n;
  
  for(int i = 0; i < n; i++){
    cin>>r>>t;
    if(r%100 == 0){//cout<<"A"<<endl;
      if(t%30 == 0){//cout<<"B"<<endl;
	ten[0] = r/100 + (t/30)*5;
	t =1;
      } else {
	ten[0] = r/100 + (t/30)*5;
	ten[1] = r/100 + (t/30)*5 + 5;
	t = 2;
      }
    } else{
      if(t%30 == 0){
	ten[0] = r/100 + (t/30)*5;
	ten[1] = r/100+1 + (t/30)*5;
	t = 2;
      }else{
	ten[0] = r/100 + (t/30)*5;
	ten[1] = r/100 + (t/30)*5 + 5;
	ten[2] = r/100+1 + (t/30)*5;
	ten[3] = r/100+1 + (t/30)*5 + 5;
	t = 4;
      }
    }

    sort(ten, ten + t);
    for(int j = 0; j < t; j++){
      if(j) cout<<" ";
      cout<<ten[j];
    }cout<<endl;
  }
  
  return 0;
}



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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
 
ll x,k,d;
bool a=true;
cin>>x>>k>>d;

ll lim=d*k;  //到達限界

if(lim/d!=k || lim/k!=d ||lim%k!=0 ||lim%d!=0){
   a=false;
}

if(lim<abs(x) && a==true){
    cout<<abs(x)-lim<<endl;
}
else{
  ll t=abs(x)/d;//t=>k 到達する場合　の回数
  ll far=abs(x)%d; //ｔ回あとの距離
  ll amari=k-t; //残り試行回数
  int p=amari%2;

  
  if(p==0){
      cout<<far<<endl;
  }
  if(p==1){
      cout<<abs(d-far)<<endl;
  }


}

}

Measured memory_bytes: 3632
import numpy as np
N, K = list(map(int, input().split()))
mod = 1000000007

m = N ** 0.5
cnt = [N // i - N // (i + 1) for i in range(1, int(m) + 1)] 
cnt = np.array((cnt + [1 for _ in range(N - sum(cnt))])[::-1])
nxt = cnt[:]
for _ in range(K - 1):
    cnt = nxt * np.cumsum(cnt)[::-1] % mod

print(sum(cnt) % mod)


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

using namespace std;

typedef long long ll;

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


int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = B / C - (A - 1) / C;
    ans += B / D - (A - 1) / D;
    ll l = lcm(C, D);
    ans -= (B / l - (A - 1) / l);
    ans = B - A + 1 - ans;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
  string s;cin>>s;
  int cnt=0,max=0;
  for(int i=0; i<3; ++i){
    if(s[i]=='R') ++cnt; else cnt=0;
    if(cnt>max) max=cnt;
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>
void sort(int* v, int l) {
	for (int i = 1; i < l; i++) {
		for (int j = 0; j < l - 1; j++) {
			if (v[j] < v[j + 1]) {
				int tmp = v[j];
				v[j] = v[j + 1];
				v[j + 1] = tmp;
			}
		}
	}
	return;
}
int main(){
    int input;
    scanf("%d", &input);
    int *value = new int[input];
    for (int i = 0; i < input; i++) {
        scanf("%d", &value[i]);
    }
    sort(value, input);
 
    int output = value[0] / 2;
    for (int i = 1; i < input; i++) {
        output += value[i];
    }
    printf("%d", output);
    return 0;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

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

    return 0;
}

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

int main()
{
	auto& in = cin;

	const int numA = 26;
	int D;
	in >> D;
	vector<int> cs;
	vector<vector<int>> ss;
	for (int i = 0; i < numA; ++i) {
		int c;
		in >> c;
		cs.push_back(c);
	}
	for (int i = 0; i < D; ++i) {
		vector<int> s;
		for (int j = 0; j < numA; ++j) {
			int is;
			in >> is;
			s.push_back(is);
		}
		ss.emplace_back(move(s));
	}

	int sat = 0;
	vector<int> ds(numA);
	for (int i = 0; i < D; ++i) {
		int t;
		in >> t;
		sat += ss[i][t - 1];
		for (int j = 0; j < numA; ++j)
			++ds[j];
		ds[t - 1] = 0;
		for (int j = 0; j < numA; ++j)
			sat -= cs[j] * ds[j];
		cout << sat << "\n";
	}

	return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> H(N);
	rep(i,N) cin >> H[i];
	int ans=0, res=0;
	rep(i,N-1){
		if(H[i]>=H[i+1]) res++;
		else{
			ans=max(ans,res);
			res=0;
		}
		if(i==N-2) ans=max(ans,res);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 5;
int lst[Max];

int main()
{
	ll n;
	cin >> n;
	ll res1 = 0, sum = 0, res2 = 0;
	for (int i = 1;i <= n;i++)scanf("%d", &lst[i]);
	int sum1 = 0;
	int sum2 = 0;
	for (int i = 1;i <= n;i++)
	{
		sum1 += lst[i];
		if (i % 2 == 1 && sum1 <= 0)
		{
			res1 += (1 - sum1);
			sum1 = 1;
		}
		else if (i % 2 == 0 && sum1 >= 0)
		{
			res1 += (sum1 + 1);
			sum1 = -1;
		}
	}
	for (int i = 1;i <= n;i++)
	{
		sum2 += lst[i];
		if (i % 2 == 0 && sum2 <= 0)
		{
			res2 += (1 - sum2);
			sum2 = 1;
		}
		else if (i % 2 == 1 && sum2 >= 0)
		{
			res2 += (sum2 + 1);
			sum2 = -1;
		}
	}
	cout << min(res1, res2);
}

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

int main(void)
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a==0){
        cout << 1 << endl;
    }
    if(b==0){
        cout << 2 << endl;
    }
    if(c==0){
        cout << 3 << endl;
    }
    if(d==0){
        cout << 4 << endl;
    }
    if(e==0){
        cout << 5 << endl;
    }


}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int n, in[maxn], ans[maxn];
vector<pii>edges;
vector<int>adj[maxn];
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		++in[a], ++in[b];
		edges.pb({a, b});
		adj[a].pb(b);
		adj[b].pb(a);
	}
	vector<int>c(n);
	for(int i = 0; i < n; i++)
		cin >> c[i];
	sort(all(c));

	queue<int>Q;
	for(int i = 1; i <= n; i++)
		if(in[i] == 1)
			Q.push(i);
	for(int i = 0; i < n; i++)
	{
		int v = Q.front();
		ans[v] = c[i];
		Q.pop();
		for(int to : adj[v])
			if(--in[to] == 1)
				Q.push(to);
	}
	int sum = 0;
	for(pii p : edges)
		sum += min(ans[p.x], ans[p.y]);
	cout << sum << "\n";
	for(int i = 1; i <= n; i++)
		cout << ans[i] << " ";
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3328
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  int N;
  cin >> N;
  if((N % 10) == (N / 100))
    cout << "Yes" <<  endl;
  else
    cout << "No" <<  endl;
  
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

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

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }



template<int MAXV>
struct scc {
  std::vector<int> G[MAXV], rG[MAXV], vs;
  bool used[MAXV];
  //int cmp[MAXV];
  scc() {}
  void dfs(int v) {
    used[v] = true;
    for(auto c: G[v]) if(!used[c]) dfs(c);
    vs.push_back(v);
  }
  void rdfs(int v, int k) {
    used[v] = true;
    //cmp[v] = k;
    for(auto c: rG[v]) if(!used[c]) rdfs(c, k);
  }
  int build(int V) {
    std::fill_n(used, V, false);
    vs.clear();
    for(int v = 0; v < V; ++v) if(!used[v]) dfs(v);
    std::fill_n(used, V, false);
    int k = 0;
    for(int i = vs.size()-1; i >= 0; --i) {
      if(!used[vs[i]]) rdfs(vs[i], k++);
    }
    return k;
  }
  void add_edge(int fr, int to) {
    G[fr].push_back(to); rG[to].push_back(fr);
  }
};

int const MAXN = 5e5;

scc<MAXN> sc;
int depth[MAXN];
int calc_depth(int v) {
  if(depth[v] >= 0) return depth[v];
  int res = -1;
  for(auto c: sc.G[v]) res = std::max(res, calc_depth(c));
  ++res;
  return depth[v] = res;
}


struct rolling_hash {
  __uint128_t m_, b_, bl_;
  int l_;
  rolling_hash(int64_t mod, int64_t base, int length)
    : m_(mod), b_(base), l_(length) {
    bl_ = 1;
    __uint128_t v = b_;
    while(length > 0) {
      if(length&1) (bl_ *= v) %= m_;
      length/=2; (v *= v) %= m_;
    }
  }
  int64_t hash(char const* s) {
    __uint128_t res = 0;
    for(int i = 0; i < l_; ++i) (res = res*b_%m_ + s[i]) %= m_;
    return res;
  }
  int64_t next(int64_t hash, char in_c, char out_c) {
    __uint128_t h = hash;
    (h = h*b_%m_ + in_c + (m_ - out_c)*bl_%m_) %= m_;
    return h; 
  }
};


int main() {
  std::string S, T; std::cin >> S >> T;
  int N = S.size(), M = T.size(), K = N+M-1;
  std::string U = S;
  for(int i = 0; i < (M-1)/N; ++i) U += S;
  U += S.substr(0, K - U.size());
  //rolling_hash rh1((int64_t)1e18+3, (int64_t)1e9+7, M);
  rolling_hash rh1((int64_t)999999937, (int64_t)17, M);
  int64_t t1 = rh1.hash(T.c_str());
  int64_t u1 = rh1.hash(U.c_str());
  std::vector<int> v;
  for(int i = 0; i < N; ++i) {
    if(t1 == u1) v.push_back(i);
    if(M+i >= K) break;
    u1 = rh1.next(u1, U[M+i], U[i]);
  }
  
  if(v.size() < 1) fin(0);
  for(int fr: v) {
    int to = (fr+M)%N;
    if(fr == to) fin(-1);
    sc.add_edge(fr, to);
  }
  if(sc.build(N) < N) fin(-1);
  std::fill_n(depth, N, -1);
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    ans = std::max(ans, calc_depth(i));
  }
  fin(ans);
  
  return 0;
}


Measured memory_bytes: 85240
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    a,b=parseMap(split(readline()))
    if a>=13
        println(b)
    elseif a>=6
        println(div(b,2))
    else
        println(0)
    end
end
main()

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

vector<int> getAxis(vector<vector<int>> v, int axis) {
    vector<int> ans(v.size());
    for (int i = 0; i < v.size(); ++i) ans[i] = v[i][axis];
    return ans;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> cnt(n, vector<int>(26, 0));
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        for (char c : s) {
            cnt[i][c - 'a']++;
        }
    }
    for (int i = 0; i < 26; ++i) {
        vector<int> v = getAxis(cnt, i);
        for (int j = 0; j < *min_element(v.begin(), v.end()); ++j) {
            cout << (char)(i + 'a');
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>
#include<time.h>
#include<stack>

using namespace std;
#define INF 1000000007

#define LINF (1LL << 62)

typedef long long i64;
typedef pair<i64,i64> P;


string s, t;

int main(){
	cin >> s >> t;
	
	cout << t+s << endl;
	
	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pll> vp;
typedef vector<ll> vll;

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

    int a, b, c;
    cin >> a >> b >> c;

    int t = 0;
    rep(i, 10000) {
        rep(j, 100) {
            int ans = c + 60 * j;
            if (t <= ans && ans <= t + a) {
                cout << ans << endl;
                return 0;
            }
        }
        t += a + b;
    }
    cout << -1 << endl;
}

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

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

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int C, n, diff, x, y, dif1, dif2, ans;
char c[1010][1010];

int main() {
	cin >> C >> n;
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 1;i <= n;i++) {
		for (int j = 1;j <= n;j++) {
			if (c[i][j] != c[i][n - j + 1])dif1++;
			if (c[i][j] != c[n - i + 1][j])dif2++;
		}
	}
	for (int i = 0;i < C;i++) {
		if (!dif1 && !dif2)ans++;
		cin >> diff;
		for (int j = 0;j < diff;j++) {
			cin >> x >> y;
			bool fl1 = 0, fl2 = 0;
			if (c[x][y] != c[x][n - y + 1])fl1 = 1;
			if (c[x][y] != c[n - x + 1][y])fl2 = 1;
			if (c[x][y] == '1')c[x][y] = '0';
			else c[x][y] = '1';
			if (c[x][y] == c[x][n - y + 1]&&fl1)dif1-=2;
			else if (c[x][y] != c[x][n - y + 1] && !fl1)dif1+=2;
			if (c[x][y] == c[n - x + 1][y])dif2 -= 2;
			else if (c[x][y] != c[n - x + 1][y] && !fl2)dif2 += 2;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4076
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;

int main(){
    //std::stack<int> stack;
    int n;
    cin >> n;
    vector<long> a(n+1);
    vector<long> b(n+1);
    vector<long> um(n+2);
    for(int i = 0; i <= n; i++){
        cin >> a[i];
    }
    um[n] = a[n];
    for(int i = n-1; i >= 0; i--){
        um[i] = um[i+1] + a[i];
    }
    long long ans = 0;
    b[0] = 1 - a[0];
    long tmp = 1;
    for(int i = 0; i <= n; i++){
        ans += tmp;
        tmp -= a[i];
        if(tmp < 0){
            cout << "-1" << endl;
            return 0;
        }
        tmp = min(tmp*2, um[i+1]);
    }
    
    cout << ans << endl;
     return 0;
}





Measured memory_bytes: 5636
import sys
from itertools import permutations

N = int(input())
i, j = 1, 1
max0 = -1
ans = 0
while i <= N // i:
    if N % i != 0:
        i += 1
        continue
    else:
        j = N // i
        if max0 > abs(i-j) or max0 == -1:
            max0 = abs(i-j)
            ans = i + j
        i += 1
print(ans-2)



Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main() {
    int n,l;
    cin >> n >> l;
    int sum = 0,i,ans;
    int mi=100000;
    
    for(i = 1; i <= n; i++) {
        mi=min(abs(mi),abs(l+i-1));
        if (l+i-1 < 0)mi=-mi;
        sum += l+i-1;
    }
    ans = sum - mi;
    cout << ans;
}



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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c,d;
    Scd2(a,b);
    Scd2(c,d);
    printf ("%d\n", min(a,b) + min(c,d));

    return 0;
}



Measured memory_bytes: 256
import kotlin.math.pow

fun main(args: Array<String>) {
	readLine()
	val aList = readLine()?.split(" ")?.map {it.toLong()} ?: return
	
	var result: Long = 0
	val mod = ((10.0.pow(9)+7).toInt())
	var sum = aList.sum() % mod

	for (a in aList) {
		sum -= a
		if (sum < 0) sum += mod
		
		result += a * sum
		result %= mod
	}
	
	println(result)
}

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

int main(){
    int n,m;
    cin >> n>> m;
    vector<int> a(n);
    for(int i=0 ;i<n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    vector<pair<int,int>> ope;
    for(int i=0; i<m; i++){
        int b,c;
        cin >> b >> c;
        pair<int, int> p;
        p = make_pair(c,b);
        ope.push_back(p);
    }
    sort(ope.begin(), ope.end());
    reverse(ope.begin(), ope.end());
    int count = 0;
    bool finish = false;
    for(int i=0; i<m; i++){
        pair<int, int> p;
        p = ope.at(i);
        int b,c;
        b= p.second;
        c = p.first;
        int time=0;
        while(time<b){
            if(c >= a.at(count)){
                a.at(count) = c;
                count++;
                time++;
            }
            else{
                finish = true;
                break;
            }
            if(count == n){
                finish=true;
                break;
            }
        }
        if(finish) break;
    }

    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += (ll)a.at(i);
        //cout << a.at(i) << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4684
def main():
  N = int(input())
  S = input()
  
  cnt = 0
  
  for i in range(N-2):
    if S[i] == 'A':
      if S[i+1] == 'B':
        if S[i+2] == 'C':
          cnt += 1
  print(cnt)
  
  
main()

Measured memory_bytes: 9160
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n, a, b = LI()
    print(max(b * n + a - b - (a * n - a + b - 1),0))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 38512
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, x, c1, c2, v[105];
int main() {
	int i, t;
	cin>>n>>m>>x;
	while(m--) cin>>t, v[t] = 1;
	for(i=0; i<=x; i++) c1 += v[i];
	for(i=x; i<=n; i++) c2 += v[i];
	cout<<min(c1, c2);
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! get_chars {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().chars().collect::<Vec<_>>()
        }
    };
    ($n:expr) => {
        {
            (0..$n)
                .map(|_| get_chars!())
                .collect::<Vec<_>>()
        }
    };
}

fn main() {
    let (a, b, _, mut k) = get!(i64, i64, i64, i64);
    if a >= k {
        println!("{}", k);
    } else {
        k -= a;
        if b >= k {
            println!("{}", a);
        } else {
            k -= b;
            println!("{}", a - k);
        }
    }
}


Measured memory_bytes: 2132
N=gets.to_i
A=Array.new(N)
N.times do |i|
  A[i]=[gets.to_i,i]
end
A.sort!
samecount=[0,0]

ans=0
N.times do |i|
  samecount[A[i][1]%2]+=1
  if i==N-1 || A[i][0]!=A[i+1][0]
    startm1=i-samecount[0]-samecount[1]
    if startm1==-1
      evennum=i/2+1
    else
      evennum=i/2-startm1/2
    end
    ans+=(samecount[0]-evennum).abs
    samecount=[0,0]
  end
end

p ans/2

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for (int i = (int)(n); i > 0; --i)
#define loop(i,x,n) for (int i = (int)(x); i < (n); ++i)
#define loops(i,x,n) for (int i = (int)(x); i <= (n); ++i)
#define loopd(i,x,n) for (int i = (int)(x); i > (n); --i)
#define loopds(i,x,n) for (int i = (int)(x); i >= (n); --i)
#define itrep(i,s) for (auto i = begin(s); i != end(s); ++i)
#define itrepd(i,s) for (auto i = --end(s); i != begin(s); --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(whole), end(whole), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(whole), rend(whole), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T> constexpr int sz(const T& a) { return (int)a.size(); }
template<class T> constexpr T pow2(const T a) { return a * a; }
template<class T, class ... Args> constexpr T mins(T& a, Args... args) { return a = min<T>({ a, args... }); }
template<class T, class... Args> constexpr T maxs(T& a, Args... args) { return a = max<T>({ a,args... }); }


int m1, m2, d1, d2;
void solve() {
    cin >> m1 >> d1 >> m2 >> d2;

    if (m1 != m2) cout << 1 << endn;
    else cout << 0 << endn;
}

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<iomanip>
#include<vector>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
using ll=long long;
const int M=100010;


int main(){
	int n,k,x[M];
	int tmp=M,ans=300000000;
	cin>>n>>k;
	rep(i,0,n)cin>>x[i];

	rep(i,0,n-k+1){
		tmp=min(abs(x[i+k-1]),abs(x[i]))+abs(x[i+k-1]-x[i]);
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;

namespace CFBC
{
    static class MainClass
    {

        public static void Main(string[] args)
        {


            string[] input1 = Console.ReadLine().Split(' ');
            long N = long.Parse(input1[0]);
            long P = long.Parse(input1[1]);

            if (P == 1 || N == 1) {
                Console.WriteLine(P);
                return;

            }

            List<long> pf = PF(P).ToList();
            pf.Sort();

            if (N > pf.Count()) {
                N = pf.Count();
            }


            //pf.ForEach(Console.WriteLine);


            var pfgrp = pf.GroupBy(a => a)
                          .Select(col => new { p = col.Key, e = col.Count() });


            long ans = 1;
            long tmp = 0;
            long ek = 0;
            foreach(var item in pfgrp){
                ek = item.e / N;
                tmp = (long)Math.Pow(item.p,ek);
                ans = ans * tmp;

            }
          

            Console.WriteLine(ans);

            return;


        }



        public static long Gcd(long a, long b)
        {
            long tmp;
            // a<bにする
            if (a >= b)
            {
                tmp = a;
                a = b;
                b = tmp;
            }

            if (a == 0)
            {
                return b;
            }

            tmp = a;
            a = b % a;
            b = tmp;
            return Gcd(a, b);

        }


        public static IEnumerable<long> PF(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0)
                {
                    tmp /= i;
                    yield return i;
                }
                else
                {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }




    }

}






Measured memory_bytes: 13652
from collections import defaultdict
def main():
    N = int( input())
    D = list( map( int, input().split()))
    M = int( input())
    T = list( map( int, input().split()))
    probs = defaultdict( int)
    for d in D:
        probs[d] += 1
    for t in T:
        if probs[t] == 0:
            print("NO")
            return
        probs[t] -= 1
    print("YES")
if __name__ == '__main__':
    main()


Measured memory_bytes: 41700
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
#define EPS (1E-10)
const int maxn=100000+10;
int n;

struct Point
{
    int x,y;
    Point() {}
    Point(int _x,int _y):x(_x),y(_y) {}
    Point operator -(Point p)
    {
        return Point(x-p.x,y-p.y);
    }
    bool operator <(Point p)
    {
        return x==p.x?y<p.y:x<p.x;
    }
    int cross(Point p)
    {
        return x*p.y-y*p.x;
    }
    int dot(Point p)
    {
        return x*p.x+y*p.y;
    }
    int norm()
    {
        return x*x+y*y;
    }

};
vector<Point> ps;

int ccw(Point p,Point p1,Point p2)
{
    #define COUNT_CLOCKWISE 1
    #define CLOCKWISE -1
    #define ONLINE_FRONT 2
    #define ONLINE_BACK -2
    #define ON_SEGMENT 0
    Point a=p1-p;
    Point b=p2-p;
    if(a.cross(b)<-EPS) return CLOCKWISE;
    if(fabs(a.cross(b)<EPS)) return CLOCKWISE;
    if(a.cross(b)>EPS) return COUNT_CLOCKWISE;
    if(a.dot(b)<-EPS) return ONLINE_BACK;
    if(a.norm()<b.norm()) return ONLINE_FRONT;
    return ON_SEGMENT;

}

vector<Point> convex_hull(vector<Point> ps)
{
    vector<Point> u,l;
    if(ps.size()<=3) return ps;
    sort(ps.begin(),ps.end());
    u.push_back(ps[0]);
    u.push_back(ps[1]);
    l.push_back(ps[ps.size()-1]);
    l.push_back(ps[ps.size()-2]);
    for(int i=2;i<ps.size();i++)
    {
        for(int n=u.size();n>=2&&ccw(u[n-2],u[n-1],ps[i])!=CLOCKWISE;n--)
        {
            u.pop_back();
        }
        u.push_back(ps[i]);
    }
    for(int i=ps.size()-3;i>=0;i--)
    {
        for(int n=l.size();n>=2&&ccw(l[n-2],l[n-1],ps[i])!=CLOCKWISE;n--)
        {
            l.pop_back();
        }
        l.push_back(ps[i]);
    }
    reverse(l.begin(),l.end());
    for(int i=u.size()-2;i>=1;i--) l.push_back(u[i]);
    return l;
}
bool is_convex(vector<Point> ps)
{
    int n=(int)ps.size();
    for(int i=0;i<n;i++)
    {
        if(ccw(ps[(i+1)%n],ps[(i)%n],ps[(i+2)%n])==COUNT_CLOCKWISE) return false;
    }
    return true;
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d",&n);
    int x,y;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&x,&y);
        ps.push_back(Point(x,y));
    }
   vector<Point> qs=convex_hull(ps);
    if(qs.size()==n) printf("1\n");
    else printf("0\n");


    return 0;

}

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

int main() {
  double a, b, c, d, e, f, x = 0, y = 0;
  while(cin >> a >> b >> c >> d >> e >> f){

    y = (c * d - a * f) / (b * d - a * e);
    x = (c - b * y) / a;
    y *= 10000.0;
    if((int)y % 10 > 4) y += 1.0;
    y /= 10000.0;
    x *= 10000.0;
    if((int)x % 10 > 4) x += 1.0;
    x /= 10000.0;
    printf("%.3f %.3f\n", x, y);
}
     
}


Measured memory_bytes: 3140
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979

int main()
{
	int n, ans = 0;
	cin >> n;
	for(int i = 1; i < n+1; i++)
	{
		if (to_string(i).length() == 1 || to_string(i).length() == 3 || to_string(i).length() == 5)
		{
			ans++;
		}
	}
	cout << ans<< endl;
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  if(S.at(0) == S.at(1) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  }
  else if(S.at(0) == S.at(1) && S.at(2) == S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(2) && S.at(1) == S.at(3)){
    cout << "Yes" << endl;
  }
  else if(S.at(0) == S.at(3) && S.at(1) == S.at(2)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<pair<int,int>> V;
ll mo=1000000007;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>x, V.push_back({x,0});
	FOR(i,N) cin>>x, V.push_back({x,1});
	sort(ALL(V));
	
	ll ret = 1;
	x = 0;
	FORR(r,V) {
		if(r.second==0) {
			if(x<0) ret = (ret*(-x))%mo;
			x++;
		}
		else {
			if(x>0) ret = (ret*x)%mo;
			x--;
		}
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int main() {
    string s;
    cin >> s;
    string ans;
    rep(i,s.size()) {
        if (s.at(i) == 'B') {
            if (!ans.empty()) {
                ans.erase(ans.size() - 1);
            }
        } else {
            ans.push_back(s.at(i));
        }
    }
    cout << ans << endl;
}


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

int main() {
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    int A[3] = {0, 0, 0}, i;
    for (i = 0; i < s.size(); ++i) ++A[s[i] - 'a'];
    sort(A, A + 3);
    cout << (A[2] - A[0] < 2 ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
  char b[2];
  
  scanf("%s",&b[0]);
  
  if(b[0]=='A'){
    printf("T");
  }else if(b[0]=='T'){
    printf("A");
  }else if(b[0]=='C'){
    printf("G");
  }else if(b[0]=='G'){
     printf("C");
  }
  
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3

'''
Author: andyli
Time: 2020-07-05 19:56:17
'''

import os
from io import BytesIO, IOBase
import sys


def main():
    n = int(input())
    ac,wa,tle,re=0,0,0,0
    for i in range(n):
        s = input()
        if s == 'AC':
            ac += 1
        elif s == 'WA':
            wa += 1
        elif s == 'TLE':
            tle += 1
        elif s == 'RE':
            re += 1
    print('AC x', ac)
    print('WA x', wa)
    print('TLE x', tle)
    print('RE x', re)
    return


# region fastio
BUFSIZE = 1048576


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = 'x' in file.mode or 'r' not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b'\n') + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode('ascii'))
        self.read = lambda: self.buffer.read().decode('ascii')
        self.readline = lambda: self.buffer.readline().decode('ascii')


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip('\r\n')

# endregion


if __name__ == '__main__':
    main()


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

bool is_parindrome(string s) {
  int n = s.size();
  for (int i = 0; i < n / 2; i++) {
    if (s.at(i) != s.at(n - i - 1)) return false;
  }
  return true;
}

int main() {
  string s; cin >> s;
  cout << (is_parindrome(s) && is_parindrome(s.substr(0, s.size() / 2)) && is_parindrome(s.substr(s.size() / 2 + 1)) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main()
{
  int H, W;
  while (1)
  {
  cin >> H >> W;
  if (H == 0 && W == 0)
    break;
  for (int h = 0; h < H; ++h)
  {
    for (int w = 0; w < W; ++w)
    {
      cout << '#';
    }
    cout << endl;
  }
  cout << endl;
  }
}


Measured memory_bytes: 3088
#include <stdio.h>

int makePatterns(int minUsbl, int maxUsbl, int n, int s);

int main(void){
    int n, s;
    
    while(scanf("%d %d",&n, &s), n!=0 || s!=0){
        printf("%d\n", makePatterns(0,9,n,s));
    }
    return 0;
}

int makePatterns(int minUsbl, int maxUsbl, int n, int s){
    int ptns=0;

//    printf("%d - %d:%d,%d\n",minUsbl, maxUsbl, n, s);    
    if (n==0){
        if (s==0){
//            printf("well done\n");
            return 1;
        }else {
//            printf("failed\n");
            return 0;
        }
    }
    if (minUsbl > s) return 0;
    
    for (int i=minUsbl; i<=maxUsbl && i<=s; i++){
        ptns += makePatterns(i+1, maxUsbl, n-1, s-i);
    }
    return ptns;
}

Measured memory_bytes: 1028
import sys
sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
edge = [[] for _ in range(N + 1)]
ab = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    a, b = ab[i][0] - 1, ab[i][1] - 1
    edge[a].append(b)
    edge[b].append(a)

ans = 0

def f(now, v):
    global ans
    v |= (1 << now)
    for to in edge[now]:
        if not (v & (1<<to)):
            f(to, v)
    if bin(v).count("1") == N:
        ans += 1

f(0, 0)

print(ans)


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

int main() {
  int64_t N;
  scanf ("%d " ,&N );
  vector<int64_t> A(N+1);
  A.at(0) = 2;
  A.at(1) = 1;
  
  for (int i = 2; i <= N; i++ ) {
    A.at(i) = A.at(i - 2) + A.at(i - 1);
  }
  
  printf("%lld \n ", A.at(N));
}


Measured memory_bytes: 256