akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

ll n = 0, m = 0, k = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//----------------------------------------------------------------------


int main(void) {
  ll low, upp, mid;
  string lows, mids;
  cin >> upp;
  upp--;
  cout << "0" << endl;

  cin >> lows;

  low = 0;

  while (1) {
	n++;
	mid = (upp + low) / 2;
	cout << mid << endl;
	cin >> mids;

	if (mids == "Vacant") {
	  return 0;
	}

	if ((mid - low) % 2 == 0) {
	  if (lows == mids) {
		low = mid + 1;
		if (mids == "Male") {
		  lows = "Female";
		}
		else {
		  lows = "Male";
		}
	  }
	  else {
		upp = mid - 1;
	  }
	}
	else {
	  if (lows != mids) {
		low = mid + 1;
		if (mids == "Male") {
		  lows = "Female";
		}
		else {
		  lows = "Male";
		}
	  }
	  else {
		upp = mid - 1;
	  }
	}
	if (n > 20) {
	  return 0;
	}
  }

  return 0;
}

Measured memory_bytes: 852
# C - Bugged

N = int(input())
s = [int(input()) for _ in range(N)]

mod10 = [x%10 for x in s]
fraction = [x for x in s if x%10 > 0]

if len(set(mod10)) == 1 and mod10[0] == 0:
    print(0)
elif sum(mod10)%10 > 0:
    print(sum(s))
else:
    print(sum(s) - min(fraction))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
constexpr double pi=3.141592653589793238;
//int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
int n,m,d[100010];
vector<int>v[100010];
bool used[100010];
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].pb(b);
        v[b].pb(a);
    }
    queue<int>q;
    q.push(0);
    used[0]=true;
    while(!q.empty()){
        int p=q.front();
        q.pop();
        for(int i:v[p]){
            if(!used[i]){
                d[i]=p;
                used[i]=true;
                q.push(i);
            }
        }
    }
    cout<<"Yes"<<endl;
    rep(i,n-1)cout<<d[i+1]+1<<endl;
    return 0;
}

Measured memory_bytes: 13116
#include <iostream>

using namespace std;

int H;

//heapify subtree whose root is i
void maxHeapify(int a[],int i){
  int left=2*i;
  int right=2*i+1;
  //select maximum node in left,i,right
  int largest=i;
  if(left<=H && a[left]>a[i]) largest=left;
  if(right<=H && a[right]>a[largest]) largest=right;
  if(largest != i){
    swap(a[i],a[largest]);
    maxHeapify(a,largest);
  }
}

void buildMaxHeap(int a[]){
  for(int i=H/2;i>0;i--){
    maxHeapify(a,i);
  }
}

int main(){
  cin >> H;
  int a[H+1];
  for(int i=1;i<=H;i++)
    cin >> a[i];
  buildMaxHeap(a);
  for(int i=1;i<=H;i++) cout << " " << a[i];
  cout << endl;
}

Measured memory_bytes: 4980
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 1e5 + 10 ;
const ll INF = 1e18 + 10 ;
int main(){
    fastio
    int n ;
    cin >> n ; 
    string s ;
    cin >> s ; 
    for(char &c : s){
        int t = c - 'A' ; 
        t = (t + n) % 26 ; 
        c = t + 'A' ;
    }
    cout << s << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;

int main()
{
    cin >> N;
    
    A = N/100;
    B = (N%100)/10;
    C = N%10;

    if((A==7) || (B==7) || (C ==7)) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>
static const int N=1000;
void trace(int A[],int n){
    int i;
    for(i=0;i<n;i++){
      if(i>0) printf(" ");
      printf("%d",A[i]);
      }
      printf("\n");
     }
     
int main(){
  int n,i,j;
  int v;
  int A[N+1];
  scanf("%d",&n);
  
	for(i=0;i<n;i++) scanf("%d",&A[i]);
	
	trace(A,n);
    for(i=1;i<n;i++){
      v=A[i];
      j=i-1;
      while(j>=0&&A[j]>v){
         A[j+1]=A[j];
         j--;
         }
         A[j+1]=v;
         trace(A,n);
        }
   return 0;
}

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

int main(){
	int a, b, n, sa, sb;
	while(1){
		sa = sb = 0;
		cin >> n;
		if( n == 0 )	break;
		for( int i=0; i<n; i++ ){
			cin >> a >> b;
			if( a > b ){
				sa += a + b;
			}else if( a < b ){
				sb += a + b;
			}else{
				sa += a;
				sb += b;
			}
		}
		cout << sa << " " << sb << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define all(t) (t).begin(),(t).end()
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}

int main(){
	int n;
	cin >> n;
	int p[100010];
	vector<int> v;
	FOR(i,n){
		cin >> p[i];
	}
	int ans=0;
	FOR(i,n-1){
		if(p[i]==i+1){
			ans++;
			p[i+1]=p[i];
		}
	}
	if(p[n-1]==n)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 640
def main():
    N, K = list(map(int, input().split(' ')))
    # K < b <= N
    # a =  K, ..., b - 1  # if K = 0, exclude the a = K case
    #      b + K, ..., b + b - 1
    #      2 * b + K, ..., 2 * b + b - 1
    #      ...
    ans = 0
    for b in range(K + 1, N + 1):
        ans += (N // b) * (b - K)
        ans += max([0, N % b - K + 1])
        if K == 0:
            ans -= 1
    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    long long int n,buf;
    vector<long long int> a;

    cin>>n;
    for(int i=0;i<n;i++){
        cin>>buf;
        a.push_back(buf);
    }

    long long int n_q;
    vector<long long int> q;

    cin>>n_q;
    for(int i=0;i<n_q;i++){
        cin>>buf;
        q.push_back(buf);
    }

    for(int i=0;i<n_q;i++){
        decltype(a)::iterator it_lb=lower_bound(a.begin(),a.end(),q[i]);
        decltype(a)::iterator it_ub=upper_bound(a.begin(),a.end(),q[i]);
    
        if(it_lb!=a.end()){
            size_t pos_lb = distance(a.begin(),it_lb);
            if(it_ub!=a.end()){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<pos_lb<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb==a[i]){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<pos_lb<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb!=a[i]){
                cout<<pos_lb<<" "<<n<<endl;
            }
        }
        
        if(it_lb==a.end() && *it_lb!=a[i]){
            if(it_ub!=a.end()){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<n<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb==a[i]){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<n<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb!=a[i]){
                cout<<n<<" "<<n<<endl;
            } 
        }else if(it_lb==a.end() && *it_lb==a[i]){
            size_t pos_lb = distance(a.begin(),it_lb);
            if(it_ub!=a.end()){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<pos_lb<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb==a[i]){
                size_t pos_ub = distance(a.begin(),it_ub);
                cout<<pos_lb<<" "<<pos_ub<<endl;
            }else if(it_ub==a.end() && *it_lb!=a[i]){
                cout<<pos_lb<<" "<<n<<endl;
            }
        }


    }
    return 0;
}



Measured memory_bytes: 5684
#include<stdio.h>
int main(void){
  int N,i;
  long int A = 0;
  scanf("%d",&N);
  for(i=1;i<=N;i++){
    if(i%3 !=0)
      if(i %5 != 0)
        A = A + i;
  }
  printf("%ld",A);
}


Measured memory_bytes: 1728
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    if (s < t) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;

main()
{
	IO;
	int n,k;
	cin>>n>>k;
	
	vector<int> v(n),ans(n,1e9);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	ans[0]=0;
	
	for(int i=1;i<n;i++)
	{
		for(int j=i-1;j>=i-k && j>=0;j--)
		{
			ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
		}
	}
	
	cout<<ans[n-1];
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(void)
{
    long long N, a[200001], i, j=1;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a[i];
    }

    for(i=1; i<=N; i++){
        if(a[i] == j){
            j++;
        }
    }

    if(j == 1){
        cout << -1 << endl;
    }

    else{
        cout << N-j+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------
int main(){
  // けんちょんさんのエラトステネスの篩
  int MAX = 101010;
  vector<int> is_prime(MAX, 1);
  is_prime[0] = 0, is_prime[1] = 0;
  for (int i = 2; i < MAX; ++i) {
      if (!is_prime[i]) continue;
      for (int j = i*2; j < MAX; j += i) is_prime[j] = 0;
  }
  vector<int> S(100100,0);
  for(int i=1; i<100005; i++){
    S[i+1] = S[i] + (is_prime[i] && is_prime[(i+1)/2]);
  }
  int Q;
  cin >> Q;
  for(int i=0; i<Q; i++){
    int l,r;
    cin >> l >> r;
    cout << S[r+1] - S[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    const double PI = acos(-1);
    int a, b, C;
    double S, L, h;
    cin >> a >> b >> C;
    h = b*sin(C*PI/180);
    S = a*h/2;
    L = a+b+sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C*PI/180));
    printf("%lf\n%lf\n%lf\n", S, L, h);
    return 0;
}


Measured memory_bytes: 3488
"use strict";

function main(arg) {
    const positions = arg.split("\n")[0].split(" ").slice(0,3);
    const limit     = arg.split("\n")[0].split(" ")[3];

    
    if(Math.abs(positions[2] - positions[0]) <= limit) {
        console.log("Yes");
        return;
    }
    
    if( (Math.abs(positions[1] - positions[0]) <= limit) &&
        (Math.abs(positions[2] - positions[1]) <= limit) ) {
        console.log("Yes");
        return;
    }
    
    console.log("No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

namespace Template
{
    class Program
    {
        static void Main(string[] args)
        {
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            long a = long.Parse(input[0]);
            long b = long.Parse(input[1]);
            long c = long.Parse(input[2]);
            long k = long.Parse(input[3]);

            k = k % 2 == 0 ? 1 : -1;

            //出力
            Console.WriteLine((a - b) * k);
        }
    }
}


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

int main(){
    string s;

    cin >> s;

    int l = s.length() - 1;

    if(s[l] == '2' || s[l] == '4' || s[l] == '5' || s[l] == '7' || s[l] == '9'){
        cout << "hon\n";
    }
    else if(s[l] == '0' || s[l] == '1' || s[l] == '6' || s[l] == '8'){
        cout << "pon\n";
    }
    else{
        cout << "bon\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF =1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define pb push_back
int main(){
    int n;
    cin >> n;
    if(n>999){
        cout << "ABD" << endl;
    }
    else{
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
import numpy as np
import math

n = int(stdin.readline().rstrip())

d,x = [int(x) for x in stdin.readline().rstrip().split()]

li = [int(stdin.readline().rstrip()) for _ in range(n)]

point = 0
for i in range(n):
    if li[i] <= d:
        point += math.ceil(d/li[i])
    else:
        point += 1
point += x
print(point)

Measured memory_bytes: 12452
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int _;
    cin >> _;
    while (_--) {
        int p, q;
        cin >> p >> q;
        int pq = p * p + q * q;
        int cnt = 0;
        for (int m = -200; m <= 200; m++) {
            for (int n = -200; n <= 200; n++) {
                if (m == 0 && n == 0) continue;
                int mn = m * m + n * n;
                if (mn > pq) continue;
                if ((m * p + n * q) % mn == 0 && (m * q - n * p) % mn == 0) cnt++;
            }
        }
        cout << (cnt == 8 ? 'P' : 'C') << endl;
    }
    return 0;
}

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

using namespace std;
int dr[] = {1,0,-1, 0}; // S,SE,E,NE,N,NW,W,SW
int dc[] = {0,1, 0,-1}; // neighbors

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int h, w, ch, cw, dh, dw;
	cin>>h>>w>>ch>>cw>>dh>>dw;
	ch--;
	cw--;
	dh--;
	dw--;
	int dist[h][w];
	char s[h][w];
	for (int i=0; i<h; ++i){
		for (int j=0; j<w; ++j){
			cin>>s[i][j];
			dist[i][j] = 1e9;
		}
	}
	int cost = 0;
	dist[ch][cw] = 0;
	deque<pair<int, int> > q; q.push_back(pair<int,int>(ch, cw) );   
	while (!q.empty()) {
    	pair<int,int> u = q.front(); q.pop_front();                        // queue: layer by layer!
    	int x = u.first;
    	int y = u.second;
    	cost = dist[x][y];
//    	cout<<x<<" "<<y<<" "<<cost<<endl;
		for (int i=0; i<4; ++i){
    		int r = x + dr[i];
    		int c = y + dc[i];
    		if (r<0 || r>=h || c<0 || c>=w) continue; // outside
    		if(s[r][c] == '#')	continue;
    		if(dist[r][c] <= cost) continue;
    		dist[r][c] = cost;
//    		cout<<r<<" "<<c<<" "<<cost<<endl;
    		q.push_front(pair<int,int>(r, c));
		}	
		cost++;
		for (int i=-2; i<=2; ++i){
			for (int j=-2; j<=2; ++j){
				int r = x + i;
				int c = y + j;
    			if (r<0 || r>=h || c<0 || c>=w) continue; // outside
    			if(s[r][c] == '#')	continue;
    			if(dist[r][c] <= cost) continue;
    			dist[r][c] = cost;
    			q.push_back(pair<int, int> (r, c));
			}
		}
	}
	dist[dh][dw] == 1e9 ? cout<<"-1":cout<<dist[dh][dw];
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int x;
  cin >> x;
  for (int i = 1;; i++) {
    x -= i;
    if (x <= 0) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
all_A = sum(A)
comp = (1/(4*M))*all_A
A.sort(reverse=True)
i = 0
ans = 0
#print(A)
while (i <= M-1):
    if A[i] >= comp:
        ans += 1
    i += 1
#print(M)
#print(ans)
if ans == M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
n, k = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))


def solve(start):
    loop = []
    llen = 0
    lsum = 0
    reach = [0]*n

    now = start
    while True:
        nxt = P[now]-1
        loop.append(now)
        llen += 1
        lsum += C[now]
        reach[now] = 1
        if reach[nxt]:
            break
        now = nxt
    
    if lsum <= 0 or llen >= k:
        res = -10 ** 20
        s = 0
        now = start
        for i in range(min(llen, k)):
            s += C[now]
            res = max(res, s)
            now = P[now]-1
        return res
    else:
        s = lsum * (k // llen)
        now = start
        for i in range(k % llen):
            s += C[now]
            now = P[now]-1
        j = loop.index(now)
        res = -10**20
        for i in range(llen):
            j -= 1
            res = max(res, s)
            s -= C[loop[j]]
        return res


def solver():
    ans = -10 ** 20
    for i in range(n):
        ans = max(ans, solve(i))
    return ans


print(solver())


Measured memory_bytes: 87092
#include<iostream>
using namespace std;
int main(){
	int N,a[100000][3];
	cin>>N>>a[0][0]>>a[0][1]>>a[0][2];
	for(int i=1;i<N;i++){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		a[i][0]=max(a[i-1][1]+a[i][0],a[i-1][2]+a[i][0]);
		a[i][1]=max(a[i-1][2]+a[i][1],a[i-1][0]+a[i][1]);
		a[i][2]=max(a[i-1][0]+a[i][2],a[i-1][1]+a[i][2]);
	}
	cout<<max(a[N-1][0],max(a[N-1][1],a[N-1][2]));
	return 0;
}

Measured memory_bytes: 1408
N = int(input())

open = []
earn = []

for _ in range(N):
    open.append(list(map(int, input().split())))

for _ in range(N):
    earn.append(list(map(int, input().split())))


ans = -float('inf')
for i in range(1, 1 << 10):
    tmp = 0
    same = [0]*N
    for j in range(N):
        for k in range(10):
            if open[j][k] == 1 and (i & (1 << k)):
                same[j] += 1

    for j in range(N):
        tmp += earn[j][same[j]]
    ans = max(ans, tmp)

print(ans)


Measured memory_bytes: 42604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    string s,t;cin>>s>>t;
    string ss=s;
    rep(i,s.size())ss.push_back(s[i]);
    reverse(ss.begin(),ss.end());
    reverse(t.begin(),t.end());
    rep(i,t.size()){
        bool can = true;
        rep(j, t.size()){
            if(t[j]!=ss[i+j]){can=false;break;}
        }
        if(can){co("Yes");return 0;}
    }
    co("No");
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static MyUtil;

class MyUtil
{
    public static int[] ReadIntArray()
    {
        return ReadLine().Split().Select(x => int.Parse(x)).ToArray();
    }
}

class Program
{
    public static void Main()
    {
        int n = int.Parse(ReadLine());
        var a = ReadIntArray();

        long[] acc = new long[n];
        acc[0] = a[0];
        for (int i = 1; i < n; i++){ acc[i] = acc[i-1] + a[i]; }

        long ans = acc[n-1];
        // B=a[0:j], C=a[j:i], D=a[i:k], E=[k:n]
        for (int j = 1, i = 2, k = 3; i <= n-2; i++)
        {
            long sumL = acc[i-1], sumB = acc[j-1], sumC = sumL - sumB;
            long d = Math.Abs(sumB - sumC);

            while (j + 1 < i)
            {
                long nSumB = sumB + a[j], nSumC = sumC - a[j];
                long newD = Math.Abs(nSumB - nSumC);

                if (newD <= d)
                {
                    j++;
                    sumB = nSumB;
                    sumC = nSumC;
                    d = newD;
                }
                else
                {
                    break;
                }
            }

            long sumR = acc[n-1] - sumL, sumD = acc[k-1] - sumL, sumE = sumR - sumD;
            d = Math.Abs(sumD - sumE);

            while (k + 1 < n)
            {
                long nSumD = sumD + a[k], nSumE = sumE - a[k];
                long newD = Math.Abs(nSumD - nSumE);

                if (newD <= d)
                {
                    k++;
                    sumD = nSumD;
                    sumE = nSumE;
                    d = newD;
                }
                else
                {
                    break;
                }
            }

            long max = Math.Max(Math.Max(sumB, sumC), Math.Max(sumD, sumE));
            long min = Math.Min(Math.Min(sumB, sumC), Math.Min(sumD, sumE));

            ans = Math.Min(ans, max-min);
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 36060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		int X = sc.nextInt();
		int[] input = new int[N];
		for (int i = 0; i < input.length; i++) {
			input[i] = sc.nextInt();
		}
		int[] cons = new int[D + 1];
		for (int element : input) {
			int today = 1;
			while (today <= D) {
				cons[today]++;
				today += element;
			}
		}
		long sum = 0;
		for (int con : cons) {
			sum += con;
		}
		System.out.println(sum + X);
	}
}


Measured memory_bytes: 36000
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int l=sc.nextInt();
        int r=sc.nextInt();
        long max=Long.MAX_VALUE;
        for (int i=l;i<r;i++){
            long ii=i;
            for (int j=i+1;j<=r;j++){
                long jj=j;
                long x=(ii*jj)%2019;
                if (x<max){
                    max=x;
                }
                if (max==0)break;
            }
            if (max==0)break;
        }
        System.out.println(max);

    }

}



Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

char k;
double d[10], v1, v2, t;

int main(){
	while (cin >> d[0]){
		double dis = d[0];
		REP(i, 9){
			cin >> k >> d[i + 1];
			dis += d[i + 1];
		}
		cin >> k >> v1 >> k >> v2;
		t = dis / (v1 + v2);
		dis = 0;
		REP(i, 10){
			dis += d[i];
			if (dis >= t*v1){
				cout << i + 1 << endl;
				break;
			}
		}
	}
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a <= b)
    {
        swap(a, b);
    }
    for (int i = 0; i < a; i++)
    {
        cout << b;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
import numpy as np

n = int(input())
abc = np.array([list(map(int, input().split())) for i in range(n)])

dp = np.zeros((n, 3))

dp[0, :] = abc[0, :]

def chmax(a, b):
    if a > b:
        return a
    else:
        return b

for i in range(n - 1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i + 1, k] = chmax(dp[i + 1, k], dp[i, j] + abc[i + 1, k])

print(int(np.max(dp[-1, :])))


Measured memory_bytes: 41872
#include <algorithm>
#include <iostream>
#include <utility>
#include <vector>

using namespace std;

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

    vector<pair<int, int>> rl(n, make_pair(0, 0));
    for (int i = 0; i < n; i++) {
        int x, l;
        cin >> x >> l;
        rl[i].first = x + l;
        rl[i].second = x - l;
    }

    sort(rl.begin(), rl.end());

    int res = 1;
    for (int i = 1, j = rl[0].first; i < n; i++) {
        if (j <= rl[i].second) {
            j = rl[i].first;
            res++;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 1024
n = gets.chomp.to_i
s = []
n.times { s << gets.chomp.to_i }
sum = s.inject(:+)
if sum % 10 != 0
    puts sum
else
    s.sort!
    min = -1
    s.each do |v|
        if v % 10 != 0
            min = v
            break
        end
    end
    
    if min == -1
        puts 0
    else
        puts sum - min
    end
end

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
    long long x;
    cin >> x;
    int s = x%11;
    long long ans = (x/11)*2;
    if(s==0){
        cout << ans << endl;
        return 0;
    }
    if(s<=6) ans++;
    if(s>6) ans += 2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char c[310][310];
ll dp[101];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	string s;
	cin >> s;
	ll l = 0, r = s.length() - 1;
	ll ans = 0;
	while (r-l>0) {
		if (s[l] == s[r]) {
			l++;
			r--;
		}
		else if (s[l] == 'x') {
			l++;
			ans++;
		}
		else if (s[r] == 'x') {
			r--;
			ans++;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3756
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)998244353 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-8 ;
const int    maxn = (int) 1e5+20 ;
const int    maxm = (int) 1000+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int slen, tlen;
char s[2005],t[2005];

void work()
{
    cin >>s >>t;
    slen = strlen(s);
    tlen = strlen(t);
    for(int i = 0; i < slen; i++) s[slen + i] = s[i];

    int ans = 0;
    for(int i = 0; i < slen; i++)
    {
        int tmp = 1;
        for(int j = 0; j < tlen; j++)
        {
            if(s[i + j] != t[j])
            {
                tmp = 0;
                break;
            }
        }
        ans |= tmp;
    }

    if(ans) puts("Yes");
    else puts("No");
}


//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define f0(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<=n;i++)
#define f2(i,a,b) for(int i=a;i<=b;i++)
#define sp <<" "                // giving space
#define sp1 <<" "<<              // giving space between two elements
                 // new line
#define M 1000000007              // for mod
#define ll long long
#define ld long double
#define vii vector <pair<int,int>>
#define vll vector <pair<ll,ll>>
#define vi vector <int>
#define vl vector <ll>
#define pb(v,x) v.push_back(x)
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Sort(v) sort(v.begin(),v.end())
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#include <set>
#include <map>


int main(){
    int n;
    cin>>n;
    map<int,int>ma;
    f0(i,n)
    {
        int x;
        cin>>x;
        ma[x]++;
    }
    if(ma.size()==n)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <string>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF=1<<29;
ll mod=1000000007;

// (nCm)
template<class Type>
Type combination(Type n,Type m){
	Type nume=1; //分子
	for(Type i=0;i<m;i++) nume*=(n-i);
	Type deno=1; //分母
	for(Type i=1;i<=m;i++) deno*=i;
	Type res=nume/deno;
	return res;
}

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

	ll N,Ans=0;
	cin>>N;
	vector<string> arr(N);
	for(int i=0;i<N;i++) cin>>arr[i];
	for(int i=0;i<N;i++) sort(arr[i].begin(),arr[i].end());
	sort(arr.begin(),arr.end());

	ll tmp=1;
	for(int i=0;i<N-1;i++){
		if(arr[i]==arr[i+1]){
			tmp++;
		}else{
			Ans+=combination(tmp,2LL);
			tmp=1;
		}
	}
	Ans+=combination(tmp,2LL);
	cout<<Ans<<endl;

	return 0;
}

Measured memory_bytes: 5760
N, A, B = map(int, input().split())
S = input()
a = 0
b = 0
for s in S:
  if s == 'c':
    print('No')
  elif s == 'a':
    if a + b < A + B:
      print('Yes')
      a += 1
    else:
      print('No')
  else:
    if a + b < A + B and b < B:
      print('Yes')
      b += 1
    else:
      print('No')


Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  map<string,int> n;
  n["SAT"] = 1;
  n["FRI"] = 2;
  n["THU"] = 3;
  n["WED"] = 4;
  n["TUE"] = 5;
  n["MON"] = 6;
  n["SUN"] = 7;
  cout << n[s] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cstdlib>


//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  string s;
  cin >> s;
  int num = stoi(s);
  int yy = num/100;
  int mm = num % 100;
  // cout << yy << " " << mm << endl;
  if ((0 < yy && yy < 13) && (0 < mm && mm < 13)) cout << "AMBIGUOUS" << endl;
  else if (0 < mm && mm < 13) cout << "YYMM" << endl;
  else if (0 < yy && yy < 13) cout << "MMYY" << endl;
  else cout << "NA" << endl;;
  
}


Measured memory_bytes: 256
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-22 22:15:40
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  auto IsParindrome = [](string& s) -> bool {
    string t = s;
    reverse(all(t));
    return t == s;
  };

  int n = s.size();
  string s1 = s.substr(0, n / 2), s2 = s.substr(n / 2 + 1, n / 2);
  debug(s1, s2);

  if (IsParindrome(s1) && IsParindrome(s2) && IsParindrome(s)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int num1,num2,temp,rem;
  
  scanf("%d%d",&num1,&num2);
  
  if(num1<num2){
    temp=num1;
    num1=num2;
    num2=temp;
  }

  rem=num1%num2;

  
  while(1){
    if(rem==0)break;
    num1=num2;
    num2=rem;
    rem=num1%num2;
  }

  printf("%d\n",num2);
  return 0;
}



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

 #define int long long
 using namespace std;



void solve(){
	int n;
cin>>n;
	if(n==0) exit(0);
string s;
	cin>>s;
	
	int g=0;
	for(int i=51;i>=0;i--)if(s[51-i]=='1')g+=(1ll<<i);
	int d=1;
	n--;
//	g/=2;
	int zen=(1ll<<53)-1;
	int bit=g;
	
	bit+=(1ll<<52);
	g+=(1ll<<52);
	g/=2;
	while(1){
		if(n==0) goto lll;
		if(g==0) goto lll;
		int kai=(zen-bit)/g;
		if(kai>=n) {
			bit+=n*g;
			goto lll;
		}
		
		n-=kai;
		bit+=kai*g;
		d++;
		bit=(bit+g)/2;
		g/=2;
		n--;
		if(n==0) goto lll;
		
	}
	
	lll:;
	for(int i=11;i>=0;i--){
		if(d&(1ll<<i))cout<<"1";
		else cout<<"0";
	}
	for(int i=51;i>=0;i--){
		if(bit&(1ll<<i))cout<<"1";
		else cout<<"0";
	}
	cout<<endl;
//cout<<ans<<endl;
}

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

    int t;
    	//cin>>t;
    	for(int i=0;;i++){
    		solve();
    	
    	}
    	return 0;
    	
            }


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

#define INF 1e18
#define MAX (1e9+5)

int main() {
  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);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	vector<int> n(3);
	cin >> n[0] >> n[1] >> n[2];
  	sort(n.begin(), n.end());
  	int ans=3;

  	if(n[0]==n[1]){
		ans--;
    }
  	if(n[1]==n[2]){
		ans--;
    }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char const *argv[]) {
	int n, i, j, max = -1000000000, min;
	int a[200000];
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
	}
	min = a[0];
	for (i = 1; i < n; i++) {
		if (max < a[i] - min) {
			max = a[i] - min;
		}
		if (min > a[i]) {
			min = a[i];
		}
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 2576
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

#define INF (1 << 30)


ll maxs, mins, maxd, mind;

int main() {
	cout << fixed << setprecision(12);	
	int n;
	cin >> n;
	maxs = -INF;
	maxd = -INF;
	mins = INF;
	mind = INF;
	for (int i = 0; i < n; i++) {
		ll t1, t2;
		cin >> t1 >> t2;
		maxs = max(maxs, t1 + t2);
		mins = min(mins, t1 + t2);
		maxd = max(maxd, t1 - t2);
		mind = min(mind, t1 - t2);
	}
	ll ret = max(maxs - mins, maxd - mind);
	cout << ret << endl;

	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3636
import numpy as np
n = int(input())
argList = [input() for _ in range(n)]
keys = list('abcdefghijklmnopqrstuvwxyz')
nMat = []
for s in argList:
    nList = [0]*26
    for i, k in enumerate(keys):
        nList[i] = s.count(k)
    nMat.append(nList)
nMat = np.array(nMat)
minLst = nMat.min(axis=0)
ret = ''
for i,num in enumerate(minLst):
    for j in range(num):
        ret += keys[i]
print(ret)

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<pi> vpi;
typedef vector<bool> vbool;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define forall(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define F0(var,n) for(ll var = 0; var < n; var++)
#define F1(var,n) for(ll var = 1; var <= n; var++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define per(i,a,b) for(int i = b-1; i >= a; i--)
#define FIN ios::sync_with_stdio(false);cin.tie(0);
#define db(x) cout<<#x<<" = "<<x<<"\n"
#define all(v) v.begin(),v.end()
#define modulo(a,b) ((a%b)+b)%b
#define F first
#define S second
#define INF 1000000000010
#define INFLL 1000000000000000000
#define eps 0.000000000001
#define mod 1000000007
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);}
ll powmod(ll a,ll b) {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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

//=======================//

/*
Cosas que hay que cambiar cada vez que se quiere usar el segment tree (lo demas es general, sirve siempre):
NEUTRAL_ELEMENT
struct item
single()
merge()
*/

typedef ll item;
struct segtree {
	int size;
	vector<item> tree;
	item NEUTRAL_ELEMENT = 0;

	item single(ll v) {
		return v;
	}

	void init(int n) {
		size = 1;
		while(size < n) size *= 2;
		tree.assign(size*2,NEUTRAL_ELEMENT);
	}

	item merge(item a, item b) {
		item res = max(a,b);
		return res;
	}

	void build(int node, int lx, int rx, vector<long long>& a) {
		if (rx-lx == 1) {
			if (lx < (int) a.size()) {
				tree[node] = single(a[lx]);
			}
			return;
		}
		int m = (lx + rx) / 2;
		build(2*node+1, lx, m, a);
		build(2*node+2, m, rx, a);
		tree[node] = merge(tree[2*node+1], tree[2*node+2]);
	}

	void build(vector<ll>& a) {
		build(0,0,size,a);
	}

	void set(int i, ll a, int node, int l, int r) {
		if (r - l == 1) {
			tree[node] = single(a);
			return;
		}
		int m = (l+r) / 2;
		if (i < m)
			set(i,a,2*node+1,l,m);
		else
			set(i,a,2*node+2,m,r);
		tree[node] = merge(tree[2*node+1], tree[2*node+2]);
	}

	void set(int i, ll a) {
		set(i,a,0,0,size);
	}

	item get(int node, int lx, int rx, int L, int R) {
		if (L >= rx || R <= lx) return NEUTRAL_ELEMENT;
		if (lx >= L && rx <= R) return tree[node];
		int m = (lx + rx) / 2;
		item s1 = get(2*node+1, lx, m, L, R);
		item s2 = get(2*node+2, m, rx, L, R);
		return merge(s1,s2);
	}

	item get(int L, int R) {
		return get(0,0,size,L,R);
	}

};

int max_val = 300001;


int main () {
	FIN

	int n, k; cin >> n >> k;
	vector<ll> ceros(max_val,0);
	vector<int> a(n);
	F0(i,n) cin >> a[i];
	segtree st;
	st.init(max_val);
	st.build(ceros);
	ll res = 0;
	for (int i = 0; i < n; i++) {
		ll last_max = st.get(a[i] - k, a[i] + k + 1);
		st.set(a[i], last_max + 1);
		res = max(res, last_max + 1);
	}
	cout << res << "\n";
	return 0;
}










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

int main(){
  int x, y, z;
  cin >> x >> y >> z;

  int ans = 0;
  x -= z;
  while(x-z >= y){
    ans++;
    x -= y;
    x -= z;
  }

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




Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public	static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String str = sc.nextLine();
		
		int q = sc.nextInt();
		
		for(int i= 0; i < q ; i++) {
			String order = sc.next();
			int a = sc.nextInt();
			int b = sc.nextInt();
			switch (order) {
				case "print":
					 System.out.println(str.substring(a,b+1));
					break;
			
				case "reverse":
					StringBuffer sb = new StringBuffer(str.substring(a,b+1));
					String rvs = sb.reverse().toString();
					str = str.substring(0,a) + rvs + str.substring(b+1);
					break;
					
				case "replace":
					String p = sc.next();
					str = str.substring(0,a) + p + str.substring(b+1);
					break;
			}
		}
	}
}



Measured memory_bytes: 29568
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    int M; cin >> M;
    LL n = 0, sum = 0;
    for (int i = 0; i < M; ++i) {
        int di; LL ci; cin >> di >> ci;
        n += ci;
        sum += di * ci;
    }
    cout << (sum-1) / 9 + n-1 << endl;
    return 0;
}


Measured memory_bytes: 3644