akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vcc;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
{
    ll i, j, n, m;

    double x;
    cin >> x;
    if (x == 0)
    {
        cout << 1 << endl;
    }
    else if (x == 1)
    {
        cout << 0 << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10860
open System

let A = stdin.ReadLine() |> int
let B = stdin.ReadLine() |> int
let C = stdin.ReadLine() |> int
let X = stdin.ReadLine() |> int

let mutable count = 0

for i in 0..A do
    for j in 0..B do
        for k in 0..C do
            if i * 500 + j * 100 + k * 50 = X then
                count <- count + 1


printfn "%d" count


Measured memory_bytes: 13916
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    int sum = 0, x;
    rep(i, 10){
      scanf("%d", &x);
      sum += x;
    }
    pri(sum);


/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define con_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define con_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
using namespace std;
template <typename T>T digitsum(T n);
template <typename T>T gcd(T u,T v);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
 
int main(){
    long long int n,ans=0,a;
    cin>>n;
    vector<pair<long long int, long long int>> sosu=prime_factor(n);
    rep(i,sosu.size()){
        a=1;
        while(sosu[i].second>=a){
            ans++;
            sosu[i].second-=a;
            a++;
        }
    }
    cout<<ans<<endl;
}
 
template <typename T>
T digitsum(T n){
    string s=to_string(n);
    T sum=0;
    T d=1;
    for(T e=0;e<s.length();e++){
        sum+=(n/d)%10;d*=10;
    }
    return sum;
}
template <typename T>
T gcd(T u,T v) {
    while ( v != 0) {
        T r = u % v;
        u = v;
        v = r;
    }
    return u;
}
template <typename T>
bool isPrime(T n){
    if(n<=1)return false;
    if(n==2)return true;
    if(n%2==0)return false;
    for(T q=3;q*q<=n;q+=2){
        if(n%q==0)return false;
    }
    return true;
}
template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    if(n%2==0){
        T tmp = 0;
        while (n % 2 == 0) {
            tmp++;
            n /= 2;
        }
        ret.push_back(make_pair(2, tmp));
    }
    for (T i = 3; i*i <= n; i+=2) {
        if(n%i==0){
            T tmp = 0;
            while (n % i == 0) {
                tmp++;
                n /= i;
            }
            ret.push_back(make_pair( i, tmp));
        }
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

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

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

int main(void) {
    string s;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    REP(i, s.length()) {
        cout << "x";
        if (i == s.length() - 1) {
            cout << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <fstream>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


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

bool comp(PI a,PI b){
  if(a.F==b.F)return a.S<b.S;
  return a.F>b.F;
}


main(){
  int m;
  while(cin>>m,m){
    vector<PI> po;

    rep(i,m){
      int num,p=0;
      cin>>num;
      int t2=0,t1=0;
      int flame=0,fi;
      int last=0;
      int sl1[10],sl2[10];
      memset(sl1,0,sizeof(sl1));
      memset(sl2,0,sizeof(sl2));

      while(true){
	int t;
	if(flame==9){
	  cin>>t;
	  int su=t;
	  sl1[flame]=t;
	  cin>>t;
	  su+=t;
	  sl2[flame]=t;
	  if(su>=10){
	    cin>>last;
	  }
	  break;
	}else{
	  cin>>t;
	  if(t==10){
	    sl1[flame]=10;
	    ++flame;
	    continue;
	  }
	  sl1[flame]=t;
	  cin>>t;
	  sl2[flame]=t;
	}
	++flame;
      }

      int sum=0;
      rep(j,10){
	if(j!=9){
	  sum+=sl1[j];
	  if(sl1[j]==10){
	    sum+=sl1[j+1];
	    if(sl1[j+1]==10){
	      if(j+2<10)sum+=sl1[j+2];
	      else sum+=sl2[j+1];
	    }else sum+=sl2[j+1];
	  }else{
	    sum+=sl2[j];
	    if(sl1[j]+sl2[j]==10){
	      sum+=sl1[j+1];
	    }
	  }
	}else{
	  sum+=sl1[j]+sl2[j]+last;
	}
      }
      po.pb(mp(sum,num));
    }
    sort(ALL(po),comp);
    rep(i,po.size()){
      cout<<po[i].S<<" "<<po[i].F<<endl;
    }
  }
}

Measured memory_bytes: 0
N,M = list(map(int,input().split()))
AB = []
from collections import deque

for i in range(M):
    AB.append(list(map(int,input().split())))


out = 0
for remove in range(M):
    G = [[] for i in range(N)]
    for i in range(M):
        if i==remove:
            continue
        else:
            A,B=AB[i]
            G[A-1].append(B-1)
            G[B-1].append(A-1)
    s = 0
    visit = [0]*N
    que = deque([s])
    visit[s] = 1
    while que:
        v = que.popleft()
        for w in G[v]:
            if visit[w] == 1:
                continue
            visit[w] =  1
            que.append(w)
    if sum(visit)!=N:
        out+=1
print(out)

Measured memory_bytes: 68196
n, m = map(int,input().split())

AC = 0
# 各問題でACがとれているか確認用
# 0 = まだ正解していない, 1 = すでに正解済み
AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)

for i in range(m):
    p,S = input().split()
    p = int(p)

    if S == "AC":
        # 初めての正解
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        # ※すでに正解している場合は加算しない
    else:
        # まだ正解していない場合
        if AC_list[p] == 0:
            WA_List[p] += 1
        # ※すでに正解している場合は加算しない

print(AC,WA)

Measured memory_bytes: 4596
from math import pi, cos

a, b, h, m = [int(item) for item in input().split()]

h += m / 60

alpha = 2 * pi * abs(h / 12 - m / 60)

ans = (a ** 2 + b ** 2 - 2 * a * b * cos(alpha)) ** .5

print(ans)


Measured memory_bytes: 9496
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    ll N, M;
    cin >> N >> M;
    //角は常に表
    ll corner_num = N>1&&M>1 ? 4: N==1&&M==1 ? 1:2;
    //bool corner = true;
    ll edge_row = N>1 ? 2*(M-2):(M-2);
    bool is_edge_row = N>1 ? true:false;
    ll edge_col = M>1 ? 2*(N-2):(N-2);
    bool is_edge_col = M>1 ? true:false;
    ll inside = (N>2 && M>2) ? N*M - (N*2 +M*2 -4):0;
    bool is_inside = false;
    //cerr << corner_num << "," <<  is_edge_row <<  "," <<  is_edge_col << endl;
    if(corner_num > 1) cout << edge_row*!is_edge_row + edge_col*!is_edge_col + inside << endl;
    else cout << 1 << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,K,Q,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;

ll dp[105][100005];//n v

int main(){
    ll n,W;
    cin >> n>>W;
    rep(i,n){
        ll w,v;
        cin >> w>>v;
        
        if(i==0){
            rep(j,v+1){
                dp[0][j]=w;
            }
            reps(j,v+1,100005){
                dp[0][j]=INF;
            }
            dp[0][0]=0;
            continue;
        }
        rep(j,100005){
            dp[i][j]=dp[i-1][j];
            if(j-v>=0&&i>0){
                dp[i][j]=min(dp[i][j],dp[i-1][j-v]+w);
            }
        }
        /*
        rep(j,20){
            cerr<<j<<' '<<dp[i][j]<<' ';
        }
        cerr<<endl;
        */
    }
    int ans=0;
    Rrep(j,100001){
        if(dp[n-1][j]<=W){
            ans=j;
            j=-INF;
        }
    }
    /*
    rep(i,20){
        cerr<<i<<' '<<dp[n-1][i]<<endl;
    }
    */
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 80128
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
const int maxn=110;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,a[maxn],vis[maxn];
int check()
{
	if(a[n]>=n) return 0;
	if(a[1]!=((a[n]+1)>>1)) return 0;
	for(int i=1;i<=n;i++) vis[a[i]]=1;
	for(int i=a[1];i<=a[n];i++) if(!vis[i]) return 0;
	if(~a[n]&1)
	{
		if(a[2]==a[1]) return 0;
	}
	else
	{
		if(a[1]==a[2]&&a[1]==a[3]) return 0;
	}
	return 1;
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	sort(a+1,a+n+1);
	if(check()) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<string>
#include<cctype>
#include<math.h>
using namespace std;


long double a(long double x){
	if(x<0)return -x;
	
	return x;
}

int main(){
 double x1,y1,x2,y2;
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
long double x,y;

/*if(x1<0&&x2>=0){
	x=a(x1)+x2;
}
else if(x2<0&&x1>=0){
	x=x1+a(x2);
}
else x=max(a(x1),a(x2))-min(a(x1),a(x2));

if(y1<0&&y2>=0){
	y=a(y1)+y2;
}
else if(y2<0&&y1>=0){
	y=y1+a(y2);
}
else y=max(a(y1),a(y2))-min(a(y1),a(y2));*/
	//printf("%f : %f",x,y);
		double ans=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
		printf("%f\n",ans);
return 0;
}

Measured memory_bytes: 1236
input = [int(x) for x in input().split()]

n = input[0]
baseK = input[1]

#x = b^y
#y = log b (x)

#log b a = log x (a) / log x (b)
count=0
while(n>0):
    count = count + 1
    n= n//baseK

print(count)

Measured memory_bytes: 2940
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

long n, k;
long h[100005];
long dp[100005];

int main(){
	scanf("%ld %ld", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%ld", &h[i]);
	}
	dp[1] = 0;
	for(int i = 2; i <= n; i++){
		dp[i] = LINF;
		for(int j = 1; j <= k && i - j > 0; j++){
			dp[i] = std::min(dp[i], dp[i-j] + std::abs(h[i] - h[i-j]));
		}
	}
	/*
	for(int i = 0; i <= n; i++){
		printf("%ld ", dp[i]);
	}
	printf("\n");
	//*/
	printf("%ld\n", dp[n]);
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(10, vector<int> (10));
  REP(i, 10) REP(j, 10) cin >> c[i][j];
  vector<vector<int>> A(H, vector<int> (W));
  REP(i, H) REP(j, W) cin >> A[i][j];

  REP(k, 10) REP(i, 10) REP(j, 10) c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
  int ret = 0;
  REP(i, H) REP(j, W) {
    if(A[i][j] == -1) continue;
    ret += c[A[i][j]][1];
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)


















int main(){
    ll n;
    cin >> n;
    set<string> st;
    REP(i, n){
        string s;
        cin >> s;
        st.insert(s);
    }
    cout << st.size() << endl;
}

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

vector<pair<int, int>> primeFactorization(int n) {
  vector<pair<int, int>> result;
  for(int i=2;i<=n;i++) {
    if(n % i != 0) continue;
    int times = 0;
    while(n % i == 0) {
      times++;
      n /= i;
    }
    pair<int, int> p = make_pair(i, times);
    result.push_back(p);
    if(n==1) break;
  }
  return result;
}

int main() {
  int n;
  cin >> n;
  int mod = 1e9 + 7;
  vector<long long int> divided(1001, 1);
  if (n == 1) cout << 1 << endl;
  else {
    for(int i=2;i<=n;i++) {
      vector<pair<int, int>> primes = primeFactorization(i);
      for(int j=0;j<primes.size();j++) {
        divided[primes[j].first] += primes[j].second;
      }
    }

    long long int total = divided[0];

    for(int i=1;i<divided.size();i++) {
      total = total * divided[i] % mod;
    }
    
    cout << total << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long num[41];
int a[41];
void cal(long long x)
{
    int pos=0;
    while(x)
    {
        a[pos++]=x%2;
        x/=2;
    }
    long long t=0;
    for(int i=0;i<pos;i++)
    {
        if(a[i]==1)
        {
            for(int j=0;j<i;j++)
                num[j]+=pow(2,i)/2;
            num[i]+=t+1;
        }
        t+=a[i]*pow(2,i);
    }
}
int main()
{
    long long a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    cal(b);
    for(int i=0;i<=40;i++)
        num[i]*=-1;
    if(a) cal(a-1);
    for(int i=0;i<=40;i++)
        num[i]*=-1,ans+=num[i]%2*(1ll<<i);
    printf("%lld\n",ans);
}


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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

//実行部
void Main()
{
  ll n; cin >> n;
  vll a(n), b(n, 0); rep(i, n - 1)
  {
    cin >> a[i];
    b[a[i] - 1]++;
  }
  rep(i, n)
  {
    cout << b[i] << endl;
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 6332
n = int(input())
A = list(int(input()) for _ in range(n))
ans = 0
for i in range(n):
    tmp = A[i]
    ans += (tmp//2)
    if i < n-1 and tmp %2 and A[i+1] > 0:
        ans += 1
        A[i+1] -= 1
print(ans)

Measured memory_bytes: 12936
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;

ll a[200010];
const ll mod=1e9+7;
int main(){
	int n;
	ll sum=0;
	scanf("%d",&n);
	
	for(int i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		sum+=a[i];
	}
	
	ll ans=0,tmp=0;
	for(int i=0;i<n;i++){
		tmp+=a[i];
		ans=(ans+a[i]*((sum-tmp)%mod)%mod)%mod;
	}
	
	printf("%lld",ans);
}

Measured memory_bytes: 5352
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define readvec(vec)    \
  for (auto& e : vec) { \
    cin >> e;           \
  }
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
typedef long long int ll;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef vector<double> vecd;
typedef vector<string> vecstr;
typedef vector<char> vecchar;
typedef vector<bool> vecbool;
typedef vector<vector<bool>> vec2bool;
typedef vector<vector<int>> vec2int;
typedef vector<vector<double>> vec2d;
////////////////////////////////////////////////
void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
////////////////////////////////////////////////
int main() {
  init();
  int n, m, q;
  cin >> n >> m >> q;
  vec2int g(n + 1, vecint(n + 1, 0)), c(n + 1, vecint(n + 1, 0));
  REP(i, m) {
    int l, r;
    cin >> l >> r;
    g[l][r]++;
  }
  REP(i, n) {
    REP(j, n) { c[i + 1][j + 1] = c[i + 1][j] + g[i + 1][j + 1]; }
  }
  vecint ans(q, 0);
  REP(i, q) {
    int l, r;
    cin >> l >> r;
    for (int j = l; j <= r; j++) {
      ans[i] += c[j][r] - c[j][l - 1];
    }
  }
  for (auto& e : ans) cout << e << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();

		/*if(n==m) {
			System.out.println(k);
		}else if(m==k){
			System.out.println(n);
		}else {
			System.out.println(m);
		}*/
		System.out.println(2*m-n);
	}
}




Measured memory_bytes: 21844
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 1;
    while(ans * 2 <= N) ans *= 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3648
program probB
  implicit none
  integer*8 n,i,j,k,l,tmp,tmp_2,tmp_3,del_tmp,mi,pl
  integer*8,allocatable :: a(:),b(:),del(:),minus_b(:),plus_a(:)

  read(*,*) n
  allocate(a(n),b(n),del(n),minus_b(n),plus_a(n))
  read(*,*) a
  read(*,*) b

  minus_b=0
  tmp_2=0
  tmp_3=0
  pl=0
  mi=0
  do i=1,n
     del(i)=b(i)-a(i)
     if(del(i)>0)then
        pl=pl+del(i)
     else
        mi=mi-del(i)
     end if
     
     select case(del(i))
     case(:-1)
        tmp_2=tmp_2+1
        minus_b(tmp_2)=i
     case(1:)
        tmp_3=tmp_3+1
        plus_a(tmp_3)=i
     end select
     
  end do

  if(pl+mi<0) then
     write(*,*)'No'
     stop
  end if

  i=0
  ! do while(mi<0.and.i<n)
  !    i=i+1
  !    if(del(i)>0) then
  !       mi=mi-del(i)
  !       a(i)=+del(i)
  !    end if
  ! end do

  l=1
  do i=1,tmp_2
     k=minus_b(i)
     do while (del(k)<0.and.l<=tmp_3)
        j=plus_a(l)
        if(del(j)>=2) then
!           write(*,*) del
           if(mod(del(j),2)==0)then
              a(j)=a(j)+min(del(j),-del(k)*2)
              b(k)=b(k)+min(del(j),-del(k)*2)/2
           else
              a(j)=a(j)+min(del(j)-1,-del(k)*2)
              b(k)=b(k)+(min(del(j)-1,-del(k)*2))/2
           end if
           del(k)=b(k)-a(k)
           del(j)=b(j)-a(j)
        else
           l=l+1
        end if
     end do
     if(sum(del)<0) then
        write(*,*)'No'
        stop
     end if
  end do
  do i=1,n
     if(del(i)<0) then
        write(*,*) 'No'
        stop
     end if
  end do
  

  write(*,*) 'Yes'  
end program probB


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define PB push_back
#define loop(i,x,y) for(int i=x;i<y;i++)
#define rloop(i,x,y) for(int i=x;i>y;i--)
#define NL cout<<"\n"
#define ans(x) cout<<x<<"\n"
#define out(x) cout<<x<<" "
#define F first
#define S second
#define ansf(x,y) cout<<fixed<<setprecision(y)<<x<<endl;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
void solve()
{
  int n;
  cin>>n;
  ans(n*n*n);
}
signed main()
{
  // FAST;
  int T=1;
  // cin>>T;
  while(T--) solve();
  return 0;
}

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

typedef long long ll;
const int Maxn = 2e5;

int N, L;
int A[Maxn + 5];

int tot;
int val[Maxn * 4 + 5], vl[Maxn * 4 + 5], vr[Maxn * 4 + 5];
int s1[Maxn * 4 + 5], s2[Maxn * 4 + 5], sum[Maxn * 4 + 5];
int now[Maxn * 4 + 5], newnow[Maxn * 4 + 5];

struct cmp {
	bool operator () (const int &lhs, const int &rhs) {
		return val[lhs] == val[rhs] ? vl[lhs] > vl[rhs] : val[lhs] > val[rhs];
	}
};
priority_queue<int, vector<int>, cmp> q;

int main() {
#ifdef LOACL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	scanf("%d %d", &N, &L);
	for(int i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
		++tot;
		val[tot] = A[i], vl[tot] = vr[tot] = i;
		s1[tot] = s2[tot] = 1;
		q.push(tot);
	}
	ll ans = 0;
	while(!q.empty()) {
		int len = 0;
		now[++len] = q.top();
		q.pop();
		while(!q.empty() && val[q.top()] == val[now[1]] && vl[q.top()] == vr[now[len]] + 1)
			now[++len] = q.top(), q.pop();
		sum[0] = 0;
		for(int i = 1; i <= len; i++)
			sum[i] = sum[i - 1] + s1[now[i]];
		for(int i = 1; i <= len; i++) {
			ans += 1LL * s1[now[i]] * s2[now[i]];
			if(i - L + 1 >= 1) ans += 1LL * s2[now[i]] * sum[i - L + 1];
		}
		int newlen = 0, last = 0;
		for(int i = 1; i <= len / L; i++) {
			int tmpl = (i - 1) * L + 1, tmpr = i * L;
			if(i == len / L) tmpr = len;
			++tot;
			vl[tot] = vl[now[tmpl]], vr[tot] = vr[now[tmpr]];
			val[tot] = val[now[1]] + 1;
			for(int j = i * L; j <= (i + 1) * L - 1 && j <= len; j++)
				s2[tot] += s2[now[j]];
			s1[tot] = sum[len % L + 1 + (i - 1) * L] - sum[last];
			last = len % L + 1 + (i - 1) * L;
			q.push(tot);
			newnow[++newlen] = tot;
		}
		sum[0] = 0;
		for(int i = 1; i <= newlen; i++)
			sum[i] = sum[i - 1] + s1[newnow[i]];
		for(int i = 1; i <= newlen; i++) {
			ans -= 1LL * s1[newnow[i]] * s2[newnow[i]];
			if(i - L + 1 >= 1) ans -= 1LL * s2[newnow[i]] * sum[i - L + 1];
		}
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
    //ソートしてループしてかうんた
    //if次の要素と同じでcontinue
    //二重ループ脱出はフラグを利用
    int N;
    cin >> N;

    vector<int> moti(N);
    for (int i = 0; i < N; i++) {
        cin >> moti.at(i);
    }
    int count = 0;
    int flag  = 0;

    for (int i = 0; i< N; i++) {
        if (i != N - 1) {
            for (int j = i + 1; j < N; j++) {
                if (moti.at(i) == moti.at(j)) {
                    flag = 1;
                    break;
                }
            }
        }
        
        if (flag == 1){
            flag = 0;
        }
        else
            count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long p[100005], N, Q, A;
int main() {
	cin >> N >> Q;
	for (int i = 0; i < N; i++)cin >> p[i];
	for (int i = 0; i < Q; i++) {
		long long sum = 0, R = 0; cin >> A;
		long long cnt = 0;
		for (int i = 0; i < N; i++) {
			while (true) {
				if (R >= N)break;
				if (sum + p[R] > A)break;
				sum += p[R]; R++;
			}
			if (sum > 0) { sum -= p[i]; }
			cnt += R - i;
			if (R < i + 1)R = i + 1;
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3872
public class Main{
  static int top;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    String s;
    char[][] f;
    int i, j, k, h, w, count;
    int[] nowh, noww, di, dj;

    f = new char[14][14]; nowh = new int[144]; noww = new int[144];
    di = new int[4]; dj = new int[4];
    di[0] = -1; di[1] = 0; di[2] = 1; di[3] = 0;
    dj[0] = 0; dj[1] = -1; dj[2] = 0; dj[3] = 1;
    for(;sc.hasNext();){
      for(i = 1;i < 13;i++){
        s = sc.next();
        for(j = 1;j < 13;j++)f[i][j] = s.charAt(j - 1);
      }

      top = 0; count = 0;
      for(i = 1;i < 13;i++)for(j = 1;j < 13;j++)if(f[i][j] == '1'){
        count++;
        f[i][j] = '0';
        pushhw(nowh, noww, i, j);
        for(;top > 0;){
          h = poph(nowh); w = popw(noww);
          for(k = 0;k < 4;k++)if(f[h + di[k]][w + dj[k]] == '1'){
            f[h + di[k]][w + dj[k]] = '0';
            pushhw(nowh, noww, h + di[k], w + dj[k]);
          }
        }
      }

      out.println(count);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int poph(int[] nowh){
    return nowh[--top];
  }
  private static int popw(int[] noww){
    return noww[top];
  }
  private static void pushhw(int[] nowh, int[] noww, int h, int w){
    nowh[top] = h; noww[top++] = w;
    return;
  }
}

Measured memory_bytes: 17140
import itertools
import numpy as np

N = 5
data = [int(input()) for i in range(N)]
result =[]

data_per = list(itertools.permutations(data))
for i in range(len(data_per)):
    sum = 0
    for j in range(N-1):
        sum += int(np.ceil(data_per[i][j] / 10) * 10)
    sum += data_per[i][N-1]
    result.append(sum)

result.sort()
print(result[0])

Measured memory_bytes: 12464
A=io.read("n")
B=io.read("n")
C=io.read("n")
X=io.read("n")
local count=0
for i=0,A do
  for j=0,B do
    for k=0,C do
      if i*500+j*100+k*50==X then
        count=count+1
      end
    end
  end
end
print(count)

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  string A,B;
  int C,D;
  cin>>A>>B>>C>>D;
  map<string,int> mp;
  mp[A] = C;
  mp[B] = D;
  string E;
  cin>>E;
  mp[E]--;
  cout<<mp[A]<<" "<<mp[B]<<endl;


  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define cinf(n,x) for(int i=0;i<(n);i++) cin >> x[i];

int main(){
  string S;
  cin >> S;
  reverse(S.begin(),S.end()) ;
  
  string devide[4] ={"dream","dreamer","erase","eraser"};
  rep(i,4) reverse(devide[i].begin(),devide[i].end()) ;
  
  bool can = true;
  for(int i=0;;i<S.size()){
    bool can2 = false  ;
    rep(j,4){
      string d = devide[j] ;
      if(S.substr(i,d.size()) == d){
        can2 = true ;
        i += d.size() ;
      }
    }
    if(!can2){
      can = false ;
      break;
    }
    if(i== S.size())
      break;
  }
  if(can)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
      

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

map<ll,int> prf(ll n){
  map<ll,int> ret;
  for(ll i=2;i*i<=n;i++){
    while(n%i==0){
     ret[i]++;
      n/=i;
    }
  }
  if(n!=1){
    ret[n]=1;
  }
  return ret;
}


int main(){cout<<fixed<<setprecision(10);
		   int n,h,w;
           cin>>n>>h>>w;
           n++;
           cout<<(n-w)*(n-h)<<endl;
}

Measured memory_bytes: 3524
#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()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;



void solve(){
	ll n;
	cin>>n;
	vll A(n);
	for(int i=0;i<n;i++) cin>>A[i];
	cout<<accumulate(all(A),0LL)-n;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


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

int main()
{
    int r, d, x, tmp;

    cin >> r >> d >>x;

    for(int i = 0;i < 10;i++){
        x = r * x - d;
        cout << x <<"\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int x,y;
	long long sum = 0;
	cin>>n;
	for(int i = 0; i < n; i++){
		cin>>x>>y;
		sum += y-x+1;
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int N=20005;
long long n,k,w,k1,t,cnt,p,p1[N],kl[N],l[N],r[N],v[N];
int main()
{
	scanf("%d",&n);
	k=1;
	if(n==1)
	{
		printf("2 1\n1 2 0\n");
		return 0;
	}
	t=1;
	while(t*2<=n)
	{
		l[++cnt]=k;
		r[cnt]=k+1;
		v[cnt]=0;
		l[++cnt]=k;
		r[cnt]=k+1;
		v[cnt]=t;
		k++;
		t=t*2;
	}
	k1=k;
	n=n-t;
	w=t;
	while(n>0)
	{
		t=1;
		k=1;
		while(t*2<=n) 
			t=t*2,k++;
		l[++cnt]=k;
		r[cnt]=k1;
		v[cnt]=w;
		w=w+t;
		n=n-t;
	}
	printf("%d %d\n",k1,cnt);
	for(int i=1;i<=cnt;i++)
		printf("%d %d %d\n",l[i],r[i],v[i]);
	return 0;
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 2e5 + 10;

int n, q, a[MAXN], cnt[MAXN];
pii weed[MAXN<<2];
int nut[MAXN<<2];

void plant(int v, int b, int e){
	if (e - b == 1){
		weed[v] = {0, 1};
		return;
	}

	int mid = b + e >> 1;
	plant(v<<1, b, mid);
	plant(v<<1^1, mid, e);
	weed[v].S = 0;
	weed[v].F = min(weed[v<<1].F, weed[v<<1^1].F);
	if (weed[v<<1].F == weed[v].F) weed[v].S += weed[v<<1].S;
	if (weed[v<<1^1].F == weed[v].F) weed[v].S += weed[v<<1^1].S;
}

void absorb(int v){
	if (!nut[v]) return;
	nut[v<<1] += nut[v];
	nut[v<<1^1] += nut[v];
	weed[v<<1].F += nut[v];
	weed[v<<1^1].F += nut[v];
	nut[v] = 0;
}

void water(int v, int b, int e, int l, int r, int val){
	if (v == 1) l++, r++;
	if (l <= b && e <= r){
		nut[v] += val;
		weed[v].F += val;
		return;
	}
	if (r <= b || e <= l) return;

	int mid = b + e >> 1;
	absorb(v);
	water(v<<1, b, mid, l, r, val);
	water(v<<1^1, mid, e, l, r, val);
	weed[v].S = 0;
	weed[v].F = min(weed[v<<1].F, weed[v<<1^1].F);
	if (weed[v<<1].F == weed[v].F) weed[v].S += weed[v<<1].S;
	if (weed[v<<1^1].F == weed[v].F) weed[v].S += weed[v<<1^1].S;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> q;
	for (int i = 0; i < n; i++){
		cin >> a[i], a[i]--;
		cnt[a[i]]++;
	}
	plant(1, 0, n);
	for (int i = 0; i < n; i++)
		water(1, 0, n, i-cnt[i], i, 1);

	while (q--){
		int x, y; cin >> x >> y, x--, y--;
		water(1, 0, n, a[x]-cnt[a[x]], a[x], -1);
		cnt[a[x]]--;
		water(1, 0, n, a[x]-cnt[a[x]], a[x], 1);
		a[x] = y;
		water(1, 0, n, a[x]-cnt[a[x]], a[x], -1);
		cnt[a[x]]++;
		water(1, 0, n, a[x]-cnt[a[x]], a[x], 1);
		if (weed[1].F)
			cout << "0\n";
		else
			cout << weed[1].S << "\n";
	}
	return 0;
}


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

using namespace std;

main(){
	int a,b;
	cin >>a>>b;
	if(a>b){
		printf("%d\n",a-b);
	}
	else if(b>a){
		printf("%d\n",b-a);
	}
	else{
		printf("%d\n",a-b);
	}
}


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

int main()
{
    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int max_A = F / (100 * A);
    int max_B = F / (100 * B);
    int max_C = F / C;
    int max_D = F / D;
    int ans_all = 0;
    int ans_sugar = 0;
    double max_dgree = 0.0;

    for (int a = 0; a <= max_A; a++)
    {
        for (int b = 0; b <= max_B; b++)
        {
            int tmp_water = 100 * A * a + 100 * B * b;
            for (int c = 0; c <= max_C; c++)
            {
                for (int d = 0; d <= max_D; d++)
                {
                    int tmp_sugar = C * c + D * d;
                    int tmp_all = tmp_water + tmp_sugar;
                    if (tmp_all == 0)
                        continue;
                    if (tmp_all > F)
                        continue;
                    if (tmp_sugar > tmp_water / 100 * E)
                        continue;
                    if ((double)tmp_sugar / tmp_all >= max_dgree)
                    {
                        max_dgree = (double)tmp_sugar / tmp_all;
                        ans_all = tmp_all;
                        ans_sugar = tmp_sugar;
                    }
                }
            }
        }
    }

    cout << ans_all << " " << ans_sugar << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	char a[110][110],s[110][110],hoge[3];
	int h,w,i,j;
	scanf("%d%d",&h,&w);
	for(i=0;i<h;i++){
		scanf("%s",s[i]);
	}
	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++){
			a[i][j]='#';
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			a[i+1][j+1]=s[i][j];
		}
	}
	for(i=0;i<=h+1;i++){
		for(j=0;j<=w+1;j++)printf("%c",a[i][j]);
		puts("");
	}
	return 0;
}


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

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define ll long long
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9;
ll INF = 2e18;
const ll mod = 1e9+7;
string k;
int D, len;
ll dp[10005][105][2];

ll solve(int idx, int rem, int isSmaller){
	if(idx==len){
		return rem==0;
	}
	ll & ret = dp[idx][rem][isSmaller];
	if(ret!=-1){
		return ret;
	}
	int limit;
	if(isSmaller){
		limit = 9;
	}else{
		limit = k[idx]-'0';
	}
	ret = 0;
	for(int i=0;i<=limit;++i){
		int ns;
		if(i<k[idx]-'0'){
			ns = 1;
		}else{
			ns = isSmaller;
		}
		ret += solve(idx+1,(rem+i)%D,ns);
		ret %= mod;
	}
	return ret;
}

int main(){
	rep(x,10001){
		rep(y,102){
			dp[x][y][0] = dp[x][y][1] = -1;
		}
	}
	cin >> k;
	cin >> D;
	len = k.length();
	ll ans = solve(0, 0, 0);
	cout<<(ans-1+mod)%mod<<endl;
	return 0;
}

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


int main() {
    int H,W;cin >> H >> W;
    vector<string> C(H);
    rep(i,H){
        string s;cin >> s;
        C.at(i) = s;
    }
    vector<string> ans(2*H);
    for (int i = 0;i < 2*H;i++){
        string s;s = C.at(i/2);
        ans.at(i) = s;
    	cout << s << endl;
    }

}       

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
#define GCD(x,y)  __gcd(x, y)
#define endl "\n"
using namespace std;
const int maxn = 1e5 * 3;
//int vis[maxn];
//int indegree[maxn];
//vector<int> graph[maxn];
//vector<int> order;
/**
int gx[]= {2,2,-2,-2,1,-1,1,-1};
int gy[] ={1,-1,1,-1,2,2,-2,-2};

void DFS(int a,bool tpsort){
        vis[a] = 1;
    for(int i=0;i<graph[a].size();i++){
        int r = graph[a][i];
            if(vis[r]==0){
                DFS(r,tpsort);
            }
    }
    if(tpsort)order.push_back(a);
}

int vis[maxn],l[maxn],l2[maxn];
vector<int> graph[maxn];
vector<int> cst[maxn];
int mx,ans;
void BFS(int root){
    memset(vis,0,sizeof(vis));
    memset(l,0,sizeof(l));
    vis[root] = 1;
    l[root] = 0;
    queue <int> q;
    ans = 0;
    mx = root;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l[r] = l[cur] + cst[cur][i];
                if(l[r]>ans){
                    ans = l[r];
                    mx = r;
                }
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}
void ultapoth(int root){
    memset(vis,0,sizeof(vis));
    memset(l2,0,sizeof(l2));
    vis[root] = 1;
    l2[root] = 0;
    queue <int> q;
    q.push(root);
    while(!q.empty()){
        int cur = q.front();
        q.pop();
        int p = graph[cur].size();
        for(int i=0;i<p;i++){
            int r = graph[cur][i];
            if(vis[r]==0){
                vis[r] = 1 ;
                l2[r] = l2[cur] + cst[cur][i];
                q.push(r);
            }
        }
    }
   // cout<< ans <<endl;
}
**/
int main(){
    fast
    string a;
    int ans,n;
        cin>>n>>a;
    int cnr = 0,pos[maxn];
    for(int i=n-1;i>=0;i--){
        if(a[i]=='R'){
            pos[cnr] = i;
            cnr++;
        }
    }
    int cnt = 0,j = 0;
    for(int i=0;i<n;i++){
        if(a[i]=='W' && cnr>0){
            swap(a[i],a[pos[j++]]);
            cnt++;
            cnr--;
        }
        else cnr--;
    }
        cout<< cnt <<endl;



    return accepted;
}


Measured memory_bytes: 4456
ss = input()
tt = input()
ans = ''
for i in range(len(ss)-len(tt)+1):
    flag = True
    for s,t in zip(ss[i:],tt):
        if s != '?' and s != t:
            flag = False
            break
    if flag:
        ans = ss[:i] + tt + ss[i+len(tt):]

if ans !='':
    print(ans.replace('?','a'))
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3060
void main()
{
    long n = rdElem;
    long[string] lists;
    long cnt;
    foreach (i; 0 .. n)
    {
        string s = rdStr;
        ++lists[s];
        cnt = max(cnt, lists[s]);
    }

    string[] results;
    foreach (x; lists.byKeyValue)
    {
        if (x.value == cnt) results ~= x.key;
    }

    results.sort!"a < b";
    foreach (x; results)
    {
        x.writeln;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 28540
// AOJ ITP2_9_D Set Symmetric Difference
// 2019.3.8 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()   // 非負整数の入力
{
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void out(int n)    // 非負整数の表示　最後に改行あり
{
	int i;
	char ob[20];

	if (!n) pc('0');
	else {
		//		if (n < 0) pc('-'), n = -n;
		i = 0; while (n) ob[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(ob[i]);
	}
	pc('\n');
}

#define INF 1000000001
int n, m;
int a[200002], b[200002];

int main()
{
	int i, j;

	n = in();
	for (i = 0; i < n; i++) a[i] = in();
	a[i] = INF;
	m = in();
	for (j = 0; j < m; j++) b[j] = in();
	b[j] = INF;
	i = j = 0; while (1) {
		while (a[i] < b[j]) out(a[i++]);
		while (b[j] < a[i]) out(b[j++]);
		if (a[i] == INF) break;
		if (a[i] == b[j]) i++, j++;
	}
	return 0;
}


Measured memory_bytes: 3148
// AtCoder Regular Contest 070
// F - HonestOrUnkind

#include <cstdio>
#include <vector>
#define MAX_N 4000
using namespace std;
typedef long long int ll;


int A, B, N;
vector<int> path;
bool is_honest[MAX_N];

bool ask(int a, int b) {
  char c;

  printf("? %d %d\n", a, b);
  fflush(stdout);
  scanf("%*c%c", &c);
  return (c == 'Y');
}

int main() {

  scanf("%d%d", &A, &B);
  if (A <= B) {
    printf("Impossible\n");
    return 0;
  }
  N = A + B;

  for (int i = 0; i < N; i++) {
    if (path.empty()) {
      path.push_back(i);
      continue;
    }
    if (ask(path.back(), i)) {
      path.push_back(i);
    } else {
      path.pop_back();
    }
  }

  for (int i = 0; i < N; i++) {
    is_honest[i] = ask(path.back(), i);
  }

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


  return 0;

}




Measured memory_bytes: 724