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

#define fst first
#define snd second
#define mp make_pair
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define per(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()

template <typename T1, typename T2>
bool umin(T1 &x, const T2 &y) {return (x>y ? (x=y,true):false);}
template <typename T1, typename T2>
bool umax(T1 &x, const T2 &y) {return (x<y ? (x=y,true):false);}

template <typename T>
void read(T& x) {
    char ch;
    T p = 1; x = 0;
    do {ch = getchar();} while(ch <= ' ');
    if (ch == '-') p = -1, ch = getchar();
    while (ch>='0' && ch<='9') x = x*10 + ch-'0', ch = getchar();
    x *= p;
}

void read(string& x) {
    char ch;
    do {ch = getchar();} while (ch <= ' ');
    while (ch > ' ') x += ch, ch = getchar();
}

void read(char& x) {do {x = getchar();} while (x <= ' ');}
template<typename T, typename... R>
void read(T& x, R&... y) { read(x); read(y...); }

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

const int N = (int)1e6+3;
const int INF = (int)1e9+17;
const ll mod = (ll)1e9+7;
const ll LLINF = (ll)1e18+17;
const ld pi = (ld)acos(-1.0);


int n, m;
int a[N];
int b[N];


int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    read(n);
    rep(i, 0, n) {
        read(a[i]);
        b[i] = a[i];
    }
    int mid = n/2 - 1;
    sort(b, b+n);
    rep(i, 0, n) {
        if (b[mid] >= a[i]) printf("%d\n", b[mid+1]);
        else printf("%d\n", b[mid]);
    }

    return 0;
}


Measured memory_bytes: 7040
#include <stdio.h>

int main(void)
{
	char cup[2];
	int ball[3];
	int i, j;
	int rese;
	
	for (i = 1; i < 3; i++){
		ball[i] = 0;
	}
	ball[0] = 1;
	
	while (scanf(" %c,%c", &cup[0], &cup[1]) != EOF){
		for (i = 0; i < 2; i++){
			switch (cup[i]){
				
				case 'A':
				cup[i] = 0;
				break;
				
				case 'B':
				cup[i] = 1;
				break;
				
				case 'C':
				cup[i] = 2;
				break;
			}
		}
		rese = ball[cup[0]];
		ball[cup[0]] = ball[cup[1]];
		ball[cup[1]] = rese;
	}
	
	for (i = 0; i < 3; i++){
		if (ball[i] == 1){
			switch (i){
				case 0:
				printf("A\n");
				break;
				
				case 1:
				printf("B\n");
				break;
				
				case 2:
				printf("C\n");
				break;
			}
		}
	}
	
	return (0);
}

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

int main()
{
    int n;
    cin >> n;
    string out = "No";
    if (n >= 1 && n <= 81) {
        for (int i = 1; i < 10; i++) {
          int j = n / i;
          int k = n % i;
          if (j < 1 || j > 9 || k > 0) {
            continue;
          }
          out = "Yes";
          break;
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
	  int[][] c = new int[3][3];
      for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
          c[i][j] = sc.nextInt();
        }
      }
      String ans = "Yes";
      for(int i = 0; i < 2; i++){
        if(!(c[0][i]-c[0][i+1]==c[1][i]-c[1][i+1] && c[0][i]-c[0][i+1]==c[2][i]-c[2][i+1])){
           ans = "No";
        }
      }
      System.out.println(ans);
    }
}

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

#define ll long long
#define inf 0x3f3f3f3f 
#define il inline 

#define in1(a) a=read()
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
#define out(a) printf( "%d" , a ) 
#define outn(a) out(a),putchar('\n')

#define int long long

#define I_int long long
inline I_int read() {

    I_int x = 0 , f = 1 ; char c = getchar() ;
    while( c < '0' || c > '9' ) {
        if( c == '-' ) f = -1 ;
        c = getchar() ;
    }
    while( c >= '0' && c <= '9' ) {
        x = (x << 1) + (x << 3) + c - 48 ;
        c = getchar() ;
    }
    return x * f ;
}
#undef I_int

using namespace std ;

#define N 100010

int n , t , a ;
int h[ N ] ;

signed main() {
	in3( n , t , a );
	for( int i = 1 ; i <= n ; i ++ ) in1( h[ i ] ) ;
	int ans = 1 ;
	for( int i = 2 ; i <= n ; i ++ ) {
		if( abs( (double)a - (double)((double)t - (double)h[ i ] * 0.006 ) ) < abs( (double)a - (double)((double)t - (double)h[ ans ] * 0.006) ) )
			ans = i ;
	}
	printf("%lld\n" , ans ) ;
	return 0 ;
}

Measured memory_bytes: 256
n,nai,out=map(int,input().split())
b=input()
kokunai=0
kaigai=0
for i in range(n):
  if(b[i]=='c'):
    print('No')
  elif(b[i]=='a'):
    if(kokunai+kaigai>=nai+out):
      print('No')
    else:
      kokunai=kokunai+1
      print('Yes')
  else:
    if(kokunai+kaigai>=nai+out or kaigai>=out):
      print('No')
    else:
      print('Yes')
      kaigai=kaigai+1

Measured memory_bytes: 4016
/*
 _     _                             
| |__ | |__   __ _  __ _ _   _  __ _ 
| '_ \| '_ \ / _` |/ _` | | | |/ _` |
| |_) | | | | (_| | (_| | |_| | (_| |
|_.__/|_| |_|\__,_|\__, |\__, |\__,_|
                   |___/ |___/       
*/
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
using namespace std;
 
#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll int n;
		cin>>n;
		ll int ans=n*(n-1)/2;
		cout<<ans;
	}
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int a[31] = {0};
    
    int n,m;
    cin>>n>>m;
    REP(i,n){
        int k;
        cin>>k;
        REP(j,k){
            int aa;
            cin>>aa;
            a[aa] += 1;
        }
    }

    int ans =0;
    REP(i,m+1){
        if(a[i]==n) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 1e9+7;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k; cin>>n>>k;
    mint ans=mint(k-n-2)*(2*k*k-k*(n+2)-n*n-n-6)/6;
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

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

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
const int MAX_N = 100010;

int N, K, R, S, P;
string T;

int GetScore(int cons, char c) {
    int ret = 0;
    if(c == 'r') {
        ret = P;
    }
    else if(c == 's') {
        ret = R;
    }
    else {
        ret = S;
    }
    if(cons % 2 == 0) {
        ret *= cons / 2;
    }
    else {
        ret *= (cons / 2 + 1);
    }
    return ret;
}

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

    cin >> N >> K;
    cin >> R >> S >> P;
    cin >> T;

    vector<string> mat(K, "");
    REP(i, N) {
        int ind = i % K;
        mat[ind] += T[i];
    }

    ll ans = 0;
    REP(i, K) {
        ll cons = 0;
        char prev = 'a';
        REP(j, mat[i].length()) {
            // 同じ文字の連続を探す
            if(prev != mat[i][j]) {
                ans += GetScore(cons, prev);
                cons = 0;
            }
            cons++;
            prev = mat[i][j];
        }
        ans += GetScore(cons, prev);
    }
    printf("%lld\n", ans);

    return 0;
}



Measured memory_bytes: 5200
/*    特徴    */

/*    教訓    */

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

#define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

// -------- template end - //


// - library ------------- //

template<typename T>
void ms_eraseone(multiset<T> &ms, T key){
  auto it = ms.find(key);
  if (it != ms.end()) ms.erase(it);
}

// --------- library end - //


int main(){

  ll N = il();
  ll surplus = 0;
  vector<ll> bc(100001,0);
  rep(i, N){
    ll a = il();
    if (bc[a]) surplus++;
    bc[a]++;
  }
  cout << N - (surplus+1)/2*2 << endl;

  
}


Measured memory_bytes: 4040
if __name__=="__main__":
    N = int(input())
    l = list(map(int,input().split(" ")))
    record = []
    dic = {i:l[i] for i in range(N)}
    sorted_list = sorted(dic.items(),key=lambda d:d[1],reverse=True)
    if sorted_list[N-1][1]>=0:
        for i in range(N-1):
            record.append([i, i+1])
    elif sorted_list[0][1]<0:
        for i in range(N-1,0,-1):
            record.append([i, i-1])
    elif sorted_list[0][1]+sorted_list[N-1][1]>=0:
        record.append([sorted_list[0][0], 0])
        record.append([sorted_list[0][0], 1])
        record.append([0,1])
        for i in range(1,N-1):
            record.append([sorted_list[0][0], i+1])
            record.append([i,i+1])
    elif sorted_list[0][1]+sorted_list[N-1][1]<0:
        record.append([sorted_list[N-1][0], N-1])
        record.append([sorted_list[N-1][0], N-2])
        record.append([N-1,N-2])
        for i in range(N-2,0,-1):
            record.append([sorted_list[N-1][0], i-1])
            record.append([i,i-1])
    print(len(record))
    for i in range(len(record)):
         print(str(record[i][0]+1)+" "+str(record[i][1]+1))

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (N % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }

            for (int i = 0; i < N / 2; i++)
            {
                if (s[i] != s[i + N / 2])
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
            return;
        }
    }
}



Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
  int S, h, m, s;

  scanf("%d", &S);

  h = S / 3600;
  m = (S % 3600) / 60;
  s = S % 60;

  printf("%d:%d:%d\n", h, m, s);

  return 0;
}


Measured memory_bytes: 2032
import java.lang.*;
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    int n;
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    n=n%10;
    if(n==0|| n==1 || n==6 || n==8)
    {
      System.out.println("pon");
    }
    else if(n==3)
    {
      System.out.println("bon");
    }
    else
    {
      System.out.println("hon");
    }
  }
}

Measured memory_bytes: 35748
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	string s;
	cin >> s;
	cout << "2018/01/" << s[8] << s[9] << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    n = int(readline())
    factors = Counter()

    for i in range(2, n + 1):
        x = i
        for j in range(2, int(i ** 0.5) + 5):
            while x % j == 0:
                factors[j] += 1
                x //= j
        if x != 1:
            factors[x] += 1

    ans = 1

    for key, val in factors.items():
        ans *= (val + 1)
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74680
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	ll n, d; cin >> n >> d;
    ll p = 2*d + 1;
	cout << (n+p-1)/p << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	deque<char> que;
	rep(i, n) que.push_back(s[i]);
	bool rev = false;
	rep(i, 2 * n) {
		if (k == 0) break;
		if (que.front() == 'A' && !rev || que.front() == 'B' && rev) {
			que.pop_front();
			if (rev) que.push_front('A');
			else que.push_front('B');
		}
		else {
			rev = !rev;
			que.pop_front();
			if (rev) que.push_back('B');
			else que.push_back('A');
		}
		k--;
	}
	string ans = "";
	while (!que.empty()) {
		char c = que.front(); que.pop_front();
		ans += c;
	}
	if (rev) {
		rep(i, n) {
			if (ans[i] == 'A') ans[i] = 'B';
			else ans[i] = 'A';
		}
	}
	if (n % 2 == 1 && k % 2 == 1) {
		if (ans[0] == 'A') ans[0] = 'B';
		else ans[0] = 'A';
	}
	cout << ans << '\n';
}

Measured memory_bytes: 4132
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        s: String
    }

    if s.contains("RRR") {
        println!(3);
        return
    }
    if s.contains("RR") {
        println!(2);
        return
    }
    if s.contains("R") {
        println!(1);
        return
    }
    println!(0);

}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
bool isPrime(const long long number) {
if (number == 2)
    return true;
if (number <= 1 || !(number & 1))
    return false;
for (int i = 3; i * i <= number; i += 2)
    if (number % i == 0)
        return false;
return true;
}
int main()
{
    int n;
    cin >> n;
    int a;
    int ans = 0;
    for (int i = 0; i < n; i++) {
       cin >> a;
       if (isPrime(a)) 
            ans++;
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int n,x,a[200010];
int main()
{
cin>>n;
for(int i=2;i<=n;i++)
{
	cin>>x;
    a[x]++;
}
  for(int i=1;i<=n;i++)
  cout<<a[i]<<endl;
return 0;
}


Measured memory_bytes: 4392
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n;
	scanf("%lld",&n);
	puts(n<1200?"ABC":"ARC");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  map<string, ll> cnt;
  REP(i, N) {
    string s; cin >> s;
    sort(ALL(s));
    cnt[s]++;
  }

  ll ans = 0;
  for (auto v : cnt) {
    if (v.second == 1) continue;
    ans += v.second*(v.second-1)/2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 11136
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a < b){
        printf("a < b\n");}
    else if (a > b){
        printf("a > b\n");}
    else{
        printf("a == b\n");}
    return 0;
}
    

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

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

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

// Self settings
// clang-format off
#define MAX_N 100
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N, K;
int x[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> K;
  REP(i, N) cin >> x[i];

  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += min(abs(0 - x[i]) * 2, abs(K - x[i]) * 2);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    int i,j;
    int r,c;
    int a[101][101] = {0};
 
    scanf("%d %d", &r,&c);
 
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
                scanf("%d", &a[i][j]);
            }   
    }
 
    for(i = 0; i < r; i++){
        for(j = 0; j < c; j++){
                a[i][c] += a[i][j];
            }   
    }
 
    for(j = 0; j < c; j++){
        for(i = 0; i < r; i++){
                a[r][j] += a[i][j];
            }   
    }
 
    for(i = 0; i < r; i++){
        a[r][c] += a[i][c];
    }
 
    for(i = 0; i <= r; i++){
        for(j = 0; j <= c; j++){
            printf("%d",a[i][j]);
            if(j != c){
                printf(" ");
            }
        }
        printf("\n");
    }
 
    return 0;
}

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

int main() {
    int h, w;
    string s[50];
    cin >> h >> w;
    for (int i=0; i<h; i++) cin >> s[i];
    const int dx[8] = {0, 0, 1, 1, 1,-1,-1,-1};
    const int dy[8] = {1,-1, 0, 1,-1, 0, 1,-1};
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            if (s[i][j] == '#') continue;
            
            int num = 0;
            for (int d=0; d<8; d++) {
                const int ni = i + dy[d];
                const int nj = j + dx[d];

                if (ni < 0 || ni >= h) continue;
                if (nj < 0 || nj >= w) continue;
                if (s[ni][nj] == '#') num++;
            }
            /*'0'の内部表現が48なので、
            num(たとえば2)を足すと、'2'を表す内部表現50となる*/
            s[i][j] = char(num + '0');

        }
    }
    
    for (int i=0; i<h; i++) cout << s[i] << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
i = 0
j = 0
tbl = [[1+i for i in range(13)] for j in range(4)]
# print(tbl)
while i < n:
    a = input()
    z = list(map(str, a.split()))
    if z[0] == "S":
        j = int(z[1]) - 1
        tbl[0][j] = 0
    elif z[0] == "H":
        j = int(z[1]) - 1
        tbl[1][j] = 0
    elif z[0] == "C":
        j = int(z[1]) - 1
        tbl[2][j] = 0
    elif z[0] == "D":
        j = int(z[1]) - 1
        tbl[3][j] = 0
    i += 1
# print(tbl)
i = 0 
for x in tbl:
    j = 0
    for y in x:
        if tbl[i][j] != 0:
            if i == 0:
                list = ["S",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 1:
                list = ["H",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 2:
                list = ["C",str(tbl[i][j])]
                print(" ".join(map(str, list)))
            elif i == 3:
                list = ["D",str(tbl[i][j])]
                print(" ".join(map(str, list)))
        j += 1
    i += 1


Measured memory_bytes: 5620
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
	u64 a, b, c;
	cin >> a >> b >> c;

	if( (a < c && c < b) || (b < c) && (c < a) ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
return 0;
}

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

int main(){
	int n;
	int inf = 1e09 + 7;
	cin >> n;
	long long ans = 1;
	for( int i = 1; i <= n; ++i ){
		ans = ans * i % inf;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  ll n;
 
  while(cin >> n,n){
    ll sum = 1000000;
    REP(i,1001){
      REP(j,101){
	if(n-i*i-j*j*j >= 0){
	  sum = min(sum,(n-i*i-j*j*j)+i+j);
	}
      }
    }
    cout << sum << endl;
  }
  return 0;
}



Measured memory_bytes: 3004
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def calc(g, b, n):
  s = 0

  while n >= 0:
    if n % b == 0:
      s += 1

    n -= g

  return s


def main():
  r, g, b, n = map(int, input().split())
  s = 0

  while n >= 0:
    s += calc(g, b, n)
    n -= r

  print(s)


if __name__ == '__main__':
  main()



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

using namespace std;

const double PI = 3.141592;
const int MAX_N = 1e5+5;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

const bool dbgEnabled = false;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef pair<string, ll> psi;
typedef pair<ll, string> pis;
typedef vector<pii> vpii;
typedef vector<psi> vpsi;
typedef vector<pis> vpis;
typedef vector<vi> vvi;

// Debug macros
#define dbg(x) do { \
	if (dbgEnabled) { cerr << #x << ": " << x << "\n"; } \
} while (0)

#define dbgv(x) do { \
	if (dbgEnabled) { cerr << #x << ": [ "; for (auto& _ : x) cerr << _ << " "; cerr << "]\n"; } \
} while (0)

#define dbgvv(x) do { \
	if (dbgEnabled) { cerr << #x << ":\n[\n"; for (auto& __ : x) dbgv(__); cerr << "]\n";} \
} while (0)

void solve() {
	ll n, x, t; cin >> n >> x >> t;
	ll ans = t*ceil((double)n/x);
	cout << ans << endl;
}

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



Measured memory_bytes: 3652
from functools import reduce
import math

def main():
    # 文字列の2進数を数値にする
    # '101' → '5'
    # 文字列の頭に'0b'をつけてint()にわたす
    # binary = int('0b'+'101',0)

    # 2進数で立っているbitを数える
    # 101(0x5) → 2
    # cnt_bit = bin(5).count('1')
    
    # N! を求める
    # f = math.factorial(N)
    
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    INF = float("inf")
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]    
    X,A,B = (int(_) for _ in input().split())
    if (B-A) <= X:        
        if B <= A:
            print('delicious')
        else:
            print('safe')
    else:
        print('dangerous')
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
n,m = map(int, input().split())
li = []
all_count = 0
for i in range(m):
  li.append(list(map(int, input().split())))
zero_one = list(map(int, input().split()))


for i in range(2**n):
  b = bin(i)[2:].rjust(n, '0')
  light = list(str(b))
  for l, j in enumerate(li):
    num_swith = j[0]
    count = 0
    for k in j[1:]:
      count += int(light[k-1])
    if count % 2 != zero_one[l]:
      break
      
    if l == m-1:
      all_count += 1
      
      
print(all_count)
      
      
    
    
    

  
  

Measured memory_bytes: 3064
n,c=gets.split.map(&:to_i)
s=n.times.map{gets.split.map(&:to_i)}
max_e=max_dist=total_e=0
r=[[0,0]]
s.each{|x,v|
  total_e+=v
  curr_e=total_e-x
  if max_e<curr_e
    max_e=curr_e
    max_dist=x
  end
  r<<[max_e,max_dist] 
}

max_e=max_dist=total_e=0
l=[[0,0]]
s.reverse.each{|x,v|
  total_e+=v
  curr_e=total_e-(c-x)
  if max_e<curr_e
    max_e=curr_e
    max_dist=c-x
  end
  l<<[max_e,max_dist]
}
max=0
0.upto(n){|i|
  r_e,r_dist=r[i]
  l_e,l_dist=l[n-i]
  temp=r_e+l_e-[r_dist,l_dist].min
  max=temp if temp>max
}

puts max

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

typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPR(i, n) for(int (i)=(n-1);(i)>=0;i--)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);i++)
#define FORR(i,m,n) for(int (i)=(m-1);(i)>=(n);i--)
#define PRINT(x) {cout<<(x)<<"\n";}
#define INF 1e9

int main(){
    int D;
    cin >> D;
    if(D==25){
        PRINT("Christmas")
    }
    else if(D==24){
        PRINT("Christmas Eve")
    }
    else if(D==23){
        PRINT("Christmas Eve Eve")
    }
    else if(D==22){
        PRINT("Christmas Eve Eve Eve")
    }
}

Measured memory_bytes: 256
N = int(input())
G2,G4 = [],[]
cnt2 = 0
cnt3 = 0
for _ in range(N):
    S = input()
    MIN = 0
    cnt = 0
    for s in list(S):
        if s == '(':
            cnt += 1
        else:
            cnt -= 1
        MIN = min(MIN,cnt)
    if MIN == 0 and cnt >= 0:
        cnt2 += cnt
    if MIN < 0 and cnt >= 0:
        G2.append([MIN,cnt])
    if MIN == cnt and cnt < 0:
        cnt3 += cnt
    if MIN < cnt and cnt < 0:
        G4.append([MIN,cnt])


G2.sort(reverse=True)
for L in G2:
    if cnt2 + L[0] < 0:
        print('No')
        exit()
    else:
        cnt2 += L[1]
for L in G4:
    if cnt2 + L[0] < 0:
        print('No')
        exit()
    else:
        cnt2 += L[1]

cnt2 += cnt3

if cnt2 == 0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 26856
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
#define ll long long
map<ll,ll>ma;
int main()
{
    ll n,m,num,sum=0;
    ll ans=0;
    cin >> n >> m;
    ma[0]++;
    for(int i=0;i<n;i++){
        cin >> num;
        sum+=num;
        sum%=m;
        ans+=ma[sum];
        ma[sum]++;
        //cout << ans << " "  << sum <<endl;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
int dp[5010][5010];

long long mod_pow(long long x,long long n){
    if(n == 0) return 1;
    long long res = mod_pow(x*x % mod, n / 2);
    if(n & 1) res = res*x % mod;
    return res;
}

signed main(){
    int n;
    string s;
    cin >> n >> s;
    int sz = s.size();
    dp[0][0] = 1;
    rep(i, 0, n){
        rep(j, 0, i + 1){
            (dp[i + 1][j + 1] += 2 * dp[i][j]) %= mod;
            (dp[i + 1][max(j - 1, (int)0)] += dp[i][j]) %= mod;
        }
    }
    
    int ans = dp[n][sz];
    ans = ans * mod_pow(2, mod - 1 - sz) % mod;
    cout << ans << endl;
}

Measured memory_bytes: 116992
//https://atcoder.jp/contests/dp/tasks/dp_k

#include <bits/stdc++.h>
#include <limits.h>
#include <algorithm>  


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

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long long int ll;

const int precision = 16;
const int modulo =  1000000007; // 10^9 + 7
using ll = long long;
const double EPS = 1e-9;


int getWinnersTurn(int  t, int k, const vector<int> & a, int & winnerTurn) {

	return k;
}

string solvekStones() {

	int n; cin >> n;
	int k; cin >> k;

	vector<int> a(n);
	for(auto &it : a) {
		cin >> it;
	}


	//dp[i] = true if the current player wins if there are i stones remaining.
	
	vector<bool> dp(k + 1, false);

	for(auto stones = 0; stones <= k; ++stones) {
		for(auto v : a) {
			if(stones - v >= 0 and dp[stones - v] == false){
				// dp[stones - v] == false, first player moving to that state lose.
				dp[stones] = true;
			}
		}
	}

	if(dp[k] == true) return "First";
	return "Second";
	
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.precision(precision);
	cout.setf(ios_base::fixed);

	
	cout << solvekStones();
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define chmin(x, y) x = min(x, y)
#define ll long long
#define ld long double
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int N; cin >> N;
  if (N % 2 == 1) cout << N/ 2 << endl;
  else cout << N / 2 - 1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>
 
using namespace std;
 
typedef long long ll;
typedef pair<string, int> P;
 
int N,A,B,C;
ll inf = 1e9;
int l[10];
 
int dfs(int cur, int a, int b, int c){
	if(cur==N){
		if(a>0&&b>0&&c>0){
			return abs(a - A) + abs(b - B) + abs(c - C) - 30;
		}else{
			return inf;
		}
	}
	int ret0 = dfs(cur + 1, a, b, c);
	int ret1 = dfs(cur + 1, a + l[cur], b, c) + 10;
	int ret2 = dfs(cur + 1, a, b + l[cur], c) + 10;
	int ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10;
	return min(min(min(ret0,ret1),ret2),ret3);
}
 
int main(){
	cin >> N >> A >> B >> C;
	for(int i=0;i<N;i++) cin >> l[i];
	
	cout << dfs(0,0,0,0) << endl;
 
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int flag=0;
  
  for(char i='a'; i<='z'; i++){
    int count=0;
    for(int j=0; j<s.size(); j++){
      if(s[j]==i) count++;
    }
    if(count%2!=0){
      cout << "No" << endl;
      flag++;
      break;
    }
  }
  
  if(flag==0) cout << "Yes" << endl;
}
      

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <stack>
#include <list>
#include <deque>
using namespace std;
long long n, m, i, j, k, t, a, b;
long long high, low;
long long A[100010];
int main(){
	cin>>k;
	for(i=1;i<=k;i++) {
		cin>>A[i];
	}
	high=2;
	low=2;
	for(i=k;i>=1;i--){
		if(low>high){
			cout<<-1;
			return 0;
		}
		high=(high/A[i])*A[i]+(A[i]-1);
		low=((low-1)/A[i]+1)*A[i];
		if(low>high){
			cout<<-1;
			return 0;
		}
	}
	cout<<low<<" "<<high;
	return 0;
}


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

int main(){
	double x1, x2, y1, y2, z1, z2;
	scanf("%lf %lf %lf %lf", &x1, &x2, &y1, &y2);
	if(x1 > y1){
		z1 = x1 - y1;
	} else {
		z1 = y1 - x1;
	}
	if(x2 > y2){
		z2 = x2 - y2;
	} else {
		z2 = y2 - x2;
	}
	printf("%f", sqrt(z1 * z1 + z2 * z2));
	return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  const int d = abs(A - B) + 1;
  if ((A == 1 && B == 2) || (A == N && B == N - 1) || ((d % 2) == 0)) {
    cout << "Borys";
  } else
    cout << "Alice";
}

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

using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	ll n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;
using Graph = vector<vector<ll>>;

int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a!=c)cout<<'1'<<endl;
    else cout<<'0'<<endl;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n,t;
    cin>>n>>t;
    int a[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int tot=0;
    for(int i=2;i<=n;i++)
    {
        if(a[i]-a[i-1]<=t)
            tot+=a[i]-a[i-1];
        else
                tot+=t;
    }

    cout<<tot+t;
} 


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent, ll module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ ll root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2, mod);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}


signed main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  REP_FROM(c, 'a', 'z'+1) {
    int lft = -10;
    REP(j, s.size()) {
      if(s[j] == c) {
        if(j - lft < 3) {
          cout << lft+1 << " " << j+1 << endl;
          return 0;
        }
        lft = j;
      }
    }
  }
  cout <<"-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
N,M=map(int,input().split())
n=[list(map(int,input().split())) for _ in range(N)]
m=[list(map(int,input().split())) for _ in range(M)]
result=[]
for i in range(len(n)):
  result=[]
  for j in range(len(m)):
    result.append(abs(n[i][0]-m[j][0])+abs(n[i][1]-m[j][1]))
  print(result.index(min(result))+1)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
using namespace std;
#define forn(i, x, n) for (int i = x; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
typedef long double ld;
typedef long long ll;
template <typename... Args> void dbg(Args &&... args) {
  using expander = int[];
  (void)expander{
      0,
      (static_cast<void>(void(cout << std::forward<Args>(args) << " ")), 0)...};
  cout << endl;
}
void gen() {
  exit(0);
}

int xa, ya;
int xb, yb;

void input() {
  scanf("%d %d", &xa, &ya);
  scanf(" %d %d", &xb, &yb);
}

void solve() {
  int c = xa - xb;
  int d = yb - ya;
  printf("%d ", xb - d);
  printf("%d ", yb - c);
  printf("%d ", xa - d);
  printf("%d ", ya - c);
  printf("\n");
}

int main() {
#ifdef DEBUG
  freopen("input", "r", stdin);
  // freopen("output", "w", stdout);
  // gen();
  while (!feof(stdin)) {
    input();
    solve();
    scanf(" ");
  }
#else
  input();
  solve();
#endif
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int k = sc.nextInt();

    int[] h = new int[n];
    int ans = 0;
    for (int i = 0; i < n; i++) {
      h[i] = sc.nextInt();
      if (h[i] >= k) ans++;
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 48304
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

trait IteratorExt: Iterator + Sized {
    fn vec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

impl<T: Iterator> IteratorExt for T {}

fn main() {
    input! {
        // usize
        // n: usize,
        // vec
        // v: [i64; n],
        a: i64,
        b: i64,
    }

    if a % 2 != b % 2 {
        println!("IMPOSSIBLE");
        return;
    }

    println!("{}", (a + b) / 2);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<algorithm>

using namespace std;

int main() {
  double heights[50];

  int i = 0;
  while(cin >> heights[i]) {
    i++;
  }

  double min_f = *min_element(heights, heights + i);
  double max_f = *max_element(heights, heights + i);

  printf("%.6lf\n", max_f - min_f);

  return 0;
}

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

int main(){
  int n,odd=0;
  cin>>n;
  rep(i,n){
      int t;
      cin>>t;
      if(t%2==1) odd++;
  }
  if(odd%2==0)cout<<"YES"<<endl;else cout<<"NO"<<endl;
  return 0;
}


Measured memory_bytes: 256