akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 2e5;
const ll inf = 1e9;
const int sz = 26;
typedef long long ll;


void input(){
    IOS;
    ll n, d;
    cin >> n >> d;
    int cnt = 0;
    f(i, n){
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d * d)++cnt;
    }
    cout << cnt << endl;
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

ll dp[110][1000100];

int main(int argc, char const *argv[])
{
	int N, W; cin >> N >> W;
	vector<int> w(N), v(N); {
		rep(i, N) cin >> w[i] >> v[i];
	}

	rep(i, 110) rep(j, 1000100) dp[i][j] = INFF;
	dp[0][0] = 0;

	rep(i, N)rep(j, 1000001) {
			if (dp[i][j] == INFF) continue;
			dp[i + 1][j + v[i]] = min(dp[i][j] + w[i], dp[i + 1][j + v[i]]);
			dp[i + 1][j] = min(dp[i][j], dp[i + 1][j]);
	}

	ll ans = -1;
	rep(i, 1000100) if (dp[N][i] <= W) ans = i;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 859648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	string s;
	cin>>s;
	ll ans=0;
	for(ll i=0;i<s.size();i++){
		if(i%2==0){
			if(s[i]=='p'){
			ans--;
			}
		}
		else{
			if(s[i]=='g'){
			ans++;
			}
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
const int mod = 1e9+7;
const int mx = INT_MAX;
const long double pi = 4*atan((long double)1);
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
#define file "orz"
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int h,w,k,sx,sy,ex,ey;
signed main()
{
    //freopen(file".inp","r",stdin);
    //freopen(file".out","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>h>>w>>k>>sx>>sy>>ex>>ey;
    char mat[h+5][w+5];
    int dist[h+5][w+5];
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			cin>>mat[i][j];
			dist[i][j]=mx;
		}
	}		
//		for(int i=1;i<=h;i++)
//		for(int j=1;j<=w;j++)
//			cout<<dist[i][j]<<" ";
	queue<pii> q;
	dist[sx][sy] = 0;
	q.push(mp(sx,sy));
	while(!q.empty())
	{
		
		int xx = q.front().fi;
		int yy = q.front().se;
//		cout<<xx<<" "<<yy<<endl;
		q.pop();
		for(int i=0;i<4;i++)
		{
			for(int j=1;j<=k;j++)
			{
//				cout<<"here";
				int xxx = xx + dx[i]*j;
				int yyy = yy + dy[i]*j;
//				cout<<xxx<<" "<<yyy<<endl;
				if(xxx<1 || h<xxx || yyy<1 || w<yyy || mat[xxx][yyy] != '.' || dist[xxx][yyy] <= dist[xx][yy]) 
					break;
                if(dist[xxx][yyy]>dist[xx][yy]+1) 
				{	
					dist[xxx][yyy] = dist[xx][yy]+1;
					q.push(mp(xxx,yyy));
				}
			}
		}
	}
	if(dist[ex][ey]>=mx)
		return cout<<-1,0;
//	for(int i=1;i<=h;i++)
//		for(int j=1;j<=w;j++)
//			cout<<dist[i][j]<<" ";
	cout<<dist[ex][ey];
}


Measured memory_bytes: 13924
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
  int N;
  cin >> N;
  vector<int> A(N), ac(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ac[i + 1] = ac[i] + A[i];
  }

  const int mod = 1e9 + 7;
  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    int t = A[i] * ((ac[N] - ac[i + 1]) % mod) % mod;
    (ans += t) %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;

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

Measured memory_bytes: 1024
n = int(input())
A = list(map(int, input().split()))
ans = 1
count = 0
if 0 in A:
    print(0)
else:
    for i in range(n):
        ans *= A[i]
        if ans > 10**18:
            count = 1
            print(-1)
            break
    if count == 0:
        print(ans)
        

Measured memory_bytes: 21656
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n = int(input())

ans = 10**3
for a in range(1,n):
    b = n-a
    tmp = 0
    for j in reversed(range(len(str(a)))):
        tmpa = (a//(10**j))
        a -= tmpa*(10**j)
        tmp += tmpa
    for j in reversed(range(len(str(b)))):
        tmpb = (b//(10**j))
        b -= tmpb*(10**j)
        tmp += tmpb

    ans = min(ans,tmp)

print(ans)

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

int main() {
	string S; cin >> S;
	int N=0;
	long sum=0;
	for(int i=0; i<S.size(); ++i){
	    if(S[i]=='W'){
	        sum += i-N;
	        ++N;
	    }
	}
	cout << sum << endl;
	return 0;
}


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

#define sz(x) (int)(x.size())
#define FOR(i,L,R) for(int i = L; i <= R; i++)
#define int long long

const int N = 2e5 + 2, inf = 1e18, mod = 1e9 + 7;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    int n;
    cin >> n;
    int ans = 0;
    vector<int> a(n);
    int sum = 0;
    for(int&x : a) cin >> x, sum += x;

    for (int x : a) {
        sum -= x;
        ans = (ans + ((x % mod) * (sum % mod))) % mod;
    }

    cout << ans;

}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int N, M;
	cin >> N >> M;

	vector<int> A(N), B(N);
	for (int i = 0; i < N; i++) cin >> A[i] >> B[i];

	vector<vector<int>> v(1e5 + 1);
	for (int i = 0; i < N; i++) v[A[i]].push_back(B[i]);

	priority_queue<int> pq;
	int ret = 0;

	for (int i = 1; i <= M; i++) {
		for (int j = 0; j < v[i].size(); j++) {
			pq.push(v[i][j]);
		}
		if (pq.empty() == 0) {
			ret += pq.top();
			pq.pop();
		}
	}

	cout << ret << endl;
}

Measured memory_bytes: 9116
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [i32; n],
    }

    p.sort();

    let ans = {
        let mut ans = 0;
        for i in 0..k {
            ans += p[i];
        }
        ans
    };

    println!("{}",ans)
}


Measured memory_bytes: 2152
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _20170409_AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            string line;
            List<string> outList = new List<string>();
            for (; (line = Console.ReadLine()) != "";)
            {
                string[] sArr = line.Split(' ');
                int x = int.Parse(sArr[0]);
                int y = int.Parse(sArr[1]);

                if (x == 0 && y == 0)
                {
                    break;
                }

                if (x < y)
                {
                    outList.Add(string.Format("{0} {1}", x, y));
                }
                else
                {
                    outList.Add(string.Format("{0} {1}", y, x));
                }
            }

            foreach (var v in outList)
            {
                Console.WriteLine(v);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9428
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
const int mod=1e9+7;
char t[maxn];
int n,p[maxn];
int main()
{
    p[0]=1;
    for(int i=1;i<maxn;i++)
        p[i]=1LL*p[i-1]*3%mod;
    scanf("%s",t+1);
    n=strlen(t+1);
    int ans=0,cnt=1;
    for(int i=1;i<=n;i++)
    {
        if(t[i]=='1')
        {
            int tmp=p[n-i];
            ans=(ans+1LL*cnt*tmp%mod)%mod;
            cnt=cnt*2%mod;
        }
    }
    ans=(ans+cnt)%mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 768
import java.util.*;
import java.io.*;
import java.math.*;
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 cnt=0;
        for(int i=0;i<N;i++)
        {
            double a = sc.nextInt();
            double b = sc.nextInt();
            a = Math.pow(a,2);
            b = Math.pow(b,2);
            double temp = a+b;
            double ans = Math.sqrt(temp);
            //System.out.println("\n\t i="+i+" ans="+ans);
            if(ans <= D)
            {
                cnt++;
                //System.out.println(cnt);
            }
            
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 59296
n = int(input())
f = 0
for k in range(1,1000):
    if k*(k-1)//2 == n:
        f = 1
        break
if f == 0:
    print("No")
    exit()
else:
    print("Yes")
    print(k)
l = [[]]*k
a = 1
for i in range(1,k):
    for j in range(0,i):
        l[j] = l[j]+[str(a)]
        l[i] = l[i]+[str(a)]
        a += 1
for i in range(k):
 print(k-1, " ".join(l[i]))

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

int n ;

bool vis[1010] ;

int main(){
	#define NAME ""
	//freopen( NAME".inp" , "r" , stdin ) ; freopen( NAME".out" , "w" , stdout ) ;

	ios_base :: sync_with_stdio(false) ;

	cin >> n ;

	vis[1] = true ;

	for (int i = 2; i <= n; ++ i){
		int foo = i ;
		for (int j = 2;; ++ j){
			foo = foo * i ;
			if(foo > n) break ;
			vis[foo] = true ;
		}
	}
	
	for (int i = n; i >= 1; -- i) if(vis[i]) return cout << i, 0 ;	

	return 0 ;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=input()
L=[]
c=0
for i in range(N):
  if c==0 and S[i]=="1":
    c=1
    s=i
  elif c==1 and S[i]=="0":
    c=0
    t=i-1
    L.append([s,t])
if c==1:
  L.append([s,N-1])
if len(L)<=K-1:
  ans=N
elif len(L)==K:
  if L[0][0]!=0 and L[-1][1]!=N-1:
    ans=max(L[-1][1]+1,N-L[0][0])
  else:
    ans=N
else:
  ans=0
  for i in range(len(L)-K):
    ans=max(ans,L[i+K][1]-L[i][0]+1)
  if L[0][0]!=0:
    ans=max(ans,L[K-1][1]+1)
  if L[-1][1]!=N-1:
    ans=max(ans,N-L[-K][0])
print(ans)

Measured memory_bytes: 11380
# Your code here!
use List::Util qw(max);
my $N= <STDIN>;
my $s= <STDIN>;
my @dat = split(/ /,$s);
my @dp1;#左つめ
my @dp2;#スキップ1
my @dp3;#スキップ2

my $M=  int($N/2);
$dp1[0]=$dat[0];
$dp2[1]=$dat[1];
$dp3[2]=$dat[2];
for(my $i=0;$i<$N;$i++){
  $dp1[$i+2]= $dp1[$i]+$dat[$i+2];
  $dp2[$i+3]= max($dp2[$i+1],$dp1[$i]) + $dat[$i+3];
  $dp3[$i+4]= max($dp3[$i+2],$dp2[$i+1],$dp1[$i]) + $dat[$i+4];
}
if($N==2){
    $ans = max($dat[0],$dat[1]);
    print $ans;exit;
}elsif($N==3){
    $ans = max($dat[0],$dat[1],$dat[2]);
    print $ans;exit;
}

if($N%2){
    print $dp3[$N-1];
}else{
    print $dp2[$N-1];
}
#print "$dp1[$N-1],$dp2[$N-1],$dp3[$N-1]\n";

Measured memory_bytes: 66336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

vector<int> edge[1000000];
int deg[1000000];
int d[1000000];


int main(){
    int n;
    cin>>n;
    int a[n][n-1];
	for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            cin>>a[i][j];
            a[i][j]--;
        }
    }
    
    for(int i=0;i<n;i++){
        for(int j=0;j<n-2;j++){
            int from=max(i,a[i][j])*n+min(i,a[i][j]);
            int to=max(i,a[i][j+1])*n+min(i,a[i][j+1]);
            edge[from].push_back(to);
            deg[to]++;
        }
    }
    queue<int> q;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(i==j)continue;
            int id=max(i,j)*n+min(i,j);
            if(deg[id]==0){
                q.push(id);
                d[id]=1;
            }
        }
    }
    vector<int> toposo;
    int ans=-1;
    while(q.size()){
        int x=q.front();
        q.pop();
        toposo.push_back(x);
        ans=max(ans,d[x]);
        for(int y:edge[x]){
            deg[y]--;
            if(deg[y]==0){
                q.push(y);
                d[y]=d[x]+1;
            }
        }
    }
    if(toposo.size()!=n*(n-1)/2){
        cout<<-1<<endl;
    }
    else{
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 53240
#! /usr/bin/env python3
import sys
sys.setrecursionlimit(10**9)


INF=10**20
def solve(N: int, S: str):
    T = S.replace("ABC","")
    ans = N - len(T)
    ans //= 3

    print(ans)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)



if __name__ == "__main__":
    main()


Measured memory_bytes: 61996
#include <iostream>
//#include <set>
//#include <map>
#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
#include <math.h>
//#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1
 
int main() {
    double r;
    double ans;
    cin >> r;
    ans = 2*r*M_PI;
 
    cout << setprecision(10) << ans << endl;
 
    return 0;
}

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

using namespace std;

#define MAX 110
#define INF (1<<29)
typedef pair<int, int> pii;

int d[11][MAX][MAX]; 

int get_max_block(int M, int N,
                  vector<int> &x, vector<int> &y)
{
    int s = x.size();
    vector<int> cnt(s, 0);
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < N; j++) {
            int mini = INF, mid = -1, c = -1;
            for (int k = 0; k < s; k++) {
                if (d[k][i][j] < mini) {
                    mini = d[k][i][j];
                    c = 1;
                    mid = k;
                } else if (d[k][i][j] == mini) {
                    c = -1;
                }
            }
            if (c == 1) {
                cnt[mid]++;
            }
        }
    }        
    return cnt[s-1];
}

int get_dist(int sx, int sy, int gx, int gy, int M, int N)
{
    queue<pii> Q;
    Q.push(pii(sx, sy));

    vector<vector<int>> md(MAX, vector<int>(MAX, INF));
    md[sy][sx] = 0;

    const int dx[2][6] = {
        {-1, +0, -1, +1, -1, +0},
        {+0, +1, -1, +1, +0, +1}
    };
    const int dy[6] = {-1, -1, +0, +0, +1, +1};
    
    while (!Q.empty()) {
        pii p = Q.front(); Q.pop();
        int x = p.first, y = p.second;
        if (x == gx && y == gy) {
            return md[y][x];
        }

        for (int i = 0; i < 6; i++) {
            int nx = x + dx[y&1][i];
            int ny = y + dy[i];

            if (0 <= nx && nx < M && 0 <= ny && ny < N) {
                if (md[y][x] + 1 < md[ny][nx]) {
                    md[ny][nx] = md[y][x] + 1;
                    Q.push(pii(nx, ny));
                }
            }
        }        
    }
    return INF;
}

int main()
{
    int M, N, s, t;
    while (cin >> M >> N, M) {
        cin >> s;
        vector<int> x(s), y(s);
        for (int i = 0; i < s; i++) {
            cin >> x[i] >> y[i];
            x[i]--; y[i]--;
            for (int j = 0; j < M; j++) {
                for (int k = 0; k < N; k++) {
                    d[i][j][k] = get_dist(x[i], y[i], j, k, M, N);
                }
            }
        }
        
        int res = 0;
        
        cin >> t;
        for (int i = 0; i < t; i++) {
            int X, Y;
            cin >> X >> Y;
            X--; Y--;
            for (int j = 0; j < M; j++) {
                for (int k = 0; k < N; k++) {
                    d[s][j][k] = get_dist(X, Y, j, k, M, N);
                }
            }
            x.push_back(X); y.push_back(Y);
            res = max(res, get_max_block(M, N, x, y));
            x.pop_back(); y.pop_back();
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3252
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <utility>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <iterator>
#include <random>
#include <fstream>
#include <chrono>
#include <math.h>
#include <cctype>
using namespace std;
#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
const int tree_size = (1 << 19);
int n, m;
vector<int> l;
vector<vector<pair<int, int>>> r;
vector<int> mx(tree_size, -2e18);
vector<int> buf(tree_size, 0);

void upd(int v, int l, int r) {
    // нам нужно обновить mx
    // update хочет чтоб в v !было буф
    // наст значеение то что нап в mx + buf[от корня до вершины вкл]
    mx[v] = mx[v] + buf[v];
    if (l < r - 1) {
        buf[2 * v + 1] += buf[v];
        buf[2 * v + 2] += buf[v];
    }
    buf[v] = 0;
}

int get_max(int v, int l, int r, int L, int R) { // l , r - границы L,R запрос
    upd(v, l, r);
    if(R <= l || L >= r)
        return -2e18;
    if(L <= l && r <= R)
        return mx[v];
    int m = (r + l)/2;
    return max(
            get_max(2*v+1, l, m, L, R),
            get_max(2*v+2, m, r, L, R)
    );
}

void relax(int v, int l, int r, int i, int x) {
    upd(v, l, r);
    mx[v] = max(mx[v], x);
    if (r-l==1)
        return;
    int m = (l + r)/2;
    if(i < m)
        relax(2*v+1, l , m, i , x);
    else
        relax(2 * v + 2, m, r, i, x);
}

void add_seg(int v, int l, int r, int L, int R, int x) {
    upd(v, l ,r);
    if(R <= l || L >= r)
        return;
    if(L <= l && r <= R) {
        buf[v]+=x;
        upd(v, l, r);
        return;
    }
    int m = (r + l)/2;
    add_seg(2*v+1, l, m, L, R, x);
    add_seg(2*v+2, m, r, L, R, x);
    mx[v] = max(mx[2 * v + 1], mx[2 * v + 2]);
}

int32_t main() {
    ios::sync_with_stdio(false);
    cin >> n >> m;
    l.resize(n);
    r.resize(n + 1);
    for (int i = 0; i < m; i++) {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        l[x] += c;
        r[y].push_back({x, c});
    }
    relax(0, -1, n, -1, 0);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        add_seg(0, -1, n, -1, i, l[i]);
        for (auto seg: r[i]) {
            add_seg(0, -1, n, -1, seg.first, -seg.second);
        }
        int cur = mx[0];
        ans = max(ans, cur);
        relax(0, -1, n, i, cur);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23988
import java.io.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str = br.readLine();
		String strArr[] = str.split(" ");

		int w, h, x, y, r;

		w = Integer.parseInt(strArr[0]);
		h = Integer.parseInt(strArr[1]);
		x = Integer.parseInt(strArr[2]);
		y = Integer.parseInt(strArr[3]);
		r = Integer.parseInt(strArr[4]);

		if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
			System.out.println("Yes");
		}
		else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17052
#include<iostream>
using namespace std;
int main(void){
  int n,a[100];
  int i,j;
  cin>>n;
  for(i=n-1;i>=0;i--){
    cin>>a[i];
  }
  for(i=0;i<n;i++){
    if(i==0){
      cout<<a[i];
    }else{
      cout<<" "<<a[i];
    }
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define INF 1e18
#define MOD 1000000007
#define PI M_PI
#define ll long long
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, n) for (int i=0; i<n; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define print(x) cout << x << endl;
#define debug(x) cout << #x << " = " << endl;

using namespace std;

void solve()
{
    int r, D, x;
    cin >> r >> D >> x;

    REP(i, 10) {
        x = r * x - D;
        print(x);
    }
}

int main()
{
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int numbers[3], tmp;
	int i, j;
	const int numbers_len = sizeof(numbers) / sizeof(numbers[0]);

	for(i = 0; i <= numbers_len - 1; i++){
		scanf("%d", &numbers[i]);
	}

	// Bubble sort
	for(i = 0; i <= numbers_len - 1; i++){
		for(j = numbers_len - 1; j > i; j--){
			if(numbers[j] < numbers[j-1]){
				tmp = numbers[j-1];
				numbers[j-1] = numbers[j];
				numbers[j] = tmp;
			}
		}
	}

	printf("%d %d %d\n", numbers[0], numbers[1], numbers[2]);
	return 0;
}

Measured memory_bytes: 596
N = int(input())
A = list(map(int,input().split()))

change = []
count = 0
for i in range(N):
  if(i+1 == A[i]): change.append(i+1)

ans = len(change)
for i in range(len(change)):
  if(i != 0): 
    if(change[i]-change[i-1] == 1): 
      ans -= 1
      change[i] = change[i-1]
print(ans)

Measured memory_bytes: 14008
A, B, C, X, Y = list(map(int, input().split()))

price1 = X * A + Y * B
price2 = X * 2 * C + (Y - X) * B if Y > X else X * 2 * C
price3 = Y * 2 * C + (X - Y) * A if X > Y else Y * 2 * C
min_price = min(price1, price2, price3)

print(min_price)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    int len=s.length();
    for(int i=0; i<len; i++)
    {
        int x=i-1,y=i+1;
        if(x>=0 && y<len)
        {
            if((s[x]==s[i] && s[i]!=s[y])  || (s[x]==s[y] && s[i]!=s[y]) ||
                    (s[y]==s[i] && s[i]!=s[x]) || (s[i]==s[x] && s[i]==s[y])
              )
            {
                cout<<x+1<<" "<<y+1<<endl;
                return 0;
            }
        }
        if(i+1<len && s[i]==s[i+1]){
            {
                cout<<i+1<<" "<<i+2<<endl;
                return 0;
            }
        }

    }
    cout<<"-1 -1"<<endl;

    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    cin>>a>>b;
    if(a.size()>b.size()){
        cout<<"GREATER"<<endl;
    }else if(a.size()<b.size()){
        cout<<"LESS"<<endl;
    }else{
        if(a>b){
            cout<<"GREATER"<<endl;    
        }else if(a<b){
            cout<<"LESS"<<endl;
        }else{
            cout<<"EQUAL"<<endl;
        }
    }
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 
#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    input!{
        N: usize,
        A: [i32; N]
    };

    let mut is_passed: bool = true;

    for v in A {
        if v % 2 == 0 {
            if !(v % 3 == 0 || v % 5 == 0) {
                is_passed = false;
            }
        }
    }

    if is_passed {
        println!("APPROVED");
    } else {
        println!("DENIED");
    }
}

fn main() {
    solve();
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,a[100],cnt=0,flag=1;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  while(flag){
    flag=0;
    for(int j=n-1;j>0;j--){
      if(a[j]<a[j-1]){
	swap(a[j],a[j-1]);
	flag=1;
	cnt++;
      }
    }
  }
  for(int i=0;i<n;i++){
    cout<<a[i];
    if(i==n-1)cout<<endl;
    else cout<<" ";
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 3124
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

struct Point{
    double x;
    double y;
};

void koch(int n,Point a,Point b){
    if(n == 0)return;
    Point s,t,u;
    double th = M_PI * 60/180.0;
    s.x = (2 * a.x + b.x) / 3.0;
    s.y = (2 * a.y + b.y) / 3.0;
    t.x = (2 * b.x + a.x) / 3.0;
    t.y = (2 * b.y + a.y) / 3.0;
    u.x = (t.x - s.x)*cos(th) -(t.y - s.y)*sin(th) + s.x;
    u.y = (t.x - s.x)*sin(th) + (t.y - s.y)*cos(th) + s.y;
    
    koch(n- 1,a,s);
    printf("%.8lf %.8lf\n",s.x,s.y);
    
    koch(n- 1,s,u);
    printf("%.8lf %.8lf\n",u.x,u.y);
    
    koch(n- 1,u,t);
    printf("%.8lf %.8lf\n",t.x,t.y);
    
    koch(n- 1,t,b);
    
}

int main(){
    Point a,b;
    int n;
    cin >> n;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
    printf("%.8lf %.8lf\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8lf %.8lf\n",b.x,b.y);
}


Measured memory_bytes: 3192
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i = 0 ; i < n ; ++i)
#define rep1(i,n) for(int i = 1 ; i <= n ; ++i)
using namespace std;
typedef long long ll;
const int VMAX=100010;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int n;
int x[100010],y[100010];
vector<int> edge[VMAX];
mint dp[100010][2];
bool f[100010];
void add_edge(int from,int to){
  edge[from].push_back(to);
  edge[to].push_back(from);
}
void dfs(int s){
  f[s] = true;
  int ss = edge[s].size();
  dp[s][0] = dp[s][1] = 1;
  rep(i,ss){
    int w = edge[s][i];
    if(f[w]) continue;
    dfs(w);
    dp[s][0] *= dp[w][0] + dp[w][1];
    dp[s][1] *= dp[w][0];
  }
}
int main()
{
  cin >> n;
  rep(i,n-1) cin >> x[i] >> y[i];

  rep(i,n-1) add_edge(--x[i],--y[i]);
  rep(i,n) f[i] = false;

  dfs(0);
  mint res = dp[0][0] + dp[0][1];
  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 13696
#include<stdio.h>
#include<stdlib.h>
#define QSIZE 100
#define INFTY 1<<21

void enqueue(int);
int dequeue(void);
void bfs(int);

int queue[QSIZE];
int head=0;
int tail=0;
int n,A[QSIZE][QSIZE],d[QSIZE];

int main()
{
  int i,j,x,y,z;
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++)A[i][j]=0;}

  for(i=0;i<n;i++){
    scanf("%d%d",&x,&y);
    for(j=0;j<y;j++){
      scanf("%d",&z);
      A[x-1][z-1]=1;}
  }

  bfs(0);
  return 0;
}

void enqueue(int num)
{
  int next=(tail+1)%QSIZE;
  if(next==head){
    printf("Queue is overflow\n");
    exit(2);}
  queue[tail]=num;
  tail=next;
}

int dequeue(void)
{
  int val;
  if(head==tail){
    printf("queue is empty\n");
    exit(3);}
  val=queue[head];
  head=(head+1)%QSIZE;
  return val;
}

void bfs(int s)
{
  int i,u,v;
  enqueue(s);
  for(i=0;i<n;i++)d[i]=INFTY;
  d[s]=0;
  while(head!=tail)
    {
      u=dequeue();
      for(v=0;v<n;v++){
	if(A[u][v]==0)continue;
	if(d[v]!=INFTY)continue;
	d[v]=d[u]+1;
	enqueue(v);
      }
    }
  for(i=0;i<n;i++){
    printf("%d ",i+1);
    if(d[i]==INFTY)printf("%d",-1);
    else printf("%d",d[i]);
    printf("\n");
  }
}



Measured memory_bytes: 2084
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <map>
#define F first
#define S second
#define INF 0x3f3f3f3f
#define MAXN 100005
#define $ ios::sync_with_stdio(0);
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> graph;

int dp[MAXN];
int v[112], w[112];
int main() {
    int n, m, ans = 0;
    scanf("%d %d", &n, &m);
    for (int i = 1; i<=n; ++i) {
        scanf("%d %d", w+i, v+i);
    }
    dp[0] = m;
    for (int i = 1; i<=n; ++i) {
        for (int j = ans; j>=0; --j) {
            if (dp[j]>=w[i]) {
                dp[j+v[i]] = max(dp[j+v[i]], dp[j]-w[i]);
                if (j+v[i]> ans) ans = j+v[i];
            }
        }
    }
    printf("%d\n", ans);
}



Measured memory_bytes: 640
//https://atcoder.jp/contests/abc125/tasks/abc125_a
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int A, B, T;
    cin >> A >> B >> T;
    int sum{};
    for( int i = A; i < T + 0.5 ; i+=A )
    {
        sum += B;
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()


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

  string d[7] = {"SAT","FRI","THU","WED","TUE","MON","SUN"};

  string s;
  cin >> s;

  int ret = 0;
  rep(i,7){
    if(s == d[i])ret = i+1;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define ll long long
#define endl "\n"
#define print_array(name,n) for(ll o=0;o<n;o++) cout<<name[o]<<" "
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 2e18
#define pll pair<ll,ll>
#define pii pair<int,int>
bool sortbysecond(const pair<int,int> &a,const pair<int,int> &b){
	return (a.ss>b.ss);
}
 
ll gcd(ll a,ll b){ if(b==0) return a; return gcd(b,a%b) ;} 

template <typename T>
string NumberTostring(T Number )
{
	ostringstream ss;
	ss<<Number;
	return ss.str();
}
 
ll h,w;
ll ix,iy,dx,dy;

bool isvalid(int r,int c,vector<vector<int>> &maze){
	return (r>=0 and r<h and c>=0 and c<w and maze[r][c]==1);
}

ll find(vector<vector<int>> &maze){
	set<pair<ll,pair<int,int>>> st;
	ll dist[h][w];
	// memset(dist,INT_MAX,sizeof(dist));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dist[i][j] = INT_MAX;
			// cout<<dist[i][j]<<" ";
		}
		// cout<<endl;
	}
	st.insert({0,{ix,iy}});
	dist[ix][iy] = 0;
// for(int i=0;i<h;i++){
// 		for(int j=0;j<w;j++){
// 			// dist[i][j] = INT_MAX;
// 			cout<<dist[i][j]<<" ";
// 		}
// 		cout<<endl;
// 	}
	while(!st.empty()){
		auto temp = *(st.begin());
		st.erase(st.begin());
		auto cur = temp.ss;

		// cout<<temp.ff<<" "<<temp.ss.ff<<" "<<temp.ss.ss<<endl;
		for(int i=-2;i<3;i++){
			for(int j=-2;j<3;j++){
				int x = cur.ff+i;
				int y = cur.ss+j;

				if(!(isvalid(x,y,maze)) ){
					continue;
				}
				long long delta;
				if(abs(x-cur.ff) + abs(y-cur.ss) ==1){
					delta = 0;

				}
				else{
					delta = 1;
				}

				if(dist[x][y]>dist[cur.ff][cur.ss]+delta){
					if(dist[x][y]!=INT_MAX){
						auto pos = st.find({dist[x][y],{x,y}});
						if(pos!=st.end()){
							st.erase(pos);
						}
					}

					dist[x][y] = dist[cur.ff][cur.ss]+delta;
					st.insert({dist[x][y],{x,y}});
				}

			}
		}

	}
	if(dist[dx][dy]==INT_MAX){
		return -1;
	}
	else{
		return dist[dx][dy];
	}
}

void solve(){
	cin>>h>>w;
	cin>>ix>>iy>>dx>>dy;
	ix--;
	iy--;
	dx--;
	dy--;
	vector<vector<int>> maze(h,vector<int>(w));
	
	for(int i=0;i<h;i++){
		string s;
		cin>>s;
		for(int j=0;j<w;j++){
			if(s[j]=='.'){
				maze[i][j] = 1;
			}
			else{
				maze[i][j] = 0;
			}
			// cout<<maze[i][j];
		}
		// cout<<endl;

	}
	cout<<find(maze)<<endl;


}
 
int main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	ll t;
	// cin>>t;
	t=1;
	while(t--){
		solve();
	}    
    return 0;
}

Measured memory_bytes: 15492
#include <iostream>
#include <utility>
int partition(int A[], int p, int r){
  int x;
  int i;

  using std::swap;

  x = A[r];
  i = p-1;
  for(int j=p; j<r; j++){
    if(A[j] <= x){
      i=i+1;
      std::swap(A[i], A[j]);
    }
  }
  std::swap(A[i+1], A[r]);
  return i+1;
}

int main(){
  int n;
  int A[100000];
  std::cin >> n;

  for(int i=0; i<n; i++){
    std::cin >> A[i];
  }
 int mid = partition(A, 0, n-1);
  for(int i=0; i<n; i++){
    if( i==mid ) std::cout << "[" << A[i] << "]";
    else  std::cout << A[i];
    if( i!=n-1 ) std::cout << " ";
  }
  std::cout << std::endl;
  return 0;
}



Measured memory_bytes: 3380
#include <iostream>

typedef long long ll;
using namespace std;

ll x, y;

int main() {
  cin >> x >> y;
  ll num = x;
  int cnt = 0;
  while (num <= y) {
    cnt += 1;
    num = 2 * num;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif


int pow(int a , int n ){
    long result=1;
            for(long i=0; i<n/2; i++){
                result=result*2;
                result=result%(1000000000+7);
            }
            
            // cout << result << endl;
    return result;
}



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    int flag = 1;
    sort(all(v));
    if(n%2==0){
        int start = 1;
        for(int i =0;i<n;i+=2){
            if(v[i]==start && v[i+1]==start){
                start+=2;

            }
            else {
                flag = 0;
                break;
            }

        }
        if(flag){
            // see(n/2);
            // cout<<pow(3,9);
            cout<<pow(2,n)<<endl;
            return 0;
        }
        else {
            cout<<0<<endl;
            return 0;
        }
    }
    else {
        // see("fasdfa");
        int start = 0;
        if(v[0]!=start){
            flag = 0;
        }
        start+=2; 

       for(int i =1;i<n;i+=2){
        

            if(v[i]==start && v[i+1]==start){
                start+=2;
            }
            else{
                // see(v[i]);
                flag = 0;
                break;
            }
        }

        if(flag){
            
            cout<<pow(2,n)<<endl;
            return 0;
        }
        else {
            cout<<0<<endl;
            return 0;
        }



    }

 
 
 
    
 
    return 0;
}


Measured memory_bytes: 640
#coding:utf-8

n = int(input())
s = input()

count = 0
r, g, b = 0, 0, 0

for i in s:
    if i == 'R':
        r += 1
    elif i == 'G':
        g += 1
    elif i == 'B':
        b += 1

count = r * g * b

for i in range(n-2):
    si = s[i]
    for j in range(i+1,n-1):
        sj = s[j]
        nk = 2 * j - i
        if not nk < n:
            break
        snk = s[nk]
        if {si, sj, snk} == {'R','G','B'}:
            count -= 1

print("{}".format(count))

Measured memory_bytes: 9188
def solve():
    N, K = map(int, input().split())
    As = list(map(int, input().split()))
    Fs = list(map(int, input().split()))

    As.sort()
    Fs.sort(reverse=True)

    def isOK(score):
        d = 0
        for A, F in zip(As, Fs):
            if A*F > score:
                d += -(-(A*F-score) // F)
        return d <= K

    ng, ok = -1, 10**12
    while abs(ok-ng) > 1:
        mid = (ng+ok) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    print(ok)


solve()


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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define rrep(i,x) for(int i=x-1;i>=0;--i)

int dp[1010][1010];

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

    rep(_, q) {
        memset(dp, -1, sizeof(dp));
        dp[0][0] = 0;

        string a,b; cin >> a>>b;

        int n = a.size(), m = b.size();
        rep(i, n+1) {
            rep(j, m+1) {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
                dp[i][j + 1] = max(dp[i][j + 1], dp[i][j]);

                if (a[i] == b[j]) {
                    dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
                }
            }
        }

        cout << dp[n][m] << endl;
    }
}

Measured memory_bytes: 7084
N = int(input())
line = input()

ans = line[1:N].count('E')
tmp = ans
for i in range(1,N):
 if line[i] == 'E':
  tmp -= 1
 if line[i-1] == 'W':
  tmp += 1
 if ans>tmp:
  ans = tmp

print(ans)

Measured memory_bytes: 3672
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	int d, n, i;
	long long num;
	cin >> d; cin >> n;

	num = n*pow(100, d);

	if (n != 100)
		cout << num << endl;
	else if (num <= 10000)
		cout << num + pow(100, d) << endl;
	else
		cout << 1010000 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    char b;
    cin >> b;
    char ans;
    if (b == 'A') {
        ans = 'T';
    }
    else if (b == 'T') {
        ans = 'A';
    }
    else if (b == 'C') {
        ans = 'G';
    }
    else
    {
        ans = 'C';
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	lint n=read<lint>();

	lint ans=n*(n+1)/2;
	lint tmp=n/3;
	lint res=tmp*(tmp+1)/2;

	ans-=(res*3);
	tmp=n/5;
	res=tmp*(tmp+1)/2;
	ans-=(res*5);
	tmp=n/15;
	res=tmp*(tmp+1)/2;
	ans+=(res*15);

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

	return 0;

}

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


int main()
{
ll n,m;
cin >> n >> m ;
set<ll> g[n];
deque<ll> ans;
rep(i, m)
{
    ll a,b;
    cin >> a>>b;
    g[a-1].insert(b-1);
    g[b-1].insert(a-1); //無向辺
}
bool see[n]={};
ll st=0,ed=*g[0].begin();
ans.push_back(ed+1);
ans.push_back(st+1);
see[st]=1,see[ed]=1;
bool ok=1;
while(ok){
  ok=0;
  for(auto a:g[st]){
    if(see[a]){
    }
    else{
      st=a;
      ok=1;
      see[st]=1;
      ans.push_back(st+1);
      break;
    }
  }
}
ok=1;
while(ok){
  ok=0;
  for(auto a:g[ed]){
    if(see[a]){
    }
    else{
      ed=a;
      ok=1;
      see[ed]=1;
      ans.push_front(ed+1);
      break;
    }
  }
}
cout << ans.size() << endl;

rep(i,ans.size())cout << ans[ans.size()-i-1] << " ";
return 0;
}


Measured memory_bytes: 15744
function main(input) {
  let args = input.split('\n');
  let count = 0;
  for (let i = 1;i < args.length;i++) {
    let x = args[i].split(' ')[0];
    let y = args[i].split(' ')[1];
    if (Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)) <= args[0].split(' ')[1]) {
      count++;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 62976
import math
kk = int(input())
s = 0
for i in range(1,kk+1):
    for j in range(i,kk+1):
        for k in range(j,kk+1):
            tmp = math.gcd((math.gcd(i,j)),k)
            if i==j:
                if j==k:
                    s += tmp
                else:
                    s += tmp*3
            elif j==k:
                s += tmp*3
            elif i==k:
                s += tmp*3
            else:
                s += tmp*6
print(s)

Measured memory_bytes: 9200
package main

import (
        "fmt"
)

func main() {
        var n int
        fmt.Scan(&n)
        var s string
        fmt.Scan(&s)
        wChanges := make([]int, n)
        for i := 1; i < n; i++ {
                wChanges[i] = wChanges[i-1]
                if s[i-1] == 'W' {
                        wChanges[i]++
                }
        }
        min := wChanges[n-1]
        eChanges := make([]int, n)
        for i := n - 1; i > 0; i-- {
                eChanges[i-1] = eChanges[i]
                if s[i] == 'E' {
                        eChanges[i-1]++
                }
                v := wChanges[i-1] + eChanges[i-1]
                if v < min {
                        min = v
                }
        }
        fmt.Printf("%d\n", min)
}

Measured memory_bytes: 7296
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <regex>
using namespace std;

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int p[10001];
    FOR(i,0,N) cin >> p[i];

    sort(p,p+N, greater<int>());
    ll ans;
    FOR(i,0,N) ans += p[i];
    ans -= p[0]/2;

    cout << ans << endl;

}



Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
int main(){
 long long int x, v,y,w,t,temp,p,k;
  cin>>x>>v; 
  cin>>y>>w; 
  cin>>t; 
  temp=abs(y-x);
  p=(v-w);
  if(p==0 && x!=y){
    cout<<"NO";
  }
  else{
    if(p<0){
      cout<<"NO";
    }
    else{
    k=ceil((double)((temp))/(p));
    if(k<=t){
      cout<<"YES";
    }
    else{
      cout<<"NO";
     }
    }
  }
  return 0;
}


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

using namespace std;

int main() {
	
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

	int n, l;
	cin >> n >> l;

	int sum = 0, diff = INT_MAX;
	for(int i = l; i < l + n; i++) {
		sum += i;
	}

	int ans;

	for(int i = l; i < l + n; i++) {
		if(abs(i) < diff) {
			diff = abs(i);
			ans = sum - i;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

const ll base = 1000;

int main() {
    int N; cin >> N;
    vector<int> A(N);
    REP(i, 0, N) cin >> A[i];

    vector<int> p;
    int prev = A[0]; bool sell = true;
    REP(i, 1, N) {
        // cout << "# i : " << i << ", prev : " << prev << endl;
        if (prev > A[i]) {
            if (sell) {
                prev = A[i];
            } else {
                p.push_back(prev);
                prev = A[i];
                sell = !sell;
            }
        } else if (prev < A[i]) {
            if (sell) {
                p.push_back(prev);
                prev = A[i];
                sell = !sell;
            } else {
                prev = A[i];
            }
        }
    }
    p.push_back(prev);
    
    ll ans = 1000;
    for (int i = 0; i < (int)p.size() - 1; i += 2) {
        // cout << p[i] << " " << p[i + 1] << endl;
        ans = ans % p[i] + ans / p[i] * p[i + 1];
    }

    cout << max(ans, base) << endl;

    return 0;
}

Measured memory_bytes: 3632