akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bitset>

using namespace std;
//using Graph = vector<vector<int>>;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
/*LL yaku(int x){
    vector<pair<LL, LL> a=[];
    LL xh;
    if(x==1){
        pair<LL, LL> tmp;
        tmp=MP(1,1);
        return tmp;
    }
    else{
        FOR(i, 1, x/2+1){
            if(x%i==0){
                a.append(MP(i,x/i));
            }
        }
    }
    return a;

}*/
LL cul(int a, int b){
    LL f = pow(a,4)+pow(a,3)*b+pow(a,2)*pow(b,2)+a*pow(b,3)+pow(b,4);
    return f;
} 
int main(){
   int cnt , a, b, c;
   cin >> a >> b >> c;
   cnt = 0;
   FOR(i, a, b+1){
       if(c%i==0) cnt++;
   }
   cout << cnt << endl;
}
    





Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> l(n);
    rep(i, n) cin >> l[i];
    sort(ALL(l), greater<int>());
    rep(i, n)
    {
        for (int k = i + 1; k < n - 1; k++)
        {
            for (int j = k + 1; j < n; j++)
            {
                if (l[i] < l[k] + l[j])
                    ans++;
                else
                    break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*
 * Author : Pranav Krishna (aka) tourpran
 */
#include <bits/stdc++.h> 
#include <algorithm>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define ll long long
#define testcase ll t;cin>>t;while(t--)
#define gcd(a,b) __gcd((a),(b))
#define fast() ios::sync_with_stdio(0);

const int mod=1e9+7;

int main() 
{
    fast()
    ll a,b;
    cin>>a>>b;
    ll tot = ((a*3)+b)/2;
    cout<<tot<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18

using namespace std;

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  
  
  
  int a[26] = {};
  for (int i = 0; i < n; i++){
    a[s[i]-'a']++;
  }
  ll ans = 1;
  for (int i = 0; i < 26; i++){
    ans = ans * (a[i] + 1) % MOD;
  }

  ans--;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s, t;
    cin >> s >> t;
    int ans = t.size() + 2;
    for(int i = 0; i <= s.size() - t.size(); i++){
        int p = 0;
        for(int j = 0; j < t.size(); j++)
            if(t.at(j) != s.at(i + j))
                p++;
        ans = min(ans, p);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<deque>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

ll mpow(ll i, ll j)
{
    if (j == 0) return 1;
    ll res = mpow(i, j / 2) % MOD;
    res = (res * res) % MOD;
    return (j & 1) ? (res * i) % MOD : res;
}

ll mcomb(ll n, ll i)
{
  ll bunbo = 1, bunsi = 1;
  ll k = i;
  rep(j, k) {
    bunbo *= n % MOD;
    bunsi *= i % MOD;
    bunbo %= MOD; bunsi %= MOD;
    n--; i--;
  }
  // フェルマーの小定理をつかう
  // x ^ (p-1) == 1 (mod p) ---> x ^ (p-2) == 1/x (mod p)
  return (bunbo * mpow(bunsi, MOD - 2)) % MOD;
}

int main(void)
{
    int n, a, b;

    cin >> n >> a >> b;

    ll total = mpow(2, n) - 1; // 0本選ぶはカウントしない
    ll result = (total - mcomb(n, a) - mcomb(n, b)) % MOD;
    // 計算途中でもあまりとってよい、ただし最終結果が負になるなら MOD を足す
    result = result < 0 ? result + MOD : result;

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
T =[]
S = ""
while n>0:
  if n%26==0:
    T.insert(0, 26)
    n = n//26 -1 
  else:
    T.insert(0, n%26)
    n = n//26
for t in T:
  S += chr(t+96)
print(S)

Measured memory_bytes: 9052
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll M,K;cin>>M>>K;
    
	// 解法
    vector<ll> a;
    ll len_a = pow(2,M+1);
    if (K>=pow(2,M)){// K>=2**Mの時は解なし, 2**M未満の数のXORは2**M未満なので
        a.pb(-1);
    }
    else if (M==0){// aは一意 = [0,0]
        if (K==0){
            REP(i,len_a) a.pb(0);
        }
        else a.pb(-1);
    }
    else if (M==1){
        if (K==0){// K=0の時のみ解あり a = [0,0,1,1]
            a.pb(0);a.pb(0);a.pb(1);a.pb(1);
        }
        else a.pb(-1);
    }
    else{//K>=2の場合
        // 0<=K, K<2**MのKで常に解あり
        // b = K以外の0-2**Mの昇順, c= K以外の0-2**Mの降順として
        // bKcKで条件成立する
        // a = bKcKの作成
        vector<ll> b, c;
        REP(i,pow(2,M)){
            if (i!=K){
                b.pb(i);
                c.pb(i);
            }
        }
        sort(c.begin(), c.end(), greater<ll>());
        REP(i,b.size()) a.pb(b[i]);
        a.pb(K);
        REP(i,b.size()) a.pb(c[i]);
        a.pb(K);
    }
	//出力
    REP(i,a.size()){
        printf("%lld ", a[i]);
    }
    printf("\n");
}


Measured memory_bytes: 4460
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
  int N;
  cin >> N;
  for(int i=1;i<=N;i++){
    if(i % 3 == 0){
      cout << " " << i;
    }else{
      int x = i;
      while(x){
        if(x % 10 == 3){
          cout << " " << i;
          break;
        }else {
          x /= 10;
        }
      }
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <time.h>
#include <stdlib.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ull unsigned long long
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define clr(x) x.clear()
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define hell 1000000007
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define all(a) a.begin(),a.end()
#define ign cin.ignore();

#define o_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define o_setll tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

using namespace std;
using namespace __gnu_pbds;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main()
{
    IOS
    int n,m;
    cin>>n>>m;
    int res=(n*(n-1))/2+(m*(m-1))/2;
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
dif = 10**10
ans = 0
for i in range(n):
    z = t-h[i]*0.006
    if dif>abs(a-z):
        dif = abs(a-z)
        ans = i+1
print(ans)

Measured memory_bytes: 9008
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n;cin>>n;
    vl l(n);
    rep(i,n)cin>>l[i];
    sort(been(l));
    ll ans =0;
    rep(i,n){
        rep2(j,i+1,n){
            rep2(k,j+1,n){
                if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k])continue;
                if(l[i]+l[j]>l[k])ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void) {
	int N;
	if (scanf("%d", &N) != 1) return 1;
#if 0
	printf("AB%c%03d\n", 'C' + (N >= 1000), N - (N >= 1000 ? 999 : 0));
#else
	printf("AB%c\n", 'C' + (N >= 1000));
#endif
	return 0;
}


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

using namespace std;

int main() {
	vector<int> a(5);
	for (int i=0; i<5; ++i) {
		cin >> a[i];
	}
	vector<int> b(5);
	for (int i=0; i<5; ++i) {
		b[i] = (10-(a[i]%10))%10;
	}
	int sum = accumulate(a.begin(), a.end(), 0);
	int wsum = accumulate(b.begin(), b.end(), 0);
	int max = *max_element(b.begin(), b.end());
	//cout << "max " << max << endl;
	wsum = wsum - max;
	sum += wsum;
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
i = list(map(lambda x: int(x), input().split(" ")))
count = 0
h = list()
c = [0 for i in range(0, i[1]+1)]
while count < i[0]:
    l = list(map(lambda x: int(x), input().split(" ")))
    l.append(sum(l))
    h.append(l)
    for j, c_ in enumerate(l):
        c[j] += c_
    count += 1
for r_ in h:
    print("%d" % r_[0], end="")
    for c_ in r_[1:]:
        print(" %d" % c_, end="")
    print("")

print("%d" % c[0], end="")
for c_ in c[1:]:
    print(" %d" % c_, end="")
print("")

Measured memory_bytes: 6860
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define MX 1000000007

struct rec
{
	ll b;
	ll w;
};
rec NX = {1,1};

rec sm(rec a,rec b)
{
	a.b=(a.b*b.w)mod;
	a.w=(a.w*(b.w+b.b)mod)mod;
	return a;
}

rec dfs(vector<ll> adj[],bool vis[],ll x)
{
	vis[x]=1;
	rec tmp = NX;
	ll k,n = adj[x].size();
	int cnt=0;
	for(ll i = 0;i<n;++i)
	{
		k = adj[x][i];
		if(vis[k]==0)
		{
			tmp = sm(tmp,dfs(adj,vis,k));
		}
	}
	return tmp;
}

int main()
{
	IOS;
	ll n,i,x,y;
	cin>>n;
	vector<ll> adj[n+1];
	bool vis[n+1];
	MS0(vis);
	FOR(i,n-1)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	rec ans = dfs(adj,vis,1);
	cout<<((ans.b+ans.w)mod);

}

Measured memory_bytes: 16080
f=[0 for i in range(10**4 + 1)]



for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if (x**2 + y**2 + z**2 + x*y+y*z+x*z) < len(f):
                f[x**2 + y**2 + z**2 + x*y+y*z+x*z]+=1

N=int(input())
for i in range(1,N+1):
    print(f[i])

Measured memory_bytes: 69576
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll v1 = (c+b-1) / b;
    ll v2 = (a+d-1) / d;
    if(v1 <= v2){
        print("Yes");
    }else{
        print("No");
    }

}

Measured memory_bytes: 3600
a, b, c = map(int, input().split())
cnt = 0
while True:
    if a % 2 or b % 2 or c % 2:
        break
    if a == b == c:
        cnt = -1
        break
    a, b, c = b // 2 + c // 2, c // 2 + a // 2, a // 2 + b // 2
    cnt += 1
print(cnt)

Measured memory_bytes: 3060
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
//#define f_(i,a,b) for (int i=a;i>=b;i--)
//#define f(i,a,b) for (int i=a;i<=b;i++)

ll n,s,ans;
bool misketa;
ll f(ll b,ll x) {
	if (x<b) return x;
	else return f(b,x/b)+x%b;
}
int main() {
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin>>n>>s;
	misketa=false;
	if (n==s) {
		printf("%lld", n+1);
		return 0;
	}
	for (long long i=1;i*i<=(n-s);i++) {
		if ((n-s)%i==0) {
			if (f(i+1,n)==s) {
				if (!misketa) {
					misketa=true;
					ans=i+1;
				}
				else if (ans>i+1) ans=i+1;
//				cout<<i+1;
//				cout<<" "<<i;
//				return 0;
			}
			if (f((n-s)/i+1,n)==s) {
				if (!misketa) {
					misketa=true;
					ans=(n-s)/i+1;
				}
				else if (ans>i+1) ans=(n-s)/i+1;
//				cout<<(n-s)/i+1;
//				cout<<" "<<n-s<<" "<<i;
//				return 0;
			}
		}
	}
	if (misketa) printf("%lld", ans);
	else printf("-1");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
    
    int h, w, i;
    while (cin >> h >> w, h or w) {
        for (i = 0; i < h; i++) {
            if (i == 0 or i == h - 1) cout << string(w, '#') << "\n";
            else cout << '#' << string(w - 2, '.') << "#" << "\n";
        }
        cout << "\n";
    }
    return 0;
}


Measured memory_bytes: 3160
class UnionFind:
    def __init__(self, size):
        self.parent = list(range(size))
        self.height = [0] * size
        self.size = [1] * size
        self.component = size

    def root(self, index):
        if self.parent[index] == index:  # 根の場合
            return index
        rootIndex = self.root(self.parent[index])  # 葉の場合親の根を取得
        self.parent[index] = rootIndex  # 親の付け直し
        return rootIndex

    def union(self, index1, index2):  # 結合
        root1 = self.root(index1)
        root2 = self.root(index2)

        if root1 == root2:  # 連結されている場合
            return

        self.component -= 1  # 連結成分を減らす

        if self.height[root1] < self.height[root2]:
            self.parent[root1] = root2  # root2に結合
            self.size[root2] += self.size[root1]
        else:
            self.parent[root2] = root1  # root1に結合
            self.size[root1] += self.size[root2]
            if self.height[root1] == self.height[root2]:
                self.height[root1] += 1
        return

    def isSameRoot(self, index1, index2):
        return self.root(index1) == self.root(index2)

    def sizeOfSameRoot(self, index):
        return self.size[self.root(index)]

    def getComponent(self):
        return self.component

N, M = map(int, input().split())
INF = 10**18
tree = UnionFind(N)

edges = [[] for _ in range(N)]
for _ in range(M):
    fr, to, d = map(int, input().split())
    fr -= 1
    to -= 1
    edges[to].append((fr, d))
    edges[fr].append((to, -d))
    tree.union(fr, to)

minDist = [INF] * N
for start in range(N):
    if tree.root(start) != start:
        continue
    st = [(start, 0)]
    while st:
        now, dist = st.pop()

        if minDist[now] == dist:
            continue

        if minDist[now] != INF and minDist[now] != dist:
            print('No')
            exit()
        minDist[now] = dist

        for to, d in edges[now]:
            if minDist[to] == d + dist:
                continue
            st.append((to, dist + d))

print('Yes')


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

int main(){
    string n;
    cin >> n;
    bool ans = false;
    for(int i = 0; i < n.size();i++){
        if(n.at(i) == '7'){
            ans = true;
            break;
        }
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3596
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    ans=K*pow(K-1,N-1)
    print(ans)

main()


Measured memory_bytes: 38256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(i, K+1):
        for k in range(j, K+1):
            #print(i,j,k)
            if i == j == k:
                ans = ans + gcd(i,j,k)
            elif i == j or j == k or i == k:
                ans = ans + gcd(i,j,k)*3
            else:
                ans = ans + gcd(i,j,k)*6

print(ans)


Measured memory_bytes: 9572
n,k = map(int, input().split())
a = list(map(int, input().split()))
tot = 0
for i in range(1,n):
  if a[i-1] + a[i] > k:
    c = min(a[i],a[i]+a[i-1]-k)
    tot += c
    a[i] -= c
    if a[i-1]+a[i] > k:
      d = a[i-1]-k
      tot += d
      a[i-1] -= d
print(tot)

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = min(a, k); k -= min(a, k);
    k -= min(b, k);
    ans -= min(c, k);
    cout << ans << '\n';

    return 0;
}

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


int main(){
  string s;cin>>s;
  vector<int>v;
  int n=s.size(),m=0;
  vector<int>ans(n,0);
  rep(i,n-1){
    if(s[i]=='L'&&s[i+1]=='R')v.push_back(i);
  }
  v.push_back(n-1);
  rep(i,v.size()){
    int k=v[i];
    if(i>0)m=v[i-1]+1;
    int j=m;
    while(j<n){
      if(s[j]=='L')break;
      j++;
    }
    if((j-1-m)%2==1){
      ans[j-1]=(k-m+1)/2;
      ans[j]=(k-m+1)-ans[j-1];
    }
    else{
     ans[j]=(k-m+1)/2;
      ans[j-1]=(k-m+1)-ans[j];
    } 
  }
  rep(i,n){
    if(i)cout<<' ';
    cout<<ans[i];
  }
  cout<<endl;
}

Measured memory_bytes: 1280
N, X, Y = map(int, input().split())


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    if i in dic:
        print(dic[i])
    else:
        print(0)


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

int main(){
    string x;
    cin >> x;
    stack<char> s;
    for(int i = 0;i < x.size();i ++){
        if(x[i]=='S') s.push(x[i]);
        else if(x[i]=='T'&&(s.empty()||s.top()=='T')) s.push(x[i]);
        else s.pop(); 
    }
    cout << s.size() << endl;
    return 0;
}

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

int n;
int a[111111];
int c[111111];

int main(){
  int f = 0;  

  scanf(" %d",&n);
  for(int i=1;i<=n;i++){
    scanf(" %d",&a[i]);
    if(a[i] == 2){
      f = 1;
    }
  }
  
  
  if(f){
    int cnt = 0;
    int now = 1;

    while(1){
      
      if(now == 2){
        printf("%d\n",cnt);
        break;
      }
      
      if(c[now] == 1){
        printf("-1\n");
        break;
      }
     
      c[now] = 1;
      now = a[now];
      cnt++;
      
    }
  
  } else {
    printf("-1\n");
  }
  
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n;
    bool flag=true;
    cin >> n;
    int k=n%4;
    for(int i=0;i<4;i++){
        if(k==0){
        }else if(k==i){
            if(n<7*(4-i)){
                flag = false;
            }
        }
    }
    if(flag==true){
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <stdio.h>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

const int MAX = 200100;
const int MOD = 1000000007;

ll 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;
    }
}
ll 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;
}

signed main(){
    COMinit();
    int n,m; cin >> n >> m;
    //素因数分解
    map<int,int> mp;
    for(int i=2;i*i<=m;i++){
        while(m%i==0){
            mp[i]++;
            m/=i;
        }
    }
    if(m!=1) mp[m]++;
    //
    ll ans=1;
    for(auto itr=mp.begin();itr!=mp.end();++itr){
        int p=itr->se;
        ans*=COM(n-1+p,p);
        ans%=MOD;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

# n, k = map(int, input().split())
n = getInputInt()

ans = 0

flg = True
i=0
while(flg):
    tmp = pow(-2,i+1)
    if n % tmp != 0:
        ans+=pow(10,i)
        n -= pow(-2,i)

    if n==0:
        flg=False
    i+=1

print(ans)

Measured memory_bytes: 13668
#E
N,W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())
w=[0]+w
v=[0]+v
INF=float('inf')
dp=[[INF for i in range(N+1)] for j in range(10**5+1)]
dp[0][0]=0
for i in range(1,N+1):
    for j in range(10**5+1):
        if j-v[i]>=0:
            dp[j][i]=min(dp[j-v[i]][i-1]+w[i],dp[j][i-1])
        else:
            dp[j][i]=dp[j][i-1]
t=True
n=1
while t:
    if dp[-n][N]<=W:
        print(10**5-n+1)
        t=False
    else:
        n+=1

Measured memory_bytes: 292096
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let l: f64 = read();
    let p = l / 3_f64;
    println!("{}", p * p * p);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll int x;
  cin>>x;
  ll int ans;
  ll int num = x/500;
  ans = ans+(num*1000);
  x = x-(num*500);
  num = x/5;
  ans = ans + (num*5);
  cout<<ans;
}
  
  

Measured memory_bytes: 256
//https://www.geeksforgeeks.org/number-of-n-length-sequences-whose-product-is-m/

#include <bits/stdc++.h> 

using namespace std; 

const long long mod = 1e9 + 7ll ;
 
const int MAX = 4e5 + 5 ;

long long modpower(long long a , long long b)
{
    if(b == 0)
        return 1ll ;
    long long x = modpower(a , b / 2ll) ;
    x = (x * x) % mod ;
    if(b & 1)
        return (x * a) % mod ;
    return (x % mod) ;
}
 
struct combination
{
    vector<long long>fact , inv ;
    combination(int sz) : fact(sz + 1) , inv(sz + 1)
    {
        fact[0] = 1ll ;
        inv[0] = 1ll ;
        for(long long i = 1 ; i <= sz ; ++i)
        {
            fact[i] = (fact[i-1] * i) % mod ;
            inv[i] = modpower(fact[i] , mod - 2ll) ;
        }
    }
    long long choose(int n , int k) const
    {
        if(k < 0 || n < k)
            return 0 ;
        return ((((fact[n] * inv[k]) % mod) * inv[n - k]) % mod) ;
    }
};

combination table(MAX) ;

int NoofSequences(int N, int M) 
{ 
	map<int, int> prime; 
	for (int i = 2; i * i <= M; ++i) 
	{ 
		while (M % i == 0) 
		{ 
			prime[i]++; 
			M /= i; 
		} 
	} 
	if (M > 1) 
		prime[M] += 1; 
	long long ans = 1ll ;
	for (auto it : prime) 
	{
		ans = (ans * (table.choose(N + it.second - 1, N - 1))) % mod; 
		ans %= mod ;
	}
	return ans; 
} 

int main() 
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , m ;
	cin>>n>>m ;
	return cout<<NoofSequences(n, m) % mod<<"\n" , 0; 
} 

Measured memory_bytes: 6656
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

string shift(string s){
    string t = "";
    t += s[s.size()-1];
    for(int i = 0; i < s.size()-1; i++){
        t += s[i];
    }
    return t;
}

int main(){
    string s, t;
    cin >> s >> t;
    string shifted = s;
    bool ans = false;
    for(int i = 0; i < s.size(); i++){
        shifted = shift(shifted);
        ans |= shifted == t;
    }
    if(ans){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//team yglance+xhwl+TTD
#include<bits/stdc++.h>
typedef long long ll;
const ll mod=1e9+7;
const ll maxn=1e5+7;
const double pi=acos(-1);
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int t;
    cin>>t;
    if(t)
    {
    	cout<<0<<endl;
	}
	else
	{
		cout<<1<<endl;
	}
 	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <numeric>
#include <bits/stdc++.h>
using namespace std;
// long long -> lint
using lint = long long;
// fast cin and cout from hitonanode-san's code
// w/o 71 ms -> w/ 18 ms (tested on ABC148-D with C++14(GCC 5.4.1))
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

int main(){
    // input
    lint N;
    cin >> N;

    lint ans = 0;
    for ( lint i = 1; i <= N; i++ ){
        if( i%3 == 0 ) continue;
        if( i%5 == 0 ) continue;
        ans += i;
    }

    // out
    cout << ans << endl;
} 

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int ans = 0;
		int now = 0;
		int bef = -1;
		for(int i = 0;i < N;i++) {
			int a = scn.nextInt();
			if(bef >= a) {
				now++;
			}else {
				ans = Math.max(ans, now);
				now = 0;
			}
			bef = a;
		}
		ans = Math.max(ans, now);
		System.out.println(ans);
	}

}

Measured memory_bytes: 47648
import math
a,b,x=map(int,input().split())
c=(2*x-b*(a**2))/a**2
ans=0
if c>=0:
    ans=90-math.degrees(math.atan2(a,b-c))
else:
    d=2*x/(a*b**2)
    ans=90-math.degrees(math.atan2(2*x,a*b**2))
print(ans)

Measured memory_bytes: 3060
module kkk
  sub main()
    
    dim n as integer = Integer.Parse(Console.ReadLine)
    dim p() as integer = Array.ConvertAll(Of String, Integer)(Console.ReadLine.Split(" "), AddressOf Integer.Parse)
    
    dim i as long
    dim cnt as long
    dim max as long
    
    max = p(0)
    
    for i = 0 to n - 1
    if max >= p(i) then
      max = p(i)
      cnt = cnt + 1
    end if
    
    
    
next

console.writeline(cnt)

end sub
end module
    
    
    
      

Measured memory_bytes: 33116
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if ((A + B) % 2 == 1) {
		cout << "IMPOSSIBLE" << endl;
	}
	else {
		int K = (A + B) / 2;
		cout << K << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <queue>
#include <functional>

using namespace std;

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

const long long INF = 10000000000ll;

typedef pair<long long, int> pli;

vector<int> g[100000];
int dang[100000];
bool zombie[100000];

int main() {
	int n, m, k, s;
	long long p, q;
	cin >> n >> m >> k >> s;
	cin >> p >> q;
	
	priority_queue<pli> que; // ttl, v;
	
	REP(i, k) {
		int c;
		scanf("%d", &c);
		c--;
		zombie[c] = true;
		que.push(pli(s, c));
	}
	
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	fill(dang, dang + n, -1);
	while (!que.empty()) {
		pli now = que.top();
		que.pop();
		
		int pos = now.second;
		int ttl = now.first;
		
		if (dang[pos] >= ttl) continue;
		dang[pos] = ttl;
		
		REP(i, g[pos].size())
			que.push(pli(ttl - 1, g[pos][i]));
	}
	dang[0] = -1;
	dang[n - 1] = -1;
	
	// dijkstra
	vector<long long> d(n, INF);
	priority_queue<pli, vector<pli>, greater<pli> > que2;
	que2.push(pli(0, 0)); // cost, v
	
	while (!que2.empty()) {
		pli now = que2.top();
		que2.pop();
		
		int pos = now.second;
		long long cost = now.first;
		
		if (d[pos] <= cost) continue;
		d[pos] = cost;
		
		REP(i, g[pos].size()) {
			int to = g[pos][i];
			
			if (zombie[to]) continue;
			
			if (dang[to] != -1) que2.push(pli(cost + q, to));
			else que2.push(pli(cost + p, to));
		}
	}
	d[n - 1] -= p;
	
	cout << d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 11784
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    long res = 0;
    for (int i = 1; i <= k; i++) {
      for (int j = i; j <= k; j++) {
        for (int l = j; l <= k; l++) {
          if (i < j && j < l) {
            res += gcd(i, gcd(j, l)) * 6;
          } else if (i < j && j == l) {
            res += gcd(i, gcd(j, l)) * 3;
          } else if (i == j && j < l) {
            res += gcd(i, gcd(j, l)) * 3;
          } else {
            res += gcd(i, gcd(j, l));
          }
        }
      }
    }
    System.out.println(res);
    sc.close();
  }

  static int gcd(int a, int b) { // 最大公約数を返す
    if (a < b) return gcd (b, a);
    if (b == 0) return a;
    return gcd (b, a % b);
  }
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<vector<int>> x(N);
  vector<vector<int>> y(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    x[i].resize(A[i]);
    y[i].resize(A[i]);
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ma = -1;
  for (int i = 0; i < (1 << N); i++) {
    bool flag = true;
    for (int j = 0; j < N; j++) {
      if (!(i & (1 << j))) continue;
      for (int k = 0; k < A[j]; k++) {
        if (((i >> x[j][k]) & 1) ^ y[j][k]) flag = false;
      }
    }
    int cnt = 0;
    for (int j = 0; j < N; j++) {
      if ((i >> j) & 1) cnt++;
    }
    if (flag) ma = max(cnt, ma);
  }
  cout << ma << endl;
  return 0;
}

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


int main(){
    int N;
    std::cin >> N;
    int number = 0;
    int tmp;
    for(int i = 0; i < N; ++i){
        std::cin >> tmp;
        number |= tmp;
    }
    int lsb = 0;
    while(!(number & 1)){
        ++lsb;
        number >>= 1;
    }
    std::cout << lsb << std::endl;
}

Measured memory_bytes: 256
fun main() {
  val (D, T, S) = readInts()
  val result = D <= T * S
  println(if (result) "Yes" else "No")
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


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

const int MOD = 1000000007;
const int INF = 1e9;

long long modpow(long long a, long long n, long long mod){
  long long res = 1;
  while(n > 0){
    //nを２進数に分解してビットの立っているところだけ掛け算していく。
    if (n &  1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a inverse (mod m)
// a^(-1) = a^(p-2) (mod p)
long long modinv(long long a, long long mod){
  return modpow(a, mod-2, mod);
}

long long Comb(long long n, long long k){
  if(n < k) return 0;
  if(n < 0 || k < 0) return 0;
  // return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
  long long ans = 1;
  for(long long i = 0; i < k; i++){
    ans = ans * (n - i) % MOD;
    ans = ans * modinv(k - i, MOD) % MOD;
  }
  return ans;
}

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

  long long ans = 1;
  ans = modpow(2, n, MOD) - 1;

  long long bya = Comb(n, a);
  long long byb = Comb(n, b);
  // cout << ans << "," << bya << "," << byb << endl;
  ans -= (bya + byb);
  ans %= MOD;
  if(ans < 0) ans = (ans + MOD) % MOD;
  cout << ans << endl;
  

  return 0;
}

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

using namespace std;

int main(){
    string S;
    int N, K;
    cin >> N >> S >> K ;

    for(int i=0;i<N;i++){
        if(S.at(i) != S.at(K-1)){
            S.at(i) = '*';
        }
    }
    cout << S << endl;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int N;
    cin >> N;
    vector<int>H(N);
    for ( int i = 0; i < N; i++ ) cin >> H.at(i);
    
    int hotelCount = 0;
    for ( int i = 0; i < N; i++) {
        bool canSeeOcean = true;
        for ( int compared_i = 0; compared_i < i; compared_i++ ) {
            if ( H.at(i) < H.at(compared_i) ) {
                canSeeOcean = false;
                break;
            }
        }
        if (canSeeOcean) {
            hotelCount++;
        }
    }
    
    cout << hotelCount << endl;
    
    return 0;
}


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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n, w ;
	cin >> n >> w;

	int w1;
	vvi st(4);
	for (int i = 0; i < n; i++) {
		int w, v;
		cin >> w >> v;
		if (!i) {
			w1 = w;
		}

		st[w - w1].push_back(v);
	}

	for (int i = 0; i < 4; i++) {
		SORT(st[i]);
		st[i].push_back(0);

		reverse(ALL(st[i]));
		for (int j = 1; j < st[i].size(); j++) {
			st[i][j] += st[i][j - 1];
		}
	}

	int ret = 0;
	for (LL i = 0;  i < st[0].size(); i++) {
		for (LL j = 0; j < st[1].size(); j++) {
			for (LL k = 0; k < st[2].size(); k++) {
				for (LL l = 0; l < st[3].size(); l++) {
					LL fact = w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l;

					if (fact <= w) {
						ret = max(ret, st[0][i] + st[1][j] + st[2][k] + st[3][l]);
					}
				}
			}
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    int n;
    cin>>n;
    if(n%2==0){
        cout<<n/2<<endl;
    }else{
        cout<<n/2 +1<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll N;
    ll M,X,A[1001];
    ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N>>M>>X;
    REP(i,M){
      cin>>A[i];
      if(X<A[i])ans++;
    }
    cout<<min(ans,M-ans);

    return 0;
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

a,b,c = IL()
d,e,f = IL()
g,h,i = IL()

if b-a==e-d==h-g and c-b==f-e==i-h and a-d==b-e==c-f and d-g==e-h==f-i:
  Y()
else:
  N()


Measured memory_bytes: 38256
import sys

K=int(input())
A=list(map(int,input().split()))
import math


MIN=2
MAX=2

for a in A[::-1]:
    M1=math.ceil(MIN/a)*a
    M2=MAX//a*a

    if M1>MAX:
        print(-1)
        sys.exit()

    else:
        MIN=M1
        MAX=M2+a-1

print(MIN,MAX)

Measured memory_bytes: 14224
s=str(input())
ans=0
cnt=0
for i in s:
    if (i == 'A') or (i == 'C') or (i == 'G') or (i == 'T'):
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans = max(ans, cnt)
print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c = 2*b;
		
		if(c>=a) {
			System.out.println(0);
		}
		else {
			System.out.println(a-c);
		}
	}
}


Measured memory_bytes: 22996
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    sc.nextLine
    val s = sc.nextLine.toCharArray

    //    var count = 0
    //    var currentChar = '@'
    //    for (i <- 0 until n) {
    //      if (s(i) != currentChar) {
    //        currentChar = s(i)
    //        count += 1
    //      }
    //    }
    //currentなんてもたなくていいのか！
    var count = 1
    for (i <- 0 until n - 1) {
      if (s(i) != s(i + 1)) {
        count += 1
      }
    }
    println(count)
  }
}


Measured memory_bytes: 30984
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const S = input[0];
  let arr = [];
  for (let i = 0, l = S.length - 2; i < l; i++) {
    arr.push(S.substr(i, 3));
    // console.log(arr);
  }
  const temp = arr.reduce((x, y) => Math.abs(x - 753) < Math.abs(y - 753) ? x : y);
  const ans = Math.abs(temp - 753);
  console.log(ans);
};

main(receive);

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(){
  long long int a,b,k;
  scanf("%lld",&a);
  scanf("%lld",&b);
  if((a-b)%2==0) {
    printf("%lld\n",(a+b)/2);
  } else {
    printf("IMPOSSIBLE\n");
  }
  return 0;
}


Measured memory_bytes: 128
n,m = map(int,input().split())
mat = []
for i in range(n):
    mat.append(list(map(int,input().split())))
#ここまで情報のインプット

#基本方針はまだ扱っていない最小のお金を持つ栄養ドリンクをとっていく。
#つまりは値がちいさいものから順に在庫が切れるまで選択するということ。

ans = 0
i = 0
mat.sort()
#値でsortする
while True:
    if m - mat[i][1] > 0:
        ans += mat[i][1]*mat[i][0]
        m -= mat[i][1]
        i += 1
    else:
        ans += mat[i][0] *m
        break
print(ans)

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

template <class F>
int lower_bound(int i0, int i1, F f) {
    while (i0 < i1) {
        int i = (i0 + i1) / 2;
        if (f(i)) i1 = i; else i0 = i + 1;
    }
    return i0;
}

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

    string s;

    cout << 0 << endl;
    cin >> s;
    if (s == "Vacant") quick_exit(0);

    string t = s;
    int i0 = 1, i1 = n;

    int i = lower_bound(1, n, [&](int i) {
        cout << i << endl;
        cin >> s;
        if (s == "Vacant") quick_exit(0);
        return (s != t) ^ (i % 2 == 1); // iが大きくなるほど満たされやすくなる条件
    });

    cout << i << endl;

    return 0;
}

Measured memory_bytes: 852
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\???????????°
	int height, width;
 
	// ???????????????
	while(1) {
 
		scanf("%d %d", &height, &width);
 
		if(height == 0 && width == 0)
			break;
 
		// ???????????°??????????????????
		for(int line = 1; line <= height; line++) {
			
			for(int column = 1; column <= width; column++) {
			
				if((line % 2 == 1 && column % 2 == 1) || (line % 2 == 0 && column % 2 == 0)) {
					
					printf("#");
					
				} else if((line % 2 == 1 && column % 2 == 0) || (line % 2 == 0 && column % 2 == 1)) {
					
					printf(".");
				}
				
				if(column % width == 0) {
					
					printf("\n");
					
				}
			}
		}
		printf("\n");
	}
  	return 0;
}

Measured memory_bytes: 1796