akhauriyash/Code-Regression huggingface dataset:
/**
 * Created by hiroqn on 13/10/06.
 */
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main() {
  var temp,
      n, m, s , g1, g2,
      d,
      i, j, k,
      cost;
  while (true) {
    temp = input.shift().split(' ');
    n = +temp[0];
    m = +temp[1];
    s = temp[2] - 1;
    g1 = temp[3] - 1;
    g2 = temp[4] - 1;
    if(n===0 && m===0){
      break
    }
    d = [];
    for (i = 0; i < n; i++) {
      d[i] = [];
      for (j = 0; j < n; j++) {
        d[i][j] = i === j ? 0 : Infinity;
      }
    }
    for (i = 0; i < m; i++) {
      temp = input.shift().split(' ');
      d[temp[0] - 1][temp[1] - 1] = +temp[2];
    }

    for (k = 0; k < n; k++) {
      for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
          d[i][j] = d[i][j] > d[i][k] + d[k][j] ? d[i][k] + d[k][j] : d[i][j];
        }
      }
    }
    cost = Infinity;
    for (k = 0; k < n; k++) {
      cost = Math.min(cost, d[s][k] + d[k][g1] + d[k][g2]);
    }
    console.log(cost);
  }

}

Measured memory_bytes: 31348
import java.util.*;

public final class Main {


    static int N;

    static long A;
    static long B;

    static long[] K;
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        N = s.nextInt();

        A = s.nextInt();

        B = s.nextInt();

        int max = 1;

        K = new long[N];

        for (int i = 0; i < N; i++) {

            int a = s.nextInt();

            K[i] = a;

            double ar = a;

            double  b = B;

            max = (int) Math.max(Math.floor(ar/b),max);
        }


        System.out.println(parametricSearch(0, 1000000000));

    }

    public static long parametricSearch(long start, long end) {

        if (end == start+1) return end;

        long middle = (start+ end) /2;

        if (can(K, middle)) {

            return parametricSearch(start,  middle);
        } else {

            return parametricSearch(middle, end);
        }
    }

    public static boolean can(long[] arr, long n) {

        long count = 0;

        for (int i = 0; i <arr.length; i++) {

            if (arr[i] - B*n <= 0) continue;

            long a  =arr[i]- B*n;

            long b = A-B;
            long k = a/b;

            if (a % b != 0) k++;

            count+=k;
        }


        return count <= n;

    }

}

Measured memory_bytes: 50468
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char *argv[]) {
  int N;
  int res = 0;
  cin >> N;
  vector<int> v(N);
  vector<int> c(N);
  vector<int> d(N);

  for(int i  = 0; i < N; i++){
    cin >> v[i];
  }
  for(int i  = 0; i < N; i++){
    cin >> c[i];
  }

  for(int i  = 0; i < N; i++){
    d[i] = v[i] - c[i];
    if(d[i] > 0){
      res += d[i];
    }
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
from sys import stdin
def LI(): return list(map(int,stdin.readline().rstrip().split()))

li = LI()

for i in range(len(li)):
    for j in range(i+1,len(li)):
        if li[i]+li[j] == li[3-i-j]:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
int K;
LL MOD=1e9+7;
LL ans[100011];

LL pp(LL x, LL b){
	LL ans=1;
	LL now=x;
	while(b!=0){
		if(b%2==1){
			ans*=now;
			ans%=MOD;
		}
		now*=now;
		now%=MOD;
		b/=2;
		//cout<<now<<" "<<b<<" "<<ans<<endl;
	}
	return ans;
}

int main(){
	cin>>N>>K;
	REP(i,K+1){
		ans[i]=0;
	}
	for(int i=K;i>=1;i--){
		vector<int>v;
		v.clear();
		for(int j=1;j*j<=i;j++){
			if(i%(j)==0){
				v.push_back(j);
				v.push_back(i/j);
			}
		}
		sort(v.begin(),v.end());
		v.erase(unique(v.begin(),v.end()),v.end());
		LL now=K/i;
		LL tmp=pp(now,N);
		//cout<<"now"<<now<<" "<<N<<" "<<tmp<<endl;
		ans[i]+=tmp;
		ans[i]%=MOD;
		//cout<<ans[i]<<" "<<tmp<<endl;
		/*REP(j,3){
			cout<<ans[j]<<endl;
		}*/
		REP(j,v.size()){
			if(i!=v[j]){
				ans[v[j]]+=MOD-ans[i];
				ans[v[j]]%=MOD;
			}
		}
		/*REP(j,10){
			cout<<ans[j]<<endl;
		}*/
	}
	/*REP(j,10){
		cout<<ans[j]<<endl;
	}*/
	LL answer=0;
	REP(i,K+1){
		answer+=(ans[i]*i);
		answer%=MOD;
	}
	cout<<answer<<endl;
}

Measured memory_bytes: 4408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer ST = new StringTokenizer(BR.readLine());
		int N = Integer.parseInt(ST.nextToken()), M = Integer.parseInt(ST.nextToken()), homeworkDays = 0;
		ST = new StringTokenizer(BR.readLine());
		for (; M > 0; M--) homeworkDays += Integer.parseInt(ST.nextToken());
		System.out.println((homeworkDays <= N) ? N - homeworkDays : -1);
	}
}


Measured memory_bytes: 27244
#include <stdio.h>

int main(){
	int n, num, i;
	long long count=0, sum=0;

	scanf("%d", &n);

	for(i=0;i<n;i++){
		scanf("%d", &num);
		if(num)
			sum+=num;
		else{
			count+=sum/2;
			sum=0;
		}
	}

	if(num)
    count+=sum/2;

	printf("%lld\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main (){
	
	int n;
	int cont=0;
	cin >> n;
	int a[n];
	bool mayor = true;
	for (int i=0; i<n; i++){
		cin >> a[i];
		for(int j=0;j<=i && mayor; j++){
			if (a[j] > a[i]){
				mayor = false; 
			}
		}
		if (mayor) cont++; 
		mayor = true;
	}
	cout << cont;
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using big_int = boost::multiprecision::cpp_int;
#define ll long long
#define pb push_back
#define mod 1000000007
#define pi 3.14159265359
#define MAX_CHAR 128
using namespace boost::multiprecision;
using namespace std;

int main() 
{
	ll i,j,k,n,x,t;
	string s;
	ll h,a;
	cin>>h>>a;
	cout<<ceil(h*1.0/a);
	return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (B >= C) {
    cout << "delicious" << endl;
    return 0;
  }
  if (C-B <= A) {
    cout << "safe" << endl;
    return 0;
  }
  cout << "dangerous" << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  int sum = 0;
  for(int i = 0; i < m; i++) {
    cin >> a.at(i);
    sum += a.at(i);
  }
  if(n-sum >= 0)cout << n - sum << endl;
  else cout << -1 << endl;
} 

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  int ans = 0;

  if (A == B && B == C) ans = 1;
  else if (A != B && B != C && A != C) ans = 3;
  else ans = 2;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
const int nax = 1000*1000 + 10;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a[5];
    for(int i =0;i<5;++i)cin>>a[i];
    int ok ;
    for(int i =0;i<5;++i)if(a[i] == 0)ok = i+1;
    cout << ok;
   
    return 0;
}
    

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    string s;
    cin >> s;
    bool isRev = false;
    string b = "";
    string e = "";
    ll Q;
    cin >> Q;
    for (ll i = 0; i < Q; ++i) {
        int type;
        cin >> type;
        if(type == 1){
            isRev = !isRev;
        }else{
            int mode;
            cin >> mode;
            char c;
            cin >>c;
            if(isRev){
                if(mode == 1){
                    e.push_back(c);
                }else{
                    b.push_back(c);
                }
            }else{
                if(mode == 1){
                    b.push_back(c);
                }else{
                    e.push_back(c);
                }
            }
        }
    }
    //cout << b << "," << e;
    reverse(b.begin(),b.end());
    s = b + s + e;
    if(isRev){
        reverse(s.begin(),s.end());
        cout << s << endl;
    }else{
        cout << s << endl;
    }
}


Measured memory_bytes: 1348
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max = 0;
		int min = 1000000000;
		for(int i = 0; i < n; i++){
			int work = sc.nextInt();
			max = Math.max(max,work);
			min = Math.min(min,work);
		}
		System.out.print(max-min);
	}
}


Measured memory_bytes: 21460
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
int imos[35][200010] = {};

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

  for (int i = 0; i < n; i++) {
    int s, t, c; cin >> s >> t >> c;
    c--;
    imos[c][2 * s - 1]++;
    imos[c][2 * t]--;
  } 

  for (int i = 0; i < c; i++) {
    for (int j = 1; j < 200010; j++) {
      imos[i][j] += imos[i][j - 1];
    }
  }

  int ans = 0;
  for (int i = 0; i < 200010; i++) {
    int tmp = 0;
    for (int k = 0; k < c; k++) {
      if (imos[k][i]) tmp++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


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

signed main() {
  int N;
  cin >> N;

  if (N % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  N /= 2;

  int div = 5, ans = 0;

  while (true) {
    ans += N / div;
    if (N / div == 0) {
      break;
    }
    div *= 5;
  }

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

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

using namespace std;

template<typename T>
class UF
{
public:
	UF()
	{
		count = 0;
	}

	void push(T a)
	{
		M[a] = count;
		V.push_back(count);
		rank.push_back(0);
		count++;
	}

	void unite(T a , T b)
	{
		long long int x = find(M[a]);
		long long int y = find(M[b]);
		if(x == y)return;
		if(rank[x] < rank[y])
		{
			V[x] = y;
		} else
		{
			V[y] = x;
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	void merge(T a , T b)
	{
		unite(a , b);
	}
	bool same(T a , T b)
	{
		return find(M[a]) == find(M[b]);
	}
	long long int group()
	{
		set<long long int>S;
		for(long long int i = 0; i < V.size(); i++)
		{
			S.insert(find(V[i]));
		}
		return S.size();
	}

private:
	vector<long long int> V , rank;
	map < T , long long int>M;
	long long int count;

	long long int find(long long int x)
	{
		if(V[x] == x)return x;
		else return V[x] = find(V[x]);
	}
};

int main()
{
	int W , H;
	while(cin >> W >> H , W || H)
	{
		vector<vector<char>>VVC(H , vector<char>(W));
		UF<pair<int , int>>UFP;
		pair<int,int>at;
		for(size_t i = 0; i < H; i++)
		{
			for(size_t j = 0; j < W; j++)
			{
				cin >> VVC[i][j];
				UFP.push(make_pair(i , j));
				if(VVC[i][j]=='@')
				{
					at=make_pair(i,j);
				}
				if(VVC[i][j] != '#')
				{
					if(i != 0)
					{
						if(VVC[i - 1][j] != '#')
						{
							UFP.merge(make_pair(i , j) , make_pair(i - 1 , j));
						}
					}
					if(j != 0)
					{
						if(VVC[i][j - 1] != '#')
						{
							UFP.merge(make_pair(i , j) , make_pair(i , j - 1));
						}
					}
				}

			}
		}
		int ans=0;
		for(size_t i = 0; i < H; i++)
		{
			for(size_t j = 0; j < W; j++)
			{
				if(UFP.same(at,make_pair(i,j)))
				{
					ans++;
				}
			}
		}
		cout<<ans<<endl;
	}
}

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

int main() {
	int n,m;
	scanf("%d%d", &n,&m);
	int p;
	int penalty=0,ACnum=0;
	char str[3]={};
	int judge[100000]={};
	for (int i = 0; i < m; i++) {
		scanf("%d%s", &p,str);
		if(strcmp(str,"AC")==0){
			if(judge[p-1]!=-1){
				penalty+=judge[p-1];
				ACnum++;
				judge[p-1]=-1;
			}
		}else{
			if((judge[p-1]!=-1)){
				judge[p-1]++;
			}
		}
	}
	printf("%d %d\n", ACnum,penalty);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>

int main(){
    ll N, X, T;
    cin >> N >> X >> T;

    ll ans = 0;
    ans = (N+X-1)/X * T;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int dp[5010][5010];
signed main(void)
{
  int n;
  cin >> n;
  VVI v;
  REP(i, n) {
    int h, p;
    cin >> h >> p;
    v.PB({h+p, h, p});
  }
  sort(ALL(v));

  // cout << endl;
  // REP(i, n) {
  //   cout << v[i][1] << " " << v[i][2] << endl;
  // }

  REP(i, n) REP(j, n+1) dp[i][j] = INF;
  dp[0][0] = 0;
  dp[0][1] = v[0][2];
  FOR(i, 1, n) {
    dp[i][0] = 0;
    FOR(j, 1, n+1) {
      if(dp[i-1][j-1] <= v[i][1]) dp[i][j] = min(dp[i-1][j], dp[i-1][j-1] + v[i][2]);
      else dp[i][j] = dp[i-1][j];
    }
  }

  // REP(i, n) {
  //   REP(j, n+1) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  int ret = 0;
  REP(i, n+1) if(dp[n-1][i] < INF) ret = i;
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 196352
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
#define INF (1 << 30)

int A[2000001];
int H;
void maxHeapify(int i);
void insert(int key);
void increaseKey(int i, int key);
int extract();

int main() { 
    string com;
    int key;
    while( 1 ) {
        cin >> com;
        if (com == "insert") {
            cin >> key;
            insert(key);
        }
        else if (com == "extract") {
            cout << extract() << '\n';
        }
        else if (com == "end")
            break;
    }
}


void maxHeapify(int i) {

    int l = i * 2;
    int r = i * 2 + 1;
    int largest;

    if (l <= H and A[l] > A[i])
        largest = l;
    else 
        largest = i;

    if (r <= H and A[r] > A[largest]) 
        largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract() {
    int maxv;
    if (H < 1) return -INF;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) {
    if ( key < A[i]) return ;
    A[i]  = key;
    while (i > 1 and A[i/2] < A[i]) {
        swap(A[i], A[i/2]);
        i = i / 2;
    }
}

void insert(int key) {
    H++;
    A[H] = -INF;
    increaseKey(H, key);
}



Measured memory_bytes: 7052
#include<stdio.h>
#include<math.h>

int main(){
    int N, L;
    int i;
    int sum=0;
    int abstmp=100000, tmp;
    int ans;

    scanf("%d %d", &N, &L);

    for(i=0; i<N; i++){
        tmp = L + i;
        sum += tmp;
        if(abstmp> abs(tmp)){
            abstmp = abs(tmp);
            ans = tmp;
        }
    }

    printf("%d", sum-ans);

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#define MAX_S 100000

char s[MAX_S+1];

int main(){
    int n;
    scanf("%s", s);
    if (s[0]==s[1]) {
        printf("1 2\n");
        return 0;
    }
    for (n=0; s[n+2]!='\0'; n++){
        if (s[n]==s[n+1]){
            printf("%d %d\n", n+1, n+2);
            return 0;
        }
        if (s[n+1]==s[n+2]){
            printf("%d %d\n", n+2, n+3);
            return 0;
        }
        if (s[n]==s[n+2]){
            printf("%d %d\n", n+1, n+3);
            return 0;
        }
    }
    printf("-1 -1\n");
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  ll ans = -1000000000000000;
  vector<vector<int>> F(n, vector<int>(10));
  vector<vector<ll>> P(n, vector<ll>(11));
  rep(i, n){
    rep(j, 10){
      cin >> F[i][j];
    }
  }
  rep(i, n){
    rep(j, 11){
      cin >> P[i][j];
    }
  }
  for (int bit = 1; bit < (1 << 10); bit++){
    vector<int> d(10,0);
    ll tmp = 0;
    rep(i,10){
      if(bit & (1 << i)){
        d[i] = 1;
      }
    }
    rep(i, n){
      int cn = 0;
      rep(j, 10){
        if(d[j] == 1 && F[i][j] == 1)cn++;
      }
      tmp += P[i][cn];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;

struct Q
{
	ll a, b;
};

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

	vector<Q> q1, q2;

	rep(i, n)
	{
		string s;
		cin >> s;

		Q q = {};
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.a = max(q.a, close - open);
			}
		}
		reverse(all(s));
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.b = max(q.b, open - close);
			}
		}

		if (q.b - q.a >= 0)
			q1.push_back(q);
		else
			q2.push_back(q);
	}

	auto p = &Q::a;

	sort(all(q1), [p](Q x, Q y) {
		return x.*p < y.*p;
		});

	p = &Q::b;
	sort(rall(q2), [p](Q x, Q y) {
		return x.*p < y.*p;
		});

	ll pos = 0, min_pos = 0;
	rep(i, q1.size())
	{
		pos -= q1[i].a;
		min_pos = min(min_pos, pos);
		pos += q1[i].b;
	}
	rep(i, q2.size())
	{
		pos -= q2[i].a;
		min_pos = min(min_pos, pos);
		pos += q2[i].b;
	}

	if (pos == 0 && min_pos >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 18720
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    ll k;
    cin >> n >> k;
    vector<P> v;
    rep(_,n) {
        int a,b;
        cin >> a >> b;
        v.eb(a,b);
    }
    sort(all(v));
    ll sum = 0;
    for(auto p : v) {
        if(sum+p.second >= k) {
            cout << p.first << endl;
            return 0;
        }
        sum += p.second;
    }
}


Measured memory_bytes: 1400
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let prefix n (a : char []) =
    let b = Array.init n (fun _ -> 0)
    let rec aux c i =
        if i >= n then
            ()
        elif i <= n - 2 && a.[i] = 'A' && a.[i+1] = 'C' then
            b.[i] <- c
            b.[i+1] <- c + 1
            aux (c + 1) (i + 2)
        else
            b.[i] <- c
            aux c (i + 1)
    aux 0 0
    b

[<EntryPoint>]
let main _ =
    let [n;q] = reads int
    let ss = (read id).ToCharArray()
    let lrs = List.map (fun _ -> reads int |> fun [l;r] -> (l-1, r-1)) [1..q]
    let p = prefix n ss
    List.iter (fun (l, r) -> printfn "%i" (p.[r] - p.[l])) lrs
    0

Measured memory_bytes: 30624
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 201

using namespace std;
int N, M, R;
vector<int> r;
bool visited[NCONS];
ll dist[NCONS][NCONS];
vector<ll> result;

ll dfs(int cur_node)
{
	ll ret = LLONG_MAX;
	if (result.size() >= (R - 1))
	{
		ret = 0;
		for (int i = 0; i < result.size(); i++)
			ret += result[i];
		return ret;
	}

	for (int i = 0; i < r.size(); i++)
	{
		auto cand = r[i];
		if (visited[cand]) continue;
		visited[cand] = true;

		result.push_back(dist[cur_node][cand]);

		ret = min(ret, dfs(cand));

		visited[cand] = false;
		result.pop_back();
		
	}
	return ret;

}


int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	cin >> N >> M >> R;
	for (int i = 0; i < R; i++) { int temp; cin >> temp; r.push_back(temp); }
	for (int i = 1; i <= N; i++) for (int j = 1; j <= N; j++) dist[i][j] = LLONG_MAX / 2;
	for (int i = 1; i <= N; i++) dist[i][i] = 0;
	for (int i = 0; i < M; i++)
	{
		int a, b, c; cin >> a >> b >> c;
		dist[a][b] = c;
		dist[b][a] = c;
	}

	for (int k = 1; k <= N; k++)
	{
		for (int i = 1; i <= N; i++)
		{
			for (int j = 1; j <= N; j++)
			{
				if (dist[i][j] > dist[i][k] + dist[k][j])
					dist[i][j] = dist[i][k] + dist[k][j];
			}
		}
	}

	ll ret = LLONG_MAX;
	for (int i = 0; i < r.size(); i++)
	{
		auto cur_node = r[i];
		visited[cur_node] = true;
		ret = min(ret, dfs(cur_node));
		visited[cur_node] = false;
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

class Dice {
	int num[6];
public:
	void set(int n, int s) {
		num[s] = n;
	}

	void move(char c) {
		if (c == 'E') {
			swap(num[0], num[3]);
			swap(num[3], num[5]);
			swap(num[5], num[2]);
		}
		else if (c == 'N') {
			swap(num[0], num[1]);
			swap(num[1], num[5]);
			swap(num[5], num[4]);
		}
		else if (c == 'S') {
			swap(num[0], num[4]);
			swap(num[4], num[5]);
			swap(num[5], num[1]);
		}
		else if (c == 'W') {
			swap(num[0], num[2]);
			swap(num[2], num[5]);
			swap(num[5], num[3]);
		}
	}

	int up() {
		return num[0];
	}

	void move_up(int n) {
		for (int i = 0; up() != n && i < 4; i++)
			move('E');
		for (int i = 0; up() != n && i < 4; i++)
			move('N');
	}

	int up_front_to_right(int n, int m) {
		move_up(n);
		if (num[1] == m) {
			return num[2];
		}
		else if (num[2] == m) {
			return num[4];
		}
		else if (num[3] == m) {
			return num[1];
		}
		else {
			return num[3];
		}
	}
};

int main() {
	Dice d;
	int n;
	for (int i = 0; i < 6; i++) {
		scanf("%d", &n);
		d.set(n, i);
	}
	int m, a, b;
	scanf("%d", &m);
	for (int i = 0; i < m; i++) {
		scanf("%d %d", &a, &b);
		printf("%d\n", d.up_front_to_right(a, b));
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using pp = pair<int, int>;
const int INF = 1e9;

char itoc(int i) { return i + '0'; }
int ctoi(char c) { return c - '0'; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S;
    cin >> S;

    vector<char> ascii;
    for (int c = 0; c < 2; c++) {
        for (int i = 17; i <= 42; i++) {
            ascii.push_back(itoc(i));
        }
    }

    vector<char> ret;
    for (int i = 0; i < S.length(); i++) {
        int d = (find(ascii.begin(), ascii.end(), S[i]) - ascii.begin());
        ret.push_back(ascii[d + N]);
    }
    for (auto& i : ret) {
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 4000007
#define mod 1000000007
int main()
{
    ll i,j,k,l,m,n,c;
    string s,s1;
    cin>>s>>s1;
    reverse(s.begin(),s.end());
    if(s==s1)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int N;
  cin >> N;
  int dp[N+1];
  const int INF = 1e9;
  for(int i=0; i<N+1; i++) dp[i] = INF;
  // dp[9^n] -> dp[2*9^n]

  int q_nine = 9;
//  while(q_nine <= N) q_nine*=9;
/*
  for(int i=0; i<N; i++){
    for(int j=0; i+(j+1)*q_nine<=N; j++){
      dp[i+(j+1)*q_nine] = min(dp[i+(j+1)q_nine], dp[i] + j+1);    
    }
  }
*/
  dp[0] = 0;
  while(q_nine <= N){
    for(int i=0; i+q_nine<=N; i++){
      dp[i+q_nine] = min(dp[i+q_nine], dp[i] + 1);    
    }
    q_nine*=9;
  }
  int q_six = 6;
  while(q_six <= N){
    for(int i=0; i+q_six<=N; i++){
      dp[i+q_six] = min(dp[i+q_six], dp[i] + 1);    
    }
    q_six*=6;
  }
  for(int i=0; i+1<=N; i++){
    dp[i+1] = min(dp[i+1], dp[i]+1);
  }
  cout << dp[N] << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 50005, P = 1e9, M = 200000;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    int cnt[123] = {0};
    for (int i = 0; i < n; i++) {
        int y;
        cin >> y;
        cnt[y] = 1;
    }
    int q = 0;
    while (true) {
        if (!cnt[x - q]) {
            cout << x - q << '\n';
            break;
        }
        else if (!cnt[x + q]) {
            cout << x + q << '\n';
            break;
        }
        q++;
    }
    return 0;
}

Measured memory_bytes: 3612
#include<stdio.h>
#define NOT_FREE (-1)
#define FREE (-2)
#define N 8
#define TRUE 1
#define FALSE 0

void putQueen(int);
void printBoard(void);
int col[N],dpos[N*2-1],dneg[N*2-1],row[N],X[N][N];
int main()
{
  int insert,i,j,k;
  for(i=0;i<N;i++)
    {
      col[i]=FREE;
      row[i]=FREE;
    }
  for(i=0;i<N*2-1;i++)
    {
      dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      X[i][j]=FALSE;
  scanf("%d",&insert);
  for(i=0;i<insert;i++)
    {
      scanf("%d %d",&j,&k);
      X[j][k]=TRUE;
    }
  putQueen(0);
  return 0;
}

void putQueen(int i)
{
  int j;
  if(i==N)
    {
      printBoard();
      return;
    }
  for(j=0;j<N;j++)
    {
      if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE)
	continue;
      row[i]=j;
      col[j]=dpos[i+j]=dneg[i-j+N-1]=NOT_FREE;
      putQueen(i+1);
      row[i]=col[j]=dpos[i+j]=dneg[i-j+N-1]=FREE;
    }
}
void printBoard(void)
{
  int i,j,k;
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(X[i][j])
	    {
	      if(row[i]!=j)return;
	    }
	}
    }
  for(i=0;i<N;i++)
    {
      for(j=0;j<N;j++)
	{
	  if(row[i]==j)
	    printf("Q");
	  else
	    printf(".");
	}
      printf("\n");
    }
}



Measured memory_bytes: 2112
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	rs := getRunes()
	rs[0]++
	ans := string(rs)
	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
def main():
    nums = [int(num) for num in input()]

    for bit in range(1<<3):
        result = nums[0]
        ans = str(nums[0])
        
        for i in range(3):
            if (bit>>i) & 1:
                result += nums[i+1]
                ans += "+" + str(nums[i+1])
            else:
                result -= nums[i+1]
                ans += "-" + str(nums[i+1])

        ans += "=7"
        if result == 7:
            print(ans)
            exit()
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
ai,ao,_,aj,al,_,_ = map(int,input().split())
K = 0
K += ao + (ai//2)*2 + (aj//2)*2 + (al//2)*2
if ai%2 + aj%2 + al%2 == 2 and ai > 0 and al > 0 and aj > 0:
    K += 1
if ai%2 + aj%2 + al%2 == 3:
    K += 3 
print(K) 


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)


int main()
{
	int n,k;
	cin>>n>>k;
	int a[n];
	ffor(i,0,n) cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    ffor(i,2,n)
    {
    	int minn=INT_MAX;
    	ffor(j,0,min(k,i))
    	{
    		int x=dp[i-j-1]+abs(a[i]-a[i-j-1]);
    		if(x<minn) minn=x;
    	}
    	dp[i]=minn;
    }
    cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main()
{	
	std::string s;

	std::cin >> s ;
	while (true) {

		std::string::size_type pos =  s.find(",");
		if (pos != std::string::npos) {
			s.replace(pos, 1, " ");
		}
		else {
			break;
		}
	}
	std::cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int n,m;
ll ans;
int wide[1500001],hight[1500001];
int w[1505],h[1505];

void enumerate_hight(){
  int sum;
  for(int i=0;i<n;i++){
    sum=0;
    for(int j=i;j<n;j++){
      sum+=h[j];
      hight[sum]++;
    }
  }
}

void enumerate_wide(){
  int sum;
  for(int i=0;i<m;i++){
    sum=0;
    for(int j=i;j<m;j++){
      sum+=w[j];
      wide[sum]++;
    }
  }
}

void solve(){
  ll max_w=0,max_h=0,maxi;
  ans=0;
  for(int i=0;i<n;i++){scanf("%d",&h[i]);max_h+=h[i];}
  enumerate_hight();
  for(int i=0;i<m;i++){scanf("%d",&w[i]);max_w+=w[i];}
  enumerate_wide();
  maxi=max(max_w,max_h);
  rep(i,maxi+1){ans+=wide[i]*hight[i];wide[i]=hight[i]=0;}
  printf("%lld\n",ans);
}

int main(){
  while(scanf("%d%d",&n,&m)){
    if(n==0&&m==0)break;
    solve();
  }
}

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

int main(){
  int n;
 string mp;
 cin>>n>>mp;
  int a=0,b=0;
  while(mp[a]=='<')a++;
  while(n-1-b&&mp[n-1-b]=='>')b++;
  cout <<n-min(a,b)<<endl;
  return 0;
}

Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String b = sc.next();
		
		if (b.equals("A")) {System.out.println("T");}
		if (b.equals("T")) {System.out.println("A");}
		if (b.equals("C")) {System.out.println("G");}
		if (b.equals("G")) {System.out.println("C");}
	}
}

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

int main() {
     int x,y,z,flag=0,count,i,j,k,n=0;
     cin>>x;
     int t=x%1000;
     if(t!=0)
     cout<<1000-t;
     else
     cout<<0;
	return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

void add(int x, set<int>& d) {
  rep(i, 21) {
    if ((x >> i) & 1) {
      d.insert(i);
    }
  }
}

void sub(int x, set<int>& d) {
  rep(i, 21) {
    if ((x >> i) & 1) {
      d.erase(d.find(i));
    }
  }
}

bool check(int x, const set<int>& d) {
  rep(i, 21) {
    if (((x >> i) & 1) && d.find(i) != d.end()) {
      return false;
    }
  }
  return true;
}

int main() {
  //
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  int l = 0, r = 0;
  set<int> digits;
  add(a[0], digits);
  ll ans = 0;
  while (l < n) {
    while (r < n - 1 && check(a[r + 1], digits)) {
      r++;
      add(a[r], digits);
    }
    ans += r - l + 1;
    // cout << l << ":" << r << endl;

    sub(a[l], digits);
    l++;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n],dp[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
		dp[i]=INT_MAX;
	}
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(i-j>=0)
			dp[i]=min(dp[i],dp[i-j]+abs(arr[i]-arr[i-j]));
		}
	}
	cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int can_up_digit(ll n) {
    int digit = 0;

    while (n >= 10) {
        if ((n % 10) != 9 && ((n / 10) % 10 >= n % 10)) {
            return digit;
        }
        else {
            digit++;
            n /= 10;
        }
    }
    if (n == 9) return digit + 1;
    else return digit;
}

ll get_next(ll n) {
    string s = to_string(n);
    int digit = can_up_digit(n), size = s.size();
    int start;
    if (digit < size) {
        s[size - digit - 1]++;
        start = size - digit;
    }
    else {
        s = "1" + s;
        start = 1;
    }
    FOR(i, start, s.size()) {
        if (s[i - 1] == '0') s[i] = '0';
        else s[i] = s[i - 1] - 1;
    }

    return stoll(s);
}

int main() {
    ll K, ans = 0;
    cin >> K;
    REP(i, K) ans = get_next(ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define read(type) readInt<type>() // Fast read
#define ll long long
#define endl "\n"
#define pb push_back
#define mk make_pair
#define pii pair<int, int>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define umap unordered_map
#define uset unordered_set
#define MOD 1000000007
#define imax INT_MAX
#define imin INT_MIN
#define exp 1e9
#define sz(x) (int((x).size()))
#define int long long

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int m; cin >> m;
    if(m < 600) {
        cout << 8 << endl;
        return 0;
    }
    if (m < 800)
    {
        cout << 7 << endl;
        return 0;
    }
    if (m < 1000)
    {
        cout << 6 << endl;
        return 0;
    }
    if (m < 1200)
    {
        cout << 5 << endl;
        return 0;
    }
    if (m < 1400)
    {
        cout << 4 << endl;
        return 0;
    }
    if (m < 1600)
    {
        cout << 3 << endl;
        return 0;
    }
    if (m < 1800)
    {
        cout << 2 << endl;
        return 0;
    }
    if (m < 2000)
    {
        cout << 1 << endl;
        return 0;
    }

    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
using namespace std;
#define ll long long
#include<bits/stdc++.h>
int main(){
  ll n;
  cin>>n;
  vector<ll>a(n);
  map<ll,ll>m;
  for(ll i=0;i<n;i++){
    cin>>a[i];
    m[a[i]]++;
  }
  ll ans=0;
  for(auto &x:m){
    if(x.second>1){
      ans+=(x.second*(x.second-1)/2);
    }
  }
  for(ll i=0;i<n;i++){
    if(m[a[i]]>1){
      cout<<ans-m[a[i]]+1<<"\n";
    }
    else
      cout<<ans<<"\n";
  }
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(), A.end());
  int ans=0;
  for(int i=1;i<N;i++){
    if(A[i]==A[i-1]){
      ans*=0;
      break;
    }
    else {
      ans++;
    }
  }
  if(ans>0){
    cout<<"YES"<<endl;
  }
  else if(ans<=0){
    cout<<"NO"<<endl;
  }
}

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

using namespace std;

int main(void){
    int n;
    cin>>n;
    int c=0,d=0;
    for (int j=1; j<=n; j++) {
        if (j%2!=0) {
            for (int i=1; i<=n; i++){
                if (j%i==0) c++;
            }
            if (c==8) {
                    d++;
                    c=0;
                }
                else{
                    c=0;
            }
        }
    }
    cout<<d<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
prev = 1000000000
max = 0
idx = 0
for i, v in enumerate(h):
    if v > prev:
        if max <= i - 1 - idx:
            max = i - 1 - idx
        idx = i
    prev = v
if max <= n - 1 - idx:
    max = n - 1 - idx
print(max)


Measured memory_bytes: 15020
#include <cstdio>
#include <cstring>

long double solve(int n,long double a,long double d){
    if(!n) return 0;
    long double res=a+d*(2*n-1)/2;
    long double a1=(a*(n-1)*2+(a+2*d)+(3*a+3*d))/(2*n);
    long double a2=((a+d)*(2*(n-1)-1)+(a+3*d)*2+(3*a+6*d))/(2*n);
    return res+solve(n-1,a1,a2-a1);
}

int main(){
    int n;
    double a,d;
    scanf("%d%lf%lf",&n,&a,&d);
    printf("%.20lf\n",(double)solve(n,a,d));
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> p(n);
    REP(i,n) cin>>p[i];
    int ans=0;
    for(int i=1;i<n-1;i++){
        int l=p[i-1];
        int m=p[i];
        int r=p[i+1];
        if((l<m && m<r) || (r<m && m<l)) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
public class Hello{
    
    public static void Main(){
        
        int line = int.Parse(System.Console.ReadLine());
        int maisu = 0;
        
        if(line % 2 == 0){
            maisu = line / 2;
        }
        else{
            maisu = line / 2 + 1;
        }
        System.Console.WriteLine(maisu);
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
#define vecout(V) for(int i=0;i<V.size();i++) {cout<<V[i]<<endl;}
typedef long long ll;

int main(void){
    int a, b;
    cin>>a>>b;
    vector<int> v;
    if(a>=b) {
        rep(i, a) v.push_back(b);
    }
    else rep(i, b) v.push_back(a);
    rep(i, v.size()) cout<<v[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
 
const int inf = (int)1e18 + 10;

void mul(int& a , int b){
  a = (a*b) % mod2;
}
signed main(){
  fast;
  

  int n;
  cin >> n;
  string s;
  cin >> s;
  int a = n , r = 0 , b = 0 , g = 0 , rb = 0 , bg = 0 , gr = 0;
  int ans = 1;
  for(int i  = 0 ; i < 3*n ; i++){
        if(s[i] == 'R'){
            if(bg  > 0)
              mul(ans , bg) , bg-- ;
            else if(b > 0)
              mul(ans , b) , b-- , rb++;
            else if(g > 0)
               mul(ans , g) , g-- , gr++;
            else
              mul(ans , a) , a-- , r++;

        }
        if(s[i] == 'B'){
            if(gr  > 0)
              mul(ans , gr)  , gr--; 
            else if(r > 0)
              mul(ans , r) , r-- , rb++;
            else if(g > 0)
               mul(ans , g) , g-- , bg++;
             else
              mul(ans , a) , a-- , b++;

        }
        if(s[i] == 'G'){
            if(rb  > 0)
             mul(ans , rb) , rb--;
            else if(b > 0)
              mul(ans , b) , b-- , bg++;
            else if(r > 0)
              mul(ans , r) , r-- , gr++;
             else 
              mul(ans , a) , a-- , g++;

        }
  }
  cout << ans << endl;

 
}

Measured memory_bytes: 720
#include <stdio.h>
#include <stdlib.h>
 
int main() {
  int i = 0;
  char s[7];
  char c;
  long a[100],temp;
 
  while(scanf("%s ", s) > 0) {
    c = s[0];
    if(c<'0' || c>'9') {
      switch (c) {
      case '+':
    temp = a[i-2] + a[i-1];
    break;
      case '-':
    temp = a[i-2] - a[i-1];
    break;
      case '*':
    temp = a[i-2] * a[i-1];
    break;
      default:
    break;
      }
      a[i-2] = temp;
      i = i-1;
    }else{
      a[i] = atol(s);
      i++;
    }
  }
  printf("%ld\n", a[0]);
 
  return 0;
}

Measured memory_bytes: 552
#include<bits/stdc++.h>
using namespace std;
int main(){
  int t,a=0,m=0,k=5;
  while(k--&&cin>>t){
    a+=(t+9)/10*10;
    m=max(m,(1000-t)%10);
  }
  cout<<a-m<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 1LL << 30;
ll min(ll a, ll b){ if(a < b) return a; else return b;}

int N;
vector<int> money;
vector<int> dp;

int req(int i){
    if(i == 1) return 1;
    if(dp[i] != INF) return dp[i];
    
    ll res = INF;
    for(int en : money){
        if( (i-en) >= 1) res = min(res, req(i - en) + 1);
    }
    
    return dp[i] = res;
}

int main(void){
    cin >> N;
    
    money.push_back(1);
    for(int i = 1; pow(6, i) <= 100000; i++){
        money.push_back(pow(6, i));
    }
    for(int i = 1; pow(9, i) <= 100000; i++){
        money.push_back(pow(9, i));
    }

    dp.resize(100000+10, INF);
    for(int i = 0; i < money.size(); i++){
        dp[money[i]] = 1;
    }
    cout << req(N) << "\n";
}


Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int count = 0;
		for (int i = a; i <= b; i++) {
			if (c % i == 0) count += 1;
		}
		System.out.println(count);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26328
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
char s[MAXN], t[MAXN];
int cnts[2][MAXN], cntt[2][MAXN];
bool check(int sa, int sb, int ta, int tb)
{
    pair<int, int>x = {(2 * sa + sb) % 3, (sa + 2 * sb) % 3};
    pair<int, int>y = {(2 * ta + tb) % 3, (ta + 2 * tb) % 3};
    if (x.first == y.first || x.second == y.second) return 1;
    return 0;
}
inline int gs(int x, int y, int c) {return cnts[c][y] - cnts[c][x - 1];}
inline int gt(int x, int y, int c) {return cntt[c][y] - cntt[c][x - 1];}
int main()
{
    scanf(" %s", s + 1);
    scanf(" %s", t + 1);
    int lens = strlen(s + 1), lent = strlen(t + 1);
    for (int i = 1; i <= lens; i++)
    {
        cnts[s[i] - 'A'][i]++;
        cnts[0][i] += cnts[0][i - 1];
        cnts[1][i] += cnts[1][i - 1];
    }
    for (int i = 1; i <= lent; i++)
    {
        cntt[t[i] - 'A'][i]++;
        cntt[0][i] += cntt[0][i - 1];
        cntt[1][i] += cntt[1][i - 1];
    }
    int q; scanf("%d", &q);
    for (int i = 1, a, b, c, d; i <= q; i++)
    {
        scanf("%d%d%d%d", &a, &b, &c, &d);
        if (check(gs(a, b, 0), gs(a, b, 1), gt(c, d, 0), gt(c, d, 1))) puts("YES");
        else puts("NO");
    }
    return 0;
}

Measured memory_bytes: 2304
n=int(input())
k=0
c=0
for i in range(n):
  a,b=map(int,input().split())
  if(a==b):
      k+=1
      if(k>=3):
          c=1
  else:
      k=0

if(c==1):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9188
N=int(input())
x=[]
u=[]
for i in range(N):
    s,t=input().split()
    x.append(float(s))
    u.append(t)
total=0
for i in range(N):
    if u[i]=="JPY":
        total+=x[i]
    else:
        total+=380000.0*x[i]
print(total)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#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++)
#define pi 3.14159265359
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vector<pair<pair<string,ll>,ll>> res(N);
  rep(i,N){
    cin>>res[i].first.first>>res[i].first.second;
    res[i].first.second*=-1;
    res[i].second=i+1;
    
  }
  sort(res.begin(),res.end());
  rep(i,N){
    cout<<res[i].second<<endl;
  }
}


Measured memory_bytes: 3632