akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN, "%d", $n);
$s = trim(fgets(STDIN));
$list = range("A", "Z");
$length = strlen($s);
for($i = 0; $i < $length; $i++) {
    $skey = array_search($s[$i], $list);
    $moveKey = ($skey + $n) % 26;
    echo $list[$moveKey];
}


Measured memory_bytes: 4984
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
double const PI=3.141592653589793;
int const INF=1001001001;
ll const LINF=1001001001001001001;
ll const MOD=1000000007;

ll N;
int A[100000];
int B[100000];

int main(){
    cin>>N;
    rep(i,N) cin>>A[i]>>B[i];

    int ans=0;
    int a=0;
    rep(i,N){
        if(A[i]>a){
            ans=A[i]+B[i];
            a=A[i];
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 4372
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d;
	string s;
	cin>>n>>a>>b>>c>>d>>s;
	a--,b--,c--,d--,s+='#';
	if(d<c){
		bool ok1=true;
		for(int i=a;i+1<=c;i++)
			if(s[i]=='#'&&s[i+1]=='#')
				ok1=false;
		for(int i=b;i+1<=d;i++)
			if(s[i]=='#'&&s[i+1]=='#')
				ok1=false;
		bool ok2=false;
		for(int i=b-1;i<d;i++)
			if(s[i]=='.'&&s[i+1]=='.'&&s[i+2]=='.')
				ok2=true;
		cout<<(ok1&&ok2?"Yes":"No")<<endl;
	}else{
		bool ok=true;
		for(int i=a;i+1<=c;i++)
			if(s[i]=='#'&&s[i+1]=='#')
				ok=false;
		for(int i=b;i+1<=d;i++)
			if(s[i]=='#'&&s[i+1]=='#')
				ok=false;
		cout<<(ok?"Yes":"No")<<endl;
	}
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        int N;
        long[] B;


        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();

            B = new long[N-1];

            for(int i = 0;i < N-1;i++){
                B[i] = sc.nextLong();
            }

        }
        long result = 0;
        long[] A =new long[N];
        A[N-1] = B[N-2];
        for(int i = N-2;i > 0;i--){
            A[i] = Math.min(B[i],B[i-1]);
        }
        A[0] = B[0];
        for(int i = 0;i < N;i++){
            result += A[i];
        }

        System.out.println(result);
    }

}


Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> A, std::vector<long long> B){
  vector<pll> BA;
  REP(N)BA.push_back({B[i],A[i]});
  sort(BA.begin(),BA.end());
  ll sum=0;
  REP(N){
    sum+=BA[i].second;
    if(sum>BA[i].first){
      cout<<NO<<endl;
      return;
    }
  }
  cout<<YES<<endl;
  return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 9200
import java.util.Scanner;
public class Main
{
    public static void main(String Args[])
    {
        Scanner sc=new Scanner (System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int[] x=new int[m];
        for(int a=0;a<m;a++)
        {
            x[a]=sc.nextInt();
            n=n-x[a];
        }
        
        if (n<0)
        System.out.println("-1");
        if(n>=0)
        System.out.println(n);
    }
}

Measured memory_bytes: 46304
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long n;
int main() {
    cin >> n;
    long long now = n;
    vector<int> S;
    long long dd = 2;
    int i = 0;
    while(now != 0) {
        if(now % dd == 0) {
            S.push_back(0);
        }else {
            S.push_back(1);
            if(i % 2 == 0) {
                now -= (dd/2);
            }else {
                now += (dd/2);
            }
        }
        dd *= 2;
        ++i;
    }

    int slen = S.size();
    for(int j = slen-1; j >= 0; --j) {
        cout << S.at(j);
    }
    if(n == 0) cout << 0 << endl;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define eb emplace_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

// 基本要素

const double EPS = 1e-8;
const double INF = 1e12;
// 点
typedef complex<double> P;
namespace std {
  bool operator < (const P& a, const P& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
// 外積
double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}
// 内積
double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

// 直線
// 線分は端点を入れる
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

// 多角形
// 頂点は反時計にすること
typedef vector<P> G;

// a->b->cという折れ線がどうなっているか
int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // 反時計周り
  if (cross(b, c) < 0)   return -1;       // 時計回り
  if (dot(b, c) < 0)     return +2;       // c--a--b の順に一直線
  if (norm(b) < norm(c)) return -2;       // a--b--c の順に一直線
  return 0;
}

// 直線の交点
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}

// 凸多角形の切断
// 直線の左側を残す
// 凸出ない場合は?

// !CAUTION! number は有理数以上
G convex_cut(const G& Poly, const L& l) {
  G Q;
  for (int i = 0; i < Poly.size(); ++i) {
    P A = Poly[i], B = Poly[(i+1)%Poly.size()];
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}

signed main(){
  int n;
  while(cin >> n, n){
    G g(n);
    rep(i,n){
      double x, y; cin >> x >> y;
      g[i] = {x, y};
    }
    G res(4);
    res[0] = {0,0};
    res[1] = {10000,0};
    res[2] = {10000,10000};
    res[3] = {0,10000};
    rep(i,n){
      L l(g[i],g[(i+1)%n]);
      res = convex_cut(res, l);
    }
    dump(area2(res));
    if(res.size()) cout << 1 << endl;
    else cout << 0 << endl;
  }
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

bool shiritori(int n) {
    vector<string> v;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (find(v.begin(), v.end(), s) != v.end()) {
            return false;
        }
        v.push_back(s);
    }
    for (int i = 1; i < v.size(); i++) {
        if (v[i - 1].back() != v[i].front()) {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    if (shiritori(n)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N; cin >> N;
    int ans;
    long long  n1=2, n2=1;
    for(int i=0;i<N;i++){
        long long  n = n1;
        n1 = n2;
        n2 = n+n2;
    }
    cout << n1 << endl;
}


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

#define ll long long 

int main(void)
{
    
   ll n,w,i,j;
   cin>>n>>w;

   vector<ll>v(n+1,0),wt(n+1,0);
   for(i=1;i<=n;i++)
   {
     cin>>wt[i]>>v[i];
   }
   

   vector<vector<ll>>dp(n+1,vector<ll>(w+1,0));

   for(i=1;i<=n;i++)
   {
      for(j=1;j<=w;j++)
      {
        dp[i][j]=dp[i-1][j];

        if(j-wt[i]>=0)
          dp[i][j]=max(dp[i][j], dp[i-1][j-wt[i]] + v[i]);
      }
   }
   
   cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 80256
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		long A = sc.nextInt();
		long B = sc.nextInt();

		if (A > 9 || B > 9) {
			System.out.println("-1");
		} else {
			System.out.println(A*B);
		}

	}
}

Measured memory_bytes: 22612
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
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(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        A[--a]++;
        A[--b]++;
    }
    rep(i, N) {
        if(A[i] % 2 != 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

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

int main(){

    int h,w;
    cin>>h>>w;

    vector<string> a(h);

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

    vector<bool> tate(h,false),yoko(w,false);

    for(int i=0;i<h;i++){

        for(int j=0;j<w;j++){

            if(a.at(i).at(j)=='#'){
                tate.at(i)=true;
                yoko.at(j)=true;
            }

        }

    }

    bool flag=false;

    for(int i=0;i<h;i++){

        flag=false;
        for(int j=0;j<w;j++){

            if(tate.at(i)==true&&yoko.at(j)==true){

                cout<<a.at(i).at(j);
                flag=true;
            }

        }

        if(flag==true) cout<<endl;

    }






    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int cont = 0;
    char v1[4];
    char v2[4];
    scanf("%s %s",v1,v2);
    for(int i = 0;i<3;++i){
        if(v1[i]==v2[i]){
            ++cont;
        }
    }
    printf("%d",cont);
    
	return 0;
}

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

int main(){
    int n,sl;
    cin >> n;
    sl = 0;
    string num;
    num = to_string(n);
    for(int i = 0;i < num.size();i++){
      int j = 0;
      j = (int)num.at(i)-48;
      sl += j;
    }
    if(n%sl == 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
ans=10**6
for i in range(1,h):
    A=i*w
    bh=int((h-i)/2)
    B1=bh*w
    C1=(h-i-bh)*w
    tmp1=max(A,B1,C1)-min(A,B1,C1)
    bw=int(w/2)
    B2=(h-i)*bw
    C2=(h-i)*(w-bw)
    tmp2=max(A,B2,C2)-min(A,B2,C2)
    ans=min(ans,tmp1,tmp2)
x=w
w=h
h=x
ans2=10**6
for i in range(1,h):
    A=i*w
    bh=int((h-i)/2)
    B1=bh*w
    C1=(h-i-bh)*w
    tmp1=max(A,B1,C1)-min(A,B1,C1)
    #print("Aの高さ={}, Bの高さ={}, Bの横幅={}, Cの高さ={}, Cの横幅={}, A={} B={} C={} tmp={}".format(i,bh,w,h-i-bh,w,A,B1,C1,tmp1))
    bw=int(w/2)
    B2=(h-i)*bw
    C2=(h-i)*(w-bw)
    tmp2=max(A,B2,C2)-min(A,B2,C2)
    #print("Aの高さ={}, Bの高さ={}, Bの横幅={}, Cの高さ={}, Cの横幅={}, A={} B={} C={} tmp2={}".format(i,h-i,bw,h-i,w-bw,A,B2,C2,tmp2))
    ans2=min(ans2,tmp1,tmp2)
print(min(ans,ans2))

Measured memory_bytes: 3064
program nomuraA
      implicit none
      integer::H1,M1,H2,M2,K
      integer::difh,difm,totalmin
      
         read *, H1,M1,H2,M2,K
         difh=H2-H1
         difm=M2-M1
         totalmin=difh*60+difm
         print *, totalmin-K
         
   end program nomuraA

Measured memory_bytes: 2844
N, M = list(map(int, input().split()))
AB = []
for i in range(M):
    a, b = list(map(int, input().split()))
    AB.append([a, b])

graph = []
for i in range(N):
    graph.append([False]*N)

for a, b in AB:
    a -= 1
    b -= 1
    graph[a][b] = True
    graph[b][a] = True

VISITED = [None] * N

count = 0

def dfs(v):
    global count
    if all(VISITED):
        count += 1
        return

    edges = graph[v]
    for i, ei in enumerate(edges):
        if ei and not VISITED[i]:
            VISITED[i] = True
            dfs(i)
            VISITED[i] = False

VISITED[0] = True
dfs(0)
print(count)

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

int main(){
  int n;
  cin>>n;
  if(n%10==0){
    cout<<10<<endl;
    return 0;
  }
  int ans=0;
  while(n>=10){
    ans+=n%10;
    n-=n%10;
    n/=10;
  }ans+=n;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3680
import sys 
RESOURCE_DICT = dict([(k,v) for k,v in zip(range(1,10),[2,5,5,4,5,6,3,7,6])])

def get_input():
    N,M = [ int(_) for _ in input().split()]
    A = [int(_) for _ in input().split()]
    return N,M,A


def solve(N,M,A):
    sorted_A = sorted(A)[::-1]
    dp = fill_dp(N,sorted_A)
    array = find_array(dp,N,sorted_A)
    return "".join(map(str,array))

def fill_dp(N,A):
    dp = [ -100*N for _ in range(N+1)]
    dp[0] = 0
    for i in range(1,N+1):
        fill(A,dp,i,N)
    return dp

def fill(A,dp,n,N):
    cand = [ dp[n-RESOURCE_DICT[num]]+1 for num in A if n - RESOURCE_DICT[num] >= 0 ]
    dp[n] = max(cand) if len(cand) > 0  else -100*N

def find_array(dp,N,sorted_A):
    array = []
    current_n = N
    for _ in range(dp[N]):
        for number in sorted_A:
            if current_n-RESOURCE_DICT[number] >= 0  and dp[current_n-RESOURCE_DICT[number]] == dp[current_n]-1:
                array.append(number)
                current_n -= RESOURCE_DICT[number]
                break
    return array


if __name__ =="__main__":
    N,M,A = get_input()
    ans = solve(N,M,A)
    print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0){
		cout<<"Possible"<<endl;
	}
	else if(b%3==0){
		cout<<"Possible"<<endl;
	}
	else if((a+b)%3==0){
		cout<<"Possible"<<endl;
	}
	else{
		cout<<"Impossible"<<endl;
	}
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int x; cin >> x;
  if(x == 25)
    cout <<"Christmas";
  else if(x == 24)
    cout <<"Christmas Eve";
  else if (x == 23)
    cout <<"Christmas Eve Eve";
  else
    cout <<"Christmas Eve Eve Eve";
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#include <cctype>
#include <locale>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<long long,long long> Pll;
#define fout(num) cout << fixed << setprecision(20) << (num) << endl
//s[i]=tolower(s[i]); islower(s[i]); cout << tolower(s[i])はバグ
//vector<vector<ll>> dp(n,vector<ll>(n))
//exist x map o setconst ll MOD = 1e9+7;return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD;

template<typename T>
struct LazySegmentTree{
private:
    int n;
    vector<T> node,lazy;
public:
    T SUP=0; /* 初期値　*/
    T merge(T x,T y){
        return x+y;
    }
    LazySegmentTree(vector<T> v){
        int sz=(int)v.size();
        n=1; while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);
        for(int i=0;i<sz;i++) node[i+n-1]=v[i];
        for(int i=n-2;i>=0;i--) node[i]=merge(node[2*i+1],node[2*i+2]);
    }
    void eval(int idx,int l,int r){
        if(lazy[idx]!=0){
            node[idx]+=lazy[idx];
            if(r-l>1){
                /* node[idx]からの伝播  */
                lazy[2*idx+1]+=lazy[idx]/2;
                lazy[2*idx+2]+=lazy[idx]/2;
            }
            lazy[idx]=0;
        }
    }
    void update(int a,int b,T x,int idx=0,int l=0,int r=-1){
        if(r<0) r=n;
        eval(idx,l,r);
        if(b<=l||r<=a) return;
        if(a<=l&&r<=b){
            lazy[idx]+=x*(r-l);
            eval(idx,l,r);
        }else{
            update(a,b,x,2*idx+1,l,(l+r)/2);
            update(a,b,x,2*idx+2,(l+r)/2,r);
            node[idx]=merge(node[2*idx+1],node[2*idx+2]);
        }
    }
    T query(int a,int b,int idx=0,int l=0,int r=-1){
        if(r<0) r=n;
        if(b<=l || r<=a) return 0;
        eval(idx,l,r);
        if(a<=l && r<=b) return node[idx];
        T vl = query(a,b,2*idx+1,l,(l+r)/2);
        T vr = query(a,b,2*idx+2,(l+r)/2,r);
        return merge(vl,vr);
    };
};



signed main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n,q; cin >> n >> q;
    vector<ll> v(n,0);
    LazySegmentTree<ll> lsg(v);
    rep(i,q){
        int x; cin >> x;
        if(x==0){
            int s,t,y; cin >> s >> t >> y;
            s--;
            lsg.update(s,t,y);
        }else{
            int s; cin >> s;
            s--;
            cout << lsg.query(s,s+1) << "\n";
        }
    }

}



Measured memory_bytes: 8712
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int calc(int a,int b,int c){
    return a*10000+b*5000+c*1000;
}
int main(void){
    // Your code here!
    long long a;
    long long b;
    cin >> a >> b;
    int ans = 0;
    while(a<=b){
        a*=2;
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
# coding: utf-8
# Here your code !
import math

def func():
    try:
        line=input().rstrip()
        numbers=line.split(" ")
        
        width=float(numbers[0])
        height=float(numbers[1])
        x=float(numbers[2])
        y=float(numbers[3])
        r=abs(float(numbers[4]))
        
    except:
        print("input error")
        return -1
    
    wsign=math.copysign(1,width)
    hsign=math.copysign(1,height)
    
    result=(wsign*x+r <= wsign*width)
    result=result and (wsign*x-r >= 0)
    result=result and (hsign*y+r <= hsign*height)
    result=result and (hsign*y-r >= 0)
    
    if result:
        print("Yes")
    else:
        print("No")
        
func()

Measured memory_bytes: 7664
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX_N = 100000;
double scores[MAX_N], players[MAX_N];
int res[MAX_N];


int main(){

    int n, left, right;
    double t;
    scanf("%d", &n);
    fill(res, res+n, 0);
    for (int i = 0; i < n; i++) {
        scanf("%lf", &t);
        players[i] = scores[i] = t;
    }
    sort(scores, scores+n);
    //for (int i = 0; i < n; i++) printf("%.2lf ", scores[i]);
    //printf("\n");

    for (int i = 0; i < n; i++) {
        left = lower_bound(scores, scores+n, players[i])-scores;
        right = (players[i] == scores[n-1]) ? n-1 : upper_bound(scores, scores+n, players[i])-scores-1;
        res[i] = 3*left + right-left;
    }
    for (int i = 0; i < n; i++) {
        printf("%d\n", res[i]);
    }


    return 0;
}



Measured memory_bytes: 4932
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        ls: [u64; n],
    }

    let mut ans = 0;
    for i in 0..n {
        for j in i + 1..n {
            for k in j + 1..n {
                let mut values = vec![ls[i], ls[j], ls[k]];
                values.sort();
                values.dedup();
                ans += u32::from(values.len() == 3 && values[0] + values[1] > values[2]);
            }
        }
    }
    println!("{}", ans);
}


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

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

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

	int ans = a - s;

	if(ans < 0){
		printf("-1\n");
	}
	else{
		printf("%d\n", ans);
	}
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if (int(X/n)):
    return Base_10_to_n(int(X/n), n)+[X%n]
  return [X%n]


#############
# Main Code #
#############
N = inputI()

ans = 0
for i in range(3,N+1)[::2]:
  if len(make_divisors(i)) == 8:
    ans+=1
    
print(ans)


Measured memory_bytes: 38512
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int[] a = new int[10];
        
        for(int i = 0; i<10; i++)
            a[i] = s.nextInt();
        
        Arrays.sort(a);
        
        System.out.println(a[9]);
        System.out.println(a[8]);
        System.out.println(a[7]);        
    }
}

Measured memory_bytes: 12000
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;

int n, a[3];
char s[N][5], ans[N];

void f(int p, int q, int r) {
	ans[p] = q + 'A';
	a[q]++, a[r]--;
}

int main() {
	int i, x, y, t;
	cin >> n >> a[0] >> a[1] >> a[2];
	for(i=0; i<n; i++) scanf("%s", &s[i]);
	for(i=0; i<n; i++) {
		x = s[i][0] - 'A';
		y = s[i][1] - 'A';
		if(!a[x] && !a[y]) return puts("No"), 0;
		if(!a[x]) f(i, x, y);
		else if(!a[y]) f(i, y, x);
		else if(a[x]==1 && a[y]==1) {
			if(x==0) {
				t = s[i+1][0] - 'A';
				t==0 ? f(i, x, y) : f(i, y, x);
			} else {
				t = s[i+1][1] - 'A';
				t==2 ? f(i, y, x) : f(i, x, y);
			}
		} else a[x]<a[y] ? f(i, x, y) : f(i, y, x);
	}
	puts("Yes");
	for(i=0; i<n; i++) printf("%c\n", ans[i]);
	return 0;
}

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

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

using namespace std;

int main(){
  ll a,b,k;cin>>a>>b>>k;
  ll l,r;
  l=a-k;
  if(b+l<0){
    cout<<0<<' '<<0;
  }else if(l<0){
    cout<<0<<' '<<b+l;
  }else{
    cout<<l<<' '<<b;
  }

  return 0;
}


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

int main() {
  string A, B;
  cin >> A >> B;

  if (A.size() > B.size()) {
    cout << "GREATER" << endl;
  } else if (A.size() < B.size()) {
    cout << "LESS" << endl;
  } else if (A.size() == B.size()) {
    for (int i; i < A.size(); i++) {
      if (A[i] > B[i]) {
        cout << "GREATER" << endl;
        return 0;
      } else if (A[i] < B[i]) {
        cout << "LESS" << endl;
        return 0;
      }
    }
    cout << "EQUAL" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
int main(){
	ll n, p, ans = 1;
	cin >> n >> p;
	if (n == 1){
		cout << p;
		return 0;
	}
	for(ll i = 2; i * i  <= p; ++i){
		ll cnt = 0, tmp = p;
		if(tmp % i == 0){
			while(tmp / i > 0 && tmp % i == 0){
				cnt++;
				tmp /= i;
				if(cnt == n){
					ans = max(ans, i);
				}
			}
		}
		cnt = 0;

	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<queue>
#include<utility>
#include<cstring>

typedef std::pair<int, int> P;

const int INF = 1 << 30;

int H, W, N;
char field[1000][1000];
int sx[10], sy[10];
int dist[1000][1000];
bool visited[1000][1000];

int bfs( int s, int g )
{
	memset( dist, 0, sizeof( dist ) );
	memset( visited, false, sizeof( visited ) );

	std::queue<P> que;
	que.push( P( sx[s], sy[s] ) );
	
	static const int dx[] = { 0, 1, 0, -1 }, dy[] = { -1, 0, 1, 0 };

	while( !que.empty() )
	{
		P p = que.front(); que.pop();
		int x = p.first, y = p.second;

		if( visited[y][x] )
			continue;

		visited[y][x] = true;

		if( x == sx[g] && y == sy[g] )
			break;

		for( int d = 0; d != 4; ++d )
		{
			int nx = x + dx[d], ny = y + dy[d];

			if( nx < 0 || nx >= W || ny < 0 || ny >= H || visited[ny][nx] || field[ny][nx] == 'X' )
				continue;

			dist[ny][nx] = dist[y][x] + 1;

			que.push( P( nx, ny ) );
		}
	}

	return dist[sy[g]][sx[g]];
}

int main()
{
	std::cin >> H >> W >> N;
	for( int i = 0; i != H; ++i )
	{
		for( int j = 0; j != W; ++j )
		{
			std::cin >> field[i][j];
		
			if( field[i][j] == 'S' )
				sx[0] = j, sy[0] = i;
			else if( field[i][j] >= '1' && field[i][j] <= '9' )
				sx[field[i][j] - '0'] = j, sy[field[i][j] - '0'] = i;
		}
	}

	int ans = 0;
	for( int i = 0; i != N; ++i )
		ans += bfs( i, i + 1 );

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 7080
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
        ll x;
        mint(ll x = 0):x((x % mod + mod) % mod) {}
        mint operator-() const { return mint(-x); }
        mint& operator+=(const mint a) {
            if ((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator-=(const mint a) {
            if ((x += mod - a.x) >= mod) x -= mod;
            return *this;
        }
        mint& operator*=(const mint a) {
            (x *= a.x) %= mod;
            return *this;
        }
        mint operator+(const mint a) const {
            mint res(*this);
            return res += a;
        }
        mint operator-(const mint a) const {
            mint res(*this);
            return res -= a;
        }
        mint operator*(const mint a) const {
            mint res(*this);
            return res *= a;
        }
        mint pow(ll t) const {
            if (!t) return 1;
            mint a = pow(t >> 1);
            a *= a;
            if (t & 1) a *= *this;
            return a;
        }
        // for prime mod
        mint inv() const {
            return pow(mod - 2);
        }
        mint& operator/=(const mint a) {
            return (*this) *= a.inv();
        }
        mint operator/(const mint a) const {
            mint res(*this);
            return res /= a;
        }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
        // vector size : n + 1
        vector<mint> fact, ifact;
        // precaliculation O(n)
        combination(int n):fact(n+1), ifact(n+1) {
            assert(n < mod);
            // 0! = 1;
            fact[0] = 1;
            // 1! = 0! * 1 ... n! = (n-1)! * n
            for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
            // 1/n! = n!^(-1)
            ifact[n] = fact[n].inv();
            // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
            for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
        }
        // combination O(1)
        // nCk = n! / (k! * (n-k)!)
        //     = n! * k!^(-1) * (n-k)!^(-1)
        mint operator()(int n, int k) {
            if (k < 0 || k > n) return 0;
            return fact[n] * ifact[k] * ifact[n-k];
        }
};
/* global variables */
/* function */
/* main */
int main(){
    int N, K;
    cin >> N >> K;
    vector<int> v(N);
    for (int i = 0; i < N; i++) cin >> v[i];
    sort(v.begin(), v.end());
    vector<mint> a(N);
    for (int i = 0; i < N; i++) a[i] = v[i];
    mint minSum = 0;
    mint maxSum = 0;
    combination c = combination(N);
    for (int i = 0; i <= N - K; i++) {
        minSum += a[i] * c(N-(i+1), K-1);
        maxSum += a[N-1-i] * c(N-(i+1), K-1);
    }
    mint ans = maxSum - minSum;
    cout << ans << '\n';
}


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

struct Node { int p, l, r; };
struct Node T[100000];
int n, D[100000];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u]<<", ";

	if (T[u].p == -1) {
		cout << "root, ";
	}
	else if (T[u].l == -1) {
		cout << "leaf, ";
	}
	else {
		cout << "internal node, ";
	}
	cout << "["; 
	for (i = 0 , c = T[u].l; c != -1; i++ , c = T[c].r) {
		if (i) {
			cout <<", ";
		}
		cout << c;
	}
	cout << "]"<<endl;
}

int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != -1) {
		rec(T[u].r, p);
	}
	if (T[u].l != -1) {
		rec(T[u].l, p+1);
	}
	return 0;
}

int main() {
	int i, j, d, v, c, l, r;
	cin >> n;
	for (i = 0; i < n; i++) {
		T[i].p = T[i].l = T[i].r = -1;
	}

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++) {
			cin >> c;
			if (j == 0) {
				T[v].l = c;
			}
			else {
				T[l].r = c;
			}
			l = c;
			T[c].p = v;

		}
	}
	for (i = 0; i < n; i++) {
		if (T[i].p == -1) {
			r = i;
		}
	}

	rec(r, 0);

	for (i = 0; i < n; i++) {
		print(i);
	}

	return 0;
}



Measured memory_bytes: 7684
import sys

input_line = input()
N, K = int(input_line.split(' ')[0]),int(input_line.split(' ')[1])

input_line = input()
height = list(map(int,input_line.split()))

count = 0
for i in range(len(height)):
    if (height[i] >= K):
        count+=1
print(count)

Measured memory_bytes: 12288
#include<stdio.h>

int prime[1000000];
bool flag[1000000];

void solve(int n)
{
	int ans=0;
	for(int i=2;i<=n;i++)
	{
		if(flag[i])
		{
			prime[ans++]=i;
			for(int j=2*i;j<=n;j+=i)
				flag[j]=false;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	int data;
	while(scanf("%d",&data)!=EOF)
	{
		for(int i=0;i<=data;i++)
			flag[i]=true;
		flag[0]=flag[1]=false;
		solve(data);
	}
}

Measured memory_bytes: 2044
N = int(input())
S = input()
if N == 2:
    print(len(set(S[0]).intersection(set(S[1]))))
else:
    ans = []
    for i in range(1, N-1):
        a = set(S[:i])
        b = set(S[i:])
        ans.append(len(a.intersection(b)))
    print(max(ans))


Measured memory_bytes: 38376
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
using namespace std;


ll B[100][100];

ll binomic(int n, int r){
	if(B[n][r]!=0) return B[n][r];
	if(n==r || r==0) return 1;
	return B[n][r] = binomic(n-1,r-1)+binomic(n-1,r);
}

int buscar(int A[],int l, int r, int dato){
	if(l>r) return -1;
	int mid = (l+r)/2;
	if(A[mid]==dato) return mid;
	if(A[mid]>dato) return buscar(A,l,mid-1,dato);
	return buscar(A,mid+1,r,dato);
}

bool isPossibleSum(int sum,int n,int A[]){
	if(n==0 && sum!=0) return false;
	if(sum==0) return true;
	if(A[n-1]>sum) return isPossibleSum(sum,n-1,A);
	return isPossibleSum(sum-A[n-1],n-1,A) || isPossibleSum(sum,n-1,A);
}



char M[101][101];

int main(){
	
	int A,B,tam=100;

	scanf("%d%d",&A,&B);

	for (int i = 0; i < tam; ++i)
	{
		for (int j = 0; j < tam; ++j)
		{
			if(i>=tam/2) M[i][j]='#';
			else M[i][j]='.';
		}
		M[i][100]='\0';
	}

	B-=1;
	A-=1;
	

	int i=0,j=0;
	while(B){
		M[i][j]='#';
		j+=2;
		if(j>=tam){j=0;i+=2;}
		B--;
	}
	

	i = tam/2+1,j=0;

	while(A){
		M[i][j]='.';
		j+=2;
		if(j>=tam){j=0;i+=2;}
		A--;
	}
	printf("100 100\n");
	for (int i = 0; i < 100; ++i)
	{
		printf("%s\n",M[i]);
	}
	





	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include<math.h>
#include<algorithm>

using namespace std;

long getketa(long num) {

	long ans = 1;

	while (num >= 10) {
		ans++;
		num /= 10;
	}

	return ans;
}


int main() {

	long num;
	cin >> num;

	long ans = LONG_MAX;
	long wk_ans;
	for (long i = 1; i * i <= num; i++) {
		if (num % i == 0) {
			wk_ans = max(getketa(i), getketa(num / i));
			if (wk_ans < ans)ans = wk_ans;
		}
	}

	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;


int main(int argc, char **argv) {
    long long N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << "0" << endl;
    } else if (K > N) {
        cout << min(N, K - N) << endl;
    } else {
        auto m = N / K;
        auto x = N - m * K;
        auto x2 = abs(x - K);
        cout << min(x, x2) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
class segment_tree_dual:
    def __init__(self, N, compose, funcval, ID_M=None):
        self.compose = compose
        self.ID_M = ID_M
        self.funcval = funcval

        self.height = (N-1).bit_length() #木の段数
        self.N0 = 1<<self.height #木の横幅 >= N
        self.laz = [self.ID_M]*(2*self.N0) #作用素の木
        self.val = None #値の配列

    #初期値の配列を作る
    def build(self,initial):
        self.val = initial[:]

    #laz[k] を子に伝える、k が一番下の場合は laz[k] を val に反映する
    def propagate(self,k):
        if self.laz[k] == self.ID_M: return;
        if self.N0 <= k:
            self.val[k-self.N0] = self.funcval(self.val[k-self.N0], self.laz[k])
            self.laz[k] = self.ID_M
        else:
            self.laz[(k<<1)  ] = self.compose(self.laz[(k<<1)  ],self.laz[k]);
            self.laz[(k<<1)+1] = self.compose(self.laz[(k<<1)+1],self.laz[k]);
            self.laz[k] = self.ID_M;
    
    # 遅延をすべて解消する
    def propagate_all(self):
        upto = self.N0 + len(self.val)
        for i in range(1,upto): self.propagate(i)

    # laz[k]およびその上に位置する作用素をすべて伝播
    def thrust(self,k):
        for i in range(self.height,-1,-1): self.propagate(k>>i)

    # 区間[l,r]に関数 f を作用
    def update(self, L,R,f):
        L += self.N0; R += self.N0+1
        """まず伝播させる（オペレータが可換なら必要ない）"""
        #self.thrust(L)
        #self.thrust(R-1)
        #登りながら関数 f を合成
        while L < R:
            if R & 1:
                R -= 1
                self.laz[R] = self.compose(self.laz[R],f)
            if L & 1:
                self.laz[L] = self.compose(self.laz[L],f)
                L += 1
            L >>= 1; R >>= 1
    
    # values[k] を取得。
    def point_get(self, k):
        res = self.val[k]
        k += self.N0
        while k:
            if self.laz[k] != self.ID_M:
                res = self.funcval(res, self.laz[k])
            k //= 2
        return res
    
    # values[k] = x 代入する
    def point_set(self, k): 
        self.thrust(k+self.N0)
        self.val[k] = x

###########################################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
 
n,m = [int(i) for i in readline().split()]
s = input()[::-1]


compose = min
funcval = min
ID_M = INF = 10**18

seg = segment_tree_dual(n+1, compose, funcval, ID_M)
seg.build([0]+[INF]*(n))

for i in range(n):
    if s[i] == "1": seg.val[i] = -1
    else:
        v = seg.point_get(i)
        #print(v,i)
        seg.update(i+1,min(n,i+m),v+1)
        #print(seg.laz)

seg.propagate_all()
#print(s)
#print(seg.val)

val = seg.val
if val[-1] == -1 or val[-1] == INF:
    print(-1)
    exit()

ans = []

now = n
time = val[-1]
while now:
    n2 = now-1
    time -= 1
    while s[n2] == "1" or val[n2] != time:
        n2 -= 1
    ans.append(now-n2)
    now = n2
    
print(*ans)    
    
    
    












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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  cin >> n >> m;
  vector<ll> w(n),b(n),r(n);
  char c;
  rep(i,n){
    rep(j,m){
      cin >> c;
      if(c == 'W'){
        w[i]++;
      }
      else if(c == 'R'){
        r[i]++;
      }
      else
        b[i]++;
    }
  }
  ll ans = inf;
  REP(i,1,n-1){
    ll tmp =0;
    rep(k,i){
      tmp += r[k] + b[k];
    }
    ll tmp3 = inf;
    REP(j,1,n-1){
      ll tmp2 = 0;
      if(j+i >= n) continue;
      REP(l,i,i+j){
        tmp2 += r[l] + w[l];
      }
      REP(l,j+i,n){
        tmp2 += w[l] + b[l];
      }
      tmp3 = min(tmp3,tmp2);
    }
    ans = min(ans,tmp+tmp3);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3232
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
h = list(map(int, input().split()))
prv = h[0]
ans = 0
c = 0
for i in range(1,n):
    if prv>=h[i]:
        c += 1
    else:
        ans = max(ans, c)
        c = 0
    prv = h[i]
ans = max(ans, c)
print(ans)

Measured memory_bytes: 87312
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b,c;
	cin >> a >> b >> c;
	if(a%2 == 0 || b%2==0 || c%2==0)cout << 0 << endl;
	else {
			cout << min({a*b,b*c,a*c}) << endl;
	}
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;
Node root;
void insert(Node);
void inorder(Node);
void preorder(Node);

int main()
{
  int n,i,x;
  char m[10];
  Node A;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%s%d",m,&x);
    if(m[0]=='i'){
      A = (Node)malloc(sizeof(struct node));
      A->right = NIL;
      A->left = NIL;
      A->parent = NIL;
      A->key = x;
      insert(A);
    }
    else if(m[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

void insert(Node A)
{
  Node y,x;

  y = NIL;
  x = root;
  
  while(x!=NIL){
    y = x;
    if(A->key < x->key) x = x->left;
    else x = x->right;
  }
  A->parent = y;

  if(y==NIL) root = A;
  else if(A->key < y->key) y->left = A;
  else y->right = A;
}

void inorder(Node A)
{
  if(A==NIL) return;
  inorder(A->left);
  printf(" %d",A->key);
  inorder(A->right);
}

void preorder(Node A)
{
  if(A==NIL) return;
  printf(" %d",A->key);
  preorder(A->left);
  preorder(A->right);
}

  
  
  




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

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

    int n;
    cin >> n;
    vector<long long> A(n), B(n);
    REP(i, n) cin >> A[i];
    REP(i, n) cin >> B[i];

    long long a = 0, b = 0;
    REP(i, n){
        if(A[i] < B[i]) a += (B[i] - A[i]) / 2;
        else b += A[i] - B[i];
    }
    
    if(a >= b) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
S = list(input())

a =  10 * int(S[0]) +int( S[1])
b =  10 * int(S[2]) + int(S[3])

def judge(x):
    if (1 <= x <= 12):
        return "MM"
    else:
        return"YY"

if ((judge (a) == "YY" )and (judge (b) == "YY" )):
    print("NA")
elif ((judge (a) == "YY" )and (judge (b) == "MM" )):
    print("YYMM")
elif((judge (a) == "MM" )and (judge (b) == "YY" )):
    print("MMYY")
else:
    print("AMBIGUOUS")

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

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

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    bool ok = false;
    char tmp = S[0];
    rep(i,S.size()){
        if(tmp != S[i]){
            ok = true;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
typedef long long ll;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<bool>> c(h, vector<bool>(w));
  for(int i = 0; i < h; i ++){
    string s; cin >> s;
    for(int j = 0; j < w; j ++){
      c[i][j] = s[j] == '#';
    }
  }
  int ans = 0;
  for(int msk = 0; msk < (1LL << h + w); msk ++){
    auto d = c;
    for(int i = 0; i < h; i ++){
      if((1LL << i) & msk){
        for(int j = 0; j < w; j ++)
          d[i][j] = 0;
      }
    }
    for(int i = h; i < h + w; i ++){
      if((1LL << i) & msk){
        for(int j = 0; j < h; j ++)
          d[j][i - h] = 0;
      }
    }
    int sum = 0;
    for(int i = 0; i < h; i ++)
      for(int j = 0; j < w; j ++)
        sum += d[i][j];
    if(sum == k)
      ans ++;
  }
  cout << ans;
}


Measured memory_bytes: 3652
N = int(input())
para = [i for i in map(int,input().split())]
"""
全ての与えられた数の２で割り切れる回数の合計を出力すれば良い？
"""
ans = 0
for i in para :
    while True :
        k = 1
        if i % 2 == 0 and i > 0:
            i = i // 2 
            ans += 1
        else : break 
print(ans)

Measured memory_bytes: 4212
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int H, W, K;
	cin >> H >> W >> K;
	vector<vector<int>> ans(H, vector<int>(W));
	int now = 1;
	vector<int> nostrawberry(H);
	for (int i = 0; i < H; i++) {
		int last = -1;
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			ans[i][j] = now;
			if (c == '#') {
				last = j;
				now++;
			}
		}
		if (last == -1) nostrawberry[i] = 1;
		if (last <W-1) for (int j = last+1; j < W; j++) ans[i][j] = now-1;
	}
	int last = 0;
	for (int i = 0; i < H; i++) {
		if (nostrawberry[i] == 0) {
			for (int j = last; j < i; j++) ans[j] = ans[i];
			last = i + 1;
		}
	}
	if (last < H) {
		for (int j = last; j < H; j++) ans[j] = ans[last-1];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) cout << ans[i][j] << (j<W-1 ? " " : "\n");
	}
}


Measured memory_bytes: 1152
#include <stdio.h>

char s[100];
int main() {
  scanf("%s", s);
  int ok = 1;
  int l = 0;
  while (s[l] != 0) {
    l++;
  }
  for (int i = 0; i < l / 2; i++) {
    if (s[i] != s[l-1-i]) {
      ok = 0;
      break;
    }
  }
  for (int i = 0; i < (l-1) / 2 / 2; i++) {
    if (s[i] != s[l/2-1-i]) {
      ok = 0;
      break;
    }
  }

  printf("%s", ok ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 128
import re

N, A, B, C, D = map(int, input().split())
S = input()
S = '#' + S
flag = True
if re.search(r'##', S[min([A,B]): max([C,D])+1]):
    flag *= False

if D < C:
    if re.search(r'\.\.\.', S[B-1:D+2]):
        flag *= True
    else:
        flag *= False
        
print('Yes') if flag else print('No')

Measured memory_bytes: 41328