akhauriyash/Code-Regression huggingface dataset:
# https://atcoder.jp/contests/abc137/tasks/abc137_d
# 全然わからん ソートしてgreedyに報酬高いやつから突っ込めるだけ突っ込んで見る←だめでした

# 解説AC
# 後ろから問題を見ていくと良いかも？
# 前から貪欲ではなぜ行けないのか？→残り日付が遠い中で最大の報酬 よりも 残り日付が近い中で最大の報酬を選んだほうが最適になる可能性があるから
# では後ろから貪欲は？→残り日付が近いなかで最大の報酬はその時点で最適な選択肢となることが確定できる。→OK
# だけどi日後までの候補に絞ってソートし直すと O(MNlogN)の計算量になる
# →priority queueで高速化
# つまり i 日後を考えるときに、それが可能となる候補をqueに追加 (最大logNがM回必要)
# その中で最大の報酬をもたらすものをpop (最大logNがM回必要)
# 日付のソートでNlogNかかる。
# この問題の計算量はO((M+N)logN)である


from heapq import heapify, heappop, heappush, heappushpop
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

    def __len__(self):
        return len(self.heap)


N, M = read_ints()
AB = read_tuple(N)
AB.sort()

q = PriorityQueue([])
l = 0  # ABのindex
ans = 0

for i in range(1, M + 1):
    for j in range(l, N):
        a, b = AB[j]
        if j == N - 1:
            l = N
        if a > i:  # i日以内に支払われない # こういう書き方はbugの原因になるから控えよう
            l = j
            break
        q.push(-b)  # pythonでは最小ヒープのため
    if q:  # qが空のときはしょうがないのでskip
        ans -= q.pop()

# # 前処理しておくと実装が楽という例
# from collections import defaultdict
# ilimb = defaultdict(lambda: [])
# for a, b in AB:
#     ilimb[a].append(b)

# for i in range(1, M + 1):
#     for b in ilimb[i]:
#         q.push(-b)  # pythonでは最小ヒープのため
#     if q:  # qが空のときはしょうがないのでskip
#         ans -= q.pop()

print(ans)


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

int main() {
  int64_t n, m = 10e16;
  vector<int64_t> c(5);
  cin >> n >> c[0] >> c[1] >> c[2] >> c[3] >> c[4];
  rep(i, 5) m = min(m, c[i]);
  cout << (n-1)/m+5 << endl;
  return 0;
}

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  int b, f, r, v;
  int a[12][10] = {0};
  cin >> n;
  rep(i, n) {
    cin >> b >> f >> r >> v;
    a[(b - 1) * 3 + (f - 1)][r - 1] += v;
  }
  rep(i, 12) {
    rep(j, 10) {
      cout <<  ' ' << a[i][j];
      if (j == 9) cout << endl;
    }
    if (i % 3 == 2 && i != 11) cout << "####################" << endl;
  }
  return 0;
}



Measured memory_bytes: 3056
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

long long int mod = 1000000007;

int main(){
  int n;
  scanf("%d",&n);
  long long int t[n],a[n],x[n];
  for(int i=0;i<n;i++) scanf("%lld",t+i);
  for(int i=0;i<n;i++) scanf("%lld",a+i);
  fill(x,x+n,mod);
  long long int r = 0;
  for(int i=0;i<n;i++){
    if(r<t[i]){
      r = t[i];
      x[i] = r;
    }
  }
  r = 0;
  for(int i=n-1;i>=0;i--){
    if(r<a[i]){
      r = a[i];
      if(x[i]==mod) x[i] = r;
      else if(r!=x[i]){
        printf("0\n");
        return 0;
      }
    }
  }
  if(t[n-1]!=a[0]){
    printf("0\n");
    return 0;
  }
  long long int ans = 1;
  long long int sd = t[n-1];
  for(int i=0;i<n-1;i++){
    if(sd!=max(t[i],a[i+1])){
      printf("0\n");
      return 0;
    }
  }
  for(int i=0;i<n;i++){
    if(x[i]==mod) x[i] = min(t[i],a[i]);
    else x[i] = 1;
    ans = (ans*x[i])%mod;
  }
  printf("%lld\n",ans);
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD=1e9+7;

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

  ll x,y;cin>>x>>y;
  ll a=min(x,y),b=max(x,y);
  if(a<=b-2) cout<<"Alice"<<endl;
  else cout<<"Brown"<<endl;
  return 0;
}


Measured memory_bytes: 256
#define Link "https://arc085.contest.atcoder.jp/tasks/arc085_c"

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define TASK "MUL"

#define pii pair<int,int>
#define i first
#define v second

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

const int oo = 1e9 + 1;
const int maxn = 1e3 + 1;
int n,S,T,a[maxn],cf[maxn],cnt,b[maxn],num[maxn];
vector <pii> e[maxn];
long long res;

void Enter()
{
    cin >> n;
    for (int i=1;i<=n;++i)
        cin >> a[i];
}

void Connect(int u, int v, int w)
{
    e[u].push_back(pii(++cnt,v));
    cf[cnt] = w;
    e[v].push_back(pii(++cnt,u));
}

void Init()
{
    S = 0;
    T = n + 1;
    cnt = 1;
    for (int i=1;i<=n;++i) {
        if (a[i] <= 0)
            Connect(S,i,-a[i]);
        else {
            Connect(i,T,a[i]);
            res += a[i];
        }
        for (int j=i+i;j<=n;j+=i)
            Connect(i,j,+oo);
    }
}

bool Can(int S, int T)
{
    queue <int> qu;
    fill(b,b+n+1+1,+oo);
    b[S] = 0;
    qu.push(S);
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        if (u == T)
            return 1;
        for (pii p : e[u]) {
            int i = p.i;
            int v = p.v;
            if (cf[i] > 0 && b[v] == +oo) {
                b[v] = b[u] + 1;
                qu.push(v);
            }
        }
    }
    return 0;
}

int Find(int u, int mn)
{
    if (u == T)
        return mn;
    num[u] = cnt;
    for (pii p : e[u]) {
        int i = p.i;
        int v = p.v;
        if (num[v] != cnt && cf[i] > 0 && b[v] == b[u] + 1)
            if (int x = Find(v,min(mn,cf[i]))) {
                cf[i] -= x;
                cf[i^1] += x;
                return x;
            }
    }
    return 0;
}

void Solve()
{
    while (Can(S,T))
        while (int x = (++cnt,Find(S,+oo)))
            res -= x;
    cout << res;
}

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

    //OpenFile();

    Enter();
    Init();
    Solve();
}


Measured memory_bytes: 256
#include <cstdio>

void countingSort(int n, int A[], int B[], int k) {
  int C[k + 1];
  for (int i = 0; i <= k; i++) C[i] = 0;

  for (int j = 0; j < n; j++) C[A[j]]++;

  for (int i = 1; i <= k; i++) C[i] += C[i - 1];

  for (int j = n - 1; j >= 0; j--) {
    B[C[A[j]] - 1] = A[j];
    C[A[j]]--;
  }
}

int main() {
  int n;
  scanf("%d", &n);
  int A[n];
  for (int i = 0; i < n; i++) scanf("%d", &A[i]);
  int B[n];
  countingSort(n, A, B, 10000);

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


Measured memory_bytes: 18256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
const double pi = 3.14159265358979;

int a, b;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << (a * b) << "\n";
	return 0;
}

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

using namespace std;

mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
typedef long double ld;

const int M = 998244353;

int add(int a, int b) {
  a += b;
  if (a >= M) {
    return a - M;
  }
  if (a < 0) {
    return a + M;
  }
  return a;
}

int mul(int a, int b) {
  return a * (ll) b % M;
}

int pw(int a, int b) {
  int r = 1;
  while (b) {
    if (b & 1) {
      r = mul(r, a);
    }
    a = mul(a, a);
    b /= 2;
  }
  return r;
}

int dv(int a, int b) {
  return mul(a, pw(b, M - 2));
}

const int N = (int) 2e5 + 7;
int fact[N], ifact[N];

int comb(int n, int k) {
  return mul(fact[n], mul(ifact[k], ifact[n - k]));
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  ifact[N - 1] = dv(1, fact[N - 1]);
  for (int i = N - 2; i >= 0; i--) {
    ifact[i] = mul(ifact[i + 1], i + 1);
  }
  int n, m, k, sol = 0;
  cin >> n >> m >> k;
  for (int x = 0; x <= k; x++) {
    int w = comb(n - 1, x);
    sol = add(sol, mul(w, pw(m - 1, n - 1 - x)));
  }
  sol = mul(sol, m);
  cout << sol << "\n";
  return 0;
}


Measured memory_bytes: 5212
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

p = [0] * 3
Max = 0
for i in range(3) :
    for j in range(n) :
        p[i] += abs(x[j] - y[j]) ** (i+1)
        if abs(x[j] - y[j]) > Max :
            Max = abs(x[j] - y[j])
            
    print('{:.5f}'.format(p[i] ** (1/(i+1))))
print('{:.5f}'.format(Max))
            


Measured memory_bytes: 5652
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	if(n == 23)printf("Christmas Eve Eve\n");
	else if(n == 24)printf("Christmas Eve\n");
	else if(n == 25)printf("Christmas\n");
	else printf("Christmas Eve Eve Eve\n");
	return 0;
}

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

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	cout << c << " " << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  ll h,w;
  cin >> h >> w;
  vec as(h*w+1);
  vec bs(h*w+1);
  ll ans=1;
  for(ll i=0;i<h;i++) {
    ll temp;
    cin >> temp;
    as[temp]++;
  }
  for(ll i=0;i<w;i++) {
    ll temp;
    cin >> temp;
    bs[temp]++;
  }
  for(ll i=h*w;i>0;i--) {
    
    if(as[i]>1||bs[i]>1) {
      cout << 0 << endl;
      return 0;
    }
    if(!(as[i]*bs[i])) {
      if(as[i]) {
        if(i!=h*w) {
          as[i]+=as[i+1];
          bs[i]+=bs[i+1];
        }
        ans=ans*bs[i]%mod;
      }
      else if(bs[i]) {
        if(i!=h*w) {
          as[i]+=as[i+1];
          bs[i]+=bs[i+1];
        }
        ans=ans*as[i]%mod;
      }
      else {
        if(i!=h*w) {
          as[i]+=as[i+1];
          bs[i]+=bs[i+1];
        }
        ans=ans*(as[i]*bs[i]%mod-(h*w-i)+mod)%mod;
      }
    }
    else {
      if(i!=h*w) {
        as[i]+=as[i+1];
        bs[i]+=bs[i+1];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
// #define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        int h, m, s, hh, mm, ss;
        int d[24 * 3600 + 100] = {};
        rep(i, 0, n){
            scanf("%d:%d:%d %d:%d:%d", &h, &m, &s, &hh, &mm, &ss);
            int st = h * 3600 + m * 60 + s;
            int ed = hh * 3600 + mm * 60 + ss;
            d[st]++; d[ed]--;
        }
        int MAX = 0;
        rep(i, 1, 24 * 3600 + 10){
            d[i] += d[i - 1];
            MAX = max(MAX, d[i]);
        }
        cout << MAX << endl;
    }
}

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

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

  if(D==25){
    cout << "Christmas" <<endl;
  }
  
  else if(D==24){
    cout << "Christmas Eve" <<endl;
  }

  else if(D==23){
    cout << "Christmas Eve Eve" << endl;
  }

  else {
    cout << "Christmas Eve Eve Eve" <<endl;
  }
}

  


Measured memory_bytes: 3632
import numpy

def main():
    a = int(input())
    a = str(a).zfill(4)
    
    A = int(a[0])
    B = int(a[1])
    C = int(a[2])
    D = int(a[3])
    
    op1 = ""
    op2 = ""
    op3 = ""
    
    for i in range(2):
        for j in range(2):
            for k in range(2):
                if A + (-1) ** (i+1) * B + (-1) ** (j+1) * C + (-1) ** (k+1) * D == 7:
                    op1 = "-" if i == 0 else "+"
                    op2 = "-" if j == 0 else "+"
                    op3 = "-" if k == 0 else "+"
                    print(str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7")
                    exit()
    
main()

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  vector<ll> a(3);
  rep(i, 3)
    in(a[i]);
  sort(all(a));
  out(a[2] - a[0]);
  memi;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
ll a[205],k[205];

ll solve(ll va,ll vk){
	if(va<vk)return 0;
	if(va%vk==0LL){
		return va/vk;
	}else{
		if(va<vk*vk){
			ll tmp=va/vk;
			ll tmp2=vk*tmp;
			ll tmp3=(va-tmp2)/(tmp+1LL);
			return solve(min(va*(vk-1LL)/vk,va-tmp3*(tmp+1LL)),vk);
		}
		return solve(va*(vk-1LL)/vk,vk);
	}
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%lld%lld",&a[i],&k[i]);
	}
	ll ans=0;
	for(int i=0;i<n;i++){
		if(a[i]<k[i]){
		}else{
			if(a[i]%k[i]==0){
				ans^=a[i]/k[i];
			}else{
				ans^=solve(a[i],k[i]);
			}
		}
	}
	printf("%s\n",ans!=0LL?"Takahashi":"Aoki");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int e;

    while(true){
        cin >> e;
        if(e == 0) break;

        int m = 10000000;
        int M; //Mはx,y,zの和（全パターン)
        for(int z = 0; z*z*z <= e; z++){
            for(int y = 0; (e - (y * y) - (z * z * z)) >= 0 ; y++){
                M = e - (y * y) - (z * z * z) + y + z;
                if(M < m) m = M;
                 //cout << '@' << e - pow(y, 2) - pow(z, 3) << " " << y << " " << z << endl;
            }
        } 
        cout << m << endl;
    }
}



Measured memory_bytes: 3076
n, m= map(int, input().split())
got=0
sell={}
buy=0
for i in range(n):
  a,b=map(int,input().split())
  if a not in sell:
    sell[a]=0
  sell[a]+=b
sell=sorted(sell.items())
if m<=sell[0][1]:
  print(m*(sell[0][0]))
  exit()
for lis in sell:
  got+=lis[1]
  if got>m:
    buy+=(m-got+lis[1])*lis[0]
    print(buy)
    exit()
  else:
    buy+=(lis[0])*(lis[1])

Measured memory_bytes: 27868
#include <bits/stdc++.h>
#define MAXN 300000
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define int long long
using namespace std;

int n, m;
pii arr[MAXN+5];
vector <int> pos[MAXN+5];
int ans[MAXN+5];

class BIT{
public:
	int arr[MAXN+5];
	inline int lowbit(int a) {
		return a&-a;
	}
	void mdy(int now, int k) {
		if (now > n) return;
		arr[now] += k;
		mdy(now+lowbit(now), k);
	}
	int qry(int now) {
		return now?arr[now]+qry(now-lowbit(now)):0;
	}
} bit;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> m >> n;
	for (int i = 1; i <= n; i++) 
		pos[0].pb(i);
	for (int i = 0; i < m; i++) {
		cin >> arr[i].ff >> arr[i].ss;
		bit.mdy(arr[i].ff, 1);
		bit.mdy(arr[i].ss+1, -1);
	}
	sort(arr, arr+m);
	int now = 0, nowR = 0;
	for (int i = 0; i < m; i++) {
		while (now < arr[i].ff) {
			while (nowR < m && arr[nowR].ff <= now)
				bit.mdy(arr[nowR++].ss+1, 1);
			for (int j = 0; j < pos[now].size(); j++) {
				if (now+pos[now][j] > n) continue;
				pos[now+pos[now][j]].pb(pos[now][j]);
				ans[pos[now][j]] += bit.qry(now+pos[now][j])-bit.qry(now);
			}
			pos[now++].clear();
		}
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 30452
#include<bits/stdc++.h>
#define ll                  long long
#define dl                 double
#define pb                push_back
#define F                  first
#define S                  second
#define endl              "\n"
#define rep(i,a,b)       for(i=a;i<b;i++)
#define all(v)             v.begin(),v.end()
#define allr(v)            v.rbegin(),v.rend()
#define mod              1000000007LL
#define CIN(V,s,n)      for(int i=s;i<n;i++){cin >> V[i];}
#define COUT(V,s,n)   {for(int i=s;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
#define fast               ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define CLEAR(V);      for(ll i=0;i<V.size();i++) V[i] = 0;
#define N                  150
#define tmod             998244353LL
using namespace std;

bool sBs(const pair<int,int> &a,const pair<int,int> &b)
{   return (a.second < b.second);   }

ll SUMD(ll n);
ll BS(vector<pair< ll ,ll > > &PS,ll s,ll e,ll ser);
ll MI(ll a, ll m);
//bool P[N+1];
void Sieve(int n=N);
ll Powb(ll b,ll n,ll m);

int main()
{
fast;
ll q=1,t;
//cin >> q; t = q;
while(q--)
{
    ll i,j,n,m,k,l,r,a,b,c=0,d=0,e,g=0,p,u,v,w,x,y,flag=1;
    //n=m=k=i=j=l=r=a=b=c=d=u=v=w=p=x=y=0;
    cin >> n >> m >> x;
    vector<vector<ll> > A(n,vector<ll>(m));
    vector<ll> C(n);
    for(i=0;i<n;i++)
    {
        cin >> C[i];
        for(j=0;j<m;j++)
            cin >> A[i][j];
    }
    ll ans = mod;
    for(i=0;i<(1LL<<n);i++)
    {
        vector<ll> T(m); flag = 1; ll tans = 0;
        for(j=0;j<n;j++)
        {
            if((1LL<<j)&i)
            {
                for(k=0;k<m;k++)
                {
                    T[k] += A[j][k];
                }
                tans += C[j];
            }
        }
        for(j=0;j<m;j++)
        {
            if(T[j]<x){flag=0;break;}
        }
        if(flag and tans<ans) ans = tans;
    }
    cout << (ans==mod? -1 : ans);


}
    return 0;
}

//*****************************************************************************************************************************************

ll Powb(ll b,ll n,ll m)
{
    if(n==0) return 1LL;
    if(n==1) return b;
    ll temp = Powb(b,n/2,m);
    if(n%2==0){return (temp*temp)%m;}
    else{return (b*((temp*temp)%m))%m;}
}

ll SUMD(ll n)
{   ll sum=0;
    while(n>0){sum += n%10;n = n/10;}
    return sum;

}
ll BS(vector<pair<ll,ll> > &PS,ll s,ll e,ll ser)
{
    if(s>e)
        return s;
    ll mid = (s+e)/2;
    if(PS[mid].F==ser)
    {
        return mid;
    }
    else if(PS[mid].F > ser)
    {
        return BS(PS,s,mid-1,ser);
    }
    else
        return BS(PS,mid+1,e,ser);
}
ll MI(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}
/*
void Sieve(int n)
{
    memset(P,true,sizeof(P));
    P[0] = false;
    P[1]= false;
    for(ll i=2;i*i<=n;i++)
    {
        if(P[i])
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                P[j]=false;
            }
        }
    }

}

*/


Measured memory_bytes: 3636
s = input().rstrip() + 'X'

r_cnt = l_cnt = 0
is_r = True
begin_l = None
ans = [0] * (len(s)-1)
for i in range(len(s)):
    if is_r and s[i] == 'R':
#         print(f'{i}: R')
        r_cnt += 1
    elif not is_r and s[i] == 'L':
#         print(f'{i}: L')
        l_cnt += 1
    elif s[i] == 'L':
#         print(f'{i}: R>L')
        is_r = False
        l_cnt = 1
        begin_l = i
    else:
#         print(f'{i}: L>?')
        is_r = True
#         print(l_cnt, r_cnt)
        tot = l_cnt + r_cnt
        small = tot//2
        large = tot - small
        if r_cnt%2:
            ans[begin_l-1] = large 
            ans[begin_l] = small
        else:
            ans[begin_l-1] = small
            ans[begin_l] = large
        r_cnt = 1
        l_cnt = 0

print(*ans)

Measured memory_bytes: 78664
# https://atcoder.jp/contests/abc162/tasks/abc162_c


K = gets.to_i

ans = 0

(K).times do |a|
  (K).times do |b|
    (K).times do |c|
      ans += (a+1).gcd(b+1).gcd(c+1)
    end
  end
end

puts ans


Measured memory_bytes: 14380
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = in.nextInt() - 1;
		for (int i = 0; i < n; i++)
			b[i] = in.nextInt();
		for (int i = 0; i < n-1; i++)
			c[i] = in.nextInt();
		System.out.println(solve(n, a, b, c));
		in.close();
	}

	private static int solve(int n, int[] a, int[] b, int[] c) {
		int r = 0;
		for (int i = 0; i < n; i++) {
			r += b[a[i]];
			if (i < n - 1)
				if (a[i] + 1 == a[i + 1])
					r += c[a[i]];
		}
		return r;
	}
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int h, w; cin >> h >> w;
    if(h == 1 or w == 1) cout << 1;
    else if(h*w % 2 == 0) cout << h*w / 2;
    else cout << (h*w + 1) / 2;

    
    
    
    return 0;
}

Measured memory_bytes: 3528
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int positions[2];
vector<int> moves[2]; // x_moves, y_moves

int dp[4000][16000][2];

bool move(int now, int position, bool if_y_looking){
    if(now == moves[if_y_looking].size()){
        return position == positions[if_y_looking];
    }else if(dp[now][position + 8000][if_y_looking] != -1){
        return dp[now][position + 8000][if_y_looking];
    }else{
        return dp[now][position + 8000][if_y_looking] = move(now + 1, position + moves[if_y_looking][now], if_y_looking) || move(now + 1, position - moves[if_y_looking][now], if_y_looking);
    }
}

int main(){
    string S;
    cin >> S >> positions[0] >> positions[1];
    int x_start = 0;
    bool if_x_starting = true;
    bool if_y_move = false;
    int F_serial = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'F' && if_x_starting){
            x_start++;
        }else if(S[i] == 'F'){
            F_serial++;
        }else if(F_serial){
            if_x_starting = false;
            moves[if_y_move].push_back(F_serial);
            if_y_move ^= 1;
            F_serial = 0;
        }else{
            if_x_starting = false;
            if_y_move ^= 1;
        }
    }
    if(F_serial){
        moves[if_y_move].push_back(F_serial);
    }
    for(int i = 0; i < 4000; i++){
        for(int j = 0; j < 16000; j++){
            dp[i][j][0] = -1;
            dp[i][j][1] = -1;
        }
    }
    if(move(0, x_start, false) && move(0, 0, true)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 500480
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 086 A "Product"
 *   https://abc086.contest.atcoder.jp/tasks/abc086_a/
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int a = in.nextInt();
		int b = in.nextInt();

		if (a * b % 2 == 0) {
			out.println("Even");
		} else {
			out.println("Odd");
		}

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

		public int[] nextIntArray(int n) {
			int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextInt();
			}
			return ret;
		}

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, String split) {
			String[][] ret = new String[h][];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


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

int main(){
    int N;
    priority_queue<int>Q;
    cin >> N;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        Q.push(tmp);
    }
    int dif = 0;
    for(int i=0; i<N; i++){
        if(i%2==0){
            dif+=Q.top();
        }
        else{
            dif-=Q.top();
        }
        Q.pop();
    }
    cout << dif;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int i,j,k,h;
    int n,sum=0;
    int a[100002];
    scanf("%d %d",&h,&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) sum=sum+a[i];
    if(sum>=h) printf("Yes\n");
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <map>

using namespace std;

map<string,int>m;

int main(){
    m["SUN"] = 7;
    m["MON"] = 6;
    m["TUE"] = 5;
    m["WED"] = 4;
    m["THU"] = 3;
    m["FRI"] = 2;
    m["SAT"] = 1;

    string s;
    cin >> s;
    cout << m[s] << endl;

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[tuple(map(int,input().split())) for i in range(m)]
l=set(l)
#[s,c]

ans=['1']+['0']*(n-1)
for s,c in l:
    #1桁の数の時は例外
    if s==1 and c==0 and n>1:
        print(-1)
        exit()
    #既に変更済みの場合
    if s==1 and ans[0]!='1':
        print(-1)
        exit()
    if s!=1 and ans[s-1]!='0':
        print(-1)
        exit()

    ans[s-1]=str(c)
if m==0 and n==1:
    print(0)
    exit()
print(*ans,sep='')

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include<vector>
using namespace std;
int main()
{
    vector<int >vi;
    int n,x,y;
    while (cin>>n)
    {
        while (n--)
        {
            cin >> x;
            switch (x)
            {
            case 0:
                cin >> y;
                vi.push_back(y);
                break;
            case 1:
                cin >> y;
                cout << vi[y] << endl;
                break;
            case 2:
                vi.pop_back();
                break;
            default:
                break;
            }

        }
    }
    return 0;
}



Measured memory_bytes: 3880
import itertools
N = int(input())
zahyo =[list(map(int,input().split())) for _ in range(N)]
N_list = [i for i in range(N)]
P = itertools.permutations(N_list,N)
P = list(P)
sm = 0
for p in P:
    for i,j in zip(p,p[1:]):
        xi,yi = zahyo[i]
        xj,yj = zahyo[j]
        sm += (((xi-xj)**2+(yi-yj)**2)**0.5)
print(sm/len(P))

Measured memory_bytes: 8052
#include <iostream>

using namespace std;

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

    if((b + W) < a){
        cout << abs((b + W) - a) << endl;
    }else if((a + W) < b){
        cout << abs((b - (a + W))) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int a;
  cin >> a >> a >> a >> a;
  if (a == 1) {
    cout << 1;
  } else {
    cout << 0;
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3632
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,a,b = inpl()
x = inpl()
res = 0
for i in range(n-1):
    dist = x[i+1] - x[i]
    res += min(dist*a, b)
print(res)

Measured memory_bytes: 21196
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define cpresent(container, element) (find(all(container),element) != container.end())
#define all(c) c.begin(), c.end()
#define mod 1000000007 
#define MOD 998244353
#define PI 3.141592654
typedef long long ll;
using namespace std;
int main(){
  ss
  ll n;
  cin>>n;
  vector<int> v(n);
  int prev=0,res=0,ans=0;
  for(int i=0;i<n;i++){
  	cin>>v[i];
  	if(i>0){
  		if(v[i]<=prev){
  			ans++;
  			res=max(ans,res);
  			prev=v[i];
		  }
		  else{
		  	ans=0;
		  	prev=v[i];
		  }
		  
	  }
	  else prev=v[0];
  }
  cout<<res;
return 0; 

}

Measured memory_bytes: 640
N = int(input())
S = input()
L,R,x = 0,0,0
for i in range(N):
    if x == 0:
        if S[i]==")":
            L += 1
        else:
            R += 1
            x += 1
    else:
        if S[i]==")":
            R -= 1
            x -= 1
        else:
            R += 1
            x += 1
print("("*L + S + ")"*R)

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

int main() {
  //----------変数置いたり代入したり----------
  
  int H, W, K; // それぞれの変数は問で与えられた通り
  cin >> H >> W >> K;
  
  vector<vector<char>> clist(H, vector<char>(W)); 
  // H×Wの配列に "." or "#"を代入
  for(int i=0; i<H; i++) {
    for(int j=0; j<W; j++) {
      char c;
      cin >> c;
      clist.at(i).at(j) = c;
    }
  }
  
  //----------ここまでは問題なしと思われる----------

  //----------処理していく(ここから不安)----------
  
  int ans = 0; 
  // ansは答えとして出力したい値を表す変数, 
  // 条件に合致する行列の選び方をしたときに+1していく
 
  //----------ビット全探索で行列の選び方を決定していく----------
  for (int tmp1 = 0; tmp1 < (1 << H); tmp1++) {
    bitset<6> s(tmp1);
    for (int tmp2 = 0; tmp2 < (1 << W); tmp2++) {
      bitset<6> t(tmp2);

      int jud=0; // "#"の個数を数えるための変数, 見つけ次第+1していく
      for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
          
          //----------最も怪しいと思われる部分----------
          //自分の考えでは、clistの要素のうち、選ばれていない行と列に属し、
          //かつ、"#"であればカウントする
          if(s.test(i) && t.test(j) && clist.at(i).at(j)=='#') {
            jud++;
          }
          //------------------------------------------
          
        }
      }
      
      //judによりカウントされた"#"の数がKであれば、
      //その行列の選び方がOKということになるため、ansに+1する
      if (jud==K) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int main() {
  int n; cin >> n;
  ll a[n], d[60], da[60];
  for(int i=0; i<n; i++) cin >> a[i];
  for(int i=0; i<60; i++) d[i] = da[i] = 0;
  for(int i=0; i<n; i++){
    for(int j=0; j<60; j++) {
      if (a[i] & (1LL<<j)) d[j]++;
      else da[j]++;
    }
  }
  //cout << d[0] << " " << da[0] << endl;
  ll an = 0;
  for(int i=0; i<n; i++){
    //for(ll x:d) cout << x << " "; cout << endl;
    for(ll j=0; j<60; j++) {
      if (a[i] & (1LL<<j)) d[j]--;
      else da[j]--;
    }
    for(ll j=0; j<60; j++) {
      if (a[i] & (1LL<<j)) an += da[j] * ((1LL << j)%mod);
      else an += d[j] * ((1LL << j)%mod);
      an %= mod;
    }
  }
  cout << an%mod << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int AMAX = 100010;

class UnionFind{
public:
    vector<int> par;
    UnionFind(int n) {
	par.resize(n, -1);
    }
    int Find(int n) {
	return (par[n] < 0 ? n : par[n] = Find(par[n]));
    }
    int Size(int n) {
	n = Find(n);
	return -par[n];
    }
    bool Union(int a, int b) {
	a = Find(a);
	b = Find(b);
	if (a == b) return false;
	if (-par[a] > -par[b]) swap(a, b);
	par[b] = a;
	return true;
    }
    bool Same(int a, int b) {
	return Find(a) == Find(b);
    }
};

int main() {
    vector<bool> isPrime(AMAX, true);
    vector<int> Prime;
    for (int i = 2; i < AMAX; i++) {
	if (isPrime[i]) {
	    Prime.push_back(i);
	    for (int j = 2 * i; j < AMAX; j += i) {
		isPrime[j] = false;
	    }
	}
    }
    
    
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(AMAX, 0);
    
    for (int i = 0; i < N; i++) {
	cin >> A[i];
	B[i] = A[i];
	C[A[i]]++;
    }
    sort(A.begin(), A.end());
    UnionFind uf(AMAX);
    
    for (int a : Prime) {
	for (int i = 2 * a; i < AMAX; i += a) {
	    if (C[i]) {
		uf.Union(a, i);
	    }
	}
    }
    bool check = true;
    for (int i = 0; i < N; i++) {
	check &= (uf.Same(A[i], B[i]));
    }
    cout << check << endl;
    return 0;
}



Measured memory_bytes: 4708
#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cerr << i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n;
  std::cin>>n;

  std::cout<<0<<std::endl;

  std::string temp,leftst;

  std::cin>>leftst;

  if(leftst=="Vacant"){
    return 0;
  }

  ll left=0,right=n;

  while(1){
    ll mid=left+(right-left)/2;

    std::cout<<mid<<std::endl;

    std::cin>>temp;
    if(temp=="Vacant"){
      return 0;
    }

    if((temp==leftst)^((mid-left)%2)){
      left=mid;
      leftst=temp;
    }else{
      right=mid;
    }
  }

  return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define mod 1000000007 
#define check exit(0)
#define nl cout<<endl;
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace __gnu_pbds;
using namespace std;

int main()
{
    jaldi
    ll n;
    cin>>n;
    ll ans=0;
    ans+=(n/500)*1000 + ((n%500)/5)*5;
    cout<<ans;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<string>S(n);
    for(int i=0;i<n;i++){
        cin >> S[i];
        sort(S[i].begin(),S[i].end());
    }
    vector<vector<int>>c(26,vector<int>(n,0));
    for(int i=0;i<n;i++){
        for(int j=0;j<S[i].size();j++){
            c[S[i][j]-'a'][i]++;
        }
    }
    for(int i=0;i<26;i++){
        sort(c[i].begin(),c[i].end());
    }
    string ans;
    for(int i=0;i<26;i++){
        for(int j=0;j<c[i][0];j++){
            ans+='a'+i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3612
#include<stdio.h>
int main(void)
{
	int sum,i,n;
	sum=0;
	for(i=0;i<4;i++){
		scanf("%d",&n);
		sum+=n;
	}
	printf("%d\n",sum/60);
	printf("%d\n",sum%60);
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,d;
  ld tmp;
  ll x,y;
  string s;
  cin >> n >> d;
  rep(i,n){
    cin >> x >> y;
    tmp = sqrt((ld)x*x+y*y);
    if(tmp <= d) result++;
  }
  cout << result << endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  string c;
  int g = 0;
  int w = 0;
  int y = 0;
  int p = 0;
  
  for(int i=0;i<N;i++){
    cin >> c;
    if(c == "G"){
      g = 1;
    }else if(c == "W"){
      w = 1;
    }else if(c == "Y"){
      y = 1;
    }else if(c == "P"){
      p = 1;
    }
  }
  int total = g + w + y + p;
  if (total == 3){
    cout << "Three" << endl;
  }else if(total == 4){
    cout << "Four" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int r; cin>>r;
	double pi=acos(-1);
	cout<<(2*pi*r);
	
	return 0;
}

Measured memory_bytes: 3788
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    private static FastScanner sc = new FastScanner();

    public static void main(String[] args) {
    	int n = sc.nextInt();
    	int sum = n * (n + 1) / 2;
    	if(n%2 == 0) {
    		System.out.println(n * (n-2) / 2);
    		for(int i=1; i<=n; i++) {
    			for(int j=i+1; j<=n; j++) {
    				if(i+j == n+1) continue;
    				System.out.println(i + " " + j);
    			}
    		}
    	} else {
    		System.out.println((n-1) + (n-1) * (n-3) / 2);
    		for(int i=1; i<=n-1; i++) {
    			System.out.println(i + " " + n);
    		}
    		for(int i=1; i<=n-1; i++) {
    			for(int j=i+1; j<=n-1; j++) {
    				if(i+j == n) continue;
    				System.out.println(i + " " + j);
    			}
    		}
    	}
    }


    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if(ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch(IOException e) {
                    e.printStackTrace();
                }
                if(buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
        public boolean hasNext() { skipUnprintable(); return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int nextInt(){
            return Integer.parseInt(next());
        }
        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

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

    string s;
    cin >> s;
    int cnt = 0;
    rep(i, (int)s.size() - 1) {
        if (s[i + 1] != s[i]) {
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

// ax + by = gcd(a, b) となるような (x, y) を求める
// 多くの場合 a と b は互いに素として ax + by = 1 となる (x, y) を求める
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    // 再帰的に解く (x, y を入れ替えておく)
    long long d = extGCD(b, a % b, y, x); 
    y -= a / b * x;
    return d;
}

// 素因数分解
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

//約数列挙
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

map<ll,ll> ma;

int main () {

    ll n;cin>>n;

    if (n%2==1) {
        cout<<0<<endl;
        return 0;
    }

    ll div = 10;
    ll ans=0;
    while (div<=n) {
        ans+=n/div;
        div*=5;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
long long dp[N][100005];
int w[N], val[N];
long long knapsack(int i, int W) {
	if ( i < 0 || W == 0) {
		return 0;
	}
	if (dp[i][W] != 0) {
		return dp[i][W];
	}
	if (w[i] > W) {
		return dp[i][W] = knapsack(i - 1, W);
	}
	long long x = val[i] + knapsack(i - 1, W -w[i]);
	long long  y = knapsack(i - 1, W);
	return dp[i][W] = max(x, y);
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n, W;
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> val[i];
	}
	cout << knapsack(n - 1, W);
	return 0;
}


Measured memory_bytes: 80128