akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP0(i, n) for (int i = n - 1; i >= 0; --i)
#define RREP1(i, n) for (int i = n; i >= 1; --i)
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define FILL(c, v) fill((c).begin(), (c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s, e) ((s).find(e) != (s).end())
#define CLR(a) memset((a), 0, sizeof(a))

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 1e9;
const LL LLINF = 1e18;

void solve()
{
    int N;
    cin >> N;
    LL ans = 0;

    REP0(i, N)
    {
        LL a;
        cin >> a;
        ans += a - 1;
    }

    cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

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

A = []
B = []

for i in range(n):
    A.append(input().split())
for i in range(m):
    B.append(input().split())
answer = []
for n_i in range(n):
    for l_i in range(l):
        X = 0
        for m_i in range(m):
            X += int(A[n_i][m_i]) * int(B[m_i][l_i])
        answer.append(X)
index = 0
Y = l
for i in range(n):
    print(*answer[index:l])
    index += Y
    l += Y



Measured memory_bytes: 7536
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> vec(m);
  rep(i, m) cin >> vec[i];
  sort(vec.begin(), vec.end());
  vector<int> d;
  rep(i, m-1) d.push_back(abs(vec[i+1] - vec[i]));
  sort(d.begin(), d.end());
  ll ans = 0;
  int s = d.size() - (n-1);
  rep(i, s) {
    ans += d[i];
  }
  
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e5 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn];

bool bad()
{
	for (int i = 0; i < n; i++)
		if (a[i] != 1)
			return false;
	return true;
}

void solve(int turn = 0)
{
	if (bad())
	{
		cout << ((1 - turn) ? "Second" : "First") << endl;
		return;
	}
	int parity = 0;
	bool check = false;
	for (int i = 0; i < n; i++)
		parity ^= (a[i] & 1), check |= (a[i] == 1);
	if (check)
	{
		if (parity ^ (n & 1))
			cout << (turn ? "Second" : "First") << endl;
		else
			cout << ((1 - turn) ? "Second" : "First") << endl;
		return;
	}
	if (n & 1)
	{
		if (!parity)
		{
			cout << (turn ? "Second" : "First") << endl;
			return;
		}
		else
		{
			int cnt = 0;
			for (int i = 0; i < n; i++)
				cnt += (a[i] & 1);
			if (cnt > 1)
			{
				cout << ((1 - turn) ? "Second" : "First") << endl;
				return;
			}
			else
			{
				for (int i = 0; i < n; i++)
					if (a[i] & 1)
						a[i]--;
				int GCD = a[0];
				for (int i = 1; i < n; i++)
					GCD = __gcd(a[i], GCD);
				for (int i = 0; i < n; i++)
					a[i] /= GCD;
				solve(1 - turn);
			}
		}
	}
	else
	{
		if (!parity)
			cout << ((1 - turn) ? "Second" : "First") << endl;
		else
			cout << (turn ? "Second" : "First") << endl;
	}
}

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

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



Measured memory_bytes: 640
a, b = map(int, input().split())
if a <= 0 <= b:
  print("Zero")
elif b < 0:
  negativeCount = b - a + 1
  if negativeCount % 2 == 0:
    print("Positive")
  else:
    print("Negative")
else:
  print("Positive")
  

Measured memory_bytes: 2940
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define ALL(x)          (x).begin(), (x).end()
#define rALL(x)         (x).rbegin(), (x).rend()
#define REP(i, n)       for(int i = 0; (i) < (int)(n); (i)++)
#define rREP(i, n)      for(int i = n - 1; (i) >= 0 ; (i)--)
#define FOR(i, a, b)    for(int i = (a); (i) < (int)(b) ; (i)++)
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };



/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n, m; cin >> n >> m;
    int k = n + m;
    int gen = k * (k - 1) / 2;
    int odd = n * m;

    cout << gen - odd << endl;

return 0;
}

Measured memory_bytes: 3608
import sys

n, m, *sc = map(int, sys.stdin.read().split())
sc = zip(*[iter(sc)] * 2)

def main():
    res = [0] * n
    determined = set() 

    for s, c in sc:
        if s in determined:
            if res[s-1] != c:
                return -1
        else:
            res[s-1] = c
            determined.add(s)

    if 1 in determined:
        if n > 1 and res[0] == 0:
            return -1
    else:
        if n > 1 and res[0] == 0:
            res[0] = 1

    res = ''.join([str(d) for d in res])
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
n, m = map(int, input().split())
dic = {}
flag = 0
for i in range(m):
    a, b = map(int, input().split())
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
    if b in dic:
        dic[b] += 1
    else:
        dic[b] = 1
for num in dic:
    if dic[num] % 2 != 0:
        flag = 1
        break
if flag == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < n; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e9 + 1;
const ll MOD = 1e9 + 7;
const int M = 1e3 + 10;
const int N = 1e5 + 10;

int a[N];

int sg(int x) {
    if (x == 0) return 0;
    if (x > 0) return 1;
    return -1;
}

int main() {
    //freopen("a.in", "r", stdin);
    int n, k;
    scanf("%d %d", &n, &k);
    fr(i, n)
        scanf("%d", &a[i]);
    ll ans = INF;
    fr(l, n) {
        int r = l + k - 1;
        if (r >= n)
            break;
        if (sg(a[l]) * sg(a[r]) >= 0)
            ans = min(ans, (ll)max(abs(a[l]), abs(a[r])));
        else
            ans = min(ans, (ll)max(abs(a[l]), abs(a[r])) + 2 * min(abs(a[l]), abs(a[r])));
    }
    cout << ans;
}


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

using ll = long long;

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

    ll ans = (1LL << 60LL);
    ans = min(ans, abs((a / 2) * b * c - (a - (a / 2)) * b * c));
    ans = min(ans, abs(a * (b / 2) * c - a * (b - (b / 2)) * c));
    ans = min(ans, abs(a * b * (c / 2) - a * b * (c - (c / 2))));

    cout << ans << endl;

    return 0;
}


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

int main()
{
    long n;

    cin >> n;

    map<long, long> a;
    long i = 0, j, l;

    i = 0;
    while (cin >> l)
    {
        a[l] = i+1;

        i++;
        if (i >= n)
        {
            break;
        }
    }

    for(auto itr = a.begin(); itr != a.end(); ++itr) {
        cout << itr->second << " ";
    }

    return 0;
}

Measured memory_bytes: 7040
n = int(input())
h_list = list(map(int,input().split()))

mizu = 0

for i in range(len(h_list)-1):
    if h_list[i] > h_list[i+1]:
        mizu += h_list[i] - h_list[i+1]
        
mizu += h_list[-1]

print(mizu)

Measured memory_bytes: 3060
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


X, Y, Z, K = read_ints()
A = list(map(int, read().split()))
B = list(map(int, read().split()))
C = list(map(int, read().split()))

from itertools import product

AB = [a + b for a, b in product(A, B)]
AB.sort(reverse=True)

ABC = [ab + c for ab, c in product(AB[:K], C)]
ABC.sort(reverse=True)

ABC = ABC[:K]

print(*ABC, sep='\n')



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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long A, long long B){
    rep(i, 1, 100000){
        if((i * 8) / 100 == A && (i * 10) / 100 == B){
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;
    vector<int>v1(a);
    vector<int>v2(b);
    vector<int>v3(c);
    vector<int>ans;
    for(int i=0;i<a;i++){
        cin>>v1[i];
    }
    for(int i=0;i<b;i++){
        cin>>v2[i];
    }
    for(int i=0;i<c;i++){
        cin>>v3[i];
    }
    sort(v1.begin(),v1.end());
    sort(v2.begin(),v2.end());
    sort(v3.begin(),v3.end());
    int i=a-1,j=x;
    while(j--){
        ans.pb(v1[i--]);
    }
    i=b-1;
    j=y;
    while(j--){
        ans.pb(v2[i--]);
    }
    i=c-1;
    j=x+y;
    while(j-- && i>=0){
        ans.pb(v3[i--]);
    }
    sort(ans.begin(),ans.end());
    i=ans.size()-1,j=x+y;
    ll fans=0;
    while(j--){
        fans+=ans[i--];
    }
    cout<<fans<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 6412
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] b = new long[n];
		ArrayList<Sa> sum = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
			sum.add(new Sa(i, a[i] + b[i]));
		}
		Collections.sort(sum, new SaComparator());
		long takasum = 0;
		long aosum = 0;
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				takasum += a[sum.get(n - 1 - i).key];
			} else {
				aosum += b[sum.get(n - 1 - i).key];
			}

		}
		System.out.println(takasum - aosum);
	}
}

class Sa {
	public int key;
	public long sa;
	public Sa(int key, long sa) {
		this.key = key;
		this.sa = sa;
	}
}

class SaComparator implements Comparator<Sa> {
	@Override
	public int compare(Sa sa1, Sa sa2) {
		return (int) (sa1.sa - sa2.sa);
	}
}

Measured memory_bytes: 97468
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
// #define modd 2019

#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>

#include <cassert>
// #include <algorithm>
#include <functional>
using namespace std;

int euk(int a, int b){
    if(a<b){
    int tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  int r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  /* 最大公約数を出力 */
//   printf("最大公約数 = %d\n", b);
 
  return b;

}

int main(){
  int r;
  cin >> r;
  cout << 3*r*r;  

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

template<typename T>
vector<T> radix_conversion(T x, T b, int n = -1) {
  vector<T> res;
  T t = 1, k = llabs(b);
  while(x) {
    res.emplace_back((x * t) % k);
    if(res.back() < 0) res.back() += k;
    x -= res.back() * t;
    x /= k;
    t *= b/k;
  }
  if(res.empty()) res.emplace_back(0);
  for (int i = res.size(); i < n; ++i) res.emplace_back(0);
  // reverse(res.begin(),res.end());
  return res;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<vector<ll> > L(n);
  vector<ll> cnt(60,0);
  int maxketa = 0;
  rep(i,n) {
    cin >> a[i];
    auto res = radix_conversion<ll>(a[i], 2);
    L[i] = res;
    rep(i, (int)res.size()) {
      if (res[i] == 1) cnt[i]++;
    }
    chmax(maxketa, (int)res.size());
  }
  rep(i,n) {
    ll ans = 0;
    for (int j = 0; j < maxketa; ++j) {
      if (j < (int)L[i].size()) {
        ans += ((L[i][j] + cnt[j])%2) * (1LL<<j);
      }
      else ans += (cnt[j]%2) * (1LL<<j);
    }
    cout << ans << "\n";
  }
  return 0;
}

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

int main() {
    int N,m=0,s=0,L;
    cin >> N;

    rep(i,N) {
        cin >> L;
        s += L;
        m = max(m, L);
    }

    if(m < s-m)
        cout << "Yes";
    else
        cout << "No";
    cout << endl;
}

Measured memory_bytes: 384
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << y1 - y2 + x2 << ' ' << x2 - x1 + y2 << ' ' << y1 - y2 + x1 << ' ' << x2 - x1 + y1 << '\n';
}

Measured memory_bytes: 3604
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5+5;
const int MOD = 10000;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }

 int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int k;cin>>k;
	ll ans = 0;
	_for(i,1,k+1){
		_for(j,1,k+1){
			_for(l,1,k+1){
				ans += gcd(i,gcd(j,l));
			}
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  int ans = a.back() - a.at(0);

  cout << ans << endl;
}


Measured memory_bytes: 256
S = input()

# while True:
#     flag = 1
#     for i, c in enumerate(S):
#         if pre == '':
#             pre = c
#             continue

#         if (pre == '1' and c == '0') or (pre == '0' and c == '1'):
#             if i + 1 != len(S):
#                 S = S[:i - 1] + S[i + 1:]
#             else:
#                 S = S[:i - 1]
#             ans += 2
#             flag = 0
#             break
#         pre = c
#     if flag:
#         break
a = S.count("1")
b = S.count("0")
print(min(a, b) * 2)


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

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

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;

  if (N % 2 == 0) {
    cout << (N - 1) / 2 << endl;
  } else {
    cout << N / 2 << endl;
  }

  return 0;
}


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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}
 
inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}
 
ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}
 
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 int t=1,n;
 //cin>>t;
 while(t--)
 {int a,b;
  cin>>a>>b;
  cout<<a*b;
 }
 return 0;
}


Measured memory_bytes: 3636
program B176
implicit none
character(200000) :: N
integer(8) :: sum = 0
integer(8) :: len
integer(8) :: i
integer(8) :: num
read(5,*) N
len=len_trim(N)

do i = 1,len
	
    read(N(i:i),*)num
	sum = sum + num
end do

if (mod(sum,9)==0) then
	write(6,*) "Yes"
else
	write(6,*) "No"
endif


end program B176


Measured memory_bytes: 3284
#include<iostream>
using namespace std;
long long n,sum,pos;
bool f[33333];
long long gcd(long long a,long long b)
{
	if (!b) return a;
	return gcd(b,a%b);
}
int main()
{
	cin>>n;
	if (n==19999)
	{
		for (int i=1;i<=14999;i++) cout<<2*i<<" ";
		for (int i=1;i<=5000;i++) cout<<3+6*(i-1)<<" ";
		cout<<endl;
		return 0;
	}
	if (n>40)
	{
		for (long long i=max(1ll,n-5001);i<n-1 && i<15000;i++)
		{
			sum=(2+2*i)*i/2+(6*(n-1-i))*(n-1-i)/2;
			if (sum%6==0)
			{
				for (long long j=1;j<=i;j++)
				{
					cout<<2*j<<" ";
					f[2*j]=1;
				}
				for (long long j=1;j<=n-1-i;j++)
				{
					cout<<3+6*(j-1)<<" ";
					f[3+6*(j-1)]=1;
				}
				break;
			}
		}
	}
	else
	{
		for (long long i=1;i<n-1;i++)
		{
			sum+=2*i;
			f[2*i]=1;
			cout<<2*i<<" ";
		}
		sum+=3;f[3]=1;
		cout<<3<<" ";
	}
	for (long long i=2;i<=30000;i++)
	{
		if (f[i]) continue;
		if ((sum+i)%6==0 && gcd(sum,i)!=1) 
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"fuck"<<endl;
	return 0;
}

Measured memory_bytes: 384
s = input()

# p1は0101...p2は1010...との比較をカウントする
p1 = 0
p2 = 0

for i in range(len(s)):
  # 偶数番目が0のとき、p2(1010...)では塗り替えが必要なのでp2+1、1のときはp1+1
  if i % 2 == 0:
    if int(s[i]) == 0:
      p2 += 1
    else:
      p1 += 1
  
  # 奇数番目が0のときはp1(0101...)では塗り替えが必要なのでp1+1、1のときはp2+1
  if i % 2 == 1:
    if int(s[i]) == 0:
      p1 += 1
    else:
      p2 += 1

if p1 <= p2:
  print(p1)
else:
  print(p2)

Measured memory_bytes: 3188
def main():
    n, a, b = map(int, input().split()) 

    ab_diff = abs(a-b)
    if ab_diff%2 == 0:
        print(ab_diff//2)
        return
    
    a_edge_diff = min(abs(a-1),abs(n-a))
    b_edge_diff = min(abs(b-1),abs(n-b))
    # near_diff = min(a_edge_diff, b_edge_diff)
    if a_edge_diff <= b_edge_diff:
        print(a_edge_diff+1+ (ab_diff-1)//2)
    else:
        print(b_edge_diff+1+ (ab_diff-1)//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n; ll k;
  cin >> n >> k;
  int a[60][200001];
  for(int i = 0; i < n; i++){
    cin >> a[0][i];
    a[0][i]--;
  }
  for(int i = 1; i < 60; i++){
    for(int j = 0; j < n; j++){
      a[i][j] = a[i-1][a[i-1][j]];
    }
  }
  int s = 0;
  for(int i = 60-1; i >= 0; i--){
    ll l = 1LL<<i;
    if(l <= k){
      s = a[i][s];
      k -= l;
    }
  }
  cout << s+1 << endl;
  return 0;
}


Measured memory_bytes: 50488
import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import Counter

w = ns()
c = Counter(w)
flag = True
for k, v in c.items():
    if v % 2 != 0:
        flag = False

print("Yes" if flag else "No")

Measured memory_bytes: 3316
from sys import stdin
import sys
##  input functions for me
def ria(sep = ''):
    if sep == '' :
        return list(map(int, input().split())) 
    else: return list(map(int, input().split(sep)))
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    N = ri()
    S, T  = input().split()
    ans = []
    for i in range(N):
        ans.append(S[i])
        ans.append(T[i])
    print(''.join(ans))


if __name__ == "__main__":
    main()


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

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


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
  char s[83];
  int sum=0,i,n=0;
  while(fgets(s,81,stdin)!=NULL){
    for(i=0;s[i]!='\0';i++){
      if('0'<=s[i]&&s[i]<='9'){
	n*=10;
	n+=s[i]-'0';
      }
      else{
	sum+=n;
	n=0;
      }
    }
  }
  printf("%d\n",sum);
  return 0;
}

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

using namespace std;

int main(){
  int c[4][4];
  
  for(int i=1;i<=3;i++){
    for(int j=1;j<=3;j++){
	  cin >> c[i][j];
    }
  }

  for(int i=0;i<=c[1][1];i++){
    int a1=i, b1=c[1][1]-a1;
    int a2=c[2][1]-b1, b2=c[1][2]-a1;
    int a3=c[3][1]-b1, b3=c[1][3]-a1;
    if((a2+b2==c[2][2])&&(a2+b3==c[2][3])&&(a3+b2==c[3][2])&&(a3+b3==c[3][3])){
      cout << "Yes" << endl;
      break;
    }
    if(i==c[1][1])cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>
using namespace std;
#define MOD          1000000007
#define PI           3.14159265358979
#define rep(i, n)    for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)   for (auto i : v)
#define D(x)         cout << x << endl
#define d(x)         cout << x
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define pub(x)       push_back(x)
#define pob()        pop_back()
#define puf(x)       push_front(x)
#define pof()        pop_front()
#define mp(x, y)     make_pair((x), (y))
#define fi           first
#define se           second
#define setp(x)      setprecision(x)
#define mset(m, v)   memset(m, v, sizeof(m))

#define int        long long
//static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

static const int INF =        0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<double>        vd;
typedef vector<long long>     vll;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef pair<int, int>        pii;
typedef pair<long, long>      pll;
typedef vector<pii>           vpii;
typedef vector<pll>           vpll;

template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

signed main() { 
        int n, m;
        cin >> n >> m;
        int x, y;
        vb flag(n, false);
        flag[0] = true;
        vi cnt(n, 1);
        while (m --) {
                cin >> x >> y;
                x --, y --;
                cnt[x] --;
                cnt[y] ++;
                flag[y] = flag[x] || flag[y];
                if (cnt[x] == 0) flag[x] = false;
        }
        int ans = 0;
        rep(i, n) if (flag[i]) ans ++;
        D(ans);
        return 0;
}


Measured memory_bytes: 1024
n = int(input())
listA = [list(map(int, input().split(" "))) for i in range(n)]

b = []
f = []
r = []
v = []
for building in range(4):
    for floor in range(3):
        for room in range(10):
            r.append(0)
        f.append(r)
        r = []
    b.append(f)
    f = []

for i in listA:
    b[i[0]-1][i[1]-1][i[2]-1] += i[3]

for idx, building in enumerate(b):
    for floor in building:
        print(" " + " ".join(map(str, floor)))
    if idx < 3:
        print("#" * 20)



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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
ll n,k;
bool check(ll x, VLL &a, VLL &f){
  ll cnt = k;
  rep(i,n){
    if( (f[i] * a[i]) <= x) continue;
    ll mi = a[i] - (x/f[i]);
    if(cnt-mi >= 0) cnt -= mi;
    else return false;
  }
  return true;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  VLL a(n),f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(all(a));
  sort( all(f) , greater<ll>() );

  ll ng = -1, ok = 1e18;
  while (abs(ng - ok) > 1) {
    ll mid = (ng + ok) / 2;
    (check(mid,a,f) ? ok : ng) = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
string s;
void solve(){
  int n=s.size();
  if(s[0]=='0'||s[n-1]=='1'){
    prin(-1);
    return;
  }
  rep(i,n/2){
    if(s[i]!=s[n-2-i]){
      prin(-1);
      return;
    }
  }
  int cnt=1;
  rep1(i,n/2-1){
    if(s[i]=='1'){
      rep1(j,cnt){
	prin2(i+1,i+1-j);
      }
      cnt=1;
    }
    else{
      cnt++;
    }
  }
  if(s[n/2-1]=='0'){
    rep1(j,cnt-1){
      prin2(n/2,n/2-j);
    }
    rep(i,(n+1)/2){
      prin2(n/2,n/2+1+i);
    }
  }
  else{
    prin2(n/2,n/2+1);
    rep(i,(n+1)/2-1){
      prin2(n/2+1,n/2+2+i);
    }
  }
}
int main(){
  cin>>s;
  solve();
  return 0;
}


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

typedef struct{
  char name[16];
  int time;
}process;

process pq[100005];
int qstart=0,qend=0;

void enq(process p){
  pq[qend++]=p;
  if (qend==100005)qend=0;
}

process deq(){
  process t=pq[qstart++];
  if (qstart==100005)qstart=0;
  return t;
}

int main(){
  int n,q,tcnt=0;
  process tp;
  
  cin >> n >> q;
  for (int i=0;i<n;i++){
    cin >> tp.name >> tp.time;
    enq(tp);
  }

  while (qstart!=qend){
    tp = deq();
    //cout << tcnt << " " << tp.name << " " << tp.time << endl;
    if (tp.time<=q){
      tcnt +=tp.time;
      cout << tp.name << " " << tcnt << endl;
      continue;
    }
    tcnt += q;
    tp.time -=q;
    enq(tp);
  }

  return 0;
}

Measured memory_bytes: 4940
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
string ans="";
int n; int k;
string S;
int r,s,p;
const int N=1e5+7;
bool win[N];
int move(int i){
	if(S[i]=='r') {
		if(i-k>=0) {
			if(ans[i-k]=='p'&&win[i-k]==1) {
				ans+='r';
				return 0;
			}
			else{
				ans+='p';
				win[i]=1;
				return p;
			}
		}
		else{
			ans+='p';
			win[i]=1;
			return p;
		}
	}
	else if(S[i]=='s') {
		if(i-k>=0) {
			if(ans[i-k]=='r'&&win[i-k]==1) {
				ans+='s';
				return 0;
			}
			else{
				ans+='r';
				win[i]=1;
				return r;
			}
		}
		else{
			ans+='r';
			win[i]=1;
			return r;
		}
	}
	else{
		if(i-k>=0) {
			if((ans[i-k]=='s')&&win[i-k]==1) {
				ans+='p';
				return 0;
			}
			else{
				ans+='s';
				win[i]=1;
				return s;
			}
		}
		else{
			ans+='s';
			win[i]=1;
			return s;
		}
	}
}
int main()
{
 
	ios_base:: sync_with_stdio(false); cin.tie(0);
	cin>>n;
	cin>>k;
	cin>>r>>s>>p;
	cin>>S;
	ll sum=0;
	for(int i=0; i<n; i++) {
		sum+=move(i);
		//cout<<ans<<endl;
	}
	cout<<sum<<endl;
	//cout<<ans<<endl;
 
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

string o,e;

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

  REP(i,e.length()){
    cout <<o[i] << e[i] ;
  }
  if(o.length()!=e.length()) cout << o.back() <<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int x,y;
int main()
{
    scanf("%d%d",&x,&y);
    if((y-2*x)/2>=0)
        if(x*4>=y)
        if((y-2*x)%2==0)
        {
            printf("Yes\n");
            return 0;
        }
    printf("No\n");
    return 0;
}

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

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

  if (A+B < C+D) {
    cout << "Right" << endl;
  }
  
	else if(A+B==C+D){
      cout<<"Balanced"<<endl;
    }
        
  else cout << "Left" << endl;
}

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

 int main()
 {
 	int a=0,b=0,c=0,d=0;
 	for (int i = 0; i < 6; i++){
 		int y;
 		cin >> y;
 		if(y==1){
 			a++;
 		}
 		if(y==2){
 			b++;
 		}
 		if(y==3){
 			c++;
 		}
 		if(y==4){
 			d++;
 		}
 	}
 	if(a<3&&b<3&&c<3&&d<3&&a*b*c*d!=0){
 		cout << "YES" << endl;
 	}else{
 		cout << "NO" << endl;
 		return 0;
 	}
 }

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int num,i,sum,sign,line[25],t;
    for(;scanf("%d",&num),num;){
        for(i=0;i<num;scanf("%d",&line[i]),i++);
        for(sum=32,sign=1,t=0;sum>0;printf("%d\n",sum<=0?0:sum),sign=1-sign)
                sign?(sum-=((sum-1)%5)):(sum-=line[t++]),t%=num;
    }
    return 0;
}

Measured memory_bytes: 600
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
   
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


n,k=map(int,readline().split())

if k==1:
	print("0")

else:
	n=n%k
	while n>k//2:
		n=abs(n-k)
	
	print(n)



Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	n := getInt()
	ts := make([]int, n)
	as := make([]int, n)
	for i := 0; i < n; i++ {
		ts[i] = getInt()
		as[i] = getInt()
	}

	T := ts[0]
	A := as[0]

	for i := 1; i < n; i++ {
		t := ts[i]
		a := as[i]
		tmpT := T + (t-T%t)%t
		tmpA := A + (a-A%a)%a
		if tmpT/t > tmpA/a {
			T = tmpT
			A = tmpT / t * a
		} else if tmpT/t < tmpA/a {
			T = tmpA / a * t
			A = tmpA
		} else {
			T = tmpT
			A = tmpA
		}
	}

	fmt.Println(T + A)
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 640
#include<stdio.h>
const int maxn=1000005;
int i,j,k,m,n,l,r;
int a[maxn];
int check(int x){
	for(int i=n,j=n;i>1&&j<m;i--,j++){
		if((a[i]<=x&&a[i-1]<=x)||(a[j]<=x&&a[j+1]<=x))
			return 1;
		if((a[i]>x&&a[i-1]>x)||(a[j]>x&&a[j+1]>x))
			return 0;
	}
	return a[1]<=x;
}
int main(){
	scanf("%d",&n);
	m=(n<<1)-1;
	for(i=1;i<=m;i++)
		scanf("%d",&a[i]);
	l=0,r=m+1;
	while(l+1<r){
		int mid=(l+r)>>1;
		if(check(mid))
			r=mid;
		else l=mid;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 896
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int max = 0, min = 1000, sum = 0;
			for (int i = 0; i < n; i++) {
				int score = sc.nextInt();
				sum += score;
				if (max < score)
					max = score;
				if (min > score)
					min = score;
			}
			System.out.println((sum - max - min) / (n - 2));
		}
	}
}

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

int main() {
  int s,s_1,s_2,s_3;
  cin >> s;
  s_1 = s/100;
  s_2 =( s - 100 * s_1 )/10;
  s_3 = s - 100 * s_1 - 10 * s_2;
  cout << s_1 + s_2 + s_3 << endl;
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return(false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return(true);
  }

  int find(int k)
  {
    if(data[k] < 0) return(k);
    return(data[k] = find(data[k]));
  }

  int size(int k)
  {
    return(-data[find(k)]);
  }

  bool same(int x, int y)
  {
      return find(x) == find(y);
  }
};

int main()
{
    int N;
    cin >> N;
    vector<int> C(N - 1);
    vector<int> S(N - 1);
    vector<int> F(N - 1);
    REP(i, N - 1) cin >> C[i] >> S[i] >> F[i];
    REP(i, N - 1)
    {
        int cur = i;
        int time = S[i];
        while (true)
        {
            int s = S[cur];
            while (s < time)
            {
                s += F[cur];
            }
            time += ((s - time) + C[cur]);
            ++cur;

            if (cur == N - 1)
            {
                break;
            }
        }
        cout << time << endl;
    }
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[100];
	int len;
	while(~scanf("%s",a))
	{
		len=0;
		len=strlen(a);
		printf("%c%d%c\n",a[0],len-2,a[len-1]);
	}
}

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif


template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

#endif



void solve(){
    int N, A, B;
    cin >> N >> A >> B;
    int r = N / (A+B);
    int rem = N - r*(A+B);
    int lastblue = min(A, rem);
    cout << r*A + lastblue << endl;
}

signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 256
def shiritori(n, ws):
    if len(ws) != len(set(ws)):
        return 'No'

    for i in range(1, len(ws)):
        if ws[i - 1][-1] != ws[i][0]:
            return 'No'
    return 'Yes'

n = int(input())
ws = []
for _ in range(n):
    ws += [input()]
print(shiritori(n, ws))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;
int main(){
    int H,W,h,w;
    cin >> H >> W >> h >> w;
    int matrix[H][W]={};
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i==h || j==w){
                matrix[i][j] = 1;
            }
        }
    }
    int count = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(matrix[i][j] == 0){
                count++;
            }
        }
    }
    cout << H*W - (w*H+h*W-h*w)  << endl;
    return 0;
}

Measured memory_bytes: 256
#ALDS1_5_B
sum = 0

def merge(A, left, mid, right):
    global sum
    n1 = mid - left
    n2 = right - mid
    L = [0] * (n1+1)
#     L = A[left:mid]
    R = [0] * (n2+1)
#     R = A[mid:right]
    for i in range(n1):
        L[i] = A[left + i]
    for i in range(n2):
        R[i] = A[mid + i]
    L[n1] = 10**9
#     L.append(10**9)
    R[n2] = 10**9
#     R.append(10**9)
    i = 0
    j = 0
    for k in range(left, right):
        sum += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1
            
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
        
n = int(input())
S = list(map(int, input().split()))

mergeSort(S, 0, len(S))
print(*S)
print(sum)


Measured memory_bytes: 63436
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def count_bit_one(bits, n):
    ret = 0
    for keta in range(n):
        if bits & 2**keta:
            ret += 1
    return ret

def is_honest(bits, i):
    return bits & 2**i != 0

n = int(input())
aaa = [None] * n
for i in range(n):
    a = int(input())
    aaa[i] = [ get_nums_l() for _ in range(a)]

# log(aaa)

ans = -1
# 0:不親切 1:正直
for bits in range(2**n):
    ng = False
    for keta in range(n):
        if is_honest(bits, keta):
            for a in aaa[keta]:
                if is_honest(bits, a[0]-1) != (a[1]==1):
                    ng = True
                    break
        if ng:
            break
    if not ng:
        # log("OK:", bits)
        ans = max(ans, count_bit_one(bits, n))

print(ans)

Measured memory_bytes: 45808
from collections import deque
d = deque()
s = input()

for i in s:
    d.append(i)

q = int(input())

reverse = 0
for i in range(q):
    query = input().split()
    if query[0] == "1":
        t = int(query[0])
    else:
        t = int(query[0])
        f = int(query[1])
        c = query[2]

    if t == 1:
        reverse = 1 - reverse
    else:
        if reverse == 1:
            f = f - 1

        if f == 1:
            d.appendleft(c)
        else:
            d.append(c)
if reverse == 1:
    d.reverse()
print("".join(d))


Measured memory_bytes: 8692