akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int dp[2][(1<<24)];
string s[501];
int n,m;
bool a[501][501];
 
int main(){
  while(cin>>n>>m,n|m){
    for(int i=0;i<n;i++){
      cin>>s[i];
      for(int j=0;j<m;j++){
        a[i][j]=(s[i][j]=='1');
      }
    }
    if(n<=m){
      int ans=0;
      for(int i=0;i<(1<<n);i++){
        if(ans>=__builtin_popcount(i))continue;
        bool ok=1;
        for(int j=0;j<m;j++){
          int cont=0;
          for(int k=0;k<n;k++){
            if(a[k][j] && i&(1<<k))cont++;
          }
          if(cont&1){ok=0;break;}
        }
        if(ok)ans=max(ans,__builtin_popcount(i));
      }
      cout<<ans<<endl;
    }else{
      int list[501];
      fill(list,list+n,0);
      for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
          if(a[i][j]){
            list[i]=list[i]|(1<<j);
          }
        }
      }
      for(int i=0;i<2;i++)for(int j=0;j<(1<<m);j++)dp[i][j]=-1;
      dp[0][0]=0;
      for(int i=0;i<n;i++){
        for(int j=0;j<(1<<m);j++)dp[(i+1)&1][j]=-1;
        for(int j=0;j<(1<<m);j++){
          if(dp[i&1][j]==-1)continue;
          dp[(i+1)&1][j^list[i]]=max(dp[(i+1)&1][j^list[i]],dp[i&1][j]+1);
          dp[(i+1)&1][j]=max(dp[(i+1)&1][j],dp[i&1][j]);
        }
      }
      cout<<dp[n&1][0]<<endl;
    }
  }
}


Measured memory_bytes: 19816
#include<stdio.h>
struct Card{
  char suit;
  int value;
};

int main(){
  struct Card C1[101], C2[101];
  int i,j,K,n,t,mini,ii;
  char ch,u;
  
  scanf("%d%c", &K, &ch);
  for ( i = 0; i < K; i++ ){
    scanf("%c%d%c", &C1[i].suit, &C1[i].value, &ch);
    C2[i].suit = C1[i].suit;
    C2[i].value = C1[i].value;
  }
  for(i=0;i<K-1;i++){
    for(j=K-1;i<j;j--){
      if(C1[j].value<C1[j-1].value){
	int t=C1[j].value;
	C1[j].value=C1[j-1].value;
	C1[j-1].value=t;
	char u=C1[j].suit;
	C1[j].suit=C1[j-1].suit;
	C1[j-1].suit=u;
      }
    }
  }
  
  for(i=0;i<K-1;i++){
    mini=i;
    for(j=i;j<K;j++){
      if(C2[j].value<C2[mini].value){
	mini=j;
      }
    }
    int t=C2[i].value;
    C2[i].value=C2[mini].value;
    C2[mini].value=t;
    char u=C2[i].suit;
    C2[i].suit=C2[mini].suit;
    C2[mini].suit=u;
  }
  for(n=0;n<K;n++){
    if(n == K-1)
      printf("%c%d",C1[n].suit,C1[n].value);
    else printf("%c%d ",C1[n].suit,C1[n].value);
  }
  printf("\n");
  printf("Stable\n");
  for(n=0;n<K;n++){
    if(n == K-1)
      printf("%c%d",C2[n].suit,C2[n].value);
    else printf("%c%d ",C2[n].suit,C2[n].value);
  }
  printf("\n");
  for(n=0;n<K;n++){
    if(C1[n].suit!=C2[n].suit){
      printf("Not stable\n");
      break;
    }
    if(n==K-1)printf("Stable\n");
  }
  return 0;
}

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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> A(H);
    for (int i = 0; i < H; i++) {
        string x;
        cin >> x;
        for (int j = 0; j < W; j++) {
            A.at(i).push_back(x.at(j));
        }
    }
    int w_count, h_count = 0;
    unordered_map<int, bool> rem_r, rem_c;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
//            cout << A.at(i).at(j);
            if (A.at(i).at(j) == '.') {
                w_count++;
            }
        }
        if (w_count == W) {
            rem_r[i] = true;
        }
        w_count = 0;
    }

    for (int j = 0; j < W; j++) {
        for (int i = 0; i < H; i++) {
            if (A.at(i).at(j) == '.') {
                h_count++;
            }
        }
        if (h_count == H) {
            rem_c[j] = true;
        }
        h_count = 0;
    }

    vector<vector<char>> ans(H - rem_r.size());
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (rem_c.find(j) == rem_c.end() && rem_r.find(i) == rem_r.end()) {
                cout << A.at(i).at(j);
            }
        }
        if (rem_r.find(i) == rem_r.end()) {
            cout << endl;
        }
    }

}

Measured memory_bytes: 3660
#include <stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  if((N+7)%10==0){
    printf("bon");
  }else if((N%10==0) || ((N+9)%10==0) || ((N+4)%10==0) || ((N+2)%10==0)){
    printf("pon");
  }else{
    printf("hon");
  }
  return 0;
}

Measured memory_bytes: 1728
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.4.3)

import math
import statistics
import numpy as np
import queue

a,b = map(int, input().split())
if a > 9 or b > 9:
  print('-1')
else:
  print(a * b)


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> vp[100010];
  for (int i = 0; i < m; i++) {
    int p, y;
    cin >> p >> y;
    vp[p].push_back({y, i});
  }

  pair<int, int> ans[100010];
  for (int i = 0; i <= n; i++) {
    sort(vp[i].begin(), vp[i].end());
    for (int j = 0; j < vp[i].size(); j++) {
      ans[vp[i][j].second] = {i, j + 1};
    }
  }

  for (int i = 0; i < m; i++) {
    cout << setfill('0') << right << setw(6) << ans[i].first;
    cout << setfill('0') << right << setw(6) << ans[i].second << endl;
  }
}


Measured memory_bytes: 7808
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main(void) {
	/*
	string str = "";
	cin >> str;
	bool suki = false;
	if (str.length() < 4) cout << "No" << endl;
	else
	{
		string subst = str.substr(0, 4);
		if (subst == "YAKI") suki = true;
		if (suki) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	*/
	int row, col, ans = 0;
	cin >> row >> col >> ans;
	bool isTrue = false;
	for (int i = 0; i < row; i++) {
		for (int j = 0; j <= col; j++) {
			if((i*j + (row - i)*(col - j)) == ans)
			{
				isTrue = true;
				break;
			}
			if (isTrue)break;
		}
	}
	if (isTrue) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main() {
  ll n; cin >> n;
  ll cnt = n;
  for (ll i = 1; i <= 1e6; ++i) {
    if (n % i == 0) {
      ll tmp = i + n / i - 2;
      if (tmp < cnt) cnt = tmp;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = input[0];
            var X = input[1];
            var city = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var dis = new int[N];
            for (int i = 0; i < N; i++) dis[i] = Math.Abs(X - city[i]);
            var ans = 0;
            if (N == 1) ans = dis[0];
            else ans = Gcd(dis[0], dis[1]);
            for (int i = 2; i < N; i++) ans = Gcd(ans, dis[i]);

            Console.WriteLine(ans);
        }

        public static int Gcd(int a, int b)
        {
            if (b == 0) return a;

            return Gcd(b, a % b);
        }

        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }
    }
}

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

using namespace std;

void solve()
{
	int h, w;
	cin >> h >> w;
	vector<long> ps(h), qs(w), accp(h+1), accq(w+1);
	for (int i = 0; i < h; i++) cin >> ps[i];
	for (int i = 0; i < w; i++) cin >> qs[i];
	long psum = 0, qsum = 0;
	sort(ps.begin(), ps.end());
	sort(qs.begin(), qs.end());
	for (int i = 0; i < h; i++)
	{
		psum += ps[i];
		accp[i + 1] = accp[i] + ps[i];
	}
	for (int i = 0; i < w; i++)
	{
		qsum += qs[i];
		accq[i + 1] = accq[i] + qs[i];
	}
	long res1 = psum+qsum*(h+1), res2 = qsum+psum*(w+1);
	for (int i = 0; i < h; i++)
	{
		int l = -1, r = w;
		while(l+1<r)
		{
			int m = (l + r) / 2;
			(ps[i] >= qs[m] ? l : r) = m;
		}
		res2 -= (l + 1) * ps[i] - accq[l + 1];
	}
	for (int i = 0; i < w; i++)
	{
		int l = -1, r = h;
		while(l+1<r)
		{
			int m = (l + r) / 2;
			(qs[i] >= ps[m] ? l : r) = m;
		}
		res1 -= (l + 1) * qs[i] - accp[l + 1];
	}
	cout << min(res1, res2) << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;
ll n, k;
ll a[100009], fact[100009],inv[100009], mod = (ll)1e9+7;
ll fp(ll b, ll p)
{
	if (p == 0)
		return 1;
	ll ans = fp(b, p / 2);
	ans = (ans * ans) % mod;
	if (p % 2)
		ans = (ans * (b % mod)) % mod;
	return ans;
}
void pre()
{
	ll e = 100005;
	fact[0] = inv[0] = 1;
	for (ll i = 1; i <= e; i++)
	{
		fact[i] = (i * fact[i - 1]) % mod;
		inv[i] = fp(fact[i], mod - 2);
	}
}
ll ncr(ll n, ll r)
{
	return ((fact[n] * inv[r]) % mod * inv[n - r]) % mod;
}
ll mx[100009], mn[100009];
int main()
{
	pre();
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n);
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (i >= k - 1)
			mx[i] = (a[i] * ncr(i, k - 1)) % mod;
		if (n - i - 1 >= k - 1 && n - i > 0)
			mn[i] = (a[i] * ncr(n - i - 1, k - 1)) % mod;
	}
	for (ll i = 0; i < n; i++)
		sum += mx[i] - mn[i];
	cout << sum % mod;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE( cout << #x" = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) TRACE( for(auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end()); } )
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() { ios::sync_with_stdio( false ); cin.tie( nullptr ); }

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod( ll a, ll b, ll mod = MOD) {
    ll res = 1; a %= mod; assert(b >= 0);
    for(;b;b>>=1) {
        if(b&1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
constexpr int mx = 64;

struct B {
    vector<long long> basis;
    B() { basis.assign(64, 0ll); }
    void insert_num(long long num) {
        for(int i = 0; i < mx; ++i) {
            if((num & 1ll << i) == 0) continue;
            if(!basis[i]) {
                basis[i] = num;
                return;
            }
            num ^= basis[i];
        }
    }
    bool contains(long long num) {
        for(int i = 0; i < mx; ++i) {
            if( (num & 1ll << i ) == 0 ) continue;
            if(basis[i] == 0) {
                return true;
            }
            num ^= basis[i];
        }
        return false;
    }
    void insert_vec(vector<long long> v) { for(auto& x : v) insert_num(x); }
};

int main() 
{
    buff();
    int t;
    cin >> t;
    while(t--)
    {
        
        int n;
        cin >> n;
        vector<long long> v(n);
        for(auto& x : v) cin >> x;
        string s;
        cin >> s;

        vector<B> dp(n + 1);
        bool win = false;
        for(int i = n - 1; i >= 0; --i) {
            if(s[i] == '0') {
                dp[i] = dp[i + 1];
                dp[i].insert_num(v[i]);
            }
            else {
                if(dp[i + 1].contains(v[i])) {
                    win = true;
                    break;
                }
                else dp[i] = dp[i + 1]; 
            }
        }
        if(win) cout << 1 << '\n';
        else cout << 0 << '\n';
    }
    return 0;
}



Measured memory_bytes: 3696
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;
//abc162
int main(){//言語C++を選択！！
    cin.tie(0);ios::sync_with_stdio(false);
    string s;
    cin>>s;
    bool ok=0;
    rep(i,3){
        if(s[i]-'0'==7) ok=1;
    }
    if(ok) cout<<"Yes";
    else cout<<"No";
}//言語C++を選択！！

//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

int A, B;

int main() {
    cin >> A >> B;
    if ((A-B)%2 == 0) {
        cout << (A+B)/2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	string s;
	cin >> s;
	int ret = 0;
	int cnt = 0;
	rep(i,s.size()){
		if( s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T' ){
			cnt++;
		} else {
			if( cnt > ret ){
				ret = cnt;
			}
			cnt = 0;
		}
	}
	if( cnt > ret ){
		ret = cnt;
	}
	cout << ret << endl;

	return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long int res = 0;
    int last = 0;
    for (int i = 0; i < n; i++) {
        if (v[i] < last) {
            res += last - v[i];
        } 
        last = max(last, v[i]);
    }
    cout << res << endl;
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,x,n) for(int i=x;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<29;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        vector<string> S(N);
        int ma=0;
        
        for(int i=0;i<N;i++){
            string A;cin>>A;
            S[i]+=A[0];
            for(int j=0;j<A.size()-1;j++){
                if(!(A[j]!='a'&&A[j]!='i'&&A[j]!='u'&&A[j]!='e'&&A[j]!='o')) S[i]+=A[j+1];
            }
            ma=max(ma,int(S[i].size()));
        }
        
        for(int i=1;i<=ma;i++){
            bool ok=true;
            for(int a=0;a<N;a++){
                for(int b=a+1;b<N;b++){
                    if(S[a].substr(0,min(i,int(S[a].size())))==S[b].substr(0,min(i,int(S[b].size())))) ok=false;
                }
            }
            if(ok){
                cout<<i<<endl;
                break;
            }
            
            if(i==ma) cout<<-1<<endl;
        }
    }
    
}



Measured memory_bytes: 3160
#include<stdio.h>

int main(void){
        int n, x, ans, b, i;
        scanf("%d", &n);
        scanf("%d", &x);
        int l[n];
        for(i=0; i<n; i++) scanf("%d", &l[i]);

        ans = 1, b = 0;
        for(i=0; i<n; i++){
                b += l[i];
                if (b<=x) ans++;
        }
        printf("%d\n", ans);
        return 0;
}

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

int main() {
  int n;
  cin>>n;
  vector<long long>B(n-1);
  for(int i=0;i<n-1;i++){
    cin>>B.at(i);
  }
  long long ans=B.at(0)+B.at(n-2);
  for(int i=0;i<n-2 ;i++){
    ans=ans+min(B.at(i),B.at(i+1));
  }
  cout<<ans<< endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin >> a >> b >> c >> d;
   if((c + b - 1) / b <= (a + d - 1) / d){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }
   return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PII pair<int,int>
#define MP make_pair
#define PB push_back
typedef long long LL;
const LL MOD = 998244353;
const int N = 100010;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,m,x,y,out[N],a[N],v[N],cnt=0;
set<int> g[N];

void process(int x){
	for(auto u:g[x]){
		if(out[x]%2){
			++out[x];
			cout<<x<<" "<<u<<endl;
		}else{
			++out[u];
			cout<<u<<" "<<x<<endl;
		}
		g[u].erase(x);
	}
	g[x].clear();
}

void dfs(int x){
	v[x]=true;
	a[++cnt]=x;
	for(auto u:g[x])if(!v[u])dfs(u);
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	cin>>n>>m;
	if(m%2){
		cout<<-1<<endl;
		return 0;
	}
	rep(i,1,m)cin>>x>>y,g[x].insert(y),g[y].insert(x);
	
	memset(v,0,sizeof v);
	dfs(1);
	rrep(i,n,1){
		process(a[i]);
	}
	return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;

const int64_t INF = 1LL << 61;
int64_t N, K;
vector<int64_t> A;

int64_t solve()
{
  sort(A.begin(), A.end());
  int64_t left = -INF, right = INF;
  while (right - left > 1)
  {
    int64_t x = (left + right) / 2;
    int64_t S = 0, T = 0;
    for (int i = 0; i < N; ++i)
    {
      if (A[i] > 0)
      {
        int l2 = -1, r2 = N;
        while (r2 - l2 > 1)
        {
          int m = (l2 + r2) / 2;
          if (A[i] * A[m] <= x)
            l2 = m;
          else
            r2 = m;
        }
        S += r2;
      }
      else if (A[i] < 0)
      {
        int l2 = -1, r2 = N;
        while (r2 - l2 > 1)
        {
          int m = (l2 + r2) / 2;
          if (A[i] * A[m] <= x)
            r2 = m;
          else
            l2 = m;
        }
        S += N - r2;
      }
      else if (x >= 0)
        S += N;
      if (A[i] * A[i] <= x)
        ++T;
    }
    int64_t num = (S - T) / 2;
    if (num >= K)
      right = x;
    else
      left = x;
  }
  return right;
}

int main()
{
  cin >> N >> K;
  A.resize(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  cout << solve() << endl;
}

Measured memory_bytes: 4820
#include "bits/stdc++.h"
using namespace std;
#define maxn 501
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define pb push_back
#define mp make_pair
#define mod 1000000007

int n, m, k, x, y, z;
vector<pair<int, int>> a;
int b[maxn * maxn];
void solve(){
	cin >> n;
	for (int i = 1; i <= n; ++i){
		cin >> x;
		a.pb(mp(x, i));
	}
	sort(a.begin(), a.end()); 
	int l = 0;
	rep(i, n){
		int pos = a[i].first;
		int num = a[i].second;
		if (b[pos] > 0){
			cout << "No";
			return;
		}
		b[pos] = num;
		rep(_, num - 1){
			while (b[++l] > 0);
			b[l] = num;
		}		
		if (l > pos){
			cout << "No";
			return;
		}
	}
	int r = n*n + 1;
	reverse(a.begin(), a.end());
	for (auto p : a){
		int pos = p.first;
		int num = p.second;
		rep(_, n - num){
			while (r >=0 && b[--r] > 0) {}
			if (r == 0){
				cout << "No";
				return;
			}
			b[r] = num;
		}
		//cout << pos << ' ' << num << ' ' << n - num << ' ' << r << endl;
		if (r < pos){
			cout << "No";
			return;
		}
	}
	cout << "Yes" << endl;
	for (int i = 1; i <= n*n; ++i){
		cout << b[i] << ' ';
	}
}

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(0);
    solve();
}

Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var cost = Console.ReadLine().Count(s => s.ToString() == "o") * 100;
            Console.WriteLine(cost + 700);
        }
    }
}


Measured memory_bytes: 11220
def d():
    n, a, b = map(int, input().split())
    l = [int(input()) for _ in range(n)]
    d = a - b

    left = 0
    right = 10**9

    def is_ok(t):
        return sum(map(lambda x: max(0, x - b*t + d-1) // d, l)) <= t

    while abs(left - right) > 1:
        now = (left + right) // 2
        if is_ok(now):
            right = now
        else:
            left = now

    print((right, left)[is_ok(left)])

d()

Measured memory_bytes: 7072
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.buffer.readline

    N = int(input())
    ans = 0
    for i in range(1, N+1):
        ans += i * (N-i+1)
    for _ in range(N-1):
        a, b = map(int, input().split())
        if a > b:
            a, b = b, a
        ans -= a * (N-b+1)
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int N, W; cin >> N >> W;
  int w[N],v[N]; REP(i,N) cin >> w[i] >> v[i];

  ll dp[N+1][W+1];
  REP(i,N+1) REP(j,W+1) dp[i][j] = 0;

  REP(i,N) REP(j,W+1) {
    dp[i+1][j] = dp[i][j];
    if (j-w[i] >= 0) {
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]] + v[i]);
    }
  }
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 79104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int H = sc.nextInt();
		int L = sc.nextInt();
		int[] t = new int[N];
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			t[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}
		int B = 0, money = 0;
		boolean flag = true;
		while (flag) {
			for (int i = 0; i < N; i++) {
				if (T == L) {
					if (t[i] != 0) {
						B = i;
						flag = false;
						break;
					} else {
						if (h[i] == 0) {
							B = i;
							flag = false;
							break;
						}
						if ((money + 10) / 10 > T) {
							B = i;
							flag = false;
							break;
						}
						h[i]--;
						H++;
						t[i] += (money + 10) / 10;
						T -= (money + 10) / 10;
						money = 0;
						continue;
					}
				} else {
					if (t[i] != 0) {
						t[i]--;
						T++;
						money += 10;
						if (money == 90) {
							money = 0;
						}
						continue;
					} else {
						if (h[i] == 0) {
							B = i;
							flag = false;
							break;
						}
						if ((money + 10) / 10 > T) {
							B = i;
							flag = false;
							break;
						}
						h[i]--;
						H++;
						t[i] += (money + 10) / 10;
						T -= (money + 10) / 10;
						money = 0;
						continue;
					}
				}
			}
		}

		System.out.println(B + 1);
		sc.close();
	}
}

Measured memory_bytes: 26512
import java.util.Scanner
import java.io.PrintWriter

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val pw = new PrintWriter(System.out)

    var h: Long = sc.nextLong()
    var ans: Long = 0
    var add: Long = 1;
    while (h > 0) {
      ans += add;
      h /= 2;
      add *= 2;
    }
    pw.println(ans)

    pw.flush()
  }
}

Measured memory_bytes: 25672
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>

#define mii map<int,int>
#define int long long
#define inf 2000000000000000000
#define re(i,x,n) for(i=x;i<=n;i++)

using namespace std;
#define int long long
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
// struct edge
// {
// 	int a;
// 	int b;
// 	int w;
// };
// edge ar[100000];
// int par[10001];
// bool comp(edge a, edge b)
// {
// 	if (a.w < b.w)
// 		return true;
// 	else
// 		return false;
// }
// int find(int a)
// {
// 	if (par[a] == -1)
// 		return a;
// 	else
// 		return par[a] = find(par[a]);
// }
// void merge(int a, int b)
// {
// 	par[a] = b;
// }
//

int32_t main()
{

	

	int n;
	cin >> n;
	if (n % 1000 == 0)
		cout << "0";
	else if (n < 1000)
		cout << 1000 - n;
	else
	{
		cout << 1000 - (n % 1000);
	}

}


Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
const ll infl = 1LL << 60;
const int inf = 1 << 30;

struct City {
    int p, y, name;
};

int main() {
    int N, M; cin >> N >> M;
    vector<City> cities(M);
    for (int i = 0; i < M; ++i) {
        int p, y; cin >> p >> y;
        cities[i].name = i;
        cities[i].p = p;
        cities[i].y = y;
    }
    sort(cities.begin(), cities.end(), [](City a, City b) {
        return a.p < b.p || (a.p == b.p && a.y < b.y);
    });
    vector<string> ids(M);
    int prevP = -1;
    int k;
    for (int i = 0; i < M; ++i) {
        if (prevP != cities[i].p) {
            prevP = cities[i].p;
            k = 1;
        }
        ostringstream ss;
        ss << setw(6) << setfill('0') << prevP << setw(6) << setfill('0') << k;
        ids[cities[i].name] = ss.str();
        ++k;
    }

    for (int i = 0; i < M; ++i) {
        cout << ids[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5624
class Facts

  def initialize(mod=10**9+7, n_max=1)
    @mod = mod
    @n_max = n_max
    @fact = [1, 1]
    @inv = [0,1]
    @factinv = [1, 1]
    setup_table(n_max) if 1 < @n_max
  end

  def cmb(n,r)
    return 0 if r < 0 || n < r
    setup_table(n) if @n_max < n
    @fact[n] * (@factinv[r] * @factinv[n-r] % @mod) % @mod
  end

  def factorial(n)
    setup_table(n) if @n_max < n
    @fact[n]
  end

  def prm(n,k)
    setup_table(n) if @n_max < n
    @fact[n] * @factinv[n-k] % @mod
  end

  private
    # O(t)
    def setup_table(t)
      (@n_max+1).upto(t) do |i|
        @fact.push( @fact[-1] * i % @mod )
        @inv.push( -@inv[@mod % i] * (@mod / i) % @mod )
        @factinv.push( @factinv[-1] * @inv[-1] % @mod )
      end
      @n_max = t
    end
end

mod = 998244353

n, m, k = gets.to_s.split.map{|e|e.to_i}

ans = 0
f = Facts.new(mod)
t = m * (m-1).pow(n-1-k, mod)

k.downto(0) do |i|
  ans += f.cmb(n-1, i) * t % mod
  t = t * (m-1) % mod
end

puts ans % mod

Measured memory_bytes: 19364
import scala.io

object Main extends App {
  val lines = io.Source.stdin.getLines
  val Array(n, m) = lines.next().split(" ").map(_.toInt)

  val twoFromN = if (n > 1) {
    n * (n - 1) / 2    
  } else 0
  val twoFromM = if (m > 1) {
    m * (m - 1) / 2
  } else 0
  
  println(twoFromN + twoFromM)
}


Measured memory_bytes: 27328
#include<stdio.h>
int main(void){
    int a, b, t;
    while(1){
        scanf("%d %d", &a, &b);

        if(a == 0 && b == 0){return 0;}
        else if(b < a){printf("%d %d\n", b, a);}
        else{printf("%d %d\n", a, b);}
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  int t[N+1],x[N+1],y[N+1],p[N+1];
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 1; i < N + 1; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  bool can = true;
  for(int i = 0; i < N; i++) {
   if( (t[i+1] - t[i]) % 2 != abs(( x[i+1] + y[i+1] )- ( x[i] + y[i] )) % 2 ||
      (abs(x[i+1]) + abs(y[i+1])) - (abs(x[i]) + abs(y[i])) > (t[i+1] - t[i]) ) {
     can = false;
     break;
   }
  }
  if(can) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" <<endl; 
  }
}

Measured memory_bytes: 1408
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	VI N(3);
	while(cin>>N[0]>>N[1]>>N[2]) {
		sort(ALL(N));
		ll ans=INF;
		do{
			ll v=N[0]%2==0?0:N[1]*N[2];
			minUpdate(ans,v);
		}while(next_permutation(ALL(N)));
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}


bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N)
{
    vector<ll> F1(3);
    F1[1] = 1;
    F1[2] = 1;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = 1, T[2][2] = 1;
    if (N == 1)
        return 1;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]) ;
    return res;
}
ll bit[10005]={0};
ll sum(ll i)
{
    ll ans=0;
    while(i>0)
    {
        ans+=bit[i];
        i-=(i&(-i));
    }
    return ans;
}
ll update(ll n,ll i)
{
    while(i<=n)
    {
        bit[i]+=1;
        i+=(i&(-i));
    }
}
//int C[10005][1];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    string s;
    cin>>s;
    ll ans=0;
    for(char c:s) if(c=='2') ans++;
    cout<<ans;
}
   //C[10005][10005];
    

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin >> n;
	map<string, int> mp;
	for (int i = 0; i < n; ++i) {
		string s; cin >> s;
		mp[s]++;
	}
	cout << "AC x " << mp["AC"] << "\n";
	cout << "WA x " << mp["WA"] << "\n";
	cout << "TLE x " << mp["TLE"] << "\n";
	cout << "RE x " << mp["RE"] << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <array>

struct Node {
    int parent = -1;
    int left = -1;
    int right = -1;
    int sibling = -1;
    int degree = 0;
    int depth = 0;
    int height = 0;
    std::string type = "internal node";
};

void showNodes(std::array<Node, 25> &Nodes, int num) {
    for (int i=0; i<num; ++i) {
        std::cout << "node " << i << ": parent = " << Nodes[i].parent << ", sibling = " << Nodes[i].sibling << ", degree = " << Nodes[i].degree << ", depth = " << Nodes[i].depth
            << ", height = " << Nodes[i].height << ", " << Nodes[i].type << std::endl;
    }
}

void setDepth(std::array<Node, 25> &Nodes, int idx, int depth) {
    Nodes[idx].depth = depth;
    if (Nodes[idx].left != -1) setDepth(Nodes, Nodes[idx].left, depth+1);
    if (Nodes[idx].right != -1) setDepth(Nodes, Nodes[idx].right, depth+1);
}

int calcHeight(std::array<Node, 25> &Nodes, int idx, int height) {
    if (idx == -1) return height-1;
    return std::max(calcHeight(Nodes, Nodes[idx].left, height+1), calcHeight(Nodes, Nodes[idx].right, height+1));
}

int main() {
    int N, id, left, right;
    std::array<Node, 25> Nodes;
    
    std::cin >> N;
    
    for (int i=0; i<N; ++i) {
        std::cin >> id >> left >> right;
        if (left != -1) {
            Nodes[id].degree += 1;
            Nodes[id].left = left;
            Nodes[Nodes[id].left].sibling = right;
            Nodes[Nodes[id].left].parent = id;
        }
        if (right != -1) {
            Nodes[id].degree += 1;
            Nodes[id].right = right;
            Nodes[Nodes[id].right].sibling = left;
            Nodes[Nodes[id].right].parent = id;
        }
        if (left==-1 && right==-1) {
            Nodes[id].type = "leaf";
        }
    }
    
    // search root
    int root = 0;
    for (int i=0; i<N; ++i) {
        if (Nodes[i].parent == -1) {
            Nodes[i].type = "root";
            root = i;
        }
        Nodes[i].height = calcHeight(Nodes, i, 0);
    }
    
    setDepth(Nodes, root, 0);
    
    showNodes(Nodes, N);
}



Measured memory_bytes: 3176
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

if(input[0] == "Sunny"){
	console.log("Cloudy");
}else if(input[0] == "Cloudy"){
	console.log("Rainy");
} else {
	console.log("Sunny");
}

Measured memory_bytes: 7372
#include <iostream>
#include<iomanip>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a;
    cin>>b;
    int d=a/b;
    int r=a%b;
    double f=double(a)/double(b);
    cout<<d;
    cout<<" ";
    cout<<r;
    cout<<" ";
    cout<< fixed<<setprecision(5)<<f;
    cout<<endl;
   
}



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

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


Measured memory_bytes: 3620
fn main() {
    let s: String = read();
    println!("{}", s.replace(",", " "));
}

fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
int main() {
	char angka[10];
	scanf("%s", &angka);
	int ada = 0;

	for(int i = 0 ; i < strlen(angka); i++) {
		if (angka[i] == '7'){
			ada = 1;
		}
	}
	if (ada ==1){
		printf("Yes");
		
	}
	else {
		printf("No");
	}
	
	puts(" ");
	
	
	return 0;
}

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

int main(){
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0;i < S.size();++i) {
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
			int j = i;
			while (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')j++;
			if (j - i > ans)ans = j - i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>

#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;

#define N  1000050

ll int expo(ll int base,ll int exponent,ll int mod){
    ll int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

ll int spf[N];

void sss()
{
	for(ll int i=1;i<N;i++) spf[i]=i;
	for(ll int i=2;i<N;i++)
	{
		if(spf[i]==i)
		{
			for(ll int j=2*i;j<N;j+=i)
			{
				if(spf[j]==j) 
				{
					spf[j]=i;
				}
			}
		}
	}
}

mii fac(ll int n)
{
	mii ma;
	while(n!=1)
	{
		ll int tmp=spf[n];
		while(n%tmp==0)
		{
			ma[tmp]++;
			n/=tmp;
		}
	}
	return ma;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{
		sss();
		ll int n;
		cin>>n;
		ll int arr[n+1];
		for(ll int i=1;i<=n;i++) cin>>arr[i];
		ll int ans=0;
		for(ll int i=1;i<=n;i++) ans=(ans+expo(arr[i],hell-2,hell))%hell;
		mii lcm;
		for(ll int i=1;i<=n;i++)
		{
			mii ma=fac(arr[i]);
			for(auto it:ma)
			{
				lcm[it.F]=max(it.S,lcm[it.F]);
			}
		}
		for(auto it:lcm) ans=(ans*expo(it.F,it.S,hell))%hell;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 8832
using System;
using System.Linq;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            var ABCDEF = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var A = ABCDEF[0];
            var B = ABCDEF[1];
            var C = ABCDEF[2];
            var D = ABCDEF[3];
            var E = ABCDEF[4];
            var F = ABCDEF[5];

            var sw = 0;
            var s = 0;
            var maxNoudo = -1d;
            for (var numA = 0; numA * 100 * A <= F; numA++)
            {
                var maxWater = F - 100 * A * numA;
                for (var numB = 0; numB * 100 * B <= maxWater; numB++)
                {
                    var water = 100 * A * numA + 100 * B * numB;
                    var maxSuger = Math.Min(F - water, water / 100 * E);
                    for (var numC = 0; numC * C <= maxSuger; numC++)
                    {
                        for (var numD = 0; numD * D <= maxSuger - C * numC; numD++)
                        {
                            var sugar = C * numC + D * numD;
                            var waterSugar = water + sugar;
                            var noudo = 100d * sugar / waterSugar;

                            if (noudo > maxNoudo)
                            {
                                sw = waterSugar;
                                s = sugar;
                                maxNoudo = noudo;
                            }
                        }
                    }
                }
            }

            var output = sw + " " + s;
            Console.WriteLine(output);
        }

        static int NumberOfDigits(long x)
        {
            if (x < 10) return 1;

            var result = 0;
            while (x > 0)
            {
                result++;
                x /= 10;
            }

            return result;
        }

        static int SumOfDigits(int x)
        {
            var sum = 0;
            while (x > 0)
            {
                sum += x % 10;
                x /= 10;
            }

            return sum;
        }
    }
}


Measured memory_bytes: 13268
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<Integer> one = nextIntArray();
		ArrayList<Integer> two = nextIntArray();
		int H = one.get(0);
		int W = one.get(1);
		int sH = two.get(0);
		int sW = two.get(1);
		myout((H - sH) * (W - sW));
	}
	//Method addition frame start

static long gcd(long m, long n) {return n != 0 ? gcd(n, m % n) : m;}

	//Method addition frame end
}


Measured memory_bytes: 32936
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define  all(v)     (v).begin(),(v).end()
#define  rall(v)    (v).rbegin(),(v).rend()
#define  pb         push_back
#define  eb         emplace_back
#define  mp         make_pair
#define  ff         first
#define  ss         second
#define  pf         push_front
#define  bs         binary_search
#define  lb         lower_bound
#define  ub         upper_bound
#define  dec(x)   fixed<<setprecision(x)
#define  lcm(a,b)   (a*b/__gcd(a,b))
const ll inf=LLONG_MAX;
const ll mod=1e9+7;
const ld pi=acos(-1);
set<ll>v[200005];
bool vis[200005]={false};
void dfs(ll n,ll& x){
    vis[n]=true;
    for(auto i: v[n]){
        if(!vis[i]){
            ++x;
            dfs(i,x);
        }
    }
}      
void solution(){
    ll n,m;
    cin>>n>>m;
    while(m--){
        ll x,y;
        cin>>x>>y;
        v[x].insert(y);
        v[y].insert(x);
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll x=1;
        if(!vis[i]){
            dfs(i,x);
        }
        ans=max(ans,x);
    }
    cout<<ans;

    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll t;
    t=1;
    //cin>>t;
    while(t--){
        solution();
        cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 41356