akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, ans =0;
	cin >>n;
	
	if(n>=1800) ans=1;
	else if(n>=1600) ans =2;
	else if(n>=1400) ans =3;
	else if(n>=1200) ans =4;
	else if(n>=1000) ans =5;
	else if(n>= 800) ans =6;
	else if(n>= 600) ans =7;
	else ans = 8;
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	string a,b,c;
	int x,y;
	cin>>a>>b>>x>>y>>c;
	if (a==c) cout<<x-1<<" "<<y;
	else cout<<x<<" "<<y-1;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<b;i++)
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n) cin>>a[i];
  int ans=0;
  rep(i,0,n) ans+=a[i]-1;
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<int,int>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0}; 
int main(){
    int h,w;cin>>h>>w;
    int hh,ww;cin>>hh>>ww;
    cout<<h*w-(hh*w+ww*h-hh*ww)<<endl;
}

Measured memory_bytes: 256
import numpy as np

D = int(input())
c = list(map(int, input().split()))
c = np.array(c)
S = np.zeros([D, 26], dtype=int)
for i in range(D):
  S[i, :] = list(map(int, input().split()))

last = np.zeros(26)

#SCORE = 0
DOWN = 0

T = []
for i in range(D):
    score = S[i, :] + DOWN
    argmax = score.argmax()
    t = argmax+1
    last[t-1] = i+1
    T.append(t)
    temp = (i+1-last)*np.array(c)
    down = (temp).sum()
    down = int(down)
    DOWN += down

#score_plus = 0
T_modified = T
for i in range(5000):
    p = np.random.randint(1, 1+D)
    q1 = T[p-1]
    q2 = np.random.randint(1, 27)
    plus, minus = 0, 0
    flag1, flag2 = 1,1
    for j in range(p+1, 1+D):
        if T[j-1] != q2:
            plus += flag1
        elif T[j-1] != q1:
            minus += flag2
        elif T[j-1] == q2:
            flag1 = 0
        elif T[j-1] == q1:
            flag2 = 0
        if flag1 + flag2 == 0:
            break
    
    s = plus*c[q2-1] - minus*c[q1-1] + S[p-1, q2-1] - S[p-1, q2-1]
    if s > 0:
        T_modified[p-1] = q2
        #score_plus += s

for i in range(D):
  print(T_modified[i])


Measured memory_bytes: 27412
#include <bits/stdc++.h>
using namespace std;
using ll     = long long;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = LONG_MAX;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {cin.tie(0),ios::sync_with_stdio(0),cout<<fixed<<setprecision(10);}

ll x[200000],a[200000],N,X,S=INF;

bool is_sum_overflow(long a, long b) {
	if (a < LONG_MAX / 2) {
		if (b < LONG_MAX / 2)
			return false;
		else
			return ((b - LONG_MAX / 2) + a > LONG_MAX / 2);
	}
	else {
		if (b < LONG_MAX / 2)
			return true;
		else
			return ((a - LONG_MAX / 2) + b > LONG_MAX / 2);
	}
}

def C(ll n){
    if(n==0)return 5LL;
    return 3+2*n;
}

def solve(ll n){
    ll i=N-1,k=0,s=0;
    while(i-n>=0){
        if(is_sum_overflow(s,(a[i]-a[i-n])*C(k)))return INF;
        s+=(a[i]-a[i-n])*C(k);
        k++;
        i-=n;
    }
    s+=a[i]*C(k);
    return s+(n+N)*X;
}

signed main(){
    cin>>N>>X;
    rep(i,N){
        cin>>x[i];
        a[i]=x[i]+(i?a[i-1]:0);
    }
    up(i,1,N){
        S=min(solve(i),S);
    }
    cout<<S<<endl;
}

Measured memory_bytes: 3328
n,m=map(int,input().split())
a=[[1,int(i)] for i in input().split()]
data=[[int(i) for i in input().split()] for i in range(m)]
data.extend(a)
data.sort(key=lambda x:x[1],reverse=True)
ans=0
flag=True
index=0
while n>0:
  tmp=min(data[index][0],n)
  ans+=data[index][1]*tmp
  n-=tmp
  index+=1
print(ans)

Measured memory_bytes: 39380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007;

ll dp[1100][1100];

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w) cin >> a[i][j];
  dp[h-1][w-1] = 1;
  for(int i = h-1; i >= 0; i--) {
    for(int j = w-1; j >= 0; j--) {
      if(i==h-1 && j==w-1) continue;
      dp[i][j] = dp[i+1][j] + dp[i][j+1];
      dp[i][j] %= mod;
      if(a[i][j]=='#') dp[i][j] = 0;
    }
  }
  cout << dp[0][0] << endl;
  return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    vector<vector<int>> parts(3, vector<int>(n));
    rep(i, 3) rep(j, n) cin >> parts[i][j];

    rep(i, 3) sort(ALL(parts[i]));
    ll cnt = 0;
    rep(i, n)
    {
        int b = parts[1][i];
        auto a = lower_bound(ALL(parts[0]), b);
        auto c = upper_bound(ALL(parts[2]), b);
        cnt += (a - parts[0].begin()) * (parts[2].end() - c);
    }

    OP(cnt);

    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
 
class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
 
 
    void solve()
    {
        int d = 1;
        int N = cin.nextint;
        while ((d + 1) * (d + 1) <= N) d++;
        WriteLine(d * d);
    }
 
}
 
class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N, M; cin >> N >> M;
    vector<PII> ba(M);
    REP(i,M)
    {
        int tmpa, tmpb;
        cin >> tmpa >> tmpb;
        ba[i] = make_pair(tmpb, tmpa);
    }
    sort(ba.begin(), ba.end());
    int ans = 0;
    int maxb = 0;
    REP(i,M)
    {
        if(maxb <= ba[i].second) // まだ戦争
        {
            maxb = ba[i].first;
            ans++;
        }

    }
    cout << ans << endl;

}


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

#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'

int main()
{
 fastIO();
 long long x , temp , year;
 cin>>x;
 temp = 100;
 year = 0;
 
 while(temp<x)
 {
 	temp = temp+(temp/100);
 	year++;
 }
 
 //cout<<"total year " << year<<endl;
 
 cout<<year<<endl;
 
 
 
 

return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  string s;
  ll k;
  cin >> s >> k;

  if (k == 1){
    cout << s[0] << endl;
    return 0;
  }

  int cnt_1 = 0;
  rep(i, s.size()) {
    if (s[i] - '0' == 1) cnt_1++;
    else break;
  }
  if (cnt_1 >= k){
    cout << 1 << endl;
    return 0;
  }

  int ans = 1;
  rep(i, s.size()){
    int v = s[i] - '0';
    if (v > 1) {
      ans = v;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int X, Y;
    cin >> X >> Y;
    int rest = Y-2*X;
    if(rest>=0 && rest%2==0 && rest<=2*X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int dp[105];

int main(void){
    int n;
    cin >> n;
    vector<int>h;
    rep(i,n){
        int x;
        cin >> x;
        h.push_back(x);
    }
    dp[0] = h[0];
    for(int i=1;i<n;i++){
        if(h[i] < h[i-1]){
            dp[i] = dp[i-1];
        }
        else{
            dp[i] = dp[i-1]+h[i]-h[i-1];
        }
    }
    
    cout << dp[n-1] <<endl;
    return 0;
}

















































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

using namespace std;

#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << endl
#define LINE cout << "line : " << __LINE__ << endl
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) ;
#define LINE     ;
#define dumpV(v);
#define STOP     ;
#endif
#define mp make_pair

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


int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
        --a[i];
    }
    vi idx(n);
    rep(i, n) idx[a[i]] = i;
    vl l(n, -1), r(n, -1);
    vl l2(n, -1), r2(n, -1);
    {
        set<int> st;
        repr(i, n) {
            auto it = st.upper_bound(idx[i]);
            if (it != st.end()) {
                r[idx[i]] = *it;

                auto it2 = st.upper_bound(*it);
                if (it2 != st.end()) {
                    r2[idx[i]] = *it2;
                }
            }
            st.insert(idx[i]);
        }
    }
    {
        set<int> st;
        repr(i, n) {
            auto it = st.lower_bound(idx[i]);
            if (it != st.begin()) {
                --it;
                l[idx[i]] = *it;
                
                auto it2 = st.lower_bound(*it);
                if(it2 != st.begin()) {
                    --it2;
                    l2[idx[i]] = *it2;
                }
            }
            st.insert(idx[i]);
        }
    }
    ll ans = 0LL;
    rep(i, n) {
        if (l[i] >= 0) {
            ll R = r[i];
            if (R < 0) R = n;

            ll L2 = l[i]-1;
            if(l2[i] >= 0) L2 = l2[i];
            else L2 = min(L2, -1LL);
            
            ans += (R - i) * (a[i]+1) * (l[i]-L2);
            // dump(mp(i, mp(R, L2)));
        }
        if (r[i] >= 0) {
            ll L = l[i];
            if (L < 0) L = -1;

            ll R2 = r[i]+1;
            if(r2[i] >= 0) R2 = r2[i];
            else R2 = n;

            ans += (i - L) * (a[i]+1) * (R2-r[i]);
            // dump(mp(i, mp(L, R2)));

        }
    }
    // dumpV(l);
    // dumpV(l2);
    // dumpV(r);
    // dumpV(r2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define N 210
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define pii pair<int, int>
#define forn(i, n) for(ll i = 0; i < n; ++i)
#define forn1(i, n) for(int i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI 3.141592653589793238462643383279502884L
#define elif else if
#define lld long double
#define r0 return 0
#define EPS 1e-7
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

const int inf = 1e9 + 1;
const ll modw = 1e9 + 9;
  
using namespace std;
using namespace __gnu_pbds;

int gcd(int a_a, int b_b)
{
	return b_b?gcd(b_b,a_a%b_b):a_a;
}

bool used[N];
int p[N];

int main()
{
    barnarnar
	int x, n;
	cin >> x >> n;
	forn(i, n)	cin >> p[i], used[p[i]] = 1;
	pair<int, int> ans = mp(inf,inf);
	forn(i, 400)
	{
		if(!used[i])
		{
			if(abs(i - x) < ans.fi)
			{
				ans.fi = abs(i - x);
				ans.se = i;
			}
		}
	}
	cout << ans.se;
    return 0;
}
/*
1
1
FMMMMFFFFFMM 1
*/



Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int a,b,c,d;
    while(cin>>a>>b>>c>>d)
        {
            int ans=0;
            for(int i=0; i<=100; i++)
                {
                    if((i>=a && i<=b)&&(i>=c&&i<=d))
                        ans++;
                }
            printf("%d\n",ans-1>=0?ans-1:0);
        }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

vector<pair<ll, ll>> Factor(ll n){
    vector<pair<ll, ll>> res;
    ll sq = sqrt(n) + 1;
    for(int i = 2; i <= sq; i++){
        sq = sqrt(n) + 1;
        if(n%i == 0){
            ll cnt = 0;
            while(n%i == 0){
                n/=i;
                cnt++;
            }
            res.push_back(make_pair(i, cnt));
        }
    }
    if(n != 1)res.push_back(make_pair(n, 1));
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    vector<ll> prime(1100000, 0);
    rep(i, n){
        vector<pair<ll, ll>> p = Factor(a[i]);
        rep(j, p.size())prime[p[j].first] = max(prime[p[j].first], p[j].second);
    }

    ll lcm = 1;
    for(ll i = 2; i < 1100000; ++i){
        if(prime[i] > 0)rep(j, prime[i])lcm *= i, lcm %= MOD;
    }

    ll ans = 0;
    rep(i, n)ans = (ans + lcm * modpow(a[i], MOD-2, MOD)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 8960
S = input()

if 1<= int(S[:2]) <= 12:
    if 1<= int(S[2:4]) <= 12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<= int(S[2:4]) <= 12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int> card(N);
  for(int i=0; i<N; i++){
    cin >>card.at(i);
  }
  sort(card.begin(), card.end());
  reverse(card.begin(), card.end());
  int A=0,B=0;
  for(int i =0;i<N; i++){
    if(i%2 ==0){
      A +=card.at(i);
    }
    else{
      B +=card.at(i);
    }
  }
  cout << A-B <<endl;

}

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

int main() {
  int a, b, c, d;
  int train, bus;
  cin >> a >> b >> c >> d;
  if(a >= b)
    train = b;
    else
    train = a;

  if(c >= d)
    bus = d;
    else
    bus = c;

  cout << train + bus << endl;

}

Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static final Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		int A = nextInt();
		int B = nextInt();
		double X = (double)nextInt();
		double s = X / A;

		double res = 0;
        if (s * 2 < A * B) {
            double t = s * 2 / B;
            res = Math.PI / 2 - Math.atan2(t, B);
        } else {
            double t = (A * B - s) * 2 / A;
            res = Math.atan2(t, A);
        }
        res *= 180 / Math.PI;

		out.println(res);
	}


	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}

	long gcd(long m,long n) {
		if (m<n) return gcd(n,m);
		if (n==0)return m;
		return gcd(n,m%n);
	}
}

Measured memory_bytes: 22732
#include <stdio.h>

int main(void)
{
	int n, i, p;
	int NotPlusOneNumCount = 0;

	scanf("%d", &n);

	//1,2,3...Nの並びと、与えられた数列Pで一致しない箇所があれば NotPlusOneNumCount を 1 増やす
	for (i = 1; i <= n; i++) {
		scanf("%d", &p);
		if (p != i) {
			NotPlusOneNumCount++;
		}
		//NotPlusOneNumCountが2より大きいとき、昇順にできない
		if (NotPlusOneNumCount > 2) {
			printf("NO\n");
			return 0;
		}
	}

	printf("YES\n");

	return 0;
}

Measured memory_bytes: 128
#include <iostream>

#include <string>
using namespace std;

int main(void){
    string S;
    cin >> S;

    bool usability = true;
    for(int i = 0; i < S.size() - 1; ++i){
        if(S[i] == S[i + 1]){
            usability = false;
        }
    }
    if(usability){
        cout << "Good" << endl;
    }else{
        cout << "Bad" << endl;
    }
    return 0;;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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

long long int gcd(long long int a, long long int b) { //最大公約数
	if (b == 0) {
		return a;
	}
	return gcd(b, a%b);
}


long long int lcm(long long int a, long long int b) { //最小公倍数
	long long int g = gcd(a, b);
	return a / g * b;
}


int main(void) {
	
	long long int n, m;
	long long int l = -1;
	long long int maxi;
	long long int mini;
	long long int ss, ts;
	long long int p, q;
	string s, t;

	cin >> n >> m;
	cin >> s >> t;

	ss = s.size();
	ts = t.size();

	maxi = lcm(ss, ts);
	mini = gcd(ss, ts);

	if (mini == 1) {
		if (s[0] == t[0]) {
			l = maxi;
		}
	}
	else {
		ss /= mini;
		ts /= mini;
		p = 0;
		q = 0;
		l = maxi;
		while (p < ss*mini && q <ts*mini) {
			//cout << p << " " << q << endl;
			if (s[p] == t[q]) {
				p += ss;
				q += ts;
			}
			else {
				l = -1;
				break;
			}
		}
	}

	cout << l << endl;


	return 0;
}

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

char readchar() {
  static char buf[1 << 18], *ptr = buf, *end = buf;
  if (ptr == end) ptr = buf, end = buf + fread(buf, 1, 1 << 18, stdin);
  return *ptr++;
}
void writechar(char c) {
  static char buf[1 << 18], *ptr = buf;
  if (ptr == std::end(buf) or c == '\0')
    fwrite(buf, 1, ptr - buf, stdout), ptr = buf;
  *ptr++ = c;
}
__attribute__((destructor)) void destructor() { writechar('\0'); }
template <class T = int>
T getint() {
  char c{};
  while (c < '-') c = readchar();
  bool neg = c == '-';
  T res = neg ? 0 : c - '0';
  while ((c = readchar()) >= '0') res = res * 10 + (c - '0');
  return neg ? -res : res;
}
template <class T>
void putint(T a, char delim = '\n') {
  if (a < 0) writechar('-'), a = -a;
  char buf[sizeof(T) * 3], *ptr = buf;
  do
    *ptr++ = '0' + a % 10;
  while (a /= 10);
  while (ptr-- > buf) writechar(*ptr);
  writechar(delim);
}
#define cin void(0)
#define cout void(0)

struct dsu {
  dsu(int n = 0) : _cc(n), dat(n, -1) {}

  int root(int v) {
    assert(0 <= v), assert(v < size());
    return dat[v] < 0 ? v : dat[v] = root(dat[v]);
  }
  bool unite(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    u = root(u), v = root(v);
    if (u == v) return false;
    --_cc;
    if (-dat[u] < -dat[v]) std::swap(u, v);
    dat[u] += dat[v];
    dat[v] = u;
    return true;
  }
  bool same(int u, int v) {
    assert(0 <= u), assert(u < size());
    assert(0 <= v), assert(v < size());
    return root(u) == root(v);
  }
  int size(int v) {
    assert(0 <= v), assert(v < size());
    return -dat[root(v)];
  }
  int size() const { return std::size(dat); }
  int cc() const { return _cc; }

 private:
  int _cc;
  std::vector<int> dat;
};

int main() {
  using namespace std;
  int n = getint(), q = getint();
  dsu d(n);
  while (q--) {
    int t = getint(), u = getint(), v = getint();
    if (t == 0)
      d.unite(u, v);
    else
      putint<int>(d.same(u, v));
  }
}


Measured memory_bytes: 4232
#include <cstdio>

using namespace std;

typedef long long int LONGLONG;

int c[505], s[505], f[505];
int n;

LONGLONG solve(int from) {
    LONGLONG ans = s[from];
    for (int i = from; i < n; ++i) {
        ans += c[i];
        if (i + 1 < n) {
            LONGLONG wait = 0LL;
            if (ans < s[i + 1])
                wait = s[i + 1] - ans;
            else {
                if ((ans - s[i + 1]) % f[i + 1])
                    wait = f[i + 1] - (ans - s[i + 1]) % f[i + 1];
            }
            ans += wait;
        }
    }
    return ans;
}

int main(int argc, char* argv[]) {
    scanf("%d", &n);
    for (int i = 1; i < n; ++i)
        scanf("%d%d%d", &c[i], &s[i], &f[i]);

    for (int i = 1; i <= n; ++i)
        printf("%lld\n", solve(i));

    return 0;
}


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

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

  vector<int> routes(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    routes[x - 1] = routes[x - 1] + 1;
    routes[y - 1] = routes[y - 1] + 1;
  }

  for (int i = 0; i < N; i++) {
    cout << routes[i] << endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <cstdlib>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
int main(){
  long long K;
  long long A[50];
  cin>>K;
  cout<<50<<endl;
  long long M=K/50;
  long long N=K%50;
  FOR(i,N,50){
    A[i]=M;
    M++;
  }
  M++;
  FOR(i,0,N){
    A[i]=M;
    M++;
  }
  FOR(i,0,50){
    if(i){
      cout<<" ";
    }
    cout<<A[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
int a[100000];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long x=-1e18;
    x=max({x,b*d,a*c,b*c,a*d});
    cout<<x<<"\n";
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   string s;
    cin >> s;
    
   int res = 0;
    int cnt = 0;
    
   for(auto x : s)
       if(x == 'R') cnt++;
       else res = max(res,cnt), cnt = 0;
    
   res = max(res,cnt);
             
    cout << res;
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <climits>
#include <functional>
#include <cmath>

using namespace std;

long double solve() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.precision(22);

    long long n, m, d;
    cin >> n >> m >> d;

    return (long double) (m-1) * (d == 0 ? n : 2*(n-d)) / n / n;
}
int main() {
    cout << solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
int N;
int A[3000];
ll dp[3001][3001]; // dp[l][r] = 左からl個、右からr個とった状態からスタートしたときのX-Y
const ll INF = 1e15;

ll dfs(int l, int r) {
  if (l + r == N) return 0;
  if (dp[l][r] != INF) return dp[l][r];

  if ((l+r) % 2 == 0)
    return dp[l][r] = max(dfs(l+1, r) + A[l], dfs(l, r+1) + A[N-1-r]);
  return dp[l][r] = min(dfs(l+1, r) - A[l], dfs(l, r+1) - A[N-1-r]);
}
int main() {
  cin >> N;

  rep(i, N)
    cin >> A[i];

  rep(i, N+1) rep(j, N+1) dp[i][j] = INF;

  cout << dfs(0, 0) << endl;
  return 0;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  ll x = N / K;
  ll ans = x * x * x;
  
  if (K % 2 == 0) {
    ll y = (N + K / 2) / K;
    ans += y * y * y;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    char str[222];
    cin>>str;
    int n=strlen(str);
    for(int i=n-2;i;i-=2){
        if(strncmp(str,str+i/2,i/2)==0){
            cout<<i;
            return 0;
        }    
    }
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

long long const MOD = 1000000007LL;

int main() {
    string s;
    cin >> s;

    string res = "No";
    if (s[0] == s[1] && s[2] == s[3]) res = "Yes";
    else if (s[0] == s[2] && s[1] == s[3]) res = "Yes";
    else if (s[0] == s[3] && s[1] == s[2]) res = "Yes";

    if (s[0] == s[1] && s[0] == s[2] && s[0] == s[3]) res = "No";

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
	string s, ans = "Yes";
	int j = 0;
	cin >> s;
	for (int i = 0; i < (s.size() - 1) / 2; i++) {
		if (s[i] != s[s.size() - i - 1]) ans = "No";
	}
	for (int i = 0; i < (s.size() - 1) / 2 / 2; i++) {
		if (s[i] != s[(s.size() - 1) / 2 - 1 - i]) ans = "No";
	}
	for (int i = (s.size() + 3) / 2 - 1; i < s.size() - 1; i++) {
		if (s[i] != s[s.size() - 1 - j]);
		j++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}
 
int main() {
 int N;
 cin>>N;
 vector<int>X(N),Y(N);
 for(int i=0;i<N;i++){
   cin>>X[i];
 }
 Y=X;
 int a=N/2;
 int b=a-1;
 sort(Y.begin(),Y.end());
 for(int i=0;i<N;i++){
  if(X[i]<Y[a]){cout<<Y[a]<<endl;}
  else{cout<<Y[b]<<endl;}
 }
 return 0;
}

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

int N;
int A[200];

int main() {

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

    int res = 0;

    while (true) {
        bool exist_odd = false;
        for(int i = 0; i < N; ++i) {
            if (A[i] % 2 != 0) exist_odd = true;
        }
        if(exist_odd) break;

        for(int i = 0; i < N; ++i){
            A[i] /= 2;
        }
        ++res;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
pub struct Scanner {
	handle: std::io::Stdin,
	buffer: std::collections::VecDeque<String>
}

impl Scanner {
	pub fn new() -> Scanner {
		Scanner {
			handle: std::io::stdin(),
			buffer: std::collections::VecDeque::new()
		}
	}
	pub fn next<T: std::str::FromStr>(&mut self) -> Result<T, T::Err> {
		if self.buffer.len() == 0 {
			loop {
				let mut available = String::new();
				self.handle.read_line(&mut available).unwrap();
				self.buffer = available.split_whitespace().map(String::from).collect();
				if self.buffer.len() > 0 {
					break;
				}
			}
		}
		T::from_str(&self.buffer.pop_front().unwrap())
	}
}

fn main() {
	let mut scanner = Scanner::new();
	let a: f64 = scanner.next().unwrap();
	let b: f64 = scanner.next().unwrap();
	let h: f64 = scanner.next().unwrap();
	let m: f64 = scanner.next().unwrap();
	let theta_h = (h*30.0 + m/2.0) * std::f64::consts::PI / 180.0;
	let theta_m = m*6.0 * std::f64::consts::PI / 180.0;
	let sqr = a*a + b*b - 2.0*a*b*(theta_h-theta_m).cos();
	println!("{:?}", sqr.powf(0.5));
}


Measured memory_bytes: 2996
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

//#include "sort/bsearch.h"

//find largest x in [s,t) which check(x) is true
template<class T>
T bsearch_largest(T s, T t, int check(T)) {
	s--;
	while (t-s>1) {
		T m = (s+t)/2;
		if (check(m)) s = m;
		else t = m;
	}
	return s;
}

//find smallest x in [s,t) which check(x) is true
template<class T>
T bsearch_smallest(T s, T t, int check(T)) {
	s--;
	while (t-s>1) {
		T m = (s+t)/2;
		if (check(m)) t = m;
		else s = m;
	}
	return t;
}

//#include "sort/merge.h"

template<class I, class N=long>
N merge(I a, I ea, I b, I eb, I &c) {
	N inv = 0;
	N n = std::distance(a, ea);
	while (a != ea && b != eb) {
		if (*b < *a) {
			*c++ = *b++;
			inv += n;
		}
		else {
			*c++ = *a++;
			n -= 1;
		}
	}
	while (a != ea) *c++ = *a++;
	while (b != eb) *c++ = *b++;
	return inv;
}


//return reverse pair count
template<class I, class N=long>
N merge_sort(const I &a, const I &e, I tmp) {
	int n = std::distance(a, e);
	if (n<2) return 0;
	auto m = std::next(a, n/2);
	auto t = tmp;
	N left  = merge_sort(a, m, t);
	N right = merge_sort(m, e, t);
	N both  = merge(a, m, m, e, t);
	copy(tmp, t, a);
	return left + right + both;
}

template<class C, class N=long>
N merge_sort(C &a) {
	int n = a.size();
	if (n<2) return 0;
	C t;
	//TODO
	auto i = back_inserter(t);
	return merge_sort(a.ebgin(), a.end(), i);
}
//#include "seq/psum.h"

//b[i] = sum:a[0,i), b can be a-1
template<class I>
void psum_create_z(I a, I e, I b) {
	*b = 0;
	while (a != e) {
		auto x = (*b++) + (*a++);
		*b = x;
	}
}

template<class I>
void psum_create(I a, I e) {
	if (a==e) return;
	auto s = *a++;
	while (a != e) {
		s = s + *a;
		*a++ = s;
	}
}


#define MAXN 100000

int n;
int a[MAXN], b[MAXN+1], c[MAXN+1];

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

int is_median(int x) {
	for (int i=0; i<n; i++)
		b[i+1] = (a[i]>=x) ? 1: -1;
	//printa(a, n); printa(b+1, n);
	psum_create_z(b+1, b+n+1, b);
	//printa(b, n+1);

	long inv = merge_sort(b+0, b+n+1, c+0);

	/*
	long inv = 0;
	for (int i=0; i<=n; i++)
		for (int j=i+1; j<=n; j++)
			if (b[i]>b[j]) inv++;
	*/

	long m = long(n)*(n+1)/2;
	long cnt = m-inv;
	int ok = cnt >= (m+1)/2;
	//p(x, 'i', inv, 'c', cnt, 'm', m, ok);
	return ok;
}

long solve() {
	int ma = *max_element(a, a+n), mi = *min_element(a, a+n);
	return bsearch_largest(mi, ma+1, is_median);
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
}

int main() {
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





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

void print_vec(vector<int> vec)
{
  cout << "[";
  for (int i = 0; i < vec.size(); i++)
  {
    cout << vec.at(i);
    if (i < vec.size() - 1)
    {
      cout << ", ";
    }
  }
  cout << "]...size: " << vec.size() << endl;
}

int main()
{
  map<string, int> hash;
  hash["right"] = 0;
  hash["acute"] = 0;
  hash["obtuse"] = 0;

  bool judge = true;
  while (judge)
  {
    int a, b, c;
    cin >> a >> b >> c;

    if (a + b <= c || b + c <= a || c + a <= b)
    {
      judge = false;
    }
    else
    {
      vector<int> vec(3);
      vec.at(0) = a * a;
      vec.at(1) = b * b;
      vec.at(2) = c * c;
      sort(all(vec));
      int x = vec.at(0);
      int y = vec.at(1);
      int z = vec.at(2);
      if (z == x + y)
      {
        hash.at("right") += 1;
      }
      else if (z < x + y)
      {
        hash.at("acute") += 1;
      }
      else
      {
        hash.at("obtuse") += 1;
      }
    }
  }

  printf("%d %d %d %d\n", hash["right"] + hash["acute"] + hash["obtuse"], hash["right"], hash["acute"], hash["obtuse"]);
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
//#define int long long
#define INF 1000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

bool is_needed(vec &vals, int i, int K){
    vector<bool> dp(K, false);
    dp[0] = true;
    REP(j, vals.size()){
        vector<bool> tmp = dp;
        if(j == i) continue;
        REP(k, K - vals[j]) if(dp[k]) tmp[k + vals[j]] = true;
        dp = tmp;
    }
    bool needed = false;
    FOR(k, K - vals[i], K){
        if(dp[k]){
            needed = true;
            break;
        }
    }
    return needed;
}

signed main(){

    int N, K; cin >> N >> K;
    vec a(N); readvec(a);
    vec vals(0);
    REP(i, N) if(a[i] < K) vals.push_back(a[i]);

    SORT(vals);
    if(vals.size() == 0){
        cout << 0;
        return 0;
    }
    if(is_needed(vals, 0, K)){
        cout << 0;
        return 0;
    }

    int i1 = 0, i2 = vals.size();
    while(i2 - i1 > 1){
        int i = (i1 + i2) / 2;
        if(is_needed(vals, i, K)){
            i2 = i;
        }else{
            i1 = i;
        }
    }
    
    cout << i2;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j,k,p,l=0,q;
	string st1[100],st2[100];
	cin >> n >> m;
	for(i=0; i<n; i++)
		cin >> st1[i];
	for(i=0; i<m; i++)
		cin >> st2[i];
	for(i=0; i<=n-m; i++)
	{
		for(j=0; j<=n-m; j++)
		{
			q=0;
			for(k=0; k<m; k++)
			{
				for(p=0; p<m; p++)
					if(st1[i+k][j+p]!=st2[k][p]) q=1;
			}
			if(q==0) l=1;
		}
	}
	if(l==1) cout <<"Yes";
	else cout << "No";
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace CSharp
{
    class Program
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            var R = new List<int>();
            var G = new List<int>();
            var B = new List<int>();
            for (int i = 0; i < N; i++)
            {
                if (S[i] == 'R')
                {
                    R.Add(i);
                }
                else if (S[i] == 'G')
                {
                    G.Add(i);
                }
                else
                {
                    B.Add(i);
                }
            }

            var result = 0L;
            for (int i = 0; i < R.Count; i++)
            {
                var ix = R[i];
                for (int j = 0; j < G.Count; j++)
                {
                    var jx = G[j];

                    var d = Math.Abs(ix - jx);
                    if (B.Contains(Math.Max(ix, jx) + d))
                    {
                        result--;
                    }
                    if (B.Contains(Math.Min(ix, jx) - d))
                    {
                        result--;
                    }
                    if ((ix + jx) % 2 == 0 && B.Contains((ix + jx) / 2))
                    {
                        result--;
                    }
                    result += B.Count;
                }
            }
            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 27836
#include<iostream>
#include<cstdio>

using namespace std;

int binSearch(int A[], int n, int key){
    int left = 0, right = n, mid;
    while(left < right) {
        mid = (left+right)/2;
        if(key == A[mid]) return 1;
        if(key < A[mid]) right = mid;
        if(key > A[mid]) left = mid+1;
    }
    return 0;
}

int main(int argc, char const *argv[])
{
    int i,n,q,A[100001],key,sum = 0;

    cin >> n;
    for( i=0; i<n; i++) scanf("%d",&A[i]);

    cin >> q;
    for (int i = 0; i < q; ++i)
    {
        scanf("%d",&key);
        sum += binSearch(A, n, key);
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  int a[n];
  rep(i,0,n) cin>>a[i];
  int b=0;
  while(true){
    bool p=true;
    rep(i,0,n){
      if(a[i]%2==0) a[i]/=2;
      else p=false;
    }
    if(!p) break;
    b++;
  }
  cout<<b<<endl;
}

Measured memory_bytes: 256
from collections import deque

def read():
    N = int(input().strip())
    G = [list() for _ in range(N+1)]
    H = [list() for _ in range(N+1)]
    pairs = []
    for i in range(N-1):
        a, b = list(map(int, input().strip().split()))
        G[a].append(b)
        G[b].append(a)
        H[a].append(i)
        H[b].append(i)
    return N, G, H

def paint_edges(N, G, max_edges, H):
    C = [-1 for _ in range(N-1)]
    q = deque()
    q.appendleft((1, -1))
    while(len(q) > 0):
        s, c = q.pop()
        for i in range(len(G[s])):
            t = G[s][i]
            idx = H[s][i]
            if C[idx] == -1:
                c = (c + 1) % max_edges
                C[idx] = c
                q.append((t, c))
    return C


def solve(N, G, H):
    max_edges = 0
    for i in range(N):
        max_edges = max(max_edges, len(G[i]))
    C = paint_edges(N, G, max_edges, H)
    return max_edges, C

if __name__ == '__main__':
    inputs = read()
    max_edges, C = solve(*inputs)
    print(max_edges)
    for c in C:
        print(c+1)

Measured memory_bytes: 77104
n, k = map(int, input().split())

top = [0]*n # t毎に最高のdを格納するlist
sub = [] # それ以外のdを格納するlist
cst = [0] # cumsum top
css = [0] # cumsum sub

for _ in range(n):
    t, d = (int(i) for i in input().split())
    t -= 1
    if top[t] == 0:
        top[t] = d
    elif d > top[t]:
        sub.append(top[t])
        top[t] = d
    else:
        sub.append(d)

top.sort(reverse=True)
sub.sort(reverse=True)

for i in range(n): # カテゴリ内最大のdが高い順に累積
    if top[i] != 0:
        cst.append(cst[-1] + top[i])

for i in range(len(sub)): # それ以外の全てのカテゴリの寿司のdが高い順に累積
    css.append(css[-1] + sub[i])

po = 0
for i in range(1, k+1):
    if len(cst)-1 >= i and len(css)-1 >= k-i:
        po = max(cst[i] + css[k-i] + i*i, po)

print(po)

Measured memory_bytes: 12212
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

int main()
{
	int N;
	cin >> N;
	vector<int> A(N), B(N), C(N - 1);
	rep(i, N)cin >> A[i];
	rep(i, N)cin >> B[i];
	rep(i, N - 1)cin >> C[i];

	int res = 0;
	rep(i, N) {
		res += B[A[i] - 1];
	}
	rep(i, N - 1) {
		if (A[i] + 1 == A[i + 1]) {
			res += C[A[i] - 1];
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define xxx         exit(0);
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x)/log(base));
}
ll n,k,dp[100005],h[100005];
ll cc(ll ind)
{
	if(ind==0) return 0;
	if(dp[ind]!=-1) return dp[ind];
	ll ans=mod;
	repi(i,1,k)
	{
		if(ind-i>=0)
		ans=min(ans,cc(ind-i)+abs(h[ind]-h[ind-i]));
	}
	return dp[ind]=ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll i,l,j,x1,y1,ans,x,y,q;
    	cin>>n>>k;
    	rep(i,0,n) cin>>h[i];
		repi(i,0,n) dp[i] = -1;
		cout<<cc(n-1);
	}
	return 0;
}














Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;


int main(){
    ll a,b;
    cin>>a>>b;
   
    //odd
    if(b%2==1){
        if((b+1)%4==0)b=0;
        else b=1;
    }
    //even
    else if(b%4!=0)b^=1;

    if(a==0){
        ll ans=b^a;
        cout<<ans<<endl;
        return 0;
    }
    a--;
    if(a%2==1){
        if((a+1)%4==0)a=0;
        else a=1;
    }
    //even
    else if(a%4!=0)a^=1;
    
    ll ans=a^b;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n>>s;
    for(char c:s)
    {
        int x=c-'A';
        x=(x+n)%26;
        putchar('A'+x);
    }
    
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int a[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int x;
        cin >> x;
        a[x]++;
    }
    for (int i = 1; i <= n; i++)
        cout << a[i] << '\n';
}

Measured memory_bytes: 4364