akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//
//-------------------関数----------------------//
ll tv[31][214514];
int main() {
  ll n, c;
  cin >> n >> c;
  REP(i, n) {
    ll s, t, c;
    cin >> s >> t >> c;
    tv[c][2 * s - 1] = 1;

    tv[c][2 * t] += -1;
  }
  REP(j, 31) {
    REP(i, 214512) { tv[j][i + 1] += tv[j][i]; }
  }
  ll maxa = 0;
  REP(i, 214512) {
    ll flag = 0;
    REP(j, 31) {
      if (tv[j][i]) {
        flag++;
      }
    }
    maxa = max(maxa, flag);
  }
  cout << maxa << endl;
}


Measured memory_bytes: 52224
from collections import deque
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(m)]
r = [[] for _ in range(n)]
v = [0]*n
for ab in AB:
    r[ab[0]-1].append(ab[1])
    r[ab[1]-1].append(ab[0])
ans = [1]*(n-1)
d = deque()
d.append(1)
v[0] = 1
while d:
    p = d.popleft()
    for i in r[p-1]:
        if v[i-1]==0:
            d.append(i)
            ans[i-2] = p
            v[i-1] = 1
print('Yes')
for an in ans:
    print(an)

Measured memory_bytes: 58600
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {

    mut       n:i64,
       }
    let mut ans = false;
    while n > 0 {
        if n % 10 == 7 {
            ans = true;
        }
        n /= 10;
    }
    yn(ans);
}

pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define ll long long
#define INF 0x7fffffff
using namespace std;
const int N = 1e6+5;

ll n,d;
bool Check(ll x,ll y) {
    return sqrt(x*x+y*y) <= d;
}
int main(){
    cin>>n>>d;
    int cnt = 0;
    for(ll i = 0,x,y;i < n;i++) {
        cin>>x>>y;
        if(Check(x,y)) cnt++;;
    }
    cout<<cnt;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    multiset<int> D;
    REP(i,N) {
        int inp;
        cin >> inp;
        D.insert(inp);
    }


    int M;
    cin >> M;
    vector<int> T(M);
    REP(i,M) cin >> T[i];

    REP(i,M) {
        if (D.empty()) {
            cout << "NO" << endl;
            return 0;
        }

        auto itr = D.find(T[i]);
        if (itr == D.end()) {
            cout << "NO" << endl;
            return 0;
        }

        D.erase(itr);
    }
    cout << "YES" << endl;



    return 0;
}


Measured memory_bytes: 12416
/*************************************************************************
>>> Author: WindCry1
>>> Mail: lanceyu120@gmail.com
>>> Website: https://windcry1.com
>>> Date: 12/20/2019 2:05:47 AM
*************************************************************************/
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <iostream>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <stack>
#include <bitset>
#include <iomanip>
#include <list>
#include <sstream>
#include <fstream>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ll long long
#define ull unsigned long long
#define DEBUG(x) cout<<#x<<" : "<<x<<endl;
#define lowbit(x) x&(-x)
#define ls(u) u<<1
#define rs(u) u<<1|1
using namespace std;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const double clf = 1e-8;
const int MMAX = 0x7fffffff;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
ostream& operator <<(ostream &out, pii &p){
	return out<<p.first<<" "<<p.second;
}
istream& operator >>(istream &in, pii &p){
	return in>>p.first>>p.second;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//ifstream cin("C:\\Users\\LENOVO\\Desktop\\in.txt");
	//ofstream cout("C:\\Users\\LENOVO\\Desktop\\out.txt");
	string s;cin>>s;
	int res=0;
	for(int i=0,j=s.size()-1;i<s.size();i++,j--)
		res+=s[i]!=s[j];
	cout<<(res>>1)<<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 repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<vector<int>> vvi;

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; map<string,int> M; 
void input(){
    cin>>N;
    rep(i,N){
        string a; cin>>a; SORT(a); M[a]++;
    }
    return;
}

void solve(){
    ll ans=0;
    for(auto p: M) ans+=(ll)(p.second-1)*p.second/2;
    cout<<ans<<endl;
    return;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, a[16], x[16][16], y[16][16], ans;
int main() {
	cin >> n;
	REP(i, n) {
		cin >> a[i];
		REP(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	REP(i, 1 << n) {
		bool ok = true;
		ll cnt = 0;
		REP(j, n) {
			if ((1ll << j) & i) {
				cnt++;
				REP(k, a[j]) {
					if ((((1ll << x[j][k]) & i) and !y[j][k]) or ((!((1ll << x[j][k]) & i) and y[j][k])))ok = false;
				}
			}
		}
		if (ok)ans = max(ans, cnt);
	}
	cout << ans << endl;
}


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

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

    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
        cout << "hon";
    else if (n == 3)
        cout << "bon";
    else
        cout << "pon";
    cout << endl;

    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vi p;
        rep(i, n){int m; cin >> m; p.pb(m); }

        vi v(n, 0);
        int count = 0;
        while(true){
            bool finish = true;
            for(int i=0;i < n; i++){
                if(p[i] != v[i]) finish = false;
            }
            if(finish) break;
            v = p;
            for(int i=0; i < n; i++){
                int c = 0;
                for(int j=0; j < n; j++){
                    if(v[i] == v[j]) c++;
                }
                p[i] = c;
            }
            count++;
        }
        cout << count-1 << endl;
        for(int i=0; i < n; i++){
            if(i == 0) cout << v[i];
            else cout << " " << v[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
deque<pair<int,int> > p;
bool flag[100000001];
int l;
void suanfa(){
    while(p.size()) {
        pair<int,int> 
		now=p.front(); 
		p.pop_front();
        if(flag[now.first]) 
		    continue;
        flag[now.first]=true;
        if(!now.first){
            cout<<now.second<<endl;
            return;
        }
        p.push_front(make_pair(now.first*10%l,now.second));
        p.push_back(make_pair((now.first+1)%l,now.second+1));
    }
}
int main() {
    cin>>l;
    p.push_front(make_pair(1,1));
    suanfa();
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {

	public static void main(String[] args) {
		final int MAX = 10000;

		Scanner stdin = new Scanner(System.in);

		int inN = stdin.nextInt();
		int[] sumArray = new int[inN + 1];
		int index = 0;
		loop:
		for (int num3 = 0; num3 <= 9; num3++) {
			for (int num2 = 0; num2 <= 9; num2++) {
				for (int num1 = 0; num1 <= 9; num1++) {
					for (int num0 = 0; num0 <= 9; num0++) {
						sumArray[index] = num3 + num2 + num1 + num0;
						index++;

						if (index > inN) {
							break loop;
						}
					}
				}
			}
		}
		if (inN == MAX) {
			sumArray[MAX] = 1;
		}

		int inA = stdin.nextInt();
		int inB = stdin.nextInt();
		int sum = 0;
		for (int i = 1; i <= inN; i++) {
			if ((inA <= sumArray[i]) && (sumArray[i] <= inB)) {
				sum += i;
			}
		}

		System.out.println(sum);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int a,b,c;
    while (~scanf("%d %d %d",&a,&b,&c)) {
        printf("%d\n", min(c, b/a));
    }
    
    return 0;
}



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

struct data{
	int id;
	int c1, c2;
};

bool comp(data d1, data d2){
	return d1.id < d2.id;
}

int index(char c){
	return (int)c - (int)'0';
}

int get_num(vector<int> vi){
	int n = 1;
	int c = 0;
	for(vector<int>::reverse_iterator iter = vi.rbegin();
		iter != vi.rend(); iter++)
	{
		c += n * index(*iter);
		n = n * 10;
	}
	return c;
}

int main(){
	vector<data> vd;
	int id;
	int day;
	string s;
	char c;
	while(getline(cin, s)){
		if(s == "") break;
		vector<int> vi;
		data d;
		string::iterator iter = s.begin();
		while(isdigit(*iter)) vi.push_back(*(iter++));
		d.id = get_num(vi);
		d.c1 = 1;
		d.c2 = 0;
		vi.clear();
		vector<data>::iterator vditer = vd.begin();
		while(vditer != vd.end() && (*vditer).id != d.id) vditer++;
		if(vditer == vd.end()) vd.push_back(d);
		else (*vditer).c1++;
	}
	while(cin >> id >> c >> day){
		vector<data>::iterator vditer = vd.begin();
		while(vditer != vd.end() && (*vditer).id != id) vditer++;
		if(vditer != vd.end()) (*vditer).c2++;
	}
	sort(vd.begin(), vd.end(), comp);
	for(vector<data>::iterator iter = vd.begin();
		iter != vd.end(); iter++)
	{
		if((*iter).c1 != 0 && (*iter).c2 != 0){
			cout << (*iter).id << " " << (*iter).c1 + (*iter).c2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 3000 + 5, MOD = 998244353;
int qpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }   
    return res;
}

int n, s;
int a[N];
int dp[N][N];

void add(int& x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;   
}

void run() {
    cin >> n >> s;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0][0] = qpow(2, n);
    int inv2 = (MOD + 1) / 2;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= s; j++) {
            if (j >= a[i]) {
                dp[i][j] = 1ll * dp[i - 1][j - a[i]] * inv2 % MOD;
            }
            dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
        }
    }
    cout << dp[n][s] << '\n';
}

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

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int ans = 0;
    rep(i, k) ans += p[i];
    cout << ans << endl;

    return 0;
}

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


int main()
{
	long long num,sum=0,div,div2,fac=0,x;
	cin>>num;
	if(num%2==1)cout<<0;
	else
	{
		div=10;
		x=num/div;
		while(x>0)
		{
			x=num/div;
			fac+=x;
			div*=5;
		}
		cout<<fac;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=200000+5;
int n;
ll a[maxn];
ll myabs(ll x){return x<0?-x:x;}
int main()
{
    scanf("%d",&n);
    ll all=0;
    for(int i=1;i<=n;i++) {scanf("%lld",&a[i]);all+=a[i];}
    ll mindel=0x3f3f3f3f3f3f3f3fll;
    ll sum=0;
    for(int i=1;i<=n-1;i++){
        sum+=a[i];
        mindel=min(mindel,myabs(sum-(all-sum)));
    }
    printf("%lld\n",mindel);
    return 0;
}


Measured memory_bytes: 1792
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    N = len(S)
    A = [0] * (N + 1)
    Start = []
    if S[0] == "<": Start.append(0)
    for i in range(N - 1):
        if S[i] == ">" and S[i+1] == "<": Start.append(i + 1)
    if S[N-1] == ">": Start.append(N)
    for s in Start:
        if s < N:
            for r in range(s, N):
                if S[r] == ">": break
                else: A[r + 1] = max(A[r + 1], A[r] + 1)
    for s in Start:
        if s > 0:
            for r in reversed(range(1, s + 1)):
                if S[r - 1] == "<": break
                else: A[r - 1] = max(A[r - 1], A[r] + 1)
    #print(A)
    print(sum(A))
    #print(Start)

    
    
    return 0

if __name__ == "__main__":
    solve()



Measured memory_bytes: 23336
#include<stdio.h>

int main(void)

{
    int a,s,d;
    
    scanf("%d %d %d",&a,&s,&d);
    
    if(a<s){
        if(s<d){
        printf("Yes\n");
        }
         else{
        printf("No\n");
        }
    }
    
    else{
        printf("No\n");
    }

    return 0;
}


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

int main() {
  
  int N;
  int b = 0; //総数
  int c = 0;
  int sa = 0;
  int min = 100000; //最終出力
  cin >> N;
  
  vector<int> A(N);
  
  for ( int i =0; i < N; i++) {
    cin >> A.at(i);
    b += A.at(i);
  }
  
  for ( int i =0; i < N - 1; i++) {
    c += A.at(i);
    sa = b - c * 2;
    if ( sa < 0) sa *= -1;
    if ( min > sa ) min = sa;
    }
  
  cout << min << endl;
  
}

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

int main(){
  char c;
  char i;
  int a[26]={};

  while(cin >> c){
    //cout << c << endl;
    if(c>='A'&&c<='Z')c+=32;//大文字を小文字に
    if(c>='a'&&c<='z'){//cがアルファベットなら文字をカウント
      a[c - 'a']+=1;
    }
  }

  for(int i=0; i<26; i++){
    cout << char(i+'a') << " : " << a[i] << endl;
  }
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define dmp(x) cerr<<#x<<":"<<x<<endl
typedef pair<int,int> P;
typedef pair<int,P> PP; 
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
const int MOD = 1e9+7;

signed main(){
  int n;
  while(cin>>n,n){
    [&](){
	 int INF=1LL<<60;
	 vector<int> a;
	 for(int i=0;i<n;i++){
	   string s;
	   cin>>s;
	   if(s=="x")a.pb(INF);
	   else a.pb(stoi(s));
	 }
	 int lower=-INF,upper=INF;
	 for(int i=0;i<n;i++){
	   if(i>0&&a[i]==INF&&a[i-1]!=INF){
		if(i%2){
		  chmax(lower,a[i-1]+1);
		}else{
		  chmin(upper,a[i-1]-1);
		}
	   }
	   if(i<n-1&&a[i]==INF&&a[i+1]!=INF){
		if(i%2){
		  chmax(lower,a[i+1]+1);
		}else{
		  chmin(upper,a[i+1]-1);
		}
	   }
	   if(i&&a[i]!=INF&&a[i-1]!=INF){
		if(i%2&&a[i-1]>=a[i]){
		  cout<<"none"<<endl;
		  return;
		}
		if(i%2==0&&a[i-1]<=a[i]){
		  cout<<"none"<<endl;
		  return;
		}
	   }
	   if(i&&a[i-1]==INF&&a[i]==INF){
		cout<<"none"<<endl;
		return;
	   }
	 }
	 //	 dmp(lower),dmp(upper);
	 if(lower==upper)cout<<lower<<endl;
	 else if(lower<upper)cout<<"ambiguous"<<endl;
	 else cout<<"none"<<endl;
    }();
  }
  return 0;
}



Measured memory_bytes: 3084
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	string s;
  	cin >> s;
  	int cnt = 0;
  	rep(i,s.size()) {
      	if(s[i] == '+'){
        	cnt++;
        }else{
        	cnt--;
        }
    }
   	cout << cnt << endl;
	return;
}

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


Measured memory_bytes: 256
li = [0,0,0,0]

for i in range(3):
    a,b = map(int,input().split())
    for j in range(1,5):
        if(a == j or b == j):
            li[j-1] += 1;

if(min(li) == 0 or max(li) == 3):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3060
def main():
    n, k = map(int, input().split())
    h = [int(x) for x in input().split()]
    h_s = sorted(h)
    if len(h_s) <= k:
        ans = 0
    else:
        for _ in range(k):
            h_s.pop()
        ans = sum(h_s)
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31332
# from pprint import pprint
# import math
# import collections
import numpy as np
import itertools
import copy

# n = int(input())
h, w, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))

white = '.'
black = '#'

c = []
c2 = [[0] * w for h in range(h)]
for i in range(h):
    c.append(list(input()))

for i in range(h):
    for j in range(w):
        c2[i][j] = 1 if c[i][j] == black else 0

# bit全探索
pattern = []
cnt = 0
for _h in list(itertools.product([0, 1], repeat=h)):
    for _w in list(itertools.product([0, 1], repeat=w)):
        pattern.append((_h, _w))

cnt = 0
for p in pattern:
    # print(p)
    test_c = copy.deepcopy(c2)
    for i, ih in enumerate(p[0]):
        for j, jw in enumerate(p[1]):
            if ih == 0 or jw == 0:
                test_c[i][j] = 0
    sum = np.array(test_c).sum()
    # print(sum)

    if sum == k:
        cnt += 1

print(cnt)


Measured memory_bytes: 27240
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeMinimum(Node x){
  while(x->left!=NIL)x = x->left;
  return x;
 
}
 
Node treeSearch(Node u, int k){
  while(u !=NIL){
    if(u->key == k)break;
    else if(u->key < k)u = u->right;
    else u = u->left;
  }
  return u;
}
 
Node treeSuccessor(Node x){
  Node y;
  if(x->right != NIL)return treeMinimum(x->right);
  y = x->parent;
  while(y!=NIL && x == y->right){
    x=y;
    y=y->parent;
  }
  return y;
}
 
void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left == NIL || z->right == NIL)y=z;
  else y = treeSuccessor(z);
  if(y->left!=NIL)x=y->left;
  else x = y->right;
  if(x != NIL)x->parent = y->parent;
  if(y->parent == NIL) root = x;

    else if(y == y->parent->left) y->parent->left = x;

    else y->parent->right = x;

    if(y != z) z->key = y->key;
}
 

 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   
  while(x != NIL){
    y=x;
    if(z->key < x->key)x = x->left;
    else x = x->right;
  }
  z->parent = y;
   if(y == NIL)
      root = z;
    else if(z->key < y->key)
        y->left = z;
    else
      y->right = z;
 
   
}
void inorder(Node u){
if(u != NIL){
    inorder(u->left);
    printf(" %d",u->key);  
    inorder(u->right);
      }
}
void preorder(Node u){
 if(u != NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
      }
}
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }
 
  return 0;
}

Measured memory_bytes: 19364
gets.to_i.times{h=Hash.new{0}
gets.to_i.times.map{gets}.map{|p|p.scan(/../).each_with_index{|s,i|h[Rational(i,p.size/2)]+=s.hex if"00"!=s}}
d=h.keys.map(&:denominator).inject(1){|r,l|r.lcm(l)}
puts d>1024?"Too complex.":d.times.map{|i|(f=h[Rational(i,d)])?format("%02X",f):"00"}*""}

Measured memory_bytes: 7108
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;

fn main() {
    let a: usize;
    input!(a);
    let ans = a / 11;
    if a % 11 == 0 {
        p(ans * 2);
    } else if a % 11 <= 6 {
        p(ans * 2 + 1);
    } else {
        p(ans * 2 + 2);
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
namespace io{
	const int L=(1<<19)+1;
	char ibuf[L],*iS,*iT,c;int f;
	char gc(){
		if(iS==iT){
			iT=(iS=ibuf)+fread(ibuf,1,L,stdin);
			return iS==iT?EOF:*iS++; 
		}
		return*iS++;
	}
	template<class I>void gi(I&x){
		for(f=1,c=gc();c<'0'||c>'9';c=gc())if(c=='-')f=-1;
		for(x=0;c<='9'&&c>='0';c=gc())x=x*10+(c&15);x*=f;
	}
};
using io::gi;
using io::gc;
const int mod=998244353;
const int M=600005;
long long fac[M],inv[M];
int n,a,b;
long long k;
int ans=0;
long long C(int x,int y){
	if(y>x||y<0)return 0;
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
    fac[0]=1;for(int i=1;i<=600000;i++)fac[i]=fac[i-1]*i%mod;
    inv[1]=1;for(int i=2;i<=600000;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
    inv[0]=1;for(int i=1;i<=600000;i++)(inv[i]*=inv[i-1])%=mod;
	scanf("%d%d%d%lld",&n,&a,&b,&k);
	for(int i=0;i<=n;i++)if((k-(long long)a*i)%b==0){
		ans=(ans+C(n,i)*C(n,(k-(long long)a*i)/b)%mod)%mod;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 9600
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// for loop
#define REP(i, n) for ((i) = 0;(i) < (ll)(n);(i)++)

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

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

	ll N, M;
	cin >> N >> M;

	vector<ll> Hs(N);
	for (ll i = 0; i < N; ++i) {
		cin >> Hs[i];
	}

	vector<vector<ll>> edges(N);
	ll a, b;
	for (ll i = 0; i < M; ++i) {
		cin >> a >> b;
		--a, --b;
		edges[a].emplace_back(b);
		edges[b].emplace_back(a);
	}

	ll res = 0;
	for (ll i = 0; i < N; ++i) {
		bool is_highest = true;
		for (ll j = 0; j < edges[i].size(); ++j) {
			if (Hs[i] <= Hs[edges[i][j]]) {
				is_highest = false;
				break;
			}
		}
		if (is_highest) {
			++res;
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 9796
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=(n);i<(int)N;i++)
#define p(s) cout<<(s)<<endl
#define ck(n,a,b) (a)<=(n)&&(n)<(b)
typedef long long ll;
using namespace std;
const int inf=1e9;

int main() {
	string A,B;
	cin>>A>>B;
	string ans;
	if(A.size()>B.size()) ans="GREATER";
	else if(A.size()<B.size()) ans="LESS";
	else if(A>B) ans="GREATER";
	else if(A<B) ans="LESS";
	else ans="EQUAL";
	p(ans);
	return 0;
}


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

typedef pair<int,string> P;

int main() {
  //input & calc
  int N;
  cin >> N;
  map<string,int> num;
  string S;
  rep(i,N) {
    cin >> S;
    if ( num.count(S) ) {
      num[S]++;
    }
    else {
      num[S] = 1;
    }
  }
  priority_queue<P, vector<P>, function<bool(P,P)>> pq(
    [](P p1, P p2)
      {
        if ( p1.first != p2.first ) {
          return p1.first < p2.first;
        }
        return p1.second > p2.second;
      }
  );
  for(auto itr = num.begin(); itr != num.end(); ++itr) {
    pq.push(make_pair(itr->second, itr->first));
  }
  //output
  P p = pq.top();
  pq.pop();
  cout << p.second << endl;
  int value = p.first;
  while(!pq.empty()) {
    p = pq.top();
    pq.pop();
    if ( p.first != value ) {
      break;
    }
    cout << p.second << endl;
  }
}

Measured memory_bytes: 29552
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;
const double PI = acos(-1);
inline bool equals(double a, double b) { return abs(b - a) < EPS; }
using Point = complex<double>;
namespace std { bool operator < (const Point &a, const Point &b) { return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b); } }
struct Line
{
    Point a, b;
    Line(Point a, Point b) : a(a), b(b) {}
};
double dot(const Point &a, const Point &b) { return real(a) * real(b) + imag(a) * imag(b); }
double cross(const Point &a, const Point &b) { return real(a) * imag(b) - imag(a) * real(b); }
bool isParallel(const Line &a, const Line &b) { return equals(cross(a.b - a.a, b.b - b.a), 0.0); }
bool isOrthogonal(const Line &a, const Line &b) { return equals(dot(a.a - a.b, b.a - b.b), 0.0); }
Point projection(const Line &l, const Point &p)
{
    double t = dot(p - l.a, l.a - l.b) / norm(l.a - l.b);
    return l.a + (l.a - l.b) * t;
}
Point reflection(const Line &l, const Point &p) { return p + (projection(l, p) - p) * 2.0; }
int ccw(const Point &a, Point b, Point c)
{
    b = b - a, c = c - a;
    if(cross(b, c) > EPS) return 1;
    if(cross(b, c) < -EPS) return -1;
    if(dot(b, c) < 0) return 2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    double x0, y0, x1, y1; cin >> x0 >> y0 >> x1 >> y1;
    int q; cin >> q;
    while(q--)
    {
        double x, y; cin >> x >> y;
        int res = ccw(Point(x0, y0), Point(x1, y1), Point(x, y));
        if(res == 1) cout << "COUNTER_CLOCKWISE" << endl;
        else if(res == -1) cout << "CLOCKWISE" << endl;
        else if(res == 2) cout << "ONLINE_BACK" << endl;
        else if(res == -2) cout << "ONLINE_FRONT" << endl;
        else cout << "ON_SEGMENT" << endl;
    }
    return 0;
}




Measured memory_bytes: 3332
package main
import (
    "fmt"
    "bufio"
    "os"
    "strings"
    "strconv"
)

var stdin = bufio.NewScanner(os.Stdin)

func sI() string {
	stdin.Scan()
	return stdin.Text()
}

type atc struct {
    ac bool
    wa int
}

func main() {
    nm := strings.Split(sI(), " ")
    //n,_ := strconv.Atoi(nm[0])
    m,_ := strconv.Atoi(nm[1])

    psMap := make(map[int]*atc)
    for i := 0; i <  m; i++ {
        ps := strings.Split(sI(), " ")
        p,_ := strconv.Atoi(ps[0])
        s := ps[1]

        if psMap[p] == nil {
            if s == "AC" {
                psMap[p] = &atc{ ac: true, wa: 0 }
            }else{
                psMap[p] = &atc{ ac: false, wa: 1 }
            }
        }else{
            if psMap[p].ac == false {
                if s == "AC" {
                    psMap[p].ac = true
                }else{
                    psMap[p].wa++
                }
            }
        }
    }

    var acSum, waSum int
    for _, value := range psMap {
        if value.ac {
            acSum++
            waSum += value.wa
        }
    }
    fmt.Println(acSum, waSum)
}


Measured memory_bytes: 7552
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long int llint;
const int SIZE = 100000;
int dp[SIZE+1];

int main(void){
  int n;
  std::cin >> n;
  for(int i=0; i<=100000; i++){
    if(i==0) dp[i] = 0;
    else     dp[i] = 1000000; // large number
  }
  for(int i=1; i<=n; i++){
    dp[i] = std::min(dp[i], dp[i-1]+1);
    for(int j=6; j<=i; j*=6){
      dp[i] = std::min(dp[i], dp[i-j]+1);
    }
    for(int j=9; j<=i; j*=9){
      dp[i] = std::min(dp[i], dp[i-j]+1);
    }
  }
  std::cout << dp[n] << std::endl;
  return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
signed main(){
    int a,b,c,d,e,f; cin>>a>>b>>c>>d>>e>>f;
    vector<bool>dp(6001+100,false);
    for(int i=0;;i++){
        if(i*a*100>f)break;
        for(int j=0;;j++){
            if(i*100*a+j*100*b>f)break;
            dp[i*100*a+j*100*b]=true;
        }
    }
    vector<bool>sug(6001+100,false);
    for(int i=0;;i++){
        if(i*c>f)break;
        for(int j=0;;j++){
            if(i*c+j*d>f)break;
            sug[i*c+j*d]=true;
        }
    }
    int x=-INF;
    pii ans=pii(0,0);
    for(int now=f;now>0;now--){
        for(int wat=now;wat>0;wat--){
            if(dp[wat]&&sug[now-wat]){
                if(100*(now-wat)>e*wat)continue;
                if(ans.first*(now-wat)>now*(ans.second)||x==-INF){
                    if(x==-INF)x=1;
                    ans=pii(now,now-wat);
                }
            }
        }
    }
    cout<<ans.first<<" "<<ans.second<<endl;
}

Measured memory_bytes: 256
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
//const n = +input[0];
//const a = [];
//for(let i=0;i<n;i++){
//	a.push(input[i+1].split(" ").map((x:string):number=>+x));
//}

//const [n, m] = input[0].split(" ").map((x: string): number => +x);
//const a = input[1].split(" ").map((x: string): number => +x);

function compareFunc(a, b){
    return a-b;
}

const [a, b]: number[] = input[0].split(' ').map((x: string): number => +x);

if ( b*2 >= a){
    console.log(0);
}else{
    console.log(a-b-b);
}



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

using namespace std;



int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  std::vector<long long> v(N);
  for(int i = 0; i < N; ++i) {
    cin >> v[i];
  }

  long long res = 0;

  std::sort(begin(v), end(v));

  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      auto part = std::lower_bound(begin(v), end(v), v[i] + v[j]);

      //(j, part)
      int dist = std::distance(begin(v), part);
      res += dist - j - 1;
    }
  }
  std::cout << res << std::endl;


  return 0;
}


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

int main(){
  int A, B, re = 0;
  
  cin >> A >> B;
  for (int i = 0; i < 2; i++){
    if(A > B){
      re += A;
      A--;
    } else {
      re += B;
      B--;
    }
  }
  
  cout << re << endl;
  
  return 0;
}

Measured memory_bytes: 256
n=int(input())
d=[]
for i in range(n):
    d.append(int(input()))
ans=0
for i in range(n):
    m=max(d)
    for _ in range(d.count(m)):
        d.remove(m)
    ans+=1
    if(len(d)==0):
        break
print(ans)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

sum = 0
for i in range(N) :
  if V[i] - C[i] > 0 :
    sum += V[i] - C[i]
  
print (sum)
  
  


Measured memory_bytes: 38384
/// wa ^3^

//#pragma GCC optimize("O3")

#include<iostream>
#include<vector>
#include<iomanip>
                           
using namespace std;

const int MOD = 1e9 + 7;

int cnt[(int)2e5+10];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int dp = -1;
    vector<int> a;
    for (int x; n--;) {
        cin >> x;
        if (x != dp)
            a.push_back(x);
        dp = x;            
    }
    dp = 1;
    for (int x : a) {
        cnt[x] += dp;
        if (cnt[x] >= MOD)
            cnt[x] -= MOD;
        dp = cnt[x];    
    }
    cout << dp;
    return 0;
}



Measured memory_bytes: 1908
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    int x;
    cin>>x;
    if(x>=30)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;

}





































Measured memory_bytes: 3608
import math
s = input()

if len(s) == 0:
    print(0)

ans1 = 0
ss = '01'*math.ceil(len(s)/2)
ss = ss[:len(s)]
for i in range(len(s)):
    if not ss[i] == s[i]:
        ans1 += 1

ans2 = 0
ss = '10'*math.ceil(len(s)/2)
ss = ss[:len(s)]
for i in range(len(s)):
    if not ss[i] == s[i]:
        ans2 += 1
print(min(ans1, ans2))

Measured memory_bytes: 3316
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
ll freq[10][10];
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, ans = 0, i, j;
    cin>>n;
    for(i=1; i<=n; i++) {
    	ll l = i % 10;
    	ll f = i;
    	while(f >= 10) {
    		f /= 10;
    	}
    	freq[f][l]++;
    }
    for(i=0; i<=9; i++) {
    	for(j=0; j<=9; j++) {
    		ans += freq[i][j]*freq[j][i];
    	}
    }
    // ans /= 2;
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
flag = 1
for i in range(n):
    if a[i]%2 ==0:
        if not((a[i]%3==0)or(a[i]%5==0)):
            flag=0

if flag:
    print("APPROVED")
else:
    print("DENIED")

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n; n++;
  ll x = 1LL*n*(n+1)*(n-1)/6;
  for(int i = n-3; i >= 0; --i){
    int a,b; cin >> a >> b;    
    if(a > b)a^=b^=a^=b;
    x -= 1LL*a * (n-b);
  }
  cout << x << '\n';
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
int main(){
    double l, a, b, h, m;
    cin >> a  >> b >> h >> m;
    //cout << h*m*11 << endl;
    printf("%.20f\n", sqrt(a*a + b*b - 2*a*b*cos((60*h + m)*11*pi / 360)));
    return 0;
}  

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

int main(){
  string s;
  cin >> s;
  int L=s.size();
  int N=0;
  for(int i=0; i<L-1; i++){
    if(s.at(i)==s.at(i+1)){
      cout << i+1 << " " << i+2 << endl;
      N=1;
      goto end;
    }
  }
  for(int i=0; i<L-2; i++){
    if(s.at(i)==s.at(i+2)){
      cout << i+1 << " " << i+3 << endl;
      N=1;
      goto end;
    }
  }
  cout << -1 << " " << -1 << endl;
end: s="a";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a, b, c, d;
  d = N % 10;
  c = ((N - d)/10)%10;
  b = ((N - 10*c-d)/100)%10;
  a = (N -100*b -10*c -d)/1000;
  if (a == b && b == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int time_next_station(int current_time,int c,int s,int f){
    int i(0);
    while(current_time>(s+f*i))i++;
    return (s+f*i+c);
}
int main(void){
    int n;
    cin>>n;
    int c[500]={0},s[500]={0},f[500]={0};
    for(int i(0);i<n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }
    for(int i(0);i<n-1;i++){
        int time(0);
        for(int j(i);j<n-1;j++){
            time = time_next_station(time,c[j],s[j],f[j]);
        }
        cout<<time<<endl;
    }
    cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll f(ll a, ll b) {
	return a / 2 - min(b, a - b);
}
int main() {
	int n; cin >> n; ll a[114514];
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	ll p = f(a[n - 1], a[0]); int ans = 0;
	for (int i = 1; i < n - 1; i++) {
		if (f(a[n - 1], a[i]) < p) {
			ans = i;
			p = f(a[n - 1], a[i]);
		}
	}
	cout << a[n - 1] << ' ' << a[ans] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum = 0;
  for (int i = 0; i <= N; ++i) 
  {if(findSumOfDigits(i) >= A && findSumOfDigits(i) <= B)
    sum += i; 
    }
  cout << sum << endl;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
        
def main():
    import sys
    
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = UnionFind(N)
    for _ in range(M):
        x,y,z = map(int, input().split())
        A.union(x,y)
    answer = []
    for i in range(1,N+1):
        answer.append(A.find(i))
    print(len(set(answer)))    
    
    
    
main()

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

int main() {
	int n, m, p;
	while(cin >> n >> m >> p && (n || m || p)){
		int x[200], sum = 0;
		for(int i = 0; i < n; ++i){
			cin >> x[i];
			sum += (x[i] * 100);
		}
		sum = sum * (100 - p) / 100;
		
		if(x[m - 1] == 0)
			cout << "0" << endl;
		else
			cout << sum / x[m - 1] << endl;
	}
	return 0;
}

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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx - sx;
    int dy = ty - sy;
    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');
    cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
    cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U' <<endl;
    
    return 0;
}

Measured memory_bytes: 256
s =input()
l = []
ans = 0
for i in range(len(s)):
    if s[i] == 'A' or s[i] == 'C' or s[i] == 'G' or s[i] == 'T':
        l.append(1)
    else:
        l.append(0)
l.append(0)
for i in range(len(l)):
    cnt = 0
    j = 0
    while l[i+j] == 1:
        cnt += 1
        j += 1
    if ans < cnt:
        ans = cnt
        
print(ans)

Measured memory_bytes: 3064