akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

template<typename T>
struct Fordfulkerson {
  struct edge {
    int to, rev;
    T cap;
  };

  std::vector<std::vector<edge>> graph;
  std::vector<bool> used;
  const T INF;

  Fordfulkerson(int n) : INF(numeric_limits<T>::max()) {
    graph.resize(n);
    used.assign(n, false);
  }

  void add_edge(int from, int to, T cap) {
    graph[from].push_back((edge){to, (int)graph[to].size(), cap});
    graph[to].push_back((edge){from, (int)graph[from].size() - 1, 0});
  }

  T dfs(int v, int t, T flow) {
    if(v == t) return flow;
    used[v] = true;
    for(auto &e : graph[v]) {
      if(!used[e.to] && e.cap > 0) {
        T d = dfs(e.to, t, min(flow, e.cap));
        if(d > 0) {
          e.cap -= d;
          graph[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  T max_flow(int s, int t) {
    T flow = 0;
    for(;;) {
      used.assign(used.size(), false);
      T f = dfs(s, t, INF);
      if(f == 0) return flow;
      flow += f;
    }
  }
};


signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VI a(n), b(n), c(n), d(n);
  rep(i, n) {
    cin >> a[i] >> b[i];
  }
  rep(i, n) {
    cin >> c[i] >> d[i];
  }
  Fordfulkerson<int> f(2*n+2);
  rep(i, n) {
    rep(j, n) {
      if(a[i] < c[j] && b[i] < d[j]) {
        f.add_edge(i, n+j, 1);
      }
    }
  }
  rep(i, n) {
    f.add_edge(2*n, i, 1);
    f.add_edge(n+i, 2*n+1, 1);
  }
  int ans = f.max_flow(2*n, 2*n+1);
  out(ans);
  return 0;
}


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

int main() {
  int N, i = 0;
  string S;
  cin >> N;

  for(; i < N; i++){
    cin >> S;
    
    if(S == "Y"){
      cout << "Four" << endl;
      break;
    }
    
  }
  
  if(i == N){
    cout << "Three" << endl;
  }
  
}


Measured memory_bytes: 256
import java.util.Scanner;

// C - Snack
// https://atcoder.jp/contests/abc148/tasks/abc148_c
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        scanner.close();

        long ans = lcm(A, B);

        System.out.println(ans);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private static long gcd(long m, long n) {
        if (m < n) return gcd(n, m);
        if (n == 0) return m;
        return gcd(n, m % n);
    }
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<string.h>
int main()
{
int sum=0,a,b,i;
scanf("%d %d",&a,&b);
if((a>=1&&a<=100)&&(b>=1&&b<=1e5))
{

for(i=0;i<a;i++)
sum=sum+500;
if(sum>b||sum==b)   printf("Yes");
else printf("No"); 
}
return 0; 

}

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

using namespace std;

int main()
{
   int a, b, c;
   cin >> a >> b >> c;

   if ((a == b && b != c) || (a == c && b != c) || (b == c && a != c))
       cout << "Yes" << endl;
   else
       cout << "No" << endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す(m進数で)
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];
	int minv = a[0];
	int maxv = -10000000000;
	for (int i = 1; i < a.size(); i++) {
		maxv = max(a[i] - minv, maxv);
		minv = min(minv, a[i]);
	}

	cout << maxv << endl;

	//system("pause");
	//return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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 (b<a) { a=b; return 1; } return 0; }

int main() {
    ld N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    ll ans = ceil((N - 1) / (K - 1));
    cout << ans << endl;
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define pii pair<int,int>
#define fi first
#define se second
#define PB push_back
using namespace std;
const int N=100005;
struct edge{
	int to,next,ok;
}e[N*2];
int head[N],tot=1,n,m;
int vis[N],deg[N];
void add(int x,int y){
	e[++tot]=(edge){y,head[x],0};
	head[x]=tot;
}
void dfs(int x,int fae){
	vis[x]=++*vis;
	for (int i=head[x];i;i=e[i].next)
		if ((i^fae^1))
			if (!vis[e[i].to]){
				dfs(e[i].to,i);
				if (deg[e[i].to]&1){	
					e[i].ok=-1;
					e[i^1].ok=1;
					deg[e[i].to]^=1;
				}
				else{
					e[i].ok=1;
					e[i^1].ok=-1;
					deg[x]^=1;
				}
			}
			else if (vis[e[i].to]<vis[x]){
				e[i].ok=1;
				e[i^1].ok=-1;
				deg[x]^=1;
			}
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,m){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y); add(y,x);
	}
	For(i,1,n)
		if (!vis[i])
			dfs(i,0);
	For(i,1,n)
		if (deg[i])
			return puts("-1"),0;
	For(i,1,n)
		for (int j=head[i];j;j=e[j].next)
			if (e[j].ok==1)
				printf("%d %d\n",i,e[j].to);
}

Measured memory_bytes: 11136
import math
a, b, x = map(int, input().split())
h = x * 2 / b / a
if h <= a:
    rad = math.atan2(b, h)
    print(math.degrees(rad))
else:
    emp_h = (a*a*b - x)*2 / a / a
    rad = math.atan2(a, emp_h)
    print(90 - math.degrees(rad))


Measured memory_bytes: 2940
#include <iostream>
#include <bits/stdtr1c++.h>
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
using namespace std;
typedef long long ll;
const int N = 100005;
const int MOD = 1000000007;
int mi(int a,int b){
    if(a<b) return a;
    return b;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    int h[n+1];
    for(int i=1;i<=n;i++){
        cin >> h[i];
    }
    int minu[n];
    minu[1]=0;
    minu[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        minu[i]=mi(minu[i-1]+abs(h[i]-h[i-1]),minu[i-2]+abs(h[i]-h[i-2]));
    }
    cout << minu[n];


    
    return 0;
}


Measured memory_bytes: 4424
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {
		    Scanner sc = new Scanner(System.in);

		    int a = sc.nextInt();
		    int b = sc.nextInt();
		    if(a + b >= 10) {
		    	System.out.println("error");
		    }
		    else {
		    	System.out.println(a+b);
		    }
		    
		    sc.close(); }
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#include<ctype.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
//#define MAX(a,b) a>b?a:b
//#define MIN(a,b) a<b?a:b

int main() {
	int n, p,b;
	for (; ~fscanf(stdin, "%d%d", &n, &p), n, p; P(d, b)) {
		b = 0;
		int a[50] = {},
			c = p;
		while (1) {
			b %= n;
			if (c == 0) c = a[b], a[b] = 0;
			else c--, a[b]++;
			if (a[b] == p)break;
			b++;
		}
	}
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;


int main(){
	int x;
	std::cin >> x;
	if(x<1200)std::cout << "ABC" << std::endl;
	else std::cout << "ARC" << std::endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ll)(1e9)+7)

vector<ll> v(3*(ll)(1e5),0);
vector<ll> v_inv(3*(ll)(1e5),0);

ll pmod(ll n, ll p){
	ll m=n%mod;
	if(p==0) return 1;
	ll ans=pmod((m*m)%mod, p/2)%mod;
	if(p%2==1) ans=ans*m%mod;
	return ans;
}

void factorial(ll n){
	v[0]=1;
	for(ll i=1; i<=n; i++){
		v[i]=v[i-1]*i%mod;
	}
	return;
}

void factorial_inv(ll n){
	for(ll i=0; i<=n; i++){
		v_inv[i]=pmod(v[i],mod-2);
	}
}

ll binom(ll n, ll k){
	if(n<k) return 0;
	ll tmp=v_inv[k]*v_inv[n-k]%mod;
	return v[n]*tmp%mod;
}

ll fcn(int n, int m){
	ll t=n*n%mod;
	return t*binom(m+1,3)%mod;
}

int main(){
	int n, m, k;
	cin >> n >> m >> k;
	factorial(200002);
	factorial_inv(200002);

	ll t=(fcn(n,m)+fcn(m,n))%mod;
	t=t*binom(n*m-2, k-2)%mod;
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define endl '\n'
#define int long long

using namespace std;

int32_t main ()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	
	int n;
	cin>>n;
	int AC=0;
	int WA=0;
	int TLE=0;
	int RE=0;
	
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		if(s=="AC")AC++;
		else if(s=="WA")WA++;
		else if(s=="TLE")TLE++;
		else if(s=="RE")RE++;
	}
	
	cout<<"AC x "<<AC<<endl;
	cout<<"WA x "<<WA<<endl;
	cout<<"TLE x "<<TLE<<endl;
	cout<<"RE x "<<RE<<endl;
	
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <stdlib.h>

using namespace std;

int main(void)
{
  int N;
  int t[100001]={0};
  int x[100001]={0};
  int y[100001]={0};
  bool flag = false;
  
  cin >> N;
  for(int i = 1; i <= N; i++)
    cin >> t[i] >> x[i] >> y[i];

  for(int i = 1; i <= N; i++){
    int tt = t[i] - t[i - 1];
    int tx = abs(x[i] - x[i - 1]);
    int ty = abs(y[i] - y[i - 1]);
    int diff = tt-(tx+ty);
    
    if(diff < 0 || (abs(diff) % 2 == 1)){
      flag = true;
      break;
    }
  }

  cout << (flag ? "No" : "Yes") << endl;
    
  return 0;
}


Measured memory_bytes: 1408
def solve_knapsack(s, n, v, w):
	dp = [[0 for x in range(s+1)] for x in range(n+1)]	
	for i in range(n):
		for j in range(1, s+1):
			if w[i] > j:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = max(dp[i][j], max(dp[i+1][j-w[i]]+v[i], dp[i][j-w[i]]+v[i]))
	return dp[n][s]
	
n, s = map(int, input().split())
v = [0]*n
w = [0]*n
for i in range(n):
	v[i], w[i] = map(int, input().split())
print(solve_knapsack(s, n, v, w))



Measured memory_bytes: 16124
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-03-28 22:12:25
**/

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

using namespace std;

using int64 = long long;

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

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

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

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

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

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

  int k; cin >> k;
  int n; cin >> n;
  vector<int> a(n); cin >> a;

  int mx = a[0] + (k - a[n - 1]);

  for (int i = 0; i < n - 1; ++i) {
    mx = max(mx, a[i + 1] - a[i]);
  }

  cout << k - mx << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int W, H, N; cin >> W >> H >> N;
  int X1 = 0, X2 = W, Y1 = 0, Y2 = H;
  REP(i, N){
    int x, y, a; cin >> x >> y >> a;
    if(a == 1){
      X1 = max(X1, x);
    }else if(a == 2){
      X2 = min(X2, x);
    }else if(a == 3){
      Y1 = max(Y1, y);
    }else if(a == 4){
      Y2 = min(Y2, y);
    }
  }
  int ans = 0;
  if(X2-X1 >= 0 && Y2-Y1 >= 0){
    ans = (X2-X1)*(Y2-Y1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
using namespace std;

int main() {
  string s, t, chk;
  cin >> s >> t;
  int len_s = s.size();
  int len_t = t.size();

  int tmp, ans = 1000;
  rep(i, 0, len_s - len_t + 1) {

    chk = s.substr(i, len_t);
    tmp = 0;
    rep(j, 0, len_t) {
      if (chk[j] != t[j]) {
        tmp++;
      }
    }
    ans = min(ans, tmp);
  }

  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 3612
#標準入力を取得
input_n = gets.to_i
input_array = gets.split(" ").map(&:to_i)
 
#辺の長さの配列を昇順にソート
input_array = input_array.sort!
 
#最大長さの辺以外の合計を格納する変数を初期化
amountLength = 0
 
#0以上n-1未満を繰り返し
(0...input_n-1).each do |i|
  #最大長さ以外の辺の長さを加算
  amountLength += input_array[i]
end
 
#最大長さ < その他の辺の長さ　を判定
if input_array[input_n-1] < amountLength
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14256
import sys
sys.setrecursionlimit(1000000)

n = int(input())
tree= [[] for i in range(n)]

for i in range(n-1):
  a,b,c = map(int,input().split())
  a = a-1
  b = b-1
  tree[a].append([b,c])
  tree[b].append([a,c])
 
q,k = map(int, input().split())
k = k-1

depth=[0]*n
visited=[False for i in range(n)]
def dfs(start,kyori):
  depth[start] = kyori
  visited[start]=True
  
  for to in tree[start]:
    if not visited[to[0]]:
      dfs(to[0],kyori+to[1])
  return

dfs(k,0)

for i in range(q):
  start,goal =  map(int, input().split())
  print(depth[start-1]+depth[goal-1])

Measured memory_bytes: 138784
from collections import deque


H, W = map(int, input().split())
Ch, Cw = map(lambda x: int(x) - 1, input().split())
Dh, Dw = map(lambda x: int(x) - 1, input().split())
maze = [input() for _ in range(H)]

INF = 10 ** 12
path = [[INF] * W for _ in range(H)]  # path: 各マスへの移動コスト

# walk:移動A, warp:移動B
walk = [(0, 1), (0, -1), (-1, 0), (1, 0)]
warp = [(i, j) for i in range(-2, 3) for j in range(-2, 3) if (i, j) not in [(0, 0)] + walk]

q = deque()
path[Ch][Cw] = 0
q.append((Ch, Cw, 0))

while q:
    x, y, s = q.popleft()
    for dx, dy in walk:  # 移動A
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s:
            path[nx][ny] = s
            q.appendleft((nx, ny, s))  # 移動Aの場合はコスト0. キューの先頭に追加する.
    for dx, dy in warp:  # 移動B
        nx = x + dx
        ny = y + dy
        if 0 <= nx < H and 0 <= ny < W and maze[nx][ny] == '.' and path[nx][ny] > s + 1:
            path[nx][ny] = s + 1
            q.append((nx, ny, s + 1))  # 移動Bの場合はコスト1. キューの最後尾に追加する.
    
ans = path[Dh][Dw] if path[Dh][Dw] < INF else '-1'
print(ans)

Measured memory_bytes: 94196
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <stack>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, f, t) for(int i=(int)(f); i<(int)(t); i++)
#define RFOR(i, f, t) for(int i=(int)(f); i>(int)(t); i--)
using namespace std;
using ll = long long;
#define MOD 1000000007
#define MOD2 998244353
constexpr int INFINT = (1 << 30) - 1;       // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1; // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;             // 1.15x10^18
typedef pair<ll, ll> P;
template<class T> inline T chmax(T& a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

/*ナップサック*/
/*制約w小さい、価値v大きい*/
/*dp[v] vの価値を達成できる最小の重さ*/

/*def*/
ll dp[101000];
ll n, w;
ll wi, vi;

int main() {
/*input*/
    cin >> n >> w;

    dp[0] = 0;
    FOR(i, 1, 100001)dp[i] = INFLL;

/*maindp*/
    int ret = 0;
    FOR(i, 0, n){
        cin >> wi >> vi;
        RFOR(j, 100000, 0){
            if (j-vi >= 0){
                chmin(dp[j], dp[j-vi] + wi);
                if (dp[j] <=w) chmax(ret, j);
            }
        }
    }

/*output*/
    cout << ret << endl;
    return 0;
}


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

int p=0,nr=0,nl=0;
int a[10]={};
vector<int> r,l;

int f(int nr,int nl,int p){
	//cout<<"a[p]="<<a[p]<<" nr="<<nr<<" nl="<<nl<<" p="<<p<<endl;;
	if(a[p]>nr){
		r.push_back(a[p]);
		nr=a[p];
		if(p==9){
			return 1;
		}
		p++;
		if(f(nr,nl,p)==1){
			return 1;
		}
		else if(f(nr,nl,p)==-1){
			if(nr>nl){
				p--;
				r.pop_back();
			}
			else if(nl>nr){
				p--;
				l.pop_back();
			}
		}
	}
	if(a[p]>nl){
		l.push_back(a[p]);
		nl=a[p];
		if(p==9){
			return 1;
		}
		p++;
		if(f(nr,nl,p)==1){
			return 1;
		}
	}
	return -1;
	}

int main(){
	int i,j,n;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<10;j++){
			cin>>a[j];
		}
		p=0;
		if(f(nr,nl,p)==1){
			cout<<"YES"<<endl;
		}
		else{
			cout<<"NO"<<endl;
		}
	}
return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

struct Mod {
    static constexpr auto kMod = 1000000007L;

    Mod() : n(0) {}
    // can be implicitly converted
    Mod(int64_t n) : n(n) {}

    Mod operator*(Mod m) const { return (n * (m.n % kMod)) % kMod; }

    Mod& operator*=(Mod m) {
        *this = *this * m;
        return *this;
    }

    Mod pow(int64_t p) {
        if (p == 0) {
            return 1;
        }
        if (p == 1) {
            return n;
        }

        int64_t r = this->pow(p / 2).n;
        if (p % 2 == 0) {
            return r * r % kMod;
        } else {
            return (r * r % kMod) * n % kMod;
        }
    }

    Mod operator/(Mod m) const {
        if (n == 0) {
            return 0;
        }

        return *this * m.pow(kMod - 2);
    }

    Mod& operator/=(Mod m) {
        *this = *this / m;
        return *this;
    }

    Mod operator+(Mod m) const { return (n + m.n) % kMod; }

    Mod& operator+=(Mod m) {
        *this = *this + m;
        return *this;
    }

    Mod operator-(Mod m) const { return (kMod + n - m.n) % kMod; }

    Mod& operator-=(Mod m) {
        *this = *this - m;
        return *this;
    }

    int64_t n;
};

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

    vector<int64_t> x(n);
    for (auto&& xx : x) {
        cin >> xx;
    }

    Mod ans;

    Mod c;
    for (auto i : irange(1L, n - 1)) {
        c += Mod(1) / (i + 1) / i;
        ans += c * x[i];
        ans -= c * x[n - i - 2];
    }

    for (auto i : irange(0L, n - 1)) {
        ans += Mod(x[n - 1] - x[i]) / (n - i - 1);
    }

    for (auto i : irange(2L, n)) {
        ans *= i;
    }

    cout << ans.n << endl;
}

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

using namespace std;

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

  int n,k,m;
  while(cin>>n>>k>>m,n|k|m){
    std::vector<int> v;
    for(int i=1;i<=n;i++) v.push_back(i);
    int pos=m-1;
    while(v.size()>1){
      v.erase(v.begin()+pos);
      pos=(pos+k-1)%v.size();
    }
    cout << v[0]<<endl;
  }
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)

#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const ll mod = 1e9 + 7;
const ll infl = 1e17;


int main()
{
    ll n;
    cin >> n;
    ll s = 0;
    vll a(n);
    rep(i, n){ cin >> a[i];
        s += a[i];
    }
    ll bunbo = (n + 1) * n / 2;
    if (s%bunbo!=0){
        cout << "NO" << endl;
        return 0;
    }
    ll xs = s / bunbo;
    vll x(n);
    if ((xs+a[n-1]-a[0]<0) || ((xs+a[n-1]-a[0])%n!=0)){

        cout << "NO" << endl;
        return 0;
    }
    else
        x[0] = (xs + a[n - 1] - a[0]) / n;
    rep(i,n-1){

        if ((xs + a[i] - a[i+1] < 0) || ((xs + a[i] - a[i+1]) % n != 0))
        {

            cout << "NO" << endl;
            return 0;
        }
        else
            x[0] = (xs + a[i] - a[i+1]) / n;
    }
    cout << "YES" << endl;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string s ;
	cin >> s ;
	int n = s.size();
	string t = "" ;
	rep(i,n){
		if(s[i] != 'B'){
			t.push_back(s[i]);
		}else{
			if(t.size()>0){
				t.pop_back();
			}
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // [b,c) イテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int64_t N, M; cin >> N >> M;

if (M >= 2 * N)
    cout  << N + (M - N * 2) / 4 << endl;
else 
    cout << M / 2 << endl;

}
// 書いて考える
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 256
// 解き直し.
// https://img.atcoder.jp/abc163/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define a first
#define b second
#define all(x) x.begin(), x.end()
LL dp[2020][2020];
vector<P> v; // joy, index.

int main(){
    
    // 1. 入力情報.
    int N;
    scanf("%d", &N);
    rep(i, N){
        LL a;
        scanf("%lld", &a);
        v.pb({a, i + 1});
    }
    
    // 2. sort.
    sort(all(v), greater<P>());
    
    // 3. 解説通り.
    // (x + y)人 を 昇順にチェックしていくとのこと.
    repx(xy, 1, N + 1){
        // A[i] * (i - p[i]) を 選択: x人
        // A[i] * (p[i] - i) を 選択: y人
        rep(x, xy + 1){
            // 3-1. x人, y人 を 設定.
            int y = xy - x;
            LL hx = 0, hy = 0;
            
            // 3-2. (x - 1)人 と y人 から (x + y)人 になる場合.
            if(x > 0) hx = dp[x - 1][y] + v[xy - 1].a * (LL)(v[xy - 1].b - x);
            
            // 3-3. x人 と (y - 1)人 から (x + y)人 になる場合.
            if(y > 0) hy = dp[x][y - 1] + v[xy - 1].a * (LL)(N + 1 - y - v[xy - 1].b);
            
            // 3-4. dp更新.
            dp[x][y] = max(hx, hy);
        }
    }
    
    // 4. 最大値.
    LL ans = 0;
    rep(i, N + 1) ans = max(ans, dp[i][N - i]);
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 26552
N = int(input())
C = list(map(int, input().split()))

MOD = 10 ** 9 + 7
C.sort()
ans = 0
for i in range(N):
    l = i
    r = N - i - 1
    now = pow(2, r, MOD)
    if r > 0:
        now += pow(2, r - 1, MOD) * r
    now *= pow(2, l, MOD)
    now *= C[i]
    ans += now
print(ans * pow(2, N, MOD) % MOD)


Measured memory_bytes: 87628
import sys
 
stdin = sys.stdin
 
ni = lambda: str(ns())
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

t1 = ni()
t1 = [t for t in t1]

result = "Yes"
for i, t in enumerate(t1) :
  if i % 2 == 0 :
    if t == "L" :
      result = "No"
      break
  else :
    if t == "R" :
      result = "No"
      break
print(result)

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using v = vector<T>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
void dumplist_debug(T list) {
#ifdef MY_DEBUG
    each(e, list) cout << e << " ";
    printf("\n");
#endif
}

inline ll inl() {
    ll x;
    cin >> x;
    return x;
}

inline string ins() {
    string x;
    cin >> x;
    return x;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

struct stx {
    ll s, t, x;

    stx(ll s, ll t, ll x) : s(s), t(t), x(x) {}
};

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif

        ll n = inl(), q = inl();
        v<stx> v;
        rep(i, n) {
            ll s, t, x;
            cin >> s >> t >> x;
            stx temp(s, t, x);
            v.eb(temp);
        }
        set<P> set1;
        rep(i, q) {
            ll d = inl();
            set1.insert(P(d, i));
        }
        sort(all(v), [](stx &a, stx &b) {
            if (a.x == b.x) {
                if (a.s == b.s) return a.t < b.t;
                return a.s < b.s;
            }
            return a.x < b.x;
        });

        vl ans(q, -1);
        rep(i, n) {
            ll s = v[i].s, x = v[i].x, t = v[i].t;
            auto it = set1.lower_bound(P(s - x, -1));
            while (it != set1.end()) {
                if (t - x <= it->F) break;
                ans[it->S] = x;
                set1.erase(it++);
            }
        }
        rep(i, q) cout << ans[i] << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 21228
N = int(input())
U = list(map(int, input().split()))
L = list(map(int, input().split()))

sumU = [U[0]]
for i in range(1, N):
    sumU.append(sumU[-1] + U[i])
sumL = [L[N - 1]]
for i in range(N - 2, -1, -1):
    sumL.insert(0, sumL[0] + L[i])

print(max([sumU[i] + sumL[i] for i in range(N)]))


Measured memory_bytes: 3064
# 素因数分解
# O(N**0.5)
def p_bunkai(N):
    ret = []
    for i in range(2, int(N ** 0.5) + 1):
        if N % i == 0:
            count = 0
            while N % i == 0:
                N //= i
                count += 1
            ret.append((i, count))
    if N != 1:
        ret.append((N, 1))
    return ret

N = int(input())

ans = 0
for _, i in p_bunkai(N):
    j = 1
    while True:
        if i >= j:
            ans += 1
            i -= j
            j += 1
        else:
            break
print(ans)
        

Measured memory_bytes: 9456
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

V<bool> seen; //検知済みかどうか
V<int> color(100010,-1);

struct edge {
    int to;
    int cost;
};

int dfs(const VVI &G,const VVI &E,int v){
    seen[v]=true;
    for(int i=0;i<G[v].size();i++){
        if(seen[G[v][i]])continue;
        if(E[v][i]%2==0)color[G[v][i]]=color[v];
        else if(color[v]==1)color[G[v][i]]=0;
        else color[G[v][i]]=1;
        dfs(G,E,G[v][i]);
    }
}

int main(void){
    int N,M; //N:頂点,M:辺数
    cin>>N;
    VVI G(N);
    VVI E(N);
    for(int i=0;i<N-1;i++){
        int a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);  //無向なのでお互いに行き先として追加
        E[a].push_back(c);
        E[b].push_back(c);
    }
    color[0]=0;
    seen.assign(N,false); //すべての頂点を初期化
    dfs(G,E,0);
    REP(i,N)cout<<color[i]<<endl;
}

Measured memory_bytes: 14080
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>
//#include <boost/multiprecision/cpp_int.hpp>

//namespace mp = boost::multiprecision;
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
//using Bint = mp::cpp_int;

vector<int>A;
vector<int>res;

int main()
{
	int N;
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int b;
		cin>>b;
		A.push_back(b);
	}
	reverse(A.begin(),A.end());
	for(int i=0;i<N;i++)
	{
		vector<int>nA;
		bool f=false;
		for(int i=0;i<A.size();i++)
		{
			if(!f&&A[i]==A.size()-i)
			{
				f=true;
				res.push_back(A[i]);
			}
			else
			{
				nA.push_back(A[i]);
			}
		}
		if(!f)
		{
			cout<<-1<<endl;
			return 0;
		}
		A=nA;
	}
	reverse(res.begin(),res.end());
	for(auto i:res)cout<<i<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    if(n%2==0)
    {
        cout<<(n/2-1)<<endl;
    }
    else
        cout<<(n/2)<<endl;
    return 0;
}


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

int main() {
  int n, y, ansa, ansb, ansc;
  bool flg = false;
  cin >> n >> y;
  y /= 1000;
  for (int m=0; m <= n; m++) {
    for (int a=0; a <= m; a++) {
      flg = (5 * a + 4 * m == y - n ? true : false);
      if (flg) {
        ansa = a; ansb = m - a; ansc = n - m;
        printf("%d %d %d",ansa, ansb, ansc);
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = list(input())
r = s.count('R')
g = s.count('G')
b = s.count('B')
cnt = r*g*b
for i in range((len(s)-1)//2):
    for j in range(i+1,len(s)-i-1):
        if s[j-(i+1)] != s[j] and s[j] != s[j+(i+1)] and s[j-(i+1)] != s[j+(i+1)]:
            cnt-=1
print(cnt)

Measured memory_bytes: 68308
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;

public final class Main {

    public static void main(String[] args) {
        final FastScanner fs = new FastScanner();
        final int n = fs.nextInt();
        final int m = fs.nextInt();
        final int mines = fs.nextInt();
        final int[] rows = new int[n + 1];
        final int[] cols = new int[m + 1];
        final List<int[]> bombs = new ArrayList<>();
        final Set<String> seen = new HashSet<>();
        int maxR = 0;
        int maxC = 0;
        for (int i = 0; i < mines; i++) {
            final int x = fs.nextInt();
            final int y = fs.nextInt();
            maxR = Math.max(maxR, ++rows[x]);
            maxC = Math.max(maxC, ++cols[y]);
            bombs.add(new int[] { x, y });
            seen.add(x + "," + y);
        }
        int res = 0;
//        for (int[] bomb : bombs) {
//            res = Math.max(res, rows[bomb[0]] + cols[bomb[1]] - 1);
//        }
        for (int row = 1; row <= n; row++) {
            if (rows[row] == maxR) {
                for (int col = 1; col <= m; col++) {
                    res = Math.max(res, maxR + cols[col] - (seen.contains(row + "," + col) ? 1 : 0));
                }
                break;
            }
        }
        for (int col = 1; col <= m; col++) {
            if (cols[col] == maxC) {
                for (int row = 1; row <= n; row++) {
                    res = Math.max(res, maxC + rows[row] - (seen.contains(row + "," + col) ? 1 : 0));
                }
                break;
            }
        }
        System.out.println(res);
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    //noinspection CallToPrintStackTrace
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        int[] readArray(int n) {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++) { a[i] = nextInt(); }
            return a;
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

int main() {
  int N, K;
  cin >> N;
  cin >> K;
  
  int count = 0;
  
  for(int i=0; i<N; i++)
  {
    int x;
    cin >> x;
    int d = abs(x-K);
//    cout << d << endl;
    if(x<d)
    {
      count += x * 2;
    }else{
      count += d * 2;
    }
  }
  
  cout << count << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

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

    bool primesearch[55600]={};
    for (int i = 2; i <= 55555;i++){
        primesearch[i] = true;
    }
    std::vector<int> prime;
    for (int top = 2; top < 236;top++){
        while(1){
            if(primesearch[top]==true)
                break;
            else
                top++;
        }
        primesearch[top] = false;
        prime.push_back(top);
        for (int i = 2; i * top <= 55555; i++)
        {
            primesearch[i * top] = false;
        }
    }
    for (int i = 2; i <= 55555;i++){
        if(primesearch[i]==true){
            prime.push_back(i);
        }
    }
    std::sort(prime.begin(), prime.end());

    int point = 0;
    for (int count = 0; count < N;point++)
    {
        if(prime[point]%10==1){
            cout << prime[point];
            if (count < N - 1)
            {
                cout << " ";
            }
            else
            {
                cout << endl;
            }
            count++;
        }
    }

    return 0;
}


Measured memory_bytes: 384
import numpy as np

N = int(input())
S = input()
left_W = 0
right_E = S.count("E")
ans = N

for i in range(N):
    if S[i] == "W":
        ans = min(ans, left_W+right_E)
        left_W += 1
    else:
        right_E -= 1
        ans = min(ans, left_W+right_E)

print(ans)



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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

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

int n,a[300000];

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

	cin>>n;
	REP(i,n*3) cin>>a[i];
	sort(a,a+3*n);
	ll sum=0;
	for(int i=n;i<3*n;i+=2) sum+=a[i];
	cout<<sum<<endl;

	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void){
  int H, W, h, w;
  int siro;
  int kuro;
  int daburi;
  int num;
  
  scanf("%d %d %d %d", &H, &W, &h, &w);
  
  siro = H * W;
  kuro = (h * W) + (w * H);
  daburi = h * w;
  
  num = siro - (kuro - daburi);
  printf("%d\n", num);
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
long long a[2000010];
long long n;
long long k;
long long s[2000010];
long long m=0;
long long ne[3000000];
long long p[3000000];
void solve(long long id) {
    //cout<<id<<endl;
    while(id<n && p[id]<=id) {
        printf("%lld ",a[id]);
        id++;
    }
    if(id==n || p[id]+1==n) return;
    solve(p[id]+1);
}
int main() {
    scanf("%lld %lld",&n,&k);
    for(long long i=0;i<n;i++) scanf("%lld",&a[i]);
    for(long long i=n-1;i>=0;i--) {
        ne[a[i]]=i;
    }
    for(long long i=n-1;i>=0;i--) {
        p[i]=ne[a[i]];
        ne[a[i]]=i;
        //cout<<i<<" "<<p[i]<<endl;
    }
    long long it=0;
    long long cur=0;
    while(cur+1<k && (it!=0 || cur==0)) {
        //cout<<it<<" "<<cur<<endl;
        if(p[it]<=it) cur++;
        if(p[it]+1==n) cur++;
        it=p[it]+1;
        if(it==n) it=0;
    }
    if(cur+1==k) {
        solve(it);
    }
    else {
        k=k%((long long)cur);
        it=0;
        cur=0;
        if(k==0) return 0;
        while(cur+1<k) {
            if(p[it]<=it || p[it]+1==n) cur++;
            it=p[it]+1;
            if(it==n) it=0;
        }
        solve(it);
    }
    return 0;
}


Measured memory_bytes: 11264
#include<stdio.h>
int main()
{
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
	{
		printf("0\n");
		return 0;
	}
	if (a == b && b == c)
	{
		printf("-1\n");
		return 0;
	}
	int ans = 0;
	int p, q, r;
	for (;;)
	{
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
			break;
		ans++;
		p = (a + b) / 2;
		q = (b + c) / 2;
		r = (c + a) / 2;
		a = p;
		b = q;
		c = r;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int h, w, d;
int a[310][310];
map<int, P> mp;
int u[90010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> d;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> a[i][j];
            a[i][j]--;
            mp[a[i][j]] = P{i, j};
        }
    }
    rep(i, 0, h * w){
        int next = i + d;
        if(next >= h * w) continue;
        u[next] = u[i] + abs(mp[i].first - mp[next].first) + abs(mp[i].second - mp[next].second);
    }
    int q;
    cin >> q;
    rep(i, 0, q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << u[r] - u[l] << endl;
    }
}

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

int cal(int ar[]){
	int f = 0;
	for(int i = 0;i < 6; i++){    	
    	if (ar[i] == 1){
      		f = 1;
      		break;
        }
    }
	return f;
}

int main(){
	int x;cin>>x;
  	int* dp = new int[x];
    for(int i = 99;i < 105; i++)
    	dp[i] = 1;
  	for(int i = 105;i < x; i++){
      	int arr[6];
      	for(int j=0;j<6;j++)
          arr[j] = dp[i-100-j];
    	dp[i] = cal(arr);
    }
  	cout<<dp[x-1];
	return 0;
}


       
        


Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll A[2][N];
    rep(i, N * 2){
        cin >> A[i / N][i % N];
    }

    ll sum[2][N];
    sum[0][0] = A[0][0];
    sum[1][0] = sum[0][0] + A[1][0];
    REP(i, N - 1){
        sum[0][i] = sum[0][i - 1] + A[0][i];
        sum[1][i] = max(sum[0][i], sum[1][i - 1]) + A[1][i];
    }

    cout << sum[1][N - 1] << endl;
    
    return 0;
}

Measured memory_bytes: 3608
fun main(arr:Array<String>) {
    val (n,m,c) = readLine()!!.split(" ").map { it.toInt() }
    val bList = readLine()!!.split(" ").map { it.toInt() }
    val aList = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
    val ans = aList.map { list->list.indices.map { bList[it] * list[it] }.sum() + c > 0 }.filter { it }
    println(ans.size)
}

Measured memory_bytes: 37932
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
using namespace std;
int main(void)
{
  string s;
  cin >> s;
  cout << (s.find("AC")==string::npos?"No":"Yes") << endl;
  return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N;
std::string S;
int cnt[26];

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

    std::cin >> N >> S;

    ll c = 0;

    for(int i=0;i<N;++i){
        ll v = 1;
        for(int j=0;j<26;++j){
            if(j == S[i] - 'a'){
                continue;
            }

            v = v * (cnt[j] + 1) % MOD;
        }

        c = (c + v) % MOD;

        cnt[S[i] - 'a'] += 1;
    }

    std::cout << c << std::endl;
}


Measured memory_bytes: 512
def solve(n):
    ans = int(1e12)
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0 and i + n // i - 2 < ans:
            ans = i + n // i - 2
    return int(ans)


num = int(input())
print(solve(num))


Measured memory_bytes: 2940