akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = 0;
    ans += a * (n / (a+b));
    if(n%(a+b) < a){
        ans += (n%(a+b));
    }
    else{
        ans += a;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 256
function Main(input){
	input=input.split(/\n|\s/);
	input.forEach(function(e,i,a){a[i]=Number(a[i]);});
	
	ans=input[0];
	if(input[0]>input[1]){ans--;}
	
	console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 22076
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <array>
#include <climits>
#include <cassert>

using namespace std;

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

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = ll(1e5) + 5;
const double EPS = 10e-8;
const double PI = 3.14159265359;

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

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

int n, m;
vector<int> g[200005];
string ans = "IMPOSSIBLE";

int main() {
    cin >> n >> m;
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    REP(i, g[0].size()) {
        REP(j, g[g[0][i]].size()) {
            if (g[g[0][i]][j] == n - 1) ans = "POSSIBLE";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12016
/*
 * d.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int doms[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

/* typedef */

typedef long long ll;

/* global variables */

int domsums[13], sumf13s[401], yfds[400];

/* subroutines */

inline bool leap(ll y) {
  return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));
}

inline int ydays(ll y) { return leap(y) ? 366 : 365; }

inline int doy(ll y, int m, int d) {
  int dsm = domsums[m - 1] + d - 1;
  return (m > 2 && leap(y)) ? dsm + 1 : dsm;
}

void prevday(ll &y, int &m, int &d) {
  if (--d > 0) return;
  if (--m <= 0) y--, m = 12;
  d = doms[m - 1];
  if (leap(y) && m == 2) d++;
}

ll num_f13s(ll y, int m, int d) {
  ll num = 0;
  num += (y / 400) * sumf13s[400];
  y %= 400;
  num += sumf13s[y];

  int maxm = (d >= 13) ? m : m - 1;

  for (int m0 = 1; m0 <= maxm; m0++) {
    int dy13 = doy(y, m0, 13);
    if ((yfds[y] + dy13) % 7 == 5) num++;
  }

  return num;
}

/* main */

int main() {
  domsums[0] = 0;
  for (int i = 0; i < 12; i++) domsums[i + 1] = domsums[i] + doms[i];
  //for (int i = 0; i <= 12; i++) printf("%d ", domsums[i]); putchar('\n');

  int dsum = 6; // 2000/01/01 = Thursday
  sumf13s[0] = 0;
  for (int y = 0; y < 400; y++) {
    yfds[y] = dsum % 7;
    int fsum = 0;
    for (int m = 1; m <= 12; m++) {
      int dy13 = doy(y, m, 13);
      if ((dsum + dy13) % 7 == 5) fsum++;
    }
    sumf13s[y + 1] = sumf13s[y] + fsum;
    dsum += ydays(y);
  }
  //printf("%d\n", sumf13s[400]);
  
  ll y0, y1;
  int m0, m1, d0, d1;
  cin >> y0 >> m0 >> d0 >> y1 >> m1 >> d1;
  //printf("%lld/%02d/%02d - %lld/%02d/%02d\n", y0, m0, d0, y1, m1 ,d1);
  //printf("%d %d\n", doy(y0, m0, d0), doy(y1, m1, d1));

  prevday(y0, m0, d0);
  ll n0 = num_f13s(y0, m0, d0);
  ll n1 = num_f13s(y1, m1, d1);

  printf("%lld\n", n1 - n0);
  return 0;
}


Measured memory_bytes: 1160
h, w = gets.split.map(&:to_i)
s = (["."*(w+2)] + h.times.map{"." + gets.chomp + "."} + ["."*(w+2)]).map(&:chars)
puts ((1..h).to_a.product((1..w).to_a).all?{|i,j| s[i][j]=="." or [[i-1,j],[i+1,j],[i,j-1],[i,j+1]].any?{|a| s.dig(*a)=="#"}}) ? "Yes" : "No"

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

int n, c, x;
int D[30][30];
int t[3][30];

int main() {
    cin >> n >> c;
    rep(i, c) rep(j, c) cin >> D[i][j];
    rep(i, n) rep(j, n) {
        cin >> x;
        t[(i + j) % 3][x - 1]++;
    }
    int res = 1 << 30;
    rep(i, c) rep(j, c) if (i != j) rep(k, c) if (i != k && j != k) {
        int tt = 0;
        rep(l, c) tt += D[l][i] * t[0][l];
        rep(l, c) tt += D[l][j] * t[1][l];
        rep(l, c) tt += D[l][k] * t[2][l];
        if (tt < res) res = tt;
    }
    cout << res << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#define INF (1e9)
#define N c[n-1]*2-2
using namespace std;
int main(){
  int n,c[50],k=0;
  while(cin>>n&&n){
    k++;
    for(int i=0;i<n;i++)cin>>c[i];
    cout<<"Case #"<<k<<": ";
    if(c[0]==1){
      int dp[2001]={};
      for(int i=1;i<=N;i++)dp[i]=INF;
      for(int i=0;i<n;i++)
	for(int j=c[i];j<=N;j++)
	  dp[j]=min(dp[j],dp[j-c[i]]+1);
      int f=0;
      for(int i=1;i<=N;i++){
	int a=0,s=i;
	for(int j=n-1;s!=0;j--){
	  a+=s/c[j];
	  s%=c[j];
	}
	if(a!=dp[i]){f=1;break;}
      }
      if(f)cout<<"Cannot use greedy algorithm"<<endl;
      else cout<<"OK"<<endl;
    }
    
    else cout<<"Cannot pay some amount"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1168
# coding: utf-8

import collections

def main():
    H, W = map(int, input().split())
    cnt = collections.Counter()
    for i in range(H):
        for c in input().strip():
            cnt[c] += 1
    cnts = list(cnt.values())
    l = len(cnts)

    if H % 2 and W % 2:
        for i in range(l):
            if cnts[i] % 2 != 0:
                cnts[i] -= 1
                break
    d = 0
    if H % 2:
        d += (W // 2) * 2
    if W % 2:
        d += (H // 2) * 2
    i = 0
    while d > 0 and i < l:
        if cnts[i] % 4 != 0:
            cnts[i] -= 2
            d -= 2
        i += 1

    for k in cnts:
        if k % 4 != 0:
            return "No"
    return "Yes"


print(main())


Measured memory_bytes: 3444
#include <stdio.h>
#include <math.h>

int n;
int a[100];
int count;

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void selectionsort() {
	for (int i = 0; i < n; i ++) {
		int mini = i;
		for (int j = i; j < n; j ++) {
			if (a[j] < a[mini]) {
				mini = j;
			}
		}
		if (i != mini) {
			swap(&a[i], &a[mini]);
			count ++;
		}
	}
}

void print() {
	for (int i = 0; i < n; i ++) {
		if (i > 0) printf(" ");
		printf("%d", a[i]);
	}
	printf("\n");
}

int main(void) {
	scanf("%d", &n);
	for (int i = 0; i < n; i ++) {
		scanf("%d", &a[i]);
	}
	selectionsort();
	print();
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 1032
using System;
using System.Collections.Generic;
using System.Linq;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadArrayInt();
            var Asort = A.OrderBy(i => i).ToArray();
            var used = new bool[N];
            var pat = new List<long>();
            for (int i = 1; Math.Pow(2, i) < Math.Pow(10, 10); i++) pat.Add((long)Math.Pow(2, i));
            var beki = pat.ToArray();
            var ans = 0L;
            var chk = 0L;
            var plus = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                if (used[i]) continue;
                used[i] = true;
                var num = beki[UpperBound(beki, Asort[i])] - Asort[i];
                var match = LowerBound(Asort, (int)num);
                if (num == chk)
                {
                    match += plus;
                }
                else
                {
                    plus = 0;
                    chk = num;
                }
                while (match < N && Asort[match] == num)
                {
                    if (!used[match])
                    {
                        ans++;
                        used[match] = true;
                        plus++;
                        break;
                    }
                    match++;
                    plus++;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static int LowerBound(int[] arr, int val)
        {
            if (arr[0] >= val) return 0;
            if (arr[arr.Length - 1] < val) return arr.Length;

            var low = 0;
            var high = arr.Length - 1;

            while (low + 1 < high)
            {
                var mid = (low + high) / 2;
                if (arr[mid] >= val) high = mid;
                else low = mid;
            }

            return high;
        }

        static int UpperBound(long[] arr, int val)
        {
            val++;
            if (arr[0] >= val) return 0;
            if (arr[arr.Length - 1] < val) return arr.Length;

            var low = 0;
            var high = arr.Length - 1;

            while (low + 1 < high)
            {
                var mid = (low + high) / 2;
                if (arr[mid] >= val) high = mid;
                else low = mid;
            }

            return high;
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 35232
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N = z()
while (N > 0):
    N -= 1000
print(abs(N))


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

vector<ll> prime(ll x) {
  vector<ll> vec;
  for (ll i = 2; i*i <= x; ++i) {
    if (x % i == 0) {
      vec.push_back(i);
      while (x % i == 0) x /= i;
    }
  }
  if (x > 1) vec.push_back(x);
  return vec;
}

int main() {
  ll a, b;
  cin >> a >> b;
  vector<ll> pria, prib;
  pria = prime(a); prib = prime(b);
  int i, j;
  i = j = 0;
  int cnt = 1;
  while (i < pria.size() && j < prib.size()) {
    if (pria[i] < prib[j]) { ++i; continue; }
    if (pria[i] > prib[j]) { ++j; continue; }
    ++i; ++j; ++cnt;
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long w[100001],v[100001],dp[3002][3002];
string s,t;
long long LIS(long long n, long long k)
{
    if(n==0 || k==0)
    {
        dp[n][k]=0;
        return 0;
    }
    
    if(dp[n][k]!=1000000000)
    return dp[n][k];
    
    if(s[n-1]!=t[k-1])
    {
      dp[n][k]=max(LIS(n-1,k),LIS(n,k-1));
      return dp[n][k];
    }
    else
    {
      dp[n][k]=LIS(n-1,k-1)+1;
      return dp[n][k]; 
    }
}
int main() {
	
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    
      long long n,i,j,k,sum=0,count=0,ans=0,x=0,y=0,l,r,m;
      cin>>s>>t;
      n=s.length();
      k=t.length();
     
      for(i=0;i<=n;i++)
      {
          for(j=0;j<=k;j++)
          dp[i][j]=1000000000;
      }
      
      sum=LIS(n,k);
      if(sum==0)
      return 0;
      
      string s2="";
      
       i=n;
      j=k;
      while(i>0 && j>0)
      {
          if(s[i-1]==t[j-1])
          {
              s2+=s[i-1];
              i--;
              j--;
          }
          else if(dp[i-1][j]>dp[i][j-1])
          {
              i--;
          }
          else
          j--;
      }
      reverse(s2.begin(),s2.end());
      cout<<s2;
   
	return 0;
}

Measured memory_bytes: 74252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF= 1e18;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N;
    cin >> N;
    vector<char> A(N);
    vector<char> B(N);
    for(int i = 0;i < N;i++) {
        cin >> A.at(i);
    }
    for(int i = 0;i < N;i++) {
        cin >> B.at(i);
    }
    vector<int> vec;
    for(int i = 0;i < N;i++) {
        if(A.at(i) == B.at(i)) {
            vec.push_back(0);
        }
        else {
            vec.push_back(1);
            i++;
        }
    }
    ll ret;
    if(vec.at(0) == 0) {
        ret = 3;
    }
    else {
        ret = 6;
    }
    for(int i = 1;i < vec.size();i++) {
        if(vec.at(i) == 0 && vec.at(i - 1) == 0) {
            ret = ret * 2 % MOD;
        }
        else if(vec.at(i) == 1 && vec.at(i - 1) == 0) {
            ret = ret * 2 % MOD;
        }
        else if(vec.at(i) == 1 && vec.at(i - 1) == 1) {
            ret = ret * 3 % MOD;
        }
    }
    cout << ret << endl;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int a2, b2, c2;
  int count = 0;
  a2 = a%2; b2 = b%2; c2 = c%2;
  
  if(a2!=b2 && a2!=c2){
    b++; c++; count++;
  }
  else if(b2!=a2 && b2!=c2){
    a++; c++; count++;
  }
  else if(c2!=a2 && c2!=b2){
    a++; b++; count++;
  }
  
  int ma = max(max(a,b), max(b,c));
  cout << count + (3*ma-a-b-c)/2;
  
  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
N = int(input())
counter = 0
arr = [int(i) for i in input().split(" ")]
flag = True
while flag:
    ret = []
    for i in range(len(arr)):
        if arr[i] % 2 == 1:
            flag = False
            break
        arr[i] = arr[i] >> 1
        if arr[i] % 2 == 1:
            counter = counter + 1
            flag = False
            break
    if flag:
        counter = counter + 1

print(counter)


Measured memory_bytes: 3060
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=10000000000000000LL;

int main() {
	int n;
	string s;
	cin>>n>>s;
	string s2=s;
	int h1=0,h2=0,h3=0;
	for(int i=0;i<n;++i){
		if(s[i]=='(')++h1;
		if(s[i]==')'){
			++h2;
			if(h1<h2)h3=max(h2-h1,h3);
		}
	}
	for(int i=0;i<h3;++i)s2='('+s2;
	for(int i=0;i<h1-h2+h3;++i)s2=s2+')';
	cout<<s2<<endl;
	return 0;
}


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

ll N, K, T, W, H, M, C;

const int MAX = 510000;
const int MOD = 1e9;

const double PI=3.14159265358979323846;

/*
long long fac[MAX], finv[MAX], inv[MAX];

vector<double> cx, cy, c;
 ll MM = 1e12;

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

std::vector<int> Eratosthenes(int n ){
    std::vector<bool> is_prime( n + 1 );
    for( int i = 0; i <= n; i++ ) is_prime[ i ] = true;
    std::vector<int> P;
    for( int i = 2; i <= n; i++ ){
        if( is_prime[ i ] ){
            for( int j = 2 * i; j <= n; j += i ){
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}*/

int length(vector<int> v, int u, int HW){
    if(v.size() == 0) return HW;
    if(v[0] > u) return v[0];
    if(v[v.size() - 1] < u) return HW - v[v.size()- 1] -1;
    else{
        int i = lower_bound(ALL(v), u)- v.begin();
        return v[i] - v[i-1] -1;
    }
}

int main(){
    cin >> N;
    string s;
    cin >> s;

    for(auto c : s){
        int t = c;
        char a = ((t-65) + N )%26 + 65;
        cout << a;
    }
    return 0;
}


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

#define MOD 1000000007
typedef unsigned long long ull;
typedef   signed long long sll;


#define N_MAX 100
#define M_MAX 100

ull n;
int a, b, c;

void swap_adj(ull *a, ull *b){
	ull tmp = *b;
	*b = *a;
	*a = tmp;
	return;
}

int comp(const void *a, const void *b){
	if (*(ull*)a > *(ull*)b) {
		return -1;
	} else if (*(ull*)a < *(ull*)b) {
		return +1;
	} else {
		return 0;
	}
}

int solve(){
	
	if (a <= c && b <= c) {
		printf("%d\n", a + b);
	} else if (a <= b && c <= b) {
		printf("%d\n", a + c);
	} else {
		printf("%d\n", b + c);
	}

	return 0;
}

int main(void){

	scanf("%d%d%d", &a, &b, &c);

	solve();

	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int m, n,i, j, a[101][101];
	long long int sum1[101]={},  ma[101] = {},sum2=0;
	cin >> m >> n;
	for (i = 0; i < m; i++)
		for (j = 0; j < n; j++)
		{
			cin >> a[i][j];
			sum1[i] += a[i][j];
			ma[j] += a[i][j];
		}
	for (i = 0; i < m; i++)
	{
		for (j = 0; j < n; j++)
			cout << a[i][j]<<" ";
		cout << sum1[i] << endl;
	}
	for (j = 0; j < n; j++)
		cout << ma[j] << " ";
	for (i = 0; i < m; i++) sum2 += sum1[i];
	cout << sum2 << endl;
	return 0;
}


Measured memory_bytes: 3112
S = input()
T = input()

# S = "cabacc"
# T = "abc"

lt = len(T)

def diff(s1, s2):
    d = len(s1)

    d -= len([i for i,j in zip(s1, s2) if i == j])
    return d

dlen = 1000000000
for i in range(len(S)):
    if i + lt <= len(S):
        dlen = min(dlen, diff(T, S[i:i+lt]))

print(dlen)


Measured memory_bytes: 9016
import math
a, b, x = map(int, input().split())
if a * a * b == x:
  print(0.0)
elif (a * a * b) / 2 > x:
  t = 2 * x / (a * b * b)
  print(90.0 - math.degrees(math.atan(t)))
else:
  t = (a**3) / (2 * (a*a*b-x))
  print(90.0 - math.degrees(math.atan(t)))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}




int main() {

	string S;
	cin >> S;

	if (S == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;

	return 0;

}


Measured memory_bytes: 3596
import java.util.*;
 
public class Main {
  public static void main(String[] args) {
    int go = 0;
    int hya = 0;
    int gozyu = 0;
    int sum = 0;
    int count = 0;
    Scanner sc = new Scanner(System.in);
    go = sc.nextInt();
    hya = sc.nextInt();
    gozyu = sc.nextInt();
    sum = sc.nextInt();
    
    int i = 0;
    int j = 0;
    int k = 0;
    for(i = 0; i <= go; i++){
        for(j = 0; j <= hya; j++){
            for(k = 0; k <= gozyu; k++){
                if(500*i+100*j+50*k==sum){
                    count++;
                }
            }
        }
    }
    System.out.println(count);
    } 
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"
using namespace std;

int64_t mod = 1000000007;

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

	int ans = 0;
	int min_abs = 1000;
	int temp;
	for (int i = 1; i <= n; i++) {
		int num = l + i - 1;
		ans += num;
		if (abs(num) < min_abs) {
			min_abs = abs(num);
			temp = num;
		}
	}
	ans -= temp;

	cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define ALL(obj) (obj).begin(), (obj).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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


int main() {
    cout<<fixed<<setprecision(10);

    ll n,m; cin>>n>>m;
    vvint edges(n);
    rep(i,m){
        ll a,b; cin>>a>>b;
        a--; b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    set<ll> used;
    vint v1, v2;
    v1.push_back(0);
    v2.push_back(edges[0].front());
    used.insert(0);
    used.insert(edges[0].front());

    while(true){
        bool ok = true;

        for(auto e:edges[v1.back()]){
            if(used.count(e)) continue;
            v1.push_back(e);
            used.insert(e);
            ok = false;
            break;
        }

        if(ok) break;
        else continue;
    }

    while(true){
        bool ok = true;

        for(auto e:edges[v2.back()]){
            if(used.count(e)) continue;
            v2.push_back(e);
            used.insert(e);
            ok = false;
            break;
        }

        if(ok) break;
        else continue;
    }

    cout<<v1.size()+v2.size()<<endl;
    repr(i, v1.size()) cout<<v1[i]+1<<" ";
    rep(i, v2.size()) cout<<v2[i]+1<<" ";
    cout<<endl;

    return 0;

}

Measured memory_bytes: 11764
#include <iostream>
//#include <string>
#include <algorithm>
using namespace std;
//#define int long long
//#define _DEBUG
class UnionFindTree{
    private:
    int P[10010];
    public:
    UnionFindTree(int N){
        for(int i=0; i<=N; i++) P[i] = i;
    }
    int root(int a){
        if (P[a] == a) return a;
        return (P[a] = root(P[a]));
    }
    bool is_same_set(int a, int b){
        return root(a) == root (b);
    }
    void unite(int a, int b){
        P[root(a)] = root(b);
    }
};
struct weight_edge{// (weight, (vert_a,vert_b))
    int w;
    int a;
    int b;
};
int n, k;
weight_edge we[10007];
bool com_we(weight_edge a, weight_edge b){
    return ((a.w == b.w)? a.a < b.a: a.w < b.w);
}
int solve(){
    if(n==0)return 0;
    sort(we, we+k, com_we);
    //for(int i=0; i<k; i++)printf("%d,%d,%d\n",we[i].w,we[i].a,we[i].b);
    auto uft = UnionFindTree(n);
    int i=0, r=0, l=0;
    while(l<n-1){
        if(!uft.is_same_set(we[i].a, we[i].b)){
            uft.unite(we[i].a, we[i].b);
            r += we[i].w;
            l++;
            //printf("%d;\tw:%d,\t(%d,%d)\n",l,we[i].w,we[i].a,we[i].b);
        }
        i++;
    }
    return r;
}
void get(){
    k = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int t;
            cin >> t;
            if(i<j && t>=0){
                we[k].w = t;
                we[k].a = i; we[k].b = j;
                k++;
            }
            //cout << t<<":"<<i<<","<<j<<"\t";
        }
        //cout << endl;
    }
    //cout << "k"<<k<<endl;
}
signed main(){    
    while(cin >> n){
        get();
        cout << solve() <<  endl;
    }
}


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

N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]

ans = 0
for i in range(N):
    d = min(A[i],B[i])
    ans += d
    B[i] -= d
    d = min(A[i+1],B[i])
    ans += d
    A[i+1] -= d

print(ans)


Measured memory_bytes: 18624
#include<stdio.h>
int main(void){
  int n,i,p,score1=0,score2=0;
  char card1[101],card2[101];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%s",&card1);
      scanf("%s",&card2);
      p = strcmp(card1,card2);
      if(p == 0){score1++; score2++;}
      else if(p>0){score1+=3;}
      else{score2 +=3;}
    }
  printf("%d %d\n",score1,score2);
  return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
#include <math.h>
#include <sstream>
#include <deque>
#include <string>
#include <map>
#include <cctype>
#include <cstring>
#include <cstdio>
const int M = 1e9 + 7;
#define start \
    int t;    \
    cin >> t; \
    while (t--)
#define ll long long int
#define loop(i, a, b) for (ll i = a; i < b; i++)
#define pb(x) push_back(x)
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);
using namespace std;


// 1<<16 = 2^16

//insta  -------  __ansh7
//MSDIAN



int main()
{
    string s;
    cin>>s;

    ll k=s.length();

    if(s[k-1]!='s')
    {
        cout<<s<<"s";
    }
    else
    {
        cout<<s<<"es";
    }





  


    return 0;
}

//sk mc

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

import collections
import fractions


A, B = map(int, input().split())


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

gcd = fractions.gcd(A, B)
c = collections.Counter(prime_factorize(gcd))

print(len(c.keys()) + 1)


Measured memory_bytes: 5056
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		String val = sc.next().trim();

		String[] vals = new String[3];
		vals[0] = val.substring(0, 1);
		vals[1] = val.substring(1, 2);
		vals[2] = val.substring(2, 3);

		int count=0;

		for(int i = 0; i<3; i++){
			if (vals[i].equals("1")){
				count ++;
			}
		}

		System.out.println(count);

		sc.close();
	}

}

Measured memory_bytes: 21844
using System;

namespace _2424
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                long x = long.Parse(Console.ReadLine());
                int ret = 0;
                while (x > 9)
                {
                    ret++;
                    long max = 0;
                    string s = x.ToString();
                    for (int j = 1; j < s.Length; j++)
                    {
                        max = Math.Max(max,int.Parse(s.Substring(0,j)) * int.Parse(s.Substring(j,s.Length - j)));
                    }
                    x = max;
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9420
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as MP
import Data.Char
import Data.List

step :: MP.Map Int Int -> Int -> MP.Map Int Int
step m x =
    case MP.lookup x m of
        Just _ -> MP.adjust (+1) x m
        Nothing -> MP.insert x 1 m

solve :: [Int] -> Int -> Int -> Int
solve [] _ _ = 0
solve (x:xs) k l
    | l <= k = 0
    | otherwise = x + solve xs k (l-1)

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    as <- VU.unfoldrN n (B.readInt . B.dropWhile isSpace) <$>  B.getLine
    let m = VU.foldl' step MP.empty as
    print $ solve (sort $ MP.elems m) k (MP.size m) 


Measured memory_bytes: 46460
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define INF 1000000009
#define LINF 1000000000000000009
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmax(T &a, const T&b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T&b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int main() {
	int h, n;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		h -= a;
	}
	cout << (h <= 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    ll n, y; cin >> n >> y;
    FOR(i, 0, n) {
        if (i * 10000 > y) {
            break;
        }
        FOR(j, 0, n-i) {
            if (i * 10000 + j * 5000 > y) {
                break;
            }
            ll rem = y - i * 10000 - j * 5000;
            if (rem / 1000 == n - i - j) {
                cout << i << " " << j << " " << rem / 1000 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define debug puts("&&&&&&&&")
#define read(x) scanf("%lld",&x)
using namespace std;
typedef long long LL;
const int maxn=1e6+5;
LL a[maxn];
LL b[maxn];
LL n;
map<LL,int>ma;
LL sqr(LL c) {
    return c*c;
}
int main() {
    while(cin>>n) {
        ma.clear();
        for(LL i=1;i<=n;i++) {
            LL t;
            cin>>t;
            for(LL j=2;j*j*j<=t;j++) {
                while(t%(j*j*j)==0) {
                    t/=(j*j*j);
                }
            }
            ma[t]++;a[i]=t;
            LL ans=1;
           for (LL j=2;j*j*j<=t;j++)
            if (t%j==0)
            {
                ans*=(t%(j*j)==0)?j:j*j;
                while (t%j==0) t/=j;
            }
            if (sqr((LL)sqrt(t))==t) ans*=(LL)sqrt(t);
            else ans*=t*t;
            b[i]=ans;
        }
        LL ans1=0;
        if(ma[1]){
            ans1++;
            ma[1]=0;}
        for(int i=1;i<=n;i++) {
            ans1+=max(ma[a[i]],ma[b[i]]);
            ma[a[i]]=ma[b[i]]=0;
        }
        cout<<ans1<<endl;
    }
    return 0;
}


Measured memory_bytes: 17664
#include<stdio.h>

#define MAX 100

int main(){
  int u,k,v,n,i,j,a[MAX][MAX];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
  }  
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      a[u-1][v-1]=1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n-1;j++){
      printf("%d ",a[i][j]);  
    }
    printf("%d\n",a[i][j]);  
    }
  
  return 0;  
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    string s, t, u;
    ll a, b;
    cin >> s >> t >> a >> b >> u;

    if(s == u) a--;
    else b--;

    cout << a << " " << b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_T = 1260 - 540 + 10;

int main() {
  int N, M;
  while(cin >>N >>M && N){
    vector< vector<int> > v(M, vector<int>(MAX_T, 0));
    int R, Q; cin >>R;
    REP(i, R){
      int t, n, m, s; cin >>t >>n >>m >>s;
      t -= 540;
      --m;
      if(s) v[m][t] += 1;
      else v[m][t] -= 1;
    }
    REP(i, M) FOR(j, 1, MAX_T) v[i][j] += v[i][j - 1];
    cin >>Q;
    REP(i, Q){
      int ans = 0, ts, te, m; cin >>ts >>te >>m;
      --m;
      ts -= 540;
      te -= 540;
      FOR(t, ts, te) ans += (v[m][t] >= 1 ? 1 : 0);
      cout <<ans <<endl;
    }
  }
  return 0;
}

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

int main()
{
  string S;
  cin >> S;
  int N = S.size();
  vector<int> a(N);

  int v1=0;
  int v0=0;
  rep(i,N){
    if(atoi(S.substr(i,1).c_str()) ==1){
      v1++;
    }else{
      v0++;
    };
  }
  cout << 2 * min(v0,v1) << endl;
}

Measured memory_bytes: 896
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1    for( i=0; i<n; i++)
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll i,j,n,k,cnt=0,ans;
    string s;
    cin>>n>>s;
    for(auto c:s)
    {
        if(c=='.')
       cnt++;
    }
    ans=cnt;
    for(auto c:s)
    {
        if(c=='.') cnt--;
        else cnt++;
        ans=min(ans,cnt);
    }
    cout<<min(ans,cnt)<<endl;



    return 0;
}





Measured memory_bytes: 3732
#include<iostream>
using namespace std;
struct pocker{
    char Suit;
    char Value;
};
void print(pocker C[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(i)
            cout<<" ";
        cout<<C[i].Suit<<C[i].Value;
    }
    cout<<endl;
}
void BubbleSort(pocker C[],int N)
{
    int i,j;
    pocker p;
    for(i=0;i<N-1;i++)
    {
        for(j=N-1;j>=i+1;j--)
        {
            if(C[j].Value<C[j-1].Value)
            {
                p=C[j];
                C[j]=C[j-1];
                C[j-1]=p;
            }
        }
    }
    print(C,N);
}
void SelectionSort(pocker C[],int N)
{
    int i,j,minj;
    pocker p;
    for(i=0;i<N-1;i++)
    {
        minj=i;
        for(j=i;j<N;j++)
        {
            if(C[j].Value<C[minj].Value)
            {
                minj=j;
            }
        }
        p=C[minj];
        C[minj]=C[i];
        C[i]=p;
    }
    print(C,N);
}
bool isEqual(pocker p1, pocker p2)
{
    if(p1.Value==p2.Value&&p1.Suit==p2.Suit)
        return true;
    else
    {
        return false;
    }
}
bool isStable(pocker in[],pocker out[],int N)
{
    int i,j,a,b;
    for(i=0;i<N;i++)
    {
        for(j=i+1;j<N;j++)
        {
            for(a=0;a<N;a++)
            {
                for(b=a+1;b<N;b++)
                {
                    if(in[i].Value==in[j].Value&&isEqual(in[i],out[b])&&isEqual(in[j],out[a]))
                        return false;
                }
            }
        }
    }
    return true;
}
int main()
{
    pocker p[36],tmp[36],tmp1[36];
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>p[i].Suit>>p[i].Value;
        tmp[i].Suit=p[i].Suit;
        tmp[i].Value=p[i].Value;
        tmp1[i].Suit=p[i].Suit;
        tmp1[i].Value=p[i].Value;

    }

    BubbleSort(p,N);
    if(isStable(tmp1,p,N))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
    SelectionSort(tmp,N);
    if(isStable(tmp1,tmp,N))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;

    return 0;
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r = 0;
    rep(i, s.size()) {
        if(s[i] == 'R') r++;
    }
    int ans = 0;
    rep(i, r) {
        if(s[i] == 'W') ans++;
    }
    ans = min(ans, r);
    ans = min(ans, n - r);
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3684
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n % 2 ==1) {
			System.out.println(n /2 +1);
		}else {
			System.out.println(n /2);
		}

	}
}

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

const ll mod = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<bool> s(n, true);
  rep(i, k){
    int d; cin >> d;
    rep(j, d){
      int a;
      cin >> a;
      a--;
      s[a] = false;
    }
  }
  int ans = 0;
  rep(i, n) if (s[i]) ans++;
  cout << ans << endl;
}

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define REP64(i, s,  n) for(int64 i = s;i < (n);i++)
#define INF 999999999
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

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

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

int N;
map<int, int> mp;

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

	cin >> N;
	int a;
	REP(i, 0, N) {
	    cin >> a;
	    mp[a]++;
	}
	
	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if(itr->first > itr->second)		ans += itr->second;
		else if(itr->first < itr->second)	ans += (itr->second - itr->first);
    }
	cout << ans << endl;
	
	return 0;
}


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

using namespace std;

int main(){
  int n, a[200009], b[200009], c[400009];
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i] >> b[i];
  }
  sort(a, a+n);
  sort(b, b+n);
  int ans=0;
  if(n%2==0){
    if((a[n/2-1] + a[n/2])%2==1)ans++;
    if((b[n/2-1] + b[n/2])%2==1)ans++;
    int a_med = (a[n/2-1] + a[n/2] - 1) / 2 + 1;
    int b_med = (b[n/2-1] + b[n/2]) / 2;
    ans += (b_med - a_med) * 2 + 1;
  }
  else{
    int a_med = a[n/2], b_med=b[n/2];
    ans += b_med - a_med + 1;
  }
  cout << ans << endl;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

int main() {
  char x, y;
  cin >> x >> y;
  
  if (x - y > 0) {
    cout << ">" << endl;
  } else if (x - y == 0) {
    cout << "=" << endl;
  } else {
    cout << "<" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;
map <int, int> cnt, mn;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    for(int i = 0 ; i < n ; i++){
        cnt[a[i]]++;
        if(mn.count(a[i]) == 0){
            mn[a[i]] = i;
        }
        mn[a[i]] = min(mn[a[i]], i);
    }
    sort(a.rbegin(), a.rend());
    a.erase(unique(a.begin(), a.end()), a.end());
    a.push_back(0);
    vector <ll> ans(n);
    n = a.size();
    int cur_idx = 1e9;
    int cur_cnt = 0;
    for(int i = 0 ; i + 1 < n ; i++){
        cur_idx = min(cur_idx, mn[a[i]]);
        cur_cnt += cnt[a[i]];
        ans[cur_idx] += 1LL * (a[i] - a[i + 1]) * cur_cnt;
        
    }
    for(auto &i : ans) cout << i << "\n";
}


Measured memory_bytes: 13860
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ASumOfTwoIntegers solver = new ASumOfTwoIntegers();
        solver.solve(1, in, out);
        out.close();
    }

    static class ASumOfTwoIntegers {
        public void solve(int testNumber, FastReader s, PrintWriter out) {
            int n = s.nextInt();
            if (n % 2 == 0) {
                out.println(n / 2 - 1);
            } else {
                out.println(n / 2);
            }
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21460
#include <bits/stdc++.h>
using namespace std;
using ll = long long; // ll は long long　と同じとする。(int64_t)
int main() {
    int N;
    cin >> N;
    if(N / 100 == 7 || (N - N / 100 * 100) / 10 == 7 || N - N / 10 * 10 == 7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

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

static const double EPS = 1E-10;
template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }

int K;
double R, L;
double P, E, T;

inline double solve(int k, double l, double r)
{
  if(semige(r, T + E) || semile(l, T - E)) return 0.0;
  if(!semile(r, T - E) && !semige(l, T + E)) return 1.0;
  double h = (l + r) / 2.0;
  if(k >= K) return !semige(abs(h - T), E) ? 1.0 : 0.0;
  double ret = 0.0;
  if(h >= T){
    ret += P * solve(k + 1, l, h);
    ret += (1.0 - P) * solve(k + 1, h, r);
  }
  else{
    ret += P * solve(k + 1, h, r);
    ret += (1.0 - P) * solve(k + 1, l, h);
  }
  return ret;
}

int main(int argc, char *argv[])
{
  cin >> K >> R >> L;
  cin >> P >> E >> T;

  printf("%.15f\n", solve(0, L, R));
  
  return 0;
}

Measured memory_bytes: 1244
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int len = s.length - t.length;
        int ans = Integer.MAX_VALUE;
        for(int i = 0; i <= len; i++){
            int tmp = 0;
            for(int j = 0; j < t.length; j++){
                if(s[i+j] != t[j]){
                    tmp++;
                }
            }
            ans = Math.min(ans,tmp);
        }
        pw.println(ans);
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 32892
n=int(input())
a=list(map(int,input().split()))
sum=0
for i in range(n):
  sum+=a[i]
ave=sum/n
min=abs(a[0]-ave)
ans=0
for i in range(1,n):
  if (abs(a[i]-ave)<min):
    min=abs(a[i]-ave)
    ans=i
print(ans)

Measured memory_bytes: 3064