akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
int main() {
    fast;
    int t = 1;
    //cin >> t;
    while (t--) {
     ll n,d;
     cin>>n>>d;
     int count=0;
     while(n--) {
         ll a, b;
         cin>>a>>b;
         if(sqrt(a*a+b*b)<=d)
             count++;
     }
     cout<<count;
    }
}



Measured memory_bytes: 3700
import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (a, b, c, d) = readInts()

    var ta = a
    var ao = c
    while (true) {
        ao -= b
        ta -= d
        if (ao <= 0) {
            println("Yes")
            return
        }
        if (ta <= 0) {
            println("No")
            return
        }
    }
}


Measured memory_bytes: 36240
import Data.List

main = do
    getLine
    line<-getLine
    let a =[read x::Int | x <- words line]
    let lwbd = minL a
    let upbd = maxL a
    print $ minL [totalCost a z | z<-[lwbd..upbd]] 

totalCost :: [Int]->Int -> Int
totalCost [] p = 0
totalCost (a:ax) p = (a-p)*(a-p) + totalCost ax p 

minL :: [Int] -> Int
minL (x:[]) = x
minL (x:xs) = min x $ minL xs

maxL :: [Int] -> Int
maxL (x:[]) = x
maxL (x:xs) = max x $ maxL xs

Measured memory_bytes: 1020
def main():
  A = int(input())
  B = int(input())
  C = int(input())
  D = int(input())
  E = int(input())
  
  a = (10 - A) % 10
  b = (10 - B) % 10
  c = (10 - C) % 10
  d = (10 - D) % 10
  e = (10 - E) % 10
 
  print(A+B+C+D+E+a+b+c+d+e-max([a,b,c,d,e]))
  
  
  
if __name__ == '__main__':
  main()

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

int main(){
	int n, m, a, i, j, now=0, ans=0;
	int s[100000];
	scanf("%d %d", &n, &m);
	s[0] = 0;
	for(i=1;i<=n-1;i++)
	{
		scanf("%d", &s[i]);
		s[i] += s[i-1];
		/*
		printf("%d ", s[i]);
		*/
	}
	for(j=0;j<m;j++)
	{
		scanf("%d", &a);
		if(a>0) ans += (s[now+a] - s[now]) % 100000;
		else ans += (s[now] - s[now+a]) % 100000;
		if(ans>100000) ans = ans % 100000;
		/*
		printf("%d ", s[now+a] - s[now]);
		*/
		now += a;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 988
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll a;
    cin >> a;
    
    a -= 400;
    
    
    mes(8-(a/200));
    
    


}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define vi vector<int>
using namespace std;

//int gcd(int a, int b){
//	return b==0 ? a : gcd(b, a%b);
//}

int32_t main(void){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	
	int arr[n][3];
	
	rep(i, 0, n)
	{
		rep(j, 0, 3)
		{
			cin>>arr[i][j];
		}
	}
	
	int temp1, temp2, temp3, temp4;
	rep(i, 1, n)
	{
		rep(j, 0, 3)
		{
			if(j-1 >= 0) temp1 = arr[i-1][j-1];
			else temp1 = 0;
			if(j+1 <= 2) temp2 = arr[i-1][j+1];
			else temp2 = 0;
			if(j+2 <= 2) temp3 = arr[i-1][j+2];
			else temp3 = 0;
			if(j-2 >= 0) temp4 = arr[i-1][j-2];
			else temp4 = 0;
			arr[i][j]+=max(temp1, max(temp2, max(temp3, temp4)));
		}
	}
	
	int final_ans = 0;
	rep(i, 0, 3) final_ans = max(final_ans, arr[n-1][i]);
	cout<<final_ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

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

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int k,n; cin >> k >> n;
    int lake[200000];
    FOR(i,n) cin >> lake[i];
    sort(lake,lake+n);
    int maxdist = 0;
    F0R(i,1,n-1) maxdist = max(maxdist,lake[i]-lake[i-1]);
    maxdist = max(maxdist,k+lake[0]-lake[n-1]);
    cout << k-maxdist << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<cmath>
#include<iostream> 
#include<cstdio>
using namespace std;

int main(){
    double x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.5f\n",sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
    return 0;
}


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

#define ll int64_t

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  ll n, k;
  cin >> n >> k;
  int a, b;
  vector<pair<int,int>> ans(n);
  for(int i=0; i<n; ++i) {
    cin >> a >> b;
    ans.at(i).first = a;
    ans.at(i).second = b;
  }
  sort(ans.begin(), ans.end());
  for(int i=0; i<n; ++i) {
    k -= ans.at(i).second;
    if(k <= 0) drop(ans.at(i).first);
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


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

bool dp[200011];

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  for(int i=0;i<k;++i){
    for(int j=0;j<n;++j){
      if(!dp[i]) dp[i+a[j]]=true;
    }
  }
  if(dp[k]){
    cout << "First" << endl;
  }else{
    cout << "Second" << endl;
  }
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n,w;
    cin >> n >> w;
    vector<ll> v[4];
    int w1 = 0;
    rep(i,n){
        int x,y;
        cin >> x >> y;
        if(i==0){
            w1 = x;
        }
        v[x-w1].push_back(y);
    }
    rep(i,4){
        sort(v[i].begin(),v[i].end(),greater<ll>());
    }
    vector<ll> imos[4];
    rep(i,4){
        imos[i].push_back(0);
    }
    rep(i,4){
        rep(j,v[i].size()){
            imos[i].push_back(imos[i].back()+v[i][j]);
        }
    }
    ll ans  =0;
    rep(i,imos[0].size()){
        ll s = w1*i;
        if(s>w){
            break;
        }
        rep(j,imos[1].size()){
            s=w1*i+(w1+1)*j;
            if(s>w){
                break;
            }
            rep(k,imos[2].size()){
                s=w1*i+(w1+1)*j+(w1+2)*k;
                if(s>w){
                    break;
                }
                rep(l,imos[3].size()){
                    s=w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l;
                    if(s>w){
                        break;
                    }
                    ll val = imos[0][i]+imos[1][j]+imos[2][k]+imos[3][l];
                    ans = max(ans,val);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
#define MOD 1000000007
using ll = long long;
using namespace std;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
if(a%2!=0 && b%2!=0){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
//system("pause");
return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll ans = 0;
    rep(i, N) {
        ll a = A[i];
        if (a % 2 == 1 && (i + 1) % 2 == 1) ans++;
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>


int main() {
	const std::string target = "E869120";
	int n; std::cin >> n;
	int count = 0;
	for (auto i = 0; i < n; ++i) {
		std::string name; std::cin >> name;
		if (target == name) {
			++count;
		}
	}
	std::cout << count << std::endl;
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n;
    cin>>n;
    string s;
    cin>>s;
    long max=0,x=0;
    for(int i = 0; i < s.size(); i++){
        if(s[i]=='I')
            x++;
        else
            x--;
        if(x>max)
            max=x;
    }
    cout<<max;
}

Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = []
for _ in range(N):
    A.append(list(map(int, input().split())))
count = 0
for i in range(N):
    s = C
    for j in range(M):
        s += A[i][j] * B[j]
    if s > 0:
        count += 1
print(count)

Measured memory_bytes: 3064
import math
def is_prime(n):
    if n == 1: return False
    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:return False
    return True
flg = [1 if (i%2==1 and is_prime(i) and is_prime((i+1)//2)) else 0 for i in range(100001)] 
for i in range(1,100001):flg[i]+=flg[i-1]
for i in range(int(input())):
    l,r= map(int,input().split())
    print(flg[r]-flg[l-1])

Measured memory_bytes: 6424
#include <stdio.h>
int n;
char s[200];
int main() {
	scanf("%d", &n);
	scanf(" %s", s);
	if (n % 2) {
		printf("No\n");
		return 0;
	}
	n /= 2;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[i + n]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if (n == 1) {
			System.out.println("Hello World");
		} else {
			int A = scan.nextInt();
			int B = scan.nextInt();
			System.out.println(A+B);
		}
	}
}


Measured memory_bytes: 24916
#include <bits/stdc++.h>
#include <cstdlib> 
using namespace std;
int main() {
  int N,M;cin >> N >> M;
  string a;
  vector<char>vec(N);
  for(int i=0;i<M+2;++i) cout << "#";
  cout << endl;
  
  for(int i=0;i<N;++i){
    cout << "#";
    cin >> a;
    cout << a << "#" << endl;
  }
  for(int i=0;i<M+2;++i) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};

int main(){
    ll n; cin >> n;
    string s,t;
    ll cur = 0;
    ll left = 0;
    ll right = n;
    rep(z,20){
        if(z==0){
            cout << cur << endl;
            fflush(stdout);
            cin >> s;
            t = s;
            if(s=="Vacant") return 0;
            else{
                cur = n/2;
            }
        }
        else {
            cout << cur << endl;
            fflush(stdout);
            cin >> s;
            if(s=="Vacant") return 0;
            if ((s==t)==(cur%2==0)){
                left = cur;
                cur = (right + cur)/2;
            }else{
                right = cur;
                cur = (left + cur)/2;
                //cout << left << " " << cur << " " << right << endl;
            }
        }
    }
}


Measured memory_bytes: 852
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k <= a){
        cout << k << endl;
    }else if(k <= a+b){
        cout << a << endl;
    }else{
        int ans = k-a-b;
        cout << a - ans << endl;
    }
}


Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n, m; cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1;
    REP(i, n) ans = ans * (1 + i) % MOD;
    REP(i, m) ans = ans * (1 + i) % MOD;
    if(n == m) ans = ans * 2 % MOD;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import queue
dx=[1,0,-1,0]
dy=[0,1,0,-1]
H,W=map(int,input().split())
S=[]
for h in range(H):
  S.append(input())

def bfs(s):
  dist = [[-1]*W for _ in range(H)]
  
  h,w = s
  dist[h][w]=0
  que = queue.Queue()
  que.put(s)
  
  while not(que.empty()):
    h,w = que.get()
    for d in range(4):
      nh = h + dx[d]
      nw = w + dy[d]
      if nh<0 or H<=nh or nw<0 or W<=nw:
        continue
      if S[nh][nw]=="#":
        continue
      if dist[nh][nw]==-1:
        dist[nh][nw]=dist[h][w]+1
        que.put([nh,nw])
  return dist[h][w]

ans = 0
for h in range(H):
  for w in range(W):
    if S[h][w]==".":
      ans = max(ans,bfs([h,w]))
print(ans)
      


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

int main(){
	int c[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>c[i][j];
		}
	}
	int a1,a2,a3,b1,b2,b3,flag=0;
	for(int i=0;i<=c[0][0];i++){
		a1=i;
		b1=c[0][0]-i;b2=c[0][1]-i;b3=c[0][2]-i;
		a2=c[1][0]-b1;a3=c[2][0]-b1;
		//cout<<c[1][2]<<endl;
		//cout<<a2<<b3<<endl;
		if(c[1][1]!=(a2+b2)||c[1][2]!=(a2+b3)||c[2][1]!=(a3+b2)||c[2][2]!=(a3+b3)){
			flag=1;
		}
	}
	if(flag){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 256
s=list(input())
t=list(input())

n=len(s)
ch=0
ch1=0
ans=0

d={}
d1={}

st=1
st1=1

s_new=[]
t_new=[]

for i in range(n):
  if s[i] not in d:
    d[s[i]]=st
    st+=1
    
for g in range(n):
  if t[g] not in d1:
    d1[t[g]]=st1
    st1+=1
    
for h in range(n):
  s_new.append(d[s[h]])
  t_new.append(d1[t[h]])
  
if s_new==t_new:
  print('Yes')
else:
  print('No')
  

Measured memory_bytes: 15208
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  int N;
  double T,A,H[1010];
  cin >> N >> T >> A ;
  cinf(N,H) ;
  int ans ;
  const int INF = 100000000 ;
  double min =INF ;
  for(int i=0;i<N;i++){
    if(abs(A-T+H[i]*0.006)<min){
       min = abs(A-T+H[i]*0.006) ;
       ans = i+1 ;
    }
  }
  cout << ans << endl;
}

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

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = 0;
  ans += a * (n / (a + b));
  ans += min(n % (a + b), a);
  cout << ans << endl;
}

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

int main()
{
  char a[10];
  int sum=0,r=0;
  scanf("%s",a);
  for(int i=0;i<10;i++){
    if(a[i]=='A'||a[i]=='T'||a[i]=='C'||a[i]=='G')
      sum++;
    else{
      if(r<sum)
        r=sum;
      sum=0;
    }
  }
  if(r<sum)
    r=sum;
  printf("%d",r);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
typedef pair<int,int>pii;
const int mxN=2e5,M=1e9+7;

int n,me=M,resp;
int v[mxN];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>v[i];
        me=min(me,v[i]);
        //cout<<me<<" "<<v[i]<<"\n";
        if(me>=v[i])resp++;
    }

    cout<<resp;
}

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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)

// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < n; ++i){
// 		res += max(0ll, a[i]-x/f[i]);
//     }
//     return res <= k;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main(){
  ll N;
  cin >> N;
  ll a, b;
  ll tmp, ans = N - 1;
for(ll i = 1; i * i <= N; i++){
    if(N % i == 0) {
      a = i;
      b = N / i;
      tmp = (a - 1) + (b - 1);
      ans = min(ans, tmp);
    }
}
print(ans);


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int N;
vector<int> x(10), y(10);

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int main() {
    cin >> N;
    rep(i, N) cin >> x[i] >> y[i];
    double ans = 0.0;

    rep(i, N-1) {
        for (int j = i+1; j < N; j++) {
            ans += dist(i, j) * 2 / N;
        }        
    }

    cout << fixed << setprecision(10) << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long power = 1;
		for (int i = 1; i <= n; i++) {
			power = power * i % 1000000007;
		}
		System.out.println(power);
		sc.close();
	}

}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define eps (1e-10)
using namespace std;
class Point
{
	public:
	double x,y;
	Point(double _x=0,double _y=0):x(_x),y(_y){}
	Point operator + (Point p){ return Point(x+p.x,y+p.y);} 
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){return Point(a*x,a*y);} 
	Point operator / (double a){return Point(x/a,y/a);}
	double norm(){return x*x+y*y;}
	double ABS(){return sqrt(norm());} //俩点间的距离 
};
struct Segment
{
	Point p1,p2;	
};

double dot(Point a,Point b)//求内积 就是向量a*b 
{
	return a.x*b.x+a.y*b.y;
}
//外积的值为a与b向量构成的平行四边形面积的值 
double cross(Point a,Point b)//求外积 
{
	return a.x*b.y-a.y*b.x;
} 


//判断是否正交 向量内积：a*b=|a||b|*cos(Y) 当cos为0时正交(90,-90垂直) 
//a*b=a.x*b.x+a.y*b.y;
bool solve1(Point a,Point b)//是否正交 
{
	double f=a.x*b.x+a.y*b.y; 
	if(fabs(f-0.0)<eps) return true;
	else return false;
}
//判断是否平行  向量外积：|a*b|=|a||b|sin(Y) 当sin为0时平行(180,0平行)
//|a*b|=|a|*|b|*sin(Y) 
bool solve2(Point a,Point b)//是否平行 
{
	double f=a.x*b.y-a.y*b.x;
	if(fabs(f-0.0)<eps) return true;
	else return false;
}

/*
求垂足x：对于给定的三点p1,p2,p从点p向通过p1,p2的直线引一条垂线
base=p2-p1;
hypo=p-p1;
 x=s.p1+base*(hypo*base/|base|^2); hypo*base 可以用向量内积求 
*/
Point solve3(Segment s,Point p)//求投影点 
{
	Point base=s.p2-s.p1;
	double r=dot(p-s.p1,base)/base.norm();
	return s.p1+base*r; 
}
/*
求投影点x：对于给定的三点p1,p2,p从点p向通过p1,p2的直线为对称轴与点p
成线对称点为x 
通过求solve3的垂足延长一倍就可以求x 
*/
Point solve4(Segment s,Point p)//求映象 
{
	return p+(solve3(s,p)-p)*2.0;
}

/*
点a与点b之间的距离等于向量a-b或b-a的绝对值。 
*/ 
double getdis(Point a,Point b)//求俩点间的距离                    
{
	return (a-b).ABS();
} 

/*
设直线p1 p2上的向量为a=p2-p1,p与p1构成的向量b=p-p1
则点p与直线p1p2的距离d就等于a,b构成的平行四边形的高
用a与b外积的大小(平行四边形的面积)除以a的大小|a|即可求出高d
d=|a*b|/|a|=|(p2-p1)*(p-p1)|/|p2-p1|; 
*/
//注意：这里Segmet s是不规范的应该是 Line s 才对 
double getdis_Li(Segment s,Point p)//点与直线的距离 
{
	return abs(cross(s.p2-s.p1,p-s.p1)/(s.p2-s.p1).ABS());
}
/*
Point a=p1-p0;
Point b=p2-p0;
1.外积大小cross(a,b)为正时,可确定b在a的逆时针方向
	sin(Y)（Y在0-180）所以是正数
2. 外积大小cross(a,b)为负时,可确定b在a的顺时针方向
3.（1,2）不符合 表示p2在直线p0p1上(注意是直线),cos(Y)大于90或小于-90
	度时为负，因此a与b的内积dot(a,b)负时，可确定p2位于线段p0p1后方
	即p2->p0->p1
4.不是3时，有俩种p0->p1-p2或者p0->p2->p1如果b的大小大于a的大小，即为
	p0->p1->p2;
5.不符合4，可以确定p2位于线段p0p1上 
*/ 
int ccw(Point p0,Point p1,Point p2)//判断三个点相对位置 
{
	Point a=p1-p0;
	Point b=p2-p0;
	if(cross(a,b)>eps) return 1;//p0,p1,p2成逆时针方向 
	if(cross(a,b)<-eps) return -1;//p0,p1,p2成顺时针方向 
	if(dot(a,b)<-eps) return 2;//p2 p0 p1一次排列在同一直线上 
	if(a.norm()<b.norm()) return -2;// p0 p1 p2一次排列在同一直线上 
	return 0;//p2在线段p0p1上 
	
}
bool intersect(Point p1,Point p2,Point p3,Point p4)
{
	return (ccw(p1,p2,p3)*ccw(p1,p2,p4)<=0&&ccw(p3,p4,p1)*ccw(p3,p4,p2)<=0);
}
int main()
{
	int T;scanf("%d",&T);
	while(T--){
		double x0,y0,x1,y1,x2,y2,x3,y3;
		scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
		Point p0(x0,y0),p1(x1,y1),p2(x2,y2),p3(x3,y3);
		if(intersect(p0,p1,p2,p3)) printf("1\n");
		else printf("0\n");
	}
	
	return 0;
}



Measured memory_bytes: 3220
#include <stdio.h>

int main(void){
	int i, j;
	int can[50];	//Candidate
	int n,p,c;
	while(1){
		scanf("%d%d",&n,&p);
		if(n==0&&p==0)	break;
		c = p;
		for(i=0;i<n;i++) can[i]=0;	//init Candidate
		i=0;
		do{
			if(c>0){
				can[i]++;
				c--;
			}else if(c==0){
				c=can[i];
				can[i]=0;
			}
			i++;
			if(i==n) i=0;
		}while(can[i]<p);
		printf("%d\n", i);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

static const int64_t kRem = 1000000007;

int64_t dp[100001][2] = { 0 };

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

	string s;
	cin >> s;

	dp[0][0] = 2;
	dp[0][1] = 1;
	FOR_LT(i, 1, s.size()) {
		if (s[i] == '1') {
			dp[i][0] = dp[i - 1][0] * 2;
			dp[i][1] = dp[i - 1][1] * 3 + dp[i - 1][0];
		}
		if (s[i] == '0') {
			dp[i][0] = dp[i - 1][0];
			dp[i][1] = dp[i - 1][1] * 3;
		}

		dp[i][0] %= kRem;
		dp[i][1] %= kRem;
	}

	int64_t ans = dp[s.size() - 1][0] + dp[s.size() - 1][1];
	ans %= kRem;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2000
#include <string>
    #include <iostream>
 void solve_D() {
	int n;
	std::cin >> n;
	std::string s;
	std::cin >> s;
	long long r_count = 0, g_count = 0, b_count = 0;
	for(int i = 0; i < n;i++) {
		if (s[i] == 'R') r_count++;
		else if (s[i] == 'G') g_count++;
		else b_count++;
	}
	long long ans = r_count * g_count * b_count;
	for (int distance = 1; distance < n + 1; distance++) {
		for (int j = 0; j + 2 * distance<n; ++j) {
			if (s[j] != s[j + distance] && s[j + distance] != s[j + 2 * distance] && s[j] != s[j + 2 * distance])
				ans -= 1;
		}
	}
	std::cout << ans << std::endl;
}

     
    int main()
    {
    	std::ios::sync_with_stdio(false);
    	//solve_A();
    	//solve_B();
    	//solve_C();
    	solve_D();
        return 0;
    }

Measured memory_bytes: 3648
import std.stdio, std.string, std.array, std.conv, std.algorithm;

void main() {
    int n = readln.chomp.to!int;
    long[string] s;
    foreach (i; 0 .. n) {
        string tmp = readln.split.to!(dchar[]).sort!("a < b").to!string;
        if (tmp in s) ++s[tmp];
        else s[tmp] = 0;
    }
    long cnt;
    foreach (val; s.values) {
        cnt += val * (val + 1) / 2;
    }
    cnt.writeln;
}

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

int main(){

 int n,h,a[1000000],x;
  cin>>n;
  h=n/2;
  for(int i=0;i<n;i++){
  cin>>a[i];
  }
  sort(a,a+n);
  x=a[h]-a[h-1];
  cout<<x<<endl;
}

Measured memory_bytes: 2560
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const int INF = 1000000;
const double PI=3.14159265359;

int main(){

  ll n,k,s;cin>>n>>k>>s;

  // if(n>=k){
  rep(i,0,n){
    if(i<k){
      cout<<s<<" ";
    }else{
      if(s==1e9)cout<<s-1<<" ";
      else if(s==1)cout<<10<<" ";
      else cout<<s+1<<" ";
      // else if(s==1e9) cout<<12348<<" ";
    }
  }
  cout<<endl;
  // }else{

  // }

  return 0;
}


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

using namespace std;

int main(){
	int N;
	string S;
	bool flag = true;

	cin >> N >> S;

	if(N % 2 == 0){
	for(int i = 0; i < N/2; i++){
		if(S.at(i) == S.at(i+N/2)){
			continue;
		}else{
			flag = false;
			break;
		}
	}
	}else{
		flag = false;
	}

	if(flag){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;

}



Measured memory_bytes: 256
import java.util.*;
import java.io.PrintWriter;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static final int MOD = 1000000007;
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		out.println(s[2]==s[3]&&s[4]==s[5]?"Yes":"No");
	}
}


Measured memory_bytes: 22228
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

x,n = map(int,stdin.readline().rstrip().split())
p = list(map(int,stdin.readline().rstrip().split()))
p.sort()
mi = 10**10
now = 10**10

for i in range(-1000,1000):
    if i not in p:
        if abs(i-x) < mi:
            mi = abs(i-x)
            now = i

print(now)

Measured memory_bytes: 9200
#define _GLIBCXX_DEBUG
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rep2(i,s,n) for(int i=s;i< (int)n; i++)
#define ll long long 
#define all(v) v.begin(),v.end()

using namespace std;
// index が条件を満たすかどうか
bool isOK(int index, vector<int>& a, int b, int c) {
    if (a[index] > abs(a[b]-a[c])) return true;
    else return false;
}
// 二分探索
int binary_search(vector<int>& a, int b,int c) {
    int left = c; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK(mid, a , b, c)) right = mid;
        else left = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}


// index が条件を満たすかどうか
bool isOK2(int index, vector<int>& a, int b, int c) {
    if (a[index] < a[b]+a[c]) return true;
    else return false;
}
// 二分探索（上から押さえる）
int binary_search2(vector<int>& a, int b,int c) {
    int left = c; //「index = b+1」が条件を満たすこともあるので、初期値は -1
    int right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;
        if (isOK2(mid, a , b, c)) left = mid;
        else right = mid;
    }
    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return left;
}


int main(){
  int n; cin >>n;
  vector<int> L(n);
  rep(i,n) cin >>L[i];
  int ans=0;
  sort(all(L));
  rep(i,n-2){
    rep2(j,i+1,n-1){
        if((binary_search(L,i,j)!=n)&&binary_search2(L,i,j)!=j) ans+=binary_search2(L,i,j)-binary_search(L,i,j)+1;
  }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

string affine(string s, int alpha, int beta){
    int n = s.size();
    for(int i=0; i<n; ++i){
        if('a' <= s[i] && s[i] <= 'z')
            s[i] = ((alpha * (s[i]-'a') + beta) % 26) + 'a';
    }
    return s;
}

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

    while(--n >= 0){
        string s;
        getline(cin, s);

        for(int a=1; a<26; ++a){
            for(int b=0; b<26; ++b){
                string s1 = affine("that", a, b);
                string s2 = affine("this", a, b);
                if(s.find(s1) != string::npos || s.find(s2) != string::npos){
                    string to(26, ' ');
                    for(int i=0; i<26; ++i)
                        to[i] = i + 'a';
                    to = affine(to, a, b);
                    string from(26, ' ');
                    for(int i=0; i<26; ++i)
                        from[to[i]-'a'] = i + 'a';


                    for(unsigned i=0; i<s.size(); ++i){
                        if('a' <= s[i] && s[i] <= 'z')
                            s[i] = from[s[i]-'a'];
                    }
                    cout << s << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int N;
	int h;
	int max_h = 0;
	vector<int> hs;
	int ans;

	cin >> N;

	hs.push_back(0);
	for(int ni = 0; ni < N; ni++){
		cin >> h;
		hs.push_back(h);
		if (h > max_h) max_h = h;
	}
	hs.push_back(0);

	ans = 0;
	int flag;
	for (int hi = 1; hi <= max_h; hi++){
		flag = 0;
		for (int ni = 1; ni < N+2; ni++){
			if (flag == 0 && hs[ni] >= hi){
				flag = 1;
			}
			if (flag == 1 && hs[ni] < hi){
				ans++;
				flag = 0;
			}
		}
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>

#define TRACE(x) std::cout << #x << " = " << x << "\n"
#define _ << " _ " <<

using namespace std;

const int MAX = 1001000;

int fl[MAX][2], fr[MAX][2];

int main() {
  std::ios_base::sync_with_stdio(false);

  string S;
  cin >> S;

  int N = S.size();
  auto can = [&](int K) -> bool {
    for (int i = 0; i <= N; ++i) {
      for (int j = 0; j < 2; ++j) {
        fl[i][j] = MAX, fr[i][j] = -MAX;
      }
    }

    fl[0][0] = 0, fr[0][0] = K - (K % 2 ? 1 : 0);
    fl[0][1] = 1, fr[0][1] = K - (K % 2 ? 0 : 1);
    for (int i = 0; i <= N; ++i) {
      for (int j = 0; j < 2; ++j) {
        fl[i][j] = max(fl[i][j], fl[0][j]);
        fr[i][j] = min(fr[i][j], fr[0][j]);
        if (fl[i][j] > fr[i][j]) fl[i][j] = MAX, fr[i][j] = -MAX;
      }
      if (i == N) break;
      if (S[i] == '0') {
        for (int j = 0; j < 2; ++j) {
          fl[i + 1][j ^ 1] = fl[i][j] - 1;
          fr[i + 1][j ^ 1] = fr[i][j] - 1;
        }
      } else if (S[i] == '1') {
        for (int j = 0; j < 2; ++j) {
          fl[i + 1][j ^ 1] = fl[i][j] + 1;
          fr[i + 1][j ^ 1] = fr[i][j] + 1;
        }
      } else {
        for (int j = 0; j < 2; ++j) {
          fl[i + 1][j ^ 1] = fl[i][j] - 1;
          fr[i + 1][j ^ 1] = fr[i][j] + 1;
        }
      }
    }

    return fl[N][0] <= fr[N][0] || fl[N][1] <= fr[N][1];
  };

  int lo = 0, hi = N;
  while (lo < hi) {
    int mid = (lo + hi) / 2;
    if (can(mid))
      hi = mid;
    else
      lo = mid + 1;
  }

  cout << lo << '\n';
  return 0;
}


Measured memory_bytes: 19916
n=gets.chomp.to_i
a=gets.chomp.split(" ").map { |e| e.to_i }.sort

def abs(n)

  if n>=0
    return n
  else
    return -n
  end

end

max = a[n-1]
min = 10**10
var = a[0]

for i in 0..n-2 do
  temp = abs(a[i] - (max+1)/2)
  if min > temp
    var = a[i]
    min = temp
  end
end

printf("%d %d\n",max,var)

Measured memory_bytes: 11008
// #define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto start = high_resolution_clock::now()
#define etime auto stop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(stop-start); cout<<"Time elapsed : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//functions: set.insert(val), *(set.find_by_order(order-1)), set.order_of_key(val)

using namespace __gnu_pbds;
using namespace std;
using namespace std::chrono;

const ll mod = 1e9+7;
const ll N = 1e6+6;
const ll maxN = 1e5+5;
const ll MAX_SIZE = 2e6+6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = mod){ // default argument
ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;}

ll power(ll x, ll y){
ll v = 1; while (y > 0) {if (y & 1)v = v * x; y = y >> 1; x = x * x;} return v;}

int main()
{
    //#ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    //#endif
    FIO
    int n;
    cin>>n;
    string s;
    cin>>s;
    int l=0,r=n-1;
    int cnt=0;
    while(l<r){
		while(l<=n-1 && s[l] == 'R') ++l;
		if(l>=r) break;
		while(r>=0 && s[r] == 'W') --r;
		if(l>=r) break;
		cnt++;
		// one swapping done here
		++l, --r;
	}
	cout<<cnt;
    return 0;
}




Measured memory_bytes: 3764
N, M = map(int, input().split())

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

paths = []
for i in range(M):
    paths.append(list(map(int, input().split())))
    paths[-1][0] -= 1
    paths[-1][1] -= 1
    
bad = set()

for path in paths:
  if H[path[0]] == H[path[1]]:
    bad.add(path[0])
    bad.add(path[1])
  elif H[path[0]] > H[path[1]]:
    bad.add(path[1])
  else:
    bad.add(path[0])
        
print(N-len(bad))

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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int Lo = K - A - B;
  if (A>=K) {
    cout << K << endl;
  }
  else if( A<K && A+B >= K) {
    cout << A << endl;
  }
  else if(A+B < K) {
    cout << A - Lo << endl;
  }
  }

Measured memory_bytes: 3624
class MyStack:
    def __init__(self, size):
        self.stack = [0 for i in range(size)]
        self.size = size
        self.top = 0

    def initialize(self):
        self.top = 0

    def push(self, elm):
        self.top += 1
        self.stack[self.top] = elm
        return self.stack

    def pop(self):
        ret = self.stack[self.top]
        self.stack[self.top] = 0
        self.top -= 1
        return ret

    def is_empth(self):
        if not self.is_full():
            return True
        return False

    def is_full(self):
        if self.size-1 is self.top:
            return True
        return False


def main(expr):
    stack = MyStack(1000)
    for i, elm in enumerate(expr):
        if expr[i] is '+':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(a) + int(b))
        elif expr[i] is '-':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(b) - int(a))
        elif expr[i] is '*':
            a = stack.pop()
            b = stack.pop()
            stack.push(int(a) * int(b))
        else:
            stack.push(elm)
    return stack.pop()


if __name__ == '__main__':
    expr = [str(s) for s in input().split()]
    print(main(expr))

Measured memory_bytes: 7744
package main

import "fmt"

func main() {
	var x, y int
	for {
		fmt.Scan(&x, &y)
		if x == 0 && y == 0 {
			break
		}
		if x < y {
			fmt.Println(x, y)
		} else{
			fmt.Println(y, x)
		}
	}
}


Measured memory_bytes: 1224
var
a:array[1..1000000]of longint;
i,j,k,n,m:longint;
procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
readln(n);
for i:=1 to n*2 do
  read(a[i]);
sort(1,n*2);
for i:=1 to n*2 do
 if i mod 2<>0 then inc(m,a[i]);
 writeln(m);
end.

Measured memory_bytes: 128
#include<bits/stdc++.h>
            #define ll long long
            #define f   first
            #define s   second
            #define pb          push_back
            #define mod        1000000007
            #define mod1       1000000009
            #define hell        998244353
            #define inf         1000000000000000000LL
            #define pi          3.14159265358979323
            #define N           1000050
            using namespace std;
            ll n,k,sum,q,res,m,val;
            ll x,y;
            void solve()    
            {   

                cin>>n>>m;
                vector<ll> v(n);
                for(int i=0;i<n;i++) cin>>v[i];
                for(int i=0;i<n-1;i++)
                {
                    if(v[i]+v[i+1]>=m)
                    {   cout<<"Possible\n";
                        for(int j=0;j<i;j++)
                            cout<<j+1<<"\n";
                        
                        for(int j=n-1;j>=(i+1);j--)
                            cout<<j<<"\n";
                        return;
                    }
                }
                cout<<"Impossible";









            }
            int main()
            {   ios_base::sync_with_stdio(false);
                cin.tie(0);cout.tie(0);
                ll t=1;
                //cin>>t;
                for(int i=1;i<=t;i++)
                    solve();
                

            }            

Measured memory_bytes: 3928
#include <iostream>
#include <string.h>
using namespace std;

int main() {
  int tmp, n;
  cin >> n;
  int nod,max = 0, ans = 1;
  for(int i=1;i<=n;i++){
    tmp = i;
    nod = 0;
    while(tmp %2 == 0){
      tmp /= 2;
      nod += 1;
    }
    if(nod > max){
        max = nod;
        ans = i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
while True:
    n=int(input())
    if n==0:
        break
    
    a=[None]*n
    for i in range(n):
        a[i]=input()
    a=list(map(int,a))
    
    for i in range(10):
        k=0
        for j in range(n):
            if a[j]==i:
                k+=1
        if k==0:
            print('-')
        else:
            print('*'*k)


Measured memory_bytes: 5728
import sys
a, b, c, x, y = [int(i) for i in sys.stdin.readline().split()]
if a + b < 2 * c:
    print(x * a + y * b)
else:
    if x > y:
        if a <= c * 2:
            print(c * y * 2 + a * (x - y))
        else:
            print(c * x * 2)
    else:
        if b <= c * 2:
            print(c * x * 2 + b * (y - x))
        else:
            print(c * y * 2)

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>

using namespace std;
 
int main(void)
{   
    int n, m, x, ans1=0,ans2=0;
    cin >> n >> m >> x;
    vector<int> a(m);
    
    for(int i = 0;i < m;i++){
        cin >> a[i];
        if(a[i]>x){
            ans1++;
        }
        else{
            ans2++;
        }
    }

    cout << min(ans1,ans2) << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[600][600];

int main(){
  int w,x,y,z;
  w = x = y = z = 0;
  cin >> s;
  rep(i,0,s.sz){
    if(s[i] == 'W')w++;
    else if(s[i] == 'E')z++;
    else if(s[i] == 'S')y++;
    else x++;
  }
  if(x != 0 && y == 0)puts("No");
  else if(y != 0 && x == 0)puts("No");
  else if(z != 0 && w == 0)puts("No");
  else if(w != 0 && z == 0)puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>

using namespace std;

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

const long long INF = 1LL << 60;

int main() {
	int n; cin >> n;
	int a;
	vector<long long> h;
	vector<long long> dp;
	for (int i = 0; i < n; i++) {
		cin >> a;
		h.emplace_back(a);
	}
	for (int i = 0; i < n + 1; i++) dp.emplace_back(INF);

	dp[0] = 0;

	for (int i = 1; i < n; i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));

	}
	cout << dp[n - 1] << endl;
}

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

typedef long long ll;
const ll MOD = 1e9+7;
const int N = 1e5+5;

int n,a[N],b[N];

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i=1;i<=n+1;i++)cin>>a[i];
    for(int i=1;i<=n;i++)cin>>b[i];

    ll ans=0;

    for(int i=1;i<=n;i++){
        int c=min(a[i],b[i]);
        ans+=1LL*c;
        b[i]-=c;
        a[i]-=c;

        c=min(a[i+1],b[i]);
        ans+=1LL*c;
        b[i]-=c;
        a[i+1]-=c;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<long long> vll;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int A;
  int B;
  char op;

  cin >> A >> op >> B;

  int ans = 0;
  if (op == '+')
    {
    ans = A + B;
    }
  else if (op == '-')
    {
    ans = A - B;
    }
 cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}

int main()
{
	int a, b;
	cin >> a >> b;
	cout << max({a + b, a - b, a * b}) << endl;
	return 0;
}

Measured memory_bytes: 3576