akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n+1),sum(n+1,0);
	FOR(i,1,n+1){
		cin>>a[i];
		sum[i]=sum[i-1]+a[i];
	}
	ll ans=inf;
	FOR(i,1,n+1){
		ll l=sum[i],r=sum[n]-l;
		ll cnt=0;
		ll tar=(l+r)/2;
		if((l+r)%2==1) cnt++;
		cnt+=(tar-min(l,r))*2;
		chmin(ans,cnt);
		//cout<<l<<' '<<r<<' '<<tar<<' '<<cnt<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3456
def arr_side_inject(arr_num)
    @data_arr[arr_num] << @data_arr[arr_num].inject(:+)
end

def arr_depth_inject(arr_num)
    depth_arr = []
    @data_num.times do |i|
        depth_arr << @data_arr[i][arr_num]
    end

    @data_arr[@data_num] << depth_arr.inject(:+)
end

def arr_rjust(arr_num)
    0.upto(@data_num) do |i|
        @data_arr[i][arr_num] = @data_arr[i][arr_num].to_s.rjust(5)
    end
end

while @data_num = gets.to_i
    break if @data_num == 0

    @data_arr = []
    @data_num.times do
        @data_arr << gets.chomp.split(' ').map!(&:to_i)
    end
    @data_arr.concat([[]])

    0.upto(@data_num - 1) do |i|
        arr_side_inject(i)
    end

    0.upto(@data_num) do |i|
        arr_depth_inject(i)
        arr_rjust(i)
    end

    0.upto(@data_num) do |i|
        puts @data_arr[i].join('')
    end
end

Measured memory_bytes: 6120
#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<int,int>;

int main(){
    int n,q;
    cin >> n >> q;
    vector <vector <int>> r(n+1);
    vector <int> r2(n+1,n+1);
    int a,b;
    rep(i,n-1){
        cin >> a >> b;
        r[a].push_back(b);
        r[b].push_back(a);
    }
    vector <int> ans(n+1,0);
    int p,x;
    rep(i,q){
        cin >> p >> x;
        ans[p]+=x;
    }
    queue <int> qu;
    qu.push(1);
    vector <int> tu(n+1,-1);
    int now;
    tu[1]=0;
    int l;

    while(qu.size()!=0){
        now=qu.front();
        qu.pop();
        l=r[now].size();
        rep(i,l){
            if(tu[r[now][i]]==0){
                continue;
            }
            qu.push(r[now][i]);
            ans[r[now][i]]+=ans[now];
            tu[r[now][i]]=0;
        }
    }

rep(i,n){
    printf("%d ",ans[i+1]);
}

    
    
    
    
    

    return 0;
}

Measured memory_bytes: 17140
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

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

    ll n;cin>>n;
    vector<ll> a(n);
    bool f = true;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] % 2)
            f = false;
    }
    if(f){
        cout<<"second"<<endl;
    }
    else{
        cout<<"first"<<endl;
    }
}


Measured memory_bytes: 1024
n,m=map(int,input().split())
s=input()
x=n
a=[]
while x!=0:
  for i in range(min(m,x),0,-1):
    if s[x-i]=="0":
      x-=i
      a.append(i)
      break
    if i==1:print(-1);exit()
print(*a[::-1])

Measured memory_bytes: 6372
#include<iostream>
#include<queue>
#include<algorithm>
#include<string.h>
#include<math.h>
using namespace std;
int nums[1000010];
int nm[200010];
int main() {
	int n,cnt=0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		nm[i] = a;
		nums[a]++;
	}
	if (nums[1]==1) {
		cout << 1;
		return 0;
	}
	if (nums[1] > 1) {
		cout << 0;
		return 0;
	}
	for(int i=1;i<=n;i++){
		int a = nm[i],j;
		if (nums[a] > 1)continue;
		for (j = 2; j <= sqrt(a); j++) {
			if (a % j == 0) {
				if (nums[a / j] || nums[j])break;
			}
		}
		if (j > sqrt(a))cnt++;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 8336
using System;
using System.Collections.Generic;
using System.Linq;

namespace Practice
{
    class Program
    {

        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);
        }
        
        static void SolveA(string[] args)
        {
            string sz = (Console.ReadLine());
            long n = long.Parse(sz);
            if(n %  2 == 0)
            {
                Console.WriteLine(n);
            }
            else
            {
                Console.WriteLine(n * 2);
            }
        }
    }

}


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

const int N = 1e5+5, M = 1e6+6, OO = 0x3f3f3f3f;
map<string, ll> m;
int n;
int main()
{
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin>>s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    ll ans = 0;
    for(auto p : m)
        ans += (p.second  * (p.second - ll(1) )/ ll(2));
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 11136
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineerin College
    Date:24/03/2020
'''

def main():
    
    # for _ in range(ii()):
    n=int(input())
    a=list(map(int,input().split()))
    f=0
    for i in a:
        if(i%2==0):
            if(i%3!=0 and i%5!=0):
                f=1
                break
    if(f):
        print('DENIED')
    else:
        print('APPROVED')
        
















    
    
if __name__ =="__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int n;
    cin >> n;
    long long int k;
    cin >> k;
    vector<long long int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }

    long long int res1 = 0, res2 = -1;
    for (int i = 62; i >= 0; i--) {
        long long int zero = 0, one = 0;
        long long int base = 1;
        // res1 == , res2 <
        long long int next_res1 = 0, next_res2 = -1;
        for (auto num : v) {
            if ((num >> i) % 2 == 1) {
                one++;
            } else {
                zero++;
            }
        }
        if ((k >> i) % 2 == 1) {
            if (res2 > 0)
                next_res2 = max(res2 + max(one, zero) * (base << i), res1 + one * (base << i));
            else
                next_res2 = res1 + one * (base << i);
            next_res1 = res1 + zero * (base << i);
        } else {
            next_res1 = res1 + one * (base << i);
            if (res2 > 0) next_res2 = max(one, zero) * (base << i) + res2;
        }
        res1 = next_res1;
        res2 = next_res2;
    }

    cout << max(res1, res2) << endl;
}


Measured memory_bytes: 4028
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){
  int x;
  cin >> x;
  cout << (1^x) << endl;

  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cmath>
#include <climits>
using namespace std;

map<long long, bool> mp;
priority_queue<long long, vector<long long> > pq;

int main()
{
    /*
     * 配列で出てきた回数カウント、2回出たものはpriority_queueに格納
     * priority_queueないの要素2個の積が解
     */
    long long N, A, rt = 1;
    cin >> N;
    while (N--) {
        cin >> A;
        if (mp[A]) {
            mp[A] = false;
            pq.push(A);
        } else {
            mp[A] = true;
        }
    }
    if (pq.size() > 1) {
        rt *= pq.top();
        pq.pop();
        rt *= pq.top();
    } else {
        rt = 0;
    }
    cout << rt << endl;
    return 0;
}


Measured memory_bytes: 6528
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    L = [0] * N
    R = [0] * N
    for i in range(1, N):
        L[i] = L[i - 1] ^ A[i - 1]
    for i in range(N - 2, -1, -1):
        R[i] = R[i + 1] ^ A[i + 1]
    ans = [L[i] ^ R[i] for i in range(N)]
    print(*ans)

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)


Measured memory_bytes: 116496
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;
#define int long long
const int N = (int) 1e6 + 6, mod = (int) 0;
int cnt[N], a[N], b[N];
int32_t main() {
	int n;
	cin >> n;
	for (int j = 0; j < n; ++j) {
		cin >> a[j] >> b[j];
		if (a[j] > b[j]) {
			swap(a[j], b[j]);
		}
	}
	int res = 1;
	int mx_all = -1e18, mn_all = 1e18;
	for (int j = 0; j < 2; ++j) {
		for (int i = 0; i < n; ++i) swap(a[i], b[i]);	
		int mx = -1e18, mn = 1e18;
		for (int i = 0; i < n; ++i) mx = max(mx, a[i]), mn = min(a[i], mn);
		res *= mx - mn;
		mx_all = max(mx_all, mx);
		mn_all = min(mn_all, mn);
	}
	int range = 1e18;
	vector<pair<int, int>> sweepline;
	set<pair<int, int>, greater<pair<int, int>>> all;
	for (int j = 0; j < n; ++j) {
		sweepline.pb(mp(a[j], j));
		sweepline.pb(mp(b[j], j));
		all.insert(mp(a[j], j));
	}
	sort(ALL(sweepline));
	for (auto x : sweepline) {
		int id = x.second, pl = x.first;
		auto most = *(all.begin());
		range = min(range, most.first - pl);
		if (cnt[id] == 1) break;
		cnt[id] = 1;
		all.erase(x);
		all.insert(mp(b[id], id));
	}
	cout << min(res, range * (mx_all - mn_all)) << endl;
}



Measured memory_bytes: 30696
#include <stdio.h>
#include <string.h>

struct Point {
	int x;
	int y;
	int z;
};
struct Pip {
	int n;
	struct Point p;
};
struct Dice {
	struct Pip pip[6];
};

const struct Point top    = { 0,  0,  1};
const struct Point front  = { 0, -1,  0};
const struct Point right  = { 1,  0,  0};
const struct Point left   = {-1,  0,  0};
const struct Point back   = { 0,  1,  0};
const struct Point bottom = { 0,  0, -1};
const char *d = "NEWSRLKD";
const int r[8][3][3] = {
	{{ 1,  0,  0}, { 0,  0,  1}, { 0, -1,  0}}, // N
	{{ 0,  0,  1}, { 0,  1,  0}, {-1,  0,  0}}, // E
	{{ 0,  0, -1}, { 0,  1,  0}, { 1,  0,  0}}, // W
	{{ 1,  0,  0}, { 0,  0, -1}, { 0,  1,  0}}, // S
	{{ 0,  1,  0}, {-1,  0,  0}, { 0,  0,  1}}, // R
	{{ 0, -1,  0}, { 1,  0,  0}, { 0,  0,  1}}, // L
	{{ 1,  0,  0}, { 0,  1,  0}, { 0,  0,  1}}, // K
	{{-1,  0,  0}, { 0,  1,  0}, { 0,  0, -1}}  // D
};

int comparePoints(struct Point p0, struct Point p1)
{
	if (p0.x == p1.x && p0.y == p1.y && p0.z == p1.z) {
		return 1;
	}
	return 0;
}

void roll(struct Dice *dice, char c)
{
	char *p = strchr(d, c);
	int n = p - d;
	for (int i = 0; i < 6; i++) {
		struct Point *p = &dice->pip[i].p;
		int x = p->x;
		int y = p->y;
		int z = p->z;
		p->x = x * r[n][0][0] + y * r[n][0][1] + z * r[n][0][2];
		p->y = x * r[n][1][0] + y * r[n][1][1] + z * r[n][1][2];
		p->z = x * r[n][2][0] + y * r[n][2][1] + z * r[n][2][2];
	}
}

int getNumber(struct Dice *dice, struct Point p)
{
	int num = 0;
	for (int i = 0; i < 6; i++) {
		struct Pip pip = dice->pip[i];
		if (comparePoints(pip.p, p)) {
			num = pip.n;
			break;
		}
	}
	return num;
}

int compareDices(struct Dice *dice0, struct Dice *dice1)
{
	if (getNumber(dice0, top) != getNumber(dice1, top)) {
		return 0;
	} else if (getNumber(dice0, front) != getNumber(dice1, front)) {
		return 0;
	} else if (getNumber(dice0, right) != getNumber(dice1, right)) {
		return 0;
	} else if (getNumber(dice0, left) != getNumber(dice1, left)) {
		return 0;
	} else if (getNumber(dice0, back) != getNumber(dice1, back)) {
		return 0;
	} else if (getNumber(dice0, bottom) != getNumber(dice1, bottom)) {
		return 0;
	}
	return 1;
}

int main(void)
{
	char rotation[6][4] = {
		{'K', 'R', 'R', 'R'},
		{'W', 'R', 'R', 'R'},
		{'E', 'R', 'R', 'R'},
		{'D', 'R', 'R', 'R'},
		{'W', 'R', 'R', 'R'},
		{'E', 'R', 'R', 'R'}
	};
	struct Dice dice0 = {
		{{1, top}, {2, front}, {3, right},
		{4, left}, {5, back}, {6, bottom}}
	};
	for (int i = 0; i < 6; i++) {
		scanf("%d", &dice0.pip[i].n);
	}
	struct Dice dice1 = {
		{{1, top}, {2, front}, {3, right},
		{4, left}, {5, back}, {6, bottom}}
	};
	for (int i = 0; i < 6; i++) {
		scanf("%d", &dice1.pip[i].n);
	}
	for (int i = 0; i < 6; i++) {
		for (int j = 0; j < 4; j++) {
			roll(&dice1, rotation[i][j]);
			if (compareDices(&dice0, &dice1)) {
				printf("Yes\n");
				return 0;
			}
		}
	}
	printf("No\n");
	return 0;
}



Measured memory_bytes: 2120
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{

    

    class Program
    {
        
        
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(',');

            Console.WriteLine(string.Join(" ", input));

            
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p,int r){
    int x, i, j, t;
    x = A[r];
    i = p-1;
    for(j=p; j<r; j++){
        if(A[j]<=x){
            i++;
            t=A[i];
            A[i] = A[j];
            A[j] = t;
        }
    }
    t = A[i+1];
    A[i+1] = A[j];
    A[j] = t;
    return i+1;
}

int main(){
    int i,q;

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

    q = partition(0,n-1);

    for(i=0; i<n; i++){
        if(i){
            printf(" ");
        }
        if(i ==q){
            printf("[");
        }
        printf("%d",A[i]);
        if(i == q){
            printf("]");
        }
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

ll dp[105][10];

ll fnum[105];

ll f(int n){
  if(n<=0)return 1;
  if(fnum[n]>0)return fnum[n];
  ll num=0;
  for(int bit=0; bit<(1<<n); bit++){
    bool suc=false;
    bool can=true;
    rep(i, n){
      if((bit>>i)&1){
        if(suc){
          can=false;
          break;
        } else {
          suc=true;
        }
      } else {
        suc=false;
      }
    }
    if(can){
      num++;
    }
  }
  return fnum[n]=num;
}

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  dp[0][0]=1;
  rep(i, h){
    rep(j, w){
      dp[i+1][j]+=dp[i][j]*f(w-j-2)*f(j-1);
      dp[i+1][j]%=mod;
      if(j-1>=0){
        dp[i+1][j-1]+=dp[i][j]*f(w-j-2)*f(j-2);
        dp[i+1][j-1]%=mod;
      }
      if(j+1<w){
        dp[i+1][j+1]+=dp[i][j]*f(w-j-3)*f(j-1);
        dp[i+1][j+1]%=mod;
      }
    }
  }
  cout << dp[h][k-1] << endl;
  return 0;
}


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

int main() {
  //定義一覧
  int N = 0;
  int M = 100000000;
  int tmp = 0;
  int O = 0;
  
  //10進数の整数の入力
  cin >> N;
  O = N;
  for(int i = 9; i > 0; i--){
    //cout << M << endl;
  	tmp = tmp + (O / M);
    O = O % M;
    M /= 10;
  }

  if((N % tmp) == 0){
  	cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
typedef long long ll;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
const long long INF = 1e18, MOD = 1e9 + 7;
using namespace std;
int main() {
	ll N,M,ans;
	ll maxL = -1;
	cin >> N >> M;
	vector<ll> L(M), R(M);
	rep(i,M) {
		cin >> L[i] >> R[i];
	}
	ll minR = INF;
	rep(i, M) {
		maxL = max(maxL, L[i]);
		minR = min(minR, R[i]);
	}
	ans = minR - maxL + 1;
	ans = max(ans, (ll)0);
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
          
using namespace std;
          
#define ll long long
#define vi vector<int> 
#define pb push_back
#define sz(s) (int)s.size() 
#define all(v) v.begin(), v.end()
#define show(a) cerr << #a <<" -> "<< a <<"\n"
 
ll mn = 1000000, mx = -1000000000; 
ll cnt, cnt2, sum, x, y;
int n;
string s[300001];
			             
int main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
    	cin >> s[i];
	}
	sort (s, s + n);
	for (int i = 0; i < n; i++) {
		if (s[i] != s[i + 1]) {
			cnt++;
		}
	}
	cout << cnt;
    return 0;
}

Measured memory_bytes: 12952
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;
vector<ll> P(0);

void sosuu_(ll x) {
    for(ll j=2; j*j<=x; j++) {
        if(x%j!=0) continue;
        P.push_back(j);
        while(x%j==0)x/=j;
    }
    if(x!=1) P.push_back(x);
}

int main(){
    ll n;
    cin>>n;
    sosuu_(n);
    ll j=0;
    map<ll,ll> mp;
    vector<ll> sosuu(0);
    while(n>1){
        if(n%P[j]==0){
            sosuu.push_back(P[j]);
            while(n%P[j]==0){
                n/=P[j];
                mp[P[j]]++;
            }
        }
        j++;
    }
    ll ans=0;
    for(ll i:sosuu){
        ll q=1;
        //cout<<mp[i]<<endl;
        while(q*(q+1)<=2*mp[i]){
            q++;
        }
        ans+=q-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var n, tMax int
	fmt.Scan(&n, &tMax)

	var c, t int
	minC := 1001
	for i := 0; i < n; i++ {
		fmt.Scan(&c, &t)
		if c < minC && t <= tMax {
			minC = c
		}
	}

	if minC == 1001 {
		fmt.Println("TLE")
		return
	}

	fmt.Println(minC)
}


Measured memory_bytes: 512
#include <iostream> 

using namespace std;
int main() {

	int n;
	cin >> n;
	int a[n];
	for (int i = 0;i<n;i++) {
		cin >> a[i];
	}
	int minv = a[0];
	int maxv = -1000000000;
	for (int i = 1;i<n;i++) {
		if (maxv<a[i] - minv) {
			maxv = a[i] - minv;
		}
		if (minv>a[i]) {
			minv = a[i];
		}
	}
	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 3896
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++) 
int h,w,s,u[200][200];
int c[40][40][40][40];
int mini,sum;
int INF = 1e9;
#define fi first
#define sc second

typedef pair<int,int> P;

int cou(int mh,int mw,int Mh,int Mw) {
    int ret = 0;
    FOR(i,mh,Mh) {
        FOR(j,mw,Mw) {
            ret += u[i][j];
        }
    }
    return ret;
}

bool used[40][40][40][40];
P memo[40][40][40][40];

P solve(int mh,int mw,int Mh,int Mw) {
    //cerr << mh << " " << mw << " " << Mh << " " << Mw << endl;

    if(c[mh][mw][Mh][Mw] < mini) {
        used[mh][mw][Mh][Mw] = true;
        return memo[mh][mw][Mh][Mw] = P(-INF,0);
    }

    if(used[mh][mw][Mh][Mw]) {
        return memo[mh][mw][Mh][Mw];
    }

    P ret(P(1,max(sum - c[mh][mw][Mh][Mw],0)));

    FOR(i,mh,Mh-1) {
        P p = solve(mh,mw,i+1,Mw);
        P q = solve(i+1,mw,Mh,Mw);

        p.fi += q.fi;
        p.sc = max(p.sc,q.sc);

        if(ret.fi != p.fi) ret = (p.fi > ret.fi) ? p : ret;
        else ret = (p.sc < ret.sc) ? p : ret;
    }
    FOR(i,mw,Mw-1) {
        P p = solve(mh,mw,Mh,i+1);
        P q = solve(mh,i+1,Mh,Mw);
        p.fi += q.fi;
        p.sc = max(p.sc,q.sc);

        if(ret.fi != p.fi) ret = (p.fi > ret.fi) ? p : ret;
        else ret = (p.sc < ret.sc) ? p : ret;
    }
    used[mh][mw][Mh][Mw] = true;
    return memo[mh][mw][Mh][Mw] = ret;
}

int main() {
    while(true) {
        cin >> h >> w >> s;
        if(h == 0)
            break;

        rep(i,h)rep(j,w) cin >> u[i][j];
        rep(i,h)rep(j,w)FOR(k,i+1,h+1)FOR(l,j+1,w+1)c[i][j][k][l] = cou(i,j,k,l);

        rep(i,h+1)rep(j,w+1)rep(k,h+1)rep(l,w+1)used[i][j][k][l] = false;

        mini = c[0][0][h][w] - s;
        sum = c[0][0][h][w];
        P ans = solve(0,0,h,w);
        cout << ans.fi << " " << s - ans.sc << endl;
    } 
}


Measured memory_bytes: 30808
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 200005;
int N, K, n;
ll s[maxn], v[maxn];
int c[maxn];
void add(int p) {
    for(; p<=n+1; p+=p&-p) c[p] += 1;
}
ll query(int p) {
    ll ans = 0;
    for(; p; p-=p&-p) ans += c[p];
    return ans;
}
int main() {
    scanf("%d%d", &N, &K);
    s[0] = 0;
    for(int i=1, a; i<=N; ++i) {
	scanf("%d", &a);
	s[i] = s[i-1]+a-K;
    }
    for(int i=0; i<=N; ++i) v[i] = s[i];
    sort(v, v+N+1);
    n = unique(v, v+N+1)-v-1;
    for(int i=0; i<=N; ++i)
	s[i] = lower_bound(v, v+n+1, s[i])-v+1;
    ll ans = 0;
    add(s[0]);
    for(int i=1; i<=N; ++i) 
	ans += query(s[i]), add(s[i]);
    printf("%lld\n", ans);
    return 0;
}


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

using namespace std;

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

	int ans=0;
	for(int i=1;i<n;i++){
		int cnt=0;

		for(char c='a';c<='z';c++){
			bool left=false,right=false;

			for(int j=0;j<i;j++){
				if (s[j]==c) left=true;
      }

			for(int j=i;j<n;j++){
				if (s[j]==c) right=true;
      }

			if (left&&right) cnt++;
		}

		if (ans<cnt) ans=cnt;
	}

	cout<<ans<<endl;
}


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

using namespace std;

int main(){
  for(int N;cin>>N,N;){
    int r[1000],w[1000];
    int rsum=0,wsum=0;
    for(int i=0;i<N;i++){
      cin>>r[i]>>w[i];
      rsum+=r[i];
      wsum+=w[i];
    }
    auto it=max_element(begin(r),begin(r)+N);
    if(*it*2<=rsum){
      cout<<rsum+wsum<<endl;
    }else{
      bool dp[1001]={true};
      for(int i=0;i<N;i++){
	if(*it==r[i])continue;
	for(int j=1000;j-w[i]>=0;j--){
	  dp[j]|=dp[j-w[i]];
	}
      }
      int x=*it*2-rsum;
      while(!dp[x]){
	x--;
      }
      cout<<*it*2+wsum-x<<endl;
    }
  }
}

Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>
 
#include <algorithm>
#include <tuple>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>
 
#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (T& x : v)
    is >> x;
  return is;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

const int N = 5010;
const ll INF = 1LL << 60;

int n, a, b;
int p[N];
ll dp[N][N];

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

  cin >> n >> a >> b;
  for (int i = 1; i <= n; ++i)
    cin >> p[i];
  for (int i = 1; i <= n; ++i) {
    fill(dp[i], dp[i] + n + 1, INF);
    for (int j = 0; j <= n; ++j) {
      if (p[i] <= j)
        dp[i][j] = min(dp[i - 1][p[i] - 1], dp[i - 1][j] + b);
      else
        dp[i][j] = dp[i - 1][j] + a;
      if (j)
        dp[i][j] = min(dp[i][j], dp[i][j - 1]);
    }
  }
  cout << dp[n][n] << '\n';

  return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

const double PI=3.14159265358979323846;

int main(){

  double a,b,h,m;
  cin >> a >> b >> h >> m;
  double theta = (h+m/60)/12-m/60;
  theta *= 2*PI;
  double x = a*a + b*b-2*a*b*cos(theta);
  double ans = sqrt(x);

  cout << fixed;
  cout << setprecision(14) << ans << endl;

  return 0;
}

Measured memory_bytes: 4212
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  int n;
  cin>>n;
  int a[n+1],b[n];
  for(int i=0;i<n+1;i++) cin>>a[i];
  for(int i=0;i<n;i++) cin>>b[i];
  ll ans=0;
  for(int i=0;i<n;i++){
    int temp=min(b[i],a[i]);
    ans+=temp;
    if(temp==a[i]){
      b[i]-=a[i];
      ans+=min(b[i],a[i+1]);
      a[i+1]-=min(b[i],a[i+1]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;

  priority_queue<int> que;
  map<int, int> mp;
  REP(i,n){
    int tmp;
    cin >> tmp;
    mp[tmp]++;
  }

  REPI(itr,mp){
    que.push(itr->second);
  }

  while(true){
    if(que.top() == 1){
      break;
    }
    int a, b;
    a = que.top();
    que.pop();
    if(que.empty()){
      cout << "1" << endl;
      return 0;
    }
    b = que.top();
    que.pop();
    a--;
    b--;
    que.push(a);
    if(b > 0){
      que.push(b);
    }
  }

  cout << que.size() << endl;

  return 0;
}



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,m,sum;
	cin>>n>>m;
	vector<long long int> a(m);
	for(int i=0;i<m;i++)
	cin>>a[i];
	sum=accumulate(a.begin(),a.end(),(long long int)0);
	if(sum<=n)
	cout<<n-sum<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 3672
import Data.Maybe
import Data.List

main :: IO ()
main = do
  input <- getContents
  putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = show $ n * (n + 1) `div` 2 where n = read s :: Int

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 508
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
int map[504][504];
int ans[504][504];

long long nCi(int n, int k){
  if (k>n/2) return nCi(n, n-k);
  long long retval = 1;
  for (int i=n; i>n-k; i--) {
    int waru = n-i+1;
    retval *= i;
    retval /= waru;
  }
  return retval;
}

int main(){
  int N, P;
  scanf("%d", &N);
  scanf("%d", &P);
  std::vector<int > A(N);
  int oddcount = 0;
  int evencount = 0;
  for (int i=0; i<N; i++){
    scanf("%d", &A[i]);
    if (A[i]%2==0) evencount++;
    if (A[i]%2==1) oddcount++;
  }
  long long ans = 0;
  if (P==0){
    for (int i=0; i<=oddcount; i+=2){
      ans += nCi(oddcount, i);
    }
  } else {
    for (int i=1; i<=oddcount; i+=2){
      ans += nCi(oddcount, i);
    }    
  }
  for (int i=0; i<evencount; i++){
    ans *= 2;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 888
####################################################################
import sys
def _p(*_a):
  #return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
def _pa(_aa):
  #return
  for _a in _aa: _p(_a)
####################################################################
H,W = map(int, input().split())
ch,cw = map(int, input().split())
dh,dw = map(int, input().split())
M = list( list(input()) for _ in range(H) )

if ch==dh and cw==dw:
  print(0)
  exit()

INF = 10**18

for h in range(H):
  for w in range(W):
    if M[h][w] == ".": M[h][w] = INF
    # if M[h][w] == "#": M[h][w] = -1

ch -= 1
cw -= 1
dh -= 1
dw -= 1

M[ch][cw] = 0
# M[dh][dw] = "G"

# _pa(M)


from collections import deque
Q = deque()
Q.append((ch,cw))

ans = INF

while Q:
  h,w = Q.popleft()

  for ih,iw in [(1,0), (-1,0), (0,1), (0,-1)]:
    nh = h + ih
    nw = w + iw
    if nh < 0 or H <= nh: continue
    if nw < 0 or W <= nw: continue
    if M[nh][nw] == "#": continue

    if nh == dh and nw == dw:
      M[nh][nw] = min(M[h][w], M[dh][dw])
      ans = min(ans, M[nh][nw])
      continue

    if M[h][w] < M[nh][nw]:
      M[nh][nw] = M[h][w]
      Q.appendleft((nh,nw))
      continue

    if M[h][w] > M[nh][nw]:
      M[h][w] = M[nh][nw]
      Q.appendleft((h,w))

  for ih,iw in [(1,1), (1,-1), (-1,1), (-1,-1), (2,0), (2,1), (2,2), (2,-1), (2,-2), (1,2), (1,-2), (0,2), (0,-2), (-1,2), (-1,-2), (-2,0), (-2,1), (-2,-2), (-2,-1), (-2,-2)]:
    nh = h + ih
    nw = w + iw
    if nh < 0 or H <= nh: continue
    if nw < 0 or W <= nw: continue
    if M[nh][nw] == "#": continue

    if nh == dh and nw == dw:
      M[nh][nw] = min(M[h][w]+1, M[dh][dw])
      ans = min(ans, M[nh][nw])
      continue

    if M[h][w]+1 < M[nh][nw]:
      M[nh][nw] = M[h][w]+1
      Q.append((nh,nw))
      continue

    if M[h][w] > M[nh][nw]+1:
      M[h][w] = M[nh][nw]+1
      Q.append((h,w))

# _pa(M)

if ans == INF: ans = -1
print(ans)






Measured memory_bytes: 148900
#include<bits/stdc++.h>
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
static const ll MAX = 1000000000000000;
static const int NIL = -1;
using namespace std;
const long double EPS = 0.0000000001;
const long double PI = (acos(-1));
const ll MOD = 1e9 + 7;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")




int main() {

    string s;
    cin >> s;

    if(s[s.length()-1] == 's') cout << (s+"es");
    else cout << (s+"s");

}


Measured memory_bytes: 3636
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define SIZE 1005

using namespace std;

char mp[SIZE][SIZE];

int main()
{
	int n,m,A,B;
	scanf("%d %d %d %d",&n,&m,&A,&B);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			mp[i][j]='.';
		}
	}
	if(n%2==1)
	{
		int t=0;
		while(A>0&&t+1<m)
		{
			mp[n-1][t]='<';
			mp[n-1][t+1]='>';
			t+=2;
			A--;
		}
	}
	if(m%2==1)
	{
		int t=0;
		while(B>0&&t+1<n)
		{
			mp[t][m-1]='^';
			mp[t+1][m-1]='v';
			t+=2;
			B--;
		}
	}
	for(int i=0;i+1<n;i+=2)
	{
		for(int j=0;j+1<m;j+=2)
		{
			if(A>=2)
			{
				mp[i][j]='<';
				mp[i][j+1]='>';
				A--;
				mp[i+1][j]='<';
				mp[i+1][j+1]='>';
				A--;
			}
			else if(B>=2)
			{
				mp[i][j]='^';
				mp[i+1][j]='v';
				B--;
				mp[i][j+1]='^';
				mp[i+1][j+1]='v';
				B--;
			}
			else if(A==1)
			{
				mp[i][j]='<';
				mp[i][j+1]='>';
				A--;
			}
			else if(B==1)
			{
				mp[i][j]='^';
				mp[i+1][j]='v';
				B--;
			}
		}
	}
	if(n%2==1&&m%2==1&&A==0&&B==1&&n>=3&&m>=3)
	{
		if(mp[n-2][m-3]=='.')
		{
			mp[n-1][m-1]='>';
			mp[n-1][m-2]='<';
			mp[n-2][m-3]='^';
			mp[n-1][m-3]='v';
			B--;
		}
	}
	if(A==0&&B==0)
	{
		puts("YES");
		for(int i=0;i<n;i++)
		{
			printf("%s\n",mp[i]);
		}
	}
	else
	{
		puts("NO");
	}
	return 0;
}


Measured memory_bytes: 2176
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<array>
using namespace std;

int main(){

    array<int, 5> dish;

    for(int i = 0; i < 5; ++i){

        cin >> dish[i];

    }

    int tmp = 10;

    for(int i = 0; i < 5; ++ i){

        int ten = dish[i]%10;
        if(ten < tmp && ten != 0){

            tmp = ten;
            swap(dish[i], dish[4]);

        }

    }

    int out = 0;
    for(int i = 0;i < 4; ++i){

        int ten = dish[i]-(dish[i]%10);
        if(dish[i]%10 != 0)out += ten+10;
        else out += ten;

    }

    out += dish[4];

    cout << out << endl;

    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
h = gets.split.map(&:to_i)

ans = 0
while h.count(0) != n
  prev = h.index{|v| v != 0}
  tail = h[prev..-1].index{|v| v==0}
  tail = tail == nil ? n : tail + prev

  ans += h[prev..(tail-1)].min
  h[prev..(tail-1)] = h[prev..(tail-1)].map{|v| v - h[prev..(tail-1)].min}
end

puts ans

Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int n; cin >> n;
    std::vector<int> l(n); rep(i,n) cin >> l[i];
    int cnt = 0;

    sort(l.begin(), l.end());

    rep(i,n) for(int j=i+1; j<n; ++j){
        int x = upper_bound(l.begin(), l.end(), l[i]+l[j]-1)-l.begin();

        if(x!=0){
            cnt += x-j-1;
        }
    }

    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 256
pub struct State {
    a: usize,
    c: Vec<usize>,
}
const INF: usize = 1 << 30;
impl State {
    pub fn new(a: usize, c: Vec<usize>) -> State {
        State { a: a, c: c }
    }
}

pub fn memo(
    p: usize,
    bit: usize,
    states: &Vec<State>,
    memos: &mut Vec<Vec<Option<usize>>>,
    n: usize,
) -> usize {
    let all_bit: usize = (1 << n) - 1;
    if bit == all_bit {
        return 0;
    }
    if p == states.len() {
        return INF;
    }
    if let Some(value) = memos[p][bit] {
        return value;
    }
    let mut result = INF;
    //not buy
    result = std::cmp::min(result, memo(p + 1, bit, states, memos, n));
    //buy
    let mut next_bit = bit;
    for c in states[p].c.iter() {
        next_bit |= (1 << (c - 1)) as usize;
    }
    result = std::cmp::min(
        result,
        memo(p + 1, next_bit, states, memos, n) + states[p].a,
    );
    memos[p][bit] = Some(result);
    return result;
}

fn solve() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let m: usize = sc.read();
    let mut states = vec![];
    for _ in 0..m {
        let a: usize = sc.read();
        let b: usize = sc.read();
        let c: Vec<usize> = sc.vec(b);
        states.push(State::new(a, c));
    }
    let mut memos = vec![vec![None; 1 << 13]; m + 1];
    let result = memo(0, 0, &states, &mut memos, n);
    if result >= INF {
        println!("-1");
        return;
    }
    println!("{}", result);
}

fn main() {
    std::thread::Builder::new()
        .stack_size(64 * 1024 * 1024) // 64MB
        .spawn(|| solve())
        .unwrap()
        .join()
        .unwrap();
}

//snippet from kenkoooo
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_line(&mut self) -> String {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b'\n' || b == b'\r')
            .take_while(|&b| b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int N;cin>>N;
    if(N<1000)cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  //index is 0-base
  
  invar(int, N);
  vi a(N);
  set<pair<int, int>> s; //value, index
  rep(i, N) {
    cin >> a[i];
    s.emplace(make_pair(a[i], i));
  }
  
  set<int> idx;
  ll sum = 0;
  while(!s.empty()) {
    auto curp = *s.begin();  //最小のVALUEから順に取得  
    s.erase(s.begin());
    int curv = curp.first;
    int curi = curp.second;
    
    //次に小さいINDEXと大きいINDEXを取得する
    int l = -1, r = N;
    {
      auto itr = idx.lower_bound(curi);
      if(itr != idx.begin()) {
        itr--;
        //iteratorはbegin()なのは有効 / 一方，end()は無効なiterator
        l = *itr;
      }
    }
    {
      auto itr = idx.lower_bound(curi);
      if(itr != idx.end()) r = *itr;
    }
    
    sum += (ll)curv * (ll)(r - curi) * (ll)(curi - l);
    //
    idx.emplace(curi);
  }
  
  fin(sum);
}

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

int main() {
  int a, b;
  cin >> a >> b;

  int cnt = 0;
  for (;a <= b; a++) {
      string s = to_string(a);
      if (s[0]==s[4] && s[1]==s[3]) cnt += 1;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
S = input()

nums = {}
for s in S:
    if not s in nums:
        nums[s] = 0
    nums[s] += 1
ans = 1
for n in nums.values():
    ans *= (n + 1)
    ans %= int(1e9 + 7)
ans = (ans + int(1e9 + 7 - 1)) % int(1e9 + 7)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll L,R;
    cin>>L>>R;
    int minn=1e9;
    if(R-L+1>=2019){
        puts("0");
        return 0;
    }
    for(long long  i=L;i<=R;i++){
        for(long long j=i+1;j<=R;j++){
            if(minn>(i%2019*j%2019)%2019){
                minn=(i%2019*j%2019)%2019;
            }
        }
    }
    printf("%d\n",minn);
    return 0;
}

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

    ans = 0
    for i in range(n):
        la = abs(pos[i] - 0)
        lb = abs(pos[i] - k)
        if la <= lb:
            ans += la*2
        else:
            ans += lb*2
    print(ans)
resolve()

Measured memory_bytes: 9172
#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 all(x) x.begin(),x.end()
typedef long long ll;
ll mod = 1000000007;
ll inf = 1e18;
int main(){

    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];

    vector<vector<int>> l(h,vector<int>(w,-1));
    int n=0;

    rep(j,w){
        rep(i,h){
            if(s[i][j]=='.'){
                n++;
            }else{
                rep(k,n) l[i-k-1][j]+=n;
                n=0;
            }
            if(i==h-1){
                rep(k,n) l[i-k][j]+=n;
                n=0;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                n++;
            }else{
                rep(k,n) l[i][j-k-1]+=n;
                n=0;
            }
            if(j==w-1){
                rep(k,n) l[i][j-k]+=n;
                n=0;
            }
        }
    }

    int ans=0;
    rep(i,h){
        rep(j,w){
            ans=max(ans,l[i][j]);
            // cout << l[i][j];
            // if(j!=w-1) cout << ' ';
            // else cout << endl;
        }
    }
    cout << ans << endl;

    return 0;
}   

Measured memory_bytes: 26464
#include<stdio.h>

int main(void)
{
	int t, h, m, s;
	scanf("%d", &t);
	h = t / 3600;
	m = t % 3600 / 60;
	s = t % 3600 % 60;
	printf("%d:%d:%d\n", h, m, s);

	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // 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 all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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 bitcount(int bits) {
    int ret = 0;
    while (bits > 0) {
        if (bits & 1) ret++;
        bits = bits >> 1;
    }
    return ret;
}

signed main() {
    string S; cin >> S;
    int ans = 0;
    rep(i, S.length()/2) {
        if (S[i] != S[S.length() - i -1]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256