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

int main()
{
	int n;
	while (cin >> n) {
		if (n == 0)
			break;

		int god_in = -1;
		string now_date = "";

		map<int, int> log;
		vector<int> ans(1000, 0); 
		for (int i = 0; i < n; ++i) {
			string date, time, e, pp;
			cin >> date >> time >> e >> pp;

			int p = atoi(pp.c_str());
			int min = atoi(time.substr(0, 2).c_str()) * 60 + atoi(time.substr(3).c_str());

			if (now_date != date) {
				log.clear();
				god_in = -1;
				now_date = date;
			}

			// god
			if (p == 0) {
				if (e == "I") {
					god_in = min;
				} else {
					// add
					for (map<int, int>::iterator it = log.begin(); it != log.end(); ++it)
						ans[it->first] += min - max(god_in, it->second);
					god_in = -1;
				}
			} else {
				// other
				if (e == "I") {
					log[p] = min;
				} else {
					if (god_in != -1)
						ans[p] += min - max(log[p], god_in);
					log.erase(p);
				}
			}
		}

		cout << *max_element(ans.begin(), ans.end()) << endl;
	}
	return 0;
}

Measured memory_bytes: 948
import java.util.*;
 
public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);    
    String S = sc.next();
    sc.close();

    String[] s = S.split("");

    int p = 0;

    for (int i = 0; i < s.length; i++) {
      if (s[i].equals("p")) {
        p++;
      }
    }

    System.out.println(s.length / 2 - p);

  }

}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::vector<std::pair<int, int>> ps;

  std::cin >> N;
  rep(i, N) {
    int A;
    std::cin >> A;
    ps.push_back(std::make_pair(A, i + 1));
  }
  std::sort(ps.begin(), ps.end());

  rep(i, N) {
    std::cout << ps[i].second << ' ';
  }
}


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

using namespace std;

int main(void)
{
    u_int a, b;
    char op;
    while (true) {
        int res;
        cin >> a >> op >> b;
        if (op == '+')
            res = a + b;
        else if (op == '-')
            res = a - b;
        else if (op == '*')
            res = a * b;
        else if (op == '/')
            res = a / b;
        else
            break;
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1156
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

n = int(input())
a = list(map(int, input().split()))

maxVal = a[0]

ans = [0]*n

for i in range(1,n):
    if maxVal > a[i]:
        ans[i] = maxVal - a[i]
    elif maxVal < a[i]:
        maxVal = a[i]

print(sum(ans))





Measured memory_bytes: 32068
#include <iostream>
int main() {
  int n, y, a=-1, b=-1, c=-1;
  std::cin >> n >> y;
  y /= 1000;
  for(int i=0; i<n+1; ++i) {
    for(int j=0; j<n+1; ++j) {
      (4*j+9*i-y+n?0:n-i-j>=0?a=i,b=j,c=n-i-j:0);
    }
  }
  std::cout << a << ' ' << b << ' ' << c << "\n";
}
  

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
N = readline()
flag = false
for n in N
    if n == '7'
        flag = true
    end
end

if flag 
    println("Yes")
else
    println("No")
end
end

main()

Measured memory_bytes: 153656
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    string S; cin >> S;
    vector<ll> cnt(2019, 0);
    ll sum = 0;
    ll d = 1;
    ll ans = 0;

    cnt[0]++;

    for (ll i = S.length(); i > 0; i--){
        sum += (S[i-1] - '0')*d;
        sum %= 2019;
        d *= 10;
        d %= 2019;
        cnt[sum]++;
    }

    for (ll i = 0; i < cnt.size(); i++){
        ans += cnt[i]*(cnt[i]-1) / 2;
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3688
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
	#print(name)
	sys.stdin = open(name)

a,b,c,d = map(int,input().split())

def chk(s,e,d):
	return(e//d-s//d)

#最大公約数
import fractions
e = c*d//fractions.gcd(c,d)

print(b-(a-1) -chk(a-1,b,c) -chk(a-1,b,d) +chk(a-1,b,e))
#print(chk(a-1,b,c))
#print(chk(a-1,b,d))
#print(chk(a-1,b,e))

Measured memory_bytes: 63980
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b,flag = 1;

    cin >> a >> b;

    if(a > b){
        if(b == 1){
            cout << "Bob" << endl;
            flag = 0;
        }
        if(flag){
            cout << "Alice" << endl;
        }
    }
    else if (b > a){
        if(a == 1){
            cout << "Alice" << endl;
            flag = 0;
        }
        if(flag){
            cout << "Bob" << endl;
        }
    }
    else {
        cout << "Draw" << endl;
    }
    
    return 0;
}




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

#define int long long
#define cint cpp_int
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int count(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    int n;
    string s;
    cin>>n>>s;

    Vi a(26);
    REP(i,0,n){
        a[s[i]-'a']++;
    }

    int ans=1;
    REP(i,0,26){
        ans = (ans*(a[i]+1))%MOD;
    }
    cout<<ans-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <typename T>
struct edge {
    int from, to;
    T cost;

    edge(int to, T cost) : from(-1), to(to), cost(cost) {}
    edge(int from, int to, T cost) : from(from), to(to), cost(cost) {}

    explicit operator int() const {return to;}
};


int main() {
    int n;
    cin >> n;
    vector<vector<edge<int>>> G(n);
    for (int i = 0; i < n-1; ++i) {
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w);
        u--; v--;
        G[u].emplace_back(v, w&1);
        G[v].emplace_back(u, w&1);
    }
    deque<int> Q;
    stack<int> s;
    int cnt = 0;
    vector<int> visited(n, 0), num(n);
    s.emplace(0);
    vector<int> dp(n);
    while(!s.empty()){
        int a = s.top(); s.pop();
        visited[a]++;
        num[a] = cnt++;
        Q.emplace_front(a);
        for (auto &&i : G[a]) {
            if(!visited[i.to]) {
                dp[i.to] = dp[a]^i.cost;
                s.emplace(i.to);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%d\n", dp[i]);
    }
    return 0;
}

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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 100005

int n , s;
int d[MAXX];
int a[MAXX];

int main()
{
    _FastIO;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> d[i];
        a[d[i]]++;
    }
    int ans = 0;
    for(int i = 1; i < MAXX; i++){
        s += a[i];
        if(s == (n / 2)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)

int main() {
	int n, s, t;
	int r[] = {0,1,2,3,4,5,6,7,8,9,5,4,3,2,1};
	cin >> n;
	rep(i,n) {
		cin >> s >> t;
		if(s<=5&&t<=5&&s>t) {
			for(int i=s;i>t;--i) cout << i << " ";
			cout << t << endl;
		} else {
			rep(i,15) {
				if(r[i]==s) {
					rep(j,15) {
						if(r[(i+j)%15]==t) break;
						cout << r[(i+j)%15] << " ";
					}
					cout << t << endl;
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 200005

using namespace std;


int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int n = s.length();
	int m = t.length();
	int dp[n+1][m+1];
	mem(dp,0);
	for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = max({1+dp[i-1][j-1], dp[i-1][j], dp[i][j-1]});
            }
            else{
                dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
            }
        }
	}
	string ans = "";
	int i=n,j=m;
	while(i && j){
        if(dp[i][j-1]==dp[i][j]){
            j--;
        }
        else if(dp[i-1][j]==dp[i][j]){
            i--;
        }
        else{
            ans = s[i-1] + ans;
            i--;
            j--;
        }
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 35456
#include<iostream>
using namespace std;
int main(){
	int n,i,k;
	cin >> n;
	char s;
	k=0;
	for(i=0;i<n;i++){
        cin >> s;
        if(s=='Y')
            k=1;
	}
	if(k==0)
        cout << "Three" << endl;
    else
        cout << "Four" << endl;
	return 0;
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    std::deque<char> A;
    string S;
    int Q;
    cin >> S >> Q;
    for(int i=0; i<S.length(); i++){
        A.push_back(S[i]);
    }
    bool b = 1;
    for(int i=0; i<Q; i++){
        int T;
        cin >> T;
        if(T==1){
            b = !b;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if(b){
                if(F==1){
                    A.push_front(C);
                } else {
                    A.push_back(C);
                }
            } else {
                if(F==1){
                    A.push_back(C);
                } else {
                    A.push_front(C);
                }
            }
        }
    }
    if(!b){
        while(A.size() > 0){
            cout << A.back();
            A.pop_back();
        }
    } else {
        while(A.size() > 0){
            cout << A.front();
            A.pop_front();
        }
    }
}

Measured memory_bytes: 896
/*author : Yashvardhan
Wednesday, January 30, 2019
9:46 PM
*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define endl '\n'

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("O2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

const int N = 3005;
int n;
vector<double> vals;
double dp[N][N];

double solve(int i,int j){
	if(dp[i][j] != -1) return dp[i][j];
	if(i == 1){
		if(j == 1) return dp[i][j] = vals[i];
		if(j == 0) return dp[i][j] = 1 - vals[i];
	}
	if(i == j) return dp[i][j] = solve(i-1,j-1)*(vals[i]);
	return dp[i][j] = solve(i-1,j)*(1-vals[i]) + solve(i-1,j-1)*(vals[i]);
}

int pow(int a, int b, int m)
{
	int ans = 1;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	
	cin>>n;
	vals.pb(-1);
	for(int i = 0; i < n ; i++){
		double x;
		cin>>x;
		vals.pb(x);
	}
	
	for(int i = 0; i <=n ; i++){
		for(int j = 0; j<=n; j++){
			dp[i][j] = -1;
		}

	}

	for(int i = 0;i<=n;i++){
		solve(n,i);
	}
	// dp[1][1] = vals[1];
	// dp[1][0] = 1 - vals[1];
	// dp[2][0] = (1 - vals[2])*dp[1][0];
	// dp[2][1] = dp[1][1]*(1 - vals[2]) + dp[1][0]*(vals[2]);
	int mini = (n/2)+1;
	double ans = 0;
	for(int i = mini; i <= n  ; i++){
		ans += dp[n][i];
	}
	cout<<setprecision(20);
	cout<<ans<<endl;

	t2 = clock();
	cerr<<endl<<t2-t1<<endl;
	
	return 0;
}



Measured memory_bytes: 70912
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 3*1e5 , limit = 9*1e18 , MOD=1e9+7;
#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
    boost;
    
    int t;cin>>t;
    if(t>=30){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
}

Measured memory_bytes: 3644
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

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

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(1, 1E8); \
                 auto rnd = bind(__dis, __gen)

const int INF = 1E18;
const int mod = 1E9 + 7;

int32_t main() {
    fastIO();
    
    int n;
    cin >> n;
    
         if (n < 1200) cout << "ABC\n";
    else if (n < 2800) cout << "ARC\n";
    else               cout << "AGC\n";
    
    return 0;
}

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

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const int inf = 1e9 + 7;
const int N = 2e5 + 5;

typedef long long ll;

int n, a[N], cnt;
pair <int, int> t[N * 4][2];
pair <int, int> v[N];
vector <int> g[N];
set < pair <int, int> > st;

void build(int v = 1, int tl = 1, int tr = n)
{
      if(tl == tr)
      {
            t[v][tl % 2] = mk(a[tl], tl);
            t[v][(tl % 2) ^ 1] = mk(inf, 0);
      }
      else
      {
            int tm = (tl + tr) >> 1;
            build(v << 1, tl, tm);
            build((v << 1) | 1, tm + 1, tr);
            t[v][0] = min(t[v << 1][0], t[(v << 1) | 1][0]);
            t[v][1] = min(t[v << 1][1], t[(v << 1) | 1][1]);
      }
}

pair <int, int> get(int l, int r, int type, int v = 1, int tl = 1, int tr = n)
{
      if(l > tr || tl > r) return mk(inf, 1);
      if(l <= tl && tr <= r) return t[v][type];
      int tm = (tl + tr) >> 1;
      return min(get(l, r, type, v << 1, tl, tm),
                        get(l, r, type, (v << 1) | 1, tm + 1, tr));
}

void dv(int l, int r, int p = 0)
{
      if(l >= r) return ;
      int c = ++ cnt;
      if(l + 1 == r)
      {
            if(p != 0) g[p].pb(c);
            else st.insert(mk(a[l], c));
            v[c] = mk(l, r);
            return ;
      }
      int aa = get(l, r - 1, l % 2).sc;
      int bb = get(aa + 1, r, (l % 2) ^ 1).sc;
      if(p != 0) g[p].pb(c);
      else st.insert(mk(a[aa], c));
      v[c] = mk(aa, bb);
      dv(l, aa - 1, p);
      dv(aa + 1, bb - 1, c);
      dv(bb + 1, r, p);
}

int main()
{
      cin >> n;

      for(int i = 1; i <= n; i ++)
            cin >> a[i];

      build();
      dv(1, n);

      while(!st.empty())
      {
            pair <int, int> vv = *st.begin();
            st.erase(st.begin());
            cout << vv.fr << " " << a[v[vv.sc].sc] << " ";
            for(int to : g[vv.sc])
                  st.insert(mk(a[v[to].fr], to));
      }
}


Measured memory_bytes: 32768
#include <iostream>
#include <algorithm>
using namespace std;
 
int main(void){
    int n;
    cin >> n;
    long long int num[n];
    int count2 = 0;
    int count4 = 0;
    int kisuu = 0;
    for(int i = 0; i < n; i++){
        cin >> num[i];
        if(num[i]%4==0)
            count4++;
        if(num[i]%2==0 && num[i]%4!=0)
            count2++;
        if(num[i]%2!=0)
            kisuu++;
    }
    if(count4 >= n/2 || (count4+count2)==n || count4>=kisuu)
        cout << "Yes" << endl;    
    else
        cout << "No" << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	int n, T;
	cin >> n >> T;
	int min=1010;
	for(int i=0; i<n; i++){
		int c, t;
		cin >> c >> t;
		if(t>T)
			continue;
		if(c<min)
			min=c;
	}
	if(min!=1010)
		cout << min << endl;
	else
		cout << "TLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(){
	ll L,R;
	cin >> L >> R;
	ll ans=2020;
	for(ll i=L; i<min(R,L+2019); i++){
		for(ll j=i+1; j<=min(R,L+2019); j++){
			ll l,r,m;
			l=i%2019;
			r=j%2019;
			m=(l*r)%2019;
			if(ans>m) ans=m;
		}
	}

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 55
#define ll long long
#define pb push_back
using namespace std;
inline void in(int &x) 
{
	x=0;
	char c=getchar();
	while(c<'0'||c>'9')c=getchar();
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
int n,m,fa[N],q[N],bk,state[N];
vector<int> v[N];
ll dp[N];
inline bool need_add(int i)
{
	int cnt=0;
	while(i)i-=i&-i,++cnt;
	return !(cnt&1);
}
int main()
{
	in(n);
	for(int i=1;i<n;++i)
	{
		int x,y;
		in(x);in(y);
		v[x].pb(y);
		v[y].pb(x);
	}
	q[bk++]=1;
	for(int i=0;i<n;++i)
	{
		int from=q[i];
		for(int j=0;j<v[from].size();++j)
		{
			int to=v[from][j];
			if(to==fa[from])continue;
			fa[to]=from;
			q[bk++]=to;
		}
	}
	in(m);
	for(int i=0;i<m;++i)
	{
		int x,y;
		in(x);in(y);
		state[x]^=1<<i;
		state[y]^=1<<i;
	}
	for(int i=n-1;i>=0;--i)
	{
		int from=q[i];
		for(int j=0;j<v[from].size();++j)
		{
			int to=v[from][j];
			if(to==fa[from])continue;
			state[from]^=state[to];
		}
	}
	ll ans=0;
	for(int mask=0;mask<(1<<m);++mask)
	{
		for(int i=n-1;i>=0;--i)
		{
			int from=q[i];
			dp[from]=1;
			for(int j=0;j<v[from].size();++j)
			{
				int to=v[from][j];
				if(to==fa[from])continue;
				if(mask&state[to])dp[from]*=dp[to];
				else dp[from]*=dp[to]<<1;
			}
		}
		if(need_add(mask))ans+=dp[1];
		else ans-=dp[1];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int K, num;
string str, ans;

vector<char> inc;


void dfs(string s) {
	for (int i = 0; num < K && i < inc.size(); i++) {
		if (str.find(s + inc[i]) != -1) {
			num++;
			if (num == K) {
				ans = s + inc[i];
			}
			else {
				dfs(s + inc[i]);
			}
		}
	}
}


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

	num = 0;
	for (int i = 0; i < str.length(); i++) {
		inc.push_back(str[i]);
	}

	sort(inc.begin(), inc.end());
	inc.erase(unique(inc.begin(), inc.end()), inc.end());

	dfs("");

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
/**
 * 
 */
//package AtCoder;
import java.util.*;
/**
 * @author Shivansh Singh
 *
 */
public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n,i;
		n=sc.nextInt();
		int []arr=new int[n];
		for (i=0;i<n;i++)
			arr[i]=sc.nextInt();
		int []dp=new int[n+1];
		dp[0]=dp[1]=0;
		dp[2]=(int)Math.abs(arr[1]-arr[0]);
		for (i=3;i<=n;i++)
			dp[i]=(int)Math.min(dp[i-1]+Math.abs(arr[i-1]-arr[i-2]),dp[i-2]+Math.abs(arr[i-1]-arr[i-3]));
		System.out.println(dp[n]);
		sc.close();
	}

}


Measured memory_bytes: 59632
import sys
import math
sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N,X,M = MI()


if M == 1:
    print(0)
    exit()

flag = [-1]*M
Z = [X]
flag[X] = 1
r = X
for i in range(2,M+2):
    r = r ** 2
    r %= M
    if flag[r] != -1:
        a,b = flag[r],i
        break
    else:
        flag[r] = i
        Z.append(r)

B = [0]*(len(Z))
for i in range(a-1):
    B[i] = 1
n = N-a+1
q = n//(b-a)
r = n % (b-a)

for i in range(a-1,a+r-1):
    B[i] = q+1
for i in range(a+r-1,b-1):
    B[i] = q

ans = 0
for i in range(len(Z)):
    ans += B[i]*Z[i]


print(ans)


Measured memory_bytes: 71800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <random>
#include <cassert>
#include <numeric>
#define ll long long int
#define LL unsigned long long
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
using namespace std;

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;



int main() {
    int n, sum = 0; cin >> n;
    vector<int> t(n);
    rep(i,n) {
        cin >> t[i];
        sum += t[i];
    }
    int m; cin >> m;
    rep(i,m){
        int p,x; cin >> p >> x;
        p--;
        cout << sum - t[p] + x << endl;
    }
}


Measured memory_bytes: 3620
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
	int h,w;
	int n[26];
	for(int i=0;i<26;i++) n[i] = 0;
	scanf("%d %d",&h,&w);
	for(int i=0;i<h;i++){
		char s[101];
		scanf("%s",s);
		for(int j=0;j<strlen(s);j++) n[s[j]-'a']++;
	}

	sort(n,n+26);
	//for(int i=0;i<26;i++) printf("%d ",n[i]);

	for(int i=0;i<(w+1)/2;i++){
		for(int j=0;j<(h+1)/2;j++){
			int kosu = 4;
			if(i==w/2 && w%2==1) kosu /= 2;
			if(j==h/2 && h%2==1) kosu /= 2;
			bool found = false;
			for(int k=0;k<26&&(!found);k++){
				if(n[k]>=kosu){
					n[k] -= kosu;
					found = true;
				}
			}
			if(!found){
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");

	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <cstdlib>
#include <map>
#include <queue>
#include <algorithm>
#include <stack>
#include <functional>
#define rep(i,j,n) for(i=j;i<(n);i++)
#define rrep(i,j,n) for(i=j;i>(n);i--)
typedef long long int lli;
#define N 1000000007

using namespace std;

int main(){
    lli n,m,x,y,ans=0;
    vector<lli> pos,vec;
    lli i,j;
    pos.push_back(1);
    cin>>n>>m;
    rep(i,0,n){
        vec.push_back(1);
        pos.push_back(0);
    }
    pos[0]=true;
    rep(i,0,m){
        cin>>x>>y;
        vec[x-1]--;
        vec[y-1]++;
        if(pos[x-1]==true){
            pos[y-1]=true;
            if(vec[x-1]==0){
                pos[x-1]=false;
            }
        }
    }
    rep(i,0,pos.size()){
        if(pos[i]==true){
            ans++;
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 2036
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	int k;
	cin>>n>>k;
	int p[n];
	for(int i=0;i<n;i++)
	{
		cin>>p[i];
	}
	sort(p,p+n);
	int sum=0;
	for(int i=0;i<k;i++)
	{
		sum =sum +p[i];

	}
	cout<<sum<<endl;
}

Measured memory_bytes: 3660
def ary(r, c, val=False): return [[val for _ in range(c)] for _ in range(r)]
def nl(): return list(map(int, input().split()))

n, m, q = nl()
M = ary(n + 1, n + 1, 0)
for _ in range(m):
    l, r = nl()
    M[l][r] += 1

for L in range(1, n + 1):
    for R in range(1, n + 1):
        M[L][R] += M[L - 1][R]
        M[L][R] += M[L][R - 1]
        M[L][R] -= M[L - 1][R - 1]

for _ in range(q):
    p, q = map(int, input().split())
    ans = M[q][q] - M[p - 1][q] - M[q][p - 1] + M[p - 1][p - 1]
    print(ans)

Measured memory_bytes: 13600
from sys import stdin
from itertools import repeat
def main():
    n = int(stdin.readline())
    dat = map(int, stdin.read().split(), repeat(10, 2 * n))
    p = []
    s = 0
    for i in xrange(n):
        if dat[i*2+1] < dat[i*2]:
            p.append(dat[i*2+1])
        s += dat[i*2]
    if not p:
        print 0
        return
    p.sort()
    print s - p[0]
main()


Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 998244353;
const double pi = 3.141592653589793;

ll mypow(ll a, ll b)
{
	ll r = 1ll;
	while(b != 0){
		if(b&1) r = r * a % MOD;
		a = a * a % MOD;
		b /= 2;
	}
	return r;
}

vector<ll> fac;
vector<ll> ifac;

void factorial_init(ll n)
{
	fac.resize(n+1);
	ifac.resize(n+1);
	fac[0] = 1;
	ifac[0] = 1;
	REP(i,n) {
		fac[i+1] = fac[i] * (i + 1) % MOD;
		ifac[i+1] = ifac[i] * mypow(i + 1, MOD - 2) % MOD;
	}
}

ll Combination(ll a, ll b)
{
	if(a == 0 && b == 0) return 1;
	if(a < b || a < 0) return 0;
	ll r = ifac[a-b] * ifac[b] % MOD;
	return r * fac[a] % MOD;
}

int main()
{
	int n, m, k;
	ll ans = 0ll;
	cin>>n>>m>>k;

	factorial_init(n+1);

	REP(i,k+1) {
		ll tmp;
		tmp = (mypow(m-1, n-i-1) * m) % MOD;
		tmp *= Combination(n-1,i);
		ans += tmp;
		ans %= MOD;
		//cout<<i<<" "<<Combination(n-1,i)<<endl;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6360
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include<algorithm>
#include <functional>
#include <queue>
using namespace std;

void func_D() {
	
	int res = 0;
	int n, m;
	cin >> n >> m;
	vector<vector<int>> jobs(m+1);

	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		if (a > m)
			continue;
		jobs[a].push_back(b);
	}
	priority_queue<int> can;

	for (int i = 0; i <= m; i++) {
		for (int b : jobs[i]) {
			can.push(b);
		}
		if (!can.empty()) {
			res += can.top();
			can.pop();
		}
	}
	cout << res << endl;
	


	
}

int main()
{
	func_D();
	return 0;
}

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

int X[4]={0,1,0,-1};
int Y[4]={-1,0,1,0};

int n,h,w,m,a,b,muki;
char Town[40][40];
string s;

bool in(int y,int x){
  if(y<0 || x<0 || h<=y || w<=x)return false;
  return true;
}

int modify(char c){
  if(c=='U')return 0;
  if(c=='R')return 1;
  if(c=='D')return 2;
  return 3;
}

char modify2(char c){
  if(c=='U')return '^';
  if(c=='R')return '>';
  if(c=='D')return 'v';
  return '<';
} 
int main()
{

  cin>>n;
  for(int k=0;k<n;k++){

    cin>>h>>w;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>Town[i][j];
	if(Town[i][j]=='^'||Town[i][j]=='v'||Town[i][j]=='<'||Town[i][j]=='>'){
	  a=i;b=j;
	  if(Town[i][j]=='^')muki=0;
	  if(Town[i][j]=='>')muki=1;
	  if(Town[i][j]=='v')muki=2;
	  if(Town[i][j]=='<')muki=3;
	}
      }
    }
    cin>>m>>s;

    for(int i=0;i<s.length();i++){
      if(s[i]=='S'){
	int c=a+Y[muki],d=b+X[muki];
	while(1){
	  if(!in(c,d))break;
	  if(Town[c][d]=='#')break;
	  if(Town[c][d]=='*'){
	    Town[c][d]='.';
	    break;
	  }
	  c+=Y[muki];
	  d+=X[muki];
	}
      }
      else {
	muki=modify(s[i]);
	if(Town[a+Y[muki]][b+X[muki]]=='.' && in(a+Y[muki],b+X[muki])){
	  Town[a][b]='.';
	  a+=Y[muki];
	  b+=X[muki];
	}
	Town[a][b]=modify2(s[i]);
      }
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cout<<Town[i][j];
      cout<<endl;
    }
    if(k!=n-1)cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
#include<complex>
using namespace std;

typedef long long ll;

#define MOD 1000000007
#define PI 3.1415926535897932384626


class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double angA = 2.0*PI*(h*60+m)/(720+0.0);
  double angB = 2.0*PI*m/(60+0.0);
  double d;
  d = sqrt(pow(a*cos(angA)-b*cos(angB),2)+pow(a*sin(angA)-b*sin(angB),2));
  cout << setprecision(10) << d << endl;
  return 0;
}


Measured memory_bytes: 4164
def Solve(n):
    k = 10
    ans = 0
    while True:
        t = N // k
        if t == 0:
            break
        ans += t
        k *= 5
    return ans

N = int(input())

if N % 2 == 0:
    print(Solve(N))
else:
    print(0)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Day of Takahashi
            var line = ReadLine();
            int a = line[0];
            int b = line[1];

            if (a <= b)
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(a - 1);
            }            
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(ll i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(ll i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
ll dp[100100];
ll n,m;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>n>>m;
	forn(i,1,m)
	{
		dp[i]=quickpower(m/i,n)%mod;
	}
	fore(i,m,1)
		for(ll j=i+i;j<=m;j+=i)
			dp[i]=(dp[i]-dp[j]+mod)%mod;
	ll ans=0;
	forn(i,1,m)ans=(ans+i*dp[i])%mod;
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 4412
h, w = map(int, input().split())

li = [".." + "." * w]
for i in range(h):
  li.append("." + input() + ".")
li.append(".." + "." * w)

for i in range(1, h+1):
  ans = ""
  for j in range(1, w+1):
    if li[i][j] =="#":
      ans+="#"
    else:
      count = 0
      for a in [-1, 0, 1]:
        for b in [-1, 0, 1]:
          if li[i+a][j+b] == "#":
            count += 1
      ans += str(count)
  print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr ll mod = 1e9+7;
int main(){ 
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;
  ll res = 0;
  int s = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      if (s1[i] == s2[i]) {
        res += 3;
        s = 0;
      } else {
        res += 6;
        s = 1;
      }
    } else {
      if (s1[i] == s2[i]) {
        if (s) {
          s = 0;
        } else {
          (res *= 2) %= mod;
          s = 0;
        }
      } else {
        if (s && s1[i] != s1[i-1]) {
          (res *= 3) %= mod;
          s = 1;
        } else if(s == 0){
          (res *= 2) %= mod;
          s = 1;
        }
      }
    }
  }
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 256
s = input()
ans = 'Yes'
if len(s) % 2 == 1:
    ans = 'No'
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] != 'h':
            ans = 'No'
    else:
        if s[i] != 'i':
            ans = 'No'
print(ans)

Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <set>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
typedef long long ll;
int main()
{
   ll n,m,ans;
   cin>>n>>m;
   if(2*n>=m) ans=m/2;
   else{
     m=m-n*2;
     ans=n+m/4;
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
pS = [input().split()[:2] for _ in range(m)]

AC = [0]*n
WA = [0]*n

for p, S in pS:
    p = int(p)
    if AC[p-1] == 0:
        if S == 'AC':
            AC[p-1] = 1
        else:
            WA[p-1] += 1

for i in range(n):
    if WA[i] > 0 and AC[i] == 0:
        WA[i] = 0
print(sum(AC), sum(WA))

Measured memory_bytes: 25876
import numpy as np

N=int(input())
X=np.array(input().split(),dtype=np.int32)

ave_point=np.average(X)

can_point=[int(ave_point),int(ave_point)+1]

s1=0
s2=0
for i in range(N):
    s1+=pow((X[i]-can_point[0]),2)
    s2+=pow((X[i]-can_point[1]),2)

if(s1>s2):
    print(s2)
else:
    print(s1)


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

#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384


int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} 
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}    //最大公約数
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}     //最小公倍数
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} //コンビネーション
int nHr(int a,int b){return nCr(a+b-1,b);}       // 重複組み合わせ
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}  //階乗
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} // a~bまでの階乗
int dsum(int x){int r=0;while(x){r+=(x%10);x/=10;}return r;}   //数字の各位の和
int dsumb(int x,int b){int r=0;while(x){r+=(x%b);x/=b;}return r;}  // b進数の各位の和？
int sankaku(int x){return ((1+x)*x)/2;} //三角数 xまでの和

//以下long long ver
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llnHr(long long a,long long b){return llnCr(a+b-1,b);}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long lldsum(long long x){long long r=0;while(x){r+=(x%10);x/=10;}return r;}
long long lldsumb(long long x,long long b){long long r=0;while(x){r+=(x%b);x/=b;}return r;}
long long llsankaku(long long x){return ((1+x)*x)/2;}

//double
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}


typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) ; for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

 
/*CODE START HERE*/
int main() {
  int64_t a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  
  forn (i,40){
    if (a%2 == 1 || b%2 == 1 || c%2 == 1){
      cout << count << endl;
      return 0;
    }
    int na = (b+c)/2;
    int nb = (a+c)/2;
    int nc = (a+b)/2;
    count ++ ;
    a = na;
    b = nb;
    c = nc;
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int L[10], v1, v2, sum;
int main() {
  while (~scanf("%d", &L[0])) {
    sum = L[0];
    for (int i = 1; i < 10; i++) {
      scanf(",%d", &L[i]);
      sum += L[i];
    }
    scanf(",%d,%d", &v1, &v2);
    double p = (double)v1 * sum / (v1 + v2);
    double d = 0.0;
    for (int i = 0; i < 10; i++) {
      d += L[i];
      if (d >= p) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
}


Measured memory_bytes: 3108
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define SIZE(x)     static_cast<i64>(x.size())
#define rep(i,n)    for (i64 i = 0, i ## _limit = (n); i < i ## _limit; ++i)
#define reps(i,s,t) for (i64 i = (s), i ## _limit = (t); i <= i ## _limit; ++i)
#define repr(i,s,t) for (i64 i = (s), i ## _limit = (t); i >= i ## _limit; --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a && (a=b, true);}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a && (a=b, true);}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template<class Itr>
ostream& printContainer(Itr begin, Itr end, const string &separator = " ", ostream &os = cout) {
    const auto rbegin = std::prev(end);
    for (; begin != rbegin; ++begin) os << *begin << separator;
    os << *rbegin;
    return os;
}

ostream& operator<< (ostream &os, ostream&) {
    return os;
}

template <class T>
void _trace(const char *s, T&& x) {
    clog << '{';
    while(*s != '\0') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail) {
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    i64 N, A, B;
    cin >> N >> A >> B;

    vector<i64> hp(N);
    rep(i, N) {
        cin >> hp[i];
    }

    const auto allDie = [&](i64 cnt) {
        const i64 diffAB = A - B;
        i64 needCnt = 0;
        for(i64 e : hp) {
            e -= B * cnt;
            chmax(e, 0);
            needCnt += (e + diffAB - 1) / diffAB;
        }
        return (needCnt <= cnt);
    };

    i64 ng = 0;
    i64 ok = int(1e9);

    while(ok - ng > 1) {
        const i64 mid = (ok + ng) / 2;
        if (allDie(mid)) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL <<60;
typedef long long ll;
using namespace std;

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

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

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

int main(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000LL
using namespace std;

vector<ll> primes;
ll computePrime() {
    vector<bool> isPrime(MAX + 1, 1);
    isPrime[0] = 0, isPrime[1] = 0;

    primes.push_back(2);
    for (ll i = 4; i <= MAX; i+=2) {
        isPrime[i] = 0;
    }

    for (ll i = 3; i <= MAX; i+=2) {
        if(isPrime[i]) {
            primes.push_back(i);
            for (ll j = i*i; j <= MAX; j+=i) {
                isPrime[j] = 0;
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    computePrime();
    ll N;
    cin >> N;
    auto it = lower_bound(primes.begin(), primes.end(), N);
    cout << *it;
    return 0;
}

Measured memory_bytes: 1528
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 100010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int n, q, ans;

int a[MAXN];

signed main() {
	n = read();
	for (rr int i = 1; i <= n; i++) {
		int x = read(); 
		ans += x;
		a[x]++;
	}
	q = read();
	for (rr int i = 1; i <= q; i++) {
		int b = read(), c = read();
		ans += a[b] * (c - b);
		a[c] += a[b], a[b] = 0;
		cout << ans << "\n";
	}
	return 0;
}

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

typedef pair<int,int> pii;
#define fi first
#define se second

int main() {
	int N;
	while(cin >> N, N) {
		vector<pii> v;
		v.resize(N);
		for(int i = 0; i < N; i++) {
			cin >> v[i].fi >> v[i].se;
		}
		sort(v.begin(), v.end());
		int sum = 0;
		int res = 0;
		for(int i = 0; i < N; i++) {
			sum += v[i].fi;
			res += v[i].fi + v[i].se;
		}
		//cout << sum << " " << v.back().fi << endl;
		if(v.back().fi*2 > sum) {
			int dp[1100] = {};
			int tmp = 0;
			dp[0] = 1;
			for(int i = 0; i < v.size()-1; i++) {
				for(int j = 1099; j >= 0; j--) {
					if(j + v[i].se < 1100 && dp[j]) {
						dp[j+v[i].se] = 1;
					}
				}
				tmp += v[i].fi;
			}
			for(int i = v.back().fi - tmp; i >= 0; i--) {
				if(dp[i]) {
					res += (v.back().fi-tmp) - i;
					break;
				}
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1208