akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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;
}

vector<int> as;
vector<int> bs;

vector<ll> ss_a;
vector<ll> ss_b;

int main(void) {
    int N, M;
    ll K;
    cin >> N >> M >> K;

    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
    }

    bs.resize(M);
    for (int i = 0; i < M; i++) {
        cin >> bs[i];
    }

    ss_a.resize(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        ss_a[i] = ss_a[i - 1] + as[i - 1];
    }

    ss_b.resize(M + 1, 0);
    for (int i = 1; i <= M; i++) {
        ss_b[i] = ss_b[i - 1] + bs[i - 1];
    }

    int ans = 0;

    for (int num_a = 0; num_a <= N; num_a++) {
        const ll acc_a = ss_a[num_a];
        ll rem = K - acc_a;
        int cand = num_a;
        if (rem >= 0) {
            auto it_b = upper_bound(ss_b.begin(), ss_b.end(), rem);
            it_b--;
            cand += (int) distance(ss_b.begin(), it_b);
            chmax(ans, cand);
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
    int a, p;
    cin >> a >> p;
    int ans = (3*a + p)/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;
typedef double D;

const D rd = acos(-1.0)/180.0;
const D r = 6378.1;

struct P3D {
    D x,y,z;
    P3D(D lat, D lon){
        x = cos(lat*rd)*cos(lon*rd);
        y = cos(lat*rd)*sin(lon*rd);
        z = sin(lat*rd);
    }
    D dist(const P3D &p){
        return (x-p.x)*(x-p.x) + (y-p.y)*(y-p.y) + (z-p.z)*(z-p.z);
    }
};

int main(){
    D a,b,c,d;
    while(cin>>a>>b>>c>>d){
        if(a<0 && b<0 && c<0 && d<0) break;
        P3D p1(a, b), p2(c, d);

        // 直線距離
        D c2 = p1.dist(p2);
        // 余弦定理(a^2 + b^2 -2ab cos(C) = c^2 )
        cout << (int)(r * acos(1-c2/2) + 0.5) << endl;
    }
    return 0;
}

Measured memory_bytes: 1272
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt();
        final long K = sc.nextLong();
        int[] teleport = new int[N];
        for(int i=0; i<N; i++) {
            teleport[i]=sc.nextInt()-1;
        }

        boolean[] clear = new boolean[N];
        clear[0] = true;

        List<Integer> list = new ArrayList<Integer>();
        list.add(0);

        int twice = -1;

        for(int i=0; i<K; i++) {
            int x= teleport[list.get(i)];
            if(clear[x]) {
                twice = x;
                break;
            }else {
                list.add(x);
                clear[x] = true;
            }
        }

        if(twice==-1) {
            System.out.println(list.get((int)K)+1);
        }else {
            int num =0;
            while(!list.isEmpty()) {
                if(list.get(0)==twice) {
                    break;
                }else {
                    list.remove(0);
                    num++;
                }
            }
            System.out.println(list.get((int)((K-num)%list.size()))+1);
        }
    }

}


Measured memory_bytes: 60252
def main():
    N = int(input())
    A = [int(a) for a in input().split()]

    sum_A = [0] + [0 for i in range(N + 1)]

    for i in range(1, N + 1):
        sum_A[i] = sum_A[i - 1] + A[i - 1]

    A = [0] + A
    ans = 0

    for i in range(1, N):
        ans += (A[i] * (sum_A[N] - sum_A[i]))

    print(ans % (10**9 + 7))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 31316
#include <bits/stdc++.h> 
#define ll long long
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x; cin >> x;
    if (x == 0) {
        cout << "1";
    }
    else if (x == 1) {
        cout << "0";
    }
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

main()


{


int a,b,c,x,y,z;


scanf("%d%d%d",&a,&b,&c);


if(a > b){

x = a;


a = b;


b = x;


}


if(b > c){


y = b;


b = c;


c = y;


}


if(a > b){


z = a;


a = b;


b = z;


}


printf("%d %d %d\n",a,b,c);


return 0;


}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    vector<ll> v;
    while(n>0){
        v.push_back(n%2);
        n/=2;
    }
    reverse(v.begin(),v.end());
    ll u=v.size();
    ll dp[u][3];
    rep(i,0,u)rep(j,0,3)dp[i][j]=0;
    dp[0][0]=1;
    dp[0][1]=1;
    rep(i,0,u-1){
        dp[i+1][2]+=dp[i][2]*3;
        dp[i+1][2]%=mod;
        dp[i+1][0]+=dp[i][0];
        dp[i+1][0]%=mod;
        dp[i+1][1]+=dp[i][1];
        dp[i+1][1]%=mod;
        if(v[i+1]==1){
            dp[i+1][1]+=dp[i][0];
            dp[i+1][1]%=mod;
            dp[i+1][2]+=dp[i][1]*2;
            dp[i+1][2]%=mod;
        }
        else{
            dp[i+1][0]+=dp[i][1];
            dp[i+1][0]%=mod;
            dp[i+1][2]+=dp[i][1];
            dp[i+1][2]%=mod;
        }
    }
    ll ans=dp[u-1][0]+dp[u-1][1]+dp[u-1][2];
    cout<<ans%mod<<endl;
    rep(i,0,u){
        //rep(j,0,3)cout<<dp[i][j]<<" ";
       // cout<<endl;
    }
}


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

signed main() {
  int a, b, c; cin >> a >> b >> c;
  bool ans = false;

  for(int i = a; i <= a*b; i += a) {
    if(i%b == c) ans = true;
  }
  cout << (ans ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

int a[100];

int main(){
    int n;
    cin >> n;
    rep(i,n){
        cin >> a[i];
    }

    sort(a, a + n, greater<int>());  	//降順

    int player[2] = {0};
    rep(i,n){
        player[i % 2] += a[i];
    }

    cout << player[0] - player[1] << endl;

    return 0;

}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k = 0;
string s, t;



int main()
{
	bool z = true;
	
	int n, m;
	cin >> n >> m;
	int x[3] = { -1,-1,-1 };
	rep(i, m)
		{
			cin >> a >> b;
			if (n!=1&&a==1 && b==0)
			{
				z = false;
			}
			if (x[a-1+3-n] != -1&&x[a-1+3-n]!=b)
			{
				z = false;
			}
			else
				x[a-1+3-n] = b;
		}
	rep(i, 3)
		{
			if (x[i] == -1)
				x[i] = 0;
		}
	if (z)
	{
		if (x[0] != 0)
			cout << x[0] * 100 + x[1] * 10 + x[2] << endl;
		else if (n == 3)
			cout << 100 + x[1] * 10 + x[2] << endl;
		else if (n == 2&&x[1]==0)
			cout << 10 + x[2] << endl;
		else if (n == 2 && x[1] != 0)
			cout<<x[1] * 10 + x[2] << endl;
		else
			cout << x[2] << endl;
	}
	else
		cout << -1<<endl;
		
	return 0;
}

Measured memory_bytes: 256
bldgs = []
for k in range(4):
    bldgs.append([[0 for i in range(10)] for j in range(3)])

n = int(input())
for i in range(n):
    b,f,r,v = map(int, input().split(' '))
    bldgs[b-1][f-1][r-1] += v

for i, bldg in enumerate(bldgs):
    if i > 0:
        print('#'*20)

    for floor in bldg:
        print(' '+' '.join([str(f) for f in floor]))

Measured memory_bytes: 7712
#include<iostream>
#include<map>
using namespace std;
int n;
long m,a[1<<17];
map<long,int>M;
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i];
	M[0]++;
	long ans=0,sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=a[i];
		sum%=m;
		ans+=M[sum]++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 4992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
using namespace std;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	int K; cin >> K;
	int cnt = 0;
	while (b <= a) {
		b *= 2;
		cnt++;
	}

	while (c <= b) {
		c *= 2;
		cnt++;
	}


	if (cnt > K) {
		pNo;
	}
	else {
		pYes;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vector<P> A(N);
  rep(i,N) {
    cin >> A[i].first;
    A[i].second=i+1;
  }
  sort(A.begin(),A.end());
  rep(i,N) cout << A[i].second << ' ';
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
const int N =1e5+6;
const int M =1e9+7;
const double eps =1e-7;
#define go_baby_go ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long
#define pb push_back
#define PQ priority_queue
#define pii pair<int,int>
#define vi vector<int>
int a[N],b[N];
int Int(){int x;scanf("%d",&x);return x;}
ll Lnt(){ll x;scanf("%I64d",&x);return x;}
#define Int Int()
#define Lin Lnt()
ll Bigmod(ll A,ll B,ll C)
{
     if(B==0LL)return 1LL;
     ll x=Bigmod(A,B/2LL,C);
     x=(x*x)%C;
     if(B%2==1)
     x=(x*A)%C;
     return x;
}
struct mar
{
     int i,j;
}cr[N];
bool cmp(mar a,mar b){
     if(a.i==b.i)
     return a.j<b.j;
     return a.i<b.i;
}
bool Cmp(int a,int b){return a>b;}
void print(int n){printf("%d\n",n);}
void Print(ll n){printf("%I64d\n",n);}
void debug(int n){printf("%d ",n);}
int polygon(int p,int n)
{
     int mx=INT_MIN;
     for(int i=1;i<=p;i++)
     {
          int u=0;
          for(int j=i;j<=n;j+=p)
          {
               u+=a[j];
          }
          if(n/p>2)
          mx=max(mx,u);
     }
     return mx;
}
int ispolygon(int n)
{
     int i,sqr=sqrt(n),mx=0;
     for(i=1;i<=sqr;i++)
     {
          if(n%i==0)
          {
               mx=max(mx,polygon(i,n));
               mx=max(mx,polygon(n/i,n));
          }  
     }
     return mx;
}
int digit()
{
     int n=Int,i,t=n;
     int p=0;
     while(n--)
     {
          int x=Int;
          a[x]=a[x-1]+1;
          p=max(p,a[x]);
     }
     return t-p;
}
int main()
{
     int n=3,i=0;
     while(n--)
     {
          a[i++]=Int;
     }
     sort(a,a+3);
     cout<<a[0]+a[1];
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

str l;
vi one;
int n;
ll md = 1000000007;
ll p3[100100];
bool hitung[100100];
ll nex[100100];
ll pow3(ll x){
    if(x==0)return 1;
    else if(x==1)return 3;
    else if(hitung[x])return p3[x];
    else{
        ll temp = pow3(x/2);
        ll res = (((temp%md) * (temp%md))%md);
        if(x%2==1){
            res = ((res%md) * (3%md))%md;
        }
        hitung[x]=true;
        p3[x] = res;
        return res;
    }
}
bool calc[100100];
ll memo[100100];
ll dp (ll x){
    if(x>n)return 1;
    else if(calc[x])return memo[x];
    else{
        ll sisa = n - x;
        ll a,b;
        a = pow3(sisa);
        b = ((2%md) * (dp(nex[x])%md))%md;
        ll res = ((a%md + b%md))%md;
        calc[x]=true;
        memo[x]=res;
        return res;
    }
}
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>l;
    for(int i=0;i<l.size();i++){
       if(l[i]=='1'){one.pb(i+1);}
    }
    n = l.size();
    one.pb(n+1);
    for(int i=0;i<one.size()-1;i++){
        nex[one[i]] = one[i+1];
    }

    ll ans = dp(one[0]);
    cout<<ans<<newl;

}


Measured memory_bytes: 6600
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


fn main() {
    let n = read::<usize>();
    let h = read_vec::<i32>();

    let mut dist_max = 0;
    let mut dist = 0;
    let mut prev = 0;
    for i in 0..n {
        if h[i] <= prev {
            dist += 1;
            if i == n -1 {
                if dist > dist_max {
                    dist_max = dist;
                }
            }
        } else {
            if dist > dist_max {
                dist_max = dist;                
            }
            dist = 0;
        }
        prev = h[i];
    }
    println!("{}", dist_max);
}


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

#define LEN 13

long long f(char* p)
{
	int lp = strlen(p);
	long long n = 0;
	for ( int i = 0 ; i < lp ; i++ )
		n = (n*10)+(p[i]-48);
	return n;
}

int main()
{
	char aa[LEN];
	char bb[LEN];
	char kk[LEN];
	scanf("%s",aa);
	scanf("%s",bb);
	scanf("%s",kk);

	long long a = f(aa);
	long long b = f(bb);
	long long k = f(kk);

	if ( a > k ) {
		printf("%lld %lld",(long long)(a-k),b);
	} else {
		k -= a;
		if ( b > k ) {
			printf("0 %lld",(long long)(b-k));
		} else {
			printf("0 0");
		}
	}

}


Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<i64>();
    let big_int = 1000_000_000 + 7;
    let (l, r) = (v[0], v[1]);

    let digit_num = format!("{:b}", r).chars().collect::<Vec<_>>().len() + 1;

    let mut dp = vec![vec![vec![vec![0; 2]; 2]; 2]; digit_num + 1];
    dp[0][0][0][0] = 1;
    for i in 0..digit_num {
        let r_bit = (r >> (digit_num - 1 - i)) & 1;
        let l_bit = (l >> (digit_num - 1 - i)) & 1;
        for r_assured in 0..2 {
            for l_assured in 0..2 {
                for max_samed in 0..2 {
                    for x in 0..2 {
                        for y in 0..2 {
                            if x == 1 && y == 0 {
                                continue;
                            }
                            if max_samed == 0 && x != y {
                                continue;
                            }
                            let mut nm = max_samed;
                            if x == 1 && y == 1 {
                                nm = 1;
                            }
                            if x == 0 && l_assured == 0 && l_bit == 1 {
                                continue;
                            }
                            let mut nl = l_assured;
                            if l_bit == 0 && x == 1 {
                                nl = 1;
                            }
                            if r_assured == 0 && y == 1 && r_bit == 0 {
                                continue;
                            }
                            let mut nr = r_assured;
                            if r_bit == 1 && y == 0 {
                                nr = 1;
                            }

                            dp[i + 1][nl][nr][nm] += dp[i][l_assured][r_assured][max_samed];
                            dp[i + 1][nl][nr][nm] %= big_int;
                        }
                    }
                }
            }
        }
    }
    debug!(dp);
    let mut ans = 0i64;
    for l in 0..2 {
        for r in 0..2 {
            for m in 0..2 {
                ans += dp[digit_num][l][r][m];
                ans %= big_int;
            }
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n1) for(int i=0;i<n1;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define yesno(flg) if(flg){cout<<'YES'<<endl;}else{cout<<'NO'<<endl;}
#define vi vector<int>
#define pb push_back
#define i197 1000000007
#define MAX_N 200002
#define PI 3.141592653589793
using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<Pii,int> Piii;
typedef pair<int,ll> Pil;
typedef pair<ll,ll> Pll;
typedef pair<string,int> Psi;
typedef pair<Psi,int> Psii;

const ll inf=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

vector<Pii> v[100001];
int dp[100000][3]={};
ll dp2[300000][60]={};
int main() {
	int n,k,r,s,p;
	string t;
	cin>>n>>k>>r>>s>>p>>t;
	int res=0;
	rep(i,k){
		int dp[2][3]={};
		for(int j1=i;j1<n;j1=j1+k){
			dp[1][0]=max(dp[0][1],dp[0][2]);
			dp[1][1]=max(dp[0][0],dp[0][2]);
			dp[1][2]=max(dp[0][0],dp[0][1]);
			if(t[j1]=='r')dp[1][2]+=p;
			if(t[j1]=='s')dp[1][0]+=r;
			if(t[j1]=='p')dp[1][1]+=s;
			dp[0][0]=dp[1][0];
			dp[0][1]=dp[1][1];
			dp[0][2]=dp[1][2];
		}
		res+=max(dp[0][0],max(dp[0][1],dp[0][2]));
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 3328
using System.Linq;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(a.Sum() >= h ? "Yes" : "No");
    }
}


Measured memory_bytes: 16992
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

#define int long long
signed main() {
	string ss; getline(cin, ss, '\n');
	string ts; getline(cin, ts, '\n');
	long long n = ss.size(), m = ts.size();

	int s[n], t[m];
	REP(i, 0, m) t[i] = ts[i] - 'a';
	REP(i, 0, n) s[i] = ss[i] - 'a';
	vector<int> freq[27];
	REP(i, 0, n) freq[s[i]].push_back(i);
	
	bool flag = 0;
	REP(i, 0, m) flag |= freq[t[i]].empty();

	if (flag) {
		cout << -1;
		return 0;
	}

	int prev = -1;
	long long ans = 0;
	REP(i, 0, m) {
		auto it = upper_bound(freq[t[i]].begin(), freq[t[i]].end(), prev);
		if (it != freq[t[i]].end())
			prev = *it;
		else {
			++ans;
			prev = freq[t[i]][0];
		}
	}

	cout << ans * n + prev + 1LL;
}

Measured memory_bytes: 3260
#include <stdio.h>

int main(void){
  int N,M,X;
  scanf("%d%d%d",&N,&M,&X);
  int data[N+1],sample;
  int cost = 0,ans;

  for(int i = 0;i < N+1;i++){
    data[i] = 0;
  }

  for(int i = 0;i < M;i++){
    scanf("%d",&sample);
    data[sample] = 1;
  }

  cost = 0;
  for(int i = 0;i < X;i++){
    if(data[i] == 1){
      cost++;
    }
  }
  ans = cost;

  cost = 0;
  for(int i = X;i < N+1;i++){
    if(data[i] == 1){
      cost++;
    }
  }

  if(ans > cost){
    ans = cost;
  }

  printf("%d\n",ans);

  return 0;
}

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

int main(){
  int begin,end;
  string s; cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='A'){
      begin=i;
      break;}}
  for(int j=s.size()-1;j>=0;j--){
    if(s[j]=='Z'){
      end=j;
      break;}}
  cout<<end-begin+1<<endl;
  return 0;
}

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

int main() {
    int n,m;
    vector<vector<int>> sw_tbl(10);
    vector<int> sw_on_list(10);

    cin >> n >> m;
    rep(i,m){
        int k;
        cin >> k;
        rep(j,k){
            int swk;
            cin >> swk;
            sw_tbl.at(i).push_back(swk);
        }
    }
    rep(i,m){
        cin >> sw_on_list.at(i);
    }

    int total = 0;

    for(int bit=0;bit<(1<<n);bit++){
        vector<int> state(n);
        rep(i,n){
            if(bit & (1<<i)){
                state.at(i) = 1;
            }
            else {
                state.at(i) = 0;
            }
        }

        bool light_ok = true;
        rep(i,m){
            int sum1 = 0;
            rep(j,sw_tbl.at(i).size()){
                // sw_tbl.at(i) i番目の電球のスイッチ
                sum1 += state[sw_tbl.at(i).at(j)-1];
            }
            if((sum1 % 2) != sw_on_list.at(i)){
                light_ok = false;
                break;
            }
        }
        if(light_ok){
            total++;
        }
    }
    cout << total << endl;

    return 0;
}



Measured memory_bytes: 256
from sys import stdin,stdout
# from math import pi
# from collections import deque
# from heapq import heappush,heappop
Pi = lambda x: stdout.write(str(x) + '\n')
Ps = lambda x: stdout.write(str(x))
S = lambda x: x*(x+1) // 2
I = lambda x: 1+(2*x)
R = lambda:stdin.readline()
Ri = lambda x:map(int,x.split())
Rs = lambda x:map(str,x.split())
Rf = lambda x:map(float,x.split())
char = lambda x,y:ord(x) - ord(y) 
gcd = lambda a,b: a if b==0 else gcd(b, a%b) 
lcm = lambda a,b: a * b // gcd(a, b)
# find = lambda u,par: u if u==par[u] else find(par[u],par)
distance = lambda a,b,c,d: ((a-c)**2) + ((b-d)**2)
# distance = lambda a,b,c,d: (abs(a-c)) + (abs(b-d))
MaxN = int(1e6) + 10
mod = int(1e9) + 7
# global fx,fy
# fx = [-2, -2, -1, -1,  1, 1,  2, 2]
# fy = [-1,  1, -2,  2, -2, 2, -1, 1]
# fx,fy = [0,0,-1,1],[1,-1,0,0]
 
def main():             
    for x in stdin:     
        if x=='\n':continue    
        n = int(x)
        ans = 1
        while (ans*n)%360!=0:
        	ans += 1
        Pi(ans)

if __name__ == '__main__':
       	main()       

Measured memory_bytes: 61884
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        
    int cnt = 0;

	int  i1 = 0 ,i2 = 0, i3 = 0;
	long L1 = 0, L2 = 0, L3 = 0;
	char ch;
	String str = "";
		
    String s3 = sc.next();
    String s1 = sc.next();
    char[] c1 = s1.toCharArray();



        System.out.print("A"+ c1[0] +"C");
        System.out.println();
	}
        
}

Measured memory_bytes: 10064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int cnt = 1;
    int cnt2 = 0;
    while(cnt < N) {
        cnt *= 2;
        cnt2++;
    }
    cnt2 += 100;
    if(K >= cnt2) {
        for(int i = 0;i < N;i++) {
            cout << N << " ";
        }
        cout << endl;
    }
    else {
        vector<int> ret = vec;
        for(int i = 0;i < K;i++) {
            vector<int> cnt(N + 1);
            for(int j = 0;j < N;j++) {
                cnt.at(max(0,j - ret.at(j)))++;
                if(j + ret.at(j) + 1 <= N) {
                    cnt.at(j + ret.at(j) + 1)--;
                }
            }
            for(int j = 0;j < N;j++) {
                cnt.at(j + 1) += cnt.at(j);
            }
            for(int j = 0;j < N;j++) {
                ret.at(j) = cnt.at(j);
            }
        }
        for(int i = 0;i < N;i++) {
            cout << ret.at(i) << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 5584
#include <iostream>
#include <cstdio>
int main(){
	int n,x,i;
	std::cin>>n;
	for(i=1;i<=n;i++){
		x=i;
		if(x%3==0 || x%10==3)
			std::cout<< " " <<i;
		else{
			while(x){
				x/=10;				
			if(x%10==3)break;			
				}
			if(x%10==3)
				std::cout<< " " <<i;		
			}
	}
	std::cout<<std::endl;
	return 0;
}

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

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

  if (abs(a - c) <= d || (abs(a - b) <= d && abs(c - b) <= d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.util.Scanner;
import java.util.OptionalInt;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int M = in.nextInt();
            int[] L = new int[M];
            int[] R = new int[M];
            for (int i = 0; i < M; i++) {
                L[i] = in.nextInt();
                R[i] = in.nextInt();
            }
            int Lmax = Arrays.stream(L).max().getAsInt();
            int Rmin = Arrays.stream(R).min().getAsInt();
            int ans = Rmin - Lmax + 1;
            out.println(ans < 0 ? 0 : ans);
        }

    }
}



Measured memory_bytes: 85424
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split())))

ans = 0
for i in range(N):
    temp = C
    for j in range(M):
        temp += A[i][j] * B[j]
    if temp > 0:
        ans += 1

print(ans)


Measured memory_bytes: 9012
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ret += x;
  }
  for (int i = 1; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 1; i < n; ++i) {
    if (a[i] == a[i - 1] + 1) {
      ret += b[a[i - 1]];
    }
  }
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int xx = sc.nextInt();
		
		int hyaku = (int)xx / 100;
		int sum = 0;
		int tmp;
		
		tmp = xx % 100;
		
		sum = sum + (int)tmp / 5;
		tmp = tmp % 5;
	
		sum = sum + (int)tmp / 4;
		tmp = tmp % 4;
		sum = sum + (int)tmp / 3;
		tmp = tmp % 3;
		sum = sum + (int)tmp / 2;
		tmp = tmp % 2;
		sum = sum + (int)tmp / 1;
		tmp = tmp % 1;
		
		if (hyaku >= sum){
			System.out.print("1");
		}else{
			System.out.print("0");
		}
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>

const int MAX_N = 10000;

int main() {
  int n = 0;
  int numbers[MAX_N] = {0};

  std::cin >> n;

  int count = n;

  for (int i = 0; i < n; i++) {
    int x = 0;

    std::cin >> x;

    if (x == 2) {
      continue;
    }
     
    if ((x > 2) && ((x % 2) == 0)) {
      count--;
    } else {
      numbers[i] = x;
    }
  }

  for (int i = 0; i < n; i++) {
    if (numbers[i] == 0) {
      continue;
    }
    
    int v = numbers[i];
    int max = std::sqrt(v);

    for (int j = 3; j <= max; j += 2) {
      if ((v % j) == 0) {
	count--;
	numbers[i] = 0;
	  
	break;
      }
    }
  }

  // for (int i = 0; i < n; i++) {
  //   std::cout << numbers[i] << std::endl;
  // }

  std::cout << count << std::endl;
  
  return 0;
}

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

int main(void) {
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);
    ll n, w;
    cin >> n >> w;

    vector<ll> weight(n);
    vector<ll> value(n);

    for (ll i = 0; i < n; i++) {
        cin >> weight[i];
        cin >> value[i];
    }

    vector<vector<ll>> dp (n*VALMAX + 1, vector<ll> (n, INT_MAX));

    dp[value[n-1]][n-1] = weight[n-1];
    dp[0][n-1] = 0;

    for (ll j = n-2; j >= 0; j--) {
        // j is the item
        for (ll i = 0; i < n*VALMAX+1; i++) {
            // i is the value
            if (value[j] > i) {
                dp[i][j] = dp[i][j+1];
            } else {
                ll one = dp[i][j+1];
                ll two = dp[i - value[j]][j+1];
                if (two < INT_MAX) {
                    two = two + weight[j];
                }

                dp[i][j] = min(one, two);
            }
        }
    }

    // for (ll i = 0; i < 21; i++) {
    //     for (ll j = 0; j < n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    ll best = 0;
    for (ll i = n*VALMAX; i >= 0; i--) {
        if (dp[i][0] <= w) {
            best = i;
            break;
        }
    }
    cout << best << endl;

    

    return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

double power (double a, int n) {
    double r;
    int    abs_n;

    r = 1;

    abs_n = n < 0 ? -n : n;

    while (0 < abs_n) {
        if (abs_n % 2 == 1) r *= a;

        a *= a;
        abs_n /= 2;
    }

    return n >= 0 ? r : 1 / r;
}

double nthroot (double a, int n) {
    double x, y;

    if (a <= 0 || n < 0) return 0;
    if (n == 0) return 1;

    /* When 0 < a and 0 < n */
    y = (1 < a) ? a : 1;

    do {
        x = y;
        y = ((n - 1) * x + a / power (x, n - 1)) / n;
    } while (y < x);

    return y;
}

// is_power
// power number or not
// (squared number, cubic number, uadruple number, etc.)
bool isPower (int a) {
    if (a == 1) return 1;

    FOR (i, 2, (int)floor (log2 (a))) {
        if ((int)power (floor (nthroot (a, i)), i) == a) return true;
    }

    return false;
}

int main() {
    int X;

    cin >> X;

    for (int i = X; 0 <= i; i--) {
        if (isPower (i)) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

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

const int N = 2e5 + 10;

int a[N];

inline int read()
{
    int x = 0;
    char ch = getchar();
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x;
}

inline int check(int k, int n)
{
    for (int i = 0; i < n - 1; ++i)
    {
        if (a[n + i] >  k && a[n + i + 1] >  k || a[n - i] >  k && a[n - i - 1] >  k) return 0;
        if (a[n + i] <= k && a[n + i + 1] <= k || a[n - i] <= k && a[n - i - 1] <= k) return 1;
    }
    return a[1] <= k;
}

int main()
{
    int n = read() * 2 - 1;
    for (int i = 1; i <= n; ++i) a[i] = read();
    int l = 1, r = n, res = 0;
    while (l <= r)
    {
        int mid = (l + r) >> 1;
        if (check(mid, n + 1 >> 1)) res = mid, r = mid - 1; else l = mid + 1;
    }
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 4388
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {
	ll N,f=0,t=0,n=0;
	string an = "No";
	cin >> N;
	rep(i, N) {
		ll a;
		cin >> a;
		if (a %2 != 0) {
			n++;
		}
		else if (a % 4 == 0) {
			f++;
		}
		else {
			t++;
		}
	}
	if (n <= f ) {
		an = "Yes";
	}
	if (n == 1 + f && t == 0) {
		an = "Yes";
	}
	
	cout << an << endl;
	
}


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

using namespace std;

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

const int mo = 1e9 + 7;
int dp[100010][13];
string s;

signed main()
{
	cin >> s;

	int n = s.size();

	dp[0][0] = 1;

	rep(i, n) {
		if (s[i] == '?') {
			rep(j, 10) {
				rep(k, 13) {
					dp[i+1][(k * 10 + j) % 13] += dp[i][k];
					dp[i+1][(k * 10 + j) % 13] %= mo;
				}
			}
		} else {
			int d = s[i] - '0';

			rep(j, 13) {
				dp[i+1][(j*10 + d) % 13] += dp[i][j];
				dp[i+1][(j*10 + d) % 13] %= mo;
			}
		}
	}

	cout << dp[n][5] << endl;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
 
int main() {
	int n,m,L,R,i;
  	cin >> n>>m;
    vector<int> l(m);
  	vector<int> r(m);
	for (int i = 0; i < m; i++) {
  		cin >> l.at(i)>>r.at(i);
	}
  	L=l.at(0);
  	R=r.at(0);
  	i=1;
  	while (i < m) {
    	if(L<l.at(i)){L=l.at(i);}
    i++;
  	}
  	i=1;
  	while (i < m) {
    	if(R>r.at(i)){R=r.at(i);}
    i++;
  	}
  	if(R-L+1<0){cout<<"0"<<endl;}
  	else{
  	cout<<R-L+1<<endl;}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,x=0,ans=0;
  string S;
  cin>>N>>S;
  for(int i=0;i<N;i++){
    if(S.at(i)=='I') x++;
    else if(S.at(i)=='D') x--;
    ans=max(ans,x);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<string>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    string s;
    cin >> s;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5))
        cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include <random>
#define ll long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const int INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h,w,n;
    cin>>h>>w>>n;
    ll x,y;
    cin>>x>>y;
    x--;y--;
    string s,t;
    cin>>s>>t;
    ll left=0,right=w-1;
    reverse(all(s));
    reverse(all(t));
    if(s[0]=='R') right--;
    if(s[0]=='L') left++;
    rep2(i,1,n){
        if(t[i]=='L') right=min(right+1,w-1);
        else if(t[i]=='R') left=max(left-1,0LL);
        if(s[i]=='L') left++;
        else if(s[i]=='R') right--;
        if(left>right){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(y<left||right<y){
        cout<<"NO"<<endl;
        return 0;
    }
    left=0,right=h-1;
    if(s[0]=='U') left++;
    if(s[0]=='D') right--;
    rep2(i,1,n){
        if(t[i]=='U') right=min(right+1,h-1);
        else if(t[i]=='D') left=max(left-1,0LL);
        if(s[i]=='D') right--;
        else if(s[i]=='U') left++;
        if(left>right){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(x<left||right<x){
        cout<<"NO"<<endl;
        return 0;
    }
    cout<<"YES"<<endl;
    return 0;
}


Measured memory_bytes: 920
#include <atcoder/dsu>
#include <cstdio>

using namespace std;
using namespace atcoder;

int main() {
    int n, q;
    scanf("%d %d", &n, &q);
    dsu d(n);
    for (int i = 0; i < q; i++) {
        int t, u, v;
        scanf("%d %d %d", &t, &u, &v);
        if (t == 0) {
            d.merge(u, v);
        } else {
            if (d.same(u, v)) {
                printf("1\n");
            } else {
                printf("0\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3416
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int N;
bool C[100000];
vector<int> A;

int main() {
  cin >> N;
  int c;
  for (int i=0; i<N; i++) {
    int a; cin >> a;
    a--;
    if (!C[a]) {
      C[a] = true;
      A.push_back(a);
    }
    else {
      c++;
    }
  }
  sort(A.begin(), A.end());
  int t = (c+1) / 2;
  cout << N - t*2 << "\n";
  return 0;
}


Measured memory_bytes: 892
from math import acos,sin,cos,radians
while 1:
    a,b,c,d=map(float,input().split())
    if a==b==c==d==-1:break
    a,c=radians(a),radians(c)
    print(int(6378.1*acos(sin(a)*sin(c) + cos(a)*cos(c)*cos(radians(d)-radians(b)))+0.5))

Measured memory_bytes: 7808
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC_110_B solver = new ABC_110_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_110_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[] x = new int[n + 1];
            int[] y = new int[m + 1];

            x[0] = in.nextInt();
            y[0] = in.nextInt();

            for (int i = 1; i < n + 1; i++) {
                x[i] = in.nextInt();
            }

            for (int i = 1; i < m + 1; i++) {
                y[i] = in.nextInt();
            }
            Arrays.sort(x);
            Arrays.sort(y);

            if (y[0] <= x[x.length - 1]) {
                out.print("War");
            } else {
                out.print("No War");
            }
        }

    }
}



Measured memory_bytes: 23764
import numpy as np
from collections import defaultdict
from functools import reduce

# s = input()
n = int(input())
w = list(map(int, input().split()))

print(min(abs(sum(w[:i]) - sum(w[i:])) for i in range(n)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res



Measured memory_bytes: 21560
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
	char x,y;
	cin >> x >> y;
	if ((x == 'H' && y == 'H' )||( x == 'D' && y == 'D')) {
		cout << "H" << endl;
	}
	else {
		cout << "D" << endl;
	}
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
//const ll MOD=1000000007;
//const ll MOD2=998244353;
//const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll H,W,M;
    cin >> H >> W >> M;
    vl h(M),w(M);
    vl cnt0(H),cnt1(W);
    ll mxh=0,mxw=0;
    rep(i,M){
        cin >> h[i] >> w[i];
        h[i]--;w[i]--;
        cnt0[h[i]]++;cnt1[w[i]]++;
        chmax(mxh,cnt0[h[i]]),chmax(mxw,cnt1[w[i]]);
    }
    ll nowh=0,noww=0;
    rep(i,H){
        if(cnt0[i]==mxh){
            nowh++;
        }
    }
    rep(i,W){
        if(cnt1[i]==mxw){
            noww++;
        }
    }
    ll now=0;
    rep(i,M){
        if(cnt0[h[i]]==mxh&&cnt1[w[i]]==mxw){
            now++;
        }
    }
    //cout << now << ' ' << nowh << ' ' << noww << '\n';
    cout << (now==nowh*noww?mxh+mxw-1:mxh+mxw) << '\n';
}
/*
overflow checked?
corner case checked?
boundary checked?
not TLE in worst case checked?
*/


Measured memory_bytes: 12680