akhauriyash/Code-Regression huggingface dataset:
A,B,C,D,E,F = map(int,input().split())
cmax = 0
x = 100*A
y = 0
for n in range(F//(100*A)+1):
    for m in range((F-n*100*A)//(100*B)+1):
        for l in range((F-n*100*A-m*100*B)//C+1):
            for k in range((F-n*100*A-m*100*B-l*C)//D+1):
#                 print("n,m,l,k={},{},{},{}".format(n,m,l,k))
                if n**2+m**2>0 and l*C+k*D<=E*(n*A+m*B):
#                     print("d={}".format((l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)))
                    if cmax<(l*C+k*D)/(n*100*A+m*100*B+l*C+k*D):
                        cmax = (l*C+k*D)/(n*100*A+m*100*B+l*C+k*D)
                        x = n*100*A+m*100*B
                        y = l*C+k*D
                    
print(x+y,y)

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

left = 0
right = n-1
count = 0
border = 0
tag = s[0]
if s[right] != tag:
    while s[right] != tag:
        right-=1
    border +=1
while True:
    while s[left] == tag and left < right:
        left+=1
    while s[right] == tag and left <= right:
        right -= 1
    if left == right:
        border += 2
        break
    if right < left:
        break
    border += 2
    if tag == 'L':
        tag = 'R'
    else:
        tag = 'L'

border = max(0, border - k * 2)
print(n - border -1)




Measured memory_bytes: 49648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int> p(a),q(b),r(c);
    rep(i,a) cin>>p[i];
    rep(i,b) cin>>q[i];
    rep(i,c) cin>>r[i];

    vector<int> pq;
    sort(all(p));
    reverse(all(p));
    rep(i,x) pq.push_back(p[i]);
    sort(all(q));
    reverse(all(q));
    rep(i,y) pq.push_back(q[i]);
    rep(i,c) pq.push_back(r[i]);

    sort(all(pq));
    reverse(all(pq));
    ll ans=0;
    rep(i,x+y) ans+=pq[i];

    cout<<ans<<endl;
}

Measured memory_bytes: 6524
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int cnt=0;
        int a[] = new int[n];
        for(int i=0;i<n;i++) a[i] = in.nextInt();
        for(int i=1;i<n-1;i++){
            if(a[i]>a[i-1] && a[i]<a[i+1]) cnt++;
            else if(a[i]<a[i-1] && a[i]>a[i+1]) cnt++;
        }
        out.println(cnt);
    }
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23252
///=======================///
/// coder: Andy - Tohrumi ///
///=======================///

#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fastio ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rep(i, a, b) for(__typeof(b) i = a; i < b; i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i > b; i--)

using namespace std;

typedef pair<ll, ll> pll;	typedef pair<int, int> ii;
typedef vector<pll> vll;	typedef vector<string> vs;		typedef vector<ii> vii;
typedef vector<int> vi; 	typedef vector<ll> vl;

///====code start here====///

ll dp[402][402], pre[402];

signed main() {
	fastio;
	int n; cin >> n;
	pre[0] = 0;
	rep(i, 0, n) {
		cin >> dp[i][i];
		pre[i + 1] = pre[i] + dp[i][i];
	}
	Rep(l, n - 2, -1) {
		rep(r, l + 1, n) {
			dp[l][r] = LLONG_MAX;
			rep(m, l, r) {
				dp[l][r] = min(dp[l][m] + dp[m + 1][r] + pre[r + 1] - pre[l], dp[l][r]);
			}
		}
	}
	cout << dp[0][n - 1] - pre[n] << endl;
	return 0;
}


Measured memory_bytes: 4844
package main

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

var sc = bufio.NewScanner(os.Stdin)

func gcd(x, y int64) int64 {
	if y == 0 {
		return x
	} else {
		return gcd(y, x%y)
	}
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
 
func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	var n int
	var g int64

	n = nextInt()

	for i := 0; i < n; i++ {
		var a int64
		a = nextInt64()
		g = gcd(g, a)
	}
	fmt.Println(g)
}

Measured memory_bytes: 2304
import Foundation

let line = readLine()!
let numbers = line.componentsSeparatedByString(" ")

var first = Int(numbers[0])!
var second = Int(numbers[1])!
var third = Int(numbers[2])!

let count = Int(readLine()!)!

for _ in 0..<count {
    if first >= second && first >= third {
        first = first * 2
    } else if second >= first && second >= third {
        second = second * 2
    } else if third >= first && third >= second {
        third = third * 2
    }
}

print("\(first + second + third)")


Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define int long long
int n, m;
int a[123456], cnt, ans;
signed main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (i)a[i] += a[i - 1];
		a[i] %= m;
	}
	a[n] = 0; n++;
	sort(a, a + n);
	cnt = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] == a[i - 1])cnt++;
		else {
			ans += cnt * (cnt - 1) / 2;
			cnt = 1;
		}
	}ans += cnt * (cnt - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n,m;
	cin>>m>>n;
	int a;
	cin>>a;
	int x,y;
	cin>>y>>x;
	int out=0;
	rep(i,a-1){
		int c,d;
		cin>>d>>c;
		if(c-x>0&&d-y>0){
			int q=min(c-x,d-y);
			out+=q;
			x+=q;y+=q;
		}
		if(c-x<0&&d-y<0){
			int q=min(-c+x,-d+y);
			out+=q;
			x-=q;y-=q;
		}
		out+=abs(c-x)+abs(d-y);
		x=c;y=d;
	}
	cout<<out<<endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) { cerr << "[ " << *it << " = " << a << " ]"; err(++it, args...); }
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 1e16;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 61;
const int DIGITSIZE = 19;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
bool take_test_cases = false;
bool print_case_no = false;

void getac(int T) {
    vector < ll > v;
    ll k;
    cin>>k;
    for(ll a=-1000;a<=1000;a++){
        for(ll b=-1000;b<=1000;b++){
            ll tempa=a*a*a*a*a;
            
            ll tempb=b*b*b*b*b;

            if(tempa-tempb==k){
                cout<<a<<' '<<b<<'\n';
                return ;
            }
        }
    }

}
int  main()
{

    fastio;
    int t = 1;
    if (take_test_cases) cin >> t;
    int t_t = 1;
    while (t--) {
        if (print_case_no)
        case (t_t);
        getac(t_t);
        t_t++;
    }
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 #include <ext/pb_ds/tree_policy.hpp>
 #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
 using namespace std;
 using namespace std::chrono;      
 using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 #define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        3e18
 #define sm         -1e9
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;

 typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
   
    #endif
}


void solve()
{

 int n,k;
 cin >> n >> k;

 int a[n+1],cy[n+1],vis[n+1],nd=1;

 forf(i,1,n+1) cin >> a[i];

 for(int i=1;i<=n;i++) cy[i]=-1,vis[i]=0;
 
 for(int i=1;i<=n;i++)
 {
   if(vis[nd])
   {
     cy[nd] = i-vis[nd];
     break;
   }
   vis[nd] = i;
   nd = a[nd];
 }
 
 nd = 1;
 
 while(k>0)
 {
  if(cy[nd]==-1)
  {
    k--;
    nd = a[nd];
  }
  else
  {
    k%=cy[nd];
    if(k>0) nd = a[nd] , k--;
    
  }
 }
 while(k>0)
 {
  nd = a[nd];
  k--;
 }


 cout<<nd<<endl;
 
}

int32_t main()
{
 pr_init();
  fastio;
  
  auto start = high_resolution_clock::now(); 
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

 }

Measured memory_bytes: 8272
#include<bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  int N,R,ans;
  cin>>N>>R;
  if(N>10) N = 10;
  ans = R + (100 * (10 - N));
  cout<<ans<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int q; cin >> q;
	VI a, print;
	rep(i, q) {
		int x, y;
		cin >> x;
		if (x == 0 || x == 1)cin >> y;

		if (x == 0) {
			a.pb(y);
		}
		else if (x == 1) {
			print.pb(a[y]);
		}
		else if (x == 2) {
			a.pop_back();
		}
	}
	for (auto ans : print) {
		cout << ans << endl;
	}
}


Measured memory_bytes: 4048
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

from collections import defaultdict
n=n0()
a=[0]
a.extend(n1())

m1=[i+a[i] for i in range(n+1)]
m2=[j-a[j] for j in range(n+1)]

d1=defaultdict(list)
d2=defaultdict(list)
for i in range(1,n+1):
    d1[m1[i]].append(i)
    d2[m2[i]].append(i)

ans=0
for i in d1:
    ans+=len(d1[i])*len(d2[i])
            
print(ans)

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

int dp[100009], total[100009];
int store[100009], mark[100009], nPrime, isPrime[100009];

///seieve
void seive(int n)
{
    int i,j, lim = sqrt(n*1.0) +2;

    mark[1] = 1;
    for(i = 4; i<=n; i+=2) mark[i] = 1;

    store[nPrime++] = 2;

    isPrime[2] = 1;

    for(i=3; i<=n; i+=2)
    {
        if(!mark[i])
        {
            store[nPrime++] = i;
            isPrime[i] = 1;

            if(i<=lim)
            {
                for(j=i*i; j<=n; j+=i*2)
                {
                    mark[j]=1;
                }
            }
        }
    }


}

int f(int n) /// is like 2017
{
    if(dp[n]!=-1) return dp[n];
    if(n%2==0) return dp[n] = 0;
    if(isPrime[n]==1 && isPrime[ (n+1)/2 ]==1) return dp[n] = 1;
    else return dp[n] = 0;
}

void cnt(int N)
{
    for(int i=0; i<=N; i++) f(i);
    total[1] = 0;
    for(int i=2; i<=N; i++)
    {
        total[i] = total[i-1]+dp[i];
    }
}

int main()
{
    int q;
    int l, r;
    int ans = 0;

    seive(100002);
    memset(dp,-1,sizeof(dp));
    cnt(100002);

    //for(int i=0; i<nPrime; i++) cout<<store[i]<<" ";
    //for(int i=0; i<100000; i++) if(dp[i]) cout<<i<<" "<<total[i]<<" "<<endl;

    cin>>q;
    while(q--)
    {
        cin>>l>>r;
        if(l==1) ans = total[r];
        else ans = total[r] - total[l-2];
        cout<<ans<<endl;
    }

    //main();


    return 0;
}


Measured memory_bytes: 2176
N = int(input())
LR = []
L, R = [], []
for _ in range(N):
    l, r = map(int,  input().split())
    LR.append((l, r))
    L.append(l)
    R.append(r)
L.sort()
R.sort()
ans = 0
for l, r in LR:
    m = L[-1]
    M = R[0]
    if l == m:
        m = L[-2]
    if M == r:
        M = R[1]
    ans = max(max(0, M-m+1)+r-l+1, ans)
LR.sort()
tmp = [LR[-1]]
Rmin = LR[-1][1]
for i in range(N-1)[::-1]:
    if LR[i][1]<=Rmin:
        tmp.append(LR[i])
        Rmin = LR[i][1]
LR = tmp[::-1]
rmin = LR[0][1]
lmax = LR[-1][0]
for i in range(len(LR)-1):
    l0, r0 = LR[i]
    l1, r1 = LR[i+1]
    res1 = max(0, rmin-l0+1)
    res2 = max(0, r1-lmax+1)
    ans = max(ans, res1+res2)
print(ans)

Measured memory_bytes: 75352
N = int(input())
hoge=[]
for i in range(10):
    if(N!=0):
        hoge.append(N%10)
        N=int(N/10)
hoge=hoge[::-1]
huga=[]
for i in range(len(hoge)-2):
    huga.append(abs(hoge[i]*100+hoge[i+1]*10+hoge[i+2]-753))
print(min(huga))

Measured memory_bytes: 3064
#pragma region Header
#define _CRT_SECURE_NO_WARNINGS
#define FOR(i,s, e) for(int i = s; i<e; ++i)
#define rFOR(i,s, e) for(int i=s-1; i>=e; --i)
#define loop(len) for(int i=0; i<len; ++i)
#define rloop(len) for(int i=len-1; i>=0; --i)
#define iPair pair<int,int>
#define LPair pair<ll,ll>
#define vecP(t,t2) vector<pair<t,t2>>
#define uoMP(t, t2) unordered_map<t, t2>
#define pb push_back
#define pp pop_back
#define beg_end(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define rev(v) reverse(v.begin(), v.end())
#define MrN ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
typedef long long  ll;
typedef long double  ld;
#include<bits/stdc++.h>
using namespace std;
#pragma endregion

ll n, Sum;
int const Size = (1e7 + 5);
ll DivMemo[Size + 5];

void countDivisors(){
	FOR(i, 1, n+1){
		// if(i > 1) DivMemo[i]++;
		for(int j = i; j <= n; j+=i){
			DivMemo[j] += 1;
		}
	}
}

int main() {
	MrN;
	// freopen("input.txt", "r", stdin);
	cin >> n;
	countDivisors();

	FOR(i, 1, n+1){
		Sum += i * DivMemo[i];
		// cout << i << " " << DivMemo[i] << '\n';
	}

	cout << Sum << '\n';


	return 0;
}


Measured memory_bytes: 81716
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    for(long long i = 0; i < n; i++) cin >> a[i];

    long long maxv = a[0];
    long long ans = 0;
    for(long long i = 0; i < n; i++){
        if(maxv > a[i]){
            ans += maxv - a[i];
        }
        else maxv = a[i];
    }

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

Measured memory_bytes: 4776
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#define int long long

using namespace std;

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

const int maxn = 1100;

struct Node{
	int x,y,h;
};

Node a[maxn];
int n,m;

int dis(int x,int y,int x1,int y2)
{
	return abs(x-x1)+abs(y-y2);
}

bool check(int x,int y)
{
	int ymh = max(a[1].h+dis(a[1].x,a[1].y,x,y),(long long)0);
	for (int i=2;i<=n;i++)
	{
		if (max(ymh-dis(a[i].x,a[i].y,x,y),(long long)0)!=a[i].h) return false;
	}
	return true;
}

bool cmp(Node a,Node b){
	return a.h>b.h;
}
signed main()
{
  n=read();
  for (int i=1;i<=n;i++)
  {
  	 a[i].x=read();
  	 a[i].y=read();
  	 a[i].h=read();
  }
  sort(a+1,a+1+n,cmp);
  for (int i=0;i<=100;i++)
    for(int j=0;j<=100;j++)
    {
    	if (check(i,j))
    	{
    	   cout<<i<<" "<<j<<" "<<max(a[1].h+dis(a[1].x,a[1].y,i,j),(long long)0);
    	   return 0;
    	}
    }
  return 0;
}


Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")

;(input => {
 
    const lines = input.split('\n')
    const N = lines[0] - 0
    const S = lines[1]

    const RGB = {R: 0, G: 0, B: 0}
    for (let i = 0; i < N; i++) {
        RGB[S[i]]++
    }
    let sum = RGB.R * RGB.G * RGB.B

    for (let i = 0; i < N - 2; i++) {
        for (let j = i + 1; j < N - 1; j++) {
            let k = i + (j - i) * 2
            if (!S[k]) break
            if (
                S[i] !== S[j] &&
                S[i] !== S[k] &&
                S[j] !== S[k]
            ) {
                sum--
            }
        }
    }

    console.log(sum)

})(input)


Measured memory_bytes: 35392
#include <bits/stdc++.h>
#define in_arr(n,A)                     for(int i=0;i<n;i++)cin>>A[i];
#define IOS                             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi                              vector <int>
#define vl                              vector <ll>
#define out_arr(n,A)                    for(int i=0;i<n;i++)cout<<A[i]<<" ";
#define LINE                            cout << endl
#define SPACE                           cout << " "
#define pb                              push_back
#define Fr                              first
#define Sc                              second
#define YES                             cout << "YES"
#define NO                              cout << "NO"
#define wrong                           cout << -1
#define pll                             pair <ll, ll>
#define pii                             pair <int, int>
#define OO                              INT_MAX
#define SMALL                           INT_MIN
#define BIGx2                           LONG_LONG_MAX
#define sz                              size()
//BIT_OP
#define isOn(s, j)                      (s & (1<<j))
#define setBit(s, j)                    (s |= ( 1<< j))
#define clearBit(s, j)                  (s &= ~( 1 << j ))
#define lowBit(s)                       (s & (-s))
#define setAll(s, n)                    ( s = ( 1 << n ) - 1)
#define modulo(s, n)                    ((s) & ( n - 1 ))
#define isPowerOfTwo(s)                 (!(s & (s - 1)))
#define nearestPowerOfTwo(s)            ((int)pow(2.0, (int)((log((double)s) / log(2.0)) + 50. )))
#define nextnearestPowerOfTwo(s)        (1<<(32 - __builtin_clz(s)))
#define turnoffLastBit(s)               ((s) & (s - 1))
#define turnonLastZero(s)               ((S) | (s + 1))
#define turnoffLastConsecutiveBits(s)   ((s) & (s + 1))
typedef long long ll;
using namespace std;
string s1, s2;
int Cnt ;
int main()
{
    IOS
    cin >> s1 >> s2;
    for(int i = 0 ; i <s1.sz ; i++)
        if(s1[i] == s2[i])
        Cnt++;
    cout << Cnt << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  int a,b,c;
  int k;
  cin>>a>>b>>c;
  cin>>k;
  rep(i,k){
    if(a>=b){
      b*=2;
    }else if(b>=c){
      c*=2;
    }
  }


  if(a<b&&b<c){
    puts("Yes");
  }else{
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 3632
(* O(n) *)
Scanf.scanf "%d" @@ fun n ->
  let a_s = Array.init n @@ fun i -> Scanf.scanf " %d" @@ (+) 0 in
  Array.fold_left max a_s.(0) a_s - Array.fold_left min a_s.(0) a_s |> Printf.printf "%d\n"

Measured memory_bytes: 384
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-Alli v[n]={0};
lli v[200001]={0};
lli level[200001]={0};
vector<lli>answer[200001];
lli bfs(lli s)
{
	queue<lli>q;
	q.push(s);
	level[s]=0;
	v[s]=1;
	lli i;
	while(!q.empty())
	{
		lli p=q.front();
		q.pop();
		for(i=0;i<answer[p].size();i++)
		{
			if(v[answer[p].at(i)]==0)
			{
				level[answer[p].at(i)]=level[p]+1;
				q.push(answer[p].at(i));
				v[answer[p].at(i)]=1;	
			}	
		}	
	}	
	
}
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		lli n,m;
		cin>>n>>m;
		lli x,y;
		while(m--)
		{
			cin>>x>>y;
			answer[x].push_back(y);
			answer[y].push_back(x);
		}
		bfs(1);
		if(level[n]==2)
		{
			cout<<"POSSIBLE"<<endl;
			continue;
		}
		cout<<"IMPOSSIBLE"<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 17128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){return modpow(x,mod-2);}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,n;
    cin>>k>>n;
    if(n==1){
        cout<<(k+1)/2<<endl;
    }
    else if(k%2==0){
        cout<<k/2<<" ";
        rep(i,n-2)cout<<k<<" ";
        cout<<k<<endl;
    }
    else{
        vector<int>v;
        rep(i,n)v.pb((k+1)/2);
        rep(_,n/2){
            if(v.size()==n){
                if(v.back()==1)v.pop_back();
                else v[v.size()-1]--;
            }
            else{
                if(v.back()!=1){
                    v[v.size()-1]--;
                    while(v.size()<n){
                        v.pb(k);
                    }
                }
                else{
                    v.pop_back();
                }
            }
        }
        for(int i:v)cout<<i<<" ";
        cout<<endl;
    }
    return 0;
}


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

const long long inf = 1e18;

struct Task {
	int n;
	vector<int> a;

	Task(int n): n(n), a(n) {
		for (auto& item : a) {
			cin >> item;
		}
	}

	void run() {
		int turn = 0;
		while (true) {
			int sum = 0;
			int odd = 0;
			int one = 0;
			for (int i = 0; i < n; ++i) {
				int item = a[i];
				sum ^= (item - 1) & 1;
				if (item & 1) {
					odd = i;
				}
				one |= item == 1;
			}
			if (one) {
				turn ^= sum ^ 1;
				break;
			}
			if (sum) {
				break;
			}
			--a[odd];
			int g = a[odd];
			for (auto& item : a) {
				g = __gcd(item, g);
			}
			for (auto& item : a) {
				item /= g;
			}
			turn ^= 1;
		}
		cout << (!turn ? "First" : "Second") << '\n';
	}
};

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

	int n;
	cin >> n;

	Task a(n);
	a.run();

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  long long int N, M;
  cin >> N >> M;
  
  vector<vector<long long int>> H(N, vector<long long int>(1));
  for(long long int i=0; i<N; i++){ cin >> H[i][0]; }
  
  for(long long int i=0; i<M; i++){
    long long int A, B;
    cin >> A >> B;
    H[A-1].push_back(B-1);
    H[B-1].push_back(A-1);
  }
  
  long long int res=0;
  for(long long int i=0; i<N; i++){
    bool highest = true;
    for(long long int j=0; j<H[i].size()-1; j++){
      if(H[i][0]<=H[H[i][j+1]][0]){ highest = false; }
    }
    if(highest){ res++; }
  }
  
  cout << res << endl;
  
}

Measured memory_bytes: 10912
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readLongList()
    val aList = readLongList()

    if (k == 0L) {
        out.println(aList.max())
        return
    }

    var ng = 0L
    var ok = 1_000_000_001L
    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        fun check(): Boolean {
            var count = 0L
            for (a in aList) {
                count += (a - 1) / mid
            }
            return count <= k
        }
        if (check()) {
            ok = mid
        } else {
            ng = mid
        }
    }

    out.println(ok)
}




fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 63776
#include <bits/stdc++.h>
#include <math.h>
int n,m,i,j,k,count1=0,count2=0;
using namespace std;
void ABC110(void);
void ABC111(void);
void ABC112(void);
void ABC113(void);
void ABC114(void);
void ABC115(void);
void ABC116(void);
void ABC117(void);
void ABC118(void);
void ABC119(void);

int main(void){
    ABC119();
}

void ABC119(){
    cin>>n;
    double sum=0,x;
    string u;
    for(i=0;i<n;i++){
        cin>>x>>u;
        if(u=="JPY")sum+=x;
        else if(u=="BTC")sum+=380000*x;
    }
    printf("%lf\n",sum);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif


ll a[60];

int main() {
	ll k;
	cin>>k;
	ll p = k/50, r = k-50*p;
	int n = 50;
	REP(i,1,n) a[i] = p+49;
	REP(i,1,r) a[i]+=n-r+1;
	REP(i,r+1,n) a[i]-=r;
	printf("%d\n",n);
	REP(i,1,n) printf("%lld ",a[i]);hr;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N=105;
const int M=15;
long long int n,f[N][M],p[N][M],x,ans=-10000000000,c[N];

int main(){
    bool b=0;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<10;j++){
            cin>>f[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<11;j++){
            cin>>p[i][j];
        }
    }
    for(int i=1;i<(1<<10);i++){
        for(int j=0;j<n;j++)c[j]=0;
        for(int j=0;j<=9;j++){
            if((i>>j)&1){
                for(int k=0;k<n;k++){
                    if(f[k][j]==1)c[k]++;
                }
            }
        }
        x=0;
        for(int j=0;j<n;j++){
            x+=p[j][c[j]];
        }
        ans=max(ans,x);
    }
    cout<<ans<<'\n';
}


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

int main()
{
  int a,b,c,result,K;
	cin>>a>>b>>c;
	result=min(a,c);
	a-=result;
  	c-=result;
	K=min(b,c);
	result+=K+b;
	b-=K;
  	c-=K;
	if(c)
      result++;
	cout<<result;
    return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll ans = max({a*c, a*d, b*c, b*d});
    cout << ans << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    int n;
    cin >> n;
    if(n==0) return 0;
    vector<int> a(n);
    LD total=0;
    for(int i=0;i<n;i++) cin >> a[i],total+=a[i];
    LD avg=total/n;
    int ans=0;
    for(int i=0;i<n;i++) if(a[i]<=avg) ans++;
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3052
#include<iostream>
#include<list>
#include<vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<math.h>
#include<unordered_map>
#include<map>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;





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

    mat A(N,vec(N));
    mat B(N,vec(N,10000000000));

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

    for(int k=0;k<N;++k) for(int i=0;i<N;++i) for(int j=0;j<N;++j)
    {
        if(i==k||k==j)continue;
        B[i][j] = min(B[i][j],A[i][k] + A[k][j]);
    }

    ll ans=0;
    for(int i=0;i<N;++i) for(int j=0;j<N;++j)
    {
        if(A[i][j]<B[i][j]) {ans += A[i][j];}
        if(A[i][j]>B[i][j])
        {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans/2 << endl;
    return 0;
}

Measured memory_bytes: 1664
//#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
const ll INF=1000000000000005;
const ll maxn=5e5+5;
const int mod=1e9+7;
ll n,m,p;
int vis[maxn];
ll num[maxn];
inline bool read(ll &num)
{
        char in;bool IsN=false;
        in=getchar();
        if(in==EOF) return false;
        while(in!='-'&&(in<'0'||in>'9')) in=getchar();
        if(in=='-'){ IsN=true;num=0;}
        else num=in-'0';
        while(in=getchar(),in>='0'&&in<='9'){
                num*=10,num+=in-'0';
        }
        if(IsN) num=-num;
        return true;
}
int main()
{
    ll cnt=1,sum=0;
    scanf("%lld%lld%lld",&n,&m,&p);
    ll minl=INF;
    minl=min(minl,(p+m-1)/m);
    minl=min(minl,(p+n-1)/n);
    printf("%lld\n",minl);
    return 0;
}
/***
7+
***/


Measured memory_bytes: 128
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
ans = "U"*dy + "R"*dx + "D"*dy + "L"*dx
ans += "L" + "U"*(dy+1) + "R"*(dx+1) + "D"
ans += "R" + "D"*(dy+1) + "L"*(dx+1) + "U"
print(ans)

Measured memory_bytes: 9008
#include<stdio.h>
int main(void)
{
	int a;
	char s[10];
	
	scanf("%d", &a);
	
	if(a>=3200)
	{
		scanf("%s", s);
		printf("%s\n", s);
	}
	else
	{
		printf("red\n");
	}
	
	
	return 0;
}

Measured memory_bytes: 128
// C - Alchemist
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(10);

	int n;
	cin >> n;
	multiset<double> a;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a.insert(x);
	}

	for (int i = 0; i < n - 1; i++) {
		double v1 = *a.begin();
		a.erase(a.begin());
		double v2 = *a.begin();
		a.erase(a.begin());
		a.insert((v1 + v2) / 2.0);
	}

	cout << *a.begin() << endl;

	return 0;
}


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

int main() {
	int W, H;
	while (cin >> W >> H && W+H!= 0) {
        char room[101][101];

        for (int w = 0; w != W; ++w) {
            cin >> room[w];
        }

        int x = 0, y = 0;
        bool loop = false;

        while (room[x][y] != '.') {
            if (room[x][y] == '>') {
                room[x][y] = 'x';
                y++;
            }
            else if (room[x][y] == '<') {
                room[x][y] = 'x';
                y--;
            }
            else if (room[x][y] == '^') {
                room[x][y] = 'x';
                x--;
            }
            else if (room[x][y] == 'v') {
                room[x][y] = 'x';
                x++;
            }
            else if (room[x][y] == 'x') {
                loop = true;
                break;
            }
        }

        if (loop) {
            cout << "LOOP" << endl;
        }
        else {
            cout << y << " " << x << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1172
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = [int(input()) for i in range(D)]
last = [[-1] for i in range(26)]
# before query
ans = 0
for i in range(D):
    op = t[i]-1
    ans += s[i][op]
    last[op].append(i)
    for j in range(26):
        ans -= c[j]*(i-last[j][-1])
    # print(ans)
from bisect import *
import random
m = int(input())
def suminc(a,b):
    return b*(b-1)//2-a*(a-1)//2
while m:
    m-=1
    update = 0
    d,q = map(int, input().split())
    # d = random.randint(1,365)
    # q = random.randint(1,26)
    d-=1
    q-=1
    oq = t[d]-1
    update += s[d][q]-s[d][oq]
    idx = bisect_left(last[oq],d)
    if idx == len(last[oq])-1:
        cnt = D - last[oq][idx]
    else:
        cnt = last[oq][idx+1] - last[oq][idx]
    update += c[oq]*suminc(0,cnt)
    cntprv = last[oq][idx] - last[oq][idx-1]
    update -= c[oq]*suminc(cntprv,cntprv+cnt)

    idx2 = bisect_left(last[q],d)-1
    if idx2 == len(last[q])-1:
        cnt = D - d
    else:
        cnt = last[q][idx2+1] - d
    if idx2 == len(last[q])-1:
        cntprv = D - last[q][idx2] - cnt
    else:
        cntprv = last[q][idx2+1] - last[q][idx2] - cnt
    update += c[q]*suminc(cntprv,cntprv+cnt)
    update -= c[q]*suminc(0,cnt)

    ans += update
    del last[oq][idx]
    last[q].insert(idx2+1,d)
    print(ans)
    t[d] = q+1







    

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

#define ll long long
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;
#define vec vector
#define vvi vector<vector<int>>

struct Edge {
   int from, to, cost;
};
const ll INF = 4e18;
int N, M;
vec<vec<Edge>> G;

void dfs(int pos, vec<ll> &dist) {
   for (Edge e : G[pos]) {
      if (dist[e.to] == INF) { // 遷移先の値が定まっていないなら
         dist[e.to] = dist[pos] + e.cost; // 遷移先の値を定める
         dfs(e.to, dist);
      }
   }
}

int main() {
   cin >> N >> M;
   G = vec<vec<Edge>>(N);
   rep (i, 0, M) {
      int l, r, d;
      cin >> l >> r >> d;
      l--, r--;
      G[l].push_back(Edge{l, r, d});
      G[r].push_back({r, l, -d});
   }

   vector<ll> dist(N, INF);
   rep (i, 0, N) {
      if (dist[i] == INF) {
         debug(i)
         dist[i] = 0;
         dfs(i, dist);
      }
   }

   rep (i, 0, N) {
      for (Edge e : G[i]) {
         if (dist[e.to] - dist[e.from] != e.cost) {
            puts("No");
            return 0;
         }
      }
   }
   puts("Yes");

   return 0;
}

Measured memory_bytes: 14208
while True:
    s = input()
    if s[0] == '.': break
    r = []
    f = False
    for c in s:
        if c == '(' or c == '[':
            r.append(c)
        elif c == ')':
            if not r or r.pop() != '(':
                print("no")
                break
        elif c == ']':
            if not r or r.pop() != '[':
                print("no")
                break
    else:
        print("yes" if not r else "no")

Measured memory_bytes: 6724
function Main(arg) {
  let n = arg.trim().split('\n');
  let ac = 0,wa = 0,tle = 0,re = 0;
  for(i = 1;i<n.length;i++){
    if(n[i] == 'AC') ac++;
    if(n[i] == 'WA') wa++;
    if(n[i] == 'TLE') tle++;
    if(n[i] == 'RE') re++;
  }
  console.log(`AC x ${ac}`);
  console.log(`WA x ${wa}`);
  console.log(`TLE x ${tle}`);
  console.log(`RE x ${re}`);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 37384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  string s;
  cin>>n>>s;
  Int c=0;
  for(char x:s) if(x=='R') c++;
  cout<<(c>n-c?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,x,y,z,o;
	scanf("%d",&a);
	x=a/1000;
	y=a%1000/100;
	z=a%100/10;
	o=a%10;
	if(x==y||y==z||z==o)
		printf("Bad");
	else
		printf("Good");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int s, w;
    cin >> s >> w;

    cout << (w >= s ? "unsafe": "safe") <<endl;

    return 0;
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use proconio::derive_readable;
use proconio::fastout;
#[allow(unused_imports)]
use num::Integer;
#[allow(unused_imports)]
use itertools::Itertools;

#[fastout]
fn main() {
  input! {
    mut a: i32,
    b: i32,
    mut c: i32,
    d: i32,
  }
  loop {
    c -= b;
    if c <= 0 {
      println!("Yes");
      break;
    }
    a -= d;
    if a <= 0 {
      println!("No");
      break;
    }
  }
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c=0; cin >> n;
    ll a[n],b[n];
    rep(i,n) cin >> a[i] >> b[i];

    ll x;
    for (ll i = n-1; i >= 0; i--){
        a[i] += c;
        x = a[i]%b[i];
        if (x > 0){
            if (a[i] < b[i]) c += b[i] - a[i];
            else if (a[i] > b[i]) c += b[i] - x;
        }
    }
    cout << c << "\n";
}

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

const int MAXN = 1005;
const int MAXV = MAXN*(MAXN-1)/2;
vector<int> to[MAXV];
int id[MAXN][MAXN];
int toId(int i, int j) {
	if (i > j) swap(i,j);
	return id[i][j];
}

bool visited[MAXV];
bool calculated[MAXV];
int dp[MAXV];
int dfs(int v) {
	if (visited[v]) {
		if (!calculated[v]) return -1;
		return dp[v];
	}
	visited[v] = true;
	dp[v] = 1;
	for (int u : to[v]) {
		int res = dfs(u);
		if (res == -1) return -1;
		dp[v] = max(dp[v], dfs(u)+1);
	}
	calculated[v] = true;
	return dp[v];
}

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(n, vector<int>(n-1));
	rep(i,n) {
		rep(j,n-1) {
			cin >> a[i][j];
			a[i][j]--;
		}
	}
	int V = 0;
	rep(i,n) rep(j,n) {
		if (i < j) {
			id[i][j] = V++;
		}
	}
	rep(i,n) {
		rep(j,n-1) {
			a[i][j] = toId(i,a[i][j]);
		}
		rep(j,n-2) {
			to[a[i][j+1]].push_back(a[i][j]);
		}
	}
	int ans = 0;
	rep(i,V) {
		int res = dfs(i);
		if (res == -1) {
			puts("-1");
			return 0;
		}
		ans = max(ans, res);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 38528
#include<stdio.h>
int main()
{
int a,b,c;
scanf("%d%d%d",&a,&b,&c);
if(((a==5)&&(b==5)&&(c==7))||((a==5)&&(b==7)&&(c==5))||((a==7)&&(b==5)&&(c==5)))
printf("YES");
else
printf("NO");
return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
 
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000000000
#define MAXN        1000005
#define mod         1000000007  
#define pi          3.1415926535897932384626433
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d,t,s;
    cin>>d>>t>>s;
    ll x=s*t;
    if(d<=x){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
int a[300001],i,j,n;main(){
for(i=2;i<300001;i++){if(i%7==1||i%7==6){for(j=2;j<=sqrt(i);j++){if(a[j]==1&&i%j==0){a[i]=0;goto E;}}a[i]=1;
E:;
}}
while(true){std::cin>>n;
if(n<2){break;}printf("%d:",n);
for(i=2;i<=n;i++){if(a[i]==1&&n%i==0){printf(" %d",i);}}
printf("\n");}}

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

int main() {
  int s1s2s3,ans;
  cin>>s1s2s3;
  ans=s1s2s3/100;
  ans=ans+s1s2s3/10-10*ans;
  ans=ans+s1s2s3%10;
   
  cout<<ans<<endl;
}

Measured memory_bytes: 3544
import java.util.Scanner;

public class Main {

    public static int lcs(String str1, String str2) {

        if (str1.equals(str2)) {
            return str1.length();
        }

        int m = str1.length();
        int n = str2.length();
        int[][] d = new int[m+1][n+1];

        for (int i = 0; i <= m; i++) {
            d[i][0] = 0;
        }

        for (int i = 0; i <= n; i++) {
            d[0][i] = 0;
        }

        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (str1.charAt(i-1) == str2.charAt(j-1)) {
                    d[i][j] = 1 + d[i-1][j-1];
                } else {
                    d[i][j] = Math.max(d[i-1][j], d[i][j-1]);
                }
            }
        }

        return d[m][n];
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int q = Integer.parseInt(in.nextLine());
        String prev = "";
        String curr = "";
        for (int i = 0; i < q * 2; i++) {
            if (i % 2 == 0) {
                prev = in.nextLine();
            } else {
                curr = in.nextLine();
                System.out.println(lcs(prev, curr));
            }
        }
    }
}


Measured memory_bytes: 64604
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a==c) printf("%d\n",b);
    else if(a==b) printf("%d\n",c);
    else if(b==c) printf("%d\n",a);
    return 0;
}


Measured memory_bytes: 256