akhauriyash/Code-Regression huggingface dataset:
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
const int INF = 1001001001;
const ll LONGINF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector<int> X(N), Y(N);

    for(int i=0; i<N; i++) {
        cin >> X[i] >> Y[i];
    }

    vector<int> perm(N);
    iota(perm.begin(), perm.end(), 0);

    double PI = acos(-1);
    double ans = LONGINF;
    do {
        vector< pair<int, int> > points;
        points.emplace_back(0, 0);
        for(auto e : perm) points.emplace_back(X[e], Y[e]);
        points.emplace_back(0, 0);

        double theta = 0, sum = 0;
        for(int i=0; i<=N; i++) {
            int dx = points[i+1].first - points[i].first;
            int dy = points[i+1].second - points[i].second;
            // fprintf(stderr, "dx = %d, dy = %d\n", dx, dy);

            double n_theta = atan2(dy, dx);

            double rot = min(abs(theta - n_theta), 2*PI - abs(theta - n_theta));
            sum += rot / PI * 180.0;
            // fprintf(stderr, "rot = %.12f\n", rot / PI * 180);
            theta = n_theta;
        }
        ans = min(ans, sum);
    }while(next_permutation(perm.begin(), perm.end()));

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



Measured memory_bytes: 3468
#include <stdio.h>
int main(void)
{
	int i2,i,a;
	for(i=1;i<=9;i++){
		for(i2=1;i2<=9;i2++){
			a=i2*i;
			printf("%dx%d=%d\n",i,i2,a);
		}
	}
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);++i)

int main() {
  for(;;) {
    int N; cin >> N; if( N == 0 ) break;
    int ans = 0;
    for(int start = 1; start < N; start++) {
      int sum = 0;
      for(int i = 0; sum < N; i++)
        sum += start + i;
      if( sum == N )
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
N = int(input())
if N == 0:
	print(2)
elif N == 1:
	print(1)
else:
	L0,L1 = 2,1
	for i in range(N-1):
		L2 = L0 + L1
		L0,L1 = L1,L2
	print(L2) 

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

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

    size_t size = str.length();

    int count=0, current=1;
    string s = "1";
    string t = "0";

    for(int i=0;i<size;i++){
        if(current == 1){
            if(str.compare(i,1,s) == 0){
                count ++;
            }
            current =0;
        }else{
            if(str.compare(i,1,t) == 0){
                count ++;
            }
            current=1;
        }
    }
    if(count *2 >size){
        count = size - count;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 512
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn in_range(path: (i32, i32), point: i32) -> bool {
    if path.0 < path.1 {
        path.0 < point && point < path.1
    } else {
        path.1 < point && point < path.0
    }
}

fn main() {
    let line = read_vec::<i32>();
    if in_range((line[0], line[1]), line[2]) {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod = 1'000'000'007;

int main(){
  int n, m;
  cin >> n >> m;
  vector<bool> broken(n+1, false);
  rep(i,m){
    int j;
    cin >> j;
    broken.at(j) = true;
  }
  vi dp(n+2);
  dp.at(n) = 1; 
  for (int i=n-1; i>=0; i--){
    if (broken.at(i)){
      dp.at(i) = 0;
      continue;
    }
    dp.at(i) = (dp.at(i+1) + dp.at(i+2)) % mod;
  }
  cout << dp.at(0) << endl;
  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	string s; cin >> s;
	ll n = s.size();
	vi cnt(26);
	for (auto c : s) cnt[c - 'a']++;
	ll ans = n * (n - 1) / 2 + 1;
	for (ll i : cnt)
	{
		if (i > 0) ans -= i * (i - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
from collections import defaultdict
N,M=map(int,input().split())
PD=defaultdict(lambda: [])
OR=dict()
ANS=dict()
for i in range(M):
    p, y=map(int,input().split())
    OR[i] = (p,y)
    PD[p].append(y)

for k in PD.keys():
    l=sorted(PD[k])
    for i,n in enumerate(l):
        ANS[(k,n)] = str(k).zfill(6) + str(i+1).zfill(6)
for k in OR.values():
    print(ANS[k])

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

int main(){
  long long n;
  string s;
  cin >> n >> s;
  long long w=0;
  long long bl;
  long long wr;
  
  for(long i=0; i<n; i++){
    if(s.at(i) == '.'){
      w++;
    }
  }
  
  bl=0;
  wr=w;
  long long res = bl+wr;
  
  for(long i=0; i<n; i++){
    if(s.at(i) == '.'){
      wr--;
    }else{
      bl++;
    }
    
    res = min(res,wr+bl);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)

using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii; 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;

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

void solve() {
	int n, x, t;
	cin >> n >> x >> t;
	
	cout << ceil(n, x) * t << endl;
}

int main(){
	ios_base::sync_with_stdio(false);
	solve();
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i > n; --i)
typedef long long ll;
#define mod 1000000007

int main() {
  int N; cin >> N;
  vector<int> p(N), a(N), b(N);
  rep(i, 0, N) cin >> p[i];
  rep(i, 0, N) {
    a[i] = i * 25000 + 1;
    b[i] = 1e9 - a[i];
  }
  rep(i, 0, N) a[p[i]-1] += i;
  for(auto p : a) cout << p << " ";
  cout << endl;
  for(auto p : b) cout << p << " ";
  cout << endl;
  return 0;
}


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

vector<vector<int>> graph;
vector<int> d;
void DFS(int v, int previous_v){
    for(int adjacent : graph[v]){
        if(adjacent == previous_v) continue;

        d[adjacent] = d[v] + 1;
        DFS(adjacent, v);
    }
}

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

    graph.resize(n);
    for(int i=0; i<n-1; i++){
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;

        graph[a].push_back(b);
        graph[b].push_back(a);
    }

    d.assign(n,0);
    DFS(0, -1);
    int furthest, dist = 0;
    for(int i=0; i<n; i++){
        if(dist < d[i]){
            furthest = i;
            dist = d[i];
        }
    }
    d.assign(n,0);
    DFS(furthest, -1);
    int diameter = 0;
    for(int i=0; i<n; i++){
        if(diameter < d[i]){
            diameter = d[i];
        }
    }

    vector<bool> ans(diameter+1);
    ans[0] = true;
    ans[1] = false;
    for(int i=2; i<=diameter; i++){
        ans[i] = (!ans[i-1]) | (!ans[i-2]);
    }
    if(ans[diameter] == true)  cout << "First"  << endl;
    if(ans[diameter] == false) cout << "Second" << endl;
    return 0;
}

Measured memory_bytes: 24300
#include <iostream>
using namespace std;
int main(){
  int e,y;
  cin >>e>>y;
  if(e==0){
    if(y<=1911){
      cout <<"M"<<y-1867<<endl;
    }
    if((y>=1912)&&(y<=1925)){
      cout <<"T"<<y-1911<<endl;
    }
    if((y>=1926)&&(y<=1988)){
      cout <<"S"<<y-1925<<endl;
    }
    if(y>=1989){
      cout <<"H"<<y-1988<<endl;
    }
  }
  if(e==1){
    cout <<y+1867<<endl;
  }else if(e==2){
    cout <<y+1911<<endl;
  }else if(e==3){
    cout <<y+1925<<endl;
  }else if(e==4){
    cout <<y+1988<<endl;
  }
  return 0;
}

Measured memory_bytes: 3100
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int a1 = 0;
    int a2 = 0;
    int e[] = new int[n+1];
    int w[] = new int[n+1];
    String t = scan.next();

    for (int i=0;i<n;i++){
      if (t.charAt(i) == 'E'){
        a1 += 1;
      }
      else{
        a2 += 1;
      }
      e[i+1] = a1;
      w[i+1] = a2;
    }

    int sum = n;
    for (int j=1;j<=n;j++){
      int check = w[j-1]+e[n]-e[j];
      sum = (int) Math.min(sum,check);
    }
    System.out.println(sum);
  }

}


Measured memory_bytes: 45044
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;




int main() {
  int N;
  cin >> N;
  int a[N];
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  int count = 0;
  for(int i = 0; i < N; i++) {
    if(a[i] == i+1) {
      if(i == 0) {
        count++;
        int tmp = a[i];
        a[i] = a[i+1];
        a[i+1] = tmp;
        continue;
      }
      else if(i + 1 == N) {
        count++;
        int tmp = a[i];
        a[i] = a[i-1];
        a[i-1] = tmp;
        continue;
      }
      else {
        if(a[i-1] == i) {
          count++;
          int tmp = a[i];
          a[i] = a[i-1];
          a[i-1] = tmp;
          continue;
        }
        if(a[i+1] == i+2) {
          count++;
          int tmp = a[i];
          a[i] = a[i+1];
          a[i+1] = tmp;
          continue;
        }
        if(a[i-1] == i) {
          count++;
          int tmp = a[i];
          a[i] = a[i+1];
          a[i+1] = tmp;
          continue;
        }
        if(a[i+1] == i) {
          count++;
          int tmp = a[i];
          a[i] = a[i-1];
          a[i-1] = tmp;
          continue;
        }
        count++;
        int tmp = a[i];
        a[i] = a[i-1];
        a[i-1] = tmp;
        continue;
      }
    }
  }

  cout << count << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i , n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
vector<long long> fact, fact_inv, inv;
void init_nCk(int SIZE) {
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
long long nCk(int n, int k) {
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}
int main(){
    int s;
    cin >> s;
    int n = s / 3;
    ll ans = 0;
    while(n > 0){
        int t = s - n * 3;
        init_nCk(t + n - 1);
        ans += nCk(t + n - 1, n - 1);
        ans %= MOD;
        n -= 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

typedef long long ll;

ll mypow(ll x, ll y, ll m)
{
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 1) {
		return mypow(x, y - 1, m) * x % m;
	} else {
		ll p = mypow(x, y / 2, m) % m;
		return p * p % m;
	}
}

ll f(ll n, ll b, ll ten, ll m)
{
	if (n == 0) {
		return 0;
	}
	if (n % 2 == 1) {
		return ((f(n - 1, b, ten, m) * (ten % m)) % m + 1) % m;
	} else {
		ll x = f(n / 2, b, ten, m);
		return  (x * mypow(ten % m, n / 2, m) % m + x) % m;
	}
}

ll g(ll n, ll b, ll ten, ll m)
{
	if (n == 0) {
		return 0;
	}
	if (n % 2 == 1) {
		return (g(n - 1, b, ten, m) * (ten % m) % m + (b % m * (n - 1) % m) % m) % m;
	} else {
		ll x = g(n / 2, b, ten, m);
		return (x * mypow(ten % m, n / 2, m) % m + x + b % m * (n / 2) % m * f(n / 2, b, ten, m) % m) % m;
	}
}

int main(int argc, char *argv[])
{
	ll L, A, B, M;
	
	cin >> L >> A >> B >> M;

	ll last = A + B * (L - 1);
	ll ten = 10;
	ll ans = 0;

	for (int i = 1; i <= 18; i++, ten *= 10) {
		ll l = ten / 10, r = ten - 1;
		if (A > r) {
			continue;
		}
		if (last < l) {
			continue;
		}
		ll a, nl;
		if (A >= l) {
			a = A;
		} else {
			ll n = ((l - A) + (B - 1)) / B;
			a = A + n * B;
			a = min(a, last);
		}
		ll nlast = 0;
		if (last <= r) {
			nlast = last;
		} else {
			ll n = (r - A) / B;
			nlast = A + n * B;
		}
		nl = (nlast - a) / B + 1;

		ans *= mypow(ten % M, nl, M) % M;
		ans %= M;
		ans += (a % M * f(nl, B, ten, M)) % M;
		ans %= M;
		ans += g(nl, B, ten, M);
		ans %= M;
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
struct edge{
  ll to,cost;
};
#define MAXN 100010
#define MAXM 100010
#define INF 100000000000000000
ll n,m,s,t;
ll u[MAXM],v[MAXM],a[MAXM],b[MAXM];
vector<edge> Ga[MAXN],Gb[MAXN];
ll da[MAXN],db[MAXN];
int main(){
  cin>>n>>m>>s>>t;
  for(int i=0;i<m;i++){
    cin>>u[i]>>v[i]>>a[i]>>b[i];
    Ga[u[i]].push_back({v[i],a[i]});
    Ga[v[i]].push_back({u[i],a[i]});
    Gb[u[i]].push_back({v[i],b[i]});
    Gb[v[i]].push_back({u[i],b[i]});
  }
  priority_queue<P,vector<P>,greater<P>> qa,qb;
  fill(da,da+MAXN,INF);
  fill(db,db+MAXN,INF);
  da[s]=0;
  db[t]=0;
  qa.push(P(0,s));
  qb.push(P(0,t));
  while(!qa.empty()){
    P p=qa.top();
    qa.pop();
    ll w=p.second;
    if(da[w]<p.first) continue;
    for(int i=0;i<Ga[w].size();i++){
      edge e=Ga[w][i];
      if(da[e.to]>da[w]+e.cost){
        da[e.to]=da[w]+e.cost;
        qa.push(P(da[e.to],e.to));
      }
    }
  }
  while(!qb.empty()){
    P p=qb.top();
    qb.pop();
    ll w=p.second;
    if(db[w]<p.first) continue;
    for(int i=0;i<Gb[w].size();i++){
      edge e=Gb[w][i];
      if(db[e.to]>db[w]+e.cost){
        db[e.to]=db[w]+e.cost;
        qb.push(P(db[e.to],e.to));
      }
    }
  }
  ll d[MAXN];
  d[n]=da[n]+db[n];
  for(int i=n-1;i>0;i--){
    d[i]=min(d[i+1],da[i]+db[i]);
  }
  for(int i=1;i<=n;i++){
    cout<<1000000000000000-d[i]<<endl;
  }
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl; 
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int N = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

inline ll read()
{
	ll x = 0; int f = 1, c = getchar(); 
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f; 
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48); 
	return x * f; 
}

int n; 
string s; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d", &n); 
	cin >> s; 
	
	stack <bool> st; 
	bool con = true; 
	string ans = ""; 
	REP(i, s.size())
	{
		if (s[i] == '(')
		{
			/*if (!con)
			{
				while (!st.empty())
				{
					ans += ')'; 
					st.pop(); 
				}
			}
			con = true; */
			ans += '('; 
			st.push(1); 
		}
		else
		{
			ans += ')'; 
			//con = false; 
			if (!st.empty()) st.pop(); 
		}
	}
	
	while (!st.empty())
	{
		ans += ')'; 
		st.pop(); 
	}
	//cout << ans << endl; 
	s = ans; 
	reverse(all(s)); 
	ans = ""; 
	con = true; 
	
	REP(i, s.size())
	{
		if (s[i] == ')')
		{
			/*if (!con)
			{
				while (!st.empty())
				{
					ans += '('; 
					st.pop(); 
				}
			}
			con = true; */
			ans += ')'; 
			st.push(1); 
		}
		else
		{
			ans += '('; 
			//con = false; 
			st.pop(); 
		}
	}
	
	while (!st.empty())
	{
		ans += '('; 
		st.pop(); 
	}
	
	reverse(all(ans)); 
	cout << ans << endl; 
	
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int main(){
  int N;
  cin >> N;
  int M = 0;
  int ans = 0;
  rep(i,N){
    int h;
    cin >> h;
    if(M <= h) ans++;
    M = max(M,h);
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 256
s = input()
ans = 'No'
if s.isupper() and len(s)==4:
  if (s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]) or \
     (s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]) or \
     (s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]):
    ans ='Yes'
print(ans)    

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

const int MOD = (int)1e9+7;

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

  for(int i=1;i<=s.size();i++){
    vector<int> alphabet(26,0);
    for(int j=0;j<=s.size()-i;j++){
      vector<bool> flag(26,false);
      for(int k=j;k<j+i;k++){
        if(!flag.at(s.at(k)-'a')){
          flag.at(s.at(k)-'a')=true;
          alphabet.at(s.at(k)-'a')++;
        }
      }
    }

    bool check=false;
    for(int j=0;j<26;j++){
      /*if(alphabet.at(j)>0){
        printf("%c=%d,",j+'a',alphabet.at(j));
      }*/
      if(alphabet.at(j)==s.size()-i+1)  check=true;
    }
    //cout << endl;
    if(check){
      cout << i-1 << endl;
      return 0;
    }
  }

  return 0;
}


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


public class Main {

	public static void main(String[] args) 
	{
		Scanner in = new Scanner(System.in);
		int n = Integer.parseInt(in.nextLine());
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		map.put("AC", 0);
		map.put("WA", 0);
		map.put("TLE", 0);
		map.put("RE", 0);
		for(int i = 0; i < n; i++)
		{
			String curr = in.nextLine();
			map.put(curr, map.get(curr) + 1);
		}
		
		System.out.println("AC x " + map.get("AC"));
		System.out.println("WA x " + map.get("WA"));
		System.out.println("TLE x " + map.get("TLE"));
		System.out.println("RE x " + map.get("RE"));
		

	}

}

Measured memory_bytes: 60448
#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 ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int minD = 0, d = 0, cnt = 0;
    REP(i, n) {
        if (s[i] == '(') {
            cnt++;
        } else {
            cnt--;
        }
        minD = min(minD, cnt);
    }
    REP(i, minD * (-1)) {
        cout << '(';
    }
    cout << s;
    REP(i, cnt - minD) {
        cout << ')';
    }
    cout << endl;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

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

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll N;cin>>N;
  map<ll,ll> yak;
  for(ll i=2; i*i<=N;i++){
    while(N%i==0){
      N/=i;
      yak[i]++;
    }
  }
  if(N!=1)yak[N]++;
  ll ans =0;
  for(ll k=1;k<=40;k++){
    for(auto x:yak){
    
      if(x.second *2>=k*k+k && x.second *2<(k+1)*(k+2)){
        ans +=k;
        
      }
    }
    
  }
  cout<< ans<<endl;
  
}


Measured memory_bytes: 3680
#include <iostream>

using namespace std;

int in[200][3], n, d[101], ans[200];

main(){
  cin >> n;
  for(int i=0;i<n;i++) for(int j=0;j<3;j++) cin >> in[i][j];
  for(int i=0;i<3;i++){
    for(int j=0;j<101;j++) d[j] = -1;
    for(int j=0;j<n;j++) d[in[j][i]] = d[in[j][i]] == -1 ? in[j][i] : 0;
    for(int j=0;j<n;j++) ans[j] += d[in[j][i]];
  }
  for(int i=0;i<n;i++) cout << ans[i] << endl;
}

Measured memory_bytes: 1164
/* - - - - - - - - - - - - - - -
	User : 		VanishD
	problem :
	Points : 	
- - - - - - - - - - - - - - - */
# include <bits/stdc++.h>
# define 	ll 		long long
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}
const int N = 200010;
int n, cnt, num[N];
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for (int i = 1; i <= n; i++){
		int x = read();
		if (x > n) cnt++;
			else num[x]++;
	}
	for (int i = 1; i <= n; i++){
		if (num[i] == 0) continue;
		if (num[i] < i) cnt += num[i];
			else cnt += num[i] - i;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
s = [input() for i in range(h)]
ans = "Yes"
for i in range(h-1):
    for j in range(w-1):
        if s[i][j] == "#" and s[i][j] != s[i][j+1] and s[i][j] != s[i+1][j]:
            if (j >= 1 and s[i][j] == "#" and s[i][j] == s[i][j-1]) or (i >= 1 and s[i][j] == "#" and s[i][j] == s[i-1][j]):
                continue
            else:
                ans = "No"
                print(ans)
                exit()
        else:
            continue
print(ans)

            
        

Measured memory_bytes: 3064
<?php
$array=[];
for($i=0;$i<4;$i++) {
  $array[] = trim(fgets(STDIN));
}
echo (($array[0]>$array[1])?$array[1]:$array[0]) + 
     (($array[2]>$array[3])?$array[3]:$array[2]);

Measured memory_bytes: 4604
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	int A, B;

	cin >> A >> B;

	cout << max(0, A - B*2) << endl;

	Never To return 0;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < 3; i++) {
    sum += n%10;
    n /= 10;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm> // sort,reverse,min,lower_bound
using namespace std;
#define df 0

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  int a; cin >>a;
  vector<int> v;
  for(int i=1;i<n;i++){
    int b; cin >>b;
    if(b==a+1) v.push_back(--a);
    a=b;
  }
  sort(v.begin(),v.end());
  if(df){
    for(int x: v){
      printf("%d\n",x);
    }
  }
  int s=0;
  for(int i=0;i<n;i++){
    int b; cin >>b;
    s+=b;
  }
  if(df)printf("%d\n",s);
  int j=0;
  if(v.size()>0)
    for(int i=0;i<n;i++){
      int c; cin >>c;
      if(i==v.at(j)){
	s+=c;
	j++;
	if(j==v.size())break;
      }
  }
  cout << s;
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <numeric>
using namespace std;


main()
{
    int n ; cin>>n;
    string s;
    set<string> ss;
    for(int i=0; i<n; ++i)


    {
        cin>>s;
        ss.emplace(s);
    }
    cout << ss.size() << "\n";
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int H, W, Ch, Cw, Dh, Dw;
V<string> S(1005);

const int INF = TEN(9);

int main() {
	cin >> H >> W >> Ch >> Cw >> Dh >> Dw;
	rep (i, H) cin >> S[i];

	Ch--, Cw--, Dw--, Dh--;

	VV<int> val(1005, V<int>(1005, INF));
	val[Ch][Cw] = 0;

	deque<P> Q;
	VV<bool> visited(1005, V<bool>(1005, false));
	Q.emplace_front(-1, -1);
	Q.emplace_front(Ch, Cw);
	int d = 0;
	while (Q.size() > 1) {
		
		auto [y, x] = Q.front();
		Q.pop_front();
		if (y == -1) {
			d++;
			Q.emplace_back(-1, -1);
			tie(y, x) = Q.front();
			Q.pop_front();
		}
		else {
			visited[y][x] = true;
		}
		rep2 (i, -2, 3) rep2 (j, -2, 3) {
			int ny = y + i;
			int nx = x + j;
			if ((!i && !j) || ny < 0 || ny >= H || nx < 0 || nx >= W || S[ny][nx] == '#' || visited[ny][nx]) {
				continue;
			}
			if (abs(i) + abs(j) <= 1) {
				chmin(val[ny][nx], d);
				Q.emplace_front(ny, nx);
			}
			else {
				chmin(val[ny][nx], d + 1);
				Q.emplace_back(ny, nx);
			}
		}
	}

	if (val[Dh][Dw] == INF) cout << -1 << endl;
	else cout << val[Dh][Dw] << endl;

	return 0;
}


Measured memory_bytes: 11880
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, [ $t:tt ]) => { { let len = read_value!($next, usize); (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() } }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,HashMap,BTreeMap,VecDeque};

// Functions

// Main
fn main(){
    input!{
        S: String,
    }
    println!("{}",if S.as_str() <= "2019/04/30" {"Heisei"}else{"TBD"});
}

Measured memory_bytes: 4352
N = int(input())
a = list(map(int,input().split()))

a.sort()


ans = 0
cnt = 0

for i in range(0,N):
    if a[i] <= cnt*2:
        ans += 1
        cnt += a[i]

    else:
        ans = 0
        cnt += a[i]
ans += 1

print(ans)


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0); 
	
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a.begin(), a.end());
	if(n % 2) {
		int med = a[n / 2];
		long long ans = 0;
		for(int i = 0; i < n; i++) {
			ans += abs(a[i] - med);
		}
		cout << ans << endl;
	} else {
		int med1 = a[n / 2], med2 = a[n / 2 - 1];
		long long ans1 = 0, ans2 = 0;
		for(int i = 0; i < n; i++) {
			ans1 += abs(a[i] - med1);
			ans2 += abs(a[i] - med2);
		}
		cout << min(ans1, ans2) << endl;
	}

	return 0;
}



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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	
	int n, k; cin >> n >> k;

	priority_queue <int, vector<int>, greater<int> > q;

	for(int i = 0; i < n; i++)
	{
		int x; cin >> x; q.push(x);
	}

	int sum = 0;

	for(int i = 0; i < k; i++)
	{
		sum += q.top();
		q.pop();
	}

	cout <<  sum << '\n';


	return 0;
}


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

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

typedef pair< long long, long long > P;
typedef pair< long long, P > PP;
typedef pair< P, P > PPP;

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

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

int n, a[1001], ans;

int main() {
	cin >> n;
	for (int i = 0;i < n;i++)cin >> a[i];
	for (int i = 0;i < n-1;i++) {
		if (a[i] == a[i + 1])ans++, a[i + 1] = 10000;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));

  $a = array_map('intval', explode(" ", trim(fgets(STDIN))));

  $l = 0;
  $r = count($a)-1;
  $L = $a[$l];
  $R = $a[$r];
  while(($r-$l)>1){
    if($L > $R){
      $r--;
      $R+=$a[$r];
    }else{
      $l++;
      $L+=$a[$l];
    }
  }
  echo abs($R-$L);


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

int main(void){

    int H,W,K;
    cin >> H >> W >> K;
    vector<string> c(H);
    for(int i=0;i<H;i++){
        cin >> c[i];
    }

    int ans = 0;
    for(int k=0;k<(1<<H);k++){
        bitset<6> bi(k); //行
        for(int t=0;t<(1<<W);t++){
            bitset<6> bj(t);    //列
            int cnt = 0;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(c[i][j]=='#' && !bi.test(i) && !bj.test(j)) cnt++;
                }
            }
            if(cnt==K) ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;
using ll = long long;
int main() {
    ll a, b;
    cin >> a >> b;
    if (a < 0) {
        if (b >= 0)
            cout << "Zero" << endl;
        else if (abs(abs(b) -abs(a))% 2 != 0)
            cout << "Positive" << endl;
        else
            cout << "Negative" << endl;
    } else
        cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 3128
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n; cin >>n;
  int a[n];
  for(int i=0; i<n; i++) cin >>a[i];
  sort(a,a+n);
  cout <<a[n/2]-a[n/2-1];
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);
  solve();
return 0;}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < n; i++)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, h;
    cin >> a >> b >> h;

    cout << h * (a+b) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (long long i = 0; i < m; i++)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
  string s;
  cin >> s;
  vector<int> vx, vy;
  bool f = true;
  int c = 0;
  REP(i, s.size()){
    if(f){
      if(s[i] == 'F') c++;
      else{
        f = false;
        vx.pb(c);
        c = 0;
      }
    }
    else{
      if(s[i] == 'F') c++;
      else{
        f = true;
        vy.pb(c);
        c = 0;
      }
    }
    if(i == (s.size()-1) && c != 0){
      if(f) vx.pb(c);
      else vy.pb(c);
    }
  }
  bitset<20001> x = 1, y = 1;
  x <<= 10000;
  y <<= 10000;
  if(s[0] == 'F') x <<= vx[0];
  REP(i, vx.size()){
    if(s[0] == 'F' && i == 0) continue;
    x = ((x << vx[i]) | (x >> vx[i]));
  }
  REP(i, vy.size()){
    y = ((y << vy[i]) | (y >> vy[i]));
  }
  int a, b;
  cin >> a >> b;
  if(x[10000+a] && y[10000+b]) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

typedef long long ll;
//vector<int>


using namespace std;

int main() {
    int n;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cnt=0;
    for(int i=0;i<n-1;i++){
        if (a.at(i)==i+1 && a.at(i+1)==i+2){
            swap(a.at(i),a.at(i+1));
            cnt++;
        }
    }
    for(int i=0;i<n-1;i++){
        if (a.at(i)==i+1 || a.at(i+1)==i+2){
            swap(a.at(i),a.at(i+1));
            cnt++;
        }
    }
    cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef pair<ll,ll>pl;


int main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL);
	ll a,b,c,d,e,t;
	cin>>a>>b>>c>>d>>e;
	t=(c-a)*60+(d-b);
	cout<<t-e;
	return 0;	
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
// const int N = ;
using ll = long long;
using ii = pair <int , int>;

int choose2(int n) {
	return (n * (n - 1)) / 2;
}

int main() {
	int n,m; scanf("%d%d" , &n , &m);
	printf("%d\n" , choose2(n) + choose2(m));
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = max(a, b) * 10 + min(a, b) + c;
  int e = max(b, c) * 10 + min(b, c) + a;
  int f = max(c, a) * 10 + min(c, a) + b;
  cout << max(d, max(e, f)) << endl;
  return 0;
}


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

int main() {
    int n;cin >> n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
}

Measured memory_bytes: 256
/*
*                                 Name : chaitanya
*
*                         Institute : ANITS,Visakhapatnam
*   "Don't regret anything you do, because in the end it makes you who you are."
*
*/
#include<cstdio>
#include<iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include<cstring>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#include<sstream>
#include <assert.h>
#define infy  1000000000
#define all(x) begin(x),end(x)
#define ll long long int
#define ff first
#define ss second
#define pb push_back
const ll m = 1000000007;
using namespace std;

map <int,int>mp;
vector < int > g[100010],t(100010);
bool vis[100010];

void dfs(int s)
{   
    vis[s] = true;
    mp[s] = 1;
    for (int i = 0; i < g[s].size(); ++i)
    {
        if( !vis[g[s][i]])
            dfs(g[s][i]);
    }
}

int main()
{  
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    {
        t[i] = i;
    }
    int c = 0;
    for (int i = 0; i < m; ++i)
    {
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    for (int i = 0; i < n; ++i)
    {
        if( mp[i] == 0)
        {
            c++;
            mp[i] = 1;
            dfs(i);
        }
    }
    cout << c-1 << "\n";
    return 0;
}


Measured memory_bytes: 15608
import collections

n = int(input())

l = []

for i in range(n):
    l.append(input())
c = collections.Counter(l)
cx = c.most_common()
nm = cx[0][1]
ans = []
ans.append(cx[0][0])
for i in range(1, len(cx)):
    if (nm == cx[i][1]):
        ans.append(cx[i][0])
    else:
        break

ansx = sorted(ans)
for i in range(len(ans)):
    print(ansx[i])

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

long long C[2001][2001] = {};
const long long M = 1e9 + 7;
int main() {
	for(int i = 0; i <= 2000; i++) {
		for(int j = 0; j <= i; j++) {
			if(j == 0) {
				C[i][j] = 1;
				continue;
			} else {
				C[i][j] = C[i-1][j-1] + C[i-1][j];
				C[i][j] %= M;
			}
		}
	}

	int N, K;
	cin >> N >> K;
	for(int i = 1; i <= K; i++) {
		long long a = C[N - K + 1][i];
		long long b = C[K - 1][i - 1];
		cout << (a * b) % M << endl;
	}
}


Measured memory_bytes: 30080
#include <stdio.h>
#include <stdlib.h>

#define N 8
#define ON 1
#define OFF 0
#define TRUE 1

int X[N], Y[N], sir[N][N], L[2*N-1], R[2*N-1];

void Output(){
  int i, j;

  for(i = 0 ; i < N ; i++){
    for(j = 0 ; j < N ; j++){
      if(sir[i][j] == TRUE){
        if(X[i] != j){
          return;
        }
      }
    }
  }

  for(i = 0 ; i < N ; i++) {
    for(j = 0 ; j < N ; j++) {
      if(X[i] == j){
        printf("Q");
      }
      else{
        printf(".");
      }
    }
    printf("\n");
  }
}

int Queen(int m){
  int n;

  if(m == N){
    Output();
    return 0;
  }

  for(n = 0 ; n < N ; n++){
    if(Y[n] == ON || L[m+n] == ON || R[m-n+N-1] == ON){
      continue;
    }

    X[m] = n;
    Y[n] = ON;
    L[m+n] = ON;
    R[m-n+N-1] = ON;

    Queen(m+1);

    X[m] = OFF;
    Y[n] = OFF;
    L[m+n] = OFF;
    R[m-n+N-1] = OFF;
  }

   return 0;
}



int main(){
  int i, j, k, r, c;

  for(i = 0 ; i < N ;  i++){
    X[i] = 0;
    Y[i] = 0;
  }

  for(i = 0 ; i < 2*N-1 ; i++){
    L[i] = 0;
    R[i] = 0;
  }

  for(i = 0 ; i < N ; i++){
    for(j = 0; j < N; j++){
      sir[i][j] = -1;
    }
  }

  scanf("%d", &k);
  for(i = 0 ; i < k ; i++){
    scanf("%d %d", &r, &c);
    sir[r][c] = TRUE;
  }
  Queen(0);

  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
const int d[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
struct node {
    int a[5005], len;
    void operator=(const node  ii) {
        memcpy(a, ii.a, sizeof(ii.a));
        len = ii.len;
    }
    node operator+(const int ii) {
        node res = *this;
        res.a[++res.len] = ii;
        return res;
    }
    bool operator<(const node ii) const {
        int i;
        if (len ^ ii.len)
            return len < ii.len;
        for (i = len; i; i--)
            if (a[i] ^ ii.a[i])
                return a[i] < ii.a[i];
        return false;
    }
};

bool c[10];
int n, m;
node f[10005];

void writeln(node ii) {
    int i;
    for (i = ii.len; i; i--)
        putchar(ii.a[i] | 48);
    putchar('\n');
}

int main() {

    int i, j, ii;

    scanf("%d %d", &n, &m);
    for (i = 1; i <= m; i++) {
        scanf("%d", &ii);
        c[ii] = true;
    }
    for (int i = 1; i <= n; i++) {
        for (j = 1; j <= 9; j++) {
            if (c[j] and i >= d[j] and (f[i - d[j]].len or i == d[j])) {
                f[i] = max(f[i], f[i - d[j]] + j);
            }
        }
    }
    writeln(f[n]);
    return 0;
}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    lint x;
    cin >> x;
    lint res = x / 500;
    res *= 1000;
    x %= 500;
    res += (x / 5) * 5;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    int x = N * 800;
    int y = (N / 15) * 200;

    std::cout << x - y << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
using namespace std;
typedef long long LL;
const LL MOD = 1e9+7;
LL gcd(LL a, LL b){ return b==0 ? a : gcd(b,a%b); }
pair<LL,LL> normalize(pair<LL,LL> u) //quadrants 1 and 2 always
{
    LL x = u.first, y = u.second;

    if(x==0 && y==0)
        return {0,0};
    if(x==0)
        return {0,1};
    else if(y==0)
        return {1,0};

    LL d = gcd(x,y);
    if(d < 0) d *= -1;

    x /= d;
    y /= d;
    if(y < 0)
    {
        x *= -1;
        y *= -1;
    }
    return {x,y};
}
pair<LL,LL> ortho(pair<LL,LL> u)
{
    return {-u.second,u.first};
}
LL mod_pow(LL base, LL exp)
{
    if(exp==0) return 1;
    if(exp&1) return (base*mod_pow(base,exp-1))%MOD;
    else return mod_pow((base*base)%MOD,exp>>1);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n; cin >> n;
    map<pair<LL,LL>,LL> slopes;
    LL total_losers = 0;
    for(int i = 0; i < n; i++)
    {
        LL x, y; cin >> x >> y;
        if(x==0 && y==0)
            total_losers++;
        else
        {
            slopes[normalize({x,y})]++;
            slopes[normalize(ortho({x,y}))]+=0;
        }
    }
    set<pair<LL,LL>> done;
    LL ans = 1;
    for(const auto& p : slopes)
    {
        pair<LL,LL> u = p.first;
        pair<LL,LL> v = normalize(ortho(u));
        //cout<<u.first<<","<<u.second<<" and "<<v.first<<","<<v.second<<endl;
        if(!done.count(u) && !done.count(v))
        {
            //cout<<slopes[u]<<" and "<<slopes[v]<<endl;
            ans = (ans*(mod_pow(2,slopes[u])+mod_pow(2,slopes[v])-1))%MOD;
            done.insert(u);
            done.insert(v);
        }
    }
    ans = ((ans+total_losers-1)%MOD+MOD)%MOD;
    cout<<ans<<'\n';

    cout<<flush;
    return 0;
}

Measured memory_bytes: 53508