akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>

using namespace std;
using ll = long long int;

int main(){
    string S,T;
    cin>>S>>T;
    int A,B;
    cin>>A>>B;
    string U;
    cin>>U;
    if(U==S) cout<<A-1<<" "<<B<<endl;
    else cout<<A<<" "<<B-1<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
ll N, K, T, W, H, M, C;
 
const int MAX = 5100000;
const int MOD = 1e9 + 7;
 
const double PI=3.14159265358979323846;
 
 
long long fac[MAX], finv[MAX], inv[MAX];
 
vector<double> cx, cy, c;
 ll MM = 1e12;
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}
 
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
 
ll lcm(ll a, ll b)
{
   return a * b / gcd(a, b);
}
 
 
 
int main(){
    cin >> K;
    ll ans = 0;
    for(int i = 1; i <= K; ++i){
        for(int j = 1; j <= K ; ++j){
            for(int k = 1; k <= K; ++k){
                ans += gcd(i , gcd(j,k));
                //cout << ans ;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool d[8][8];

int main() {
    int n,m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin >> a >> b;
        a--,b--;
        d[a][b] = 1;
        d[b][a] = 1;
    }
    vector<int> o(n);
    for (int i = 0; i < n; ++i) o[i] = i;
    int ans = 0;
    do{
        if(o[0] != 0) break;
        bool ok = 1;
        for (int i = 0; i < n-1; ++i) {
            if(!d[o[i]][o[i+1]]) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(o.begin(),o.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
//#include<unordered_set>

using namespace std;

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> st;*/

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define int long long

mt19937 rnd(51);

int pow(int n, int v){
    if (v == 0){
        return 1;
    }
    if (v % 2 == 0){
        int g = pow(n, v / 2);
        return g * g;
    }
    else{
        return pow(n, v - 1) * n;
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, now = 26, sum = 0, m = 0;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < 11; i++){
        sum += now;
        v.pb(sum);
        now *= 26;
    }
    for (int i = 0; i < 11; i++){
        if (n <= v[i]){
            m = i + 1;
            if (i != 0) n -= v[i - 1];
            break;
        }
    }
    for (int i = 0; i < m; i++){
        if (n == 0){
            cout << 'a';
            continue;
        }
        for (char j = 'a'; j <= 'z'; j++){
            if ((j - 'a' + 1) * pow(26, m - i - 1) >= n && n < (j - 'a' + 2) * pow(26, m - i - 1)){
                cout << j;
                n -= (j - 'a') * pow(26, m - i - 1);
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3520
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	vector<bool> used(20,false);
	ll ans=0; 
	int r=0;
	rep(l,n){
		if(l==r){
			rep(i,20){
				used[i]=false;
				if(1<<i & a[l]){
					used[i]=true;
				}
			}
			r++;
		}
		while(r<n){ 
			bool flag=true;
			rep(i,20){
				if(1<<i & a[r]){
					if(used[i]){
						flag=false;
						break;
					}
				}
			}
			if(!flag) break;
			rep(i,20){
				if(1<<i & a[r]){
					used[i]=true;
				}
			}
			r++;
		}
		ans+=r-l;
		rep(i,20){
			if(1<<i & a[l]){
				used[i]=false;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll y;
    cin >> n >> y;
    vector<ll> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    vector<ll> c_sum(2 * n + 1);
    for (int i = 0; i < 2 * n; i++)c_sum[i + 1] = c_sum[i] + a[i % n];

    ll ret = 0;
    for (int start = 0; start < n; start++) {
        vector<vector<ll>> dp(n + 1, vector<ll>(6));
        dp[0][0] = 1;

        for (int from = 0; from < n; from++) {
            for (int cut = 4; cut >= 0; cut--) {
                for (int to = from + 1; to <= n; to++) {
                    if (c_sum[start + to] - c_sum[start + from] + y >= c_sum[n] / 5)dp[to][cut + 1] += dp[from][cut];
                }
            }
        }

        ret += dp[n][5];
    }
    cout << ret / 5 << endl;
    return 0;
}



Measured memory_bytes: 3184
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
      	int M = sc.nextInt();
      	int[] A=new int[M];
        int sum=0;
      	for(int i=0;i<M;i++){
        	A[i]=sc.nextInt();
        }
        for(int i=0;i<M;i++){
        	sum=sum+A[i];
        }
      if(sum>N){
      	System.out.println(-1);
      }
      else{
        System.out.println(N-sum);
      }
		
		
	}
}

Measured memory_bytes: 39192
import warnings

data = map(int, raw_input().split())

a = data[0]
b = data[1] + 1
c = data[2]

count = 0
for i in range(a, b):
	if(c % i == 0):
		count = count + 1
#		print i

#print "The number of divisor is:" + str(count)
print count

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


int main() 
{ 
    ios_base::sync_with_stdio(0) ;
    cin.tie(0); cout.tie(0) ;
    
    string s,t;
    cin >> s >> t ;
    int d = 0 ;
    for( int i = 0 ; i < s.size() ; i ++ )
    {
    	if( s[i] == t[i] ) d++;
	}
	cout  << d ;
    
    return 0; 
}  

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 200005;

void solve(){
	int a,b;
	cin >> a >> b;
	cout << a*b << '\n';
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3508
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD 1000000007
#define MOD2 998244353
#define MOD3 1000000009
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
//ifstream cinn("in.in");ofstream coutt("out.out");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), is_sorted(),


signed main(){
    FASTER;
    int x;cin>>x;
    cout<<(x>=30?"Yes":"No");
    
}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main() {
	int a,b;

	cin >> a >> b;

	printf("%d %d %f\n",a/b,a%b,((double)a)/b);

	return 0;
}



Measured memory_bytes: 3128
#coding:utf-8
n = int(input())
#これだけでも二次元リストができる
st = [input().split() for _ in range(n)]
x = input()
flag = False
ans = 0
#print(st)

for s, t in st:
    if flag == True:
        ans += int(t)
    if s == x:
        flag = True

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<int, int>;
#define INF 1001001001
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n , x) for (int i = (int)(x); i < (int)(n); ++i)
#define repB(i, n) for (int i = n; i >= 1; --i)
#define repBX(i, n , x) for (int i = (int)(n); i >= int(X); --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int X,N;
    cin >> X >> N;
    vector<int>p(N);
    rep(i,N)cin >> p[i];
    sort(p.begin(),p.end());
    vector<pp> d(105);
    rep(i,105){
        pp np;
        np.first = abs(X - i);
        np.second = i;
        rep(j,N) if(p[j]==i)np.first = INF;
        d[i] = np;
    }
    sort(d.begin(),d.end());
    cout << d[0].second << endl;
    
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



#ifdef ONLINE_JUDGE
const int N = 1e6+50;
#else
const int N = 1e2+10;
#endif




int main() {
	double a,b,x;
	cin>>a>>b>>x;
	double tot = a*a*b, ans;
	if (x>=tot/2) {
		double t = 2*(a*a*b-x)/a/a;
		ans = atan(t/a)/acos(-1)*180;
	}
	else {
		double t = 2*x/b/a;
		ans = atan(b/t)/acos(-1)*180;
	}
	printf("%.30lf\n",ans);
}









Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> vec(n);
  for (auto &v : vec)
    cin >> v;

  vector<pair<ll, ll>> vec2(m);
  for (auto &v : vec2)
    cin >> v.first >> v.second;
  sort(vec2.begin(), vec2.end(),
       [](auto &lhs, auto &rhs) { return lhs.second > rhs.second; });

  int cnt = 0;
  for (auto &v : vec2) {
    if (n <= cnt)
      break;
    for (int i = 0; i < v.first; ++i)
      vec.push_back(v.second);
    cnt += v.first;
  }

  sort(vec.begin(), vec.end(), greater<ll>());

  cout << accumulate(vec.begin(), vec.begin() + n, 0LL) << endl;
}

Measured memory_bytes: 7804
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

vint r(11);
void mainmain(){
	string s;
	while(getline(cin,s)){
		rep(i,11){
			r[i]=0;
		}
		stringstream ss;
		ss<<s;
		int n;
		ss>>n;
		vector<double> v;
		int t;
		int cnt=0;
		while(ss>>t){
			v.PB(t);
			r[t]++;
			cnt++;
		}
		// sort(ALL(v));
		double ans=INF;
		rep(i,11){
			if(r[i]){
				double tans=i;
				vint tmp=r;
				tmp[i]--;
				int c=0;
				int a=i;
				while(c!=cnt-1){
					pii t=mkp(0,-1);
					rep(j,11){
						if(tmp[j]&&abs(j-a)>=t.F){
							t=mkp(abs(j-a),j);
						}
					}
					tans+=2*sqrt(a*t.S);
					a=t.S;
					tmp[t.S]--;
					c++;
				}
				tans+=a;
				ans=min(ans,tans);
			}
		}
		if(n>=ans) cout<<"OK\n";
		else cout<<"NA\n";
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int N, W;
int v[111], w[111];
int dp[111][111111];

void solve() {
   rep (i, N) {
      for (int j = 0; j <= W; j++) {
         // dp[i+1][j] = dp[i][j]; // これダメ
         chmax(dp[i+1][j], dp[i][j]);
         if (j + w[i] <= W) {
            chmax(dp[i+1][j+w[i]], dp[i][j]+v[i]);
         }
      }
   }

   cout << dp[N][W] << endl;
}

int main() {
   cin >> N >> W;
   rep (i, N) { cin >> v[i] >> w[i]; }

   solve();

   return 0;
}


Measured memory_bytes: 7368
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N, K;
	cin >> N >> K;
	VI l(N);
	FOR(i, 0, N) {
		cin >> l[i];
	}
	sort(l.begin(), l.end(), greater<int>());

	LL ans = 0;
	FOR(i, 0, K) {
		ans += l[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import copy
H, W = map(int, input().split())
S = [input() for _ in range(H)]

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(H*W):
        for i in range(H*W):
            for j in range(H*W):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


d = [[float("inf")]*(H*W) for i in range(H*W)] 
#d[u][v] : 辺uvのコスト(存在しないときはinf)
for i in range(H-1):
    for j in range(W-1):
        if S[i][j] == ".":
            if S[i+1][j] == ".":
                d[i*W+j][(i+1)*W+j] = 1
                d[(i+1)*W+j][i*W+j] = 1
            if S[i][j+1] == ".":
                d[i*W+j][i*W+(j+1)] = 1
                d[i*W+(j+1)][i*W+j] = 1
for i in range(W-1):
    if S[H-1][i] == "." and S[H-1][i+1] == ".":
        d[(H-1)*W+i][(H-1)*W+(i+1)] = 1
        d[(H-1)*W+(i+1)][(H-1)*W+i] = 1
for i in range(H-1):
    if S[i][W-1] == "." and S[i+1][W-1] == ".":
        d[i*W+(W-1)][(i+1)*W+(W-1)] = 1
        d[(i+1)*W+(W-1)][i*W+(W-1)] = 1

for i in range(H*W):
    d[i][i] = 0 #自身のところに行くコストは０

ans = 0
data = warshall_floyd(d)
for items in data:
    for item in items:
        if item != float("inf"):
            ans = max(ans, item)
print(ans)


Measured memory_bytes: 133896
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int N,mini=1e9,secmini;
double ans;

int main(){
    cin>>N;
    double V[N];
    rep(i,N){
        cin>>V[i];
    }
    sort(V,V+N);
    rep(i,N-1){
        ans=(V[i+1]+V[i])/2.0;
        V[i+1]=ans;
    }
    out(ans);

    
    
    
    
}


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

int main() {
	int a[5];
	for( int i = 0; i < 5; i++ ) {
		cin >> a[i];
	}
	sort(a, a + 5, greater<int>());
	for( int i = 0; i < 4; i++ ) {
		cout << a[i] << " ";
	}
	cout << a[4] << endl;
	return 0;
}

Measured memory_bytes: 1176
import scala.io.StdIn

object Main extends App {

  case class Dice(su1: Int, su2: Int, su3: Int, su4: Int, su5: Int, su6: Int){
    private val nums = Map(1 -> su1, 2 -> su2, 3 -> su3, 4 -> su4, 5 -> su5, 6 -> su6)
    def currentTop(): Int = nums(1)
    
    def roll(d: Char): Dice = d match {
        case 'N' => Dice(su2, su6, su3, su4, su1, su5)
        case 'S' => Dice(su5, su1, su3, su4, su6, su2)
        case 'W' => Dice(su3, su2, su6, su1, su5, su4)
        case 'E' => Dice(su4, su2, su1, su6, su5, su3)
    }
    
    def dicePattern(top: Int, front: Int): Int = (top, front) match {
        case (this.su4, this.su2) => this.su1
        case (this.su2, this.su3) => this.su1
        case (this.su3, this.su5) => this.su1
        case (this.su5, this.su4) => this.su1
        case (this.su1, this.su4) => this.su2
        case (this.su4, this.su6) => this.su2
        case (this.su6, this.su3) => this.su2
        case (this.su3, this.su1) => this.su2
        case (this.su6, this.su5) => this.su3
        case (this.su5, this.su1) => this.su3
        case (this.su1, this.su2) => this.su3
        case (this.su2, this.su6) => this.su3
        case (this.su1, this.su5) => this.su4
        case (this.su5, this.su6) => this.su4
        case (this.su6, this.su2) => this.su4
        case (this.su2, this.su1) => this.su4
        case (this.su1, this.su3) => this.su5
        case (this.su3, this.su6) => this.su5
        case (this.su6, this.su4) => this.su5
        case (this.su4, this.su1) => this.su5
        case (this.su2, this.su4) => this.su6
        case (this.su4, this.su5) => this.su6
        case (this.su5, this.su3) => this.su6
        case (this.su3, this.su2) => this.su6
    }
    
  }
  
  val nums = StdIn.readLine().split(' ').map(_.toInt)
  var dice1 = Dice(nums(0), nums(1), nums(2), nums(3), nums(4), nums(5))
  val n = StdIn.readLine().toInt
  val results = (0 until n).map{ _ =>
    val Array(top, front) = StdIn.readLine().split(' ').map(_.toInt)
    dice1.dicePattern(top, front)
  }
  
  results.foreach(println)
  
}


Measured memory_bytes: 43952
#include <bits/stdc++.h>
using namespace std;
#define N 2010
bitset<2000010> f;
int a[N],n,sum;

int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i){
        scanf("%d",a+i);
        sum+=a[i];   
    }
    f[0]=1;
    for(int i=n;i>=1;i--){
        f|=f<<a[i];
    }
    for(int i=(sum+1)>>1;i<=sum;++i)
        if(f[i]){
            printf("%d\n",i);
            return 0;
        }
}

Measured memory_bytes: 1152
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef string str;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	int a,b;
	cin >> a >> b;
	cout << 6 - a - b;
}


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

int main(){
    int N;
    cin >> N;
    int *p=new int[N+1];
    for(int i=1;i<=N;i++) cin >> p[i];

    int cnt=0;
    for(int i=1;i<=N-1;i++){
        if(p[i]==i){
            p[i+1]=p[i];
            cnt++;
        }
    }
    if(p[N]==N) cnt++;

    cout << cnt << endl;

    delete[] p;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<cmath>
#include<stdio.h>
#include<vector>
#include<set>
#include<utility>
#include<ctype.h>
#include<ctime>
# define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
# define ll long long
using namespace std;
int gcd(int a,int b){
    int r;
    while(b){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
int GCD(int a,int b)
{
    if(a==0) return b;
    else return GCD(b%a,a);
}
long long int power(long long int a,long long int b,ll int mod){
    long long int r=1;
    while(b){
        if(b & 1){
            r=((r%mod)*(a%mod))%mod;
            b--;
        }
        a=((a%mod)*(a%mod))%mod;
        b>>=1;
    }
    return r;
}
int palindrome(char *s,int len)
{
    int i,j,k,count=0,c=0;
    for(i=0,j=len-1;i<len,j>=0;i++,j--){
        if(s[i]==s[j]) count++;
    }
	if(count==len) return 1;
    	else return 0;
}
//long long int binary(char *s,long long int len)
//{
//    long long int i,j,k,r=0,p=0,num;
//    for(i=len-1;i>=0;i--){
//        num=s[i]-'0';
//        r+=(num*power(2,p));
//        p++;
//    }
//    return r;
//}
int binary_search(int *ara,int size,int n)
{
    int high,mid,low;
    low=0;
    high=size-1;
    while(low<=high){
        mid=(low+high)/2;
        if(ara[mid]==n){
            return 1;
        }
        else if(n>ara[mid]) low=mid+1;
        else if(n<ara[mid]) high=mid-1;
    }
    return -1;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	ll int i,j,k,n,T,q;
	string s1,s2;
	cin>>n;
	int ara[n];
	for(i=0;i<n;i++) cin>>ara[i];
	sort(ara,ara+n);
	if(n & 1){
        for(i=2;i<n;i+=2){
            if(ara[i]!=ara[i-1]){
                cout<<"0"<<endl;
                return 0;
            }
        }
        q=(n-1)/2;
	}
    else{
        for(i=1;i<n;i+=2){
            if(ara[i]!=ara[i-1]){
                cout<<"0"<<endl;
                return 0;
            }
        }
        q=n/2;

    }
	cout<<power(2,q,1000000007)<<endl;
}



Measured memory_bytes: 640
kaibun = input()
NList = list(kaibun)
N = len(NList)

T1 = True
T2 = True
T3 = True

for s in range(len(NList)):
    if NList[s] != NList[len(NList) - (s+1)]:
        T1 = False
        break


NList = list(kaibun[0:int((N - 1)/2)])

for s in range(len(NList)):
    if NList[s] != NList[len(NList) - (s+1)]:
        T2 = False
        break

NList = list(kaibun[int(((N+3)/2)-1):N])
for s in range(len(NList)):
    if NList[s] != NList[len(NList) - (s+1)]:
        T3 = False
        break

if T1 and T2 and T3:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e10;
const ll MOD = 1e9 + 7;

int main(){
	ll H, W;
	cin >> H >> W;
	vector<string> S;
	ll i, j;
	for (i = 0; i < H; i++){
		string s;
		cin >> s;
		S.push_back(s);
	}
	bool flg = true;
	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			if (S[i][j] == '.'){
				continue;
			}
			if (i >= 1){
				if (S[i - 1][j] == '#'){
					continue;
				}				
			}
			if (i < H - 1){
				if (S[i + 1][j] == '#'){
					continue;
				}
			}
			if (j >= 1){
				if (S[i][j - 1] == '#'){
					continue;
				}
			}
			if (j < W - 1){
				if (S[i][j + 1] == '#'){
					continue;
				}
			}
			flg = false;
		}
	}
	if (!flg){
		cout << "No" << endl;
	}
	else{
		cout << "Yes" << endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>

using namespace std;

int num[4];

int kei[4];

int sun[12];

int main()
{
	int n;
	scanf("%d",&n);
	num[0] = 100000;
	num[1] = 100000;
	num[2] = 100000;
	num[3] = 100000;
	for(int i = 0; i < n; i++)
	{
		int w;
		scanf("%d",&w);
		for(int j = 0; j < 4; j++)
		{
			if(num[j] > w)
			{
				int ww = num[j];
				num[j] = w;
				w = ww;
			}
		}
	}
	for(int i = 0; i < 4; i++)
	{
		for(kei[i] = 1; kei[i] <= num[i]; kei[i] *= 10){}
	}
	int now = 0;
	for(int i = 0; i < 4; i++)
	{
		for(int j = 0; j < 4; j++)
		{
			if(i != j)
			{
				sun[now] = num[i] * kei[j] + num[j];
				now++;
			}
		}
	}
	sort(sun,sun + 12);
	printf("%d\n",sun[2]);
	return 0;
}

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

int main(){
  int64_t N;
  while(std::cin >> N){
    int64_t ans = 0;

    for(int i = 1; i <= N; ++i){
      int64_t c = N / i;
      ans += c * (c + 1) / 2 * i;
    }
    
    std::cout << ans << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    REP(i,S.size()-1){
        if(S[i] == S[i+1]){
            cout << i+1 << ' ' << i+2 << endl;
            return 0;
        }
        else if(i+2 <S.size() && S[i] == S[i+2]){
            cout << i+1 << ' ' << i+3 << endl;
            return 0;
        }
    }
    cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll v;
    vector<lpair> ans;
    if(N % 2 == 0){
        v = N+1;
    }else{
        v = N;
    }
    rep(i,1,N+1){
        rep(j,1,N+1){
            if(i >= j) continue;
            if(i + j != v){
                ans.push_back(make_pair(i,j));
            }
        }
    }
    print(ans.size());
    rep(i,0,ans.size()){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

    
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

template<typename T> vector<pair<T, int>> RLE(vector<T> xs) {
  vector<pair<T, int>> es;

  T current = xs[0];
  int current_count = 1;
  for (int i = 1; i < xs.size(); i++) {
    if (xs[i] == current) {
      current_count++;
    } else {
      es.push_back(make_pair(current, current_count));
      current = xs[i];
      current_count = 1;
    }
  }
  es.push_back(make_pair(current, current_count));
  return es;
}

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

  string s;
  cin >> s;

  vector<char> cs(s.begin(), s.end());
  auto es = RLE(cs);

  int64 sum = 0;
  for (int i = 0; i < es.size(); i++) {
    if (i + 1 < es.size() && es[i].first == '<' && es[i + 1].first == '>') {
      int64 x1 = get<1>(es[i]);
      int64 x2 = get<1>(es[i + 1]);
      if (x1 >= x2) x2--;
      else x1--;
      sum += x1 * (x1 + 1) / 2;
      sum += x2 * (x2 + 1) / 2;
      i++;
      // cout << "sum (path 1): " << sum << endl;
    } else {
      int64 x = get<1>(es[i]);
      sum += x * (x + 1) / 2;
    }
  }
  cout << sum << endl;
}

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

struct node{
	int num;
	set<node *> as;
	int df;
	int ds;
};

int main(){
	int n, in1, in2;
	int fanc(vector<bool> &c, vector<node> &vn, int n);
	
	cin >> n;
	vector<node> vn(n);
	rep(i, n) vn.at(i).num = i;
	vn.at(0).df = 0;
	vn.at(n-1).ds = 0;
	rep(i, n-1){
		cin >> in1 >> in2;
		in1--;
		in2--;
		vn.at(in1).as.insert(&(vn.at(in2)));
		vn.at(in2).as.insert(&(vn.at(in1)));
	}
	
	queue<tuple<int, int, int>> q;//zahyo, count, mae
	vector<bool> cf(n, false);
	cf.at(0) = true;
	q.push(make_tuple(0, 0, 0));
	int fc = -1, sc = 0;
	while(!q.empty()){
		auto t = q.front(); q.pop();
		for(node *an : vn.at(get<0>(t)).as){
			if(cf.at(an->num) == false){
				q.push(make_tuple(an->num, get<1>(t)+1, get<0>(t)));
				vn.at(an->num).df = get<1>(t)+1;
				cf.at(an->num) =true;
			}
		}
	}
	
	vector<bool> cs(n, false);
	cs.at(n-1) = true;
	q.push(make_tuple(n-1, 0, 0));
	while(!q.empty()){
		auto t = q.front(); q.pop();
		for(node *an : vn.at(get<0>(t)).as){
			if(cs.at(an->num) == false){
				q.push(make_tuple(an->num, get<1>(t)+1, get<0>(t)));
				vn.at(an->num).ds = get<1>(t)+1;
				cs.at(an->num) =true;
				if(vn.at(an->num).df <= vn.at(an->num).ds){
					//cerr << "f" << an->num+1 << endl;
					fc++;
				}else{
					//cerr << "s" << an->num+1 << endl;
					sc++;
				}
			}
		}
	}
	
	
	if(fc <= sc) cout << "Snuke" << endl;
	else cout << "Fennec" << endl;
	
	return 0;
}

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

int main(){
    int a;
    vector<int> VE(32);
    cin >> a;
    a = a - 1;
    VE = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << VE.at(a) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  string s;
  long long int k;
  cin>>k;
  cin>>s;
  if(s.size()<=k){
    cout<<s<<endl;
  }else{
    s=s.substr(0,k);
    cout<<s<<"..."<<endl;
  }
}

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

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pi pair < int, int >
#define pii pair < int, pi >
#define vii vector < pi >

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int a[N];
int c[2][N];
int n, mx[2][2], mxn[2][2];

main(){
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        c[i % 2][a[i]]++;
        if (mx[i % 2][0] < c[i % 2][a[i]]){
            mx[i % 2][0] = c[i % 2][a[i]];
            mxn[i % 2][0] = a[i];
        }
    }
    for (int i = 1; i <= n; i++){
        if (mx[i % 2][1] < c[i % 2][a[i]] && mxn[i % 2][0] != a[i]){
            mx[i % 2][1] = c[i % 2][a[i]];
            mxn[i % 2][1] = a[i];
        }
    }
    if (n % 2 == 0){
        if (mxn[0][0] != mxn[1][0])
            cout << (n / 2 - mx[1][0]) + (n / 2 - mx[0][0]);
        else
            cout << min((n / 2 - mx[1][1]) + (n / 2 - mx[0][0]), (n / 2 - mx[1][0]) + (n / 2 - mx[0][1]));
    }
    else {
        if (mxn[0][0] != mxn[1][0])
            cout << (n / 2 + 1 - mx[1][0]) + (n / 2 - mx[0][0]);
        else
            cout << min((n / 2 + 1 - mx[1][1]) + (n / 2 - mx[0][0]), (n / 2 - mx[1][0]) + (n / 2 - mx[0][1]));
    }
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int cnt[26];
int main()
{
int n;
  cin>>n;
  string s;
  cin>>s;
  for(auto i:s)cnt[i-'a']++;
  long long ans=1;
  for(int i=0;i<26;i++)
  {
    ans*=(cnt[i]+1);
    ans%=(int)(1e9+7);
  }
cout<<ans-1;
}

Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static int n;
    static string s;
    static string t;
    static void Main()
    {
        var hwn = Console.ReadLine().Split().Select(int.Parse).ToArray();
        n = hwn[2];
        var rc = Console.ReadLine().Split().Select(int.Parse).ToArray();
        //どっちにも耐えられる状況
        //チェックメイトになる部分
        s = Console.ReadLine();
        t = Console.ReadLine();
        Console.WriteLine(Solve(hwn[0], rc[0] - 1, 'U', 'D') && Solve(hwn[1], rc[1] - 1, 'L', 'R') ? "YES" : "NO");
    }
    static bool Solve(int width, int point, char l, char r)
    {
        //0←L, R→n
        int deadL = -1;
        int deadR = width;
        for (int i = n - 1; i >= 0; i--)
        {
            //逆から見ているので、青木くんの巻き返し
            if (t[i] == l) deadR = Min(width, deadR + 1);
            if (t[i] == r) deadL = Max(-1, deadL - 1);
            if (s[i] == l) deadL = deadL + 1;
            if (s[i] == r) deadR = deadR - 1;
            if (deadL + 1 >= deadR) return false;
        }
        if (deadL < point && point < deadR) return true;
        else return false;
    }
}


Measured memory_bytes: 14932
#include<bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define loop(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll
#define br                break
#define con               continue

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
 
const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

priority_queue<pii, vector<pii>, greater<pii> >q;

#include<bits/stdc++.h>
using namespace std;
signed main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output1.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
 
	string s;
	cin>>s;
	int ans=0;
	for(int i=0;i<s.size();i++)ans+=s[i]-48;
	if(ans%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
 
}

Measured memory_bytes: 3736
week =input()

if week=="SUN":
  print("7")
elif week=="MON":
  print("6")
elif week=="TUE":
  print("5")
elif week=="WED":
  print("4")  
elif week=="THU":
  print("3")
elif week=="FRI":
  print("2")
else:
  print("1")

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

int main()
{
  int n;
  while(cin >> n,n){
    string order[105];
    for(int i=0;i < n;i++){
      cin >> order[i];
    }
    int cnt=0;
    for(int i=0;i < n;i++){
      if(order[i] == "lu" && order[i+1] == "ru"){
	cnt++;
	continue;
      }
      else if(order[i] == "ru" && order[i+1] == "lu"){
	cnt++;
	continue;
      }
      
      if(order[i] == "ld" && order[i+1] == "rd"){
	cnt++;
	continue;
      }
      else if(order[i] == "rd" && order[i+1] == "ld"){
	cnt++;
	continue;
      }
    }
    cout << cnt << endl;
  }
}


Measured memory_bytes: 3072
#include <iostream>
#include <stack>

using namespace std;

int main() {
    stack<int> st;
    int n;
    
    while (cin >> n) {
        if (n == 0) {
            cout << st.top() << endl;
            st.pop();
        } else {
            st.push(n);
        }
    }
    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d;
   cin >> a >> b >> c;
   if(b<a){
       d = b ; b = a ; a = d ;
   }
   if(c<b){
       d = c ; c = b ; b = d ;
   }
   if(b<a){
       d = b ; b = a ; a = d ;
   }
   cout << a;
   cout << " ";
   cout << b;
   cout << " ";
   cout << c;
   cout << endl;
    
}


Measured memory_bytes: 3104
import sys
sys.setrecursionlimit(10**6)
N,M = map(int,input().split())
AB = [tuple(map(int,input().split())) for i in range(M)]
if M%2:
    print(-1)
    exit()

class UnionFind:
    def __init__(self,N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N
        self.count = 0
    def root(self,a):
        if self.parent[a] == a:
            return a
        else:
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    def is_same(self,a,b):
        return self.root(a) == self.root(b)
    def unite(self,a,b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb: return
        if self.rank[ra] < self.rank[rb]:
            self.parent[ra] = rb
        else:
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]: self.rank[ra] += 1
        self.count += 1
uf = UnionFind(N)
outdeg = [0] * N
es = [[] for _ in range(N)]
ans = []
for a,b in AB:
    a,b = a-1,b-1
    if uf.is_same(a,b):
        outdeg[a] += 1
        ans.append((a+1,b+1))
    else:
        uf.unite(a,b)
        es[a].append(b)
        es[b].append(a)

def rec(v,p=-1):
    k = outdeg[v]
    for to in es[v]:
        if to==p: continue
        r = rec(to,v)
        if r:
            ans.append((to+1,v+1))
        else:
            ans.append((v+1,to+1))
        k += (r+1)
    return k%2
rec(0)

for row in ans:
    print(*row)

Measured memory_bytes: 130172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF MOD
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    int x, n;
    cin >> x >> n;
    set<int> p;
    rep(i,n) {
        int a;
        cin >> a;
        p.insert(a);
    }
    int ans_a;

    for (int i = x; i <= 110; i++) {
        if (p.find(i) == p.end()) {
            ans_a = i;
            break;
        }
    }
    int ans_b;
    for (int i = x; i >= -110; i--) {
        if (p.find(i) == p.end()) {
            ans_b = i;
            break;
        }
    }
    int ans;
    if (abs(x - ans_a) < abs(x - ans_b)) ans = ans_a;
    else if (abs(x - ans_a) > abs(x - ans_b)) ans = ans_b;
    else ans = ans_b;
    cout << ans << endl;
}

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

int a,b,c,d,ans;

int main(){
	cin>>a>>b>>c>>d;
	for(int i=0;i*500<=d&&i<=a;i++)
		for(int j=0;j*100+i*500<=d&&j<=b;j++)
			for(int k=0;k*50+j*100+i*500<=d&&k<=c;k++)
				if(k*50+j*100+i*500==d)
					ans++;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let xs: [Int] = readInts()
    var i = 0
    for x in xs {
        i += 1
        if x == 0 {
            print(i)
        }
    }
}

main()


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

int main(){
    ll n,ans=0;
    cin >> n;
    vector<ll> a(3*n);
    rep(i,n*3) cin >> a[i];
    sort(a.begin(),a.end(),greater<ll>());
    for(int i=1;i<n*2;i+=2){
        ans += a[i];
    }
    cout << ans << endl;
} 

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

int num[20], bonus[20];

int dp[120005];

const int lim = 120000;
int main()
{
	int n, g;
	scanf("%d %d", &n, &g);
	g /= 100;
	for(int i = 1; i<= n; i++)
	{
		scanf("%d %d", &num[i], &bonus[i]);
		bonus[i] /= 100;
	}
	dp[0] = 0;
	for(int i = 1; i<= lim; i++) dp[i] = 1e9;
	for(int i = 1; i<= n; i++)
	{
		for(int k = lim; k>= i; k--)
		{
			for(int j = 1; j< num[i]; j++)
			{
				if(k>= i*j)
					dp[k] = min(dp[k], dp[k-i*j]+j);
			}
			if(k>= i*num[i]+bonus[i])
			{
				dp[k] = min(dp[k], dp[k-i*num[i]-bonus[i]]+num[i]);
			}
		}
	}
	int best = 1e9;
	for(int i = g; i<= lim; i++) best = min(best, dp[i]);
	printf("%d\n", best);
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;
//constexpr ll N = 2e5;
//ll a[N];

//constexpr int max = 2147483647;



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

	bool f = true;
	while (true)
	{
		if(a <= 0 || c <= 0)
			break;

		if (f) {
			c -= b;
		}
		else {
			a -= d;
		}
		f = !f;
	}

	if (a <= 0)
		cout<<"No";
	else
		cout <<"Yes";
	
	return 0;
}


Measured memory_bytes: 3636
N,A,B,C = map(int,input().split())
L = [int(input()) for i in range(N)]

def dfs(cnt,la,lb,lc,cost):
    if cnt == N:
        if la == 0 or lb == 0 or lc == 0:
            return 10**10
        else:
            return cost+abs(A-la)+abs(B-lb)+abs(C-lc)-30
    else:
        a = dfs(cnt+1,la+L[cnt],lb,lc,cost+10)
        b = dfs(cnt+1,la,lb+L[cnt],lc,cost+10)
        c = dfs(cnt+1,la,lb,lc+L[cnt],cost+10)
        d = dfs(cnt+1,la,lb,lc,cost) 
        return min(a,b,c,d)

print(dfs(0,0,0,0,0))

Measured memory_bytes: 3064