akhauriyash/Code-Regression huggingface dataset:
//1フロア10部屋ある3階建の4つの棟のそれぞれの部屋にいる人数を可視化するプログラム

#include <stdio.h>

#define MAX_ROOM_NUM 10
#define MAX_FLOOR_NUM 3
#define MAX_BUILDING_NUM 4

int main(void)
{
    //変数定義
    int iInputDataNumber;       //入力データ数
    int iRoomCount;             //部屋番号カウンタ
    int iFloorCount;            //階カウンタ
    int iBuildingCount;         //棟番号カウンタ
    int iCount;                 //データ入力カウンタ
    int iInputRoomNumber;       //部屋番号
    int iInputFloorNumber;      //階
    int iInputBuildingNumber;   //棟の番号  
    int iInputHumanNumber;      //入居者数
    int aiHumanNumber[MAX_BUILDING_NUM][MAX_FLOOR_NUM][MAX_ROOM_NUM];      //入居者数を格納する配列

    //変数初期化
    iInputRoomNumber = 0;
    iInputFloorNumber = 0;
    iInputBuildingNumber = 0;
    iInputHumanNumber = 0;
    iInputDataNumber = 0;
    //全ての部屋の初期入居者は0人
    // for (iBuildingCount = 1; iBuildingCount <= MAX_BUILDING_NUM; iBuildingCount++)
    // {
    //     for (iFloorCount = 1; iFloorCount <= MAX_FLOOR_NUM; iFloorCount++)
    //     {
    //         for (iRoomCount = 1; iRoomCount <= MAX_ROOM_NUM; iRoomCount++)
    //         {
    //             aiHumanNumber[iBuildingCount][iFloorCount][iRoomCount] = 0;
    //             printf("%d ",aiHumanNumber[iBuildingCount][iFloorCount][iRoomCount]);
    //         }
    //     }
    // }

    for (iBuildingCount = 0; iBuildingCount < MAX_BUILDING_NUM; iBuildingCount++)
    {
        for (iFloorCount = 0; iFloorCount < MAX_FLOOR_NUM; iFloorCount++)
        {
            for (iRoomCount = 0; iRoomCount < MAX_ROOM_NUM; iRoomCount++)
            {
                aiHumanNumber[iBuildingCount][iFloorCount][iRoomCount] = 0;
               // printf("%d ",aiHumanNumber[iBuildingCount][iFloorCount][iRoomCount]);
            }
        }
    }

    //データ数の入力
    scanf ("%d",&iInputDataNumber);

    //各部屋の入居人数を代入する
    for (iCount = 0; iCount < iInputDataNumber; iCount++)
    {
        scanf ("%d %d %d %d",&iInputBuildingNumber,&iInputFloorNumber,&iInputRoomNumber,&iInputHumanNumber);
        aiHumanNumber[iInputBuildingNumber - 1][iInputFloorNumber - 1][iInputRoomNumber - 1] += iInputHumanNumber;
    }

    //各部屋の入居者数の状況を出力する
    for (iBuildingCount = 0; iBuildingCount < MAX_BUILDING_NUM; iBuildingCount++)
    {
        for (iFloorCount = 0; iFloorCount < MAX_FLOOR_NUM; iFloorCount++)
        {
            for (iRoomCount = 0; iRoomCount < MAX_ROOM_NUM; iRoomCount++)
            {
                printf(" %d",aiHumanNumber[iBuildingCount][iFloorCount][iRoomCount]);
            }
            printf("\n");
        }
        if (iBuildingCount != MAX_BUILDING_NUM - 1)
        {
            printf("####################\n");
        }
    }
  
    return 0;
}


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

using namespace std;
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k;
    string s;
    cin>>k;
    cin>>s;
    if(s.size()<=k)
    {
        cout<<s;
    }
    else
    {
        for(int i=0;i<k;++i)
        {
            cout<<s[i];
        }
        cout<<"...";
    }
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 0;
    int i = 0, j = s.size() - 1;
    while (i < j) {
        if (s[i] != s[j]) ++ans;
        ++i; --j;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll all = 0;
    for(int i=0; i<n; i++){
        cin >> a[i];
        all ^= a[i];
    }

    for(int i=0; i<n; i++){
        ll ans = all^a[i];
        cout << ans << " ";
    }
    return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<algorithm>
#include<utility>
using namespace std;
int main()
{
	int n, m;
	pair<int, int> super[100000];
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &super[i].first, &super[i].second);
	sort(super, super + n);
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		if (m == 0)
			break;
		if (m >= super[i].second)
		{
			m -= super[i].second;
			sum += (long long)super[i].first*super[i].second;
		}
		else
		{
			sum += (long long)super[i].first*m;
			m = 0;
		}
	}
	printf("%lld\n", sum);
	return 0;
}

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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

char s[1<<21];
int n,K,dp[25][1<<21];
int main() {
	scanf("%d%d",&n,&K);
	for(int i=0;i<=n;++i){
		scanf("%s",s);
		for(int j=0;j<=(1<<i)-1;++j){
			if(s[j]=='1')dp[i][j|(1<<i)]=1;
		}
	}
	for(int i=n;i>=1;--i){
		for(int j=i;j<=n;++j){
			int b=(1<<j);
			for(int k=0;k<b;++k){
				int tmp=dp[i][k|b],p=-1,q=-1;if(!tmp)continue;
				for(int t=i;t>=1;--t)if(((k>>(t-1))&1)==1){p=t;break;}
				for(int t=i;t>=1;--t)if(((k>>(t-1))&1)==0){q=t;break;}
				dp[0][(k+b)>>i]+=tmp;
				if(p!=-1)dp[p-1][(k&((1<<(p-1))-1))|(((k>>i)<<1|1)<<(p-1))|(b>>(i-p))]+=tmp;
				if(q!=-1)dp[q-1][(k&((1<<(q-1))-1))|(((k>>i)<<1)<<(q-1))|(b>>(i-q))]+=tmp;
			}
		}
	}
	for(int i=n;i>=0;--i){
		for(int j=0;j<(1<<i);++j){
			if(dp[0][j|(1<<i)]>=K){
				for(int k=i-1;k>=0;--k)if((j>>k)&1)putchar('1');else putchar('0');
				puts("");
				return 0;
			}
		}
	}
	assert(0);
	return 0;
}

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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define INF (INT_MAX/2)

int E[100][100];

int main() {
    int n, k;
    while (cin >> n >> k, n|k) {
        fill_n((int *)E, 100*100, INF);
        REP(i, n) E[i][i] = 0;
        bool updated = false;
        REP(i, k) {
            int a, b, c, d, e;
            int f;
            cin >> f;
            if (f == 1) {
                cin >> c >> d >> e;
                c--;
                d--;
                if (E[c][d] > e) {
                    E[c][d] = E[d][c] = e;
                    updated = true;
                }
            } else {
                if (updated) {
                    updated = false;
                    REP(i, n) REP(j, n) REP(k, n) E[j][k] = min(E[j][k], E[j][i] + E[i][k]);
                }
                cin >> a >> b;
                a--;
                b--;
                cout << (E[a][b] == INF ? -1 : E[a][b]) << endl;
            }
        }
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        e[--u].push_back(--v);
        e[v].push_back(u);
    }
    vector<int> dis, parent(n);
    auto bfs = [&](int s) {
        dis.assign(n, -1);
        dis[s] = 0;
        queue<int> que;
        que.push(s);
        parent[s] = -1;
        while (!que.empty()) {
            int u = que.front();
            que.pop();
            for (int v : e[u]) {
                if (dis[v] == -1) {
                    dis[v] = dis[u] + 1;
                    parent[v] = u;
                    que.push(v);
                }
            }
        }
        return max_element(dis.begin(), dis.end()) - dis.begin();
    };
    int s = bfs(0);
    int t = bfs(s);
    cout << dis[t] / 2 + 1 << " ";
    vector<int> deg;
    function<void(int, int, int)> dfs = [&](int u, int p, int d) {
        if (d >= (int)deg.size())
            deg.resize(d + 1);
        deg[d] = max(deg[d], (int)e[u].size());
        for (int v : e[u]) {
            if (v == p)
                continue;
            dfs(v, u, d + 1);
        }
    };
    int d = dis[t];
    if (d % 2 == 1) {
        for (int i = 0; i < d / 2; ++i)
            t = parent[t];
        s = parent[t];
        deg.clear();
        dfs(s, t, 0);
        dfs(t, s, 0);
        LL ans = 2;
        for (int i = 0; i < (int)deg.size() - 1; ++i)
            ans *= deg[i] - 1;
        cout << ans << endl;
    } else {
        for (int i = 0; i < d / 2; ++i)
            t = parent[t];
        deg.clear();
        dfs(t, -1, 0);
        LL ans = 1;
        for (int i = 0; i < (int)deg.size() - 1; ++i)
            ans *= deg[i] - (i > 0);
        for (int v : e[t]) {
            deg.clear();
            dfs(v, t, 0);
            dfs(t, v, 0);
            LL res = 2;
            for (int i = 0; i < (int)deg.size() - 1; ++i)
                res *= deg[i] - 1;
            ans = min(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  int h;
  double a, b, m, hx, hy, mx, my, ans=0 ,pi = 3.141592653589793238;
  cin >> a >> b >> h >> m;
  double hh = (double)(h % 12);
  
  hx = a * cos((hh / 6.0 + m / 360) * pi);
  hy = a * sin((hh / 6.0 + m / 360) * pi);
  mx = b * cos(m / 30.0 * pi);
  my = b * sin(m / 30.0 * pi);

  ans = sqrt(pow(hx - mx, 2) + pow(hy - my, 2));
  cout << fixed << setprecision(10);
  cout << ans << endl;
}

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

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;

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

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

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

  int sum = 0;
  rep(a, k) rep(b, k) rep(c, k){
    sum += gcd(a+1, gcd(b+1, c+1));
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    string a;
    
    while(getline(cin,a)){
        
        for(int i=0; i<(int)a.length(); i++){
            if(a[i]==' '|| a[i]=='.'){
                
            }else{
                a[i]=toupper(a[i]);
            }
        }
        
        cout<<a<<endl;;
    }
    
    return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(a * b, c * d) << endl;
    return 0;
}



Measured memory_bytes: 3616
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)

Measured memory_bytes: 40076
#include<stdio.h>
long long dp[100][21];
int dat[100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",dat+i);
	}
	dp[0][dat[0]]=1;
	for(int i=1;i<a-1;i++){
		for(int j=0;j<=20;j++){
			if(j-dat[i]>=0)dp[i][j]+=dp[i-1][j-dat[i]];
			if(j+dat[i]<=20)dp[i][j]+=dp[i-1][j+dat[i]];
		}
	}
	//for(int i=0;i<=20;i++){
	//	printf("%lld\n",dp[a-2][i]);
	//}
	printf("%lld\n",dp[a-2][dat[a-1]]);
}

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

using namespace std;

template <typename T>
using vec1 = vector<T>;

template <typename T>
T cin2var()
{
    T val;
    cin >> val;
    return val;
}

template <typename T>
vec1<T> cin2vec(size_t size)
{
    vec1<T> vec1(size);
    for (auto& v : vec1) {
        v = cin2var<T>();
    }
    return vec1;
}

void sub()
{
    const auto N(cin2var<size_t>());
    const auto Vs(cin2vec<uint64_t>(N));
    priority_queue<uint64_t, vec1<uint64_t>, greater<uint64_t>> pq{Vs.cbegin(), Vs.cend()};
    double sum = pq.top(); pq.pop();
    while (!pq.empty()) {
        sum += pq.top();
        sum /= 2.0;
        pq.pop();
    }
    cout << sum << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    sub();
    return 0;
}


Measured memory_bytes: 256
n,y=map(int,input().split())
y=y//1000
if y<n or 10*n<y:
    print(-1,-1,-1)
else:
    for i in range((y-n)//9+1):
        if (y-n-9*i)%4==0:
            a=i
            b=(y-n-9*i)//4
            if n-a-b>=0:
                print(a,b,n-a-b)
                break
    else:
        print(-1,-1,-1)


Measured memory_bytes: 3064
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long a, b;

//gcd
long gcd(long num1, long num2){
	if(num2 > num1){
		std::swap(num1, num2);
	}
	if(num2 == 0){
		return num1;
	}else{
		return gcd(num2, num1 % num2);
	}
}

int main(){
    scanf("%ld%ld", &a, &b);
    printf("%ld\n", a*b/gcd(a, b));
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>
#include <set>
#include <utility>
typedef long long ll;

using namespace std;

void bitPlus(vector<int> &bit, int index) {
	if(bit.size() <= index) {
		return;
	}
	
	if(bit[index] == 0) {
		bit[index] = 1;
	}
	else {
		bit[index] = 0;
		bitPlus(bit, index + 1);
	}
}

int xyz(int n) {
	int ans = 1;
	for(int i = 0; i < n; i++) {
		ans *= 2;
	}
	return ans;
}

int main() {
	int n, m;
	cin >> n >> m;
	
	vector<int> k(m);
	vector<vector<int>> s = vector<vector<int>>(m);
	for(int i = 0; i < m; i++) {
		cin >> k[i];
		s[i] = vector<int>(k[i]);
		for(int j = 0; j < k[i]; j++) {
			cin >> s[i][j];
		}
	}
	
	vector<int> p(m);
	for(int i = 0; i < m; i++) {
		cin >> p[i];
	}
	
	vector<int> bit(n, 0);
	int ans = 0;
	for(int i = 0; i < xyz(n); i++) {
		bool flag = true;
		
		for(int j = 0; j < m; j++) {
			int cnt = 0;
			for(int l = 0; l < k[j]; l++) {
				if(bit[s[j][l] - 1] == 1) {
					cnt++;
				}
			}
			
			if(cnt % 2 != p[j]) {
				flag = false;
			}
		}
		
		if(flag) {
			ans++;
		}
		
		bitPlus(bit, 0);
	}
	
	cout << ans << endl;
	
    return 0;
}

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

int main()
{
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<int> a(N);

  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  /* XとYさんがいるが、XがN-1枚かN枚引くかのみが解になる
     のでその2つを比較すれば良い。 */

  // XがN-1枚引く場合、Xの持つのはa[N-2]の値でYが持つのはa[N-1]
  // XがN枚引くとき、Xが持つのはa[N-1]でYはW(最初のカード)
  int result = 0;
  if (N > 1) result = max(abs(a[N-2] - a[N-1]), abs(a[N-1] - W));
  else result = abs(a[0] - W);

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n , m ;
	cin >> n >> m; 
	if(n==m) cout << "Yes\n";
	else cout << "No\n";
	
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;


int main()
{
   FAST/**/
   
   ll n,m;
   cin>>n>>m;
   ll arr[n];
   rep(n)
        cin>>arr[i], arr[i]/=2;
   
   ll temp = arr[0];
   ll po = 1;
   while(temp%2 == 0)
   {
       temp/=2;
       po*=2;
   }
   bool pos = 1;
   for(ll i=0;i<n;i++)
   {
       if(arr[i]%po == 0 && (arr[i]%(2*po)) != 0)
            continue;
       pos = 0;        
   }
   
   if(!pos)
   {
       cout<<0;
       return 0;
   }
   
   ll lcm = arr[0];
   for(ll i=1;i<n;i++)
   {
       if(lcm>m)
       {
           cout<<0;
           return 0;
       }
       ll g = __gcd(arr[i],lcm);
       lcm = (lcm)*(arr[i]/g);
   }
   
   if(lcm>m)
   {
       cout<<0;
       return 0;
   } 
   
   ll lim = m/lcm;
   if(lim == 0)
   {
       cout<<0;
       return 0;
   }
   
   ll ans = (lim+1)/2;
   cout<<ans;
    
   return 0;        
}  
   

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <iomanip>
 
using namespace std;
 
//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
 
//container util
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQUE(a)  (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto 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(i,0,n)
#define RFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define RREP(i,n) RFOR(i,n,0)
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << "[L " << __LINE__ << "] " << #x << " = " << (x) << "\n";
 
// #define X first
// #define Y second
 
const int INF = 1e9;
const ll LINF = 1e18;
const long double PI = 3.1415926535897932;
const int _N = 2e5;
const int _M = 270000;
int n,m,r,go[8],dist[200][200];
int dp[1<<8][8];
int solve(int i,int s){
    if(dp[s][i]!=-1)return dp[s][i];
    if(s==(1<<r)-1)return dp[s][i]=0;
    int minv=INF;
    REP(j,r)if(!((1<<j)&s))if(dist[go[i]][go[j]]!=INF){
        minv=min(minv,dist[go[i]][go[j]]+solve(j,s|(1<<j)));
    }
    return dp[s][i] = minv;
}
int main() {
  omajinai;
  cin>>n>>m>>r;
  REP(i,r){
      cin>>go[i];
      go[i]--;
  }
  REP(i,n)REP(j,n)dist[i][j]=INF;
  REP(i,n)dist[i][i]=0;
  REP(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      dist[a][b]=c;
      dist[b][a]=c;
  }
  REP(k,n)REP(i,n)REP(j,n)
    dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
  REP(i,1<<r)REP(j,r)dp[i][j]=-1;
  int ans=INF;
  REP(i,r){
    ans=min(ans,solve(i,1<<i));
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
n = int(input())
AC,WA,TLE,RE = 0,0,0,0

for x in range(n):
    s = input()
    if s == 'AC':
        AC = AC + 1
    elif s == 'WA':
        WA = WA + 1
    elif s == 'TLE':
        TLE = TLE + 1
    elif s == 'RE':
        RE = RE + 1

print('AC x ' + str(AC))
print('WA x ' + str(WA))
print('TLE x ' + str(TLE))
print('RE x ' + str(RE))



Measured memory_bytes: 9132
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N);
  rep (i, N) cin >> A[i];
  vector<long> mountain(N, 0);
  rep (i, N) {
    if (i % 2 == 0) mountain[0] += A[i];
    else mountain[0] -= A[i];
  }
  for (long i = 1; i < N; i++) {
    mountain[i] = A[i-1] * 2 - mountain[i-1];
  }
  bool space = false;
  rep (i, N) {
    if (space) cout << " ";
    space = true;
    cout << mountain[i];
  }
  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;

int main()
{
    int n, m, s, c;
    cin >> n >> m;
    vector<pair<int, bool>> t(n, {0, false});
    for (int i = 0; i < m; i++)
    {
        cin >> s >> c;
        if (t[s - 1].second == false)
        {
            t[s - 1] = {c, true};
        }else if(t[s-1].first == c){
            continue;
        }else{
            cout << -1 << endl;
            exit(0);
        }
    }
    if(t[0].second == false && t.size() != 1) t[0].first = 1;

    if(t.size() != 1 && t[0].first == 0){
        cout << -1 << endl;
    }else{
        for(int i =0; i<n;i++){
            cout << t[i].first;
        }
        cout << endl;
    }
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	REP(i, n) {
		if (a[i] == b[i]) {
			if (b[i] != c[i])cnt++;
		}
		else {
			if (b[i] != c[i]) {
				if (a[i] == c[i]) {
					cnt++;
				}
				else {
					cnt += 2;
				}
			}
			else {
				cnt++;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
	int a[3][3];
	for (int i = 0; i < 3; ++i)
	{
		for (int j = 0; j < 3; ++j)
		{
			cin >> a[i][j];
		}
	}
	int n;
	cin >> n;
	int b;
	int bingo[3][3] = {};
	for (int i = 0; i < n; ++i)
	{
		cin >> b;
		for (int j = 0; j < 3; ++j)
		{
			for (int k = 0; k < 3; ++k)
			{
				bingo[j][k] += (a[j][k] == b);
			}
		}
	}
	int ans = 0;
	int now;
	for (int i = 0; i < 3; ++i)
	{
		now = 0;
		for (int j = 0; j < 3; ++j)
		{
			now += bingo[i][j];
		}
		ans += now / 3;
		now = 0;
		for (int j = 0; j < 3; ++j)
		{
			now += bingo[j][i];
		}
		ans += now / 3;
	}
	now = 0;
	for (int i = 0; i < 3; ++i)
	{
		now += bingo[i][i];
	}
	ans += now / 3;
	now = 0;
	for (int i = 0; i < 3; ++i)
	{
		now += bingo[i][2 - i];
	}
	ans += now / 3;
	cout << (ans != 0?"Yes":"No") << endl;
	return 0;
}

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

int main()
{
    ll N, a, b, c, d;
    bool flag = false; 
    cin >> N >> a >> b >> c >> d;
    N--;
    for(int i = 0; i <= N; i++) {
        ll l = a + c * i - d * (N - i);
        ll h = a + d * i - c * (N - i);
        if(l <= b && b <= h) flag = true;
    }
    if(flag) cout << "YES" << endl;
    else cout << "NO" << endl;
    return (0);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# N,M = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(int(sys.stdin.readline()) for _ in range(N)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# N = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections,math,fractions
sys.setrecursionlimit(1000000)
INF = float("inf")

N,K = map(int,sys.stdin.readline().split())
xyc = tuple(tuple(sys.stdin.readline().rstrip().split()) for _ in range(N)) # multi line with multi param
xyc = tuple((int(x)%(2*K),int(y)%(2*K),c=="W")for x,y,c in xyc)
W = K
H = K
grid_w = [[0]*(W) for _ in range(H)]
grid_b = [[0]*(W) for _ in range(H)]

for x,y,c in xyc:
    r = (x//K+y//K)%2 # reverse or not
    c = c ^ r
    if c:
        grid_w[y%K][x%K] += 1
    else:
        grid_b[y%K][x%K] += 1
# 4 3
# 0 1 W
# 1 2 W
# 5 3 B
# 5 4 B

# 6 2
# 1 2 B
# 2 1 W
# 2 2 B
# 1 0 B
# 0 6 W
# 4 5 W
white =  [[0]*(W+1) for _ in range(H+1)]
black =  [[0]*(W+1) for _ in range(H+1)]
for r in range(H):
    for c in range(W):
        black[r+1][c+1] = black[r+1][c]+grid_b[r][c]
        white[r+1][c+1] = white[r+1][c]+grid_w[r][c]
for r in range(H):
    for c in range(W+1):
        black[r+1][c] += black[r][c]
        white[r+1][c] += white[r][c]
#print(grid_b,grid_w)
#print(black,white)
ret = 0
for r in range(K+1):
    for c in range(K+1):
        b = black[H][W]-black[H][c]-black[r][W]+2*black[r][c]
        w = white[H][c]+white[r][W]-2*white[r][c]
        #print(r,c,b,w)
        ret = max(ret,b+w)
        b = black[H][c]+black[r][W]-2*black[r][c]
        w = white[H][W]-white[H][c]-white[r][W]+2*white[r][c]
        #print(r,c,b,w)
        ret = max(ret,b+w)

print(ret)

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

int main() {
    int N,K,X,Y;
    cin>>N>>K>>X>>Y;
    
    int sum=0;
     
    if(N>K){
     cout<<K*X+(N-K)*Y<<endl;
    }
     else {
     cout<<N*X<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int ans[1005][1005];
priority_queue<pair<int, int> > que;
int main() {
	int n, m, a, b;
	cin >> n >> m >> a >> b;
	for (int i = 0; i <= n; i++) {
		int s = a * i + (m - a) * (n - i) - (n - b) * m;
		int k = 2 * b - n;
		if (!k || (k && s % k == 0)) {
			int j = (k ? s / k : 0);
			if (j < 0 || j > m) continue;
			for (int c = 1; c <= m; c++) {
				que.push(make_pair(c <= j ? b : n - b, c));
			}
			for (int r = 1; r <= n; r++) {
				int g = r <= i ? a : m - a;
				vector<pair<int, int> > vec;
				while (g--) {
					pair<int, int> p = que.top(); que.pop();
					p.first--;
					ans[r][p.second] = 1;
					if (p.first) vec.push_back(p);
				}
				for (pair<int, int> p : vec) que.push(p);
			}
			for (int r = 1; r <= n; r++, putchar('\n'))
				for (int c = 1; c <= m; c++)
					printf("%d", ans[r][c]);
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 5248
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();

		int number = Integer.parseInt(br.readLine());

		for(int i = 1; i <= number; i++){
			String count = String.valueOf(i);
				if(i % 3 == 0 || i % 10 == 3 || count.contains("3")){
					sb.append(" " +i);
				}
			}
		System.out.println(sb);
	}
}

Measured memory_bytes: 27184
#include  <cmath>
#include  <fstream>
#include  <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
using namespace std;

int Combination(int a, int b, int c)
{
    if(a==b && b==c)
    {
        return 1;
    }
    else if(a==b || b==c || c==a)
    {
        return 3;
    }
    else
    {
        return 6;
    }
}

int gcd(int a, int b)
{
    int min = a;
    if(a >b)
    {
        min = b;
    }

    int a_copy = a;
    int b_copy = b;
    int GCD = 1;
    for(int i=min; i>1; i--)
    {
        if(a_copy ==1 || b_copy ==1)
        {
            break;
        }
        else
        {
            if(a_copy%i ==0 && b_copy%i==0)
            {
                a_copy /= i;
                b_copy /= i;
                GCD *= i;
            }

        }
    }
    return GCD;
}

int gcd(int a, int b, int c)
{
    int GCD_AB = gcd(a, b);
    int GCD_ABC = gcd(GCD_AB, c);
    return GCD_ABC;
}

int SumGCD(int k)
{
    int Sum = 0;
    for(int a=1; a<=k; a++)
    { // a
        for(int b=a; b<=k; b++)
        { //b
            for(int c=b; c <=k; c++)
            {
                Sum += Combination(a, b, c) * gcd(a, b, c);
            }
        } //b end
    } // a end

    return Sum;
}

int main(void)
{
    int K;
    cin >> K;
    cout <<  SumGCD(K) << endl;



    return 0;
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        a[x] = i;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << a[i] << " ";
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh

int main(){
	dhoom;
	int n;
	cin >> n;
	map< int , int > mp;
	for(int i = 0 ; i < n ;i++){
		int x;
		cin >> x;
		if(mp[x] == 1)
			return cout << "NO",0;
		mp[x] = 1;
	}
	cout << "YES" <<endl;
	return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define PREP(i, s, x) for(ll i = (s); i < (x); i++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i--)
#define REP(i, x) PREP(i, 0, x)
using namespace std;
using ll = long long;
typedef long long ll;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

// ////////////////////////////////////////////

constexpr ll INF = (1ll << 60);
constexpr ll MOD = 998244353ll;

string d_kakko(string s) {
    stack<char> st;
    ll n = s.length();
    REP(i, n) {
        if(!st.empty() && st.top() == '(' && s[i] == ')') {
            st.pop();
            continue;
        } else {
            st.push(s[i]);
        }
    }
    string res = "";
    while(!st.empty()) {
        res += st.top();
        st.pop();
    }
    reverse(res.begin(), res.end());
    return res;
}

int main() {
    ll n;
    cin >> n;
    n %= 10;
    string ans = "";
    switch (n)
    {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
        ans = "hon";
        break;

    case 0:
    case 1:
    case 6:
    case 8:
        ans = "pon";
        break;    
    case 3:
        ans = "bon";
        break;
    }

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

Measured memory_bytes: 3600
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t K;

void rec(int64_t d, int64_t val, std::vector<int64_t> &lunlun)
{
	lunlun.push_back(val);
	if (d == 10) return;

	for (int64_t diff = -1; diff <= 1; diff++)
	{
		// 1の位だけ見る
		int64_t add = (val % 10) + diff;
		if (0 <= add && add <= 9) rec(d + 1, val * 10 + add, lunlun);
	}
}

void solve()
{
    std::cin >> K;
	std::vector<int64_t> lunlun;

	for (int64_t i = 1; i < 10; i++)
	{
		rec(1, i, lunlun);
	}

	std::sort(lunlun.begin(), lunlun.end());
	std::cout << lunlun[K - 1] << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 5324
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int E = sc.nextInt();
            if(E==0)break;
            
            int ans = E;
            
            for(int z=0;z*z*z<=E;z++){
                int Cz = z*z*z;
                for(int y=0;y*y<=E-z*z*z;y++){
                    int Sy = y*y;
                    int x = E - Cz - Sy;
                    
                    if(ans>x+y+z){
                        ans = x+y+z;
                    }
                }
            }
            
            System.out.println(ans);
            
        }
        
    }
}

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

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

lli lcm(lli a,lli b)
{
    return (a*b)/gcd(a,b) ;
}

int main() {
	lli a,b;
	cin >> a >> b ;
	cout << lcm(a,b);// your code goes here
	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
static const int INF = 2000000000;



int main(){
  int n;
  cin >> n;
  int ans;
  for (int i = 1; i*i <= n; i++){
    ans = i*i;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace std;
int main() {
	string S;
	cin >> S;
	int min=1000;
	for (int i = 0; i < S.size()-2; i++) {
		if(abs(753-stoi(S.substr(i,3)))<min){
		
			min = abs(753 - stoi(S.substr(i, 3)));
		
		}


	}

	cout << min;

}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, c;
    cin >> n >> c;
    auto d = make_vec<int>(c, c);
    rep(i, c) rep(j, c) cin >> d[i][j];
    auto g = make_vec<int>(n, n);
    rep(i, n) rep(j, n) cin >> g[i][j];
    rep(i, n) rep(j, n) g[i][j]--;
    auto cnt = make_vec<int>(3, c);
    rep(i, n) rep(j, n) {
        cnt[(i+j)%3][g[i][j]]++;
    }
    const ll inf = 1LL<<60;
    ll ans = inf;
    rep(i, c) rep(j, c) rep(k, c) {
        if (i == j || j == k || k == i) continue;
        ll res = 0;
        rep(from, c) {
            res += 1LL * d[from][i] * cnt[0][from];
            res += 1LL * d[from][j] * cnt[1][from];
            res += 1LL * d[from][k] * cnt[2][from];
        }
        chmin(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4232
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,l;
    while(cin >> n >> l,n){
        vector<pair<int,int>> v(n);
        for(int i=0;i<n;i++){
            char c; cin >> c;
            cin >> v[i].first;
            v[i].second=(c=='R'?1:-1);
        }
        int ti=0,id=-1;
        while(1){
            ti++;
            for(int i=0;i<n;i++){
                if(v[i].first==-1)continue;
                v[i].first+=v[i].second;
            }
            int jd=-1;
            for(int i=0;i<n;i++){
                if(v[i].first==0||v[i].first==l){
                    if(v[i].first==0)jd=i+1;
                    else if(jd==-1)jd=i+1;
                    v[i].first=-1;
                }
                else{
                    for(int j=i+1;j<n;j++){
                        if(v[i].first==v[j].first){
                            swap(v[i].second,v[j].second);
                            break;
                        }
                    }
                }
            }
            id=jd;
            bool ed=1;
            for(int i=0;i<n;i++){
                if(v[i].first!=-1){
                    ed=0;
                    break;
                }
            }
            if(ed)break;
        }
        printf("%d %d\n",ti,id);
    }
}


Measured memory_bytes: 3176
import sys
n = int(input())
a_ls = [int(i) for i in sys.stdin.readline().split()]
memo_ls = [[0 for j in range(n)] for i in range(n)]
for j in range(n):
    for i in range(j,-1,-1):
        if i == j:
            memo_ls[i][j] = a_ls[j]
        else:
            memo_ls[i][j] = max(- memo_ls[i+1][j] + a_ls[i], - memo_ls[i][j-1] + a_ls[j])
print(memo_ls[0][n-1])


Measured memory_bytes: 120284
#include <bits/stdc++.h>
using namespace std;
 
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>


///////////////////////////////////////////////////////////////////////////////////////////////////
 
void solve(int TC) { 
    int n; cin >> n;
    int a[n+1];
    for(int i=1; i<=n; i++) cin >> a[i];
    int ans = 0;
    for(int i=1; i<n; i++) if(a[i] == i) {
        swap(a[i], a[i+1]);
        ans++;
    }
    if(a[n] == n) ans++;
    cout << ans << endl;
}
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);
 
 
    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve(i);
    }
    return 0;
 
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n, m;
    cin >> n >> m;

    int sum = 0, tmp = 0;
    rep(i,0,m){
        cin >> tmp;
        sum += tmp;
    }

    if(n >= sum) cout << n-sum << "\n";
    else cout << "-1\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

int main(void){
	int h,m,s,x,y,diff;
	
	while(cin >> h >> m >> s){
		x = h * 3600 + m * 60 + s;
		cin >> h >> m >> s;
		y = h*3600+m*60+s;
		diff = y-x;
		h = diff / 3600;
		diff -= h * 3600;
		m = diff / 60;
		diff -= m * 60;
		printf("%d %d %d\n", h, m, diff);
	}
}

Measured memory_bytes: 0
/*
 * author: calgagi
 *         Calvin Gagliano 
 */
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ull unsigned long long
#define ii pair<int, int>
#define ar array
#define f first
#define s second
#define dd long double

void solve() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;

    return;
}

int main() {
    ios_base::sync_with_stdio(false);  
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count()); 
    
    int t = 1;
    /* cin >> t; */
    while (t--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3620
#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>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#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 SUM(s) accumulate(s.begin(), s.end(), 0LL);
#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); }

//同じ数が何個ずつあるか
vector<int> getSameNoCount(vector<int> list) {
	SORT(list);
	vector<int> result;
	int m = list[0];
	int c = 1;
	FOR(i, 1, list.size()) {
		if (m == list[i]) {
			c++;
		}
		else {
			result.push_back(c);
			c = 1;
			m = list[i];
		}
	}
	result.push_back(c);
	return result;
}

int main() {
	string s;
	cin >> s;
	int n = s.size();

	vector<vector<int>> dp(n);
	vector<int> a(n), c(n);
	rep(i, n) {
		a[i] = (int)s[n - 1 - i] - 48;
	}

	c[0] = a[0];
	int j = 1;
	rep(i, n - 1) {
		j = j * 10 % 2019;
		c[i + 1] = (c[i] + j * a[i + 1]) % 2019;
	}
	c.push_back(0);
	auto z = getSameNoCount(c);
	ll ans = 0;
	rep(i, z.size()) {
		ll m = z[i];
		ans += m * (m - 1) / 2;
	}
	cout << ans << endl;


}




Measured memory_bytes: 10384
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string,priority_queue<int>> layer;
    for (;N--;){
        string C; int D; cin >> C >> D;
        layer[C].emplace(D);
    }
    int M; cin >> M;
    vector<string> O(M);
    for (int i=0;i<M;++i) cin >> O[i];
    int now=INF;
    for (int i=M-1;i>=0;--i){
        while(!layer[O[i]].empty()&&now<=layer[O[i]].top()) layer[O[i]].pop();
        if (layer[O[i]].empty()){
            cout << "No" << '\n';
            return 0;
        }
        now=layer[O[i]].top();layer[O[i]].pop();
    }
    cout << "Yes" << '\n';
}


Measured memory_bytes: 27232
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = Integer.parseInt(sc.next());
        int bit = 0;
        for(int i=0; i<num; i++){
            bit |= Integer.parseInt(sc.next());
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

Measured memory_bytes: 21972
#include<stdio.h>
int main(){
  int n;
  int S[10001];
  int q;
  int T[501];
  int i,j;
  int ans=0;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++) scanf("%d",&T[i]);

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	ans++;
	break;
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}



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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=2e5+100;
bool cmp(int x,int y){return x>y;}
vector<int>p;
int st[N],en[N];
int stt[N],enn[N];
int main()
{
    int n,k,c;
    cin>>n>>k>>c;
    string s;cin>>s;
    int tot=1;
    int f=1;
    for(int i=0;i<s.size();i++){
        if(s[i]=='o'){
            st[tot++]=i,i=i+c;
        }
    }
    for(int i=s.size()-1,tot=k;i>=0&&tot>=1;i--){
        if(s[i]=='o'){
           stt[tot--]=i,i=i-c;
        }
    }
    for(int i=1;i<=k;i++)
        if(st[i]==stt[i]) p.push_back(st[i]+1);
    sort(p.begin(),p.end());
    for(auto v:p) cout<<v<<endl;
    return 0;
}
/*
10 3 1
oxxxoxxxoxxo
*/


Measured memory_bytes: 4216
# an = list(map(int, input().split()))
# n, m = map(int, input().split())
n = int(input())

cnt = 0
a = 1
while True:
  if n < a:
    break
  elif n < a * 10:
    cnt += n - a + 1
    break
  else:
    cnt += 9 * a
    a *= 100
print(cnt)

Measured memory_bytes: 2940