akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    max_num = max(num_list)

    num_list.remove(max_num)

    sum_list = sum(num_list)

    if sum_list > max_num:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <cfenv>
#include <cinttypes>
#include <cstdint>
#endif
#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>
#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <forward_list>
#include <initializer_list>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
#if __cplusplus >= 201402L
#include <shared_mutex>
#endif

#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;

const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};

ll gcd(ll x,ll y){
    x = x%y;
    return x == 0 ? y : gcd(y,x);
}
ll lcm(ll x, ll y){
    return x*y/gcd(x,y);
}



int main(){
 
    ll a,b;
    ll c,d;
    cin >> a >> b >> c >> d;
    ll e = lcm(c,d);
    ll tc;
    tc = b/c - (a-1)/c;
    ll td;
    td = b/d - (a-1)/d;
    ll tt;
    tt = b/e - (a-1)/e;
    ll ans;
    ans = b-a+1 - tc - td + tt;
    cout << ans << endl;



    return 0;
}


Measured memory_bytes: 3160
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
using namespace std;

typedef pair<int,int> pii;

int N;
pii rw[1001];
bool dp[1001];
int r[1001], w[1001];

int main() {
    while(cin>>N, N) {
        for (int i=0; i<N; ++i) {
            int a,b; cin>>a>>b;
            rw[i] = make_pair(a,b);
        }
        sort(rw, rw+N, greater<pii>());
        for (int i=0; i<N; ++i) r[i] = rw[i].first, w[i] = rw[i].second;

        int sum = 0;
        for (int i=1; i<N; ++i) sum += r[i];
        if (sum >= r[0]) {
            sum += r[0];
            for (int i=0; i<N; ++i) sum += w[i];
            cout<<sum<<endl;
            continue;
        }

        int rem = r[0] - sum;
        memset(dp, false, sizeof(dp));
        dp[0] = true;
        for (int i=1; i<N; ++i) {
            for (int p=rem; p>=0; --p)
                if (dp[p] && p + w[i] <= rem) dp[p+w[i]] = true;
        }

        int mx = -1;
        for (int p=rem; p>=0; --p)
            if (dp[p]) { mx = p; break; }

        int ans = r[0] * 2;
        for (int i=0; i<N; ++i) ans += w[i];
        ans -= mx;

        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <algorithm>
#include <iostream>

#define REP(i, n) for(int i=0;i<n;i++)
#define ll long long
#define INF 999999999
#define pb(a) push_back(a)

int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

using namespace std;

int main(){

  int h, w;
  char s[51][51];

  scanf("%d %d", &h, &w);
  REP(i, h){
    scanf("%s", s[i]);
  }

  REP(i, h){
    REP(j, w){
      if(s[i][j] == '.'){
        int num = 0;
        REP(k, 8){
            if(i + dy[k] < 0 || i + dy[k] >= h || j + dx[k] >= w || j + dx[k] < 0)
              continue;

            if(s[i + dy[k]][j + dx[k]] == '#'){
              num++;
            }
        }
        s[i][j] = '0' + num;
      }
    } 
  }

  REP(i, h){
    printf("%s\n", s[i]);
  }

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
int n;
int s[505],c[505],f[505]; 
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<n;++i) cin>>c[i]>>s[i]>>f[i];
    for (int i=1;i<n;++i){
    	int res=0;
    	for (int j=i;j<n;++j){
    		if (res<s[j]) res=s[j];
    		while(res%f[j]) ++res;
			res+=c[j];
		}
		cout<<res<<endl;
	}
	cout<<0<<endl;
    return 0; 
}

Measured memory_bytes: 256
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	long long int X, Y, A, B, C,  ans = 0; cin >> X >> Y >> A >> B >> C;
	vector<ll>a(A), b(B);
	rep(i, A) {
		cin >> a[(ll)i];
	}
	sort(a.begin(), a.end(), greater<ll>());
    rep(i, B) {
		cin >> b[(ll)i];
	}
	sort(b.begin(), b.end(), greater<ll>());
	priority_queue<ll, vector<ll>>W;

	rep(i, X) {
		W.push(a[(ll)i]);
    }
	rep(i, Y) {
		W.push(b[(ll)i]);
	}
	rep(i, C) {
		long long int c; cin >> c;
		W.push(c);
	}
	rep(i, X+Y) {
		ans += W.top(); W.pop();
	}


	
	
	cout << ans << endl;
}































    





Measured memory_bytes: 7664
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long 
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
 // #define forn(i, n) for (int i = 0; i < int(n); i++)
  
  int32_t main()
  { 
     #ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
     #endif
    
    IOS
    int n;
    cin >> n;
    vector<int> v(n,0);
    int x;
    for(int i=0;i<n-1;i++)
    {
      cin>>x;
      v[x-1]++;
    }
    for(int i=0;i<n;i++)
    { cout<<v[i]<<"\n";}
    return 0;
   
}



Measured memory_bytes: 4732
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        FMitsui solver = new FMitsui();
        solver.solve(1, in, out);
        out.close();
    }

    static class FMitsui {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long t1 = in.nextLong();
            long t2 = in.nextLong();
            long a1 = in.nextLong();
            long a2 = in.nextLong();
            long b1 = in.nextLong();
            long b2 = in.nextLong();
            long suma1 = a1 * t1;
            long suma2 = a2 * t2;
            long sumb1 = b1 * t1;
            long sumb2 = b2 * t2;
            long asum = suma1 + suma2;
            long bsum = sumb1 + sumb2;
            if (asum > bsum) {
                if (suma1 > sumb1) {
                    out.println("0");
                } else {
                    long dif = asum - bsum;
                    long tmpdif = sumb1 - suma1;
                    if (tmpdif % dif == 0) {
                        out.println(tmpdif / dif * 2);
                    } else {
                        out.println(tmpdif / dif * 2 + 1);
                    }
                }
            }
            if (asum < bsum) {
                if (suma1 < sumb1) {
                    out.println("0");
                } else {
                    // a1 > b1 && a2 < b2
                    long diff = bsum - asum;
                    long tmpdiff = suma1 - sumb1;
                    if (tmpdiff % diff == 0) {
                        out.println(tmpdiff / diff * 2);
                    } else {
                        out.println(tmpdiff / diff * 2 + 1);
                    }
                }
            }
            if (asum == bsum) {
                out.println("infinity");
            }
        }

    }
}



Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
using namespace std;
int n,a[1<<17],m,d;
main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>m)m=a[i];
	}
	d=-1;
	for(int i=0;i<n;i++)
	{
		if(a[i]!=m)
		{
			if(abs(m-2*a[i])<abs(m-2*d))d=a[i];
		}
	}
	cout<<m<<endl<<d<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define ff               first
#define ss               second
#define pb               push_back
#define all(x)           (x).begin(), (x).end()
#define mem0(x)          memset(x, 0, sizeof (x))
#define mem1(x)          memset(x, -1, sizeof (x))

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector <ii> vii;
typedef vector<vii> vvii;
typedef vector <ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int T=1, n;
    while (T--){
        cin >> n;
        ll ans = 1;
        ll aux = 1;
        ll aux2 = 1;
        int mod = 1e9+7;
        if (n == 1){
            cout << "0\n";
            return 0;
        }
        for (int i = 0; i < n; ++i) {
            ans *= 10ll;
            aux *= 8ll;
            aux2 *= 9ll;
            ans %=mod;
            aux %=mod;
            aux2 %=mod;
        }
        cout << (ans + aux - 2*aux2 + 2*mod)%mod << "\n";
    }
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
typedef long long ll;
typedef pair<int, int> pii;
              //999999999
const int inf=1010001000;
const ll  INF=1001000100010001000;
const int mod=(int)1e9+7;
int n,c;
int cou;
bool ch(ll s){
    cou++;
    string t=to_string(s);
    //vector<bool>cv(3,0);
    ll ccv=1;
    rep(i,0,t.size()){
        if(t.at(i)=='3')ccv*=3;//cv.at(0)=true;
        if(t.at(i)=='5')ccv*=5;//cv.at(1)=true;
        if(t.at(i)=='7')ccv*=7;//cv.at(2)=true;
    }
    bool cc=false;
    if(ccv%3==0 and ccv%5==0 and ccv%7==0)cc=true;//rep(i,0,3){
    //    if(cv.at(i)==0) cc= false;
    //}
    if(cc) return true;
    else return false;
}
void dfs(ll s){
    if(357<=s and s<=n){
        if(ch(s)) c++;
    }
    if(s>=n) return;
    dfs(s*10+7);
    dfs(s*10+5);
    dfs(s*10+3);
}
int main(){
    cin>>n;
    c=0;
    cou=0;
    dfs(0);
    cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256
a = []
for i in range(5):
    a.append(int(input()))
k = int(input())
is_true = True
for i in range(len(a)):
    for j in range(i + 1, len(a)):
        if a[j] - a[i] > k:
            is_true = False
            break
if is_true:
    print("Yay!")
else:
    print(":(")

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

using namespace std;

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

  int n, m;
  cin >> n >> m;
  string sn[n], sm[m];
  for (int i = 0; i < n; i++) {
    cin >> sn[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> sm[i];
  }

  bool a = false;
  for (int i = 0; i + m <= n; i++) {
    for (int j = 0; j + m <= n; j++) {
      bool b = true;
      for (int k = 0; k < m; k++) {
        for (int l = 0; l < m; l++) {
          if (sn[i + k][j + l] != sm[k][l]) b = false;
        }
      }
      if (b) a = true;
    }
  }
  puts(a ? "Yes\n" : "No\n");
  return 0;
}

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

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

//#define _USE_MATH_DEFINES
//#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>
#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;


const i64 MAXN = 300004;

i64 n, h;
i64 a[MAXN];
i64 b[MAXN];
i64 dp[MAXN];

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
    cin >> h >> n;

    for (i64 i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    for (i64 i = 1; i <= h; i++) {
        dp[i] = inf;
    }

    i64 R = inf;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = 0; j < h; j++) {
            if (j + a[i] >= h) {
                R = min(R, dp[j] + b[i]);
            }
            else {
                dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
            }
        }
    }

    cout << R << endl;


    return 0;
}

Measured memory_bytes: 4480
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    string s;
    cin >> s;
    if(s[3]==s[2]&&s[4]==s[5]) cout << "Yes" ;
    else cout << "No" ;
    
    return 0;
}

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

int main() {
  string s,t,u,v;
  cin >> s >> t >> u >> v;
  
  string w = s+t+u+v;
  
  int n=0;
  int o=0;
  int p=0;
  int q=0;
  
  for(int i=0;i<4;i++){
    if(w.at(i)=='1'){
      n++;
    }
    
    else if(w.at(i)=='9'){
      o++;
    }
    
    else if(w.at(i)=='7'){
      p++;
    }
    
    else if(w.at(i)=='4'){
      q++;
    }
  }
  
  if(n==1&&o==1&&p==1&&q==1){
    cout << "YES" << endl;
  }
  
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <climits>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n,r,k,t,p,s,d,v;
	int wf[100][100];
	rep(i,100)rep(j,100)wf[i][j] = 1<<21;

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> r >> k;
		r--;
		for(int j=0;j<k;j++){
			cin >> t;
			t--;
			wf[r][t] = 1;
		}
	}
	rep(k,n)rep(i,n)rep(j,n)wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
	
	cin >> p;
	for(int i=0;i<p;i++){
		cin >> s >> d >> v;
		s--;d--;
		if(v > wf[s][d] )cout << wf[s][d]+1 << endl;
		else cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
# AOJ 0522: JOI and IOI
# Python3 2018.6.30 bal4u

while True:
	try: s = input()
	except: break
	c = [s[i:i+3] for i in range(len(s)-2)]
	print(*[c.count(a) for a in ["JOI", "IOI"]], sep='\n')


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

int main() {
	string S;
	cin>>S;
	int len=S.length();
	if(S.length()%2==0){
		int count=0;
		string tmp1="",tmp2="";
		for(int i=0; i<=(len/2)-2;i++) tmp1+=S[i];
		for(int i=len-1; i>=(len/2)+1; i--) tmp2+=S[i];
		for(int i=0; i<tmp1.size(); i++){
			if(tmp1[i]!=tmp2[i]) count++;
		}
		if(S[len*0.5]!=S[(len*0.5)-1]) count++;
		cout<<count<<endl;
		return 0;
		}
		
	else{
		int count=0;
		string tmp1="",tmp2="";
		for(int i=0; i<len/2; i++) tmp1+=S[i];
		for(int i=len-1; i>len/2; i--) tmp2+=S[i];
		for(int i=0; i<tmp1.size(); i++){
			if(tmp1[i]!=tmp2[i]) count++;
		}
		cout<<count<<endl;
	}
}
		
		
		
		
		
	
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MaxN = 200003;
int n;char str[MaxN];
int f[MaxN],dp[MaxN];
map<int,int> mn;

int main() {
    scanf("%s",str+1);
    n=strlen(str+1);
    for (int i=1;i<=n;++i) {
        f[i]=f[i-1]^(1<<(str[i]-'a'));
    }
    for (int i=1;i<=n;++i) mn[f[i]]=0x7f7f7f7f;
    mn[0]=0;
    for (int i=1;i<=n;++i) {
        dp[i]=0x7f7f7f7f;
        if (mn.count(f[i])) dp[i]=min(dp[i],mn[f[i]]+1);
        for (int j=0;j<26;++j) {
            int t=f[i]^(1<<j);
            if (mn.count(t)) dp[i]=min(dp[i],mn[t]+1);
        }
        mn[f[i]]=min(mn[f[i]],dp[i]);
    }
    printf("%d\n",dp[n]);
    return 0;
}

Measured memory_bytes: 13312
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
using namespace std;

string itos(int n) {
	ostringstream os;
	os << n;
	return os.str();
}

string ope(const string& s) {
	string res;
	for(int i = 0; i < s.size();) {
		int len = 1;
		while(i + len < s.size() && s[i] == s[i + len]) ++len;

		res += itos(len);
		res += s[i];

		i += len;
	}

	return res;
}

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

	for(int n; cin >> n, n;) {
		string s;
		cin >> s;

		for(int i = 0; i < n; ++i)
			s = ope(s);

		cout << s << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int R, S, P;
    cin >> R >> S >> P;
    map<char, int> mp;
    mp['r'] = P, mp['s'] = R, mp['p'] = S;
    string t;
    cin >> t;
    vector<vector<char>> v(k);
    rep(i,n) {
        v[i%k].push_back(t[i]);
    }
    int ans = 0;
    rep(i,k) {
        ans += mp[v[i][0]];
        char banned = v[i][0];
        for (int j = 1; j < v[i].size(); j++) {
            if (v[i][j] != banned) {
                ans += mp[v[i][j]];
                banned = v[i][j];
            }
            else {
                banned = '-';
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5120
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H, W = MAP()
a = [list(input()) for _ in range(H)]

a = [s for s in a if s != ["."]*W]

b = [[0]*len(a) for _ in range(len(a[0]))]
for i in range(len(a)):
	for j in range(len(a[0])):
		b[j][i] = a[i][j]

b = [s for s in b if s != ["."]*len(b[0])]

c = [[0]*len(b) for _ in range(len(b[0]))]

for i in range(len(b)):
	for j in range(len(b[0])):
		c[j][i] = b[i][j]

for s in c:
	print("".join(s))


Measured memory_bytes: 4148
// #pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define IMAX 2147483647
#define LMAX 9223372036854775807
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);
#define fou(i,a,n) for(int i=a;i<n;i++)
#define fod(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(n) fou(_,0,n)
#define tra(a,x) for(auto& a : x)
#define elif(c) else if(c)
#define VI vector<int>
#define VD vector<double>
#define VC vector<char>
#define VS vector<string>
#define VVI vector<VI>
#define VVD vector<VD>
#define VVC vector<VC>
#define VVS vector<VS>
#define PII pair<int,int>
#define PIII pair<int,PII>
#define VPII vector<PII>
#define VPIII vector<PIII>
#define emb emplace_back
#define pub push_back
#define pob pop_back
#define mp make_pair
#define mp3(a,b,c) mp(a,mp(b,c))
#define fi first
#define se second
#define th se.se
#define si(vec) ((int)(vec).size())
#define all(vec) vec.begin(),vec.end()
#define lla(vec) vec.rbegin(),vec.rend()
#define range(vec,x,y) vec.begin()+x,vec.begin()+y
#define sortup(vec) sort(all(vec))
#define sortdown(vec) sort(lla(vec))
#define rotateleft(vec,n) rotate(a.begin(),a.begin()+n,a.end())
#define rotateright(vec,n) rotate(a.rbegin(),a.rbegin()+n,a.rend())
#define eraseif(vec,condition_VAR) vec.erase(remove_if(all(vec),[&](auto VAR){return condition_VAR;}),vec.end())
#define countif(vec,condition_VAR) count_if(all(vec),[&](auto VAR){return condition_VAR;})
#define replaceif(vec,condition_VAR,n) replace_if(all(vec),[&](auto VAR){return condition_VAR;},n)
#define erase_unique(vec) vec.erase(unique(all(vec)),vec.end())
#define calcvec(vec,calc_VAR) for_each(all(vec),[&](auto&VAR){VAR=calc_VAR;});
#define calc2vec(vec1,op,vec2) {rep(1){int s=min(si(vec1),si(vec2));fou(i,0,s)vec1[i]=vec1[i] op vec2[i];}}
template<class C>void mini(C &a,C b){a=min(a,b);}
template<class C>void maxi(C &a,C b){a=max(a,b);}
#define in(T,...) T __VA_ARGS__;_cin(__VA_ARGS__);
#define out(...) _cout(__VA_ARGS__);
void _cin(){}template<class Head,class...Tail>void _cin(Head&head,Tail&&...tail){cin>>head;_cin(forward<Tail>(tail)...);}
template<class Head>void _cout(Head head){cout<<head<<endl;}template<class Head,class...Tail>void _cout(Head head,Tail...tail){cout<<head<<" ";_cout(forward<Tail>(tail)...);}
template<class C>void outvec(vector<C> vec){int vecsize=si(vec);fou(i,0,vecsize-1)cout<<vec[i]<<" ";out(vec[vecsize-1]);}
template<class C> C gcd(C a,C b){if(a&&b)return gcd(min(a,b),max(a,b)%min(a,b));else return a;}
template<class C> C lcm(C a,C b){return a/gcd(a,b)*b;}
template<class C>int binarysearch(vector<C> vec,C n,char c){int left=-1;int right=si(vec);bool outleft=(c=='d'||c=='U');int getmin=(c=='u'||c=='d')?1:-1;while(right-left>1){int mid=left+(right-left)/2;bool OK=vec[mid]*getmin>=n*getmin;if(outleft==OK) left=mid;else right=mid;}return outleft?left:right;}


// #define int int64_t
// #define double long double


// map,makepair


signed main(){
  IOS;

  in(int,n);
  VI v(n),c(n);
  fou(i,0,n) cin>>v[i];
  fou(i,0,n) cin>>c[i];

  VI gain(n);
  fou(i,0,n) gain[i]=v[i]-c[i];

  int ans=0;
  fou(i,0,n) if(gain[i]>0) ans+=gain[i];
  out(ans);

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int n;
	cin >> n;
	int tax = ((double)n/1.08);
	int tat = (double)tax*1.08;
	while(tat<=n){
		tat = (double)tax*1.08;
		// cerr << tax << ":" << tat << endl;
		if(n==tat){
			cout << tax << endl;
			return 0;
		}
		tax++;
	}cout << ":(" << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;}
#define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;}
#define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;}
#define Size(n) (n).size()

typedef long long ll;


using namespace std;

const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;


long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

      
      cin>>n>>x;
      rep(i,n)cin>>a[i];
      sort(a,a+n);
      rep(i,n){
        if(i==n-1){
          if(x==a[i])ans++;
          else break;
          break;
        }
        if(x<a[i])break;
        x-=a[i];
        ans++;
      }
      Cout(ans);
     

       
return 0;
}


Measured memory_bytes: 256
import collections

def trial_division(n):
    if n < 2:
        return []
    
    prime_factors = []

    for i in range(2, int(n**0.5)+1):
        while n % i == 0:
            prime_factors.append(i)
            n //= i
    
    if n > 1:
        prime_factors.append(n)
    
    return prime_factors

counter = 0
if __name__ == "__main__":
    N = int(input())
    
    c = collections.Counter(trial_division(N))
    for primary_number, count in c.items():
        for i in range(1, count+1):            
            z = primary_number ** i
            if N % z == 0:
                counter += 1
                N //= z
    
    print(counter)


Measured memory_bytes: 9656
fun main() {
    val input = readLine()!!.split(" ").map { it.toInt()}
    val r = input[0]
    val g = input[1]
    val b = input[2]

    val n = 100 * r + 10 * g + b

    val result = if (n % 4 == 0) "YES" else "NO"
    print(result)
}

Measured memory_bytes: 36412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

#define ll long long int
#define mod 1000000007

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<ll> vec(n);
    unordered_map<ll, ll> um;
    ll total = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        total += x;
        um[x]++;
    }
    int k;
    cin >> k;
    for(int i =0; i < k; i++){
        ll a, b;
        cin >> a >> b;
        auto x = um.find(a);
        if(x == um.end())
            cout << total << '\n';
        else{
        ll times = um[a];
        total -= times * a;
        um.erase(x);
        um[b] += times;
        total += times * b;
        cout << total << '\n';
        }
    }
}









Measured memory_bytes: 7280
#include<stdio.h>

int main(void) {
	int A, B, C;
	scanf("%d", &A);
	scanf("%d", &B);
	scanf("%d", &C);
	int cnt = 0;
	int days = 0;

	while (1) {
		days++;
		cnt += A;
		if (days % 7 == 0) {
			cnt += B;
		}
		if (cnt >= C) {
			break;
		}
	}
	printf("%d\n", days);
	return 0;
}


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

public class Main {
	
	static int depth[];
	static Node tree[];
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		
		int n=in.nextInt();
		tree=new Node[n];
		
		for(int i=0;i<n;i++) tree[i]=new Node();
		for(int i=0;i<n;i++) {
			int id=Integer.parseInt(in.next()),k=Integer.parseInt(in.next());
			
			int l=-1;
			for(int j=0;j<k;j++) {
				int c=Integer.parseInt(in.next());
				
				tree[c].parent=id;
				if(j==0) tree[id].left=c; //最も左
				if(l>-1)tree[l].right=c; //右兄弟
				
				l=c;
			}
		}
		
		depth=new int[n];
		
		//getroot
		int r=0;
		while(tree[r].parent!=-1)r++;
		
		//setDepth(r,0);
		
		PrintWriter out=new PrintWriter(System.out);
		for(int i=0;i<n;i++) {
			out.print("node "+i+": parent = "+tree[i].parent+", depth = "+getDepth(i)+", "+getType(i)+", ");
			out.println(getChildren(i));
		}
		out.flush();
	}
	
	static int getDepth(int i) {
		int d=0;
		while(tree[i].parent!=-1) {
			d++;
			i=tree[i].parent;
		}
		return d;
	}
	
	static void setDepth(int p, int d) {
		depth[p]=d;
		if(tree[p].left!=-1)setDepth(tree[p].left,d+1);
		if(tree[p].right!=-1)setDepth(tree[p].right,d);
	}
	
	static String getType(int i) {
		if(tree[i].parent==-1)return "root";
		else if(tree[i].left==-1) return "leaf";
		else return "internal node";
	}
	
	static List<Integer> getChildren(int i){
		List<Integer> clist=new ArrayList<>();
		i=tree[i].left;
		while(i!=-1) {
			clist.add(i);
			i=tree[i].right;
		}
		return clist;
	}

}

class Node{
	int parent=-1,left=-1,right=-1;
}


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

#define pq priority_queue
#define mp make_pair
#define cauto const auto &

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define clr(ar, val) memset(ar, val, sizeof(ar))

typedef long long int64;
typedef long long lint;
typedef long long lli;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

typedef pair<int, int> pint;
typedef pair<long, long> plong;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> ll sized_subset(T &comb) {
    T x = comb & -comb, y = x + comb;
    return ((comb & ~y) / x) >> 1 | y;
}

ll abso(ll s) { return (s > 0) ? s : -s; }

int main() {
    ll s, n, count = 0, ans = 0, mini = 1000000000;
    cin >> n;
    for (ll i = 0; i < n; i++) {
        cin >> s;
        if (s < 0) {
            count++;
        }
        ans += abso(s);
        mini = min(mini, abso(s));
    }
    if (count % 2 == 1) {
        ans -= 2*mini;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python2
from __future__ import division, print_function

import os
import sys
from atexit import register
from io import BytesIO

range = xrange

sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))

input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
a = [int(i) for i in input().split()]

pref_sums = [0] * (n + 1)
for i in range(n):
    pref_sums[i + 1] = pref_sums[i] + a[i]

dp = [[0] * n for _ in range(n)]


def solve(start, end):
    if (dp[start][end] == 0) and (start != end):
        dp[start][end] = min(pref_sums[i + 1] - pref_sums[start] + pref_sums[end + 1] - pref_sums[i + 1] +
                             solve(start, i) + solve(i + 1, end) for i in range(start, end))
    return dp[start][end]


print(solve(0, n - 1))


Measured memory_bytes: 35944
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_pair tree<pair<int,int>,null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_set_mutiset tree<int,null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<int,int> pi; 
#define PI 3.1415926535897932384
#define FOR(i,vv,n) for(ll i=vv;i<n;i++)
#define FORR(i,n,vv) for(ll i=n-1;i>=vv;i--)
#define ve vector 
#define maxind(v) (max_element(v.begin(),v.end())-v.begin())
#define minind(v) (min_element(v.begin(),v.end())-v.begin())
#define maxe(v) *max_element(v.begin(),v.end())
#define mine(v) *min_element(v.begin(),v.end())
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define eb emplace_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp make_pair
#define M 1000000007ll
#define INF 1000000000000000000ll
#define PRECISE cout.precision(18);
#define all(v) v.begin(),v.end()
#define BS(v,n) binary_search(all(v),n)
#define srt(v) sort(v.begin(),v.end())
#define rsrt(v) sort(all(v),greater <ll>())
#define uni(v) v.resize(unique(all(v))-v.begin())
#define F first
#define S second
#define GET(i,p) get<p>(i)


int main(){

	#ifndef ONLINE_JUDGE
    // for getting input from input.txt	
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
	 #endif

    FAST
	//PRECISE

ll a,b,c,d;
cin>>a>>b>>c>>d;
ll ans=-INF;
ans=max(ans,a*c);
ans=max(ans,a*d);
ans=max(ans,b*c);
ans=max(ans,b*d);
if(0<=b&&0>=a)ans=max(ans,0ll);
if(0<=c&&0>=d)ans=max(ans,0ll);
cout<<ans;

return 0;
 }



Measured memory_bytes: 3652
K = int(input())
if K % 7 ==  0:
    K //= 7
if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()
elif K == 1:
    print(1)
    exit()

ans = 1
X = 1
history = set()
while True:
    if X == 0:
        print(ans)
        exit()
    elif X in history:
        print(-1)
    else:
        ans += 1
        X = (X*10 + 1) % K


Measured memory_bytes: 63148
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s, t;
    cin >> s >> t;
    int ans = 0;
    fr(i, 0, len(s))
    {
        if (s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3796
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <random>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
typedef pair<int, int> P;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
#define OUTPUT(i) (cout << (ll)i << endl)
#define ALL(a) ((a).begin(), (a).end())

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
int N, K;
int ub, lb;
int ans[1008];
vector<vector<int>> v(1001);

bool check()
{

    for (int i = 0; i < K; ++i)
    {
        int cnt = 0;
        for (int j = 0; j < N / 2; ++j)
        {
            cnt += ans[v[i][j]];
        }
        if (cnt < lb || cnt > ub)
            return false;
    }
    return true;
}

void solve()
{
    for (int i = 0; i < N / 2; ++i)
        ans[i] = 1;
    while (1)
    {
        std::random_device seed_gen;
        std::mt19937 engine(seed_gen());
        shuffle(ans, ans + N, engine);
        if (check())
            break;
    }
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    //cout << fixed << setprecision(15);

    int sum = 0;
    for (int i = 0; i < 4; ++i)
    {
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum / 60 << "\n"
         << sum % 60 << endl;
    return 0;
}



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

const int N = 505;

int n, m;
char s[N][N], result[2][N][N];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; ++i) {
        scanf("%s", s + i);
        for (int j = 0; j < m; ++j) {
            result[0][i][j] = result[1][i][j] = s[i][j];
        }
    }
    for (int i = 0; i < n; ++i) {
        if (i & 1) 
            result[0][i][0] = '#';
        else 
            for (int j = 0; j < m - 1; ++j)
                result[0][i][j] = '#';
    }
    for (int i = 0; i < n; ++i) {
        if (~i & 1) 
            result[1][i][m - 1] = '#';
        else 
            for (int j = 1; j < m; ++j)
                result[1][i][j] = '#';
    }
    for (int id = 0; id < 2; ++id) {
        for (int i = 0; i < n; ++i)
            puts(result[id][i]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 1536
#pragma optimization_level 3
#include <bits/stdc++.h>
#define  f               first
#define  s               second
#define  sym(s)          s = "#" + s + "#";
#define  all(x)          (x).begin(), (x).end()
#define  alll(x,n)       x+1, x+n+1
#define  newl            cout<<"\n";
#define  foo(i,a,n)      for(ll i = (a); i <= n; i++)
#define  deb1(a)         cout<<a<<"\n";
#define  deb2(a,b)       cout<<a<<" "<<b<<"\n";
#define  deb3(a,b,c)     cout<<a<<" "<<b<<" "<<c<<"\n";
#define  deb4(a,b,c,d)   cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n";
#define  debp(a)         cout<<a.f<<" "<<a.s<<"\n";
#define  debv(a)         for(auto it: a)cout<<it<<" ";newl;
#define  debm(a)         for(auto it: a)cout<<"{"<<it.f<<","<<it.s<<"}, ";newl;
#define  deb1d(a,n)      foo(i,1,n)cout<<a[i]<<" ";newl;
#define  deb2d(a,n,m)    foo(i,1,n){foo(j,1,m){cout<<a[i][j]<<" ";}newl;}

using namespace std;
using ll              =  long long;
using ld              =  long double;
const ll   MOD        =  1e+9 + 7;
const ll   INF        =  LLONG_MAX;
const int  N          =  (int)2e+5 + 8;

ll n,a[N];
string s;

void MAIN(int tc){
	cin >> n;
    int cur  =0, ok = 0;
    for(int i = 1; i <= n; i++){
        int x, y;
        cin >> x >> y;
        if(x == y) cur++;
        else cur = 0;
        if(cur == 3) ok = 1;
    }
    ok?cout<<"Yes":cout<<"No";
}

int main(){
    ios:: sync_with_stdio(false); 
    cin.tie(nullptr); cout.tie(nullptr);
    cout<<fixed; cout<<setprecision(10);

    int test_cases = 1;
    //cin>>test_cases;
    for(int i = 1; i <= test_cases; i++){
        MAIN(i);
    }
}

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

int main() {
	int n, m, c;
	cin >> n >> m >> c;
	int b[m], a[n][m];
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		long cnt = 0;
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
			cnt += a[i][j] * b[j];
		}
		if (cnt + c > 0) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define f first
#define s second
#define inf 1e18+9
using namespace std;
const int N=200009;
int a[N];
int n,k,ans=-1,z=0;
vector <int> p,m;
int count(int s){
	int sum=0;
	if(s>=0){
		sum+=z*(p.size()+m.size())+p.size()*(long long)m.size()+z*(z-1)/2;
		int i=0,j=(long long)p.size()-1;
		while(i<j){
			while(j>=0 and p[j]*p[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
		i=0,j=(long long)m.size()-1;
		while(i<j){
			while(j>=0 and m[j]*m[i]>s)j--;
			sum+=max(j-i,0ll);
			i++;
		}
	}
	else if(s<0){
		int i=0,j=m.size()-1;
		while(i<p.size()){
			while(j>=0 and i<p.size() and m[j]*p[i]>=-s)j--;
			sum+=j+1;
			i++;
		}
		sum=p.size()*(long long)m.size()-sum;
	}
	return sum;
}
int32_t main(){
	if(fopen("input.txt", "r"))
		freopen("input.txt", "r", stdin),
		freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]>0)p.push_back(a[i]);
		else if(a[i]<0)m.push_back(-a[i]);
		else z++;
	}
	sort(p.begin(),p.end());
	sort(m.begin(),m.end());
	int lo=-inf,hi=inf;
	while(hi>=lo){
		int mid=(hi+lo)/2;
		int c=count(mid),d=count(mid-1);
		if(c>=k){
			ans=mid;
			hi=mid-1;
		}
		else lo=mid+1;
	}
	cout << ans ;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
ll N;
const ll MAX_N=100;
vector<ll> b;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N;
	REP(i,N){
		ll b0;
		cin>>b0;
		b.push_back(b0);
	}
	vector<ll> ans;
	REP(i,N){
		ll inx=-1;
		REP(j,b.size()){
			if(b[j]==j+1){
				inx=j;
			}
		}
		if(inx==-1)break;
		ans.push_back(inx+1);
		b.erase(b.begin()+inx);
	}
	if(ans.size()==N){
		REP(i,N){
			cout<<ans[N-1-i]<<endl;
		}
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define simplify ios_base::sync_with_stdio(0);cin.tie(0);
#define int long long
#define endl "\n"
using namespace std;

const int mod=998244353;
const int N=2e5+5;

int fact[N];
int invFact[N];

int inverseMod(int x,int mod);
void precompute(){
    fact[0]=fact[1]=1;

    for(int i=2;i<N;i++){
        fact[i]=fact[i-1]*i;
        fact[i]%=mod;
    }

}
int NCR(int n,int r){

    if(r>n)return 0;
    int ans=fact[n];
    ans*=inverseMod(fact[r],mod);
    ans%=mod;
    ans*=inverseMod(fact[n-r],mod);
    ans%=mod;
    return ans;
}



int power(int x,int n,int mod){
//(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}

int inverseMod(int x,int mod){

return power(x,mod-2,mod);
}




int32_t main(){

    simplify
    int n,m,k;
    cin>>n>>m>>k;
    precompute();
    int ans=0;
    int other;
    for(int i=0;i<=k;i++){
        other=m*power(m-1,n-1-i,mod);
        other%=mod;
        other=other*NCR(n-1,i);
        other%=mod;
        ans+=other;
        ans%=mod;
    }
    cout<<ans;




    
    return 0;
}








Measured memory_bytes: 5188
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;




int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	int n;
	cin >> n;
	vpii a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(all(a));
	for (int i = 0; i < n; i++)
		cout << a[i].second << " ";
	return 0;
}

Measured memory_bytes: 1536
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int i,j,q,l,r,a[100001],ni[100001],sum[100001],x;
	for(i=2;i<=100000;i++)	a[i]=1;
	for(i=2;i*i<=100000;i++)	{
		if(a[i]==1)	{
			for(j=2;j*i<=100000;j++)	{
				a[i*j]=0;
			}
		}
	}
	a[1]=0;
	for(i=1;i<=100000;i++)	{
		x=(i+1)/2;
		if(a[i]==1 && a[x]==1)	ni[i]=1;
		else ni[i]=0;
	}
	sum[0]=0;
	sum[1]=ni[1];
	for(i=2;i<=100000;i++)	{
		sum[i]=sum[i-1]+ni[i];
	}
	scanf("%d",&q);
	for(i=0;i<q;i++)	{
		scanf("%d %d",&l,&r);
		x=sum[r]-sum[l-1];
		printf("%d\n",x);
	}
	return 0;
}

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

using namespace std;

int main(){
    long long n;
    cin >> n;
    map<string, long long>mp;
    for(long long i = 0; i < n; ++i){
        string tmp; cin >> tmp;
        sort(tmp.begin(), tmp.end());
        mp[tmp]++;
    }
    long long ans = 0;
    for(auto x:mp){
        ans += (x.second * (x.second - 1)) / 2;
    }
    cout << ans;

    return 0;

}


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


int main() {
  string s;
  cin >> s;
  
  int cnt = 0;
  for(int i=0; i<3; i++) {
    if (s.at(i)=='R') cnt++;
  }
  if (s.at(1)=='S' && cnt==2) cnt = 1;
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 3620
# coding: utf-8
# Your code here!
import heapq

N,M=map(int,input().split())

X=list(map(int,input().split()))
X.sort()

if N>=M:
    print(0)
    exit()

l=[]
for i in range(M-1):
    l.append(-(X[i+1]-X[i]))

heapq.heapify(l)

for _ in range(N-1):
    heapq.heappop(l)

print(-sum(l))

Measured memory_bytes: 13960
def Z(): return int(input())
def ZZ(): return [int(_) for _ in input().split()]

def main():
  N = Z()
  A = [Z() for _ in range(N)]
  print('first' if any([a%2 == 1 for a in A]) else 'second')
  return

if __name__ == '__main__':
  main()

Measured memory_bytes: 7848