akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

#define MAX_N 100000

int n;
ll m;
vector<ll> a;

bool isOK(ll mid){
    ll cnt = 0;
    for(int i = 0; i < n; i++){
        cnt += a.end() - lower_bound(ALL(a), mid - a[i]);
    }
    return m <= cnt;
}

signed main(){
    cin >> n >> m;
    a.resize(n);
    REP(i,n){
        cin >> a[i];
    }
    sort(ALL(a));
    ll ok = 0, ng = LINF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    vector<ll> sum(n + 1);
    for(int i = 0; i < n; i++){
        sum[i + 1] = sum[i] + a[i];
    }
    ll ans = 0, mem = 0;
    for(int i = 0; i < n; i++){
        int t = lower_bound(ALL(a), ok - a[i]) - a.begin();
        ans += sum[n] - sum[t];
        ans += a[i] * (n - t);
        mem += n - t;
    }
    ans -= ok * (mem - m);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int N = 1e5 + 100;

int a[N], b[N];

int main(){
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);

	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i], b[i] = a[i];

	sort(b, b + n);
	for (int i = 0; i < n; i++)
		a[i] = lower_bound(b, b + n, a[i]) - b;

	int cnt = 0;
	for (int i = 0; i < n; i++)
		if (a[i] % 2 != i % 2) cnt++;
	
	cout << (cnt + 1) / 2 << endl;
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <sstream>
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i);
#define ms(x,a) memset((x),a,sizeof((x))) 
#define INF 0x3f3f3f3f
#define eps 1e-8
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define np next_permutation
#define gapline cout<<"##======================##"<<endl
using namespace std;
const int maxn=300;
const int maxl=26;
const int maxm=1e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
int n,m;
int dp[maxn][maxn],a[maxn][maxn];
void solve(){
	rep(i,1,n+1){
		rep(j,1,m+1){
			dp[i][j]=max(dp[i-1][j],dp[i][j-1])+a[i][j];
		}
	}
} 

int main(){
	ios::sync_with_stdio(false);
	while(cin>>m){
		ms(dp,0);
		n=2;
		
		rep(i,1,n+1){
			rep(j,1,m+1) cin>>a[i][j];
		}
		solve();
		cout<<dp[2][m]<<endl;
		
	}
}

Measured memory_bytes: 640
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int x = scan.nextInt();
        for(int i = 1;; i++){
            if(x * i % 360 == 0){
                System.out.println(i);
                return;
            }
        }
    }
    
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 27008
#include <iostream>
#include <deque>
#include <algorithm>
#include <string>
#include <sstream>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int q;
	std::deque<long> deq;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	q = std::stoi(buf);

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		if(buf[0] == '0'){
			std::istringstream stream(buf);
			int tmp, d, x;

			stream >> tmp >> d >> x;
			if(d == 0){
				deq.push_front(x);
			}
			else{
				deq.push_back(x);
			}
		}
		else if(buf[0] == '1'){
			std::istringstream stream(buf);
			int tmp, p;

			stream >> tmp >> p;
			std::cout << deq[p] << std::endl;
		}
		else{
			std::istringstream stream(buf);
			int tmp, d;

			stream >> tmp >> d;
			if(d == 0){
				deq.pop_front();
			}
			else{
				deq.pop_back();
			}
		}
	}
	return 0;
}


Measured memory_bytes: 6284
main = do
    fs <- getLine
    let (n1:n2:_) = map (\x -> read x :: Int) $ words fs
    putStrLn $ show $ mygcd n1 n2

mygcd n1 n2
  | n1 == n2 = n1
  | otherwise = mygcd (abs $ n1-n2) (min n1 n2)


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

int solve(){
    string s;
    cin >> s;
    if(s == "#") return 1;
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;
    int h=0, w;
    string v;
    for(auto c : s){
        if(c=='b'){
            v.push_back(c);
        }
        if(isdigit(c)){
            int n = c-'0';
            for(int i=0;i<n;i++) v.push_back('.');
        }
        if(c=='/'){
            h++;
        }
    }
    h++;
    w = v.size()/h;
    swap(v[a*w+b], v[c*w+d]);
    string ans = "";
    int cnt = 0;
    for(int i=0;i<h;i++){
        int cnt=0;
        for(int j=0;j<w;j++){
            if(v[i*w+j]=='b'){
                if(cnt>0){
                    ans.push_back('0'+cnt);
                    cnt = 0;
                }
                ans.push_back('b');
            }
            else cnt++;
        }
        if(cnt>0) ans.push_back('0'+cnt);
        ans.push_back('/');
    }
    ans.pop_back();
    cout << ans << endl;
    return 0;
}

int main(){
    while(solve()==0);
    return 0;
}



Measured memory_bytes: 3124
n=int(input())
dp=[0,0,0]
for i in range(n):
    a,b,c=map(int,input().split())
    dp=[max(dp[1],dp[2])+a,max(dp[0],dp[2])+b,max(dp[0],dp[1])+c]
print(max(dp))
                             

Measured memory_bytes: 47448
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <stdio.h>
using namespace std;

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

bool s[200010], t[200010];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N,M,a[200010], b[200010];
	scanf("%d %d", &N, &M);
	REP(i, M) {
		scanf("%d %d", &a[i], &b[i]);
		if (a[i] == 1) {
			s[b[i]] = true;
		}
		if (b[i] == N) {
			t[a[i]] = true;
		}
	}
	REP(i, N) {
		if (s[i] && t[i]) {
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
int main() {
	int x,y;
	cin>>x>>y;
	set<int> se;
	REP(i,x+1){
		se.insert(i*y);
	}
	REP(i,y+1){
		se.insert(i*x);
	}
	cout<<se.size()<<endl;
	return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using P = pair<int,int>;
const int INF = 1e9;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = max({a*c, b*c, a*d, b*d});
    cout << ans << endl;
    return 0;
}

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

int main() {
	int N, M, C;
	cin >> N >> M >> C;
    vector<int> B;
	vector<vector<int>> A;
  
  for (int i = 0; i < M; i++)
  {
    int b;
    cin >> b;
    B.push_back(b);
  }
  
  int count = 0;
  for (int j = 0; j < N; j++)
  {
    int sum = 0;
	for (int i = 0; i < M; i++)
    {
      int a;
      cin >> a;
      sum += B[i] * a;
    }
    if (sum + C > 0)
      count++;
  }
    
    
	cout << count << endl;
	

	return 0;
}

Measured memory_bytes: 256
/// 5:21 PM 03/05/20
/// Author: t_bone_289 (An Immature Programmer.... I'm still developing !!)
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

template<typename T>
void ContainerError(T &v);

ll powmod(ll base, ll exp, ll MOD);

ll mpow(ll base, ll exp);

ll gcd(ll a, ll b);

ll modify(ll a0, ll b0, ll a1, ll b1, vector<ll> &v) {
    if (v[a0] == 0 && v[b0] == 0) {
        return -1;
    } else if (v[a0] == 1 && v[b0] == 1) {
        if (a1 == -1 || b1 == -1) {
            v[a0]++;
            v[b0]--;
            return a0;
        }
        if (a0 == a1 || a0 == b1) {
            v[a0]++;
            v[b0]--;
            return a0;
        } else {
            v[a0]--;
            v[b0]++;
            return b0;
        }
    }
    if (v[a0] > v[b0]) {
        v[a0]--;
        v[b0]++;
        return b0;
    } else {
        v[b0]--;
        v[a0]++;
        return a0;
    }
    return -1;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll n;
    cin >> n;
    vector<ll> value(3);
    for (auto &x:value) {
        cin >> x;
    }
    vector<string> v(n);
    for (ll i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector<ll> ans;
    for (ll i = 0; i < n; i++) {
        string s = v[i];
        if (i == n - 1) {
            ll val = modify(s[0] - 'A', s[1] - 'A', -1, -1, value);
            if (val == -1) {
                cout << "No";
                return 0;
            }
            ans.pb(val);
        } else {
            string next = v[i + 1];
            ll val = modify(s[0] - 'A', s[1] - 'A', next[0] - 'A', next[1] - 'A', value);
            if (val == -1) {
                cout << "No";
                return 0;
            }
            ans.pb(val);
        }
    }
    cout << "Yes" << endl;
    for (auto x:ans) {
        cout << char('A' + x) << endl;
    }
    return 0;
}

template<typename T>
void ContainerError(T &v) {
    cout << "{";
    for (auto &x:v) { cout << x << ','; }
    cout << "}" << endl;
    return;
}

ll powmod(ll base, ll exp, ll MOD) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return (res % MOD);
}

ll mpow(ll base, ll exp) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = (res * base);
        base = (base * base);
        exp /= 2;
    }
    return (res);
}

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }



Measured memory_bytes: 7396
#include <iostream>

int main()
{
	int n;
	int min = 1000001;
	int max = -1000001;
	int a;
	long long int sum = 0;
	std::cin >> n;
	for (int i=0; i<n; i++) {
		std::cin >> a;
		if (a < min) min = a;
		if (a > max) max = a;
		sum += (long long int)a;
	}
	std::cout << min << " " << max << " " << sum << std::endl;
	
	return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<deque>

using namespace std;

#define sz(x) (int)(x.size())
#define rep(i,a,b) for(int i=a;i<b;++i)
#define per(i,a,b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////////

int const N = 1e5 + 41;
int const INF = 1e9 + 41;
int n;
ll h[N];
ll a, b;
ll h1[N];

bool can(ll m){
	rep(i, 0, n){
		ll rem = h[i] * 1LL - m * 1LL * b;
		rem = max(rem, 0LL);
		h1[i] = rem;
	}
	sort(h1, h1 + n);
	ll cnt = m;
	rep(i, 0, n){
		ll cur = h1[i] / (a - b);
		if( (h1[i] % (a - b)) > 0) ++cur;
		cnt -= cur;
	}

	return cnt >= 0;
}

void solve(){
	cin >> n >> a >> b;
	rep(i, 0, n) cin >> h[i];
	ll l = 0;
	ll r = INF;
	while(r-l>1){
		ll m = (l+r)/2;
		if(can(m)) r = m;
		else l = m;
	}
	cout << r << endl;
}


int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

Measured memory_bytes: 1792
N=int(input())
P=[int(input())-1 for i in range(N)]
Q=[0 for i in range(N)]
for i in range(N):
    Q[P[i]]=i
L=[1]
k=0
for i in range(1,N):
    if Q[i-1]<Q[i]:
        L[k]+=1
    else:
        L.append(0)
        k+=1
        L[k]+=1
print(N-max(L))


Measured memory_bytes: 20504
#include <stdio.h>
int main(){

  int n,m,a,i,j,h,p,q,c=1;
  int  chart[2000][300]={{}};
  int  count[2000][300]={{}};

  for(;;){
    scanf("%d %d %d",&n,&m,&a);

    if(n==0&&m==0&&a==0){
      break;
    }
    for(i=1;i<=m;i++){
      scanf("%d %d %d",&h,&p,&q);

      chart[h][p]=1;
      chart[h][q]=1;
      count[h][p]=c;
      count[h][q]=c;
      c++;
    }
    /*for(i=1;i<=1000;i++){
      for(j=1;j<=1000;j++){
	 printf("%d %d\n",chart[i][j],count[i][j]);
      }
      }*/


 
    for(i=1000;i>=0;i--){
      if(chart[i][a]==1&&chart[i][a+1]==1&&count[i][a]==count[i][a+1]){
	a+=1;
	continue;
      }
      else if(chart[i][a]==1&&chart[i][a-1]==1&&count[i][a]==count[i][a-1]){
	a-=1;
	continue;
      }
      //printf("%d\n",a);
    }

    printf("%d\n",a);
    c=1;
    for(i=1;i<=1001;i++){
      for(j=1;j<=101;j++){
	chart[i][j]=0;
	count[i][j]=0;
      }
    }   
  }
  return 0;
}

Measured memory_bytes: 5296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int a[n];
    int sum=0;
    int ct=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    bool b=true;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=((double)sum/(4*m)))
        {
            ct++;
        }
    }
    if(ct>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
                      //Alhamdulilla...


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

typedef struct {
  int a_val;
  int b_val;
} st;

int cmp_a(const void *x, const void *y) {
  st *X = (st *)x;
  st *Y = (st *)y;
  return Y->a_val - X->a_val;
}

int cmp_b(const void *x, const void *y) {
  st *X = (st *)x;
  st *Y = (st *)y;
  return X->b_val - Y->b_val;
}
/*
int cmp(const void *a, const void *b) {
  int(*func[])(st* pa_, st* pb_) = {&cmp_a, &cmp_b};
  st *pa = (st*)a;
  st *pb = (st*)b;
  for (int i = 0; i < sizeof(func) / sizeof(func[0]); i++) {
    int ret = func[i](pa, pb);
    if (ret != 0) {
      return ret;
		}
	}
}
*/

int main() {
  int i;
  int n;
  scanf("%d", &n);

  int *a, *b;
  a = (int *)malloc(sizeof(int) * n);
  b = (int *)malloc(sizeof(int) * n);

  for(i = 0; i < n; i++) {
    scanf("%d %d", &a[i], &b[i]);
  }

  st *c;
  c = (st *)malloc(sizeof(st) * n);
  for(i = 0; i < n; i++) {
    c[i].a_val = a[i];
    c[i].b_val = b[i];
  }

  qsort(c, n, sizeof(st), cmp_b);

  int alltime = 0;
  for(i = 0; i < n; i++) {
    alltime += c[i].a_val;
    if(alltime > c[i].b_val) {
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i)
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
    ~debug() { cerr << endl; }
eni(!=) { cerr << boolalpha << i; ris; }
eni(==) { ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << &", " [ 2 * (it == d.b)] << *it;
  ris << "]";
}
#else
    sim dor(const c&) { ris; }
#endif
};
#define imie(...) "" << #__VA_ARGS__ " = " << (__VA_ARGS__) << ""
#define arr array
using ll = long long;
const int INF = 1e9 + 5;
const int N = 1e6 + 5;

//dp[i][j] => max length of LCS at index i in a and index j in b
int main() {
	string a,b;
	cin >> a >> b;
	vector<vector<pair<int,pair<int,int>>>> dp(a.size() + 1,vector<pair<int,pair<int,int>>>(b.size() + 1,{-INF,{0,0}}));
	
	dp[0][0] = {0,{0,0}};
	for(int i = 0; i < (int)a.size(); i++) {
		for(int j = 0; j < (int)b.size(); j++) {
			if(a[i] == b[j]) {
				dp[i+1][j+1] = max(dp[i+1][j+1], make_pair(1 + dp[i][j].first, make_pair(i, j)));
			}
			dp[i+1][j] = max(dp[i+1][j], make_pair(dp[i][j].first, make_pair(i, j)));
			dp[i][j+1] = max(dp[i][j+1], make_pair(dp[i][j].first, make_pair(i, j)));
	  	}
	}
	
	pair<int,pair<int,int>> ans = {0,{0,0}};
	for(int i = 0; i <= (int)a.size(); i++) {
		for(int j = 0; j <= (int)b.size(); j++) {
			ans = max(ans, make_pair(dp[i][j].first, make_pair(i, j)));
		}
	}
	
	//debug() << ans;
	string s;
	pair<int,int> curr = ans.second;
	while(curr.first > 0 && curr.second > 0) {
		int i = curr.first;
		int j = curr.second;
		pair<int,int> previous = dp[i][j].second; //dp[i][j] => the cell from which we reach (i,j)
		if(previous == make_pair(i - 1, j - 1)) {
			s += a[i-1];
		}
		curr = previous;
	}

	reverse(s.begin(),s.end());
	cout << s << "\n";

    return 0;
}




Measured memory_bytes: 108844
#include<iostream>
#include<cstdio>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#define LL long long
#define For(i,n) for(int i=1;i<=n;i++)

using namespace std;
int n,m,t;

int main()
{
	char a[10],b[10];
	while(cin>>a>>b){
	
		if(a[0]=='H')
		{
			if(b[0]=='H')
			{
				cout<<"H";
			}
			else cout<<"D";
			
		}
		else if(a[0]=='D')
		{
			if(b[0]=='H')
			{
				cout<<"D";
			}
			else cout<<"H";
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  long long int a,b,c,d=0,f,g,h;
  cin>>a>>b>>c;
  d=max(a,max(b,c));
  cout<<a+b+c+d*9;
}

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

typedef unsigned long long parallel_type;
const int bit_width=8*sizeof(parallel_type);

int main(){
	int H,W;
	for(;~scanf("%d%d",&H,&W)&&H&&W;){
		vector<string>m(H);
		for(int h=0;h<H;h++)cin>>m[h];
		if(H<=21){
			vector<vector<parallel_type> >l(H);
			int parallel_width=(W+bit_width-1)/bit_width;
			for(int h=0;h<H;h++){
				l[h].resize(parallel_width);
				for(int w=0;w<W;w++)l[h][w/bit_width]|=parallel_type(m[h][w]=='1')<<(w%bit_width);
			}
			int R=0;
			for(int i=0;i<1<<H;i++){
				vector<parallel_type> v(parallel_width);
				int r=0;
				for(int j=0;j<H;j++)if(i>>j&1){
					r++;
					for(int k=0;k<parallel_width;k++)v[k]^=l[j][k];
				}
				if(none_of(v.begin(),v.end(),[](parallel_type e){return e;}))R=max(R,r);
			}
			cout<<R<<endl;
		}else{
			vector<int>b(H);
			for(int h=0;h<H;h++){
				for(int w=0;w<W;w++)b[h]=(b[h]<<1)|(m[h][w]=='1');
			}
			vector<short>s(1<<W),t(1<<W);
			for(int w=1;w<1<<W;w++)s[w]=-1;
			for(int h=0;h<H;h++){
				for(int w=0;w<1<<W;w++){
					t[w]=max(s[w],short(s[w^b[h]]>=0 ? 1+s[w^b[h]] : -1));
				}
				swap(s,t);
			}
			cout<<s[0]<<endl;
		}
	}
}

Measured memory_bytes: 19596
#include <stdio.h>

int main(void){
  int num,db[10000]={0},cnt=0,i;
  double Wei,Hei,BMI;
  char comma;

  while( scanf("%d %c %lf %c  %lf" ,&num ,&comma ,&Wei ,&comma ,&Hei) != EOF ){

    BMI = Wei / (Hei*Hei); 

    if( BMI >= 25 ){
      db[cnt] = num;
      cnt++;
    }

  }

  for( i = 0 ; i < cnt ; i++ ) printf("%d\n" ,db[i]); 

  return 0;
}

Measured memory_bytes: 672
s=input()

cnt_start0 = 0
cnt_start1 = 0
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] == '0':
            cnt_start1 += 1
        if s[i] == '1':
            cnt_start0 += 1
    if i % 2 == 1:
        if s[i] == '0':
            cnt_start0 += 1
        if s[i] == '1':
            cnt_start1 += 1

print(min(cnt_start0, cnt_start1))

Measured memory_bytes: 3188
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%v", &N)

	words := make([]string, 0, N)

	for i := 0; i < N; i++ {
		var s string
		fmt.Scanf("%s", &s)
		words = append(words, s)
	}

	tail := string(words[0][0])
	already := make(map[string]bool)
	for _, w := range words {
		if _, exist := already[w]; exist {
			fmt.Println("No")
			return
		}
		already[w] = true
		if tail != string(w[0]) {
			fmt.Println("No")
			return
		}
		tail = string(w[len(w)-1])
	}

	fmt.Println("Yes")
	return
}


Measured memory_bytes: 1852
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    final int N=sc.nextInt();
    int answer=0;
    for(int i=1;i<N+1;i++){
      answer=answer+i;
    }
    System.out.println(answer);
  }
}

Measured memory_bytes: 20820
nblues = int(input())
profits = dict()
for _ in range(nblues):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) + 1

nreds = int(input())
for _ in range(nreds):
    word = input().rstrip("\n")
    profits[word] = profits.get(word, 0) - 1

print(max(0, max(profits.items(), key=lambda t: t[1])[1]))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int a[(int)1e5 + 5];
bool b[(int)1e5 + 5];

int main()
{
	ios_base::sync_with_stdio(0);
	memset(a, 0, sizeof(a));
	memset(b, false, sizeof(b));
	int N, M; cin >> N >> M;
	rep (i, N) a[i] = 1;
	b[0] = true;

	rep (i, M){
		int x, y; cin >> x >> y;
		--x, --y;
		if(b[x] && a[x] > 0){
			b[y] |= true;
		} // end if
		a[y]++; a[x]--;
		if (b[x] && a[x] == 0){
			b[x] = false;
		} // end if
	} // end rep
	int res = (int)count(b, b+N, true);
	cout << res << endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
Apparently, the tree supports the same operations as the set 
(at least I haven't any problems with them before), but also there are two new features — 
find_by_order() — The first returns an iterator to the k-th largest element (counting from zero)
order_of_key() — the number of items in a set that are strictly smaller than our item. 
https://codeforces.com/blog/entry/11080
using namespace __gnu_pbds; */
using namespace std;
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define int long long
#define MOD 998244353
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
vector<int> fac;
int modInverse(int n) 
{ 
    return p(n, MOD-2); 
}  
int nCrModPFermat(int n, int r) 
{   if(r == 0)  return 1; 
    return m(m(m(fac[n])*m(modInverse(fac[r])))*m(modInverse(fac[n-r]))); 
} 
signed main(){
    fast();
    int n, k, m1;
    cin >> n >> m1 >> k;
    fac.resize(n+1);
    fac[0] = 1; 
    for (int i=1; i<=n; i++)   fac[i] = m(m(fac[i-1])*m(i)); 
    int ans = 0;
    for(int i=0; i<=k; i++){
        ans = m(m(ans) + m(m(nCrModPFermat(n-1, i))*m(m(m1)*m(p(m1-1, n-i-1)))));
    }
    cout << ans << endl;
}

Measured memory_bytes: 4772
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const double EPS = 1e-10;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int main()
{
  int N, M;
  while (cin >> N >> M) {
    vector<pair<int, int> > ab(M);
    for (int i = 0; i < M; ++i)
      cin >> ab[i].first >> ab[i].second;
    
    int ans = 0, prev = 1;
    for (int t = 0; t < M; ++t) {
      int next = -1;
      for (int i = 0; i < M; ++i) {
        if (ab[i].first <= prev)
          next = max(next, ab[i].second);
      }
      ++ans;
      prev = next+1;
      if (prev > N)
        break;
    }

    if (prev > N)
      cout << ans << endl;
    else
      cout << "Impossible" << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
/*BINH :))*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long llu;
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define v  first
#define w  second
#define mp make_pair
#define pb push_back
#define ep emplace_back
#define sz(a) (int) a.size()
#define FOR(x,a,b) for (ll x=a,u;x<=b;x++)
#define FOD(x,a,b) for (int x=a;x>=b;x--)
#define REP(x,a,b) for (int x=a;x<b;x++)
#define RED(x,a,b) for (int x=a;x>b;x--)
#define EL cout<<endl
#define maxn 1005
#define vi vector<int>
#define ii pair<ll,ll>
#define vii vector<ii>
#pragma GCC optimize("Ofast")
int m,n,f[3000][3000],mod = 1e9+7;
char a[3000][3000];
int main(){
    IO
    cin >> m >> n;
    FOR(i,1,m){
        FOR(j,1,n){
            cin >> a[i][j];
        }
    }
    f[1][1] = 1;
    FOR(i,1,m){
        FOR(j,1,n){
            if(i==1 && j==1)continue;
            if(a[i][j] == '#') continue;
            f[i][j] = (f[i-1][j]%mod + f[i][j-1]%mod)%mod;
        }
    }
    FOR(i,1,n){

    }
    cout<<f[m][n];

    
    
}


Measured memory_bytes: 18688
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        sc.close();

        Arrays.sort(a);

        int count = 0;
        for(int i=0; i<n; i++) {
            if(i == n-1) {
                if(x - a[i] == 0){
                    count++;
                    break;
                }
            } else if(x - a[i] >= 0) {
                x -= a[i];
                count++;
            } else {
                break;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23124
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>
#include <iomanip>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
/*
int stoi(string sstoi){//string->int
  ll int stois=0;
  rep(stoii,0,sstoi.length()){
    stois+=ctoi(sstoi[stoii])*jo(10,sstoi.length()-stoii-1);
  }
  return stois;
}*/
  
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  string s;
  cin>>s;
  if(s=="SUN") cout<<7;
  else if(s=="MON") cout<<6;
  else if(s=="TUE") cout<<5;
  else if(s=="WED") cout<<4;
  else if(s=="THU") cout<<3;
  else if(s=="FRI") cout<<2;
  else if(s=="SAT") cout<<1;
  
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//cout<<fixed<<setprecision(n);  //小数点n桁まで表示


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

const string T = "AKIHABARA";

int main() {
    string S;
    cin >> S;
    int j = 0, k = 0;
    bool ok = true;
    for (; j < S.size() && k < T.size(); ++j, ++k) {
        if (S[j] == T[k]) {
            // ok
        } else if (T[k] == 'A') {
            --j;
        } else {
            ok = false;
        }
    }
    cout << ((ok && j == S.size() && k >= T.size()-1) ? "YES" : "NO") << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    set<string> s;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        s.insert(S);
    }
    cout << s.size() << "\n";
    return 0;
}

Measured memory_bytes: 19124
class UnionFind
  def initialize(size)
    @rank = Array.new(size, 0)
    @parent = Array.new(size, &:itself)
  end

  def unite(id_x, id_y)
    x_parent = get_parent(id_x)
    y_parent = get_parent(id_y)
    return if x_parent == y_parent

    if @rank[x_parent] > @rank[y_parent]
      @parent[y_parent] = x_parent
    else
      @parent[x_parent] = y_parent
      @rank[y_parent] += 1 if @rank[x_parent] == @rank[y_parent]
    end
  end

  def get_parent(id_x)
    @parent[id_x] == id_x ? id_x : (@parent[id_x] = get_parent(@parent[id_x]))
  end

  def same_parent?(id_x, id_y)
    get_parent(id_x) == get_parent(id_y)
  end
end

N,M=gets.split.map &:to_i
as=M.times.map{gets.split.map(&:to_i)}
tree=UnionFind.new(N+1)
for i in 0...M
    tree.unite(as[i][0],as[i][1])
end
puts (1..N).to_a.map{|x|tree.get_parent(x)}.uniq.size


Measured memory_bytes: 19892
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

int main(){
    ll n, m ; cin >> n  >> m;
    vl xs(m), ys(m-1, 0); REP(i, m) cin >> xs[i];
    sort(xs.begin(), xs.end());
    REP(i, m-1){
        ys[i] = abs(xs[i+1] - xs[i]);
    }
    sort(ys.begin(), ys.end());
    ll ans = 0;
    REP(i, m-n){
        ans += ys[i];
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <tuple>

using namespace std;
typedef tuple<int, int, int> tiii;

int main(){
	ios_base::sync_with_stdio(false);
	while(true){
		int h, w;
		cin >> h >> w;
		if(h == 0 && w == 0){ break; }
		const tiii input(h * h + w * w, h, w);
		tiii answer(150 * 150 * 2, 150, 150);
		for(int i = 1; i <= 150; ++i){
			for(int j = i + 1; j <= 150; ++j){
				const tiii t(i * i + j * j, i, j);
				if(t > input && t < answer){ answer = t; }
			}
		}
		cout << get<1>(answer) << " " << get<2>(answer) << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
int main()
{
    int n,x;
    scanf("%d",&n);
    for(int i=1;i<100000;i++)
    {
        if(i*i>n)
        {
            printf("%d\n",(i-1)*(i-1));
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

// helpful functions
#define fl(i,n) for(int i = 0; i < n; i++)
#define fls(i,a,b) for(int i = a; i < b; i ++)
#define afl(i,a,n) int a[n]; for(int i = 0; i < n; i++) scanf("%d", &ar[i])

// printers
#define iprint(x) printf("%d\n", x)
#define lprint(x) printf("%lld\n", x)
#define fprint(x,n) printf("%.nf\n", x)
#define dprint(x,n) printf("%.nlf\n", x)
#define sprint(x) printf("%s\n", x)

// scanners
#define iscan(x) scanf("%d", &x)
#define lcan(x) scanf("%lld", &x)
#define fscan(x) scanf("%f", &x)
#define dscan(x) scanf("%lf", &x)
#define scan(x) scanf("%s", x)
#define qs(x) int x; scanf("%d", &x)

int main()
{
	int n; scanf("%d", &n);
	int num[n], count[n] = {0}, u = 0, ans = 0;
	for(int i = 0; i < n; i++)
	{
		int x, yes = 1;
		scanf("%d", &x);
		for(int j = 0; j < u; j++) 
		{
			if(x == num[j])
			{
				yes = 0;
				count[j]++;
				break;
			}
		}
		if(yes) 
		{
			count[u]++;
			num[u++] = x;
		}
	}
	fls(i,0,u) fls(j,i+1,u) fls(k,j+1,u)
	{
		if(num[i]+num[j]>num[k] && num[i]+num[k]>num[j] && num[k]+num[j]>num[i]) ans += count[i]*count[j]*count[k];
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1700
N = int(input())
list = list(map(int, input().split()))
mydict = {}
number = []
for i in list:
    if i in mydict.keys():
        mydict[i] += 1
    else:
        mydict[i] = 1
        number.append(i)
number.sort()

count = 0
length = len(number)
if length >= 3:
    for i in range(2,length):
        max = number[i]
        for j in range(0,i):
            for k in range(j+1, i):
                if max < number[j]+number[k]:
                    count += mydict[max]*mydict[number[j]]*mydict[number[k]]

print(count)


Measured memory_bytes: 9128
n = int(input())

ans = 0

i = 2
num = n
while i * i <= n:
  cnta = 0
  cntb = 0
  while num % i == 0:
    num //= i
    if cnta == cntb:
      ans += 1
      cnta = 0
      cntb += 1
    else:
      cnta += 1
  i += 1
  
if (ans == 0 and n != 1) or num != 1:
  ans += 1
print(ans)


Measured memory_bytes: 9172
#include <iostream>
#include <vector>
#include <cmath>
#include <climits>
#include <utility>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define finish(x) std::cout<< x <<endl
#define all(x) (x).begin(), (x).end()
#define forn(i, j) for(ll i = 0; i < j; i++)
#define rforn(i, j) for(ll i = j-1; i >= 0; i--)
#define forit(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll INF = 1e9;
const ll mod = 1e9 + 7;
ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; }


void solve() {
        ll n;
        cin >> n;
        int count = 1;
        ll sum = 100;
        while(sum <= n) {
                sum += (.01)*sum;
                if(sum < n)
                        count += 1;
        }
        cout << count << endl;
}

int main() {

        boost;

        ll t;
        // cin >> t;
        t = 1;

        while(t--) {
                solve();
        }
        return 0;
}

Measured memory_bytes: 3656
L,R = map(int,input().split())
l = L // 2019
r = R // 2019
L = L % 2019
R = R % 2019
min = 2020
if r - l >= 1:
    print(0)
    exit()
elif L % 2019 == 0:
    print(0)
    exit()
for i in range(L,R):
    for j in range(i+1,R+1):
        if i*j % 2019 < min:
            min = i*j % 2019
print(min)

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

// 各桁の和を計算する関数
int fsum(int N) {
  int sum = 0;
  while (N > 0) { // N が 0 になるまで
    sum += N%10;
    N = N/10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  if ( N%fsum(N) == 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int a, p;

int main()
{
    IOS
    //freopen("planet.in", "r", stdin);
    cin >> a >> p;
    cout << (a*3 + p) / 2 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long
#define ull unsigned long long
#define EPS 1e-8
#define test cout<<"test"<<endl;
using namespace std;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
const double pi = acos(-1.0);
int read()
{
	int ret=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	for(;ch>='0'&&ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret;
}
const int MAX_N=2e5+5;
ll a[MAX_N],sum[MAX_N],k,n,ans;
vector <ll> s;
ll BIT[MAX_N];
ll lowbit(ll x)
{
	return x&(-x);
}
void add(ll x,ll val)
{
	while(x<MAX_N)
	{
		BIT[x]+=val;
		x+=lowbit(x);
	}
}
ll Qsum(ll x)
{
	ll res=0;
	while(x)
	{
		res+=BIT[x];
		x-=lowbit(x);
	}
	return res;
}
int main()
{
 	#ifdef TEST
	 	freopen("input.txt","r",stdin);
	#endif
	mem(BIT,0);
	scanf("%lld%lld",&n,&k);
	sum[0]=0;
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",a+i);
		a[i]-=k;
		sum[i]=sum[i-1]+a[i];
	}
	for(int i=0;i<=n;i++)
	{
		s.push_back(sum[i]);
	}
	sort(s.begin(),s.end());
	s.erase(unique(s.begin(),s.end()),s.end());
	for(int i=0;i<=n;i++)
	{
		sum[i]=lower_bound(s.begin(),s.end(),sum[i])-s.begin()+1;
	}
	ans=0;
	for(int i=0;i<=n;i++)
	{
		ans+=Qsum(sum[i]);
		add(sum[i],1);
	}
	printf("%lld\n",ans);
	return 0;
}



Measured memory_bytes: 7156
import java.util.*;
import java.util.Arrays;

public class Main{
        public static void main(String[] args){
                Scanner scanCnt = new Scanner(System.in);
                int N = scanCnt.nextInt();
                int K = scanCnt.nextInt();
                int array[] = new int[N];
                long result=10000000000L;
                int tmp;

                for(int i = 0;i<N;i++ ){
                        array[i] = scanCnt.nextInt();
                }

                int arraySort[] = new int[N];
                Arrays.sort(array);
                for(int i = 0;i<N;i++ ){
                        arraySort[i]=array[N-i-1];
                }

                for(int i = 0;i<N-K+1 ;i++ ){
                        tmp = arraySort[i]-arraySort[i+K-1];
                        if(tmp < result){
                                result = tmp;
                        }
                }
                System.out.println(result);
        }
}

Measured memory_bytes: 50272
S=input()
S_f=S
enzan=[]
op_cnt = len(S) - 1  #+を入れられるのは2**(n-1)個
for i in range(2 ** op_cnt):
    op = ["-"] * op_cnt  # あらかじめ ["-", "-"] というリストを作っておく
    for j in range(op_cnt):
        if ((i >> j) & 1):
            op[op_cnt - 1 - j] = "+"  # フラグが立っていた箇所を "+" で上書き
    enzan.append(op)

ans=0
for i in enzan:
  S_f=S
  now=0
  for j in range(len(S)-1):
    if i[j]=='+':
      now+=int(S_f[:j+1])
      S_f="0"*len(S_f[:j+1])+S_f[j+1:]

  now+=int(S_f)
  ans+=now
print(ans)


Measured memory_bytes: 3064
#include <string>
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main(){
  int n; cin >> n;
  vector<string> v;
  map<string,int> cnt;
  string ans="Yes";
  string t;
  for(int i=0;i<n;i++){
    string s; cin >> s;
    cnt[s]++;
    if(cnt[s]>1) ans="No";
    if(i>0) if(*s.begin()!=*(--t.end())) ans="No";
    t=s;
    //if(i>0) if(--((v.back()).end())!=s.begin()) ans="No";
    //v.push_back(s);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#abc159 d

import itertools
from math import factorial
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce

sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7

#ここから書き始める
n = int(input())
cnt = [0] * n
a = list(map(int, input().split()))
for i in a:
    cnt[i - 1] += 1
total = 0
for i in cnt:
    total += i * (i - 1) // 2
for i in a:
    total2 = total
    if cnt[i - 1] >= 1:
        total2 -= cnt[i - 1] * (cnt[i - 1] - 1) // 2
        total2 += (cnt[i - 1] - 1) * (cnt[i - 1] - 2) // 2
    print(total2)


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

typedef long long ll;

const ll INF = 1e18;

ll n, s;

bool ok(ll b) {
	ll sum = 0, ncopy = n;
	while (ncopy) {
		sum += ncopy % b;
		ncopy /= b;
	}
	return sum == s;
}

int main() {
	cin >> n >> s;
	ll ans = INF;
	if (n == s) ans = n + 1;
	for (ll i = 1; i * i <= n - s; i++) {
		if (abs(n - s) % i) continue;
		if (ok(i + 1)) 
			ans = min(ans, i + 1);
		if (ok((n - s) / i + 1)) 
			ans = min(ans, (n - s) / i + 1);
	}	
	if (ans == INF) ans = -1;
	cout << ans;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
//typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009
int T[2100][2100];
int d[2100][2100];
int L[2100][2100];
int R[2100][2100];
void solve()
{
	ll h,w;
	rl2(h,w);
	vector<string> arr(h);
	fr(i,0,h)
		cin>>arr[i];
	fr(i,0,h)
	{
		ll cur=0;
		fr(j,0,w)
		{
			if(arr[i][j]=='#')
				cur=0;
			else
				cur++;
			L[i][j]=cur;
		}
	}
	fr(j,0,w)
	{
		ll cur=0;
		fr(i,0,h)
		{
			if(arr[i][j]=='#')
				cur=0;
			else
				cur++;
			d[i][j]=cur;
		}
	}
	fr(i,0,h)
	{
		ll cur=0;
		frr(j,w,0)
		{
			if(arr[i][j]=='#')
				cur=0;
			else
				cur++;
			R[i][j]=cur;
		}
	}
	fr(j,0,w)
	{
		ll cur=0;
		frr(i,h,0)
		{
			if(arr[i][j]=='#')
				cur=0;
			else
				cur++;
			T[i][j]=cur;
		}
	}
	ll ret=0;
	fr(i,0,h)
		fr(j,0,w)
			ret=max(ret,(ll)(T[i][j]+d[i][j]+L[i][j]+R[i][j]-3));
	wl(ret);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 72448
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <string>
#include <vector>

#define N 1000000007

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a);
    vector<ll> q(b);
    vector<ll> r(c);
    for (int i = 0; i < a; i++)
        cin >> p[i];
    for (int i = 0; i < b; i++)
        cin >> q[i];
    for (int i = 0; i < c; i++)
        cin >> r[i];

    sort(p.begin(), p.end(), [](ll x, ll y){ return x > y; });
    sort(q.begin(), q.end(), [](ll x, ll y){ return x > y; });
    sort(r.begin(), r.end(), [](ll x, ll y){ return x > y; });

    int a_i = x - 1, b_i = y - 1, c_i = 0;

    while (a_i >= -1 && b_i >= -1 && c_i < c) {
        if (a_i >= 0 && b_i >= 0 && p[a_i] < r[c_i] && q[b_i] < r[c_i]) {
            if (p[a_i] < q[b_i]) {
                a_i--;
            } else {
                b_i--;
            }
            c_i++;
        } else if (a_i >= 0 && p[a_i] < r[c_i]) {
            a_i--;
            c_i++;
        } else if (b_i >= 0 && q[b_i] < r[c_i]) {
            b_i--;
            c_i++;
        } else {
            break;
        }
    }

    ll sum = 0;
    for (int i = 0; i <= a_i; i++)
        sum += p[i];
    for (int i = 0; i <= b_i; i++)
        sum += q[i];
    for (int i = 0; i < c_i; i++)
        sum += r[i];

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) {};

    void init(int n) {
        par.assign(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return -par[root(x)];
    }
};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i], --b[i];
    }

    UnionFind uf(n);

    int res = 0;
    rep(i, m) {
        uf.init(n);
        rep(j, m) {
            if (i == j) continue;
            uf.unite(a[j], b[j]);
        }
        if (uf.size(0) != n) res++;
    }

    cout << res << endl;

    return 0;
}

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

lli n, m;
string s, t;

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

int main(void){
	cin >> n >> m >> s >> t;
	lli l = n*m/gcd(n, m);
	bool ans = true;
	unordered_map<lli, char> mp;
	for(int i = 0; i < n; i++){
		mp[l/n*i] = s[i];
	}
	for(int i = 0; i < m; i++){
		if(mp.count(l/m*i) > 0 && mp[l/m*i] != t[i]) ans = false;
	}
	if(ans) cout << l << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 7296