akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void)
{
	int W, H, x, y, r;

	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	
	if ((x + r <= W) && (y + r <= H)) {
		if ((x - r>= 0) && (y - r >= 0))
			printf("Yes\n");
		else
			printf("No\n");
	}
	else
		printf("No\n");

	return 0;
}




Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
const long long MOD=1e9+7;
// const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
#define LOCAL

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();++itr){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();++itr){
        os << *itr;
        if (++itr!=s.end()) os << ',';
        --itr;
    }
    os << '}';
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}

const int MAX=1e6+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N); cin >> A;
    vector<int> cnt(MAX,0),check(MAX,0);
    for (int i=0;i<N;++i) ++cnt[A[i]];
    int ans=0;
    for (int i=1;i<MAX;++i){
        if (!check[i]&&cnt[i]==1) ++ans;
        if (cnt[i]>0){
            for (int j=i;j<MAX;j+=i) check[j]=1;
        }
    }
    cout << ans << '\n';
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  reverse(a.begin(), a.end());
  
  vector<int> x;
  x.emplace_back(a.at(0));
  for(int i = 1; i < n; i++){
    if(x.back() <= a.at(i)) x.emplace_back(a.at(i));
    else *upper_bound(x.begin(), x.end(), a.at(i)) = a.at(i);
  }
  
  cout << x.size() << '\n';
}

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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//Write From this Line

int main()
{
	ll x;
	cin >> x;
	For(i,1,100000){
		if(x*i % 360 == 0){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3584
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  s.pop_back();
  while(s.size() > 0){
    if(s.size()%2==0 && s.substr(0,s.size()/2) == s.substr(s.size()/2, s.size()/2)){
      cout << s.size() << endl;
      return 0;
    }
    s.pop_back();
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll f(string s){
  string s1 = s;
  reverse(all(s1));
  if(s==s1)return 1;
  return 0;
}

int main(){
  string s;
  cin>>s;
  if(f(s)==1){
    string s1,s2;
    rep(i,0,s.sz/2){
      s1 += s[i];
    }
    rep(i,s.sz/2+1,s.sz){
      s2 += s[i];
    }
    if(f(s1)==1&&f(s2)==1){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

#define p(x) ((x)*(x))
#define c(x) (((double)((int)(x)*1000+0.5))/1000)

int main(){
	double x1,x2,x3,y1,y2,y3;
	double xp,yp,r;
	double a1,a2,b1,b2,c1,c2;
	int n;
	scanf("%d",&n);
	for(;n>0;n--){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
		a1 = 2*(x2-x1);
		b1 = 2*(y2-y1);
		c1 = p(x1)-p(x2)+p(y1)-p(y2);
		a2 = 2*(x3-x1);
		b2 = 2*(y3-y1);
		c2 = p(x1)-p(x3)+p(y1)-p(y3);
		xp = (b1*c2-b2*c1)/(a1*b2-a2*b1);
		yp = (c1*a2-c2*a1)/(a1*b2-a2*b1);
		r = sqrt(p(xp-x1)+p(yp-y1));
		printf("%.3f %.3f %.3f\n",xp,yp,r);
	}
	
	return 0;
}

Measured memory_bytes: 0
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	int n;
	cin>>n;
	vi in(n);
	rep(i,n)cin>>in[i];
	vvi dp(n+1,vi(5,inf));//0,even,odd,even,0
	dp[0][0]=0;
	rep(i,n)rep(j,5)if(dp[i][j]-inf)loop(k,j,5){
		int t=in[i];
		if(k==1||k==3)if(t)t%=2;else t=2;
		if(k==2)t++,t%=2;
		cmin(dp[i+1][k],dp[i][j]+t);
	}
	int out=inf;
	rep(i,5)cmin(out,dp[n][i]);
	cout<<out<<endl;
}


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

void solve(void) {
  int K, X;
  cin >> K >> X;

  for(int x = X - (K-1); x <= X + (K-1); ++x) cout << x << " ";
  cout << endl;

}
int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner((System.in));
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;
		ans = x-a-((x-a)/b)*b;
		
		System.out.println(ans);

		sc.close();
	}
}


Measured memory_bytes: 22868
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>


using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll ans = 0;
    string tmp = "";
    string x = "";
    FOR(i,0,s.size()){
      x.push_back(s[i]);
      if(tmp != x){
        tmp = x;
        ans++;
        x = "";
      }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 720
#include<iostream>
#include<algorithm>

int main() {
	int n, m;
	std::cin >> n >> m;

	int food[30]{};  //[1,30] = [0,29] = [0,30)

	for (int i{}; i < n; ++i) {
		int k{};
		std::cin >> k;
		
		for (int ki{}; ki < k; ++ki) {
			int t;
			std::cin >> t;
			food[t-1]++;
		}
	}
	/*
	for (const auto&e : food) {
		std::cout << " " << e;
	}std::cout << "\n";
	*/
	auto ans = std::count(std::begin(food), std::end(food), n);

	std::cout << ans << "\n";

	return 0;
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int a = (n + 1) / 2;
  printf("%.10f\n", (1.0 * a) / (1.0 * n));
  return 0;
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int i=0;i<(n);i++)        //repeat n times
#define REP2(i,s,n) for(int i=(s);i<(n);i++)   //repeat from s to n 
#define REPD(i,n) for(int i=(n);i>=0;i--)      //repeat from n to 0
#define REPD2(i,s,e) for(int i=(s);i>=(e);i--) //repeat from s to e
#define RANGE(i,v) for(auto &i:v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pll = P<LL,LL>;
using Pdd = P<double,double>;
using Psi = P<string,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int K;
    cin>>K;
    string S;
    cin>>S;
    
    if(S.size()<=K){
        cout<<S<<endl;
    }else{
        cout<<S.substr(0,K)<<"..."<<endl;
    }

    return 0;
}

Measured memory_bytes: 3640
import Data.Array.IArray
import Data.List

main = do
  n <- readLn :: IO Int
  a <- getContents >>= return . (map read) . lines :: IO [Int]

  let arr = listArray (1, n) a :: Array Int Int

  let
    func _ 0 = []
    func i n = i : (func (arr!i) (n-1))

  putStrLn $ g (elemIndex 2 (func 1 n))
  where
    g Nothing = "-1"
    g (Just x) = show x


Measured memory_bytes: 32380
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 55
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    int N;
    cin>>N;
    vector<int> p(N);
    for(int i=0;i<N;i++) cin>>p[i],p[i]--;
    vector<int> a(N),b(N);
    for(int i=0;i<N;i++){
        a[p[i]]=i+1;
        b[p[i]]=i+1;
    }
    for(int i=1;i<N;i++){
        a[i]+=a[i-1];
    }
    for(int i=N-2;i>=0;i--){
        b[i]+=b[i+1];
    }
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<a[i];
    }
    cout<<endl;
    for(int i=0;i<N;i++){
        if(i) cout<<" ";
        cout<<b[i];
    }


}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
/*
2019/05/25
*/
int main(){
  int r,d,x;
  cin>>r>>d>>x;
  int ansx;
  for(int i=0;i<10;i++){
    ansx=r*x-d;
    cout<<ansx<<endl;
    x=ansx;
  }
  
}


Measured memory_bytes: 256
#include<stdio.h>
int p[1000001],x[1000001];
int main(void)
{
	long long int n,m,s,sum,i,a,b,c;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=m;i++) scanf("%d",&p[i]);
	for(i=1;i<m;i++){
		if(p[i]<p[i+1]){
			x[p[i]]++; x[p[i+1]]--;
		}
		if(p[i]>p[i+1]){
			x[p[i]]--; x[p[i+1]]++;
		}
	}
	s=0; sum=0;
	for(i=1;i<=n;i++){
		if(n!=i) scanf("%lld%lld%lld",&a,&b,&c);
		//printf("s=%d sum=%d\n",s,sum);
		s+=x[i];
		if(a*s<b*s+c) sum+=a*s;
		else sum+=b*s+c;
	}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 2524
#include "stdio.h"

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	int sum_ab=0;
	int sum_ac=0;
	int sum_bc=0;
	
	sum_ab = a+b;
	sum_ac = a+c;
	sum_bc = b+c;
	
	if(sum_ab <= sum_ac && sum_ab <= sum_bc){
		printf("%d\n", sum_ab);
	}
	else if(sum_ac <= sum_ab && sum_ac <= sum_bc){
		printf("%d\n", sum_ac);
	}
	else if(sum_bc <= sum_ac && sum_bc <= sum_ab){
		printf("%d\n", sum_bc);
	}
	
	return (0);
}

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

#define ll long long int 
#define pii pair<int, int>
#define INF 0x3f3f3f3f
#define fi first
#define se second
#define f(n) for(int i = 0; i < n; i++)
#define f2(n) for(int i = 1; i <= n; i++)
#define t cout << "TESTE" << endl
#define debug(x) if(on)cout << x << endl
#define on true
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back

int main(){

	string s;

	cin >> s;

	int cont1 = 0, cont2 = 0;
	int e = 1;

	for(int i = 0; i < s.size(); i++){
		if(s[i] != (e + '0'))
			cont1++;
		e ^= 1;

	}

	e = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] != (e+'0'))
			cont2++;
		e ^= 1;
	}

	int resp = min(cont1, cont2);

	cout << resp << endl;
return 0;
}



Measured memory_bytes: 512
require 'pp'

# 空白区切の入力値を数値の配列で返却する
def gets_i_list()
  gets.chomp.split(" ").map(&:to_i)
end

S, C = gets_i_list

if S >= C * 2
  # S が C*2 より多い
  puts [S, C/2].min
elsif S >= C / 2
  puts C / 2
else
  diff = C - S * 2
  puts S + diff / 4
end




Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int a[105];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            for(int k = j + 1; k < n; k++){
                if(a[i] == a[j] || a[j] == a[k]) continue;
                if(a[i] + a[j] > a[k]) ans++;
            }
        }
    }
    cout << ans;

    return 0;
}


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

/* debug macros */
#ifdef WAFDAYO
#define DBG_PRINT(s, t, u) { std::cerr << s << " \e[2m=\e[m \e[1m" << t << "\e[m" << u; }
#else
#define DBG_PRINT(s, t, u) {}
#endif
#define dbg(x) DBG_PRINT(#x, x, std::endl)
#define dbgc(x) DBG_PRINT(#x, x, ", ")
#define idbg(x, i) DBG_PRINT(#x "[" << i << "]", x[i], std::endl)
#define idbgc(x, i) DBG_PRINT(#x "[" << i << "]", x[i], ", ")

/* IO utilities */
struct read_item { read_item() {}; template<class T> operator T() { T t; std::cin >> t; return t; } };

/* types and constants */
typedef long long i64;
const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;
const i64 mod = 1e9 + 7;

i64 modpow(i64 x, i64 p) {
	i64 y = 1;
	for(int i = 0; i < 63; i++) {
		if((p >> i) & 1) {
			y = y * x % mod;
		}
		x = x * x % mod;
	}
	return y;
}

i64 modinv(i64 x) {
	return modpow(x, mod - 2);
}

int main() {

	const int n = read_item();
	vector<int> xs(n);
	for(int i = 0; i < n; i++) {
		xs[i] = read_item();
	}

	vector<i64> fact(n);
	fact[0] = 1;
	fact[1] = 1;
	for(int i = 2; i < n; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}

	vector<i64> r(n);
	r[0] = 0;
	r[1] = fact[n - 1];
	for(int i = 2; i < n; i++) {
		i64 v = modinv(i);
		r[i] = (r[i - 1] + fact[n - 1] * v) % mod;
	}

	i64 ans = 0;

	for(int i = 0; i < n - 1; i++) {
		ans = (ans + r[1 + i] * (i64)(xs[i + 1] - xs[i])) % mod;
	}

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

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 2176
import sys
#input = sys.stdin.buffer.readline

def main():
    S = input()
    l = len(S)
    S = "0"+ S
    up = 0
    ans = 0
    for i in range(l):
        num = int(S[-i-1])+up
        if num == 5:
            ans += 5
            if int(S[-i-2]) < 5:
                up = 0
            else:
                up = 1
        elif num > 5:
            ans += 10-num
            up = 1
        else:
            ans += num
            up = 0
            
    print(ans+up)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 5492
import java.io.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();        
        String S = r.s(),
               T = r.s();
        int len = S.length();
        int[] sChar = new int[26],
              tChar = new int[26];
        for(int i = 0; i < len; i++){
            sChar[S.charAt(i)-'a']++;
            tChar[T.charAt(i)-'a']++;
        }
        Arrays.sort(sChar);
        Arrays.sort(tChar);
        for(int i = 25; i > -1; i--){
            if(sChar[i] != tChar[i]){
                print("No");
                return;
            }
        }
        print("Yes");       
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
    }
}

Measured memory_bytes: 25704
main(s,t,T){double x,y;
	for(t=90;scanf("%d,%d",&s,&T),s||T;t-=T)x+=s*cos(t/57.3),y+=s*sin(t/57.3);
	printf("%d\n%d\n",(int)x,(int)y);
	exit(0);
}

Measured memory_bytes: 604
#include<stdio.h>
int main(void)
{
  int a,b,i,j=1,flag;
  
  while(1)
    {
      flag=0;
      scanf("%d %d",&a,&b);
      
      if(a==0 && b==0)break;

      if(j!=1)printf("\n");
      
      for(i=a;i<=b;i++)
	{
	  if(i%100==0 && i%400==0)
	    {
	      printf("%d\n",i);
	      flag=1;
	    }
	  else if(i%4==0 && i%100!=0)
	    {
	      printf("%d\n",i);
	      flag=1;	    
	    }
	  
	  
	}
      
      if(flag==0)printf("NA\n");
      
      j++;
    }
  return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var s = new List<List<int>>();

            while (true)
            {
                var a = Console.ReadLine().Split(' ');
                if (int.Parse(a[0]) == 0 && int.Parse(a[1]) == 0)
                {
                    break;
                }

                s.Add(new List<int>() { int.Parse(a[0]), int.Parse(a[1]) });
            }

            foreach (var S in s)
            {
                var n = S[0];
                var x = S[1];
                var c = 0;
                for (int i = 1; i <= n; i++)
                {
                    for (int j = i + 1; j <= n; j++)
                    {
                        for (int k = j + 1; k <= n; k++)
                        {
                            if (i + j + k == x)
                            {
                                c++;
                            }
                        }
                    }
                }

                Console.WriteLine(c);
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9208
#include <iostream>
#include <stdio.h>
#include <vector>
#include <map>
using namespace std;
int main() {
  vector<vector<char>> c (3, vector<char>(3));
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      cin >> c.at(i).at(j);
    }
  }
  for ( int i = 0; i < 3; i++ ) cout << c.at(i).at(i);
}

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

long long combination(int n, int k) {
    if (k < 0 || n < k) return 0;
    long long res = 1;
    for (long long i = 1; i <= k; ++i) {
        res *= n--;
        res /= i;
    }
    return res;
}

int main() {
    int N, P;
    cin >> N >> P;
    long long A, cntOdd = 0, cntEven = 0;
    rep (i, N) cin >> A, A % 2 ? cntOdd++ : cntEven++;
    if (P) {
        long long tmpOdd = 0, tmpEven = 0;
        for (int i = 1; i <= cntOdd; i += 2) tmpOdd += combination(cntOdd, i);
        for (int i = 0; i <= cntEven; i ++) tmpEven += combination(cntEven, i);
        cout << tmpOdd * tmpEven << endl;
    }
    else {
        long long tmpOdd = 0, tmpEven = 0;
        for (int i = 0; i <= cntOdd; i += 2) tmpOdd += combination(cntOdd, i);
        for (int i = 0; i <= cntEven; i ++) tmpEven += combination(cntEven, i);
        cout << tmpOdd * tmpEven << endl;
    }
    return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)


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

  int N,M;
  cin>>N>>M;
  vector<int>A(N);
  for(int i=0;i<N;i++)cin>>A[i];
  vector<int>B(M),C(M);
  rep(i,M)cin>>B[i]>>C[i];
  priority_queue<pii>q;
  rep(i,N)q.push({A[i],1});
  rep(i,M)q.push({C[i],B[i]});
  int c=0;
  ll ans=0;
  rep(i,N){
    ll a=q.top().first;
    ll n=q.top().second;
    q.pop();
    if(c+n<=N){
      ans+=a*n;
      c+=n;
    }
    else{
      ans+=a*max(N-c,0);
      c=N;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3572
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 1
    cnt = [3 if i == 0 else 0 for i in range(n + 1)]

    for a in A:
        res = res * cnt[a] % mod
        cnt[a] -= 1
        cnt[a + 1] += 1

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 14364
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

int N;
int dp[110][5][5][5];

int rec(int n, int a, int b, int c) {
  if (n == N) return 1;
  if (dp[n][a][b][c] > 0) return dp[n][a][b][c];

  int res = 0;
  if (a == 0 && b == 2) {
    for (int i = 0; i < 4; i++) {
      if (i != 1) {
        res += rec(n + 1, b, c, i);
        res %= MOD;
      }
    }
  } else if (b == 2 && c == 0) {
    for (int i = 0; i < 4; i++) {
      if (i != 1) {
        res += rec(n + 1, b, c, i);
        res %= MOD;
      }
    }
  } else if (b == 0 && c == 2) {
    for (int i = 0; i < 4; i++) {
      if (i != 1) {
        res += rec(n + 1, b, c, i);
        res %= MOD;
      }
    }
  } else if (b == 0 && c == 1) {
    for (int i = 0; i < 4; i++) {
      if (i != 2) {
        res += rec(n + 1, b, c, i);
        res %= MOD;
      }
    }
  } else if (a == 0 && c == 2) {
    for (int i = 0; i < 4; i++) {
      if (i != 1) {
        res += rec(n + 1, b, c, i);
        res %= MOD;
      }
    }
  } else {
    for (int i = 0; i < 4; i++) {
      res += rec(n + 1, b, c, i);
      res %= MOD;
    }
  }

  return dp[n][a][b][c] = res;
}

signed main() {
  cin >> N;
  cout << rec(0, 4, 4, 4) << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template<typename T>
struct Kruskal{
  
  struct edge{
    int from,to;
    T cost;
    int used;
    edge(){}
    edge(int from,int to,T cost):
      from(from),to(to),cost(cost),used(0){}
    bool operator<(const edge& e) const{
      return cost<e.cost;
    }
  };

  int n;
  vector<int> p,r;
  vector<edge> edges;

  Kruskal(){}
  Kruskal(int n):n(n){}

  void init(int n){
    r.assign(n,1);
    p.resize(n);
    iota(p.begin(),p.end(),0);
  }
  
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }

  bool same(int x,int y){
    return find(x)==find(y);
  }

  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }

  void add_edge(int u,int v,T c){
    edges.emplace_back(u,v,c);
  }

  void input(int m,int offset=0){
    int a,b;
    T c;
    for(int i=0;i<m;i++){
      cin>>a>>b>>c;
      add_edge(a+offset,b+offset,c);
    }
  }
  
  T build(){
    sort(edges.begin(),edges.end());
    init(n);
    T res=0;
    for(auto &e:edges){
      if(!same(e.from,e.to)){
	res+=e.cost;
	unite(e.from,e.to);
	e.used=1;
      }
    }
    return res;
  }
};
//END CUT HERE
int main(){
  int V,E;
  cin>>V>>E;
  Kruskal<int> kruskal(V);
  kruskal.input(E);
  cout<<kruskal.build()<<endl;
  return 0;
}

/*
  verified on 2018/01/11
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
*/



Measured memory_bytes: 4912
// AOJ 0395: A Round Table for Sages
// 2019.2.23 bal4u

#include <stdio.h>
#include <stdlib.h>

#define gc() getchar()
int in()
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int a[12];

int main()
{
	int N, w, s;
	int i, lmin, rmin;

	N = in();
	s = 0; for (i = 0; i < N; i++) a[i] = in(), s += a[i];
	if (s == 0 || s == N) {
		puts("0");
		return 0;
	}
	lmin = rmin = 1001;
	for (i = 0; i < N; i++) {
		w = in();
		if (a[i]) {
			if (w < lmin) lmin = w;
		}
		else {
			if (w < rmin) rmin = w;
		}
	}
	printf("%d\n", lmin + rmin);
	return 0;
}


Measured memory_bytes: 2064
x, y = map(int, input().split())
l1 = [1, 3, 5, 7, 8, 10, 12]
l2 = [4, 6, 9, 11]
l3 = [2]
ans = 'No'
if (x in l1 and y in l1) or (x in l2 and y in l2) or (x in l3 and y in l3):
  ans = 'Yes'
print(ans)

Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sum := 0
	var N int 
	fmt.Scan(&N)
	var i int
	y := []int{} 
	b := true   
	scanner := bufio.NewScanner(os.Stdin)

	for b {
		b = scanner.Scan()
		t := scanner.Text()
		i, _ = strconv.Atoi(t) 

		if b == false { 
			break
		}
		y = append(y, i)
		if t == "終わり" {  
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(y)))
	for i := 1; i < N; i++ {

		sum += y[i]
	}
	fmt.Println(y[0]/2 + sum)
}


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

int main() {
    long long n, k;
    cin >> n >> k;
  // aとbがともにKの倍数である
  // aとbの mod K の和がKの倍数である
  // 2つ目の条件はkが奇数のとき、整数にならないので、そこを場合分けしてる
    if (k % 2 == 0) {
        long long a = n / k;
        long long b = (n + (k/2)) / k;
        cout << a*a*a + b*b*b << endl;
    }
    else {
        long long a = n / k;
        cout << a*a*a << endl;
    }
}

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

using namespace std;

int main()
{
    int n;
    string s;

    cin >> n >> s;

    int ans = 0;
    
    for (int i = 0; i < n-2; i++)
    {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C')
            ans++;
    }

    cout << ans << "\n";    

    return 0;
}

Measured memory_bytes: 256
#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(){
  ll X;
  cin >> X;
  int counter =0;
  long long int A=0, B=0;
  rep(i,1000){
    rep(j,1000){
      if(i*i*i*i*i-j*j*j*j*j == X){
        A = i;
        B = j;
        counter ++;
        break;
      }
      if(i*i*i*i*i+j*j*j*j*j == X){
        A = i;
        B = -j;
        counter ++;
        break;
      }
    }
    if (counter > 0)
      break;
  }
  cout << A << ' ' <<B;
}


Measured memory_bytes: 3624
#include <iostream>
using namespace std;
int main(void)
{
	int a=0,b,c,d;
	for (a=0;a<4;a++)
	{
		cin>>b;
		d=d+b;
	}
	c=d/60;
	cout<<c<<endl;
	c=d%60;
	cout<<c<<endl;
	return 0;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
    }
    int mn = p[0];
    int ans = 0;
    rep(i, n)
    {
        if (mn >= p[i])
        {
            ans++;
        }
        mn = min(mn, p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

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

	if (a > b)
		swap(a, b);

	if (b - (a + W) < 0)
		cout << 0 << endl;
	else
		cout << b - (a + W) << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s;
    string t;
    cin>>s>>t;  
    REP(i,s.size()){
        if(s==t) {
            cout<<"Yes"<<endl;
            return 0;
        }
        s=s[s.size()-1]+s.substr(0,s.size()-1);
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int fir, sec,per;
	int div, inc;

	div = 0;

	scanf("%d %d %d", &fir, &sec, &per);

	for (inc = fir; inc <= sec; inc++)
	{
		
		if ((per%inc)==0)
		{
			div = div + 1;
		}

	}

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


		return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main()
{
  string s;
  cin >> s;
  if(s=="ABC")cout << "ARC" << "\n";
  else
    cout << "ABC"
         << "\n";
  return 0;
}


Measured memory_bytes: 3592
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}


template<lint mod>
struct Int_{
  unsigned x;
  unsigned mpow(Int_ a,unsigned k){
    Int_ res=1;
    while(k){
      if(k&1) res=res*a;
      a=a*a;
      k>>=1;
    }
    return res.x;
  }
  unsigned inverse(Int_ a){
    return mpow(a,mod-2);
  }
  Int_(): x(0) { }
  Int_(long long sig) {
    int sigt=sig%mod;
    if(sigt<0) sigt+=mod;
    x=sigt;
  }
  unsigned get() const { return (unsigned)x; }
  
  Int_ &operator+=(Int_ that) { if((x += that.x) >= mod) x -= mod; return *this; }
  Int_ &operator-=(Int_ that) { if((x += mod - that.x) >= mod) x -= mod; return *this; }
  Int_ &operator*=(Int_ that) { x = (unsigned long long)x * that.x % mod; return *this; }
  Int_ &operator=(Int_ that) { x=that.x; return *this;}
  Int_ &operator/=(Int_ that) { x=(unsigned long long) x * inverse(that.x)%mod; return *this;}
  bool operator==(Int_ that) const { return x==that.x; }
  bool operator!=(Int_ that) const { return x!=that.x; }

  Int_ operator-() const { return Int_(0)-Int_(*this);}
  Int_ operator+(Int_ that) const { return Int_(*this) += that; }
  Int_ operator-(Int_ that) const { return Int_(*this) -= that; }
  Int_ operator*(Int_ that) const { return Int_(*this) *= that; }
  Int_ operator/(Int_ that) const { return Int_(*this) /= that; }

};

namespace std{
  template<lint mod>
  ostream &operator <<(ostream& out,const Int_<mod>& a){
    out<<a.get();
    return out;
  }
  template<lint mod>
  istream &operator >>(istream& in,Int_<mod>& a){
    in>>a.x;
    return in;
  }
};

typedef Int_<1000000007> Int;

//const int INF=5e8;
int n,m,k;

Int fact[900005],inv[900005];
Int pw2[900005],pw3[900005];
Int C(int a,int b){
  if(a<0 || b<0 || b>a) return 0;
  return fact[a]*inv[b]*inv[a-b];
}
int main(){
  fact[0]=1;
  pw2[0]=pw3[0]=1;
  REP(i,900004) fact[i+1]=fact[i]*(i+1),pw2[i+1]=pw2[i]*2,pw3[i+1]=pw3[i]*3;;
  Int one=1;
  inv[900000]=one/fact[900000];
  for(int i=899999;i>=0;--i) inv[i]=inv[i+1]*(i+1);

  cin>>n>>m>>k;

  Int res=0;
  Int sum1=0,sum2=0;
  for(int i=n;i<=n+m+k;++i){
    Int tmp=C(i,n)-C(i-1,n);
    sum1=sum1*2+C(i-n-1,i-n-m-1);
    sum2=sum2*2+C(i-n-1,i-n-k-1);
    tmp*=pw2[i-n]-sum1-sum2;
    tmp*=pw3[n+m+k-i];
    res+=tmp;
  }
  cout<<res<<endl;
  return 0;
}





Measured memory_bytes: 14336
N,K = map(int,input().split())

nums = []
for i in range(0,N):
    ab = list(map(int,input().split()))
    nums.append(ab)

nums = sorted(nums,key = lambda x: x[0])
tmp = 0
index = 0
for i in range(0,N):
    tmp += nums[i][1]
    if tmp >= K:
        index = i
        break

print(nums[i][0])

Measured memory_bytes: 29912
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}


int main() {
    ll n, sum = 0, tmp;
    
    cin>>n;
    
    for(int i= 1;i<=n; i++){
        for(int j= 1;j<=n; j++){
            for(int k= 1;k<=n; k++){
                tmp = gcd(i, j);
                sum += gcd(tmp, k);
            }
        }
    }
    
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;

#define X first
#define Y second

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

#define debug(x) cerr << #x << " = " << (x) << endl;
template<typename T>
ostream& operator<<(ostream& o, vector<T>& v) {
    for (auto& x : v) o << x << ' ';
    return o;
}

int R, C, n;
int add(int x, int y){
    if (x == 0) return y;
    if (y == C) return x + C;
    if (x == R) return (C-y) + C + R;
    return (R-x) + C + R + C;
}

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

    cin >> R >> C >> n;
    vector<pii> arr;
    vi fst(n);
    for (int i = 0; i < n; i++){
        int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
        if ((x1 == 0 || x1 == R || y1 == 0 || y1 == C)
            && (x2 == 0 || x2 == R || y2 == 0 || y2 == C))
        {
            int a = add(x1, y1), b = add(x2, y2);
            arr.emplace_back(a, i);
            arr.emplace_back(b, i);
            fst[i] = min(a, b);
        }
    }
    sort(arr.begin(), arr.end());
    stack<int> stk;
    for (pii p : arr){
        if (fst[p.Y] == p.X) stk.push(p.Y);
        else {
            assert(!stk.empty());
            if (stk.top() != p.Y) {
                cout << "NO" << endl;
                return 0;
            }
            stk.pop();
        }
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 2804
//BISMILLAH
#include<bits/stdc++.h>
using namespace std;
int n,m,q;
vector<int> a,b,c,d,A; //globaly dec kortei hobe
int ans=0;

int check()
{
    int res=0;
    for(int i=0;i<q;i++)
    {
        if(A[b[i] - 1] - A[a[i] - 1] == c[i]) {
			res += d[i];
		}
    }
    return res;
}

void makesequence(int i,int curr)
{
    if(i>=n) // n lengh er e hote hobe A list k . 111 jokhn hobe tokhn tekei eikhane ese , sum hobe . 11,12,1,22,3 esob sequence lagbe na.
    {
        ans=max(ans,check());
        return;

    }
    for(int j=curr;j<=m;j++) //A sequence tar max value hote pare m
    {
        A.push_back(j);
        makesequence(i+1,j);
        A.pop_back(); // 111 jokhn hobe then recursion sesh hole last er 1 pop hoye j++ hobe then 112 hobe .tai pop
    }
}
int main()
{
    cin>>n>>m>>q;
    a=b=c=d=vector<int>(q); //sob gular size q

    for(int i=0;i<q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i]; // ai,bi,ci,di nilam q times
    }

    makesequence(0,1);

    cout<<ans<<endl;
}


Measured memory_bytes: 3640
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int nmap[410][410];
pair<int, int> pmap[410 * 410];
vector<string> smap;
int H, W;

void dfs(int y, int x, int n)
{
	static const int dx[] = { 1,0,-1,0 };
	static const int dy[] = { 0,1,0,-1 };
	nmap[y][x] = n;
	if (smap[y][x] == '.')
	{
		pmap[n].first++;
	}
	else
	{
		pmap[n].second++;
	}
	rep(i, 0, 4)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (0 <= nx && nx < W && 0 <= ny && ny < H&&nmap[ny][nx] < n&&smap[y][x] != smap[ny][nx])
		{
			dfs(ny, nx, n);
		}
	}
}

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

	cin >> H >> W;
	string S;
	rep(i, 0, H)
	{
		cin >> S;
		smap.push_back(S);
	}

	int n = 410 * 410 - 1;
	rep(i, 0, H)rep(j, 0, W)
	{
		if (nmap[i][j] == 0)
		{
			dfs(i, j, n);
			n--;
		}
	}

	int ans = 0;
	rrep(i, n + 1, 410 * 410)
	{
		ans += pmap[i].first*pmap[i].second;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 19200
n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)):
    print(*A)
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key :
        A[j+1] = A[j]
        j -= 1
    A[j+1] = key
print(*A)

Measured memory_bytes: 7868
#include <bits/stdc++.h>
using namespace std;
int n,q,l,r;
string s;
int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    cin>>n>>q>>s;
    vector<int> X(n);
    X[0]=0;
    for (int i=0;i<n-1;++i)
		if (s[i]=='A' && s[i+1]=='C') X[i+1]=X[i]+1;
		else X[i+1]=X[i];
	for (int i=0;i<q;++i)
	{
		cin>>l>>r;
		cout<<X[r-1]-X[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1488
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll MOD = 1000000007;

ll pow(ll x,ll y){
  if(y==0){
    return 1;
  }else if(y==1){
    return x%MOD;
  }else if(y%2==0){
    return pow(x,y/2)*pow(x,y/2)%MOD;
  }else{
    return pow(x,y-1)*x%MOD;
  }
}

int main(){
  ll N;cin >> N;
  ll ans = pow(ll(10),N);
  ans = ans+pow(ll(8),N);
  ans = ans % MOD;
  ll minus = pow(ll(9),N);
  ans = ans - minus - minus;
  while(ans<0){
    ans += MOD;
  }
  cout << ans << endl;
}

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

int main(){
    int n, point_a = 0, point_b = 0;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    for (int i = 0; i < n; i += 2) point_a += a.at(i);
    for (int j = 1; j < n; j += 2) point_b += a.at(j);

    cout << point_a - point_b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define se second
const int N = 2e5+5;
ll a[N];
ll suf[N];
ll n,m;
ll ans ;
bool ch(int x){
    ll trt = 0;
    for(int i=0;i<n;i++){
        ll j = (lower_bound(a,a+n,x-a[i])-a);
        trt+=(n-j);
    }
    if(trt>=m)return true;
    else return false;
}
void solve(){
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    suf[n-1] = a[n-1];
    for(int i=n-2;i>=0;i--)suf[i] = suf[i+1]+a[i];
    int st = 0;
    int en = 2e5+5;
    while(st<=en){
        int mid = (st+en)/2;
        if(ch(mid)){
            st = mid+1;
        }
        else{
            en = mid-1;
        }
    }
    st--;
    ll trt = 0;
    for(int i=0;i<n;i++){
        ll j = (lower_bound(a,a+n,st-a[i])-a);
        ans+=suf[j];
        ans+=(n-j)*a[i];
        trt+=(n-j);
    }
    ans-=(trt-m)*st;
    cout<<ans<<endl;

}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 5132
import sys
s=list(map(str,input()))
for i in range(len(s)):
    if i%2==0 and s[i]=='L':
        print('No')
        sys.exit()
    else:
        if i%2==1 and s[i]=='R':
            print('No')
            sys.exit()
print('Yes')   

Measured memory_bytes: 3060
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), x = sc.nextInt();
		int cnt = 0;
		for(int i = 0; i <= a; i++) {
			for(int j = 0; j <= b; j++) {
				for(int k = 0; k <= c; k++) {
					if(500 * i + 100 * j + 50 * k == x) {
						cnt++;
					}
				}
			}
		}
		System.out.println(cnt);

	}

}


Measured memory_bytes: 21844
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	string s, t;
	int a, b;
	string u;
	cin >> s >> t >> a >> b >> u;
	if (s == u)--a;
	else --b;
	printf("%d\n%d\n", a, b);

	Please AC;
}


Measured memory_bytes: 888