akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <assert.h>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n;
string s;
int p;
pll expr();
pll fact(){
	if(s[p] == '('){
		++p;
		pll res = expr();
		++p;
		return res;
	}else if(s[p] == '~'){
		++p;
		pll res = fact();
		swap(res.first, res.second);
		return res;
	}else if(s[p] == 'x'){
		while(isalnum(s[p])) p++;
		return pll(1, 1);
	}else assert(false);
}


pll term(){
	pll res = fact();
	while(s[p] == '&'){
		++ p;
		pll l = res, r = fact();
		res.first  = (l.first*r.first) % MOD;
		res.second = (l.second*r.second + l.second*r.first + l.first*r.second) % MOD;
	}
	return res;
}

pll expr(){
	pll res = term();
	while(s[p] == '|'){
		++ p;
		pll l = res, r = term();
		res.first  = (l.first*r.first + l.second*r.first + l.first*r.second) % MOD;
		res.second = l.second*r.second % MOD;
	}
	return res;
}

int main(){
	ios::sync_with_stdio(false);
	cin >> s;
	p = 0;
	if(s.size() > 900000) cout << 1 << endl;
	else cout << expr().first << endl;
	
	return 0;
}

Measured memory_bytes: 2708
<?php
//error_reporting(0);
//$A = explode(" ",trim(fgets(STDIN)));
list($N,$H) = explode(" ",trim(fgets(STDIN)));
//$N=trim(fgets(STDIN));
for($i=0;$i<$N;$i++) {
  list($s[],$t[])=explode(" ",trim(fgets(STDIN)));
}
$smax = max($s);
rsort($t);
$ans = $H;
for($k=0;$k<=$N;$k++) {
  if ($k > 0) $H -= $t[$k-1];
  $cnt=0;
  if ($H>0) $cnt=ceil($H/$smax);
  $ans = min($ans,$k+$cnt);
}
printf("%d\n",$ans);


Measured memory_bytes: 39796
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

char s[MAXN+1]; int n;
int onesum[MAXN+1];

bool ok(int l,int r) {
	//printf("testing %d..%d\n",l,r);
	if(l>=r) return true;
	int len=r-l+1,ones=onesum[r+1]-onesum[l];
	return ones==0||ones==len;
}

void run() {
	scanf("%s",s); n=strlen(s);
	onesum[0]=0; REP(i,n) onesum[i+1]=onesum[i]+(s[i]=='1'?1:0);
	int ret=0;
	FORE(k,1,n) {
		int l=n-k,r=k-1;
		if(!ok(l,r)) break;
		ret=k;
	}
	printf("%d\n",ret);

}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int n, k; cin >> n >> k; k--;
    string s; cin >> s;

    s[k] += 32;
    cout << s << endl;
}

Measured memory_bytes: 256
def main():
    high, width = map(int, input().split())
    data = [list(input()) for i in range(high)]

    for i in range(high)[::-1]:
        if data[i].count('#') == 0:
            data.pop(i)

    for i in range(width)[::-1]:
        flg = 1
        for j in range(len(data)):
            if data[j][i] == '#':
                flg = 0
                break
        if flg:
            for j in range(len(data)):
                data[j].pop(i)

    for i in range(len(data)):
        print(''.join(data[i]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	cout << (1900 * m + 100 * (n - m) )* (int)pow(2, m) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int n, m;
	static int[] a, b;
	static boolean[] vis;
	static boolean[][] connect;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		a = new int[m];
		b = new int[m];
		vis = new boolean[n];
		connect = new boolean[n][n];
		for(int i = 0 ; i < m ; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			connect[a[i]][b[i]] = connect[b[i]][a[i]] = true;
		}
		vis[0] = true;
		int ans = dfs(0);
		System.out.println(ans);
	}

	public static int dfs(int x) {
		boolean all_vis = true;
		for(int i = 0 ; i < n ; i++) {
			if(!vis[i]) all_vis = false;
		}
		if(all_vis) return 1;
		int ret = 0;
		for(int i = 0 ; i < n ; i++) {
			if(vis[i]) continue;
			if(!connect[x][i]) continue;
			vis[i] = true;
			ret += dfs(i);
			vis[i] = false;
		}
		return ret;
	}

}


Measured memory_bytes: 24276
#include "stdio.h"

long long int N;
long long int T;
long long int t[200001];
long long int ans;

int main() {
	scanf("%lld %lld", &N, &T);
	ans = T;
	for (int i = 1; i <= N; i++) {
		scanf("%lld", &t[i]);
		if (i > 1) {
			if (t[i] - t[i - 1] >= T)ans += T;
			if (t[i] - t[i - 1] < T)ans += t[i] - t[i - 1];
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int X, N;
    cin >> X >> N;
    vector<int> p(N);
    REP(i, N) cin >> p[i];
    int mi = INF;
    int ans = -1;
    set<int> st;
    REP(i, 102) st.insert(i);
    REP(i, N) st.erase(p[i]);
    for(int y : st) {
        if(abs(X-y) < mi) {
            mi = abs(X-y);
            ans = y;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3660
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
b.sort()
c.sort()

bc = []
for bb in b:
    for cc in c:
        bc.append(bb + cc)
bc.sort()

from bisect import bisect_left, bisect_right

def C(x):
    # count "abc <= x"
    ret = 0
    for aa in a:
        idx = bisect_right(bc, x - aa)
        ret += idx
    return ret

kk = x * y * z - k + 1
lb = 0
ub = (10 ** 10) * 4
while ub - lb > 1:
    mid = (ub + lb) // 2
    if C(mid) >= kk:
        ub = mid
    else:
        lb = mid

kth = ub

l = []
for aa in a:
    idx = bisect_left(bc, kth - aa)
    for i in range(idx, len(bc)):
        l.append(aa + bc[i])

l.sort(reverse=True)
l = l[:k]
for ll in l:
    print(ll)


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

int main(){
  string s;
  cin >> s;
  ll res =0;
  ll num = 0;
  ll k = s.size();
  for (ll i = 0; i < k; i++){
    if (s[k-1-i] == 'B') res += (k -1 - num) - (k - 1 - i), num++;
  }
  
  cout << res << endl;
    
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <set>
#include <map>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

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

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

int main(void){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<PII> sorted(n);

  rep(i, n) {
    cin >> a[i];
    sorted[i].first = i;
    sorted[i].second = a[i];
  }

  int max_num = -1;
  int second_max = -1;

  sort(sorted.begin(), sorted.end(), sortbysec);

  rep(i, n) {
    if (max_num == -1) max_num = sorted[i].first;
    else if (second_max == -1) second_max = sorted[i].first;
    else break;
  }

  rep(i, n) {
    if (i != max_num) {
      cout << a[max_num] << endl;
    } else if (i == max_num) {
      cout << a[second_max] << endl;
    }
  }


  return 0;
}

Measured memory_bytes: 3968
N, M = map(int, input().split())
X = input().split()
X = [int(i) for i in X]
X = sorted(X)
cnt = 0
sa = []

for i in range(len(X)-1):
    sa.append(abs(X[i]-X[i+1]))
sa = sorted(sa, reverse=True)

ans = 0
for i in range(N-1, len(sa)):
    ans += sa[i]
print(ans)

Measured memory_bytes: 13840
k = int(input())
 
def gcd2(a,b):
    if b == 0:
        return a
    return gcd2(b,a%b)

def gcd3(a,b,c):
    return gcd2(gcd2(a,b), c)

ans = 0
for i in range(1,k+1):
    for j in range(i,k+1):
        for m in range(j, k+1):
            if i == j == m:
                ans += gcd3(i,j,m)
            elif i == j or j == m:
                ans += gcd3(i,j,m)*3
            else:
                ans += gcd3(i,j,m)*6

print(ans)


Measured memory_bytes: 9200
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long n,m;
    scanf("%lld %lld",&n,&m);
    if(n!=1&&m!=1)
        printf("%lld",n*m-2*n-2*m+4);
    else if(n==1&&m==1)
        printf("1");
    else if(n==1)
        printf("%lld",m-2);
    else if(m==1)
        printf("%lld",n-2);
    return 0;
}


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

int main() {
  ll N;
  cin >> N;
  ll root_N = sqrt(N);
  for (ll i=root_N; i>0; i--) {
    if (N%i == 0 && i + (N/i) >= 2 * root_N) {
      cout << i + (N/i) -2 << endl;
      break;
    }
  }
}

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

typedef long long ll;

int main() {
    string S;
    cin >> S;
    int N = S.size();
    auto sa = suffix_array(S);
    auto lcp = lcp_array(S, sa);
    /*
    rep(i, sa.size()) {
        cout << sa[i] << "\n";
    }
    */
    ll ans = N - sa[0];
    rep(i, N - 1) {
        ans += N - sa[i + 1] - lcp[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 15664
import math
from decimal import *
a,b,x = map(Decimal,input().split())
two = Decimal("2")
three = Decimal("3")
if x >= a**2 * b /2:
  ans_theta =  math.degrees(math.atan2( two* (a**two*b -x),a**three  ))
else:
  ans_theta =  math.degrees(math.atan2(a*b**two,two*x))
print(ans_theta)


Measured memory_bytes: 59884
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;


ll modpow(ll a, ll n, ll mod) {
  if(mod<0) return 0;
  ll res = 1;
  while(n > 0) {
    if(n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  string s; 
  cin >> n >> s;

  int one = count(ALL(s), '1');
  int num1 = 0;
  REP(i,n) num1 = (num1*2 + (s[i]-'0')) % (one+1);

  int num2 = 0;
  if(one>1){
    REP(i,n) num2 = (num2*2 + (s[i]-'0')) % (one-1);
  } 

  REP(i,n){
    int tmp = 0;
    if(s[i]=='0') tmp = (num1 + modpow(2, n-i-1, one+1)) % (one+1);
    else{
      if(one>1) tmp = (num2 - modpow(2, n-i-1, one-1) + one-1) % (one-1);
    }

    if(one==1 && s[i]=='1'){
      cout << 0 << '\n';
      continue;
    }
    
    int cnt = 1;
    while(tmp>0){
      int cp = tmp;
      int one2 = 0;
      while(cp>0){
        if(cp&1) one2++;
        cp >>= 1;
      }
      tmp %= one2;
      cnt++;
    }
    cout << cnt << '\n';
  }
  
  return 0;
}


Measured memory_bytes: 3768
module Main where

import Data.Bool
import Data.Functor
import Data.List
import Data.Maybe

getDice :: IO Dice
getDice = toDice . map read . words <$> getLine

toDice :: [Int] -> Dice
toDice [u,v,w,x,y,z] = (u,v,w,x,y,z)

main :: IO ()
main = do
  { d1 <- getDice
  ; d2 <- getDice
  ; putStrLn $ bool "No" "Yes" (d1 `elem` trans d2)
  }
type Dice = (Int,Int,Int,Int,Int,Int)

updowns :: Dice -> [Dice]
updowns d@(t,s,e,w,n,b) = [d,(b,s,w,e,n,t)]

spins d@(t,s,e,w,n,b) = [d,(s,w,b,t,e,n),(w,t,n,s,b,e)]

rots :: Dice -> [Dice]
rots d@(t,s,e,w,n,b) = [d,(t,e,n,s,w,b),(t,n,w,e,s,b),(t,w,s,n,e,b)]

trans :: Dice -> [Dice]
trans = concatMap spins . concatMap rots . updowns

Measured memory_bytes: 3660
//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int n;
//    while(~scanf("%d",&n)) {
//        if( n < 1200) cout << "ABC" << endl;
//        else if(n < 2800) cout << "ARC" << endl;
//        else cout << "AGC" << endl;
//    }
//    return 0;
//}
//





//#include <bits/stdc++.h>
//
//using namespace std;
//
//int main() {
//    int n;
//    string str;
//    while(cin >> str) {
//        bool vis[200];
//        memset(vis,0,sizeof(vis));
//        int len = str.size();
//        if(str[0] != 'A') {
//            cout << "WA" << endl;
//            return 0;
//        }
//        int flag= 0 ;
//        int id = 0;
//        for(int i = 0;i < len;i++){
//            if(str[i] == 'C'){
//                id = i;
//                break;
//            }
//        }
//        for(int i = id + 1;i < id + 4;i++){
//             if(!vis[str[i] - 'a']) vis[str[i] - 'a'] = 1;
//             else{
//
//             }
//        }
//        if(!flag)cout << "WA" << endl;
//        else cout << "AC" << endl;
//    }
//    return 0;
//}
//






#include <bits/stdc++.h>

using namespace std;


const int maxn = 200;
int d,gg,c[maxn],p[maxn],vis[maxn];
struct node {
    int c,p;
    int id,s;
} g[maxn];

int getans() {
    int ans = 0;
    int sum = 0;
    int G = gg;
    for(int i = 1; i <= d; i++) {
        if(vis[i]) G -= (g[i].p * 100 * i + g[i].c),ans += g[i].p;
    }
    for(int i = d; i >= 1; i--) {
        if(!vis[i]) {
            if(G > 0) {
                if(G >= g[i].p * 100 * i) {
                    ans += g[i].p;
                    G -= (g[i].p * 100 * i + g[i].c);

                } else {
                    ans += G / (i * 100);
                    G -= 100 * i * (G / (i * 100));
                }
            }

        }
    }
    if(G <= 0) return ans;
    else return 1e9;
}
int main() {
    while(cin >> d >> gg) {
        int ans = 1e9;
        for(int i = 1; i <= d; i++)
            cin >> g[i].p >> g[i].c,g[i].id = i;
        for(int i = 0; i < (1 << d); i++) {
            for(int j = 1; j <= d; j++) {
                if(1 & (i >> (j - 1))) vis[j] = 1;
                else vis[j] = 0;
            }
            int sum = getans();
            ans = min(ans,sum);
        }
        cout << ans << endl;
    }
    return 0;
}


//
//5 25000
//
//20 1000
//40 1000
//50 1000
//30 1000
//1 1000


//#include <stdio.h>
//#include <string.h>
//#include <algorithm>
//#include <string.h>
//
//using namespace std;
//
// char str[2000000];
// const int mod = 100000007;
//int main() {
//    int t;
//    while(t--) {
//        scanf("%s",str);
//        int len = strlen(str);
//        long long cnt1 = 0,cnt2 = 0,cnt3 = 0;
//        long long ans = 0;
//    }
//    return 0;
//}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<pair<char,int> > v;
    vector<int> ans;
    int r = 0, l = 0;
    for(int i = 0; i < n; i++){
        if(i == n-1){
            l++;
            v.push_back(make_pair('L',l));
        }else if(s[i] == 'R' && s[i+1] == 'L'){
            r++;
            v.push_back(make_pair('R',r));
            r=0;
        }else if(s[i] == 'L' && s[i+1] == 'R'){
            l++;
            v.push_back(make_pair('L',l));
            l = 0;
        }else if(s[i] == 'R'){
            r++;
        }else{
            l++;
        }
    }
    for(int i = 0; i < v.size(); i += 2){
        int a = v[i].second;
        int b = v[i+1].second;
        for(int j = 0; j < a; j++){
            if(j != a-1){
                ans.push_back(0);
            }else{
                if((a+b) % 2 == 0){
                    ans.push_back((a+b)/2);
                }else{
                    ans.push_back((a+1)/2+b/2);
                }
            }
        }
        for(int j = 0; j < b; j++){
            if(j == 0){
                if((a+b) % 2 == 0){
                    ans.push_back((a+b)/2);
                }else{
                    ans.push_back(a/2+(b+1)/2);
                }
                
            }else{
                ans.push_back(0);
            }
        }
    }
    for(int i = 0; i < n; i++){
        cout<< ans[i] << ' ';
    }
}

Measured memory_bytes: 2292
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB = sorted(AB, key=lambda x: x[0])
ans = 0
count = 0
i = 0

while True:
  ans += AB[i][0] * AB[i][1]
  count += AB[i][1]
  if count >= M:
    break
  i += 1
ans -= AB[i][0] * (count - M)
print(ans)

Measured memory_bytes: 29792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string S;
    cin >> S;

    if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int socket = A;
  int ans=1;
  if(B==1)ans=0;
  else{
    while(socket<B){
      socket += A-1;
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main() {
  double t,x;
  cin >> t >> x;
  t/=x;
  cout << fixed << setprecision(10) << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = 0x3f3f3f3f;

ll a[300001];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("C.txt", "r", stdin);
    #endif
    int n, ans=0;
    cin >> n;
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=1; i<n-1; i++)
    {
        if(a[i-1]>a[i]&&a[i+1]<a[i]||a[i-1]<a[i]&&a[i+1]>a[i]) ans++;
    }
    cout << ans;
}



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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL n,p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	map<LL,LL> so;
	so[p]++;
	LL pp = p;
	for (LL i = 2; i <= sqrt(pp)+1; i++) {
		if (p%i == 0) {
			so[i]++;
			p /= i;
			i--;
		}
	}
	LL ans = 1;
	for (auto&& var : so) {
		for (LL i = n; var.second >= i; i += n) {
			ans *= var.first;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
MaxA = max(As) + 1
numbers = [0] * (MaxA+1)
for i in range(N):
    A = As[i]
    if A != 0:
        numbers[A-1] += 1
    numbers[A] += 1
    numbers[A+1] += 1
print(max(numbers))

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

int main(){
  int N;
  cin>>N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin>>L.at(i);
  }
  sort(L.begin(),L.end());

  int ans=0;
  for(int i=2;i<N;i++){
    int left=0;
    int right=i-1;
    while(left!=right){
      if(L.at(left)+L.at(right)>L.at(i)){
        ans+=right-left;
        right--;
      }else{
        left++;
      }
    }
  }

  cout<<ans<<endl;
}


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

int main(){
  
      string a;
      cin >> a;
     
       
       int n = a.length();

       int  dp[2][n+1];
       memset(dp,INT_MAX,sizeof(dp));
       dp[0][0] = a[0] -'0';
       dp[1][0] = 10 - (a[0] - '0') + 1;

       for(int i =1;i<n;i++){
           for(int j =0;j<2;j++){
               if( j == 0){
                   dp[0][i] = min(dp[0][i-1] + (a[i]-'0'),dp[1][i-1] + (a[i]-'0'));
               }
               else{
                   dp[1][i] = min(dp[0][i-1] + 11 -(a[i] -'0'),dp[1][i-1] + (10- (a[i]-'0') -1));
               }

           }
       }

   cout << min(dp[0][n-1],dp[1][n-1]) << endl;


}




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

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;

#define EPS (1e-9)

// KEXÌÁ@ÅA§®ðÆ­
bool gauss_jordan(const mat&A,const vec &b){
    int n=A.size();
    mat B(n,vec(n+1));
    for(int i = 0; i < n;i++)
        for(int j=0;j<n;j++)
            B[i][j]=A[i][j];
    for(int i = 0; i < n; i++)
        B[i][n]=b[i];
    // eÏÉÚ
    for(int i = 0; i < n; i++){
        // ÅåÌWÌâÎlðàÂàÌðiÔÚÉÁÄ­é
        int piv=-1;
        int val=-1;
        for(int j=i;j<n;j++){
            if(val<abs(B[j][i])){
                piv=j;
                val=abs(B[j][i]);
            }
        }
        // EÓª0ÉÈé©Ç¤©²×é
        if(piv==-1||val<=0)
            continue;
        swap(B[piv],B[i]);
        for(int j = 0; j < n; j++){
            if(i==j)continue;
            int mulnum=B[j][i];
            if(mulnum==1){
                for(int k = i; k <= n; k++)
                    B[j][k]=(B[j][k]+B[i][k])%2;
            }
        }
    }
    vec res(n);
    for(int i = 0; i < n; i++){
        res[i]=B[i][n];
        if(B[i][i]==0){
            if(B[i][n]==1)return false;
        }
    }
    return true;
}
int M,N,D;
int field[101][101];

int main(){

    while(cin>>M>>N>>D&&(M|N|D)){
        for(int i=0;i<N;i++)for(int j=0;j<M;j++)cin>>field[i][j];
        mat A(M*N,vec(M*N));
        vec B(M*N,0);
        for(int i=0;i<N;i++){
            for(int j=0;j<M;j++){
                if(field[i][j])B[i*M+j]=1;
                for(int k=0;k<N;k++){
                    for(int l=0;l<M;l++){
                        // }nb^£
                        int dist=abs(l-j)+abs(i-k);
                        if(dist==D||dist==0)A[i*M+j][k*M+l]=1;
                    }
                }
            }
        }
        bool res=gauss_jordan(A,B);
        if(res)cout<<1<<endl;
        else cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 4000
#include <iostream>

using namespace std;

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

    for(c=1;c<=3;c++){
        if((a*b*c)%2!=0){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <vector>
#include <string.h> // for memset in CF judge.
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
int N, K;
cin >> N >> K;
    int count = 0;
    while(N > 0) {
      count++;
        N /= K;
    }
    cout << count;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int x, y;
  cin >> x >> y;
  int a[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  cout << (a[x] == a[y] ? "Yes" : "No") << endl;

  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int n=s.length(),k,count=0,m;
  cin >> k;
  m=min(n,5);
  vector<string> sub1(m*n-m*(m-1)/2);
  if(n==1)cout<<s<<endl;
  else {
   r(i,n)sub1[i]=s.substr(i,1);
    r(i,n-1)sub1[i+n]=s.substr(i,2);
     r(i,n-2)sub1[i+2*n-1]=s.substr(i,3);
     r(i,n-3)sub1[i+3*n-3]=s.substr(i,4);
     r(i,n-4)sub1[i+4*n-6]=s.substr(i,5);
    sort(sub1.begin(),sub1.end());
    string keep;
    r(i,n*(n+1)/2){
      if(!i){
        count++;
        keep=sub1[i];
      }
      else {
        if(sub1[i]!=keep){
          count++;
          keep=sub1[i];
        }
      }
      if(count==k){
       cout<<sub1[i]<<endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 1664
#include <iostream>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  unordered_map<int, int> Acnt;
  rep(i, N) {
    cin >> A[i];
    Acnt[A[i]]++;
  }
  vector<int> B(N);
  unordered_map<int, int> Bcnt;
  rep(i, N) {
    cin >> B[i];
    Bcnt[B[i]]++;
  }

  for (auto& a : Acnt) {
    if (Bcnt.count(a.first) && (N < a.second + Bcnt[a.first])) {
      cout << "No" << endl;
      return 0;
    }
  }

  int j = 0;
  int prev = -1;
  rep(i, N) {
    if (prev != A[i]) j = 0;
    if (A[i] == B[i]) {
      for (; j < N; ++j) {
        if (A[i] != A[j] && A[i] != B[j]) {
          swap(B[i], B[j]);
          break;
        }
      }
    }
    prev = A[i];
  }

  cout << "Yes" << endl;
  rep(i, N) {
    if (i != 0) cout << " ";
    cout << B[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 21100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define all(n) (n).begin(),(n).end()
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}



int main(){
	int n;
	cin >> n;
	long double x[10],y[10];
	FOR(i,n){
		cin >> x[i] >> y[i];
	}
	vector<long double> v;
	FOR(i,n){
		for(int j=i+1;j<n;j++){
			v.push_back(sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])));
		}
	}
	long double ans=0,sum=n;

	for(int i=n-1;i>=1;i--){
		sum*=i;
	}
	

	FOR(i,v.size()){
		
		ans+=v[i]*(sum/n*2);
	}		
	cout << fixed << setprecision(12);
	cout << ans/sum << endl;
	

}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main ()
{
	long int a, b, c;
	cin>>a>>b>>c;
	long int l1 = a/c;
	long int l2 = b/c;
	if(a%c==0)
		l2++;
	cout<<l2-l1<<endl;
	return 0;
}

Measured memory_bytes: 256
N=io.read("*n","*l")
ans=1
L={}
for arg in io.read("*a"):gmatch("[^%s]+") do table.insert(L, arg) end

table.sort(L)

for i=1,N-1,1 do if L[i]~=L[i+1] then ans=ans+1 end end

print(ans)

Measured memory_bytes: 19892
#include<iostream>

using namespace std;

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

	int ans = 0;
	if (a >= k)ans = k;
	else {
		ans = a;
		if ((k - a) > b) ans -= (k-a-b);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
a,b,c=map(int,input().split())
print(min(abs(a-b)+abs(b-c),abs(a-c)+abs(c-b),abs(b-a)+abs(a-c),abs(b-c)+abs(c-a),abs(c-a)+abs(a-b),abs(c-b)+abs(b-a)))

Measured memory_bytes: 3060
package main

import "fmt"

func main() {
	var p, q, r int
	fmt.Scan(&p, &q, &r)
	if p+q < p+r {
		if q+r < p+q {
			fmt.Println(q + r)
		} else {
			fmt.Println(p + q)
		}
	} else {
		if q+r < p+r {
			fmt.Println(q + r)
		} else {
			fmt.Println(p + r)
		}
	}
}


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


int main()
{
    int t=1;
    //cin>>t;


    while( t-- )
    {
        int k;
        cin>>k;

        string s;
        cin>>s;

        if( s.size()<=k )
            cout<<s;
        else
        {
            for( int i=0 ; i<k ; i++ )
                cout<<s[i];
            cout<<"..."<<endl;
        }
    }
    return 0;
}


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

fn main(){
    let n: usize = read();
    let x: usize = read();
    if n == x {
        println!("Yes");
        for i in 1..2 * n {
            println!("{}", i);
        }
    } else if x != 1 && x < n {
        println!("Yes");
        let mut ans = 1;
        for i in 1..2 * n {
            if i == n - 1 {
                println!(1);
            } else if i == n {
                println!("{}", x);
            } else {
                ans += 1;
                if ans == x {
                    ans += 1;
                }
                println!("{}", ans);
            }
        }
    } else if x != 2 * n - 1 && x > n {
        println!("Yes");
        let mut ans = 2 * n - 1;
        for i in 1..2 * n {
            if i == n - 1 {
                println!("{}", 2 * n - 1);
            } else if i == n {
                println!("{}", x);
            } else {
                ans -= 1;
                if ans == x {
                    ans -= 1;
                }
                println!("{}", ans);
            }
        }
    } else {
        println!("No");
    }
}

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")
}

Measured memory_bytes: 5628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl '\n'

int t=1,T;

void print2d(vector<vector<int>> &v){
    for(int i=0;i<v.size();i++){
        for(int x:v[i]){
            cout << x <<' ';
        }
        cout <<endl;
    }
}

void print(vector<int> &a){
    for(int x : a){
        cout << x <<' ';
    }
    cout << endl;
    return;
}

int fun(int x,int y){
    return x*x+y*y;
}

void solve(){
    int mod;
    cin >> mod;

    int val=7%mod;
    for (int i=1; i<1e7; i++) {
        if (val==0) {
            cout << i <<endl;
            return;
        }
        val=(val*10+7)%mod;
    }
    cout << -1 <<endl;
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    #ifndef ONLINE_JUDGE
    freopen("/home/harsha/Desktop/code/input.txt","r",stdin);
    freopen("/home/harsha/Desktop/code/output.txt","w",stdout);
    #endif

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

    return 0;
}

/*

*/

Measured memory_bytes: 3620
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  int sum;
  while(cin >> str && str!="0"){
    sum = 0;
    for(int i=0,l=str.size();i<l;i++) sum += str[i]-'0';
    cout << sum << endl;
  }
}



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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
int mod = 1000000000+7;

int main(){

    int k,a,b;
    cin>>k>>a>>b;
    int flag=0;
    for(int i=a;i<=b;i++){
        if(i%k==0)flag=1;
    }
    if(flag==1)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;

    return 0;
}

Measured memory_bytes: 3648
# coding: utf-8
import math

a, b, C = map(float, input().split())
S =  0.5 * a * b * math.sin(C * math.pi / 180)
L = a + b + (a ** 2 + b ** 2 - 2 * a * b * math.cos(C * math.pi / 180)) ** 0.5
h = 2 * S / a

print("%f\n%f\n%f" % (S, L, h))


Measured memory_bytes: 5708
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n;  cin >> n;
    string s;   cin >> s;
    int p = 0, q = 0, a = 0, b = 0;
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '(')
            a++;
        else {
            if (a <= b) {
                p++;
                b++;
                a++;
            }
            else {
                b++;
            }
        }
    }

    for (int i = 0; i < p; i++)
        cout << "(";
    cout << s;
    for (int i = 0; i < a-b; i++)
        cout << ")";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3620
(let* ((n (read))
    (a (make-array (+ n 1)))
    (b (make-array n))
    (ans 0))

    (loop for i below (+ n 1) do
        (setf (aref a i) (read))
    )
    (loop for i below n do
        (setf (aref b i) (read))
    )

    (loop for i below n do
        (progn
            (if (<= (aref a i) (aref b i))
                (progn
                    (incf ans (aref a i))
                    (decf (aref b i) (aref a i))
                    (setf (aref a i) 0)
                    ;; (format t "1 ANS=~D ~A ~A~%" ans a b)

                )
                (progn
                    (incf ans (aref b i))
                    (decf (aref a i) (aref b i))
                    (setf (aref b i) 0)
                    ;; (format t "2 ANS=~D ~A ~A~%" ans a b)

                )
            )
            (if (not (zerop (aref b i)))
                (if (<= (aref a (+ i 1)) (aref b i))
                    (progn
                        (incf ans (aref a (+ i 1)))
                        (decf (aref b i) (aref a (+ i 1)))
                        (setf (aref a (+ i 1)) 0)
                        ;; (format t "3 ANS=~D ~A ~A~%" ans a b)

                    )
                    (progn
                        (incf ans (aref b i))
                        (decf (aref a (+ i 1)) (aref b i))
                        (setf (aref b i) 0)
                        ;; (format t "4 ANS=~D ~A ~A~%" ans a b)
                    )
                )
            )
        ;; (format t "~%")
        )
    )
    (format t "~D~%" ans)
)

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

int n;
vector<double> a;

vector<double> pref_sums;
vector<vector<double>> dp;

double solve(int start, int end) {
    if ((dp[start][end] == 0) and (start != end)) {
        double res = INFINITY;
        for (int i = start; i < end; ++i)
            res = min(res, solve(start, i) + solve(i + 1, end) + pref_sums[end + 1] - pref_sums[start]);

        dp[start][end] = res;
    }

    return dp[start][end];
}

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

    cin >> n;

    a.resize(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    pref_sums.resize(n + 1);
    dp.resize(n, vector<double>(n));

    for (int i = 0; i < n; ++i)
        pref_sums[i + 1] = pref_sums[i] + a[i];

    cout << (long long)solve(0, n - 1);
}

Measured memory_bytes: 1536
#include <bitset>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, a, b) for(int i = (a); i >= (b); i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える

int n, m;
vector<vector<int>> ks;
vector<int> p;

bool isOK(int bit){
    bool res = true;

    rep(i, m){
        int k_i = ks[i][0];

        int s_cnt = 0;
        for(int j = 1; j <= k_i; j++){
            int s = ks[i][j];
            if(bit & (1 << s)) s_cnt++;
        }

        if(s_cnt % 2 != p[i]) res = false;
    }

    return res;
}

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

    ks.resize(m);

    rep(i, m){

        int k_i; cin >> k_i;
        ks[i].resize(k_i+1);
        ks[i][0] = k_i;

        for(int j = 1; j <= k_i; j++){
            int s_ij; cin >> s_ij;
            ks[i][j] = s_ij -1;
        }
    }

    p.resize(m);
    rep(i, m) cin >> p[i];

    int cnt = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        if(isOK(bit)) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}



int main() {
	int n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n / 2 << endl;
	}
	else {
		cout << n / 2 + 1 << endl;
	}
	return 0;
}



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

class Node{
  int Date;
  Node* p;
  Node* n;
public:
  Node(int i){
    Date = i;
  }
  void SetPrev(Node* p){
    this->p = p;
  }
  void SetNext(Node* n){
    this->n = n;
  }
  void SetDate(int d){
    Date = d;
  }
  int GetData(){
    return Date;
  }
  Node* GetPrev(){
    return p;
  }
  Node* GetNext(){
    return n;
  }
};

class LinkedList{
  Node* First;
  Node* Last;
public:
  LinkedList(){
    First = new Node(0);
    Last = new Node(0);
    First->SetNext(Last);
    Last->SetPrev(First);
  }
  void insert(int x){
    Node* tmp = new Node(x);
    tmp->SetNext(First->GetNext());
    tmp->SetPrev(First);
    First->GetNext()->SetPrev(tmp);
    First->SetNext(tmp);
  }
  void Delete(int x){
    Node* tmp = First->GetNext();
    while(tmp!=Last){
      if(tmp->GetData() == x){
        tmp->GetPrev()->SetNext(tmp->GetNext());
        tmp->GetNext()->SetPrev(tmp->GetPrev());
        delete tmp;
        break;
      }
      tmp = tmp->GetNext();
    }
  }
  void DeleteFirst(){
    Node* tmp = First->GetNext();
    First->SetNext(tmp->GetNext());
    tmp->GetNext()->SetPrev(First);
    delete tmp;
  }
  void DeleteLast(){
    Node* tmp = Last->GetPrev();
    Last->SetPrev(tmp->GetPrev());
    tmp->GetPrev()->SetNext(Last);
    delete tmp;
  }
  friend ostream& operator<< (ostream& os,const LinkedList& ll);
};

ostream& operator<< (ostream& os,const LinkedList& ll){
  Node* tmp = ll.First->GetNext();
  while(1){
    os << tmp->GetData();
    tmp = tmp->GetNext();
    if(tmp == ll.Last){
      break;
    }
    os << ' ';
  }
  return os;
}

int main(){

  LinkedList ll;
  int num=0;
  cin >> num;
  string order="";
  int x=0;
  for(int i=0; i<num; i++){
    cin >> order;
    if(order == "insert"){
      cin >> x;
      ll.insert(x);
    //  cout << ll << endl;
    }
    else if(order == "delete"){
      cin >> x;
      ll.Delete(x);
      //cout << ll << endl;
    }
    else if(order == "deleteFirst"){
      ll.DeleteFirst();
    //  cout << ll << endl;
    }
    else if(order == "deleteLast"){
      ll.DeleteLast();
    //  cout << ll << endl;
    }
  }
  cout << ll << endl;
  return 0;
}

Measured memory_bytes: 34420
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Cost(int N, int X, int[] x, int n)
        {
            long cost = 0;
            for (int i = 0; i < n; ++i)
            {
                cost += x[i];
                for (int j = 0; true; ++j)
                {
                    if ((j + 1) * n + i < N)
                    {
                        cost += Math.BigMul(j + 2, j + 2) * (x[j * n + i] - x[(j + 1) * n + i]);
                    }
                    else
                    {
                        cost += Math.BigMul(j + 2, j + 2) * x[j * n + i];
                        break;
                    }
                }
            }
            return cost + Math.BigMul(N + n, X);
        }
        static long Solve(int N, int X, int[] x)
        {
            Array.Sort(x, (a, b) => b.CompareTo(a));
            int x0 = 1;
            int x3 = N;
            long y0 = Cost(N, X, x, x0);
            long y1;
            long y2;
            long y3 = Cost(N, X, x, x3);
            while (true)
            {
                int x1 = (x3 - x0) * 1 / 3 + x0;
                int x2 = (x3 - x0) * 2 / 3 + x0;
                y1 = Cost(N, X, x, x1);
                y2 = Cost(N, X, x, x2);
                if (x3 - x0 <= 3) { break; }
                if (y1 < y2)
                {
                    x3 = x2;
                    y3 = y2;
                }
                else
                {
                    x0 = x1;
                    y0 = y1;
                }
            }
            return new[] { y0, y1, y2, y3 }.Min();
        }
        static void Main(string[] args)
        {
            int[] V1 = ReadInts();
            int[] x = ReadInts();
            Console.WriteLine(Solve(V1[0], V1[1], x));
        }
    }
}


Measured memory_bytes: 34524
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
using namespace std;
using namespace std::chrono;
int main(){
    int n;
    cin >> n;
    string  w[110];
    int l[110];
    for(int i = 0; i < n; i++){
        cin >> w[i];
        l[i] = w[i].length();
    }

    int acount = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(w[i] == w[j]) acount++;
        }
    }

    int bcount = 0;
    for(int i = 0; i < n-1; i++){
        if(w[i][l[i]-1] == w[i+1][0]) bcount++;
    }
    //cout << acount << " " << bcount << w[0][l[0]-1] << endl;


    if(bcount == n-1 && acount == n) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	int d, a;
	int cnt[100];
	for (int i = 0; i < n; i++)
		cnt[i] = 0;
	for (int i = 0; i < k; i++)
	{
		scanf("%d", &d);
		for (int j = 0; j < d; j++)
		{
			scanf("%d", &a);
			cnt[a - 1]++;
		}
	}
	int answer = 0;
	for (int i = 0; i < n; i++)
		if (cnt[i] == 0)
			answer++;
	printf("%d\n", answer);
	return 0;
}

Measured memory_bytes: 1736