akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  int n;
  cin >> n;
  ll a[n];
  FOR(i,0,n) scanf("%lld", a + i);
  vector<ll> b(n);
  int r = n - 1;
  int l = 0;
  FOR(i,0,n) {
    if(i % 2 == 0) {
      b[l] = a[n - 1 - i];
      l++;
    }
    else {
      b[r] = a[n - 1 - i];
      r--;
    }
  }
  //reverse(b.begin(), b.end());
  FOR(i,0,n){
    printf("%lld%c", b[i], i == n-1 ? '\n' : ' ');
  }
  return 0;
}


Measured memory_bytes: 5248
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<functional>
using namespace std;

#define INF 1<<21
#define DIV 1000000007

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

int main() {
  int n,a=0,b=0;
  string s;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; i++) {
	if (s[i] == '(') {
	  a++;
	}
	else {
	  a--;
	  if (a == -1) {
		a = 0;
		b++;
	  }
	}
  }
  for (int i = 0; i < b; i++) {
	cout << '(';
  }
  cout << s;
  for (int i = 0; i < a; i++) {
	cout << ')';
  }
  cout << endl;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
allsum = 0
for i in range(1,n+1):
  sum = 0
  ti = i
  while True:
    sum += i%10
    if i//10 == 0:
      break
    i //= 10
  if sum >= a and sum <= b:
    allsum += ti
print(allsum)

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int n = 7;
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }

    int ans1 = 0;
    if (data[0] && data[3] && data[4]) {
        ans1 += 3;
        data[0]--; data[3]--; data[4]--;
        ans1 += (data[0] / 2) * 2;
        ans1 += (data[3] / 2) * 2;
        ans1 += (data[4] / 2) * 2;
        ans1 += data[1];
        data[0]++; data[3]++; data[4]++;
    }
    int ans2 = 0;
    ans2 += (data[0] / 2) * 2;
    ans2 += (data[3] / 2) * 2;
    ans2 += (data[4] / 2) * 2;
    ans2 += data[1];

    cout << max(ans1, ans2) << endl;

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 100009 /// I wanna be the wind
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a,b;
    cin>>a>>b;
    ll ans=0;
    rep(i,0,sz(a)){
        if(a[i]!=b[i])ans++;
    }
    cout<<ans<<"\n";
    return 0;  
}

Measured memory_bytes: 3820
n = int(input())
p = list(map(int, input().split()))
a = []
ans = 0
for i in range(1, n-1):
    a.append([p[i-1], p[i], p[i+1]])
for k in range(n-2):
    if min(a[k]) < a[k][1] < max(a[k]):
        ans += 1
    else:
        pass
print(ans)


Measured memory_bytes: 3060
#pragma comment(linker, "/STACK:102400000,102400000")
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#define LL long long
using namespace std;
const int M = 1e5 + 5, INF = 0x3f3f3f3f, mod = 1000007;
int A[M];
int main() {
    int n;
    scanf("%d",&n);
    for(int j=1;j<=n;j++) scanf("%d",&A[j]);
    int ans=0;
    for(int j=1;j<=n;j++){
        if(j==A[A[j]]) ans++;
    }
    printf("%d\n",ans/2);
    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if((a+b) == c || (b+c) == a || (c+a) == b){
		printf("Yes");
	}
	else{
		printf("No");	
	}
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
int num[maxn];
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::map;
map<string,int>mp;
int main()
{
    /**int n=read;
    int flag=1;
    for(int i=1;i<=n;i++)
    {
        num[i]=read;
        if(num[i]%2==0){
            if(num[i]%3!=0&&num[i]%5!=0)
                flag=0;
        }
    }
    if(flag==0) printf("DENIED\n");
    if(flag) printf("APPROVED\n");**/
    ll n;
    ios_base::sync_with_stdio(false);
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ///scanf("%s",ss);
        ///getchar();
        string ss;
        cin>>ss;
        mp[ss]++;
    }
    int maxx=-1;
    for(const auto& x : mp){
        int temp=x.second;
        if(temp>maxx) maxx=temp;
    }
    for(auto it=mp.begin();it!=mp.end();it++){
        if(it->second==maxx)
            cout<<it->first<<endl;
    }
	return 0;
}


Measured memory_bytes: 23808
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    int a, b;
    cin >> a >> b;
    cout << a*b << endl;
}


Measured memory_bytes: 3636
import sys
 
sys.setrecursionlimit(100000)
 
H, W = map(int, input().split())

stage = []
for h in range(H):
    a = list(input())
    stage.append(a)

memo = [[-1 for i in range(W)] for j in range(H)]

def move(x, y):
    if x >= W or y>=  H:
        return 0
    if x == W-1 and y == H-1:
        return 1
    if stage[y][x] == "#":
        return 0
    if memo[y][x] != -1:
        return memo[y][x]
    p = move(x+1, y)+move(x,y+1)
    memo[y][x] = p
    return p

print(move(0,0)%(10**9+7))

Measured memory_bytes: 167156
#include<bits/stdc++.h>
using namespace std;
#define BeatMeScanf ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define sz 150010
const int mod=1000000007;

int main(){
    BeatMeScanf;
    string s;
    while(cin>>s){
        if(s=="SUN") cout<<7<<endl;
        else if(s=="MON") cout<<6<<endl;
        else if(s=="TUE") cout<<5<<endl;
        else if(s=="WED") cout<<4<<endl;
        else if(s=="THU") cout<<3<<endl;
        else if(s=="FRI") cout<<2<<endl;
        else if(s=="SAT") cout<<1<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import collections
from functools import reduce
from operator import mul

N = int(input())
Hs = []


def cmb(n, r):
    try:
        r = min(n - r, r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1, r + 1))
        return over // under
    except:
        return 0


for line in range(N):
    l = list(input())
    l.sort()
    Hs.append(','.join(l).replace(',', ''))

c = collections.Counter(Hs)

su = 0
for v in c.values():
    su += cmb(v, 2)

print(su)


Measured memory_bytes: 20004
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    rep(i, n)
    {
        cin >> a.at(i);
        a[i]--;
        b[a[i]] = i;
    }
    ll now = 0;
    ll ans = 0;
    rep(i, n - 1)
    {
        if (b[i] < b[i + 1])
        {
            now++;
        }
        else
        {
            now = 0;
        }
        ans = max(ans, now);
    }
    ans = max(ans, now);
    cout << n - 1 - ans << endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;



int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int h, w;
	int ans = 0;
	cin >> h >> w;

	vector<string> mp(h);
	rep(i, 0, h) cin >> mp[i];

	rep(i, 0, h) rep(j, 0, w) if (mp[i][j] == '.') {
		vector<vi> dist(h, vi(w, 999));
		dist[i][j] = 0;

		queue<pair<int, int>> q;
		q.push({i, j});

		while (!q.empty()) {
			int a, b; tie(a, b) = q.front(); q.pop();
			const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
			rep(d, 0, 4) {
				int na = a + dir[d][0], nb = b + dir[d][1];
				if (0 <= na && na < h && 0 <= nb && nb < w && dist[a][b] + 1 < dist[na][nb] && mp[na][nb] == '.') {
					dist[na][nb] = dist[a][b] + 1;
					ans = max(ans, dist[na][nb]);
					q.push({na, nb});
				}
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
typedef long long ll;
using namespace std;
int main()
{
    long K, ans, i;    cin >> K;
    std::queue<long> que;
    for(i=1; i<=9; i++){
        que.push(i);
    }
    while(i <= K){
        long x = que.front();
        que.pop();
        if(x%10 != 0){
            que.push(x*10 + x%10 - 1);
            i = i+1;
        }
        if(i > K)  break;
        que.push(x*10 + x%10);
        i = i+1;
        if(i > K)  break;  
        if(x%10 != 9){
            que.push(x*10 + x%10 + 1);
            i = i+1;
        }
    }
    if(K >= 9)  ans = que.back();
    else    ans = K;
    cout << ans;
}

Measured memory_bytes: 4180
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<1<<endl;
    }
    else if(a!=b&&b!=c&&a!=c){
        cout<<3<<endl;
    }
    else if(a==b&&b!=c){
        cout<<2<<endl;
    }
    else if(b==c&&a!=c){
        cout<<2<<endl;
    }
    else if(a==c&&c!=b){
        cout<<2<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <limits>
#include <iomanip>
using namespace std;

int main(){

    int N;
    cin >> N;

    vector<long> A(N, 0);
    for( int i = 0 ; i < N ; i++ ) cin >> A[i];

    sort( A.begin(), A.end(), std::greater<long>() );

    bool bsame = false;
    for( int i = 0 ; i < N-1 ; i++ ){
        if( A[i+1] == A[i] ) bsame = true;
    }

    if( bsame )  cout << "NO" << endl;
    if( !bsame ) cout << "YES" << endl;

}

Measured memory_bytes: 1792
#include <string>
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>
#include <functional>

using namespace::std;

int main(void){
  string input;
  int total=0;


  getline(cin, input);

  stringstream ss(input);
  vector<int> a;

  string buf;

  while(!ss.eof()){
    ss >> buf;
    a.push_back(stoi(buf));
  }

  sort(a.begin(),a.end());
  for(int i=0;i<2;i++){
    total += abs(a.at(i)-a.at(i+1));
  }




  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<string>

#define ll long long
using namespace std;
#define MAX 200000



int N, M, numA[MAX], numB[MAX],x,y, isOK[MAX];
multiset<int> E[MAX];
string S;

void check(int i)
{
	if(isOK[i])
	{
		if(numA[i]==0 || numB[i]==0)
		{
			isOK[i]=0;
			if(S[i]=='A')
				for(auto a: E[i])
				{
					//cerr<<i<<" "<<a<<endl;
					--numA[a];
					check(a);
				}
			else
				for(auto a: E[i])
				{
					//cerr<<i<<" "<<a<<endl;
					--numB[a];
					check(a);
				}
		}
	}
}
int main()
{
	cin >> N>>M;
	cin>>S;
	for(int i=0; i<N; ++i)
		isOK[i]=1;
	for(int i=0; i<N; ++i)
		numA[i]=0;
	for(int i=0; i<N; ++i)
		numB[i]=0;
	for(int i=0; i<M; ++i)
	{
		cin>>x>>y;
		--x;--y;
		E[x].insert(y);
		if(x!=y)
			E[y].insert(x);
		if(S[y]=='A')
			++numA[x];
		else
			++numB[x];
		if(x!=y)
		{
			if(S[x]=='A')
				++numA[y];
			else
				++numB[y];
		}
	}
	for(int i=0; i<N; ++i)
		check(i);
	/*
	for(int i=0; i<N; ++i)
		cerr<<i+1<<" "<<isOK[i]<<" "<<numA[i]<<" "<<numB[i]<<endl;
	cerr<<endl;
	*/
	for(int i=0; i<N; ++i)
		if(isOK[i])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	cout<<"No"<<endl;
	return 0;
}


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

typedef long long LL;

vector<int> standard(vector<int> x) {
  for (int i = 0; i < 4; i++) x.push_back(x[i]);

  vector<int> ret = {10000, 10000, 100000, 100000};
  for (int j = 0; j < 4; j++) {
    vector<int> color;
    for (int k = 0; k < 4; k++) color.push_back(x[j + k]);
    if (ret > color) ret = color;
  }
  return ret;
}

LL MAX;
LL encode(const vector<int> x) {
  LL val = 0;
  for (int i = 0; i < 4; i++) {
    val *= 1000;
    val += x[i];
  }
  LL best = val;
  for (int i = 0; i < 4; i++) {
    val *= 1000;
    val %= MAX;
    val += x[i];
    best = min(best, val);
  }

  return best;
}

void dump(vector<int> x) {
  for (auto val : x) cout << val << " ";
  cout << endl;
}

int main() {
  MAX = 1000000;
  MAX *= MAX;
  int N;
  cin >> N;
  // map<vector<int>, int> colors;
  // map<vector<int>, int> muls;
  map<LL, int> colors;
  map<LL, int> muls;
  set<vector<int>> keys;
  for (int i = 0; i < N; i++) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<int> base_color = {a, d, c, b, a, d, c, b};
    vector<vector<int>> tmp_color;
    for (int j = 0; j < 4; j++) {
      vector<int> color;
      for (int k = 0; k < 4; k++) color.push_back(base_color[j + k]);
      tmp_color.push_back(color);
    }
    vector<int> color = standard(tmp_color[0]);
    colors[encode(color)]++;
    int mul = 0;
    for (int j = 0; j < 4; j++)
      if (tmp_color[0] == tmp_color[j]) mul++;
    muls[encode(color)] = mul;
    keys.insert(color);
  }

  LL ans = 0;
  vector<vector<int>> keyv;
  for (auto key : keys) {
    keyv.push_back(key);
  }

  for (auto low : keyv) {
    for (auto up : keyv) {
      for (int z = 0; z < 4; z++) {
        LL low_key = encode(low);
        LL up_key = encode(up);
        LL ret = 1;
        ret *= colors[low_key];
        colors[low_key]--;
        ret *= colors[up_key];
        colors[up_key]--;

        vector<LL> hozon;
        for (int i = 0; i < 4; i++) {
          vector<int> cur;
          cur = {low[(7 - i) % 4], low[(6 - i) % 4], up[(1 + i + z) % 4],
                 up[(i + z) % 4]};
          LL key = encode(cur);
          ret *= colors[key] * muls[key];

          colors[key]--;
          hozon.push_back(key);
        }
        for (auto key : hozon) {
          colors[key]++;
        }

        ans += ret;
        colors[low_key]++;
        colors[up_key]++;
      }
    }

    // colors[low] = 0;
  }
  cout << ans / 6 << endl;
  return 0;
}

Measured memory_bytes: 160384
#include<stdio.h>
#include<math.h>
#define pie 3.1415926535897
 
 void koch(int n,double p1x,double p1y,double p2x,double p2y){
       double sx,sy,tx,ty,ux,uy,th;
       if(n==0)return;
       th=pie*60.0/180.0;
       sx=(p1x*2.0+p2x*1.0)/3.0;
       sy=(p1y*2.0+p2y*1.0)/3.0;
       tx=(p1x*1.0+p2x*2.0)/3.0;
       ty=(p1y*1.0+p2y*2.0)/3.0;
       ux=(tx-sx)*cos(th)-(ty-sy)*sin(th)+sx;
       uy=(tx-sx)*sin(th)+(ty-sy)*cos(th)+sy;
       koch(n-1,p1x,p1y,sx,sy);
       printf("%f %f\n",sx,sy);
       koch(n-1,sx,sy,ux,uy);
       printf("%f %f\n",ux,uy);
       koch(n-1,ux,uy,tx,ty);
       printf("%f %f\n",tx,ty);
       koch(n-1,tx,ty,p2x,p2y);
       }
                    
 
 int main(){
       int n;
       double p1x;
       double p1y;
       double p2x;
       double p2y;
       p1x=0.0;
       p1y=0.0;
       p2x=100.0;
       p2y=0.0;
        
       scanf("%d",&n);
       printf("%f %f\n",p1x,p1y);
       koch(n,p1x,p1y,p2x,p2y);
       printf("%f %f\n",p2x,p2y);
       return 0;
       }


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

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

    
    cout << X+X*X+X*X*X << endl;
    return 0;
}

Measured memory_bytes: 3592
#!/usr/bin/env python3
import numpy as np
import math
import re

n = input()
n = re.split(" ",n)

if(abs(int(n[0]) - int(n[1])) <= int(n[3]) and abs(int(n[1]) - int(n[2])) <= int(n[3])):
    print('Yes')
elif(abs(int(n[0]) - int(n[2])) <= int(n[3])):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 12508
#include <stdio.h>
main(){
  int n,i,j,k,a[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",a[i]);
    if(i==0){
      printf("\n");
    }
    else{
      printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

	public static void main(String[] args)  {

		Scanner scaner = new Scanner( System.in );

		int first = Integer.parseInt( scaner.next() );
		int secand= Integer.parseInt( scaner.next() );

		String sign = "a == b";

		if ( first > secand ) {
			sign = "a > b";
		}
		else if ( first < secand ) {
			sign = "a < b";
		}

		System.out.println( sign );

		scaner.close();
	}

}

Measured memory_bytes: 26108
#include"bits/stdc++.h"
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define MX 500009 
#define INF 100000000009
using namespace std;
 
int main(){
    ll n;
    cin>>n;
    if(n%2==0)n--;
    cout<<n/2<<endl;
    return 0;
}

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

int E[300005], n;
char S[300005];

int main(){
    scanf("%d",&n);
    scanf("%*c%s",S+1);
    for(int i = 1; i <= n; i++){
        E[i] = E[i-1] + (S[i] == 'E');
    }
    int ans = n;
    for(int i = 1; i <= n; i++){
        ans = min(ans, (i-1 - E[i-1] + E[n] - E[i]));
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1664
import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static class Walk implements Comparable<Walk>{
		int cost,pose, x, y;
		
		public Walk(int cost, int pose, int x, int y) {
			super();
			this.cost = cost;
			this.pose = pose;
			this.x = x;
			this.y = y;
		}

		@Override
		public int compareTo(Walk arg0) {
			return this.cost - arg0.cost;
		}
	}
	
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);

		while(true){
			final int w = sc.nextInt();
			final int h = sc.nextInt();
			
			if(h == 0 && w == 0){
				break;
			}
			
			int[][] map = new int[h][w];
			
			for(int i = 0; i < h; i++){
				for(int j = 0; j < w; j++){
					map[i][j] = sc.nextInt();
				}
			}
			boolean[][][] is_visited = new boolean[h][w][4];
			
			int[] ops = new int[4];
			for(int i = 0; i < 4; i++){
				ops[i] = sc.nextInt();
			}
			
			int[][] st = {
					{1,0},
					{0,-1},
					{-1,0},
					{0,1}
			};
			
			
			PriorityQueue<Walk> queue = new PriorityQueue<Walk>();
			queue.add(new Walk(0, 0, 0, 0));
			
			
			while(!queue.isEmpty()){
				Walk wa = queue.poll();
				
				//System.out.println(wa.x + " " + wa.y + " " + wa.cost);
				
				if(wa.x >= w || wa.x < 0 || wa.y >= h || wa.y < 0){
					continue;
				}
				
				if(is_visited[wa.y][wa.x][wa.pose]){
					continue;
				}else{
					is_visited[wa.y][wa.x][wa.pose] = true;
				}
				
				if(wa.y == h-1 && wa.x == w-1){
					System.out.println(wa.cost);
					break;
				}
				
				for(int i = 0; i < 4; i++){
					int cost = map[wa.y][wa.x] == i ? 0 : ops[i];
					
					switch(i){
					case 0:
						queue.add(new Walk(wa.cost + cost, wa.pose, wa.x + st[wa.pose][0], wa.y + st[wa.pose][1]));
						break;
					case 1:
						queue.add(new Walk(wa.cost + cost, (wa.pose + 3) % 4, wa.x + st[(wa.pose + 3) % 4][0], wa.y + st[(wa.pose + 3) % 4][1]));
						break;
					case 2:
						queue.add(new Walk(wa.cost + cost, (wa.pose + 2) % 4, wa.x + st[(wa.pose + 2) % 4][0], wa.y + st[(wa.pose + 2) % 4][1]));
						break;
					case 3:
						queue.add(new Walk(wa.cost + cost, (wa.pose + 1) % 4, wa.x + st[(wa.pose + 1) % 4][0], wa.y + st[(wa.pose + 1) % 4][1]));
						break;
					default:	
						break;
					}
				}
			}
		}
	}

}

Measured memory_bytes: 13000
#include<iostream>
#include<numeric>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<climits>
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define rep(i,from,to) for(int i=from;i<to;i++)
#define repd(i,from,till) for(int i=from;i>=till;i--)
#define waste ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inf 1e9+1
#define mod 1e9+7
#define inf1 1e18+1
#define pie 3.14159265358979323846
#define N 100005

using namespace std;

int n,m;
vector <int> vec[100002];
int dp[100002];

int rec(int i){
	//cout<<i<<endl;
	if(vec[i].size(	)==0) return dp[i]=0;
	if(dp[i]!=-1)return dp[i];
	rep(j,0,vec[i].size()){
		dp[i]=max(dp[i],1+rec(vec[i][j]));
	}
	return dp[i];
}

int solve(){
    cin>>n>>m;
	rep(i,0,m){
		int a,b;
		cin>>a>>b;
		vec[a].pb(b);	
	}
	int maxi=-1;
	rep(i,0,100002)dp[i]=-1;
	rep(i,1,n+1){
		int a=rec(i);
		maxi=max(maxi,a);
	}
	cout<<maxi<<endl;
	return 0;
}
int main(){
    waste;
    int t;
    //cin>>t;
    t=1;
    while(t--){
       	solve();
    }
}


Measured memory_bytes: 8192
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <numeric>
#include <cmath>
#include <cstdlib>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
#define ALL(x) x.begin(), x.end()
#define INF (1001000000)
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i:c)
#define EXIST(cs,v) (find(ALL(cs),(v))!=cs.end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define UNIQ(c) (c).erase(unique((c).begin(),(c).end()), (c).end());
#define P(p) cout<<(p)<<endl;

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

    int n;
    cin >> n;

    REP(i, 100/4) {
        REP(j, 100/7) {
            if (4*i + 7*j == n) {
                P("Yes");
                return 0;
            }
        }
    }
    P("No");

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int h,w;
		while(true){
			h=sc.nextInt();
			w=sc.nextInt();
			if(h!=0||w!=0){
				for(int i=0;i<h;i++){
					for(int j=0;j<w;j++){
						if((i+j)%2==0){
							System.out.print("#");
						}
						else{
							System.out.print(".");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			else{
				break;
			}
		}
	}
}


Measured memory_bytes: 37808
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N;
  cin >> N;
  int d = 0, tmp = N;
  while(tmp) {
    d++;
    tmp /= 10;
  }
  int ans = 0, p = 1;
  for(int i=1; i<d; i+=2)
    ans += 9*pow(10, i-1);
  if(d%2)
    ans += N-(pow(10, d-1)-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=0;
	rep(i,22,b+1){
		int m=(i/10)*(i%10);
		if(i%10>=2&&1<=m&&m<=a)ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		S = S.replaceAll("eraser",  "-");
        S = S.replaceAll("erase",   "-");
        S = S.replaceAll("dreamer", "-");
        S = S.replaceAll("dream",   "-");
        S = S.replaceAll("-", "");
        if (S.length() == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
	}

}

Measured memory_bytes: 28960
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<ll>;

int main(){
   int n;
   cin >> n;
   
   int sum =0;
   for(int i=0;i<n;i++){
      int l,r;
      cin >>l >> r;
      sum += r-l+1;
   }

   cout << sum;

   return 0;
}
  
  

Measured memory_bytes: 256
def counting_sort(a, b, k):
	c = [0] * (k + 1)
	for i in range(len(a)):
		c[a[i]] += 1

	for i in range(1, k+1):
		c[i] = c[i] + c[i - 1]

	for i in range(len(a) - 1, -1, -1):
		c[a[i]] -= 1
		b[c[a[i]]] = a[i]

n = int(input())
a = list(map(int, input().split()))
b = [0] * n
counting_sort(a, b, max(a))
print(b[0], end='')
for i in range(1, n):
	print(' ' +  str(b[i]), end='')
print()



Measured memory_bytes: 224380
# include <iostream>

using namespace std;

int sum_of_digits(int num) {
    int rest, sum=0;
    while(num != 0) {
        rest = num % 10;
        sum += rest;
        num /= 10;
    }
    return sum;
}

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

    int res = 0;
    for (int i=1; i<=n; i++) {
        if (sum_of_digits(i) >= a && sum_of_digits(i) <= b) {
            res += i;
        }
    }
    cout << res << endl;

}

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

int main()
{
  string s;
  cin >> s;
  if(s[2]==s[3]&&s[4]==s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int dp[1024][1024];

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(q, N) {
    memset(dp, 0, sizeof(dp));
    string X, Y;
    cin >> X >> Y;
    int LX = X.size(), LY = Y.size();
    REP(i, LX) REP(j, LY) {
      if (X[i] == Y[j]) {
	dp[i+1][j+1] = max(dp[i][j] + 1, max(dp[i+1][j], dp[i][j+1]));
      } else {
	dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
      }
    }
    cout << dp[LX][LY] << endl;
  }
  return 0;
}

Measured memory_bytes: 5316
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCodeeeer
{
    class AtCOOOOOOOOOOOder
    {
        static void Main(string[] args)
        {
            long n = long.Parse(ReadLine());
            decimal divide = (decimal)(n / 2D);
            long ans = (long)(divide * (1 + n));

            WriteLine(ans - n);
        }
    }
}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    int a, b, c;
    cin >> a >> b >> c;
    int sum = a + b + c;
    cout << (sum >= 22 ? "bust" : "win");
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting, graph is not a tree/connected
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define mp make_pair

using namespace std;

typedef long long int64;
typedef vector<int> vi;
typedef pair<int, int> ii;

class TaskB {
 public:
  void solveOne(istream &in, ostream &out) {
    string s;
    in >> s;
    int left = -1;
    int right = s.size();
    while (right - left > 1) {
      int middle = (left + right) / 2;
      int minOdd = 1;
      int maxOdd = middle;
      if (!(maxOdd & 1)) --maxOdd;
      int minEven = 0;
      int maxEven = middle;
      if (maxEven & 1) --maxEven;
      for (char c : s) {
        int minDelta;
        int maxDelta;
        if (c == '0') {
          minDelta = maxDelta = -1;
        } else if (c == '1') {
          minDelta = maxDelta = 1;
        } else {
          minDelta = -1;
          maxDelta = 1;
        }
        int nminOdd;
        int nmaxOdd;
        if (minEven <= maxEven) {
          nminOdd = minEven + minDelta;
          nmaxOdd = maxEven + maxDelta;
        } else {
          nminOdd = 1;
          nmaxOdd = 0;
        }
        while (nminOdd < 0) nminOdd += 2;
        while (nmaxOdd > middle) nmaxOdd -= 2;
        int nminEven;
        int nmaxEven;
        if (minOdd <= maxOdd) {
          nminEven = minOdd + minDelta;
          nmaxEven = maxOdd + maxDelta;
        } else {
          nminEven = 1;
          nmaxEven = 0;
        }
        while (nminEven < 0) nminEven += 2;
        while (nmaxEven > middle) nmaxEven -= 2;
        minOdd = nminOdd;
        maxOdd = nmaxOdd;
        minEven = nminEven;
        maxEven = nmaxEven;
      }
      if (minOdd <= maxOdd || minEven <= maxEven) {
        right = middle;
      } else {
        left = middle;
      }
    }
    out << right << "\n";
  }

  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int it = 0; it < nt; ++it) {
      solveOne(in, out);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  TaskB solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m, a, b, q;
string s;

int main() {
    cin >> a >> b >> q;

    Vl s(a), t(b);
    REP(i, a) cin >> s[i];
    REP(i, b) cin >> t[i];

    sort(ALL(s));
    sort(ALL(t));

    REP(i, q) {
        ll x;
        cin >> x;
        ll mini = 1e18;

        auto sr = lower_bound(ALL(s), x);
        if (sr != s.end()) {
            auto srtr = lower_bound(ALL(t), *sr);
            if (srtr != s.end()) {
                mini = min(mini, abs(x - *sr) + abs(*sr - *srtr));
            }
            if (srtr != t.begin()) {
                mini = min(mini, abs(x - *sr) + abs(*sr - *(srtr-1)));
            }
        }
        if (sr != s.begin()) {
            auto sl = sr-1;
            auto sltr = lower_bound(ALL(t), *sl);
            if (sltr != t.end()) {
                mini = min(mini, abs(x - *sl) + abs(*sl - *sltr));
            }
            if (sltr != t.begin()) {
                mini = min(mini, abs(x - *sl) + abs(*sl - *(sltr-1)));
            }
        }

        auto tr = lower_bound(ALL(t), x);
        if (tr != t.end()) {
            auto trsr = lower_bound(ALL(s), *tr);
            if (trsr != s.end()) {
                mini = min(mini, abs(x - *tr) + abs(*tr - *trsr));
            }
            if (trsr != s.begin()) {
                mini = min(mini, abs(x - *tr) + abs(*tr - *(trsr-1)));
            }
        }
        if (tr != t.begin()) {
            auto tl = tr-1;
            auto tlsr = lower_bound(ALL(s), *tl);
            if (tlsr != s.end()) {
                mini = min(mini, abs(x - *tl) + abs(*tl - *tlsr));
            }
            if (tlsr != s.begin()) {
                mini = min(mini, abs(x - *tl) + abs(*tl - *(tlsr-1)));
            }
        }

        std::cout << mini << '\n';
    }


    return 0;
}


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

int main() {
        int h, w;
        cin >> h >> w;
        vector<string> s(h);
        rep(i, h) {
                cin >> s[i];
        }
        /*
        bool sw = false;
        if (s[0][0] == '#') {
                rep(i, h) rep(j, w) s[i][j] = ('#' ^ '.' ^ s[i][j]);
                sw = true;
        }
        */
        vector<vector<int>> dp(h, vector<int> (w));
        rep(i, h) {
                rep(j, w) {
                        if (i == 0 && j == 0) {
                                if (s[i][j] == '#') {
                                        dp[i][j] = 1;
                                } else {
                                        dp[i][j] = 0;
                                }
                        } else if (i == 0) {
                                dp[i][j] = dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#');
                        } else if (j == 0) {
                                dp[i][j] = dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#');
                        } else {
                                dp[i][j] = 
                                        min(dp[i - 1][j] + (s[i - 1][j] == '.' && s[i][j] == '#'),
                                            dp[i][j - 1] + (s[i][j - 1] == '.' && s[i][j] == '#'));
                        }
                }
        }
        cout << dp[h - 1][w - 1] << endl;
        return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n;ll sum,c,d,len;
int main()
{
    fastio;
    cin>>n;
    rep(i,1,n) {
        cin>>d>>c;
        len+=c;
        sum+=c*d;
    }
    cout<<len+(sum-1)/9-1;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,a,b,c=0; cin>>n;
	bool f = false;
	while(n--){
		cin>>a>>b;
		if(a==b){
			++c;
			if(c==3){
				f = true;
				break;
			}
		}
		else{
			c=0;
		}
	}
	if(f){
		cout<<"Yes"<<"\n";
	}
	else{
		cout<<"No"<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int K;
  cin >> K;

  if(K%7==0)  K/=7;
  K*=9;

  set<int> S;
  int now=10;
  for(int i=1;;i++){
    now%=K;
    if(now==1){
      cout << i << endl;
      return 0;
    }
    if(S.count(now)){
      cout << -1 << endl;
      return 0;
    }
    S.insert(now);
    now*=10;
  }

  return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    ll b[n];
    b[0] = a[0];
    repd(i, 1, n) {
        b[i] = b[i - 1] + a[i];
        b[i] %= mod;
    }

    ll ans = 0;
    repd(i, 1, n) {
        ans += a[i] * b[i - 1];
        ans %= mod;
    }

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



Measured memory_bytes: 6764
using System;

namespace ITP1_5_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 3; i <= n; i++)
                if (Check.Mult_Three(i) || Check.Cont_Three(i))
                    Console.Write(" " + i);
            Console.WriteLine();

        }
    }
    class Check
    {
        static public bool Mult_Three(int x)
        {
            if (x % 3 == 0) return true;
            else return false;
        }
        static public bool Cont_Three(int x)
        {
            if(x==0) return false;
            if (x % 10 == 3) return true;
            else return Cont_Three(x / 10);
        }
    }
}

Measured memory_bytes: 9364
n,q=gets.split.map(&:to_i)
edges=Array.new(n+1){Array.new}
(n-1).times{
  a,b=gets.split.map(&:to_i)
  edges[a] << b
  edges[b] << a
}
score=Array.new(n+1,0)
q.times{
  p,x=gets.split.map(&:to_i)
  score[p]+=x
}
visited=Array.new(n+1)
queue=[1]
until queue.empty?
  p=queue.shift
  visited[p]=true
  edges[p].each{|q|
    next if visited[q]
    score[q]+=score[p]
    queue << q
  }
end

puts score[1..n].join(" ")

Measured memory_bytes: 27388
#include<iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
const long long int mod1=1000000007;
const long long int mod2 = -1;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define pp pop_back                                       
#define ff first
#define ss second
#define ll long long int
#define ull unsigned long long int
#define ordered_set tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define ordered1 tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define inf mod1
ll gcd(ll a, ll b){
    ll c;
     while(b){
        c = b;
        b = a % b;
        a = c;
     }
     return a;
}
ll power1(ll a, ll b){
     if(b == 0) return 1;
     else if(b % 2) return a * power1(a, b - 1);
     else {
        ll temp = power1(a, b / 2);
        return temp * temp;
     }
}
ll power2(ll a, ll b, ll m){
     a %= m;
     if(b == 0) return 1;
     else if(b % 2) return (a * power2(a, b - 1, m)) % m;
     else{
        ll temp = power2(a, b / 2, m);
        return (temp * temp) % m;
     }
}
ll mod(ll x, ll p){
return (x % p + p) % p;
}
ll lcm(ll x, ll y){
return (x * y)/gcd(x, y);
}
int main(){
	fast;
	ll h = 1;
	//cin >> h;
    while(h--){
        char x;
        cin >> x;
        x++;
        cout << x << endl;
}
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	int n;
	cin >> n;
	int d[100010];
	for (size_t i = 0; i < n; i++)
	{
		cin >> d[i];
	}
	sort(d, d + n);
	int hi = 200000;
	int lo = 1;
	bool find = false;
	while (hi - lo > 1)
	{
		int mid = (hi + lo) / 2;
		int abc = 0;
		for (size_t i = 0; i < n; i++)
		{
			if (d[i] < mid) abc++;
		}
		int arc = n - abc;
		if (abc < arc) {
			lo = mid;
		}
		else {
			hi = mid;
		}
		if (abc == arc) find = true;
	}
	if (!find) {
		cout << 0 << endl;
	}
	else {
		int p = lower_bound(d, d + n, hi) - d;
		cout << d[p] - d[p - 1] << endl;
	}

}

int main() {
	//	COMinit();
	solv();

	return 0;
}
 

Measured memory_bytes: 640
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    int a, b, x;
    double h, theta;
    cin >> a >> b >> x;
    if(x <= (double)a*a*b/2){
        h = (double)2*x / (a*b);
        theta = 180 * acos(h / sqrt(b*b + h*h)) / M_PI;
    }
    else{
        h = 2*(b - (double)x / (a*a));
        theta = 180 * asin(h / sqrt(a*a + h*h)) / M_PI;
    }
    printf("%.10f\n", theta);
    return 0;
}

Measured memory_bytes: 256