akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i< (n);i++)
using namespace std;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep(ri,2){
        {//solve
            int cnt = 0;
            rep(i,n){
                if(s[i] == 'R') cnt++;
                else{
                    ans[i] += cnt/2;
                    ans[i-1] += (cnt+1)/2;
                    cnt = 0;
                }

            }
        }
        reverse(ans.begin(),ans.end());
        reverse(s.begin(),s.end());
        rep(i,n){
            if(s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i,n){
        printf("%d%c", ans[i], i == n-1? '\n': ' ');
    }
    return 0;
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a < b){
            if(b < c){
                System.out.printf("%d %d %d\n", a,b,c);
            }else if(a < c){
                System.out.printf("%d %d %d\n", a,c,b);
            }else{
                System.out.printf("%d %d %d\n", c,a,b);
            }
        }else{
            if(b > c){
                System.out.printf("%d %d %d\n", c,b,a);
            }else if(a < c){
                System.out.printf("%d %d %d\n", b,a,c);
            }else{
                System.out.printf("%d %d %d\n", b,c,a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26208
l = []
c = list([0] * 100)
while True:
    try:
        c[int(raw_input()) - 1] += 1
    except:
        break
m = max(c)
for i in xrange(c.count(m)):
    j = c.index(m)
    print j + 1
    c[j] = 0

Measured memory_bytes: 4224
S=input()
if S[1]=='R':
    if S[0]=='R' and S[2]=='R':
        print(3)
    elif S[0]=='S' and S[2]=='S':
        print(1)
    else:
        print(2)
    
else:
    if S[0]=='S' and S[2]=='S':
        print(0)
    else:
        print(1)

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5;
int ans, k, s;
int cnt[N];

int main() {
    cin >> k >> s;
    for (int i = 0; i <= k; ++i) {
        for (int j = 0; j <= k; ++j) {
            ++cnt[i + j];
        }
    }
    for (int i = 0; i <= k; ++i) {
        int d = s - i;
        if (d >= 0) {
            ans += cnt[d];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
        int flag = 0;
        string s;
        cin >> s;
        if (s[0] == s[1])
                flag = 1;
        if (s[1] == s[2])
                flag = 1;
        if (s[2] == s[3])
                flag = 1;
        if (flag == 1)
                cout << "Bad" << endl;
        else
                cout << "Good" << endl;
        return 0;
}

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

int main(){
	long long int n,a[1200000],ans = 1;
  cin >> n;
  for(int i=0; i<n; i++){
  	cin >> a[i];
    if(a[i] == 0) {
      cout << "0";
      return 0;
    }
  }
  for(int i=0; i<n; i++){
  	ans *= a[i];
      if(ans > 1000000000000000000){
      cout << "-1";
        return 0;
      }
  }
  if(ans == 0 || ans < 0) {
  	cout << "-1";
    return 0;
  }
  cout << ans;
}


Measured memory_bytes: 4420
#include<stdio.h>
#include<stdlib.h>
typedef long long LL;
const LL LINF=0x7fffffffffffffff;
#define rep(i,N) for(int i=0;i<(LL)N;i++)
#define array(N,t) (t*)calloc(N,sizeof(t))
int compare(const int*a,const int*b){if(*a<*b)return -1;else if(*a==*b)return 0;else return 1;}
inline LL IN(void)
{
  LL x=0;int f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
signed main(void)
{
  int N,m=0,p=0,z=0,NG,OK,BASE,minus,temp;
  LL K,L=-LINF/2,M,R=LINF/2,count;
  N=IN(),K=IN();
  int *A=array(N,int);
  rep(i,N){A[i]=IN();if(A[i]<0)m++;else if(A[i]>0)p++;else z++;}
  qsort(A,N,sizeof(int),(int(*)(const void*,const void*))compare);
  if(K>1ll*m*p&&K<1ll*m*p+1ll*z*(N-1)/2)return puts("0"),0;else temp=0;
  if(K<=1ll*m*p)R=1ll;else L=-1ll;
  while(R-L>1)
  {
    M=(L+R)/2,count=0;
    for(int i=temp;i<N;i++)
    {
      NG=i,OK=N,minus=A[i]<0;
      while(OK-NG>1)
      {
        BASE=(NG+OK)/2;
        if(1ll*A[i]*A[BASE]<=M){if(minus)OK=BASE;else NG=BASE;}
        else{if(minus)NG=BASE;else OK=BASE;}
      }
      count+=(minus)?N-OK:NG-i;
      if(!minus&&i==m*(m-1)-1){count+=m*(m-1);temp=N*(N-1)-p*(p-1)-1;}
    }
    if(count<K)L=M;else R=M;
  }
  return printf("%lld\n",R),0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int x;
  cin >> x;
  int ans = 0;
  for(int i=0; i<50; i++){
    int tmp = i;
    for(int j=0; j<20; j++){
      tmp *= i;
      if(tmp<=x) ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v))-v.begin())

#define endl '\n'

const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

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

lli gcd(lli a , lli b) {
    if(b == 0) return a;
    a %= b;
    return gcd(b,a);
}

void solve() {
    string s;
    cin >> s;
    lli idx, n = static_cast<lli>(s.length());
    lli left[n], right[n], ans[n];

    memset(ans, 0, sizeof(ans));

    idx = n - 1;

    for (auto i = n - 1; i >= 0; --i) {
        if (s[i] == 'L') {
            idx = i;
        }
        left[i] = idx;
    }

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            idx = i;
        }
        right[i] = idx;
    }

    for (int i = 0; i < n; ++i) {
        if (s[i] == 'R') {
            lli diff = left[i] - i;

            if (diff & 1) {
                ans[left[i] - 1]++;
            } else {
                ans[left[i]]++;
            }
        } else {
            lli diff = i - right[i];

            if (diff & 1) {
                ans[right[i] + 1]++;
            } else {
                ans[right[i]]++;
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << " ";
    }
}

int main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    lli t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3024
#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(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    /**
     * MMである条件
     * 00ではない
     * 13未満であること
     * */
    string s;
    cin >> s;
    int si = stoi(s);

    int mi, li;
    mi = si / 100;
    li = si % 100;

    bool flag[2] = {false};
    if (mi > 0 && mi < 13) flag[0] = true;
    if (li > 0 && li < 13) flag[1] = true; 

    if (flag[0] && !flag[1]) cout << "MMYY" << endl;
    else if (flag[1] && !flag[0]) cout << "YYMM" << endl;
    else if (flag[0] && flag[1]) cout << "AMBIGUOUS" << endl;
    else cout << "NA" << endl;
    return 0;
}

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

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<int> xs;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		xs.push_back(x);
	}

	int result = 900000000;
	for (int i = 0; i < N - K + 1; ++i) {
		auto x1 = xs[i];
		auto x2 = xs[i + K - 1];
		result = min(result, min(abs(x1) + abs(x2 - x1), abs(x2) + abs(x1 - x2)));
	}
	cout << result << endl;
	return 0;
}

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

int main(){
  string s;
  cin >> s;
  int N = s.size();
  int count_0 = 0;
  int count_1 = 0;

  for (int i=0;i<N;i++){
    if (i%2 == 0){
      if (s[i] != '0'){
        count_0 += 1;
      }
    }
    else {
      if (s[i] != '1'){
        count_0 += 1;
      }
    }
  }

  for (int i=0;i<N;i++){
    if (i%2 == 0){
      if (s[i] != '1'){
        count_1 += 1;
      }
    }
    else {
      if (s[i] != '0'){
        count_1 += 1;
      }
    }
  }

  cout << min(count_0,count_1) << endl;

  return 0;
}


Measured memory_bytes: 512
//B - Varied: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    map<char, int> show;
    bool ans = true;
    cin >> s;
    for(auto x : s) {
        if(show[x]) ans = false;
        else show[x]++;
    }
    if(ans) cout << "yes\n";
    else cout << "no\n";

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cstring>
#include<functional>
#include<bits/stdc++.h>
#include<map>
#include<utility>

#define vec2c vector<vector<char>>
#define vec2i vector<vector<int>>
#define vecc vector<char>
#define vecs vector<string>
#define veci vector<int>
#define vecd vector<double>
#define vecl vector<long>
#define vecll vector<long long>
#define rep(i, n) for(int i=0; i < (int)(n); i++)
#define rrep(i, n) for(int i=(int)(n); i>=0;i--)
#define rep1e(i, n) for(int i=1; i <= (int)(n); i++)
#define rep1ne(i, n) for(int i=1; i < (int)(n); i++)

#define MAX 100010

using namespace std;

unsigned digit(unsigned num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  string S;
  cin >> S;
  string ans = "";
  if (S == "Sunny") ans = "Cloudy";
  else if (S == "Cloudy") ans = "Rainy";
  else ans = "Sunny";

	cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll MOD = 1000000007;
const int MAX = 100000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }


int main(){
    ll N,K; cin >> N >> K;
    int cnt=0;
    ll a=K;
    while(N>=a){
        cnt++;
        a*=K;
    }
    cout << cnt+1 << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
minV = 10000
ans = 0

for i in range(2, len(s)):
    temp = int(s[i-2] + s[i-1] + s[i])
    if abs(temp - 753) < minV:
        minV = abs(temp - 753)
#        ans = abs(temp

print(minV)


Measured memory_bytes: 2940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


//ABC125_b
int main() {
	int n;
	int v[100];
	int c[100];

	cin >> n;
	rep(i, n) {
		cin >> v[i];
	}
	rep(i, n) {
		cin >> c[i];
	}

	int res = 0;
	rep(i, n) {
		if (v[i]-c[i]>0) res += v[i]-c[i];
	}
	cout << res << endl;
}

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

int main(){
  long int A,B,C,D,tmp,lcm,r;
  cin >>A >>B >>C >>D;
  lcm = C*D;
  if(C<D) {
    tmp = C;
    C = D;
    D = tmp;
  }

  long int x,y;
  x = B/C - (A-1)/C;
  y = B/D - (A-1)/D;

  r = C%D;
  while(r!=0){
    C = D;
    D = r;
    r = C%D;
  }
  lcm /= D;

  long int ans = x + y - (B/lcm - (A-1)/lcm);
  ans = (B-A+1) - ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	int N;
	cin >> N;
	vector<int> a(N);
	rep(i, N) cin >> a.at(i);
	auto itr = find(a.begin(), a.end(), 1);
	if(itr == a.end())
	{
		cout << -1 << endl;
		return 0;
	}
	
	int count=1;
	rep(i, N) if(a.at(i) == count) count++;
	cout << N - count + 1 << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int H,W;
    int a[600][600];
    map<int,pair<int,int>> stap_cell;
    int R[300000];int r=0;
    cin >> H >> W;
    REP(i,H){REP(j,W){cin >> a[i][j];}}
    int e=0;
    REP(i,H){
        if(i%2==0){
            REP(j,W){
                stap_cell[e]=make_pair(i,j);
                e++;
            }
        }else{
            RREP(j,W){
                stap_cell[e]=make_pair(i,j);
                e++;
            }
        }
    }
    REP(i,H*W){
        pair<int,int> q=stap_cell[i];
        if(a[q.first][q.second]%2==1){
            R[r]=i;r++;
        }
    }
    
    
    vector<int> sx,sy,gx,gy;
    
    REP(i,r/2){
        int A=R[2*i],B=R[2*i+1];
        for(int j=A;j<B;j++){
            sx.push_back(stap_cell[j].first);
            sy.push_back(stap_cell[j].second);
            gx.push_back(stap_cell[j+1].first);
            gy.push_back(stap_cell[j+1].second);
        }
    }
    
    
    
    
    cout << gx.size() << endl;
    REP(i,gx.size()){
        cout << sx[i]+1 << " " << sy[i]+1 << " ";
        cout << gx[i]+1 << " " << gy[i]+1 << endl;
    }
    
    return 0;
}   

Measured memory_bytes: 26840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define MOD 1000000007
//#define MOD 998244353
const int INF = 1145141919810893364;
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


signed main(void){
    int N,a;
    vector<int> A;
    cin >> N;
    REP(i,N+1){
        cin >> a;
        A.push_back(a);
    }
    
    vector<int> B(N+1,0);
    bool illegal = false;
    
    if(N==0){
        if(A[0]==1){
            cout << 1 << endl;
        }else{
            cout << -1 << endl;
        }
        return 0;
    }
    
    if(A[0]!=0){
        illegal=true;
    }
    
    B[0]=1;
    REP(i,N){
        B[i+1] = min(INF,2*B[i]-A[i+1]);
        if(B[i+1]<0)illegal=true;
    }
    
    B[N]=0;
    B[0]=1;
    RREP(i,N){
        B[i]=min(B[i],B[i+1]+A[i+1]);
    }
    
    
    //REP(i,N+1){cout << A[i] << " ";}cout << endl;
    //REP(i,N+1){cout << B[i] << " ";}cout << endl;
    
    if(illegal){
        cout << -1 << endl;
        return 0;
    }
    
    int Ans=0;
    REP(i,N+1){
        Ans+=A[i];
        Ans+=B[i];
    }
    cout << Ans << endl;
    
    return 0;
}




Measured memory_bytes: 5000
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int t = sc.nextInt();

    if (x-t>=0) {
      System.out.println(x-t);
    } else {
      System.out.println("0");
    }
  }

}


Measured memory_bytes: 21332
#include <set>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

char b[8][16];

int main(){
  REP(i,8) scanf("%s", b[i]);

  // ÜÝÁ½            

  char mami = 'o';
  char shal = 'x';

  char ck[2] = { mami, shal };
  int turn = 0;
  int bad = 0;

  while(bad < 2){
    int maxcnt = 0;
    int px, py;

    //printf("bad: %d\n", bad);

    REP(y,8) REP(x,8) if(b[y][x] == '.'){
      int cnt = 0;
      REP(i,3) REP(j,3) if(i != 1 || j != 1){
	int dy = i - 1;
	int dx = j - 1;

	int xx = x + dx;
	int yy = y + dy;

	int cc = 0;

	while(true){
	  if(xx < 0) break;
	  if(yy < 0) break;
	  if(xx > 7) break;
	  if(yy > 7) break;

	  if(b[yy][xx] == ck[turn]){
	    cnt += cc;
	    break;
	  }else if(b[yy][xx] == ck[(turn + 1) % 2]){
	    cc++;
	  }else{
	    break;
	  }

	  yy += dy;
	  xx += dx;
	}
      }

      if(turn == 0){
	if(cnt > maxcnt){
	  maxcnt = cnt;
	  px = x;
	  py = y;
	}
      }else{
	if(cnt >= maxcnt){
	  maxcnt = cnt;
	  px = x;
	  py = y;
	}
      }
    }

    if(maxcnt > 0){
      bad = 0;

      b[py][px] = ck[turn];
      REP(i,3) REP(j,3) if(i != 1 || j != 1){
	int dy = i - 1;
	int dx = j - 1;

	int xx = px + dx;
	int yy = py + dy;

	while(true){
	  if(xx < 0) break;
	  if(yy < 0) break;
	  if(xx > 7) break;
	  if(yy > 7) break;

	  if(b[yy][xx] == ck[turn]){
	    dx = -dx;
	    dy = -dy;
	    yy += dy;
	    xx += dx;

	    while(yy != py || xx != px){
	      b[yy][xx] = ck[turn];
	      yy += dy;
	      xx += dx;
	    }

	    break;
	  }else if(b[yy][xx] == ck[(turn + 1) % 2]){
	  }else{
	    break;
	  }

	  xx += dx;
	  yy += dy;
	}
      }

    }else{
      bad++;
    }
    
    turn = (turn + 1) % 2;
  }

  REP(i,8) puts(b[i]);

  return 0;
}

Measured memory_bytes: 0
n = int(input())
ans = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}

for i in range(n):
    s = input()
    ans[s] += 1

print('AC x ' + str(ans['AC']))
print('WA x ' + str(ans['WA']))
print('TLE x ' + str(ans['TLE']))
print('RE x ' + str(ans['RE']))


Measured memory_bytes: 9208
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

void fail(){
    cout<<-1<<endl;
    exit(0);
}

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

  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  ll target=0;
  for(int i=2;i<N;i++) target^=A[i];

  ll a=0,b=A[0]+A[1];
  ll mia=0,mab=0;
  //cout<<target<<endl;
  for(ll k=59;k>=0;k--){
      ll tval=(1ll<<k);
      //cout<<k<<" "<<mia<<" "<<mab<<" "<<b<<endl;
      if((tval&target)!=0){
          if((mab&tval)!=0) continue;
          if(b<tval) fail();
          mab+=tval;
          b-=tval;
      }else{
          //if(b>=tval&&k==0) fail();
          if(b>=2*tval){
              if((tval&mab)!=0){
                  mia+=tval;
                  b-=tval;
              }else{
                  mia+=tval;
                  mab+=tval;
                  b-=2*tval;
              }
              continue;
          }

          if((tval&mab)!=0){
              if(b<tval) fail();
              mia+=tval;
              b-=tval;
          }else if(b>=tval){
              if(k==0) fail();
              mab+=tval/2;
              b-=tval/2;
          }else continue;
      }
  }
  //cout<<a<<" "<<b<<" "<<mia<<" "<<mab<<endl;
  //mia+=b;
  if(b>0) fail();
  if((mia^mab)!=target) fail();

  if(mab<A[1]) fail();
  /*if(mia==0){
      if(mab!=target) fail();
      for(ll k=0;k<60;k++){
          cout<<(target&(1ll<<k))<<endl;
          if((1ll<<k)&mab){
              if(mab==(1ll<<k)) continue;
              cout<<(1ll<<k)<<" "<<(mab^(1ll<<k))<<endl;
              return 0;
          }
      }
      fail();
  }*/

  for(ll k=59;k>=0;k--){
      ll tval=(1ll<<k);
      if(((mia&tval)==0)&&((mab&tval)>0)){
          if(mab-tval>=A[1]&&mia+tval<=A[0]){
              mab-=tval;
              mia+=tval;
          }
      }
  }
  if(mia==0) fail();

  //cout<<mia<<" "<<mab<<endl;
  cout<<A[0]-mia<<endl;

  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
 
using namespace std;
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
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; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
bool dp[100100];

int gcd(int p, int q){
    if(p % q == 0) return q;
    return gcd(q,p%q);
}

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

    int sum = 0;
    repr(i,1,K+1){
        repr(j,1,K+1){
            repr(k,1,K+1){
                sum += gcd(gcd(i,j),k);
            }
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=500005,INF=1<<30;
int cnt[MAX],X[MAX],Xsum[MAX],cntsmall[MAX],cntbig[MAX];

struct BIT{
    vector<int> bit;
    int N;
    //1-indexed
    
    void init(int n_){
        N=n_;
        n_*=2;
        for(int i=30;i>=0;i--){
            if(n_&(1<<i)){
                n_=1<<i;
                n_++;
                break;
            }
        }
        bit.assign(n_,0);
    }
    
    int sum(int i){
        int s=0;
        while(i>0){
            s+=bit[i];
            i-=i&-i;
        }
        return s;
    }
    
    //sからtの和=sum(t)-sum(s-1)
    
    void add(int i,int x){
        while(i<=N){
            bit[i]+=x;
            i+=i&-i;
        }
    }
};

ll rui(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b/=2;
    }
    return ans;
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<int> P(N);
    for(int i=0;i<N;i++) cin>>P[i];
    
    ll ans=0;
    for(int i=N-1;i>=0;i--){
        cnt[i]=cnt[i+1];
        if(P[i]==0){
            cnt[i]++;
        }else{
            X[P[i]]=1;
        }
    }
    
    for(int i=1;i<=N;i++){
        Xsum[i]=Xsum[i-1]+X[i];
        cntsmall[i]=i-Xsum[i];
        cntbig[i]=cnt[0]-cntsmall[i];
    }
    
    BIT bi;
    
    bi.init(N);
    
    ll fac=1,sum=0;
    
    for(int i=N-1;i>=0;i--,fac*=max(1,N-1-i),fac%=mod){
        ll plus=0;
        if(P[i]==0){
            plus+=rui(2,mod-2)*cnt[i+1];
            plus%=mod;
            
            plus+=sum*rui(cnt[0],mod-2)%mod;
            plus%=mod;
        }else{
            plus+=cntsmall[P[i]]*rui(cnt[0],mod-2)%mod*cnt[i+1]%mod;
            plus%=mod;
            
            plus+=bi.sum(P[i]);
            ans%=mod;
            
            bi.add(P[i],1);
            sum+=cntbig[P[i]];
            sum%=mod;
        }
        
        ans+=fac*plus%mod;
        ans%=mod;
        
        //cout<<ans<<endl;
    }
    
    ll p=1;
    
    for(int i=1;i<=cnt[0];i++){
        ans*=i;
        p*=i;
        ans%=mod;
        p%=mod;
    }
    ans+=p;
    ans%=mod;
    
    cout<<ans<<endl;
}



Measured memory_bytes: 14080
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string pat = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
string board[] = {"100101", "10011010", "0101", "0001",
            "110", "01001", "10011011", "010000",
            "0111", "10011000", "0110", "00100",
            "10011001", "10011110", "00101", "111",
            "10011111", "1000", "00110", "00111",
            "10011100", "10011101", "000010", "10010010",
            "10010011", "10010000", "101", "010001",
            "000011", "10010001", "000000", "000001"};

int main() {
    string s; 
    while(getline(cin, s)) {
        string gen = "";
        for(size_t i=0; i<s.length(); i++) {
            int c = pat.find(s[i]);
            string tmp = "";
            for(int j=0; j<5; j++) {
                if(c & 1) tmp += '1';
                else tmp += '0';
                c >>= 1;
            }
            reverse(tmp.begin(), tmp.end());
            gen += tmp;
        }

        string tmp = "", ans = "";
        for(size_t i=0; i<gen.length(); i++) {
            tmp += gen[i];
            for(int j=0; j<32; j++) {
                if(board[j] == tmp) {
                    ans += pat[j];
                    tmp = "";
                    break;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);;

	int tam;

	cin >> tam;

	set <string> pals;

	string cad;

	for (int i = 0; i < tam; ++i)
	{
		cin >> cad;

		pals.insert(cad);
	}

	cout << pals.size();

	return 0;
}

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

void trial(void)
{
  const int LOSE = 0;
  const int WIN = 1;
  const int YET = 2;
  
  const int N = 40;
  int memo[N][N];
  function<int(int, int)> rec = [&] (int x, int y)
  {
    int& ret = memo[x][y];
    if (ret != YET) return ret;
    int best = LOSE;
    for (int i = 1; 2 * i <= x; ++i) {
      best = max(best, rec(x - 2 * i, y + i) ^ 1);
    }
    for (int i = 1; 2 * i <= y; ++i) {
      best = max(best, rec(x + i, y - 2 * i) ^ 1);
    }
    return ret = best;
  };

  for (int x = 0; x < N / 2; ++x) {
    for (int y = 0; y < N / 2; ++y) {
      fill(&memo[0][0], &memo[N - 1][N - 1] + 1, YET);
      // cout << make_pair(x, y) << ", " << rec(x, y) << endl;
      cout << rec(x, y) << " ";
    }
    cout << endl;
  }

  return ;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  // trial(); return 0;
  
  lli x, y;
  while (cin >> x >> y) {
    cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  vector<int> A(5);
  for(int i=0;i<5;i++){
  cin >> A[i];
  }
  int ans=0;
  
  for(int i=0;i<5;i++){
  if( A[i]== 0){
  ans = i+1;
  break;
  }
  }
  
  cout << ans << endl;
  
 
}

Measured memory_bytes: 3544
n = int(input())
a = [0]
for i in range(n):
    a.append(int(input()))

cnt = 1
idx = 1
for i in range(n):
    if a[idx] == 2:
        print(cnt)
        break

    else:
        idx = a[idx]
        cnt += 1
else:
    print(-1)

Measured memory_bytes: 7080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m;
struct node{
	int a,b;
}boat[200001];
int jilu[200001];
bool ok[200001];
int tot;
bool wawa;
int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>boat[i].a>>boat[i].b;
		if(boat[i].a==1)jilu[++tot]=i;
		if(boat[i].b==n)ok[boat[i].a]=1;
	}
	for(int i=1;i<=tot;i++)
	{
		if(ok[boat[jilu[i]].b])wawa=1;
	}
	if(wawa==1)printf("POSSIBLE");
	else printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;

class Main {
	
	private static int mcd(int a, int b, int c){
		return mcd(a, mcd(b, c));
	}
	
	private static int mcd(int a, int b){
		if(a==1 || b==1) return 1; 
		if(a==b) return a;
		if(a<b) return mcd(a, b-a);
		else return mcd(a-b, b);
	}
	
	public static void main(String... args){
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();
		long somma = 0;
		for(int a=1; a<=K; ++a)
			for(int b=1; b<=K; ++b)
				for(int c=1; c<=K; ++c) somma+=mcd(a, b, c);
		System.out.print(somma);
	}
}

Measured memory_bytes: 36124
n, m = map(int, input().split())
h = list(map(int, input().split()))
ok = [True] * 100001

for _ in range(m):
    a, b = map(int, input().split())
    if h[a-1] > h[b-1]:
        ok[b-1] = False
    elif h[b-1] > h[a-1]:
        ok[a-1] = False
    else:
        ok[a-1] = False
        ok[b-1] = False

count = 0

for i in range(n):
    if ok[i]:
        count += 1

print(count)


Measured memory_bytes: 20120
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int main(){
  long long N,M; cin>>N>>M;
  
  vector<pair<long long,long long> > AB;
  
  for(long long i=0;i<N;i++){
    long long a,b; cin>>a>>b;
    AB.push_back(make_pair(a,b));
  }
  long long ans=0,res=M;
  sort(AB.begin(),AB.end());
  
  for(long long i=0;i<N;i++){
    if(res<AB[i].second){
      ans+=AB[i].first*res;
      res=0;
    }
    else{
      ans+=AB[i].first*AB[i].second;
      res-=AB[i].second;
    }
    if(res==0) break;
  }

  cout<<ans<<endl;

  return 0;
}


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

int main(){
	unsigned long long H, W;
  	cin >> H >> W;
  	if(H==1 or W==1){
		cout << 1 << endl;
    }
  	else if(H%2==0 or W%2==0){
  		cout << (H*W)/2 << endl;
    }
  	else{
  		cout << ((H*W)/2 + 1) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
 
 
int main() {
    int64_t n,m,ans,penalty;
    int64_t p;
    string s;
    ans=0;
    penalty=0;
     cin>>n>>m;
   
    vector<int> ac(n);
    vector<int> wa(n);
    
    for(int64_t i=0;i<n;i++){
        ac.at(i)=0;
        wa.at(i)=0;
        
    }
   //  vector<int> p(m);
    //vector<string> s(m);
    
    
    //vector<int> a(n-1);
   
    for(int i=0;i<m;i++){
       // cin>>p.at(i);
       // cin>>s.at(i);
       cin>>p;
       cin>>s;
        if(s=="AC"&&ac.at(p-1)==0){
            ac.at(p-1)=1;
            ans+=1;
        }else if(s=="WA"&&ac.at(p-1)==0){
            penalty+=1;
            wa.at(p-1)+=1;
        }
        
    }
    for(int i=0;i<n;i++){
        if(ac.at(i)==0) penalty-=wa.at(i);
    } 
    
    
    
    cout<<ans<<" "<<penalty<<endl;
    
    
}

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

int K = 0;

string S;
string m = "...";

int main(){
  
  cin>>K;
  
  cin>>S;
  
  
  if(S.length() > K){
    
    string nS = S.substr(0,K);
    nS += m;
    
    cout<<nS;
  }else{
    cout<<S;
  
  }
  
  
  return 0;
}

Measured memory_bytes: 3644
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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


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

    int n,a,b,c,d,e; cin >> n >> a >> b >> c >> d >> e;
    int m;
    m = min(a,b);
    m = min(m,c);
    m = min(m,d);
    m = min(m,e);

    int ans = 0;

    ans += (n-1) / m + 1;
    ans += 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int n;
string s[60];
int cnt[26][60];
int mn[26];

int main() {
    for(int i=0;i<26;i++) mn[i] = 10000;
    cin >> n;
    for(int i=0;i<n;i++) cin >> s[i];

    for(int i=0;i<n;i++){
        for(int j=0;j<s[i].size();j++){
            cnt[s[i].at(j) - 'a'][i]++;
        }
    }

    for(int i=0;i<26;i++){
        for(int j=0;j<n;j++){
            mn[i] = min(mn[i], cnt[i][j]);
        }
    }

    string ans = "";
    for(int i=0;i<26;i++){
        for(int j=0;j<mn[i];j++){
            ans += 'a' + i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // 整数スキャン（複数）
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s;
    cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s;
        cin >> s;
        slist.push_back(s);
    }
    */

int main() {
    int n;
    scanf("%d",&n);
    int w;
    scanf("%d",&w);
    ll a[n+1] = {};
    ll b[n+1] = {};
    srep(i,1,n+1){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    ll dp[n+1][w+1];
    rep(i,n+1){
        rep(j,w+1){
            if(i==0||j==0){
                dp[i][j]=0;
            }else{
                if(a[i]>j){
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                }else{
                    dp[i][j]=max(dp[i-1][j-a[i]]+b[i],max(dp[i-1][j],dp[i][j-1]));
                }
            }
        }
    }

    ll ans = 0;
    ans=dp[n][w];
    cout << ans << endl;
    return 0;
}
 
 


Measured memory_bytes: 79104
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n, a, b;
    cin >> n >> a >> b;

    vs64 v(n);
    rep (i, n) cin >> v[i];

    s64 dp[n + 1][n + 1];
    rep (i, n + 1) rep (j, n + 1) dp[i][j] = 0;
    s64 dp2[n + 1][n + 1];
    rep (i, n + 1) rep (j, n + 1) dp2[i][j] = 0;
    dp2[0][0] = 1;

    rep (i, n)
    {
        rep (j, n + 1)
        {
            if (j > 0)
            {
                if (dp[i][j] < dp[i][j - 1] + v[i])
                {
                    dp[i + 1][j] = dp[i][j - 1] + v[i];
                    dp2[i + 1][j] = dp2[i][j - 1];
                }
                else if (dp[i][j] == dp[i][j - 1] + v[i])
                {
                    dp[i + 1][j] = dp[i][j];
                    dp2[i + 1][j] = dp2[i][j] + dp2[i][j - 1];
                }
                else
                {
                    dp[i + 1][j] = dp[i][j];
                    dp2[i + 1][j] = dp2[i][j];
                }
            }
            else
            {
                dp[i + 1][j] = dp[i][j];
                dp2[i + 1][j] = dp2[i][j];
            }
        }
    }

    s64 num = 1;
    s64 temp = -1;
    double ans = 0;
    s64 ans2 = 0;
    for (int i = a; i <= b; ++i)
    {
        if (temp * i < dp[n][i] * num)
        {
            num = i;
            temp = dp[n][num];
        }
        if (temp * i == dp[n][i] * num)
        {
            ans2 += dp2[n][i];
        }
    }

    ans = (double)temp / num;

    cout << std::fixed << ans << "\n";
    cout << ans2 << "\n";
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define AORD(f) puts((f)?"APPROVED":"DENIED")
ll n;
//ld ;
//string s;
 
int main() {
  cin >> n;
  bool app = true;
  for(ll i=0;i<n;i++){
    ll a;
    cin >> a;
    if(a%2==0){
      if((a%3!=0)&&(a%5!=0)){
        app = false;
      }
    }
  }
  AORD(app);
  return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: Evergrowing Tree
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

typedef vector<int> vi;

/* global variables */

/* subroutines */

void trv(vi &v, int a, int n) {
  while (a) {
    v.push_back(a);
    a = (a - 1) / n;
  }
  v.push_back(a);
}

void printv(vi &v) {
  for (int i = 0; i < v.size(); i++) printf("%d ", v[i]);
  putchar('\n');
}

/* main */

int main() {
  int n, q;
  scanf("%d%d", &n, &q);

  while (q--) {
    int a, b;
    scanf("%d%d", &a, &b);

    if (n == 1) {
      printf("%d\n", min(a, b));
      continue;
    }
    
    a--, b--;
    vi va, vb;
    trv(va, a, n);
    trv(vb, b, n);
    //printv(va), printv(vb);

    int an = va.size(), bn = vb.size(), m = min(an, bn);
    int k = 1;
    for (; k < m && va[an - 1 - k] == vb[bn - 1 - k]; k++);
    printf("%d\n", va[an - k] + 1);
  }
  return 0;
}


Measured memory_bytes: 1280
import java.io.*;
import java.lang.*;
import java.util.*;

class Node{
        int weight;
        long value;
        Node(int w , long v)
        {
            this.weight =w;
            this.value =v;
        }
        
    }

public class Main {
    
    
    
	public static void main (String[] args) throws IOException
	{
	   BufferedReader br = new BufferedReader( new InputStreamReader ( System.in));
	   String line1= br.readLine();
	   String strs1[]= line1.trim().split("\\s+");
	   int n= Integer.parseInt( strs1[0] );
	   int total= Integer.parseInt(strs1[1]);
	   
	   long arr[][]= new long[n+1][total+1];
	   
	   for(int i=0 ; i<total+1 ;i++)
	   {
	       arr[0][i]=0;
	   }
	   
	   for(int i=0;i<=n; i++)
	    arr[i][0]=0;
	    
	   Node data[]= new Node[n];
	   
	   for(int i=0;i<n ; i++)
	   {
	        String line=br.readLine();
	        String strs[]=line.trim().split("\\s+");
	        int w= Integer.parseInt(strs[0] );
	        long v= Long.parseLong(strs[1] );
	        Node temp=new Node(w , v);
	        data[i]=temp;
	   }
	   Arrays.sort(data , new The_comparator() );
	   
	   for(int i=1 ; i<=n ; i++)
	   {
	       int w1=data[i-1].weight;
	       long v1=data[i-1].value;
	       for(int j=1 ; j<=total ; j++)
	       {
	           if(j<w1)
	              arr[i][j]=arr[i-1][j];
	           else
	                arr[i][j]= Math.max( arr[i-1][j] , arr[i-1][j-w1] + v1);
	       }
	   }
	   
	   System.out.println(arr[n][total]);
		//code
	}
}

class The_comparator implements Comparator<Node>
{
    public int compare(Node n1 , Node  n2)
    {
        return(n1.weight-n2.weight);
    }
}

Measured memory_bytes: 126548
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string disp(bool x){
    return x ? "Yes" : "No";
}

int main(){
    int n; cin >> n;
    vi a;
    
    rep(i,n){
        int q; cin >> q;
        if(q == 0){
            int x; cin >> x;
            a.push_back(x);
        }
        
        if(q == 1){
            int p; cin >> p;
            cout << a[p] << endl;
        }
        
        if(q == 2){
            a.pop_back();
        }
    }
    
}








Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main() 
{
    IOS;
    int n;
    cin>>n;
    set<int>s;
    int ans=0;
    for(int i=1;i*i<=(n-1);i++)
    {
        if((n-1)%i==0)
        {
            s.insert((n-1)/i);
            s.insert(i);
        }
    }
    for(int i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            s.insert(n/i);
            s.insert(i);
        }
    }
    for(int i:s)
    {
        if(i==1)
            continue;
        int temp=n;
        while(temp%i==0)
            temp/=i;
        int mul=temp/i;
        temp-=mul*i;
        if(temp==1)
            ans++;
    }
    print(ans);
}   


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

static const int MAX_N = 1000000;
static const int MAX_P = 2000000000;

int N, M, Q, S[MAX_N];

map<int, int> PM; // point map
vector<int> ATI, ATV;
vector<int> MS;
set<int> R;
vector<pair<int, int> > seg;

void init(){
  MS.clear();
  for ( set<int>::iterator it = R.begin(); it != R.end(); it++ ){
    MS.push_back(S[*it]);
  }
  sort(MS.begin(), MS.end());
}
//MS 5 8
int getCount(int r){
  seg.clear();

  if ( MS.size() > 0 ) seg.push_back(make_pair(MS[0]-r, MS[0]));
//seg[0] -2001999995, 5
  for ( int i = 1; i < MS.size(); i++ ){
    int b = MS[i]-r;
    int e = MS[i];
    if ( b <= seg[seg.size()-1].second){
      seg[seg.size()-1].second = max(seg[seg.size()-1].second, e);
    } else {
      seg.push_back(make_pair(b, e));
    }
  }

  int cnt = 0;

  for ( int i = 0; i < seg.size(); i++ ){
    int a = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].first) )) - 1;
    int b = distance(ATI.begin(), lower_bound(ATI.begin(), ATI.end(), max(0, seg[i].second) ));
    cnt += ATV[b] - ATV[a];
  }

  return cnt;
}

void bsearch(int X){
  init();

  int l = 0;
  int r = MAX_P+2000000;
  int m;
  int diff = r - l;
  int cnt = getCount(r);
  if ( cnt < X ){
    cout << "NA" << endl;
    return;
  }

  //  for (int i = 0; i < 100; i++ ){
  while(1){
    m = (l+r)/2;
    cnt = getCount(m);
    if ( cnt >= X ){
      r = m;
    } else if ( cnt < X ){
      l = m;
    }
    if ( diff == l - r ) break;
    diff = l - r;
  }
  cout << r << endl;
}

int main(){
  scanf("%d %d", &N, &Q);

  MS.clear();
  PM.clear();
  ATI.clear();
  ATV.clear();

  rep(i, N) {
    scanf("%d", &S[i]);
    PM[S[i]]++;
  }

  bool isR[MAX_N];
  rep(i, N) isR[i] = false;

  M = 0;

  ATI.push_back(-1);
  ATV.push_back(0);
  int pre = 0;
  for ( map<int, int>::iterator it = PM.begin(); it != PM.end(); it++ ){
    ATI.push_back((*it).first);
    ATV.push_back((*it).second + ATV[pre++]);
  }

  string com;
  int x;
  rep(i, Q){
    cin >> com >> x;
    if ( com[0] == 'C' ){
      bsearch(N - x);
    } else if ( com[0] == 'R' ){
      x--; // 0 base
      R.erase(R.find(x));
      M--;
    } else if ( com[0] == 'A' ){
      x--; // 0 base
      R.insert(x);
      M++;
    }
  }
  return 0;
}

Measured memory_bytes: 61732