akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll & a, ll  b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll & a, ll b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N=500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin>>n;
    vl A;
    rep(i,n){
        cin>>x;
        A.push_back(x);
    }

    if(n%2==1){
        a=0;
        rep(i,n){
            a+=A[i];
        }

        if(a%2==1)cout<<"First"<<endl;
        else cout<<"Second"<<endl;
    }
    else{
        x=INF;
        a=0;
        rep(i,n){
            a+=A[i];
            x=min(x,A[i]);
        }
        if(a%2==0&&x%2==0)cout<<"Second"<<endl;
        else cout<<"First"<<endl;
    }
}


Measured memory_bytes: 4968
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n;
    cin >> n;
    print(n * n * n);
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;



int main(){

int N,M;
cin>>N>>M;
int modsum[M],Xsum[100001];
rep(i,M)modsum[i]=0;
rep(i,100001)Xsum[i]=0;
rep(i,N){
    int X;
    cin>>X;
    Xsum[X]++;
    modsum[X%M]++;
}
int count=0;
rep3(i,100000){
    
    if((Xsum[i]>=2)&&(modsum[i%M]>=modsum[(M-i%M)%M]+2)){
        if(Xsum[i]>=modsum[i%M]-modsum[(M-i%M)%M]){
            count+=(modsum[i%M]-modsum[(M-i%M)%M])/2;
            modsum[i%M]-=(modsum[i%M]-modsum[(M-i%M)%M])/2*2;
        }
        else{
            count+=Xsum[i]/2;
            modsum[i%M]-=Xsum[i]/2*2;
        }

    }
    
}
for(int i=1;i<=M/2;i++){
    if((M%2==0)&&(i==M/2))continue;
count+=min(modsum[i],modsum[(M-i)%M]);
}
count+=modsum[0]/2;
if(M%2==0)count+=modsum[M/2]/2;
cout<<count<<endl;

return 0;
}

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

// https://beta.atcoder.jp/contests/abc113/tasks/abc113_a
void c113_a()
{
	int x, y;
	cin >> x >> y;
	cout << x + y / 2 << endl;
}

int main()
{
	c113_a();
	return 0;
}


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

using namespace std;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<int> num(n);
		for(int i = 0; i < n; ++i)
		{
			cin >> num[i];
		}
		vector<int> memo(n);
		memo[0] = num[0];
		for(int i = 1; i < n; ++i)
		{
			if(memo[i - 1] + num[i] > num[i])
			{
				memo[i] = memo[i - 1] + num[i];
			}
			else
			{
				memo[i] = num[i];
			}
		}
		int max_num = -999999999;
		for(int i = 0; i < n; ++i)
		{
			if(max_num < memo[i])
			{
				max_num = memo[i];
			}
		}
		cout << max_num << endl;
	}
}

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

Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

char itoc(int i)
{
    return char(i+48);
}

int main()
{
    int h,w;
    cin>>h>>w;
    vector< vector<char> > m1(h,vector<char>(w));
    rep(i,h) rep(j,w) cin>>m1[i][j];

    vector< vector<char> > m2(h,vector<char>(w));
    rep(i,h)
    {
        rep(j,w)
        {
            int count=0;
            if(m1[i][j]=='#')
            {
                m2[i][j]='#';
                continue;
            }
            for (int k = -1; k < 2; k++)
            {
                int index_y=i+k;
                if(index_y<0 || index_y>h-1) continue;
                for (int l = -1; l < 2; l++)
                {
                    int index_x=j+l;
                    if(index_x<0 || index_x>w-1) continue;
                    if(m1[index_y][index_x]=='#') count++;
                }
            }
            m2[i][j]=itoc(count);
        }
    }
    rep(i,h)
    {
        rep(j,w)cout<<m2[i][j];
        cout<<endl;
    }

    return 0;
}

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

int main() {
	int k, n;
	cin >> k >> n;
	int m_dist = 0, a, b, start, goal;
	cin >> a;
	start = a;
	for (int i = 1; i < n; i++) {
		cin >> b;
		m_dist = max(m_dist, b - a);
		a = b;
	}
	goal = b;
	m_dist = max(m_dist, k - goal + start);
	cout << k - m_dist << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <queue>
#include <map>

using namespace std;

int main()
{
  int tmp;
  priority_queue<pair<int,string>, vector<pair<int,string> >, greater<pair<int,string> > > P;
  map<string, int> map;
  P.push(make_pair(0,"01234567"));
  map.insert(make_pair("01234567",0));
  for(;!P.empty();)
    {
      pair<int,string> tmp=P.top();
      P.pop();
      for(int i=0;i<8;i++)
	{
	  if(tmp.second[i]=='0')
	    {
	      string ss=tmp.second;
	      //		      cout<<"i:"<<i<<" str="<<ss<<endl;
	      if(i!=3 && i!=7)
		{
		  ss=tmp.second;
		  swap(ss[i],ss[i+1]);
		  //  cout<<"swap:"<<i<<" "<<i+1<<" "<<ss<<endl;
		  if(map.insert(make_pair(ss,tmp.first+1)).second==1)
		    P.push(make_pair(tmp.first+1,ss));
		}
	      if(i!=0 && i!=4)
		{
		  ss=tmp.second;
		  swap(ss[i-1],ss[i]);
		  //			  cout<<"swap:"<<i-1<<" "<<i<<" "<<ss<<endl;
		  if(map.insert(make_pair(ss,tmp.first+1)).second==1)
		    P.push(make_pair(tmp.first+1,ss));
		}
	      if(i<4)
		{
		  ss=tmp.second;
		  swap(ss[i],ss[i+4]);
		  //			  cout<<"swap:"<<i<<" "<<i+4<<" "<<ss<<endl;
		  if(map.insert(make_pair(ss,tmp.first+1)).second==1)
		    P.push(make_pair(tmp.first+1,ss));
		}
	      else if(i>3)
		{
		  ss=tmp.second;
		  swap(ss[i-4],ss[i]);
		  //			  cout<<"swap:"<<i-4<<" "<<i<<" "<<ss<<endl;
		  if(map.insert(make_pair(ss,tmp.first+1)).second==1)
		    P.push(make_pair(tmp.first+1,ss));
		}
	    }
	}
      //	  	  cout<<tmp.first<<" "<<tmp.second<<endl;
    }
  
  
  
  for(;cin>>tmp;)
    {
      string s;
      s+=tmp+'0';
      for(int i=0;i<7;i++)
	{
	  cin>>tmp;
	  s+=tmp+'0';
	}
      int ans=-1;
      cout<<map[s]<<endl;
    }
}

Measured memory_bytes: 3468
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};




signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;

    char x;
    cin>>x;
    cout<<(char)(x-'a'+1+'a')<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
    アリナ・グレイが好きです。
*/

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

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

int main(void){
    int k;
    long long int sum = 0;
    cin >> k;
    
    for(int i = 1;i <= k;i++){
        for(int j = 1;j <= k;j++){
            for(int l = 1;l <= k;l++){
                if(i == j && j == l)sum += i;
                else if(i == j)sum += gcd(i,l);
                else if(i == l)sum += gcd(i,j);
                else if(l == j)sum += gcd(i,j);
                else {
                    int a = gcd(i,j);
                    sum += gcd(a,l);
                }
            }
        }
    }
    
    cout << sum << endl;
    
}


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll X;
  IN(X);
  if(X>=30){
    OUT("Yes");
  }else{
    OUT("No");
  }

  return 0;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void){

  int a,b,c,d,e;
  int total_time;
  
  while(cin >> a >> b >> c >> d >> e){

    total_time=0;

    if(a<0)
      total_time=total_time+(-1)*a*c+b*e+d;
    else if(a>0)
      total_time+=e*(b-a);

    cout << total_time << endl;

  }

  return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;
  vint a(n);
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  map<int, int> mp;
  vint vec;
  for(int i = 0; i < n; ++i) {
    mp[a[i]]++;
  }
  for(auto p : mp) vec.push_back(p.second);
  sort(all(vec));
  reverse(all(vec));
  int cnt = 0;
  reps(i, k, vec.size()) cnt += vec[i];
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 16500
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

    int n; cin >> n;
    string s; cin >> s;

    vector<int> a(n, 0);
    REP(i, n) a[i] = s[i] % 3;

    vector<int> count(3, 0);
    REP(i, n) count[a[i]]++;

    long long ans = 1;
    REP(i, 3) ans *= count[i];

    REP(j, n) REP(i, j) {
        int k = j + j - i;
        if (k < n) {
            if (a[i] == a[j]) continue ;
            if (a[j] == a[k]) continue ;
            if (a[k] == a[i]) continue ;
            ans--;
        }
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3616
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = 0;
        int q = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            p += x * Math.pow(10, n - i -1);
        }
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt();
            q += x * Math.pow(10, n - i -1);
        }
        List<Integer> a = new ArrayList<>();
        dfs(a, n, 1, 0, 0);
        Collections.sort(a);
        int b = 0;
        int c = 0;
        for (int i = 0; i < a.size(); i++) {
            if(a.get(i) == p) b = i;
            if(a.get(i) == q) c = i;
        }
        System.out.println(Math.abs(b-c));
        sc.close();

    }

    private static void dfs(List<Integer> a, int n, int x, int sum, int bit) {
        for (int i = 0; i < n; i++) {
            if((bit >> i & 1) == 1)continue;
            int y = sum + x * (int)Math.pow(10, n - i -1);
            if(x == n) a.add(y);
            else {
                bit |= 1 << i;
                dfs(a, n, x+1, y, bit);
                bit ^= 1 << i;
            }
        }
    }

}


Measured memory_bytes: 25432
#include<iostream>

using namespace std;
int cd[100];

int main(){

    while(1){
        int n, p;
        cin>> n>> p;
        if(n==0&&p==0) break;
        for(int i=0; i<n; i++) cd[i]=0;
        int turn=0;
        while(1){
            int c=0, ans;
            for(int i=0; i<n; i++){
                if(cd[i]!=0&&p==0){
                    ans=i;
                }else{
                    c++;
                }
            }
            if(c==n-1){
                cout<< ans<< endl;
                break;
            }
            if(p!=0){
                p--;
                cd[turn]++;
            }else{
                p+=cd[turn];
                cd[turn]=0;
            }
            turn=(turn+1)%n;
        }
    }

    return 0;
}

Measured memory_bytes: 2984
#include<iostream>
#include<cmath>
#include<stdio.h>
using namespace std;

int main(){
    int n;
    double x[101],y[101],sum,tmp=-1;
    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i];
    for(int j=0;j<n;j++)cin>>y[j];
    //p=1
    sum=0;
    for(int i=0;i<n;i++){
        if(x[i]-y[i]<0)sum+=y[i]-x[i];
        else sum+=x[i]-y[i];
    }
    printf("%f\n",sum);
    //p=2
    sum=0;
    for(int i=0;i<n;i++){
        sum+=(x[i]-y[i])*(x[i]-y[i]);
    }
    printf("%f\n",sqrt(sum));
    //p=3
    sum=0;
    for(int i=0;i<n;i++){
        if(x[i]-y[i]<0)sum+=(y[i]-x[i])*(y[i]-x[i])*(y[i]-x[i]);
        else sum+=(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
    }
    printf("%f\n",cbrt(sum));
    //p->inf
    for(int i=0;i<n;i++){
        if(x[i]-y[i]<0){
            if(y[i]-x[i]>tmp)tmp=y[i]-x[i];
        }
        else{
            if(x[i]-y[i]>tmp)tmp=x[i]-y[i];
        }
    }
    printf("%f\n",tmp);

    return 0;
}


Measured memory_bytes: 3384
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc  = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    final int al = a.length();
    final int bl = b.length();
    final int cl = c.length();
    int aa = al;
    int bb = bl;
    int cc = cl;
    char judge = a.charAt(al - aa);
    aa = aa - 1;
    while(true){
      if(judge == 'a'){
        if(aa == 0){break;}else{
        judge = a.charAt(al - aa);
        aa = aa -1;
        }
      }else if (judge == 'b') {
        if(bb == 0){break;}else{
        judge = b.charAt(bl - bb);
        bb = bb -1;
        }
      }else if(judge == 'c'){
        if(cc == 0){break;}else{
        judge = c.charAt(cl - cc);
        cc = cc -1;
        }
      }
    }
    if(judge == 'a'){System.out.println("A");}else if(judge == 'b'){System.out.println("B");}else{System.out.println("C");}
  }
}


Measured memory_bytes: 9676
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string>
#include<vector>
#include<stack>
#include<queue>
using namespace std;



int main()
{
	int a, b, c, d ;
	int e = 0;
	cin >> a >> b >> c >> d;
	if (a == 1 || b == 1 || c == 1 || d == 1) { e++; }
	if (a == 9 || b == 9 || c == 9 || d == 9) { e++; }
	if (a == 7 || b == 7 || c == 7 || d == 7) { e++; }
	if (a == 4 || b == 4 || c == 4 || d == 4) { e++; }
	if (e == 4) { cout << "YES" << endl; }
	else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,ans=0;
    string a;
    cin>>N>>a;
    stack<int> rstack;
    for(int i=0;i<N;i++){
        if(a[i]=='R'){
            rstack.push(i);
        }
    }
    for(int i=0;i<N;i++){
        if(rstack.empty()||rstack.top()<=i){
            break;
        };
        if(a[i]=='W'){
            a[rstack.top()]='W';
            a[i]='R';
            rstack.pop();
            ans++;
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 4432
n = gets.to_i
p = gets.chomp.split(" ").map(&:to_i)
cnt = 0
n.times do |i|
  if p[i] == i+1
    if i == n-1
      cnt += 1
    else
      if p[i+1] == i+2
        cnt += 1
        p[i],p[i+1] = p[i+1],[i]
      else
        cnt += 1
      end
    end
  end
end
puts cnt


Measured memory_bytes: 24064
#include <iostream>
using namespace std;
int main(void){
   
   int n;
   
   cin >> n;
   int l[n];
   for(int i=0 ; i<n ; i++){
       cin >> l[i];
   }
   //一番長い辺を探す
   int longest = l[0];
   int sum = 0;
   for(int i=0 ; i<n ; i++ ){
       if(longest < l[i]){
           longest = l[i];
       }
      sum += l[i];
   }
   sum -= longest;
   
   //一番長い辺＜N-1個の辺の合計　ですか？
   if(longest < sum){
       cout << "Yes" << endl;
   }else{
       cout << "No" << endl;
   }

}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

#dp[i][smaller] : 上からi番目を決定したときの最大値
#dp[][smaller] {0:次の桁はK以下になるようにする,1:次の桁は何でもok}
dp = [[0,0] for _ in range(42)]

for i in range(1,42):
    if dp[i-1][1] == 1:
        dp[i][1] = 1
    
    #ctr:i行目が1のAの個数
    ctr = 0
    for j in range(n):
        if (a[j]>>(41-i))&1 == 1:
            ctr += 1

    if ctr >= n-ctr:
        #i行目は0にする
        dp[i][0] = dp[i-1][0] + ctr*(2**(41-i))
        if (k >> (41-i))&1 == 1:
            dp[i][1] = 1
    else:
        #i行目は1にしたい
        if dp[i][1] == 1:
            #1にする
            dp[i][0] = dp[i-1][0]+(n-ctr)*(2**(41-i))
        else:
            if (k >> (41-i))&1 == 1:
                #1にする
                dp[i][0] = dp[i-1][0]+(n-ctr)*(2**(41-i))
            else:
                #1にできないので0にする
                dp[i][0] = dp[i-1][0] + ctr*(2**(41-i))

print(dp[41][0])
                

Measured memory_bytes: 14620
N, M = map(int, input().split())
A_B = [list(map(int, input().split())) for _ in range(N)]

A_B = sorted(A_B, key=lambda a_b: a_b[0]) # 価格の安い順に並べ替え

count = 0
amt = 0
for a_b in A_B:
    a = a_b[0]
    b = a_b[1]
    if count + b < M:
        count += b
        amt += a * b
        continue
    else:
        amt += ((M - count) * a)
        break

print(amt)

Measured memory_bytes: 29796
#include <iostream>
#include <algorithm>
#include <string>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    string N;
    cin >> N;
    if (N[0] == N[2]) cout << "Yes" << endl;
    else              cout << "No"  << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C,D;
    int sum=0;
    
    cin >> A >> B >> C >> D ;
    
    if(A<=B) sum=sum + A;
    else sum=sum + B;
    
    if(C<=D) sum=sum + C;
    else sum=sum + D;
    
    cout << sum <<endl;
    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
cs int base = 233;
cs int ff = 3e6+1;
cs int mod = 998244353;
cs int inf = 1e9+1;
int a[2011][2011], su[2011][2011], ans = inf, tag[2001], pt[2001];
char s;
int getsum( int aa, int bb, int cc, int dd )
	{ return su[cc][dd] - su[cc][bb-1] - su[aa-1][dd] + su[aa-1][bb-1]; }
void init()
{
	int h, w, k;
	cin >> h >> w >> k;
	rep(i, 1, h)
		rep(j, 1, w)
			cin >> s, a[i][j] = ( s == '1' );
	rep(i, 1, h)
		rep(j, 1, w)
			su[i][j] = su[i-1][j] + su[i][j-1] - su[i-1][j-1] + a[i][j];
	int mxzt = (1<<h) - 1;
	rep(i, 0, mxzt)
	{
		int las = 1, cnt = 0, ccnt = 0, tg = 0;
		rep(j, 1, w) tag[j] = 0, pt[j] = 0;
		int top = 0; pt[++top] = 1;
		rep(j, 1, h)
		{
			if( (i & (1<<(j-1) ) ) == 0 ) continue;
			ccnt++; pt[++top] = j;
		} pt[++top] = h+1;
		rep(z, 1, w)
		{
			int siz = 0;
			rep(js, 2, top)
			{
				if( getsum(pt[js-1], las, pt[js]-1, z) > k )
					if( las >= z ) { tg = 1; break; }
					else { siz = 1; break; }
			}
			if( siz )
				++cnt, las = z;
		}
		if(!tg)
			ans = min(ans, cnt + ccnt);
	}
	cout << ans;
}
signed main()
{
	int T = 1;
	while(T--) 
		init();
} 


Measured memory_bytes: 2432
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
#include <set>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b;
    cin >> a >> b;
    cout << max( a + b , max( a - b , a * b ) );
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    long long int sum=0;
    
    cin>>n;
    for(int i=1;i<=n;i++){
      if(i%15==0) continue;
      else if(i%5==0) continue;
      else if(i%3==0) continue;
      sum+=i;
    }
    
    cout<<sum<<endl;
}


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

void insertSort( int A[], int N )
{
	int time = 0;
	for( int i = 0 ; i < N; i++ )
	{
		int min = i;
		for( int j = i+1 ; j < N; j++ )
		{
			if( A[j] < A[min])
			   min = j;
		}
		if( min != i )
		{
		   int temp = A[i]; A[i] = A[min]; A[min] = temp;
		   time++; 
		}
		   
	}
	for( int i = 0 ; i < N-1 ; i++ )
	{
		cout << A[i] << " ";
    }
    cout << A[N-1] << endl;
    cout << time << endl;
}

int main()
{
	int N;
	cin >> N;
	int *A = new int [N];
	for( int i = 0; i < N ; i++ )
	{
		cin >> A[i];
	}
	insertSort( A , N );
	return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int x;
    vector<int> a(4,0);
    rep(i, 6){
        cin >> x;
        ++a[x - 1];
    }
    if (a[0] <= 2 && a[1] <= 2 &&a[2] <= 2 &&a[3] <= 2 ) {
        YES;
    }else{
        NO;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans[15];
int end1=0x3f3f3f3f;
int c[15];
int a[15][15];
int main()
{
    int n,m,x;cin>>n>>m>>x;
    for(int i=1;i<=n;i++)
    {
    	cin>>c[i];
    	for(int j=1;j<=m;j++)
    	{
    		cin>>a[i][j];
		}
	}
    for(int i=0;i<(1<<n);i++) //´Ó0¡«2^n-1¸ö×´Ì¬
    {
    	int hua=0;
        for(int j=0;j<n;j++) //±éÀú¶þ½øÖÆµÄÃ¿Ò»Î»
        {
            if(i&(1<<j))//ÅÐ¶Ï¶þ½øÖÆµÚjÎ»ÊÇ·ñ´æÔÚ
            {
                hua+=c[j+1];
                for(int k=1;k<=m;k++)
                {
                	ans[k]+=a[j+1][k];
				}
            }
        }
        int flag=1;
        for(int k=1;k<=m;k++)
        {
        	if(ans[k]<x)
        	{
        		flag=0;
			}
		}
		if(flag==1)
		{
			end1=min(end1,hua);
		}
		memset(ans,0,sizeof(ans));
        //cout<<endl;
    }
    if(end1==0x3f3f3f3f)
	{
		cout<<"-1";
	}else cout<<end1;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, n;
  cin >> h >> n;
  int sum = 0;
  for(int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
  }
  cout << ((h <= sum) ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
var GetCityPos = function(input){
  var arr = input.split('\n');
  var items1 = arr[0].split(' ');
  var items2 = arr[1].split(' ');
  var ModCity = new Set();
  var Min = undefined;

  for(var i =0;i<items2.length;++i){
    var a = items2[i];
    var modCurrentCity = a - items1[1];
    if(modCurrentCity < 0){
      modCurrentCity *= -1;
    }
    ModCity.add(modCurrentCity);

    if(Min == undefined){
      Min = modCurrentCity;
    } else {
      if(Min > modCurrentCity){
        Min = modCurrentCity;
      }
    }
  }
  return {Cities: ModCity, Min: Min};
}

// 割り切れるか確認する関数
var ModZeroCheck = function(CitySet, ModNum){
  var result = true;
  CitySet.forEach(function(value){
    if(!result){
      return;
    }
    if(value%ModNum != 0){
      result = false;
    }
  });
  return result;
}

var Main = function(input){
  // スタート位置を差し引いた位置情報を生成
  var Data = (GetCityPos(input));
  var result = 0;
  // console.log(Data);
  // console.log(Data.Cities);
  // console.log(Data.Cities.size);
  
  if(Data.Cities.size == 1){
    var iterator1 = Data.Cities.values();
    console.log(iterator1.next().value);
    return;
  }

  for(var i = 1; i<=Data.Min;++i){
    if(Data.Min % i != 0){
      continue;
    }
    if(ModZeroCheck(Data.Cities, i)){
      result = i;
    }
  }
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    int N, M;

    cin >> N;
    vector<string> s_N(N);
    rep2(i, 0, N) cin >> s_N.at(i);

    cin >> M;
    vector<string> s_M(M);
    rep2(i, 0, M) cin >> s_M.at(i);

    vector<string> list(0);
    list.push_back(s_N.at(0));

    int check;

    rep2(i, 1, N){
        check = 0;

        rep2(j, 1, list.size()){
            if(s_N.at(i) == list.at(j)){
                check = 1;
                break;
            }
        }

        if(check == 0) list.push_back(s_N.at(i));
    }


    int score, max_score = 0;
    rep2(i, 0, list.size()){
        score = 0;
        rep2(j, 0, N){
            if(list.at(i) == s_N.at(j)) score++;
        }
        rep2(j, 0, M){
            if(list.at(i) == s_M.at(j)) score--;
        }

        if(max_score < score) max_score = score;
    }

    cout << max_score << endl;
}


Measured memory_bytes: 3628
N, A, B = map(int, raw_input().split(' '))
s = raw_input()
oversea = 0
japan = 0
for ch in s:
    if ch == 'c':
        print 'No'
    elif ch == 'a':
        if oversea + japan < A+B:
            japan += 1
            print 'Yes'
        else:
            print 'No'
    elif ch == 'b':
        if oversea + japan < A+B and oversea < B:
            oversea += 1
            print 'Yes'
        else:
            print 'No'
    else:
        print 'No'

Measured memory_bytes: 3076
def warshall_floyd(paths, N):
    for k in range(N):
        for i in range(N):
            for j in range(N):
                paths[i][j] = min(paths[i][j], paths[i][k] + paths[k][j])


def iter_patterns(l):
    if len(l) == 1:
        return [l]
    patterns = []
    for i in range(len(l)):
        patterns += [[l[i]] + p for p in iter_patterns(l[:i] + l[i+1:])]
    return patterns


def main():
    N, M, R = map(int, input().split())
    r = list(map(int, input().split()))
    paths = [[float("inf")] * N for _ in range(N)]
    for _ in range(M):
        A, B, C = map(int, input().split())
        paths[A-1][B-1] = C
        paths[B-1][A-1] = C
    for i in range(N):
        paths[i][i] = 0
    warshall_floyd(paths, N)
    retval = float("inf")
    for p in iter_patterns(r):
        dist = 0
        for i in range(R-1):
            dist += paths[p[i]-1][p[i+1]-1]
        retval = min(retval, dist)
    print(retval)


if __name__ == "__main__":
    main()


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

using namespace std;
typedef vector<pair<pair<string,int>,int>> vsii;
#define REP(i,n) for (int i = 0; i < n; ++i)
#define MP make_pair

int N;
vsii res;

int main() {
    cin >> N;
    REP (i, N) {
        string s; int p;
        cin >> s >> p;
        res.push_back(MP(MP(s, -p), i+1));
    }
    sort(res.begin(), res.end());
    REP (i, N) cout << res[i].second << "\n";
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;



int main(){
    rep(i,7){
        int a,b;
        cin>>a>>b;
        cout<<a-b<<endl;
    }
    
 return 0;
}

Measured memory_bytes: 1160
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll l;
    cin >> l;
    l = l*l*l;
    double ans = (double)l/27.0;
    printf("%.7f\n", ans);

    return 0;
}

Measured memory_bytes: 256
n= int(input())

v = list(map(int,input().split()))
c = list(map(int,input().split()))


x_y = 0
for i in range(2**n):

    tmp_x_y = 0
    tmp_cost=0
    tmp_value=0

    for j in range(n):
        if (i>>j) &1:
            tmp_cost+=c[j]
            tmp_value+=v[j]

    tmp_x_y = tmp_value - tmp_cost

    x_y = max(x_y,tmp_x_y)

print(x_y)

Measured memory_bytes: 41196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const long long INF = 1e15;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    for(int i = 0; i < k; i++){
        if(a >= b){
            b *= 2;
            continue;
        } else if(b >= c){
            c *= 2;
            continue;
        }
    }
    if(a < b && b < c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
	ios::sync_with_stdio(0), cin.tie(0);
 	ll x;
	cin >> x;
	if (x >= 30) cout << "Yes";
	else cout << "No";   
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
        A[i]--;
    }

    vector<ll> sum(N + 1, 0);
    rep(i, N) {
        sum[i + 1] += (sum[i] + A[i]) % K;
    }

    queue<ll> que;
    map<ll, ll> cnt;
    ll ans = 0;
    rep(i, N + 1) {
        que.push(sum[i]);
        ans += cnt[sum[i]]++;
        if ((int)que.size() >= K) {
            cnt[que.front()]--;
            que.pop();
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17536
import java.io.BufferedReader

fun main(args: Array<String>) {
    /** comment in when you submit **/
    System.`in`.bufferedReader().use { println(getOutputString(it)) }

    /** delete below after your test **/
    //    executeTest()
}

private fun getOutputString(reader: BufferedReader): String {
    //min = Int.MAX_VALUE
    val cond = reader.readLine().split(" ").map(String::toInt)
    val items = reader.readLines().map { it.split(" ").map(String::toInt) }.sortedBy { it[2] * -1 }
    val max_a = items.map { it[0] }.sum()
    val max_b = items.map { it[1] }.sum()
    val dp = (0..cond[0]).map {
        (0..max_a).map {
            (0..max_b).map { Int.MAX_VALUE }.toIntArray()
        }
    }
    dp[0][0][0] = 0
    (0..(cond[0] - 1)).forEach { i -> // each items
        (0..max_a).forEach { j ->
            (0..max_b).forEach { k ->
                if (dp[i][j][k] == Int.MAX_VALUE) {
                    return@forEach
                }
                val item = items[i]
                // not to add
                dp[i + 1][j][k] = Math.min(dp[i + 1][j][k], dp[i][j][k])
                // add
                dp[i + 1][j + item[0]][k + item[1]] = Math.min(dp[i + 1][j + item[0]][k + item[1]], dp[i][j][k] + item[2])
            }
        }
    }
    return (dp[dp.lastIndex].mapIndexed { i, a_list ->
        a_list.mapIndexed { j, n ->
            if (i > 0 && j > 0 && i * cond[2] == j * cond[1]) n else Int.MAX_VALUE
        }.min() ?: Int.MAX_VALUE
    }.min() ?: Int.MAX_VALUE).let {
        if (it == Int.MAX_VALUE) -1 else it
    }.toString()
}

/** delete below after your test **/
private fun String.mustBe(expected: String): Unit {
    if (this != expected) throw Exception("\"$this\" must be \"$expected\"")

    println("ok")
}

private fun executeTest() {
    getOutputString("3 1 1\n1 2 1\n2 1 2\n3 3 10".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("3")
    getOutputString("1 1 10\n10 10 10".toByteArray(Charsets.UTF_8).inputStream().bufferedReader()).mustBe("-1")
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll a; cin >> a;
	string s; cin >> s;

	if (a < 3200) s = "red";
	cout << s << endl;
}



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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

struct P
{
    int x;
    int y;
    int h;
};

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

    vector<P> v(N);
    for (int i = 0; i < N; i++) cin >> v[i].x >> v[i].y >> v[i].h;

    for (int cx = 0; cx <= 100; cx++)
    {
        for (int cy = 0; cy <= 100; cy++)
        {
            int pos = 0;
            while (v[pos].h == 0) pos++;

            int H = v[pos].h + abs(cx - v[pos].x) + abs(cy - v[pos].y); 

            bool flag = true;
            for (int i = 0; i < N; i++)
            {
                if (v[i].h != max(H - abs(cx - v[i].x) - abs(cy - v[i].y), 0))
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                cout << cx << " " << cy << " " << H << endl;
                return 0;
            }
        }   
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int a, b;
    cin >> a >> b;
    if (a > b) {
        int tmp = a;
        a = b;
        b = tmp;
    }
    
    for (int i = 0; i < b; i++)
        cout << a;
    cout << endl;
}

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

using namespace std;

struct node {
    int l, r;
    long long x, z;
} tree[800004];

void build(int x, int ql, int qr) {
    tree[x].l = ql;
    tree[x].r = qr;
    tree[x].x = 1ll * 200000 * 1000000000 + 1;
    tree[x].z = 0;
    if (ql != qr) {
        build(2 * x, ql, (ql + qr) / 2);
        build(2 * x + 1, (ql + qr) / 2 + 1, qr);
    }
}

void prop(int x) {
    if (tree[x].l != tree[x].r) {
        tree[2 * x].z += tree[x].z;
        tree[2 * x + 1].z += tree[x].z;
    }
    tree[x].x += tree[x].z;
    tree[x].z = 0;
}

void pull(int x) {
    prop(x);
    prop(2 * x);
    prop(2 * x + 1);
    tree[x].x = min(tree[2 * x].x, tree[2 * x + 1].x);
}

long long query(int x, int ql, int qr) {
    prop(x);
    if (tree[x].l > qr || ql > tree[x].r) return 1ll * 200000 * 1000000000 + 1;
    if (ql <= tree[x].l && tree[x].r <= qr) return tree[x].x;
    return min(query(2 * x, ql, qr), query(2 * x + 1, ql, qr));
}

void upd(int x, int ql, int qr, long long v) {
    prop(x);
    if (tree[x].l > qr || ql > tree[x].r) return;
    if (ql <= tree[x].l && tree[x].r <= qr) {
        tree[x].z += v;
        return;
    }
    upd(2 * x, ql, qr, v);
    upd(2 * x + 1, ql, qr, v);
    pull(x);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<pair<int, int> > qry[n];
    long long ans = 0;
    while (m--) {
        int l, r, a; cin >> l >> r >> a;
        l--; r--;
        qry[r].push_back(make_pair(l, a));
        ans += a;
    }
    build(1, 0, n);
    upd(1, 0, 0, 0 - query(1, 0, 0));
    for (int i = 0; i < n; i++) {
        upd(1, i + 1, i + 1, query(1, 0, i) - query(1, i + 1, i + 1));
        for (int j = 0; j < qry[i].size(); j++) upd(1, 0, qry[i][j].first, qry[i][j].second);
    }
    cout << ans - query(1, 0, n);
    return 0;
}


Measured memory_bytes: 25472
IDENTIFICATION DIVISION.
 PROGRAM-ID. 042A. 
 DATA DIVISION.
 WORKING-STORAGE SECTION.
  01 INP.
    03 A      PIC 9(1).
    03 FILLER PIC X.
    03 B      PIC 9(1).
    03 FILLER PIC X.
    03 C      PIC 9(1).
  01 COUNT5   PIC 9(1) VALUE ZERO.
  01 COUNT7   PIC 9(1) VALUE ZERO.
       
 PROCEDURE DIVISION.
 
  ACCEPT INP.
      
  IF A = 5 
      ADD 1 TO COUNT5
      ELSE
      IF A = 7
      	ADD 1 TO COUNT7
        ELSE
        CONTINUE
      END-IF
  END-IF.
      
  IF B = 5 
      ADD 1 TO COUNT5
      ELSE
      IF B = 7
      	ADD 1 TO COUNT7
        ELSE
        CONTINUE
      END-IF
  END-IF.
      
  IF C = 5 
      ADD 1 TO COUNT5
      ELSE
      IF C = 7
      	ADD 1 TO COUNT7
        ELSE
        CONTINUE
      END-IF
  END-IF.
  
  IF COUNT5 = 2 AND COUNT7 = 1
      DISPLAY "YES"
  ELSE
      DISPLAY "NO"
  END-IF.
        
 STOP RUN.

Measured memory_bytes: 512
let () = Scanf.scanf "%d\n%s\n%s\n" @@ fun n s t ->
  Array.init (n + 1) (fun i -> i)
  |> Array.to_list
  |> List.rev
  |> List.find (fun i ->
      String.sub s (n - i) i = String.sub t 0 i)
  |> ( - ) (2 * n)
  |> Printf.printf "%d\n"

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <chrono>
using namespace std::chrono;
using namespace std;
#define fr(x,i,n) for(int x = i; x < n; ++x)
#define fb(x,i,n) for(int x = i; x >= n; --x)
#define pr pair<int,int>
#define ll long long int
const int mod=1e9+7;
/*    auto start = high_resolution_clock::now();
    auto stop = high_resolution_clock::now();
    auto duration = duration_cast<microseconds>(stop - start);
    cout << "\nduration="<<duration.count()/1e6 << endl;
*/
void solve(){
    string s;
    cin>>s;
    ll k;
    cin>>k;
    ll n=s.length();
    bool f=1;
    fr(i,0,n-1){
    	if(s[i]!=s[i+1])
    	f=0;
	}
	if(f){
		ll ans=(n*k)/2;
		cout<<ans;
		return;
	}
    ll ans=0;
    int i0=0,j0=n-1;
    while(i0<n&&s[i0]==s[0])
    i0++;// first element not equal to s[0]
    while(j0>i0&&s[j0]==s[0]){
        j0--; // last element not equal to s[0]
    }
   // cout<<"i0="<<i0<<" j0="<<j0<<endl;
    fr(i,i0,j0+1){
        int j=i;
        while(j<=j0&&s[i]==s[j])
        j++;
        ans+=(j-i)/2;
        i=j-1;
    }
    
    ans*=k;
    ll x=i0+(n-1-j0);
    ans+=(k-1)*(x/2);
    ans+=i0/2;
    ans+=(n-1-j0)/2;
    cout<<ans;


}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    while(t--)
    solve();

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  cin >> s >> t;
  for (int i = s.size() - t.size(); ~i; i--) {
    int j = 0;
    for (; j < t.size(); j++) {
      if (s[i + j] != t[j] && s[i + j] != '?') {
        break;
      }
    }
    if (j >= t.size()) {
      for (int k = 0; k < i; k++) {
        cout << (s[k] == '?' ? 'a' : s[k]);
      }
      for (int k = 0; k < t.size(); k++) {
        cout << t[k];
      }
      for (int k = i + t.size(); k < s.size(); k++) {
        cout << (s[k] == '?' ? 'a' : s[k]);
      }
      cout << '\n';
      return 0;
    }
  }
  cout << "UNRESTORABLE\n";
  return 0;
}


Measured memory_bytes: 256
s = input()

if s.count("N") > 0:
    if s.count("S") == 0:
        print("No")
        exit()

if s.count("S") > 0:
    if s.count("N") == 0:
        print("No")
        exit()

if s.count("W") > 0:
    if s.count("E") == 0:
        print("No")
        exit()

if s.count("E") > 0:
    if s.count("W") == 0:
        print("No")
        exit()

print("Yes")


Measured memory_bytes: 9096
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <deque>
#include <string>
#include <cstring>
#include <iomanip>
#include <fstream>
#include <map>
#include <unordered_map>
#include <bitset>
#include <fstream>
#pragma warning(disable:4996)
#define hayai ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define INF 0x3F3F3F3F
#define MAX 100001
#define MAXLOGO 17
#define MOD 1000000007
#define ALPHABET 128
using namespace std;
typedef long long ll;

//freopen("perimetric_chapter_1_input.txt", "r", stdin);
//freopen("result.txt", "w", stdout);



int main (void)
{
    ll n; cin >> n;
    cout << (n ^ 1) << endl;
}

Measured memory_bytes: 3588
n, k = list(map(int, input().split()))
P = list(map(int, input().split()))
Q = [(p+1)/2 for p in P]
c = [0]
for q in Q:
   c.append(c[-1]+q)
ans = 0
for i in range(k, n+1):
   ans = max(ans, c[i] - c[i-k])
print(ans)

Measured memory_bytes: 25060
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] ar = new int[200000];
        Map<Integer, Integer> map = new LinkedHashMap<>();
        for (int i = 0; i < n; i++) {
            ar[sc.nextInt()]++;
        }
        Arrays.sort(ar);
        int ind = 0;
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] != 0) {
                ind = i;
                break;
            }
        }
        long ans = 0;
        for (int i = ind; i < 200000  - k; i++) {
            ans += ar[i];
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 84516