akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// debug
#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl;
#define ddd(x, y, z) cerr << "(" #x "," #y "," #z "):(" << x << "," << y << "," << z << ")" << endl;
#define dump(v) cerr<<#v":[ ";for (auto macro_vi:v){cerr<<macro_vi<< " ";}cerr<<"]"<<endl;
#define ddump(v) cerr<<#v":"<<endl;for(auto macro_row:v) {cerr<<"["; for (auto macro__vi:macro_row){cerr<<macro__vi<< " ";}cerr<<"]"<<endl;}
#define damp(m) for(auto macro_pair:m){cerr<< macro_pair.first<<":"<<macro_pair.second<<endl;}
#define dpair(p) cerr << #p":"<<"(" << p.first << "," << p.second << ")" << endl;
// iterate
#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// etc
#define chmin(mi, val) mi = min(mi, val);
#define chmax(ma, val) ma = max(ma, val);
using ll = long long;

using namespace std;

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

    map<string, int> mp;
    rep(i,n){
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        mp[tmp]+=1;
    }
    damp(mp)
    ll ans=0LL;
    for(auto p : mp){
        ans+= (p.second-1LL)*(p.second)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11264
import java.util.*;
import java.io.*;
class Main{
  static long count =0;
  static int n=0;
  public static void main(String args[])throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    n = Integer.parseInt(br.readLine());
    String str [] = br.readLine().split("\\s+");
    int array [] = new int[n];
    for(int i = 0; i<n; i++){
      array[i] = Integer.parseInt(str[i]);
    }
    merge_sort(array,0,array.length);
    System.out.println(count);
  }
  //TLE
  // static void Inversions(int A[]){
  //   for(int i = 0; i<n-1; i++){
  //     for(int j = i+1;j<n;j++){
  //         if(A[i]>A[j])count++;
  //     }
  //   }
  // }

  //TLE
  // static void Inversions(int A[]){
  //   int max = 0;
  //   int max_n = 0;
  //   int prev = 99999;
  //   for(int j =0; j<A.length;j++){
  //     max = 0;
  //
  //     max_n = 0;
  //     for(int i = 0; i < A.length; i++){
  //       if(max<A[i]&&prev>A[i]){
  //         max = A[i];
  //         max_n=i;
  //       }
  //     }
  //     for(int i = max_n+1; i <A.length; i++){
  //       if(A[i]<max)count++;
  //     }
  //     prev = A[max_n];
  //   }
  // }

  static void merge(int A[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    int L[] = new int[n1+1];
    int R[] = new int[n2+1];
    for(int p = left, k= 0; p < mid; k++, p++){
      L[k] = A[p];
    }
    for(int p =mid, k =0; p < right; k++, p++){
      R[k] = A[p];
    }
    L[n1] = (int)Double.POSITIVE_INFINITY;
    R[n2] = (int)Double.POSITIVE_INFINITY;
    int i = 0;
    int j = 0;
    for(int k = left; k<right; k++){
      if(L[i]>R[j]){
        A[k] = R[j++];
        count += (mid - left - i);
      }else{
        A[k] = L[i++];

      }
    }
  }

  static void merge_sort(int A[], int left, int right){
    if(right-left<2)return;
    int mid = (left+right)/2;
    merge_sort(A,left, mid);
    merge_sort(A,mid, right);
    merge(A, left, mid, right);
  }
}


Measured memory_bytes: 63016
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
int main(void){
    int n, ans = 0;
    string s;
    std::cin >> n >> s;
    rep(i, n - 2){
        if(s.at(i) == 'A'){
            if(s.at(i + 1) == 'B'){
                if(s.at(i + 2) == 'C'){
                    ans++;
                }
            }
        }
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

#pragma region mod
const int p = 1e9 + 7; //10^9 + 7
struct mint
{
    ll x;
    mint(ll xx = 0) : x(xx % p) {}
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += p - a.x) >= p)
            x -= p;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= p;
        return *this;
    }

    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const
    {
        mint r = 1;
        mint a = *this;
        while (true)
        {
            if (t & 1)
            {
                r *= a;
            }
            t >>= 1;
            if (t == 0)
                break;
            a *= a;
        }

        return r;
    }

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

    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
};
istream &operator>>(istream &is, mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct comb
{
    vector<mint> fact, invs;
    comb(ll n) : fact(n + 1), invs(n + 1)
    {
        assert(n < p);

        fact[0] = 1;
        for (ll i = 1; i <= n; ++i)
            fact[i] = fact[i - 1] * i;

        invs[n] = fact[n].inv();
        for (ll i = n; i >= 1; --i)
            invs[i - 1] = invs[i] * i;
    }
    mint operator()(ll n, ll k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * invs[n - k] * invs[k];
    }
};
#pragma endregion

int main()
{
    ll k;
    string s;
    cin >> k >> s;
    ll n = s.length() + k;
    comb ncr(n);
    mint ans = 0;
    for (int i = s.length(); i <= n; i++)
    {
        ans += ncr(i - 1, s.length() - 1) * mint(25).pow(i - s.length()) * mint(26).pow(n - i);
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

using ll = long long;
using pint = pair<int, int>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    s << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    s << ']';
	return s;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
	cin >> n;

	vector<ll> a(n);
	vector<ll> b(n);
	int ncnt = 0;
	ll sum = 0ll;
	bool z = false;
	rep(i, n){
	    cin >> a[i];
		if(a[i] < 0) ++ncnt;
		if(a[i] == 0) z = true;
		sum += abs(a[i]);
		b[i] = abs(a[i]);
	}

	if(z){
		ppp(sum);
		return 0;
	}

	sort(b.begin(), b.end());
	rep(i, ncnt%2){
		sum -= 2*abs(b[i]);
	}

	ppp(sum);

    return 0;
}


Measured memory_bytes: 1792
#  --*-coding:utf-8-*--

MOD =  1000000007

def f(N, A):
    A.append(-1)

    a = A.pop(0)

    c0 = 0
    c1 = 1

    for i in range(1, N+1):
        c0, c1 = c1, (c0+c1)%MOD

        if i == a:
            c1 = 0
            a = A.pop(0)

    return c1
            


def main():
    N,M = map(int, input().split())
    A = [int(input()) for i in range(M)]

    print(f(N, A))


if __name__ == '__main__':
    main()


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

using namespace std;

#define endl '\n'

int n, m, a, b;
bool posible_piedra_roja[100005];
int piedras[100005];
int resp = 0;

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

    cin >> n >> m;

    posible_piedra_roja[1] = true;
    for(int i = 1; i <= n; i++)
    {
        piedras[i] = 1;
    }

    while(m--)
    {
        cin >> a >> b;

        if(piedras[a] == 1)
        {
            piedras[b] += 1;
            piedras[a] = 0;
            if(posible_piedra_roja[a])
            {
                posible_piedra_roja[a] = false;
                posible_piedra_roja[b] = true;
            }
        }
        else
        {
            piedras[b] += 1;
            piedras[a] -= 1;
            if(posible_piedra_roja[a])
            {
                posible_piedra_roja[b] = true;

            }
        }
    }

    for(int i = 1; i <= n; i++)
    {
        resp += posible_piedra_roja[i];
    }

    cout << resp << endl;
}


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

const int mod=1000000007;

int dp[2005][2005];

int C(int n,int r){
    if(r<0||n<r)return 0;
    if(r==0)return 1;
    if(r==1)return n;
    if(n==r)return 1;
    if(dp[n][r])return dp[n][r];
    return dp[n][r]=(C(n-1,r-1)+C(n-1,r))%mod;
}

int n,k;

int main(){

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

    cin>>n>>k;
    for(int i=1;i<=k;i++){
        if(i==1){
            cout<<n-k+1<<endl;
            continue;
        }
        long long res=C(k-1,i-1);
        long long red=C(n-k-1,i-2);
        red+=C(n-k-1,i-1);
        red+=C(n-k-1,i-1);
        red+=C(n-k-1,i);
        red%=mod;
        cout<<res*red%mod<<endl;
    }

    return 0;
}

Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=3e5+5;

int n, m, current=0;
int l[N], r[N], ans[N];
int bit[N];
map<int, vector<pair<int, int> > > event;

void update(int idx, int val)
{
	while(idx<=m)
	{
		bit[idx]+=val;
		idx+=idx&-idx;
	}
}

int pref(int idx)
{
	int ans=0;
	while(idx>0)
	{
		ans+=bit[idx];
		idx-=idx&-idx;
	}
	return ans;
}

int rsum(int l, int r)
{
	return pref(r) - pref(l-1);
}

int32_t main()
{
	IOS;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>l[i]>>r[i];
		event[r[i]-l[i]+1].push_back({l[i], r[i]});
		update(l[i], +1);
		update(r[i]+1, -1);
	}
	for(int i=m;i>=1;i--)
	{
		for(auto &it:event[i])
		{
			current++;
			update(it.first, -1), update(it.second+1, 1);
		}
		for(int j=0;j*i<=m;j++)
			ans[i]+=pref(j*i);	
		ans[i]+=current;
	}
	for(int i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 24064
#include <iostream>

using namespace std;

int main()
{
    int n;cin>>n;int a[n];int cnt=0;
    for(int i=1;i<=n;i++){
            cin>>a[i];
            if (a[i]%2!=0 &i%2!=0)cnt++;
    }

    
        
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 3568
A,B,C,K = map(int, input().split())
ans =0
for c,i in enumerate([A,B, C]):
  K -= i
  if K>=0:
    if c ==0:
    	ans += i
    elif c == 2:
      	ans -= i
      
  else:
    if c ==0:
    	ans += K +i
    elif c == 2:
      	ans -= K+i
    break
    
  

print(ans)


Measured memory_bytes: 61744
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k;
  cin >> k;
  cout<<a[k-1]<<endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
  int N, K;
  
  cin >> N >> K;
  
  vector<ll> P;
  
  for (int i = 0; i < N; i++) {
    ll in;
    
    cin >> in;
    
    P.push_back(in);
  }
  
  for (int i = K; i < N; i++) {
    if (P[i - K] < P[i]) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 5368
import java.util.Scanner;

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


		// n=xm+x=x(m+1) m>x
		// 1を足すとnの約数になる数字を出す
		// nの約数を列挙して合計して約数の個数を引く
		// x...xの時、x^2+2x以上
		long ans = 0;

		for (long i = 1; i <= Math.floor(Math.sqrt(n)) +1; i++) {
			if (n % i == 0&&((n/i)-1)>(i)) {
				// System.out.println(i);
				ans += ((n / i) - 1);
				// System.out.println((n/i)+"\t"+n/i);

			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<int,int> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    sort(begin(a),end(a),greater<int>());
    int ans=0;
    rep(i,n){
        if(i%2==0){
            ans+=a[i];
        }else{
            ans-=a[i];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
#define ALL(a) (a).begin(), (a).end()
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int dy8[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dx8[] = {0, 1, 0, -1, 1, 1, -1, -1};
int ny, nx;
typedef long long ll;
using namespace std;

int main(){
    int D; cin >> D;
    vector<int> c(26);
    REP(i,26) cin >> c[i];

    int s[D][26];
    REP(i,D) REP(j,26) cin >> s[i][j];

    REP(i,D) cout << i%26 + 1 << endl;

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

struct point{
    double x, y;
};

void koch(int d, point p1, point p2);

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

    point p1, p2;

    p1.x = p1.y = 0.0;
    p2.x = 100.0;
    p2.y = 0.0;

    printf("%.8f %.8f\n", p1.x, p1.y);
    koch(n, p1, p2);
    printf("%.8f %.8f\n", p2.x, p2.y);
    
    return 0;
}

void koch(int d, point p1, point p2)
{
    if(d == 0) return;

    double kaku_60 = M_PI * 60.0 / 180.0;
    double l = sqrt((p2.x - p1.x)*(p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));

    point s, u, t;

    s.x = (2 * p1.x + p2.x) / 3;
    s.y = (2 * p1.y + p2.y) / 3;
    t.x = (p1.x + 2 * p2.x) / 3;
    t.y = (p1.y + 2 * p2.y) / 3;
    u.x = (t.x - s.x) * cos(kaku_60) - (t.y - s.y) * sin(kaku_60) + s.x;
    u.y = (t.x - s.x) * sin(kaku_60) + (t.y - s.y) * cos(kaku_60) + s.y;

    koch(d-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    koch(d-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    koch(d-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    koch(d-1, t, p2);
}


Measured memory_bytes: 3120
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#define INF 1000000000000000000
#define MP(a,b,c) make_pair(a,make_pair(b,c))
using namespace std;
typedef long long ll;
typedef pair <ll,pair<int,int> > P;
int h,w,n;
ll mp[1010][1010],D[1010][1010];
bool visited[1010][1010];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};

void mk_mp(int x,int y,int t,string str){
  mp[y][x]++;
  while(t--)
    for(int i=0;i<(int)str.size();i++){
      int j=0;//D
      if(str[i]=='U')j=1;
      if(str[i]=='L')j=2;
      if(str[i]=='R')j=3;
      int nx=x+2*dx[j],ny=y+2*dy[j];
      if(nx<1||ny<1||nx>=2*w||ny>=2*h)continue;
      x=nx,y=ny;
      mp[y][x]++;
      mp[y-dy[j]][x-dx[j]]++;
    }  
}

ll dijkstra(int x,int y,int gx,int gy){
  for(int i=0;i<1010;i++)
    for(int j=0;j<=1010;j++) D[i][j]=INF;
  priority_queue <P,vector<P>,greater<P> > Q;
  Q.push(MP(0,x,y));
  D[y][x]=0;
  while(!Q.empty()){
    ll dis=Q.top().first;
    int x=Q.top().second.first;
    int y=Q.top().second.second;
    Q.pop();
    if(x==gx&&y==gy)return dis;
    if(visited[y][x]==1)continue;
    visited[y][x]=1;  
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i];
      if(nx<0||ny<0||nx>2*w||ny>2*h||D[ny][nx]<=dis+mp[ny][nx])continue;
      Q.push(MP(dis+mp[ny][nx],nx+dx[i],ny+dy[i]));
      D[ny][nx]=dis+mp[ny][nx];
    }
  }
  return -1;
}

int main() {
  int sx,sy,gx,gy;
  cin>>w>>h>>n;
  cin>>sx>>sy>>gx>>gy;
  for(int i=0;i<n;i++){
    int x,y,t;
    string str;
    cin>>x>>y;
    cin>>t>>str;
    mk_mp(2*x+1,2*y+1,t,str);
  }
  cout << dijkstra(2*sx,2*sy,2*gx,2*gy)<<endl;
  return 0;
}

Measured memory_bytes: 22960
#include <cstdio>


int reachable(char* s,int lwbd,int upbd)
{
    int i,cc=0;
#ifdef  LOCAL
    printf(" s is %s \n",s);
#endif

    for(i=lwbd;i<upbd && cc<2;i++)
    {
        if(s[i]=='#')
            cc++;
        else if(s[i]=='.')
            cc=0;
    }
    if(cc>1)
        return 0;
    else
        return 1;
}

int main(void)
{
    int N,As,Ae,Bs,Be,i;
    char* s ;
    
    scanf("%d",&N);
    scanf("%d%d%d%d",&As,&Bs,&Ae,&Be);
    s=new char [N+1];
    scanf("%s",s);
    --As;
    --Ae;
    --Bs;
    --Be;
    if(Ae<Be)
    {
#ifdef LOCAL
        printf("MODE 1\n");
#endif
        if(reachable(s,As,Ae) && reachable(s,Bs,Be))
            printf("Yes\n");
        else
            printf("No\n");
        // check reachable(A) and reachable(b)

    }
    else
    {
#ifdef LOCAL
        printf("MODE 2\n");
#endif        
        //check reachable in each steps  b at [bs,be]
        if(reachable(s,As,Ae))
        {
            for(i=Bs;i<=Be;i++)
            {
                if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.')
                {
                    break;
                }
            }
            if(i<=Be)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else
        {
            printf("No\n");
        }

    }
    delete [] s;

    return 0;
}



Measured memory_bytes: 384
n=int(input())
a=list(map(int, input().split()))
flag=True
c=0
while flag:
    flag=False
    for i in range(n-1,0,-1):
        if a[i-1]>a[i]:
            a[i],a[i-1]=a[i-1],a[i]
            flag=True
            c+=1
print(*a)
print(c)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(10);
}
bool comp_first(const pair<int,int>& firstElof, pair< int,int>& secondElof) {
	return firstElof.first< secondElof.first;
}
bool comp_second(const pair<int, int>& firstElof, pair< int, int>& secondElof) {
	return firstElof.second>secondElof.second;
}
signed main() {
	my_io();
	int n;
	cin >> n;
	vector<pair<int, int>>rs(n);
	vector < pair<int, int>>bs(n);
	for (int i = 0; i < n; i++) {
		int f, s;
		cin >> f >> s;
		rs[i] = { f,s };
	}
	sort(rs.begin(), rs.end(), comp_second);
	for (int i = 0; i < n; i++) {
		int f, s;
		cin >> f >> s;
		bs[i] = { f,s };
	}
	sort(bs.begin(), bs.end(), comp_first);
	int ans = 0;
	for (int i = 0; i < bs.size(); i++) {
		for (int j = 0; j <rs.size(); j++) {
			if (bs[i].second > rs[j].second&&bs[i].first > rs[j].first) {
				ans++;
				rs.erase(rs.begin() + j);
				break;
				
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>

typedef long long ll;

struct Fenwick {
    
    std::vector<ll> data;
    
    Fenwick(int size) : data(size, 0) { }
    
    void inc(int pos, int val) {
        for (int p = pos; p < (int)data.size(); p |= (p+1)) {
            data[p] += val;
        }
    }
    
    ll get(int r) const {
        ll ret = 0;
        for (int p = r; p >= 0; p = (p & (p+1)) - 1) {
            ret += data[p];
        }
        return ret;
    }
};

ll count(int x, const std::vector<int>& input) {
    std::vector<int> arr;
    for (auto& it : input) {
        arr.push_back(it >= x ? 1 : -1);
    }
    std::vector<int> sum{0};
    for (auto& it : arr) {
        sum.push_back(sum.back() + it);
    }
    // sum[i] - sum[j-1] >= 0 <--> sum[i] >= sum[j-1]
    const int n = (int)sum.size();
    Fenwick fw(2 * n + 1);
    fw.inc(n, 1);
    ll answ = 0;
    for (int i = 1; i < n; ++i) {
        answ += fw.get(n + sum[i]);
        fw.inc(n + sum[i], 1);
    }
    return answ;
}

int main() {
    int n; scanf("%d", &n);
    std::vector<int> arr(n);
    for (auto& it : arr) scanf("%d", &it);
    int low = *std::min_element(arr.begin(), arr.end())-1;
    int high = *std::max_element(arr.begin(), arr.end())+1;
    while (high - low > 1) {
        int mid = (low + high) / 2;
        if (count(mid, arr) >= ((ll)n * (n+1)/2 + 1) / 2) {
            low = mid;
        } else high = mid;
    }
    printf("%d", low);
    return 0;
}

Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100001],b[500];
int main()
{
    ll i,j,k,l,n,x;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    ll f=0;
    j=0;
    for(i=n-1;i>=0;i--)
    {
        if(a[i]==a[i-1])
        {
            b[j++]=a[i];
            b[j++]=a[i-1];
            i--;
            f++;
        }
    }
    if(f>=2)
    {
        x=b[0];
        ll y=b[2];
        cout<<x*y<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }

map<char,pint> ma;
string str;

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    ma['A'] = pint(0,0); ma['B'] = pint(0,1); ma['C'] = pint(0,2);
    ma['D'] = pint(1,0); ma['E'] = pint(1,1); ma['F'] = pint(1,2);
    ma['G'] = pint(2,0); ma['H'] = pint(2,1); ma['I'] = pint(2,2);
    for (int id = 0; id < 1000; ++id) {
        cin >> str;
        bool ok = true;
        for (int i = 0; i < str.size()-1; ++i) {
            char a = str[i], b = str[i+1];
            if (a == b) ok = false;
            pint p = ma[a], q = ma[b];
            if ( abs(p.first - q.first) + abs(p.second - q.second) != 1 ) ok = false;
        }
        if (ok) cout << str << endl;
    }
    return 0;
}


Measured memory_bytes: 1176
n = int(input())
prime_dic = {}

def prime_factorization(n):
    count = 0
    while n % 2 == 0:
        count += 1
        n = n / 2
    
    if 2 in prime_dic.keys():
        prime_dic[2] += count
    else:
        two = {2:count}
        prime_dic.update(two)

    f = 3
    count = 0
    while f*f <= n:
        if n % f == 0:
            
            if f in prime_dic.keys():
                prime_dic[f] += 1
            else:
                new = {f:1}
                prime_dic.update(new)
            n = n / f
        else:
            f += 2
    if n != 1:
        if n in prime_dic.keys():
            prime_dic[n] += 1
        else:
            new = {n:1}
            prime_dic.update(new)
    return 

for i in range(2,n+1):
    prime_factorization(i)

ans = 1
for key, val in prime_dic.items():
    ans = ans * (val+1) % (10**9 +7)

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define repc2(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const int A = 0;
const int C = 1;
const int G = 2;
const int T = 3;

const ll M = 1000000007;
int n;
ll dp[4][4][109];

ll solve(int n) {
    rep(i, 4) {
        rep(j, 4) { dp[i][j][2] = 1; }
    }
    repc2(i, 3, 100) {
        rep(p1, 4) {
            rep(p2, 4) {
                rep(j, 4) { dp[p1][p2][i] += dp[j][p1][i - 1]; }
                if (p1 == G && p2 == C) {
                    dp[G][C][i] -= dp[A][G][i - 1];
                }
                if (p1 == C && p2 == G) {
                    dp[C][G][i] -= dp[A][C][i - 1];
                }
                if (p1 == A && p2 == C) {
                    dp[A][C][i] -= dp[G][A][i - 1];
                }
                dp[p1][p2][i] %= M;
                if (p1 == G && p2 == C) {
                    dp[G][C][i] -= dp[A][T][i - 2];
                    if (dp[G][C][i] < 0) dp[G][C][i] += M;
                    dp[G][C][i] %= M;

                    dp[G][C][i] -= dp[A][G][i - 2];
                    if (dp[G][C][i] < 0) dp[G][C][i] += M;
                    dp[G][C][i] %= M;
                }
                if (p1 == T && p2 == C) {
                    dp[T][C][i] -= dp[A][G][i - 2];
                    if (dp[T][C][i] < 0) dp[T][C][i] += M;
                    dp[T][C][i] %= M;
                }
            }
        }
    }
    ll ans = 0;
    rep(i, 4) {
        rep(j, 4) { ans = (ans + dp[i][j][n]) % M; }
    }
    return ans;
}

int main() {
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n, m;
	cin >> n >> m;
	vector<int> cnt(n, 0);
	for(int i=0; i<m; i++){
		int a, b;
		cin >> a >> b;
		a--; b--;
		cnt[a]++;
		cnt[b]++;
	}
	for(int i=0; i<n; i++){
		if(cnt[i]%2==1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = list(map(int,input().split()))
su = [0]*(N+1)
um = [0]*(N+1)
ans = 10000000
for i in range(N):
    su[i+1] = su[i]+S[i]
    um[i+1] = um[i]+S[N-1-i]

for i in range(N+1):
  ans = min(abs(su[N-i]-um[i]),ans)
print(ans)

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

public class Main {
    static final Scanner     sc = new Scanner(System.in);
    static final PrintStream so = System.out;

    public static void main(String[] args) {
        int N = ni();
        int[] a = new int[N+2];
        int[] gcdLeft = new int[N+2];
        int[] gcdRight = new int[N+2];
        for (int i = 1; i <= N; i++) {
            a[i] = ni();
            gcdLeft[i] = gcd(a[i], gcdLeft[i-1]);
        }
        for (int i = N; i > 0; i--) {
            gcdRight[i] = gcd(a[i], gcdRight[i+1]);
        }
        
        int ans = 0;
        for (int i = 1; i <= N; i++) {
            ans = Math.max(ans, gcd(gcdLeft[i-1], gcdRight[i+1]));
        }
        so.println(ans);
    }
    
    static int gcd(int m, int n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }
    private static int ni() {
        return sc.nextInt();
    }
}


Measured memory_bytes: 60628
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
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; }
ll mod= 1e9 + 7;



int main() {
  ll n;
  cin >>n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=0;

  ll sum[n];
  for(int i=n-1;i>=0;i--){
    if(i==n-1){sum[i]=a[i];}else{sum[i]=(sum[i+1]+a[i])%mod;}
  }
  rep(i,n-1){
    ll g=(a[i]*sum[i+1])%mod;
    ans=(ans+g)%mod;
  }
  cout << ans << endl;
}


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

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


void solve(){
     
    return ;
}

int main(){
    int n;
    cin>>n;
    vi a(n, 0);
    int count = 0;
    for(int i = 1;i<= n;i++){
        int temp;
        cin>>temp;
        if(i%2 == 1 && temp %2 == 1)count++;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int n,m,ans=0;
  cin >> n >> m;
  char a[n][m]={},b[n][m]={};
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> a[i][j];
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<m; j++) {
      cin >> b[i][j];
      if(a[i][j]!=b[i][j]) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 10928
#include<stdio.h>

int main(){
    int n;
    scanf("%d",&n);
    double v[n],t;
    for(int i=0;i<n;i++){
        scanf("%lf",&v[i]);
    }
    for(int j=0;j<n;j++){
        for(int k=1;k<n;k++){
            if(v[k-1]>v[k]){
                t=v[k-1];
                v[k-1]=v[k];
                v[k]=t;
            }
        }
    }
    for(int m=0;m<n-1;m++){
        v[m+1]=(v[m]+v[m+1])/2;
    }
    printf("%lf\n",v[n-1]);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int n;

	cin >> n;
	vector<int> a1(n);
	vector<int> a2(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a1[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> a2[i];
	}

	int maxx = 0;
	int total = 0;
	int k = 0;
	for (int i = 0; i < n; i++)
	{


		for (k = 0; k <= i; k++)
		{
			total += a1[k];

		}

		for (int j = k - 1; j < n; j++)
		{
			total += a2[j];
		}

		maxx = max(maxx, total);
		total = 0;


	}
	





	cout << maxx << endl;




}

Measured memory_bytes: 256
import java.util.*;

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

        int n, r, p, c;
        while (true) {
            n = sc.nextInt();
            r = sc.nextInt();

            if (n == 0 && r == 0) break;

            int[] a = new int[n], tmp = new int[n];

            for (int i=0; i<n; i++) a[i] = n - i;
            for (int i=0; i<r; i++) {
                System.arraycopy(a, 0, tmp, 0, n);

                p = sc.nextInt();
                c = sc.nextInt();
                System.arraycopy(Arrays.copyOfRange(a, p-1, p-1+c), 0, tmp, 0, c);
                System.arraycopy(Arrays.copyOfRange(a, 0, p), 0, tmp, c, p-1);

                System.arraycopy(tmp, 0, a, 0, n);
            }
            System.out.println(a[0]);
        }
    }
}

Measured memory_bytes: 36568
#include <iostream>
#include <cstring>
#include <queue>

using namespace std;

int main(){
    bool used[26];
    memset(used, false, 26*sizeof(bool));
    string S;
    cin >> S;
    if(S.size() < 26){
        for(int i = 0; i < S.size(); i++){
            used[S[i]-'a'] = true;
        }
        for(int i = 0; i < 26; i++){
            if(!used[i]){
                cout << S << char(i+'a') << endl;
                return 0;
            }
        }
    }else{
        for(int i = 24; i >= 0; i--){
            if(S[i] < S[i+1]){
                for(int j = 0; j < i; j++) cout << S[j];
                char tmp = 'z';
                priority_queue<char> que;
                for(int j = i; j < 26; j++){
                    que.push(S[j]);
                    if(S[j] > S[i] && S[j] < tmp) tmp = S[j];
                }
                cout << tmp;
                /*
                while(!que.empty()){
                    char top = que.top();
                    que.pop();
                    if(top != tmp) cout << top;
                }
                */
                cout << endl;
                return 0;
            }
        }
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
const int N=360005;
int n,d1,d2,col[N],ans[N],t[4],dx[]={1,1,-1,-1},dy[]={1,-1,1,-1};
vector<int>E[N];
int p(int x,int y){
	return x*n*2+y;
}
void dfs(int u,int c){
	col[u]=c;
	for(int v:E[u])if(!~col[v])dfs(v,c^1);
}
void solve(int d,int v){
	for(int i=0;i<4*n*n;++i)E[i].clear(),col[i]=-1;
	for(int x=0;x<n+n;++x){
		if(x*x>d)continue;
		int y=sqrt(d-x*x);
		if(x*x+y*y!=d)continue;
		for(int i=0;i<n+n;++i)
			for(int j=0;j<n+n;++j)
				for(int k=0;k<4;++k){
					int ii=i+dx[k]*x,jj=j+dy[k]*y;
					if(ii<0||ii>=n+n||jj<0||jj>=n+n)continue;
					E[p(i,j)].push_back(p(ii,jj));
				}
	}
	for(int i=0;i<4*n*n;++i){
		if(col[i]==-1)dfs(i,0);
		ans[i]|=col[i]<<v;
	}
}
int main(){
	scanf("%d%d%d",&n,&d1,&d2);
	solve(d1,0);solve(d2,2);
	for(int i=0;i<4*n*n;++i)++t[ans[i]];
	for(int c=0;c<4;++c)
		if(t[c]>=n*n)
			for(int i=0,cnt=n*n;i<4*n*n;++i)
					if(ans[i]==c){
						printf("%d %d\n",i/(n+n),i%(n+n));
						if(!--cnt)return 0;
					}
}


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

using namespace std;

int main() {
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    int a, b, k;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++)
        if (i % k == 0) {
            puts("OK");
            return 0;
        }
    puts("NG");
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int change_to_sec(string time)
{
  int hour = stoi(time.substr(0, 2));
  int minute = stoi(time.substr(3, 2));
  int sec = stoi(time.substr(6, 2));
  // cout << hour << ' ' << minute << ' ' << sec << endl;
  sec += hour * 3600 + minute * 60;
  // cout << sec << endl;
  return sec;
}

int main()
{
  while (true)
  {
    int n;
    cin >> n;
    if (n == 0)
    {
      break;
    }
    vector<int> time_table(86401, 0);
    for (int i = 0; i < n; ++i)
    {
      string start, end;
      cin >> start;
      cin >> end;
      int sec = change_to_sec(start);
      time_table.at(sec) += 1;
      sec = change_to_sec(end);
      time_table.at(sec) -= 1;
    }
    int ans = time_table.at(0);
    // for (int i = 0; i < 86400; ++i)
    // {
    //   if (time_table.at(i) != 0)
    //   {
    //
    //     cout << time_table.at(i) << endl;
    //   }
    // }
    for (int i = 0; i < 86400; ++i)
    {
      time_table.at(i + 1) += time_table.at(i);
      ans = max(ans, time_table.at(i + 1));
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3456
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    int W = s.nextInt();
    int a = s.nextInt();
    int b = s.nextInt();
    if (b > a+W) {
      System.out.println(Math.abs(b-(a+W)));
    } else if (a > b+W){
      System.out.println(Math.abs(a-(b+W)));
    } else {
      System.out.println(0);
    }
  }
}


Measured memory_bytes: 24660
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;

int n;
int v[2][100010];
int la[2][100010],ne[2][100010];

int main(){
	scanf("%d",&n);
	for(int i=0;i<=1;i++)
		for(int j=1;j<=100000;j++) v[i][j]=n/2;
	la[0][0]=la[1][0]=ne[0][100001]=ne[1][100001]=1e9;
	int x;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		v[i%2][x]--;
	}
	for(int i=1;i<=100000;i++) la[0][i]=min(la[0][i-1],v[0][i]),la[1][i]=min(la[1][i-1],v[1][i]);
	for(int i=100000;i>=1;i--) ne[0][i]=min(ne[0][i+1],v[0][i]),ne[1][i]=min(ne[1][i+1],v[1][i]);
	int mmin=1e9;
	for(int i=1;i<=100000;i++){
		mmin=min(mmin,v[0][i]+min(la[1][i-1],ne[1][i+1]));
		mmin=min(mmin,v[1][i]+min(la[0][i-1],ne[0][i+1]));
	}
	printf("%d\n",mmin);
}

Measured memory_bytes: 2560
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		out.println(((N / 111) + (Math.min(N % 111, 1))) * 111);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 22740
N = int(input())
A = list(map(int, input().split()))
A.sort()
minNum = A[0]
maxNum = A[N - 1]
countList = [0]*(10**6 + 1)
answer = 0

# Aにnがm個あるときcountList[n] = m
for i in A:
  countList[i] += 1

for j in range(minNum, maxNum + 1):
  # Aにjが含まれていれば、jの倍数をすべてcountListから除外
  # jの倍数pはjで割り切れるので除外可能
  # pの倍数qはjでも割り切れるのでjの時の処理によって除外される
  if countList[j] > 0:
    for k in range(2 * j, 10**6 + 1, j):
      countList[k] = 0
  # jが2個以上ある場合にはそれを正解としてカウントしない
  if countList[j] == 1:
      answer += 1

print(answer)

Measured memory_bytes: 32276
#include<stdio.h>

int fib(int);

int a[45];

int main(){
int n,i;

for(i=0;i<45;i++)a[i]=-1;

scanf("%d",&n);
printf("%d\n",fib(n));

return 0;
}

int fib(int n){
if(n==0||n==1)return a[n]=1;
if(a[n]!=-1)return a[n];
return a[n]=fib(n-1)+fib(n-2);
}

Measured memory_bytes: 596
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

-- ----------

main :: IO ()
main = do
	s <- getLine
	t <- getLine
	putStrLn $ if length s + 1 == length t && take (length s) t == s
		then "Yes"
		else "No"


Measured memory_bytes: 3764
import copy

N = int(input())
l = []
for i in range(N):
  l.append(int(input()))

mcnt = 0
mv = max(l)
for i in range(N):
  if l[i] == mv and mcnt == 0:
    a = copy.copy(l)
    del a[i]
    print(max(a))
    mcnt = mcnt + 1
  else:
    print(mv)
    



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

using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    long long tot = 0;
    for (int i = 0; i < n; i++) {
        int v;
        cin >> v;
        a[i] = v;
        tot += mp[v];
        mp[v]++;
    }
    for (int v: a) {
        auto cur = tot - (mp[v] - 1);
        cout << cur << "\n";
    }
}



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

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

using LL = long long;

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

int main(){
    int w,h,x,y;
    cin>>w>>h>>x>>y;
    
    double s = double(w)*double(h)/2.0;

    cout<<fixed<<setprecision(10)<<s<<" "<<(x*2==w && y*2==h)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int a,b,c;
int main()
{
	cin>>a>>b>>c;
	a-=c;
	cout<<a/(b+c)<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
const int P = 1e9+7;
#define fr(i,low,up,st) for(register int i = low;i <= up;i += st)
#define nfr(i,low,up,st) for(register int i = low;i >= up;i -= st)
#define clr(a) memset(a,0,sizeof a)
#define SZ(a) (a.size())

int n,k,a[N];
int main(){
   scanf("%d%d",&n,&k);
   fr(i,1,n,1) scanf("%d",a+i);
   int ans = 0;
   fr(i,1,n,1)
      fr(j,1,n,1){
         if(i == j)continue ;
         if(i < j && a[i] > a[j])ans += 1LL*k*(k+1)/2%P;
         else if(i > j && a[i] > a[j])ans += 1LL*(k-1)*(k)/2%P;
         ans %= P;
      }
   printf("%d\n",ans);
   return 0;
}


Measured memory_bytes: 256