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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5;
int mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
ll infll = 1e18 + 7;



signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int x1, y1, x2, y2, t;
    cin >> x1 >> y1 >> x2 >> y2 >> t;
    int x = x1 * 60 + y1, y = x2 * 60 + y2;
    cout << max(0ll, y - x - t);
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3652
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<math.h>
#include<time.h>
#include<vector>
#include<bitset>
#include<memory>
#include<utility>
#include<fstream>
#include<stdio.h>
#include<sstream>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
using namespace std;
long long x[100005],v[100005];
long long ans1[100005];
long long ans2[100005];
long long sum[100005];
multiset<long long> s;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int n;
    long long c;
    cin>>n>>c;
    int i;
    for (i=0;i<n;i++)
    {
        cin>>x[i]>>v[i];
    }
    for (i=0;i<n;i++)
    {
        sum[i+1]=sum[i]+v[i];
    }
    long long max_ans=0;
    for (i=0;i<n;i++)
    {
        ans1[i]=sum[i+1]-x[i];
        ans2[i]=(sum[n]-sum[i])-(c-x[i]);
    }
    s.erase(s.begin(),s.end());
    s.insert(0);
    for (i=0;i<n;i++)
    {
        max_ans=max(max_ans,ans2[i]-(*s.begin()));
        s.insert(-ans1[i]+x[i]);
    }
    s.erase(s.begin(),s.end());
    s.insert(0);
    for (i=n-1;i>=0;i--)
    {
        set<int>::iterator ii;
        max_ans=max(max_ans,ans1[i]-(*s.begin()));
        s.insert(-ans2[i]+(c-x[i]));
    }
    cout<<max_ans<<endl;
    return 0;
}


Measured memory_bytes: 8832
N,K=map(int,input().split())
H=[]
count=10**9
for i in range(N):
   h=int(input())
   H.append(h)
H.sort()

for i in range(0,N-K+1):
   hmax_min=H[i+K-1]-H[i]
   count=min(count,hmax_min)

print(count)

Measured memory_bytes: 7488
#include<iostream>
#include<fstream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>

#define FIO ios_base::sync_with_stdio(0);  cin.tie(0);
#define PI 3.14159265358979323846
#define mod 1000000007
#define ll long long
#define vll vector<long long>  

#define all(c) c.begin(), c.end()

// Used to traverse in any STL container with iterators
#define tr(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)

// Find whether element is present in given container or not
#define present(container, element) (container.find(element) != container.end())

// Finds whether element in present container is present in vector or not
#define cpresent(container, element) (find(all(container),element) != container.end())

using namespace std;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    FIO
    
    int n;
    cin>>n;
    int arr[n];
    int dp[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    dp[0]=0;
    dp[1]=abs(arr[1] -arr[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1] + abs(arr[i] - arr[i-1]), dp[i-2]+ abs(arr[i]- arr[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

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

int main(){
  int N,l,r;
  int sum=0;
  cin>>N;
  
  for(int i=0;i<N;i++){
    cin >> l >> r;
    sum += r-l+1;}
  
  cout << sum <<endl;
  
  
  
  
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int a, b, x;
    std::cin>>a>>b>>x;

    std::string ans = "NO";
    for(int i = 0;i <= b;i++){
        if(a + i == x){
            ans = "YES";
        }
    }
    std::cout<<ans<<std::endl;
    return 0;
}

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

#define forn(i, a, b) for (int i = a; i <= b; ++i)
#define forr(i, a, b) for (int i = a; i >= b; --i)

using namespace std;

const int N = (int)1e5 + 1;
const long long INF = 1e13 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

int n, k, a[N];
int main (){
  scanf ("%d %d", &n, &k);
  forn (i, 1, n){
    scanf ("%d", a + i);
  }
  if (n == k) return printf ("1\n"), 0;
  printf ("%d\n", 1 + (n - k - 1) / (k - 1) + 1);
  return 0;
}

Measured memory_bytes: 640
function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = input.trim();
	if(input.length==2)
		console.log(input)
	else{
		var s='';
		for (var i = 0; i < input.length; i++) {
			s=s+input[input.length-1-i];
		}
		console.log(s)
	}
	
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 22964
N = int(input())
li = []
for i in range(N):
    a,b = map(int,input().split())
    li.append([b,a])
li.sort()
t = 0
co = 1
for i in range(N):
    t += li[i][1]
    if li[i][0] < t:
        co = 0
        break
if co:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 35608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};
 
int main(){
    int N;
    string S, L, R;
    cin >> N >> S;
    rep(i, N) L += S[i], R += S[2*N-1-i];
    ll ans = 0;
    map<pair<string, string>, ll> mp;
    rep(i, 1<<N){
        string a, b;
        rep(j, N){
            if(i & (1<<j)) a += R[j];
            else b += R[j];
        }
        //cout<<a<<" "<<b<<endl;
        mp[make_pair(a, b)]++;
    }
    //cout<<endl;
    rep(i, 1<<N){
        string a, b;
        rep(j, N){
            if(i & (1<<j)) a += L[j];
            else b += L[j];
        }
        ans += mp[make_pair(a, b)];
        //cout<<a<<" "<<b<<endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 91904
import java.util.*;

public class Main{
    
     static int n,m;
     static Pair[] e;
     
     static class Pair{
         int a,b,c;
         
         Pair(int a,int b,int c){
             this.a = a;
             this.b = b;
             this.c = c;
         }
         
     }
    
      public static void main(String[] args) {
          
           Scanner sc = new Scanner(System.in);
       
           n = sc.nextInt();           
           m = sc.nextInt();
           
           e = new Pair[m];
           
           for(int j = 0;j < m;j++){
               int s = sc.nextInt() - 1;
               int t = sc.nextInt() - 1;
               int u = -sc.nextInt();
               e[j] = new Pair(s,t,u);
           }
           
           long dist[] = new long[n];
           
           Arrays.fill(dist, (long) (1E+9) * (n - 1));
           dist[0] = 0;
           boolean[] f = new boolean[n];
           Arrays.fill(f, false);
           
    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < m; j++) {
        int s = e[j].a;
        int t = e[j].b;
        int u = e[j].c;
        dist[t] = Math.min(dist[t], dist[s] + u);
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        int s = e[j].a;
        int t = e[j].b;
        int u = e[j].c;
        if (dist[s] == (long) (1E+9) * (n - 1)) {
          continue;
        }
        if (dist[s] + u < dist[t]) {
          dist[t] = dist[s] + u;
          f[t] = true;
        }
        if (f[s]) {
          f[t] = true;
        }
      }
    }
    if (f[n - 1]) {
      System.out.println("inf");
    } else {
      System.out.println(-dist[n - 1]);
    }
   
    
  }   
}   

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

using namespace std;
typedef long long ll;

ll Search(int l, ll &x, vector<vector<ll>> &d) {
	if (x == 0)
		return 0;
	if (x >= d[l][1]) {
		x -= d[l][1];
		return d[l][0];
	}
	x--;
	ll ans = Search(l - 1, x, d);
	if (x > 0) {
		ans++;
		x--;
	}
	ans += Search(l - 1, x, d);
	return ans;
}

int main(void) {
	int n, i;
	ll x, ans;
	cin >> n >> x;
	vector<vector<ll>> d(n + 1, vector<ll>(2));
	d[0][0] = 1;
	d[0][1] = 1;
	for (i = 0; i < n; i++) {
		d[i + 1][0] = (d[i][0] << 1) + 1;
		d[i + 1][1] = (d[i][1] << 1) + 3;
	}
	ans = Search(n, x, d);
	cout << ans << "\n";
	return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  Graph(int n):E(n){E.resize(n);V=n;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
ll sum[100010]={};
class segTree{
public:
  const ll Inf = llINF;
  ll n=0;
  vector<ll>node;
  segTree(ll nn){
    n=1;
    while(n<nn)n*=2;
    node.resize(n*2);
    //initializer
    //ex. RMQ
    init(-Inf);
  }
  
  void init(ll hoge){//RMQ
    for(int i=0;i<node.size();i++)node[i]=hoge;
  }

  void init(vector<ll> hoge){//RSQ
    for(int i=0;i<hoge.size();i++)update(i,hoge[i]);
  }

  void update(int index,const ll value){
    index+=n;
    node[index]=value;//RMQ
    while(index > 0){
      index/=2;
      node[index] = ope(node[2*index],node[2*index+1]);
    }
  }
  ll find(int l,int r){
    if(l == r) return node[r+n];
    l += n; r += n;
    ll ans = -Inf;
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans=ope(ans,node[l]); return ans;}
      if(r%2 == 0) ans=ope(ans,node[r]),--r;
      if(l%2) ans=ope(ans,node[l]),++l;
    }
    return ans;
  }
  ll ope(const ll a,const ll b){
    return max(a,b);
  }
};

int main(){
  ll n,c;cin>>n>>c;
  vector<ll>le(n+10),ri(n+10);
  vector<ll>pll(n);
  vector<ll>pl(n);
  for(int i=0;i<n;i++){
    
    cin>>pll[i]>>pl[i];
    le[i+1]=pl[i]+le[i];
  }
  for(int i=n;i>0;i--){
    ri[i]=ri[i+1]+pl[i-1];
  }
  segTree seg(n+5),seg3(n+5);
  for(int i=1;i<=n;i++){
    seg.update(i-1,le[i]-pll[i-1]);
    seg3.update(i-1,ri[i]-(c-pll[i-1]));
  }
    ll ans=0;
  for(int i=0;i<n;i++){
      ans=max(seg.find(i,i),ans);ans=max(seg3.find(i,i),ans);
  }
  //cout<<endl;

  for(int i=0;i<n;i++){
   // cout<<le[i+1]-2*pll[i]<<" "<<seg3.find(i+1,n-1)<<endl;
    //cout<<ri[i+1]-2*(c-pll[i])<<" "<<seg.find(0,i-1)<<endl;
    ans=max(ans,max(0LL,le[i+1]-2*pll[i])+max(0LL,seg3.find(i+1,n-1)));
    ans=max(ans,max(0LL,ri[i+1]-2*(c-pll[i]))+max(seg.find(0,i-1),0LL));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main(void){
    int N;
    cin >> N;
    int x[N+1];
    int A[N];

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

    for(int j=0;j<N;j++){
            x[0] += A[j]*(std::pow(-1, j));
    }
    x[N] = x[0];

    for(int i=N-1;i>-1;i--){
        x[i] = A[i] - (x[i+1]/2);
        x[i] *= 2;
    }

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

Measured memory_bytes: 2048
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}

std::string s;
int dp[10][2][2][2][2][2];
int32_t  func(int i, int a, int b, int c, int z , int m) {
	if (i == s.size()) {
		if (a > 0 && b > 0 && c > 0) {
			return 1;
		}
		return 0;
	}

	auto& memo = dp[i][a][b][c][z][m];
	if (memo != -1) {
		return memo;
	}
	memo = 0;

	if (m == 0 || s[i] > '7') {
		memo += func(i+1, 1,b,c, 1,0);
		memo += func(i+1, a, 1, c, 1, 0);
		memo += func(i+1, a, b, 1, 1, 0);
		if (z == 0)memo += func(i + 1, a, b, c, 0, 0);
	}
	else {
		if (s[i] == '7') {
			memo += func(i+1, 1, b, c, 1, 1);
			memo += func(i+1, a, 1, c, 1, 0);
			memo += func(i+1, a, b, 1, 1, 0);
			if (z == 0)memo += func(i + 1, a, b, c, 0, 0);
		}
		else if(s[i] >= '5') {
			memo += func(i+1, a, 1, c, 1, s[i] == '5');
			memo += func(i+1, a, b, 1, 1, 0);
			if (z == 0)memo += func(i + 1, a, b, c, 0, 0);
		}
		else if (s[i] >= '3') {
			memo += func(i+1, a, b, 1,1, s[i] == '3');
			if (z == 0)memo += func(i + 1, a, b, c, 0, 0);
		}
		else {
			if (z == 0)memo += func(i + 1, a, b, c, 0, s[i] == '0');
		}
	}
	return memo;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	fill_all(dp, -1);
	in >> s;
	out << func(0, 0, 0, 0,0, 1) << endl;

	return 0;
}
#endif


Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
 
using namespace std;
 
int main() {
    string s;
    cin >> s;
    if (s[0] == 'a' || s[0] == 'i' || s[0] == 'u' || s[0] == 'e' || s[0] == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# AtCoder Beginner Contest 081 A
# [URL]      https://atcoder.jp/contests/abc081/tasks/abc081_a
# [compiler] Version 0.5.0
# [reference]
# <1> https://atcoder.jp/contests/abc081/submissions/3181551

#==================================================================================================#
function isTargetNum( char, target )
	return Base.ifelse( Base.isequal(char, target), 1, 0 )
end

function abc081_a()

	# STEP.01
	# get the target positive numbers
	buffer = Base.readline( Base.STDIN )

	# STEP.02
	# count up the target letter
	count = Base.zero( Core.Int16 )

	for itr in buffer
		count += Main.isTargetNum( itr, '1' )
	end

	# STEP.03
	# output the result
	Base.println( Base.STDOUT, count )

	# STEP.TRUE_END
	return Base.nothing

end

#==================================================================================================#

Main.abc081_a()


Measured memory_bytes: 108040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;cin>>n;
	//char a,b;
	string sw="";
	string sr="";
	string olds="";
	rep(i,n){
	    char c;cin>>c;
	    if(c=='W')sw+=c;
	    if(c=='R')sr+=c;
	    olds+=c;
	}
	
	string news=sr+sw;
	
	int ans=0;
	rep(i,n){
	    if(news[i]!=olds[i])ans++;
	}
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 4160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            var d = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            Array.Sort(d);
            Console.WriteLine(d[N/2]-d[N/2-1]);

        }
    }
}


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

typedef long long ll; 

int main(){
    int a,b,c; 
    cin>>a>>b>>c; 
    int sum=a+b+c; 
    int m=max(a,max(b,c)); 
    if(a==b && b==c) { cout<<0;  } 
    else {
        int op=0; 
        while(sum%3!=0 ||  sum/3<m) { sum+=2; op++; } 
        cout<<op; 
    }
	return 0; 
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = a + b;
			System.out.println(Integer.toString(c).length());
		}
	}

}

Measured memory_bytes: 20448
#include<stdio.h>
#include<stdlib.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(n == i*j){
        printf("Yes");
        exit(0);
      }
    }
  }
  printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S;
    cin >> S;
    bool first, second;
    if ((S[0] == '0' && S[1] != '0') || (S[0] == '1' && (S[1] == '0' || S[1] == '1' || S[1] == '2')))
        first = true;
    else
        first = false;

    if ((S[2] == '0' && S[3] != '0') || (S[2] == '1' && (S[3] == '0' || S[3] == '1' || S[3] == '2')))
        second = true;
    else
        second = false;

    if (first && second)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (first)
    {
        cout << "MMYY" << endl;
    }
    else if (second)
    {
        cout << "YYMM" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : a)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    string s;
    cin >> s;
    rep(i, s.size()) {
        if(s[i] == '?')
            cout << 'D';
        else
            cout << s[i];
    }
    return 0;
}

Measured memory_bytes: 3756
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?????????: n??\???????´???°
vector<int> getPrimes(int n) {
	vector<char> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
	vector<int> primes;
	rep(i, 0, n + 1)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}

signed main() {
	for (int n; cin >> n&&n;) {
		cout << getPrimes(2 * n).size() - getPrimes(n).size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3420
object Main extends App {

	def m(x1: Int, y1: Int, x2: Int, y2: Int): Int = {
		(x1 - x2).abs + (y1 - y2).abs
	}

	val s = io.StdIn.readLine

	val N = s.split(" ")(0).toInt
	val M = s.split(" ")(1).toInt

	val Nx: Array[Int] = new Array(N)
	val Ny: Array[Int] = new Array(N)

	val Mx: Array[Int] = new Array(M)
	val My: Array[Int] = new Array(M)

	val Ans: Array[Int] = new Array(N)

	for(i <- 0 until N){
		val s = io.StdIn.readLine
		Nx(i) = s.split(" ")(0).toInt
		Ny(i) = s.split(" ")(1).toInt
	}

	for(i <- 0 until M){
		val s = io.StdIn.readLine
		Mx(i) = s.split(" ")(0).toInt
		My(i) = s.split(" ")(1).toInt
	}

	for(i <- 0 until N){
		var t = m(Nx(i), Ny(i), Mx(0), My(0))
		var ans = 0
		for(j <- 1 until M){
			val z = m(Nx(i), Ny(i), Mx(j), My(j)) 
			if(t > z){
				t = z
				ans = j
			}
		}
		Ans(i) = ans + 1;
	}

	for(i <- 0 until N){
		println(Ans(i))
	}

}

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

using namespace std;



int main(void)
{
    int k, n;
    cin >> k >> n;
    
    vector<int> a(n);
    for ( int i=0; i < n; ++i ) cin >> a[i];
    
    vector<int> sa(n);
    for ( int i=0; i < n-1; ++i ) 
        sa[i] = a[i+1] - a[i];
    sa[n-1] = k - a[n-1] + a[0]; 
    
    
    int maxv = 0;
    int sum  = 0;
    for ( int i=0; i < n; ++i ) 
    {
        maxv = max(maxv, sa[i]);
        sum += sa[i];
    }
    
    cout << sum - maxv;
        
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>

#define MODIFIER (1'000'000'007)

long long int add(long long int x, long long int y) {
  return ((x % MODIFIER) + (y % MODIFIER)) % MODIFIER;
}

long long int multiply(long long int x, long long int y) {
  return ((x % MODIFIER) * (y % MODIFIER)) % MODIFIER;
}

int main() {

  int N;
  std::cin >> N;

  int A[200'000];
  long long int sumASoFar = 0;
  long long int sum = 0;

  for (int i=0; i<N; ++i) {
    int t;
    std::cin >> t;
    sum = add(sum, multiply(t, sumASoFar));
    sumASoFar += t;
  }

  std::cout << sum << std::endl;

  return 0;

}


Measured memory_bytes: 3620
#include <iostream>
#include <map>
using namespace std;
using LL = long long;

int N;
int A[200020];
map<LL, LL> m;

int main() {
    LL ans = 0;
    cin >> N;
    for(int i = 1; i <= N; ++i) {
        scanf("%d", A + i);
    }

    // j - i == A[j] + A[i]
    // i + A[i] == j - A[j]
    for(int i = 1; i <= N; ++i) {
        ans += m[i - A[i]];
        m[i + A[i]]++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 26600
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
int cnt[100000];
int main(){
    int N;
    cin>>N;
    int n=0;
    for(int i=0;i<N;i++){
        int A;
        cin>>A;
        cnt[A]++;
        n=max(n,A);
    }
    bool flag=false;
    if(N%2){
        if(cnt[0]!=1){
            flag=true;
        }else{
            for(int i=2;i<N;i+=2){
                if(cnt[i]!=2){
                    flag=true;
                    break;
                }
            }
        }
    }else{
        for(int i=1;i<N;i+=2){
            if(cnt[i]!=2){
                flag=true;
                break;
            }
        }
    }
    if(flag){
        cout<<0<<endl;
        return 0;
    }

    if(N%2)N--;
    N/=2;
    int ans=1;
    for(int i=0;i<N;i++){
        ans*=2;
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, n, m) for (int i = n; i < m; i++)
#define ll long long int

using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if((a-c)*(b-c) < 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

typedef long long ll;

int a, b, k;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> k >> a >> b;
    if (a%k&&a/k==b/k)
        cout << "NG" << endl;
    else
        cout << "OK" << endl;

    return 0;
}



Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
 
#define int long long

const int N = 1e2 + 10;
int n, sum1, sum2, mn = (int)1e18, ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
		sum2 += ar[i];
	}
	
	for (int i = 0; i < n - 1; i++) {
		sum1 += ar[i];
		sum2 -= ar[i];
		mn = min(mn, abs(sum1 - sum2));
	}
	cout << mn;
}

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

int main(){
  int N;
  string A,B,C;
  cin>>N>>A>>B>>C;
  int ans=0;
  for(int i=0;i<N;i++){
    int a=A.at(i);
    int b=B.at(i);
    int c=C.at(i);
    if(a==b&&b==c){
      continue;
    }else if(a==b||b==c||c==a){
      ans+=1;
    }else{
      ans+=2;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3600
from itertools import accumulate
N, Q = map(int,input().split())
S = input()
A = [list(map(int,input().split())) for q in range(Q)]
#print(A)

#フラグを立てて累積和で高速化
flg = []
for n in range(N-1):
    tmp_s = S[n:n+2]
    if tmp_s == "AC":
        flg.append(1)
    else:
        flg.append(0)

flg2 = [0] + flg
flg2 = list(accumulate(flg2))
#print(flg2)

for a in A:
    print(flg2[a[1]-1] - flg2[a[0]-1])

Measured memory_bytes: 32756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String rst;
		s=s.replaceAll("eraser","");
		s=s.replaceAll("erase","");
		s=s.replaceAll("dreamer","");
		s=s.replaceAll("dream", "");
		
			
		
		if(s.length()==0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
	}

}

Measured memory_bytes: 28196
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
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; }
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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;
}

ll extend_lcm(ll a[], ll n) {
  if(n < 2) return -1;
  ll rsl = lcm(a[0], a[1]);
  rep(i, 2, n) rsl = lcm(a[i], rsl);
  return rsl;
}

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

  int n;
  cin >> n;
  ll t[n];
  rep(i, 0, n) cin >> t[i];
  if(n == 1) {
    cout << t[0] << endl;
    return 0;
  }
  cout << extend_lcm(t, n) << endl;
}



Measured memory_bytes: 256
from math import factorial


def comb(n, r):
    if n < r:
        return 0
    return factorial(n) // (factorial(r) * factorial(n - r))


N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
cnt = 0
cnt2 = 0
for i in range(N):
    if v[i] > v[A]:
        cnt += 1
    if v[i] == v[A]:
        cnt2 += 1
avg_max = sum(v[:A]) / A
print(avg_max)
ans = 0
if v[0] != v[A]:
    print(comb(cnt2, A-cnt))
else:
    for i in range(A, min(B+1, cnt2 + 1)):
        ans += comb(cnt2, i)
    print(ans)


Measured memory_bytes: 38896
n, k = map(int, input().split())
'''
data = [10 ** 9]
for i in range(n):
    a, b = map(int, input().split())
    temp = [a] * b
    data.extend(temp)

rev = sorted(data)
#rev = data.reverse() > 大きい順
ans = rev[k - 1]
print(ans)

>最大で（１０*＊１０）サイズリストになる。

バケツソートが必要。
（出現回数を格納したリストから、答えを出す。）
'''

data = [0] * (10 ** 5 + 1)
for i in range(n):
    a, b = map(int, input().split())
    data[a] += b

count = 0
for i in range(1, 10 ** 5 + 1):
    count += data[i]
    if (count >= k):
        ans = i
        break

print(ans)


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

#define ll long long
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define PP pair<P,int>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#define all(a) (a).begin(),(a).end()
#define int long long


signed main(){
    int n;
    cin>>n;
    int ans=1;
    for(int i=1;i<=n;i++){
        (ans*=i)%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int h,w,n;
    cin>>h>>w>>n;
    int a[n];
    int color[h*w],c=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        for(int j=0;j<a[i];j++){
            color[c]=i+1;
            c++;
        }
    }
    //for(int i=0;i<h*w;i++) cout<<color[i]<<endl;
    c=0;
    int ans[h][w];
    int k=0;
    while(c!=h){
        if(c%2==0){
            for(int i=0;i<w;i++){
                ans[c][i]=color[k];
                k++;
            }
        }
        else {
            for(int i=w-1;i>-1;i--){
                ans[c][i]=color[k];
                k++;
            }
        }
        c++;
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<ans[i][j]<<" ";
        }
        cout<<endl;
    }

}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long int n;
  cin>>n;long long int m=n;long long int t;
  for(long int i=1;i*i<=n;i++)
  {
  if(n%i==0)
    t=(i-1)+((n/i)-1);
    if(t<m)
      m=t;
  }cout<<m;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	char z[27];
	scanf("%s",z);
	a=0;
	for(i=0;i<strlen(z)-1;i++){
		for(j=i+1;j<strlen(z);j++){
			if(z[i]==z[j]){
				a=1;
				break;
			}
		}
		if(a==1) break;
	}
	if(a==0) printf("yes\n");
	else printf("no\n");
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
int n,m,WA=0,AC=0;
  scanf("%d%d",&n,&m);
  int a,wc[100000]={};//なんこ目の問題か
	char s[3];			  
  for(int i=0;i<m;i++){
	scanf("%d %s",&a,s);
   if(wc[a]==-1)continue; 
    if(s[0]=='W')wc[a]++;
    else {
      WA+=wc[a];
      wc[a]=-1;
      AC++;
    }
    
  }
  printf("%d %d",AC,WA);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)2e5 + 777;

int dp[3][MAX_N]; // dp[take][pref]
int n;
string str;

void solve()
{
	cin >> str;
	n = len(str);

	for(int t = 0; t < 3; ++t)
	{
		for(int i = 0; i < MAX_N; ++i)
			dp[t][i] = -INT_INF;
	}

	if(len(str) == 1)
	{
		cout << "1" << endl;
		return;
	}

	if(len(str) == 2)
	{
		cout << 1 + (str[0] != str[1]) << endl;
		return;		
	}

	dp[1][1] = 1;
	dp[2][2] = 1;

	if(str[0] != str[1])
		dp[1][2] = 2;

	for(int i = 3; i <= n; ++i)
	{
		if(str[i - 1] != str[i - 2])
		{
			dp[1][i] = max(dp[1][i], 1 + dp[1][i - 1]);
		}

		dp[1][i] = max(dp[1][i], 1 + dp[2][i - 1]);
		dp[2][i] = max(dp[2][i], 1 + dp[1][i - 2]);

		if(i >= 4 && (str[i - 1] != str[i - 3] || str[i - 2] != str[i - 4]))
		{
			dp[2][i] = max(dp[2][i], 1 + dp[2][i - 2]);
		}
	}
	
	cout << max(dp[1][n], dp[2][n]) << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n,m; cin >> n >> m;
    vl a(m),b(m),c(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        rep(j,b[i]){
            int d; cin >> d; d--;
            c[i] |= (1<<d);
        }
    }
    vvl dp(m+1,vl(5000,INF));
    dp[0][0] = 0;
    rep(i,m){
        rep(j,(1<<n)){
            chmin(dp[i+1][j],dp[i][j]);
            chmin(dp[i+1][j|c[i]],dp[i][j]+a[i]);
        }
    }
    if(dp[m][(1<<n)-1] != INF)cout << dp[m][(1<<n)-1] << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 39424
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string S;
	cin>>S;
	
	if(S[S.length()-1] == 's')
	 S = S + 'e' + 's' ;
	else
	 S = S + 's';
	 
	cout<<S;
	
}


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

using namespace std;

#define ll long long int
#define ld long double
#define pii pair<int,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define bit(a,b) ((a>>b)&1)
#define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

const ll mx = 1e5+1, Mod = 1e9+7;

int n;

int pw[mx];

ll get(int i)
{
    if(i<0) return 0;
    return pw[i];
}

int main()
{
    IOS;
    pw[0] = 1;
    for(int i=1;i<mx;i++)
        pw[i] = pw[i-1]*3LL%Mod;
    string s;
    cin >> s; n = s.size();
    int a, b, c; a = b = c = 0;
    ll ab=0, bb=0, aa=0;
    int t=0;
    for(char ch:s)
        t += ch=='?';
    ll res = 0; bool q;
    for(char ch:s)
    {
        q = (ch=='?');
        if(ch=='C' || q)
        {
            res += ab*get(t-q); res %= Mod;
            res += aa*get(t-1-q); res%=Mod;
            res += bb*get(t-1-q); res%=Mod;
            res += ((1LL*c*(c-1)/2)%Mod)*get(t-2-q); res %= Mod;
            if(q)
            {
                aa += a; aa %= Mod;
                c++;
            }
        }
        else if(ch=='A')
            a++;
        else if(ch=='B')
            ab += a, ab %= Mod, bb += c, bb %= Mod;
    }
    cout << res << '\n';
    return 0;
}












Measured memory_bytes: 896
N = int(input())
judge_list = []
for i in range(N):
  judge_list.append(input())
  
print("AC x {}".format(judge_list.count("AC")))
print("WA x {}".format(judge_list.count("WA")))
print("TLE x {}".format(judge_list.count("TLE")))
print("RE x {}".format(judge_list.count("RE")))

Measured memory_bytes: 16168
loop do
    n = gets.to_i
    break if n== 0
    a = n.times.map{gets.to_i}
    max = temp = 0
    a.each_with_index do |aa, i|
        if i == 0
            max = temp = a[0]
            next
        end
        temp = [a[i], a[i] + temp].max
        max = [temp, max].max
    end
    puts max
end

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

int main(){
  int D, T, S;
  cin >> D >> T >> S;
  
  if (D%S == 0 && D/S <= T) cout << "Yes" << endl;
  else if(D%S!=0 && D/S < T) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
    int n; cin >> n;
    vector<int> x(n),y(n);
    for(int i=0;i<n;i++){
    	cin >> x[i] >> y[i];
	}
    for(int i=0;i<n;i++){
    	if(abs((x[0] + y[0]) % 2) != abs((x[i] + y[i]) % 2)){
    		cout << -1 << endl; return 0;
		}
	}
    int par = (1==abs((x[0] + y[0]) % 2) ? 0 : 1);
    cout << 31 + par << endl;
    int p = 1;
    if(par) cout << 1 << " ";
    for(int i=0;i<31;i++){
  		cout << p << " ";
    	p = 2 * p;
  	}
   	cout << endl;
    for(int i=0;i<n;i++){
	 	p = 1073741824;
  	  	if(par) cout << "D";
		int xx = x[i], yy = y[i] + par;
    	char c[32]; c[31] = '\0';
   	    for(int j=0;j<31;j++){
      		int u = xx + yy, v = xx - yy;
      	  	if(u >=0 && v >= 0){
				c[30-j] ='R'; xx -= p;
			}else if(u >=0 && v <= 0){
			    c[30-j] ='U'; yy -= p;
			}else if(u <=0 && v <= 0){
				c[30-j] ='L'; xx += p;
			}else if(u <=0 && v >= 0){
      	    	c[30-j] ='D'; yy += p;
			}
	   		p /= 2;
      	}
      	cout << c << endl;
  	}
   	return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
N = int(input())
A = tuple(map(int, input().split()))

Table = [[None] * W for _ in range(H)]
h, w = 0, 0
for i, a in enumerate(A):
    for x in range(a):
        Table[h][w] = i + 1
        if h % 2:
            if w == 0:
                h += 1
            else:
                w -= 1
        else:
            if w == W - 1:
                h += 1
            else:
                w += 1
for t in Table:
    print(*t)


Measured memory_bytes: 3828
#include<stdio.h>
#include<stdlib.h>
#include <limits.h> 
 
#define WHITE 0
#define BLACK 1
#define MAX 100
#define N -1
 
int d[MAX];
int w[MAX][MAX];
int c[MAX];
 
int main(){
 
  int n,i,j,mincost,x,y,cost=0;
 
  scanf("%d", &n);
 
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&w[i][j]);
    }
  }

  for(i = 0;i < n;i++){
    d[i] = INT_MAX;
    c[i] = WHITE;
  }
 
  d[0] = 0;
 
  while(1){
    mincost = INT_MAX;
 
    for(i = 0;i < n;i++){
      if(d[i] < mincost && c[i] == WHITE){
	mincost = d[i];
	x = i;
      }
    }
 
    if(mincost == INT_MAX){
      break;
    }
    cost += mincost;
    c[x] = BLACK;
     
    for(y = 0 ; y < n ; y++){
      if(w[x][y] == N) continue;
      if(d[y] > w[x][y]) d[y] = w[x][y];
      
    }
  }
 
  printf("%d\n",cost);
 
  return 0;
 
}

Measured memory_bytes: 640
#from collections import Counter
n = int(input())
d = {}
for i in range(n):
  s = input()
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

ds = sorted(d.items(), key=lambda t:(-t[1],t[0]))

m = ds[0][1]
#print(m)
ans = []
for k, v in ds:
  if v != m:
    break
  print(k)


Measured memory_bytes: 61828
#include "bits/stdc++.h"
using namespace std;

//template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }


//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;


//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())

//repetition
//------------------------------------------
#define REP(n) for(int i=0; i<n; i++)
#define REPj(n) for(int j=0; j<n; j++)
#define REPinit(a,n) for(int i=a; i<n; i++)
#define REPinitj(a,n) for(int j=a; j<n; j++)

//algorithm
//#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
//clear memory
//#define CLR(a) memset((a), 0 ,sizeof(a))



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

	cout << (N + ((2 * D + 1) - 1)) / (2 * D + 1) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
S_P_list = [input().split() for i in range(N)]

for i, S_P in enumerate(S_P_list):
    S_P_list[i][1] = (int)(S_P_list[i][1])
    S_P_list[i].append(i+1)

S_P_list = sorted(S_P_list)

for i, S_P in enumerate(S_P_list):
    for j in range(i):
        if (S_P_list[i][0] == S_P_list[j][0])and (S_P_list[i][1] > S_P_list[j][1]):
            tmp = S_P_list[i]
            S_P_list[i] = S_P_list[j]
            S_P_list[j] = tmp

for i, S_P in enumerate(S_P_list):
    print(S_P_list[i][2])

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 8080

using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;
int N,A,B;
int main(){
	cin>>N>>A>>B;
	int C=A+B;
	if(((N+A-1)/A)<=B&&B<=N+1-A){
		vi seq;
		int cnt=N-A-B+1;
		seq.pb(A);
		
		for(int i=0;i<B-1;i++){
			if(cnt>A-1){
				seq.pb(A);
				cnt-=A-1;
			}else{
				seq.pb(cnt+1);
				cnt=0;
			}
		}
		/*for(int i=0;i<seq.size();i++)cout<<seq[i]<<" ";
		cout<<endl;*/
		int now=N;
		for(int i=0;i<seq.size();i++){
			int x=seq[i];
			for(int j=now-x+1;j<=now;j++)cout<<j<<" ";
			now=now-x;
		}
		cout<<endl;
	}else{
		cout<<-1<<endl;
	}
}


Measured memory_bytes: 2932
def resolve():
    n = int(input())
    a = list(map(int, input().split()))
    dict = {}
    for i in range(n):
        if a[i] in dict:
            dict[a[i]] += 1
        else:
            dict[a[i]] = 1
    dval = list(dict.values())
    total = 0
    for i in range(len(dval)):
        total += (dval[i] * (dval[i]-1))/2
    for i in range(n):
        test = a[i]
        print(int(total-dict[test]+1))
resolve()

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int mod = 1000000007;
ll n, k, res;

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> k;

	while (k <= n + 1) {
		ll mn = k * (k - 1) / 2;
		ll mx = k * n - k * (k - 1) / 2;

		res += mx - mn + 1;
		res %= mod;

		k++;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 3640