akhauriyash/Code-Regression huggingface dataset:
import sys
import time

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(input())
    s = list(map(int, readline().split()))
    ans = 0

    for c in range(1, n):
        dp = 0
        visited = set()
        for k in range(1, (n - 1) // c):
            forward = k * c
            backward = n - 1 - k * c
            if forward == backward:
                break
            if (forward or backward) in visited:
                break
            visited.add(forward)
            visited.add(backward)
            dp = dp + s[n - 1 - k * c] + s[k * c]
            ans = max(ans, dp)

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

void doc() {
}

void solve() {
    long long K,A,B;
    cin >> K >> A >> B;
    if (B <= A) {
        cout << K + 1;
        return;
    }
    if (K <= A) {
        cout << K + 1;
        return;
    }
    long long TMP = K + 1;
    K -= A + 1;
    //cout << K << '\n';
    long long Thua = K % 2;
    long long SL = K / 2;
    long long Res = B + 1LL * SL * (B - A) + Thua;
    cout << max(TMP,Res);
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    doc();
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int N,M;
int num[20] = {};
int wa[20][100001] = {};

int dp[1048576]; //=10^6
int solve(int state){
    if(dp[state] != -1) return dp[state];

    int sum = 0;
    for(int i=0; i<M; i++){
        if((state >> i)%2 == 1){
            sum += num[i];
        }
    }

    int re = INT_MAX;
    for(int i=0; i<M; i++){
        if((state >> i)%2 == 0){
            re = min(re, num[i] - (wa[i][sum+num[i]] - wa[i][sum]) + solve(state + (1 << i)));
        }
    }
    return dp[state] = re;
}

int main(){
    
    cin >> N >> M;
    int A[100000];
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i]--;
        num[A[i]]++;

        for(int j=0; j<M; j++){
            wa[j][i+1] = wa[j][i];
        }
        wa[A[i]][i+1] += 1;
    }

    for(int i=0; i<(1 << M); i++){
        dp[i] = -1;
    }
    dp[(1 << M) - 1] = 0;

    cout << solve(0) << endl;
    
    return 0;
}


Measured memory_bytes: 15388
import java.util.*;

public class Main {
    	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String str;
		str = sc.next();
		
		boolean E=false, W=false, N=false, S=false;
		for(int i=0; i<str.length(); i++){
			if(str.charAt(i)=='E') E=true;
			else if(str.charAt(i)=='W') W=true;
			else if(str.charAt(i)=='N') N=true;
			else if(str.charAt(i)=='S') S=true;
		}
		
		if(E!=W || N!=S){
			System.out.println("No");
		}
		else{
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 22100
#include <cstdio>
typedef long long ll;

const int N = 203, mod = 998244353;

struct pnt {
	int x, y;
	inline void in() {scanf("%d%d", &x, &y);}
	friend inline pnt operator - (const pnt&A, const pnt&B) {return (pnt) {A.x - B.x, A.y - B.y};}
	friend inline int operator * (const pnt&A, const pnt&B) {return A.x * B.y - A.y * B.x;}
} p[N];

inline bool con(const pnt&A, const pnt&B, const pnt&C) {
	return (C - A) * (B - A) == 0;
}

int n;
int bin[N];
bool vs[N];
ll Ans;

int main() {
	scanf("%d", &n);
	for(int i=bin[0]=1;i<=n;++i) bin[i] = (bin[i-1] << 1)%mod;
	for(int i=1;i<=n;++i) p[i].in();
	for(int i=1;i<n;++i) {
		for(int j=1;j<=n;++j) vs[j] = false;
		
		for(int j=i+1;j<=n;++j)
			if(!vs[j]) {
				int ct = 2;
				for(int k=j+1;k<=n;++k)
					if(con(p[i], p[j], p[k])) vs[k] = true, ++ct;
				
				bool flg = true;
				for(int k=1;k<i and flg;++k)
					if(con(p[i], p[j], p[k])) flg = false;
				if(flg) Ans += bin[ct] - ct - 1;
			}
	}
	Ans = ((ll)mod*mod - Ans - n - 1 + bin[n])%mod;
	printf("%lld\n", Ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>

class Solver {
public:
    void solve();
};


void Solver::solve() {
    // 入力
	int a, b;
	std::cin >> a >> b;
	int res[4];
	res[0] = a;
	res[1] = a - 1;
	res[2] = b;
	res[3] = b - 1;
	std::sort(res, res + 4, std::greater<int>());

	int ans = res[0] + res[1];
	std::cout << ans << std::endl;
}

int main() {
    Solver solver = Solver();
    solver.solve();
    return 0;
}

Measured memory_bytes: 256
n,c = map(int,input().split())
L = [[] for i in range(c)]
for i in range(n):
    s,t,k = map(int,input().split())
    L[k-1].append([s,t])
for i in range(c):
    L[i].sort()
for i in range(c):
    d = [0]*(10**5+1)
    T = []
    for j in range(len(L[i])):
        d[L[i][j][0]] += 1
        d[L[i][j][1]] -= 1
    for j in range(10**5):
        d[j+1] += d[j]
    cur = 0
    start = 0
    end = 0
    for j in range(10**5+1):
        if d[j] == 1 and cur == 0:
            start = j
            cur = 1
        elif d[j] == 0 and cur == 1:
            end = j
            cur = 0
            T.append([start*2-1, end*2])
    L[i] = T
dp = [0]*(10**5)*3
ans = 0
for i in range(c):
    for j in range(len(L[i])):
        dp[L[i][j][0]] += 1
        dp[L[i][j][1]] -= 1
for j in range(1,(10**5)*3):
    dp[j] = dp[j-1]+dp[j]
    ans = max(ans, dp[j])
print(ans)


Measured memory_bytes: 84824
H, W, K = map(int, input().split())
mod = 10**9 + 7

dp = [0]*W
dp[0] = 1

OK = [0, 1, 1, 2, 3, 5, 8, 13]
NG = [0, 1, 2, 3, 5, 8, 13, 21]

if W == 1:
  print(dp[K-1])
else:
  for _ in range(H):
    temp = dp[:]
    for i in range(W):
      if i == 0:
        dp[i] = temp[i] * NG[W-1-i] + temp[i+1] * OK[W-1-i]
      elif i == W-1:
        dp[i] = temp[i-1] * OK[i] + temp[i] * NG[i]
      else:  
        dp[i] = temp[i-1] * OK[i] * NG[W-1-i] + temp[i] * NG[i] * NG[W-1-i] + temp[i+1] * NG[i] * OK[W-1-i]
      dp[i] %= mod
  print(dp[K-1])

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

 using namespace std;

 int main() {
   int N, i, Alice, Bob;

   cin >> N;

   vector<int> a(N);

   for (i = 0; i < N; i++) cin >> a.at(i);

   sort(a.begin(), a.end());
   reverse(a.begin(), a.end());

   Alice = 0;
   Bob = 0;

   for (i = 0; i < N / 2; i++) {
     Alice += a.at(2 * i);
     Bob += a.at(2 * i + 1);
   }

   if (N % 2 == 1) Alice += a.at(N - 1);

   cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
n = int(input())
T, A = map(float, input().split())
h = list(map(float, input().split()))
ans = 1

temp = abs(T-h[0]*0.006-A)
tempmin = temp
for i in range(1,n):
    temp = abs(T-h[i]*0.006-A)
    if(temp<tempmin):
        ans = i+1
        tempmin = temp
print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]==',') cout<<" ";
		else cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int kosu=sc.nextInt();
		String a="";

		int[][] chars=new int[kosu+1][26];

		for(int i=0; i<=kosu; i++) {
			for(int j=0; j<26; j++) {
				chars[i][j]=0;
			}
		}

		for(int i=0; i<kosu; i++) {
			a=sc.next();
			for(int j=0; j<a.length(); j++) {
				chars[i][a.charAt(j)*1-97]++;
			}
		}

		String b="";

		for(int i=0; i<26; i++) {
			int tmp=114514810;
			for(int j=0; j<kosu; j++) {
				tmp=Math.min(tmp,chars[j][i] );
			}
			chars[kosu][i]=tmp;
			if(chars[kosu][i]>0) {
				char unko=(char) ('a'+i);
				for(int k=0; k<chars[kosu][i]; k++) {
					b=b+unko+"";
				}
			}
		}
		System.out.println(b);
	}
}

Measured memory_bytes: 24020
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int h, w, k;
	cin >> h >> w >> k;
	ll dp[h+1][w];
	memset( dp, 0, sizeof(dp) );
	dp[0][0] = 1;
	vector<int> amida;
	for( int i = 0; i < (1<<(w-1)); ++i ){
		bool flag = false;
		for( int j = 0; j < (w-2); ++j ){
			int adj = (1<<j) + (1<<(j+1));
			if( ( i & adj ) == adj ){
				flag = true;
				break;
			}
		}
		if( !flag ){
			amida.push_back(i);
		}
	}
	for( int i = 1; i <= h; ++i ){
		for( int a : amida ){
			for( int j = 0; j < w; ++j ){
				if( j > 0 && ( a & (1<<(j-1)) ) ){
					dp[i][j] += dp[i-1][j-1];
					dp[i][j] %= MOD;
				} else if ( j < w-1 && ( a & (1<<j) ) ){
					dp[i][j] += dp[i-1][j+1];
					dp[i][j] %= MOD;
				} else {
					dp[i][j] += dp[i-1][j];
				}
			}
		}
	}
	cout << dp[h][k-1] % MOD << endl;
	return 0;
}

Measured memory_bytes: 256
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;


int main() {
	int n; cin >> n;
	vector<p> r(n),b(n);
	rep(i, 0, n) cin >> r[i].first >> r[i].second;
	rep(i, 0, n) cin >> b[i].first >> b[i].second;
	sort(b.begin(), b.end());
	int ans = 0;
	vector<bool> pairing(n, false);
	rep(i, 0, n){
		int maxx = -1,ite=-1;
		rep(j, 0, n) {
			if (b[i].first > r[j].first && b[i].second > r[j].second && r[j].second > maxx && (!pairing[j])) {
				maxx = r[j].second;
				ite = j;
			}
		}
		if (ite >= 0) {
			ans++;
			pairing[ite] = true;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s=list(map(int,input().split()))
ans=[list(map(str,input().split())) for i in range(s[1])]
ac=[0]*s[0]
wa=[0]*s[0]
a=0
b=0
c=0
for i in range(s[1]):
  c=int(ans[i][0])-1
  if ac[c]==0:
    if ans[i][1]=='WA':
      wa[c]+=1
    else:
      a+=1
      b+=wa[c]
      ac[c]=1
print(a,b)

Measured memory_bytes: 33684
(defvar +rate+
  '((399 . "gray")
    (799 . "brown")
    (1199 . "green")
    (1599 . "cyan")
    (1999 . "blue")
    (2399 . "yellow")
    (2799 . "orange")
    (3199 . "red")))

(defun select-color (point)
  (loop for (rate . color) in +rate+
        when (<= point rate)
        return color))

(let ((n (read))
      (a (make-hash-table))
      (any 0))
  (dotimes (i n)
    (let ((color (select-color (read))))
      (if color
          (setf (gethash color a)
                (1+ (gethash color a 0)))
          (incf any))))
  (let* ((count (loop for key being each hash-key of a
                      using (hash-value value)
                      count (< 0 value)))
         (mini (max count 1))
         (maxi (+ count any)))
    (format t "~A ~A~%" mini maxi)))

Measured memory_bytes: 16612
#include <iostream>
using namespace std;
 
int A[100000], n;
 
int partiton(int p, int r){
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for ( j=p; j<r; j++){
    if(A[j] <= x){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i+1];
  A[i+1] = A[r];
  A[r] = t;
  return i+1;
}
 
int main() {
    ios::sync_with_stdio(false);
    int q;
    cin >> n;
    for(int i=0; i<n; i++){
      cin >> A[i];
    }
    q = partiton(0, n-1);
    for(int i=0; i<n; i++){
      if(i) cout << " ";
      if(i==q) cout << "[";
      cout << A[i];
      if(i==q) cout << "]";
    }
    cout << "\n";
 
}

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

int main(){
    string s;
    cin>>s;
    reverse(s.begin(),s.end());
    string a[4]={"dream","dreamer","erase","eraser"};
    for(int i=0;i<4;i++){
        reverse(a[i].begin(),a[i].end());
    }
    while(s.size()){
        if(s.substr(0,5)==a[0]||s.substr(0,5)==a[2]){
            s=s.substr(5);
        }
        else if(s.substr(0,7)==a[1]){
            s=s.substr(7);
        }
        else if(s.substr(0,6)==a[3]){
            s=s.substr(6);
        }
        else{
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>

using namespace std;

int mat[55][55]; // y x
int S[55];
int N,M,A,B,C,T;

void debug(int a[55][55]){
  int i,j;
  printf("debug----\n");
  for(i = 0;i < N;i++){
    for(j = 0 ;j < N;j++){
      printf("%d ",a[i][j]);
    }
    printf("\n");
  }
  printf("debug----\n");
}

void init(){
  memset(mat,0,sizeof(mat));
  memset(S,0,sizeof(S));
}

void make_mat(){
  int i,j,k;
  for(i = 0;i < N;i++){
    mat[i][i] = B;
  }
  for(i = 1;i < N;i++){
    mat[i][i-1] = A;
    mat[i-1][i] = C;
  }
  //debug(mat);
}

void mat_pow(){
  int i,j,k,t;
  int tmp[55][55];
  int ret[55][55];
  int ans[55][55];
  memset(tmp,0,sizeof(tmp));
  memset(ans,0,sizeof(tmp));
  memset(ret,0,sizeof(tmp));
  for(i = 0;i < N;i++){
    tmp[i][i] = 1;
    ans[i][i] = 1;
  }
  //debug(tmp);
  while(T){
    if( T & 1){
      for(i = 0;i < N;i++){
        for( j = 0; j < N;j++){
          ret[i][j] = ans[i][j];
          ans[i][j] = 0;
        }
      }
      for(i = 0;i < N;i++){
        for(j = 0;j < N;j++){
          for(k = 0;k < N;k++){
            ans[i][j] = (ans[i][j] + ret[i][k] * mat[k][j]) % M;
          }
        }
      }
    }

    for(i = 0;i < N;i++){
      for(j = 0;j < N;j++){
        tmp[i][j] = mat[i][j];
        ret[i][j] = tmp[i][j];
        tmp[i][j] = 0;
      }
    }

    for(i = 0;i < N;i++){
      for(j = 0;j < N;j++){
        for(k = 0;k < N;k++){
          tmp[i][j] = (tmp[i][j] + ret[i][k] * mat[k][j]) % M;
        }
      }
    }
    for(i = 0; i < N;i++){
      for(j = 0;j < N;j++){
        mat[i][j] = tmp[i][j];
      }
    }
    T >>= 1;
  }
  //debug(tmp);
  for(i = 0; i < N;i++){
    for(j = 0;j < N;j++){
      mat[i][j] = ans[i][j];
    }
  }
  //debug(mat);
}

void solve(){
  int i,j,k;
  int ret[55];
  for(i = 0;i < N;i++){
    ret[i] = S[i];
    S[i] = 0;
  }
  for(i = 0; i < N;i++){
    for( j = 0; j < N;j++){
      S[i] = (S[i] + mat[i][j] * ret[j]) % M;
    }
  }
  for(i = 0; i < N;i++){
    if(i == N-1) printf("%d\n",S[i]);
    else printf("%d ",S[i]);
  }
}

int main(){
  int i,j,k;
  scanf("%d %d %d %d %d %d",&N,&M,&A,&B,&C,&T);
  while( N|M|A|B|C|T ){
    init();
    for(i = 0;i < N;i++){
      scanf("%d",&S[i]);
    }
    make_mat();
    mat_pow();
    solve();
    scanf("%d %d %d %d %d %d",&N,&M,&A,&B,&C,&T);
  }
  return 0;
}


Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long A[3000];
long Pow(long R){
	if(R == 0){
		return 1;
	}
	if(R % 2 == 0){
		long t = Pow(R/2);
		return t*t % mod;
	}
	return 2 * Pow(R-1) % mod;
}
long State[3000*3000];
void Calc(){
	int N = rei();
	int Q = rei();
	for(int i=0;i<N;i++){
		A[i] = rel();
	}
	long TQ = Pow(Q);
	long HALF = Pow(mod-2);
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			if(i != j){
				if(A[i]<A[j]){
					State[i*3000+j] = TQ;
				}
			}
		}
	}
	for(int i=0;i<Q;i++){
		int X = rei()-1;
		int Y = rei()-1;
		for(int j=0;j<N;j++){
			if(j != X && j != Y){
				State[X*3000+j] = (State[X*3000+j]+State[Y*3000+j]) * HALF % mod;
				State[Y*3000+j] = State[X*3000+j];
				State[j*3000+X] = (State[j*3000+X]+State[j*3000+Y]) * HALF % mod;
				State[j*3000+Y] = State[j*3000+X];
			}
			State[X*3000+Y] = (State[X*3000+Y] + State[Y*3000+X]) * HALF % mod;
			State[Y*3000+X] = State[X*3000+Y];
		}
	}
	long count = 0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			count += State[j*3000+i];
		}
	}
	count %= mod;
	cout << count << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 70656
A,B,C,X,Y = map(int,input().split())
a = 0

if A+B < C*2:
    a += (A+B) * min(X,Y)
else:
    a += C*2 * min(X,Y)
if X > Y:
    a += min(A,C*2) * (X-Y)
else:
    a += min(B,C*2) * (Y-X)
print(a)

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

int main() {
    std::string S;
    std::cin >> S;

    if ((S[2] == S[3]) && (S[4] == S[5])) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n"; 
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],k=1,f;
int main(){
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i];
	for (int i=0;i<n;i++) if (a[i]==k) k++,f=1;
	if (f==0)
		cout<<-1<<endl;
	else
		cout<<n-k+1<<endl;
	return 0;
}

Measured memory_bytes: 1024
use std::io;


fn main() {
    let mut a = 0;
    let mut b = 0;
    let mut c = 0;
    let mut d = 0;
    for _ in 0..3 {
        let ab = read::<usize>();
        for i in ab {
            match i {
                1 => a += 1,
                2 => b += 1,
                3 => c += 1,
                4 => d += 1,
                _ => unreachable!(),
            }
        }
    }

    if a > 2 || b > 2 || c > 2 || d > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>

int main() {
  auto min = [](auto a, auto b) { return (a < b) ? a : b; };
  unsigned long long int N, A, B;
  std::cin >> N >> A >> B;

  unsigned long long int res{0};
  res += A * (N / (A + B));
  N %= (A + B);
  res += min(A, N);
  printf("%llu", res);
}

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

using ll = long long;
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

bool seen[1000][1000], winnable[1000][1000];
bool ans(int x, int y) {
  if (seen[x][y]) return winnable[x][y];
  seen[x][y] = true;
  bool re = false;
  int x0 = x, y0 = y;
  while (x0 >= 2 && !re) {
    x0 -= 2;
    y0 += 1;
    if (!ans(x0, y0)) re = true;
  }
  x0 = x;
  y0 = y;
  while (y0 >= 2 && !re) {
    y0 -= 2;
    x0 += 1;
    if (!ans(x0, y0)) re = true;
  }
  return winnable[x][y] = re;
}
void solve(long long x, long long y) {
  cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
}

int main() {
  long long X;
  scanf("%lld", &X);
  long long Y;
  scanf("%lld", &Y);
  solve(X, Y);
}


Measured memory_bytes: 3784
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int n = Integer.parseInt(sc.nextLine());
        for (int i = 0; i < n; i++) {
            String[] array = sc.nextLine().split("[\\s]");
            int n1 = Integer.parseInt(array[0]);
            int n2 = Integer.parseInt(array[1]);
            int n3 = Integer.parseInt(array[2]);
            int swap = n3;
            if (n1 < n2 && n3 < n2) {
                n3 = n2;
                n2 = swap;
            } else if (n2 < n1 && n3 < n1) {
                n3 = n1;
                n1 = swap;
            }

            if ((n1 * n1) + (n2 * n2) == (n3 * n3)) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
        sc.close();
    }

}

Measured memory_bytes: 25240
#include <bits/stdc++.h>
//#define DEBUG
#define REP( i , nn ) for(int i = 0 ; i < (int) nn; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
template <class T>
void print_vect(std::vector<T> v){
    for(int i = 0 ; i < v .size(); i++) cout << v[i] << " ";
    cout << endl;
}

void solve(){
    int n;
    cin >> n;
    vi a(n);
    vi b(n);
    REP(i, n){ cin >> a[i]; b[i] = a[i];}
    sort(a.begin(), a.end());
    int max_num = a.back();
    int osshi = a[n-2];

    REP(i, n){
        int ans = (b[i] == max_num) ? osshi : max_num;
        cout << ans << "\n";
    }
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/

    #ifdef DEBUG
    int TEST_CASES = 2;
    while(TEST_CASES--){
    #endif // DEBBUG

    solve();

    #ifdef DEBUG
    }
    #endif // DEBUG
    
    return 0;
}

//Thanks to CSES problemset
// I am trained with this kind of problem

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

using namespace std;

int main() {
    int test;
    cin >> test;
    int x = 0, y = 0, t = 0;
    for (int i = 1; i <= test; ++i) {
        int X, Y, T;
        cin >> T >> X >> Y;
        if (abs(X - x) + abs(Y - y) > T - t) {
            cout << "No" << endl;
            return 0;
        }
        int c1 = abs(X - x) + abs(Y - y);
        int c2 = T - t;
        if (c1 % 2 != c2 % 2) {
            cout << "No" << endl;
            return 0;
        }
        x = X, y = Y, t = T;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    from sys import stdin, setrecursionlimit
    setrecursionlimit(10**6)
    r = stdin.readline()[:-1]
    #n = int(stdin.readline()[:-1])   
    #r = [stdin.readline() for i in range(n)]
    #t = [int(stdin.readline()) for i in range(n)]

    a = list(map(int, r.split()))
    a.sort()
    res = 0
    for i in range(1,3):
        res += a[i] - a[i-1]
    print(res)

if __name__ == '__main__':
    main()



Measured memory_bytes: 38512
from itertools import combinations

N = int(input())
S = [input() for _ in range(N)]

chenge = list("MARCH")
d = dict()
for i, c in enumerate(chenge):
    d[c] = i

cnt = [0] * 5

for s in S:
    if s[0] in chenge:
        cnt[d[s[0]]] += 1

ans = 0

for i, j, k in combinations(cnt, 3):
    ans += i * j * k

print(ans)

Measured memory_bytes: 9856
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(void){

  int a,b,k;

  cin>>a;
  cin>>b;
  cin>>k;

  //cout << b-a+1<<endl;
  //cout << 2*k<<endl;  

  if(b-a+1 < 2*k){
    for(int i=a;i<b+1;i++){
      cout << i << endl;
    }
  }
    else{
      for(int i=0;i<k;i++){
	cout << a+i << endl;
      }
      for(int i=0;i<k;i++){
	cout << b-(k-i)+1 << endl;
      }       
    }
  
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
//#include "test.h"

using namespace std;


int main()
{
	int r;

	cin >> r;

	cout << r * r << endl;

	/*
		rを読み取る
		(r*r)/(1*1)を求める
		表示する
	*/
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x, y; cin >> x >> y;
  vector<int> a = {0, 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  if (a[x] == a[y]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
n,m,c = readline() |> split .|> parseInt
b = readline() |> split .|> parseInt |> Vector
A = fill(0,n,m)
for i = 1:n
    A[i,:] .= readline() |> split .|> parseInt
end
ans = A*b .+ c
ret = 0
for i in ans
    if i > 0 
    	global ret += 1 
    end
end
println(ret)

Measured memory_bytes: 216528
#include<queue>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

bool bh[1000001];

int main()
{
	priority_queue< int,vector<int>,greater<int> > pq;
	pq.push(1);	bh[1]=true;
	while(pq.top()<1000000){
		int a=pq.top();	pq.pop();
		if(2*a<=1000000&&!bh[2*a])	pq.push(2*a),bh[2*a]=true;
		if(3*a<=1000000&&!bh[3*a])	pq.push(3*a),bh[3*a]=true;
		if(5*a<=1000000&&!bh[5*a])	pq.push(5*a),bh[5*a]=true;
	}

	vector<int> ham;
	for(int i=0;i<=1000000;i++)	if(bh[i])	ham.push_back(i);

	for(int m,n;scanf("%d%d",&m,&n),m;){
		printf("%d\n",
			distance(lower_bound(ham.begin(),ham.end(),m),
					 upper_bound(ham.begin(),ham.end(),n))
		);
	}

	return 0;
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m,k;
    cin >> m >> k;
    ll ma = (1LL<<m);
    if(k>=ma){
        cout << -1 << endl;
        return 0;
    }
    if(m==0){
        if(k==0){
            printf("%d %d\n",0,0);
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    if(k==0){  
        for(ll i=0;i<ma;++i){
            cout << i << " " << i << ((i==ma-1)?("\n"):(" "));
        }
        return 0;
    }
    if(m==1){
        cout << -1 << endl;
        return 0;
    }
    for(ll i=0;i<ma;++i){
        if(i!=k){
            cout << i << " ";
        }       
    }
    cout << k << " ";
    for(ll i=ma-1;i>=0;--i){
        if(i!=k){
            cout << i << " ";
        }       
    }
    cout << k << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>

#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	unsigned long long int x, y;
	cin >> x >> y;

	if (x % y == 0)
		cout << -1 << endl;

	else{
		unsigned long long int i = 1;
		while (true) {
			if ((x * i) % y != 0) {
				cout << x * i << endl;
				break;
			}
			i++;
		}
	}

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

a, b, c = MAP()

a, b = b, a
a, c = c, a
print(a, b, c)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.List;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        List<String> lines = new ArrayList<String>();
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            lines.add(line);
        }
        int width = lines.get(0).length();
        int height = lines.size() / 2;
        int[][] nodes = new int[height + 1][width + 1];
        for (int i = 0; i < lines.size(); i++) {
            String line = lines.get(i);
            int y = i / 2;
            if (i % 2 == 0) {
                for (int x = 0; x < width; x++) {
                    if (line.charAt(x) == '1') {
                        nodes[y][x] |= 1;
                        nodes[y][x + 1] |= 1 << 2;
                    }
                }
            } else {
                for (int x = 0; x <= width; x++) {
                    if (line.charAt(x) == '1') {
                        nodes[y][x] |= 1 << 1;
                        nodes[y + 1][x] |= 1 << 3;
                    }
                }
            }
        }
        int cx = 0;
        int cy = 0;
        int cd = 0;
        while (true) {
            int node = nodes[cy][cx];
            for (int i = 3; i <= 6; i++) {
                int nd = (cd + i) % 4;
                int mask = 1 << nd;
                if ((node & mask) > 0) {
                    cd = nd;
                    break;
                }
            }
            if (cd == 0) {
                cx += 1;
            } else if (cd == 1) {
                cy += 1;
            } else if (cd == 2) {
                cx -= 1;
            } else {
                cy -= 1;
            }
            out.print(chars[cd]);
            if (cx == 0 && cy == 0) {
                out.println();
                break;
            }
        }
    }

    private static final char[] chars = { 'R', 'D', 'L', 'U' };
}

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

int main()
{

  int x,y,z,res;

  scanf("%d %d",&x,&y);

  if(x<1 || y>1000000000) exit(2);

  if(x<y){
    z=x;
    x=y;
    y=z;
  }

  res = x%y;
  while(res!=0){
    x=y;
    y=res;
    res = x%y;
  }
  printf("%d\n",y);

  return 0;
}



Measured memory_bytes: 2140
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void){
    int i, N, ANS=0, j, w;
    scanf("%d", &N);
    for(i=1; i<=N; i+=2){
        w=0;
        for(j=1; j<=i; j++){
            if(i%j==0) w++;
        }
        if(w==8) ANS++;
    }
    printf("%d\n", ANS);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int> > Matrix;
const int MOD = 1e9+7;


int main(){
  double n; cin>>n;
  bool flag=0;
  int q=0;  double p=0;
  int res=0;
  REP(i,n+1){
   p=i*1.08; q=p;
    if(q==n){
      flag=1; res=i;
    }
  }
  if(flag)cout<<res<<endl;
  else cout<<":("<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = [0]*N
B = [0]*N
for i in range(N): A[i],B[i] = map(int,input().split())
A.sort()
B.sort()

sorted_A = A
sorted_B = B

if N % 2 != 0:
  center_A = sorted_A[N//2]
  center_B = sorted_B[N//2]
  print(center_B - center_A + 1)
else:
  center_A = (sorted_A[N//2-1] + sorted_A[N//2]) / 2
  center_B = (sorted_B[N//2-1] + sorted_B[N//2]) / 2
  print(int((center_B - center_A)*2 + 1))

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

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	int n;
	cin >> n;
	bool f=true;
	ll a[n];
	FOR(i,n) {
		cin >> a[i];
		if(a[i]%2) f=false;
	}	
	if(f) cout << "second";
	else cout << "first";
	return 0;
}

Measured memory_bytes: 4372
import math
import random
import sys

def gcd(a,b):
    if a==b:
        return a
    if a>b:
        return gcd(b,a)
    if b%a==0:
        return a
    return gcd(b%a,a)

def rabin(n):
##    print(n)
    for t in range(100):
        x=random.randint(2,n-1)
       ## print(x)
        if gcd(n,x)!=1:
            return False
        if pow(x,n-1,n)!=1:
            return False
            
    return True



def main():

    x,y = map(int,input().split())
    if y<0:
        if x==1:
            print(11)
        else:
            for _ in range(2*x):
                print(9,end='')
            print()
        return
    
    r=10**x
    r-=1
    rr=10**(x-1)-1
    while r!=rr:
        s=str(r)
        c=str(y)
        t=s[::-1]
        
        w=int(s+c+t)
        
        if rabin(w):
            print(w)
            return
        r=r-1
##    print("nasi")
    for _ in range(x):
        print(9,end='')
    print(y,end='')
    
    for _ in range(x):
        print(9,end='')
    print()
    
if __name__ == '__main__':
    main()


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

int main() {
	string s;
	cin >> s;
	int n = s.size() + 1;
	vector<int> x(n);
	for (int i = 0; i < n - 1; i++) {
		if (s[i] == '<') x[i + 1] = max(x[i + 1], x[i] + 1);
	}
	for (int i = n - 1; i > 0; i--) {
		if (s[i - 1] == '>') x[i - 1] = max(x[i - 1], x[i] + 1);
	}
	ll ans = 0;
	rep(i, n) ans += x[i];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5856
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };

int main() {
  R(X);
  u8t ans=(X/500)*1000;
  X%=500;
  ans+=X/5*5;
  P(ans);
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
   int t;
   cin>>t;
   int c=0,mx=0;
   while(t--){
       int a,b; cin>>a>>b;
       if(a==b) c++;
       else
       {
           c=0;
       }
       mx=max(mx,c);
   }
   if(mx>=3)    cout<<"Yes";
   else
   {
       cout<<"No";
   }
   
}

Measured memory_bytes: 3100
import math
import itertools
import statistics
#n, m = list(map(int, input().split()))
s = input()

#print(len(s))

for i in range(int(len(s))//2):
    if s[i]!=s[len(s)-1-i]:
        print("No")
        exit()

s2 = ""
for i in range((len(s)-1)//2):
    s2 += s[i]

s3 = ""
for i in range((len(s)+1)//2, len(s)):
    s3 += s[i]
    

#print(s2)
#print(s3)

for i in range(int(len(s2))//2):
    if s2[i]!=s2[len(s2)-1-i]:
        print("No")
        exit()


for i in range(int(len(s3))//2):
    if s3[i]!=s3[len(s3)-1-i]:
        print("No")
        exit()


print("Yes")

Measured memory_bytes: 5404
<?php
$input = explode(' ', trim(fgets(STDIN)));

$n = (int)$input[0];
$k = (int)$input[1];
$args = [];
for ($i=0; $i < $n; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	$key = (int)$input[0];
	$cnt = (int)$input[1];
	if (empty($args[$key])) {
		$args[$key] = $cnt;
	}else{
		$args[$key] += $cnt;
	}
}
ksort($args);
$total = 0;
foreach ($args as $key =>$val) {
	$total += $val;
	if ($total >= $k) {
		echo $key;
		exit;
	}
}

Measured memory_bytes: 8952
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N, K;
int h[MAX_N];

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

  cin >> N >> K;
  REP(i, N) cin >> h[i];

  int ans = 0;
  REP(i, N) if (h[i] >= K) ans++;

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, k;
	cin>>n>>k;
	vector<int> v(n);
	for(int i = 0; i < n; i++){
		cin>>v[i];
	}
	int ans = 0;
	for(int l = 0; l < n; l++){
		for(int r = 0; r + l <= n; r++){
			if(l + r > k)break;
			vector<int> vec;
			for(int i = 0; i < l; i++){
				vec.push_back(v[i]);
			}
			for(int i = 0; i < r; i++){
				vec.push_back(v[n - 1 - i]);
			}
			sort(vec.rbegin(), vec.rend());
			int cur = accumulate(vec.begin(), vec.end(), 0);
			int mx = k - l - r;
			while(mx--){
				if(vec.empty() || vec.back() >= 0)break;
				cur -= vec.back(); vec.pop_back();
			}
			ans = max(ans, cur);
		}
	}
	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define Y printf("YES\n")
#define N printf("NO\n")
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define pr(a) printf("%lld\n",a)

int main()
{
    ll n,m,i,j,k,l,t,x,y,z;

    ll a[10];

    for(i=0;i<5;i++){

        cin>>a[i];

        if(a[i]==0)t=i+1;
    }

    cout<<t<<endl;

}


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

int main()
{
	//freopen("in.txt","t",stdin);
	int l,r,d;
	cin>>l>>r>>d;
	int cnt=0;

	while(l<=r)
	{
		if(l%d==0)
			cnt++;
		l++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define inf 1e9

int nmax = 100010;
vector<vector<int>> graph(nmax);
vector<int> usedu(nmax,-1);
vector<int> usedv(nmax,inf);

void dfs(int locate,int cnt){
    rep(i,0,graph[locate].size()){
        if(usedv[graph[locate][i]] == inf){
            usedv[graph[locate][i]] = cnt+1;
            dfs(graph[locate][i],cnt+1);
        }
    }
}
void udfs(int locate,int cnt){
    rep(i,0,graph[locate].size()){
        if(usedu[graph[locate][i]] == -1 && usedv[graph[locate][i]] > cnt){
            usedu[graph[locate][i]] = cnt+1;
            udfs(graph[locate][i],cnt+1);
        }
    }
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,u,v;
    cin >> n >> u >> v;
    u--;
    v--;
    if(u==v){
        cout << 0 << endl;
        return 0;
    }
    usedu[u] = 0;
    usedv[v] = 0;

    rep(i,0,n-1){
        int a,b;
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    dfs(v,0);
    udfs(u,0);
    int maxi = 0;
    rep(i,0,n){
        if(usedu[i] == -1) continue;
        maxi = max(maxi,usedv[i]);
    }
    cout << maxi-1 << endl;


}

Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> h(n);
    if(n<=k){
        cout << 0;
    }else{
        REP(i,n){
            cin >> h.at(i);
        }
        sort(ALL(h));
        ll sum=0;
        REP(i,n-k){
            sum += h.at(i);
        }
        cout << sum;
    }
    
    return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>

int main(){
	long long N, K, count=0;
	scanf("%lld %lld", &N, &K);
	long long s[N];
	for(long long i=0;i<N;i++){
		scanf("%lld",&s[i]);
	}
	long long temp=0;
	for(long long j=K+count; j>0+count; j--){
			temp += s[j-1];
		}
	for(long long i=K-1;i<N-1;i++){
		long long t2=0;
		for(long long j=K+count; j>0+count; j--){
			t2+=s[j];
		}
		if(t2>temp){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		temp=t2;
		count++;
	}
	
	return 0;
}

Measured memory_bytes: 4592
def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    return g1[n] * g2[r] * g2[n - r] % mod


mod = 10**9 + 7  #出力の制限
N = 2000005
g1 = [1, 1]  # 元テーブル
g2 = [1, 1]  #逆元テーブル
inverse = [0, 1]  #逆元テーブル計算用テーブル

for i in range(2, N + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

K = int(input())
S = len(input())
ans = 0
for i in range(S, S + K + 1):
    ans += cmb(S + K, i, mod) * pow(25, K + S - i, mod)
    ans %= mod
print(ans)


Measured memory_bytes: 222924
import java.util.Scanner;

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

        long N = scanner.nextLong();

        long[] cap = new long[5];

        int bottleIdx = -1;
        long min = Long.MAX_VALUE;

        for(int i=0; i<5; i++){
            cap[i] = scanner.nextLong();
            if(cap[i] < min){
                bottleIdx = i;
                min = cap[i];
            }
        }

        long time = 0;

        time += 4;


        time += (N / cap[bottleIdx]);

        if(N%cap[bottleIdx] != 0){
            time++;
        }

        System.out.println(time);

    }
}


Measured memory_bytes: 25044
#!/usr/bin/env python3

n = int(input())
s = [input() for _ in range(n)]
d = {}

for c in s:
    if c[0] not in d:
        d[c[0]] = 1 
    else:
        d[c[0]] += 1

tmp = d.copy()
t = ['M', 'A', 'R', 'C', 'H']
for c in tmp:
    if c not in t:
        d.pop(c)

ans = 0 
dlist = list(d.items())
for i in range(len(dlist)):
    for j in range(i+1, len(dlist)):
        for k in range(j+1, len(dlist)):
            ans += dlist[i][1]*dlist[j][1]*dlist[k][1]
print(ans)


Measured memory_bytes: 16064
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum[1000000], ans=INF, dp[10000][2], a[2000000],b[2000000];
string str, ss,dd;
bool f,ff;
char c[1000000];
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL to, cost; };
vector<Edge>vec[10000];
vector<LL>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> c[i];
		sum[i + 1] = sum[i];
		if (c[i] == 'W')
			sum[i + 1]++;
	}
	sum[n + 1] = sum[n];
	sum[n + 2] = sum[n];
	rep(i, n) {
		ans = min(ans, sum[i] + n - i - 1 - (sum[n+1] - sum[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7040
use std::io;

fn main() {
    let (a, b, c) = input();

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

fn input() -> (i32, i32, i32) {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");

    let mut iter = s.trim().split_whitespace();

    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();

    (a, b, c)
}



Measured memory_bytes: 5024