akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            //ここから
            //int n=Readint();
            //string[] str = Console.ReadLine().Split(' ');

            int n = Readint();
            string[] str = Console.ReadLine().Split(' ');

            int count = 0;
            for(int i=0;i<n;i++)
            {
                if (i % 2 == 0 && int.Parse(str[i]) % 2 == 1) count++;
            }

            Cout(count);
            //ここまで
        }

        static void Cout(string s)
        {
            Console.WriteLine(s);
            return;
        }

        static void Cout(int n)
        {
            Console.WriteLine(n);
            return;
        }

        static void Cout(long n)
        {
            Console.WriteLine(n);
            return;
        }

        static int Readint()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] ReadArray(int n)
        {
            string[] str = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i=0; i < n; i++){ a[i] = int.Parse(str[i]); }
            return a;
        }
        static long[] ReadArray(long n)
        {
            string[] str = Console.ReadLine().Split(' ');
           long[] a = new long[n];
            for (long i = 0; i < n; i++) { a[i] = long.Parse(str[i]); }
            return a;
        }

        static long Readlong()
        {
            return long.Parse(Console.ReadLine());
        }

        static int Min(int a, int b)
        {
            if (a < b) return a;
            return b;
        }

        static int Max(int a, int b)
        {
            if (a > b) return a;
            return b;
        }


    }

}


Measured memory_bytes: 27540
// Marcin Knapik
#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

//#include <ext/pb_ds/assoc_container.hpp> // order_of_key
//#include <ext/pb_ds/tree_policy.hpp> // find by order
//using namespace __gnu_pbds; 
//#define ordered_set tree< int , null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ull>(a, b)(rng)
#define losuj_real(a, b) uniform_real_distribution<long double>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef unsigned long long      ull;
typedef pair<ll, ll>            pll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vector<ii>>      vvii;
typedef vector< ll >            vll;
typedef vector< pll >           vpll;
 
#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second
#define rr "\e[31m "
#define bb "\e[m "

template <class T> inline bool setmin(T &a, T b){if (a > b)return a = b, 1;return 0;}
template <class T> inline bool setmax(T &a, T b){if (a < b)return a = b, 1;return 0;}
 
template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> inline T russian(T a, T b, T mod) {ll res = 0; while(b){if(b&1) res = (res + a)%mod; a = (a+a)%mod; b>>=1;}return res;}
template <class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<typename T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll N = 1e6+7;
const ll T = 1<<20;
const ll BIG_INF = 1e18 + 7;

ll n, m;
#define vvi vector<vector<ll>>
#define M vvi
M ID;

M operator*(M a, M b){
	M ret(n, vll(n, 0));
	FOR(i, n)
		FOR(j, n)
			FOR(k, n)
				(ret[i][j] += a[i][k] * b[k][j]) %= INF;
	return ret;
}

M operator^(M a, ll pot){
	M ret = ID;
	M pom = a;

	while(pot){
		if(pot&1)
			ret = ret * pom;
		pom = pom * pom;
		pot /= 2;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);	
	
	cin >> n >> m;
	M tab(n, vll(n, 0));
	FOR(i, n)
		FOR(j, n)
			cin >> tab[i][j];
	ID.resize(n, vll(n, 0));
	FOR(i, n)
		ID[i][i] = 1;
	auto x = tab^m;

	ll wyn = 0;

	FOR(i, n)
		FOR(j, n)
			wyn += x[i][j];
	cout << wyn % INF << '\n';
}	


Measured memory_bytes: 384
import scala.io.StdIn._

import Math._
object Main extends App {
  val eps0 = 1e-12

  val q = readLine.toInt

  val xs = new Array[Int](q+2)
  val ys = new Array[Int](q+2)
  for (i <- 0 until q) {
    val Seq(x, y) = readLine.split(' ').map(_.toInt).toList
    xs(i) = x
    ys(i) = y
  }

  xs(q) = xs(0); xs(q+1) = xs(1)
  ys(q) = ys(0); ys(q+1) = ys(1)

  val subarea = for (i <- 0 until q) yield {
    val xs1 = xs(i+1) - xs(i)
    val ys1 = ys(i+1) - ys(i)
    val xs2 = xs(i+2) - xs(i)
    val ys2 = ys(i+2) - ys(i)

    xs1 * ys2 - ys1 * xs2
  }

  println(if (subarea.forall(_ >= 0)) "1" else "0")
}


Measured memory_bytes: 44264
#include <bits/stdc++.h>
#include <sstream>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mk make_pair
#define xx first
#define yy second

double pi=3.141592653589793238;
const int M = 1e9+7;
const int Nmax=5005;
const int MM = 2e5+1;



int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int T=1;
//cin>>T;
while(T--){
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
sort(arr,arr+n,greater<int>());
ll ans=arr[0];
int cnt=n;
cnt-=2;
for(int i=1;i<n;i++){
    if(cnt==0)break;
    if(cnt>=2){
        ans+=2*arr[i];
        cnt-=2;
    }
    else if(cnt==1){
        ans+=arr[i];
        cnt-=1;
    }
}
cout<<ans<<"\n";

}
return 0;
}

/*_*/


Measured memory_bytes: 4436
s=input()
d='BDEFGHIJKLMNOPQRSTUVWXYZ'
if s[0]=='A' and s.count('A')==1 and s.count('C')==1 and s[2:-1].count('C')==1:
    for t in d:
        if t in s:
            break
    else:
        print('AC')
        exit()
print('WA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	ll mn=1e18;
	for(i=1;i<=100;i++){
		ll c=0;
		for(j=1;j<=n;j++){
			c+=(i-ar[j])*(i-ar[j]);
		}
		mn=min(mn,c);
	}
	cout<<mn;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

const int INF = 2147483647;
int N, Q;

struct SegmentTree {
private:
    int n;
    vector <int> node;

public:
    SegmentTree(vector <int> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1, INF);
        for (int i = 0; i < sz; i++) node[i+n-1] = v[i];
        for (int i = n-2; i >= 0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

    void update(int x, int val) {
        x += n - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }

    int getmin(int a, int b, int k=0, int l=0, int r=-1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return INF;
        if (a <= l && r <= b) return node[k];
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

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

    cin >> N >> Q;
    SegmentTree seg(vector<int>(N, INF));
    for (int i = 0; i < Q; i++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            seg.update(x, y);
        } else {
            cout << seg.getmin(x, y+1) << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 4164
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main () {
    int n;
    
    scanf("%d", &n);
    
    long long int sum = 1;
    
    for (int i = 1; i <= n; i++) {
        sum = sum * i % 1000000007;
    }
    printf("%lld", sum);
}

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

typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define all(x) x.begin(),x.end()

int main()
{
	int n;
	cin>>n;
	vector<int> a;
	int prev=0;
	a.push_back(1);
	a.push_back(0);
	rep(i,n){
		int x;
		cin>>x;
		if(x==prev)continue;
		prev=x;
		a.push_back(x);
	}

	a.push_back(0);
	n=a.size();
	vector<P> h;
	repi(i,1,n-1) h.push_back(P(a[i],i));
	sort(all(h));

	int ans=0,cnt=0,height=-1;
	rep(i,n){
		if(h[i].first!=height){
			ans=max(ans,cnt);
			height=h[i].first;
		}
		int pos=h[i].second;
		if(a[pos-1]>height && height < a[pos+1]) cnt++;
		if(a[pos-1]<height && height > a[pos+1]) cnt--;
		a[pos]=-1;
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    int N;
    cin >> N;
    int a[N];
    rep(i, N) cin >> a[i];
    int ex = 0;
    rep(i, N) ex ^= a[i];
    rep(i, N) {
        cout << (ex ^ a[i]) << endl;
    }
}

Measured memory_bytes: 4372
/*
[abc115] C - Christmas Eve
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1e5;
const int INF = 1e9 + 1;

int N, K;
int h[MAX_N];

int solve() {
    sort(h, h + N);
    int ans = INF;
    for (int i = 0; i + K - 1 < N; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }
    return ans;
}

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

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 30030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin>>n;
	int x=1;
	int y=-1;
	int z=1;
	while(z*(z+1)/2<n)
	{z++;
	}
	z--;
	x=n-z*(z+1)/2;
	if(x)
	{
		z++;
		y=z*(z+1)/2-n;
	}
	rep(i,1,z+1)
	{
		if(i!=y)
		cout<<i<<" ";
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int x;
    cin >> x;
    
    if(x == 7 or x == 5 or x == 3) {
        cout << "YES";
    }else{
        cout << "NO";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    readonly Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        WriteLine(cin.nextint * cin.nextint / 2);
    }

}

class Scanner
{
    string[] s; int i;
    readonly char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
    public void join<T>(IEnumerable<T> values) { WriteLine(string.Join(" ", values)); }
}

Measured memory_bytes: 11092
require 'matrix'
n,m,l = gets.split.map(&:to_i)
a=[]
b=[]
n.times {a << gets.split.map(&:to_i)}
m.times {b << gets.split.map(&:to_i)}
ma = Matrix.build(n,m){|r,c| a[r][c]}
mb = Matrix.build(m,l){|r,c| b[r][c]}
(ma*mb).to_a.map{|r| puts r * ' '}



Measured memory_bytes: 7856
h, w = map(int, input().split())
s = [list(map(str, input())) for i in range(h)]
isCase = True
count = 1

def isBlack(i, j, h, w):
    if ((i-1>0 and s[max(i-1,0)][j] == 'B') or (j-1>0 and s[i][max(j-1,0)] == 'B') or (j+1<w-1 and s[i][min(j+1,w-1)] == 'B') or (i+1<h-1 and s[min(i+1,h-1)][j] == 'B')):
        return True
    else:
        return False

while (count != 0 and isCase):
    count = 0
    for i in range(h):
        for j in range(w):
            if (s[i][j] == '#'):
                s[i][j] = 'B'
                count += 1
                if (s[max(i-1,0)][j] == '#'): #上
                    s[max(i-1,0)][j] = 'B'
                elif (s[i][max(j-1,0)] == '#'): #左
                    s[i][max(j-1,0)] = 'B'
                elif (s[i][min(j+1,w-1)] == '#'): #右
                    s[i][min(j+1,w-1)] = 'B'
                elif (s[min(i+1,h-1)][j] == '#'): #下
                    s[min(i+1,h-1)][j] = "B"
                elif (isBlack(i, j, h ,w)):
                    pass
                else:
                    isCase = False
                    break
        if (isCase == False):
            break

if (isCase):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
using namespace std;

int bin_search(vector<int>& arr, int key){
    int l, r, m;
    bool found;
    found = false;
    l = 0;
    r = arr.size();
    while(r > l){
        m = (l + r) / 2;
        if(arr[m] == key){
            found = true;
            break;
        }

        else if(arr[m] < key){
            l = m + 1;
        }
        else {
            r = m;
        }
    }
    if(found){
        return 0;
    }
    else {
        int t = l;
        if(t == 0){
            return min(abs(key - arr[t]), abs(key - arr[t+1]));
        }
        else if(t == (int)(arr.size()) - 1){
            return min(abs(key - arr[t-1]), abs(key - arr[t]));
        }
        else {
            return min(abs(key - arr[t-1]), min(abs(key - arr[t]), abs(key - arr[t+1])));
        }
    }
}
int main()
{
    while(true){
        int d, n, m, tmp;
        long long answer;
        answer = 0;
        cin >> d;
        if(d == 0){
            break;
        }
        cin >> n >> m;
        vector<int> shop(n+1, 0);
        vector<int> order(m, 0);
        for(int i=0; i<n+1; ++i){
            if(i == 0){
                shop[0] = 0;
            }
            else if(i == n){
                shop[n] = d;
            }
            else {
                cin >> shop[i];
            }
        }
        sort(shop.begin(), shop.end());
        for(int i=0; i<m; ++i){
            cin >> order[i];
            tmp = bin_search(shop, order[i]);
            answer += tmp;
        }
        cout << answer << endl;
    }
}


Measured memory_bytes: 3428
import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int n = sc.nextInt();
    	int x = sc.nextInt();
    	long t = sc.nextInt();
    	System.out.println((n + x - 1) / x * t);
    }
}



Measured memory_bytes: 35676
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int pval = 0, pid = -1;
    int mval = 0, mid = -1;
    rep(i,n){
        if(a[i] >= 0) {
            if(a[i] > pval){
                pval = a[i];
                pid = i;
            }
        }
        if(a[i] <= 0){
            if(abs(a[i]) > mval){
                mval = abs(a[i]);
                mid = i;
            }
        }
    }
    vector<P> res;
    if(pval > mval){
        rep(i,n){
            //全部正に
            if(a[i] < 0){
                //a[i] += a[pid];
                res.push_back(P(pid, i));
            }
        }
    }else{
        rep(i,n){
            //全部負に
            if(a[i] > 0){
                //a[i] += a[mid];
                res.push_back(P(mid, i));
            }
        }
    }
    //累積和
    if(pval > mval){
        for(int i = 0; i < n-1; i++) res.push_back(P(i,i+1));
    }else{
        for(int i = n-1; i >= 1; i--) res.push_back(P(i,i-1));
    }
    cout << res.size() << endl;
    for(int i = 0; i < res.size(); ++i){
        cout << res[i].first + 1 << " " << res[i].second + 1 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

Ans = 0
Cnt = [0]*9
for i in range(N):
    if A[i]>3200:
        A[i] = 3200
    Cnt[A[i]//400] += 1

for i in range(8):
    if Cnt[i]>0:
        Ans += 1

# 最低1色は必要
# 自由色が選択可能なのは8色だけではない
print(max(1,Ans), Ans+Cnt[8])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>


const long long MOD_CONST = 1000000007;


using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k(m);
	vector<vector<int>> s(m);
	vector<int> p(m);
	int ans = 0;
	for (int i = 0; i < m; i++) {
		
		cin >> k[i];
		
		for (int j = 0; j < k[i]; j++) {
			int tmp;
			cin >> tmp;
			s[i].emplace_back(tmp-1);
		}
	}

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

	for (int switches = 0; switches < (1 << n); switches++) {
		bool isOn = true;
		for (int i = 0;i < m; i++) {
			int cnt = 0;
			for (int j = 0; j < k[i];j++) {
				if ((switches >> s[i][j]) & 1) {
					cnt++;
				}
			}
			//cout << cnt << endl;
			if (cnt % 2 != p[i]) {
				//cout << switches << endl;
				isOn = false;
				break;
			}
		}
		if (isOn) {
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
/* ITP1_1_C 
*/

#include <stdio.h>

int main(void)
{
	int A, B;
	
	
	fscanf(stdin, "%d %d", &A, &B);
	
	fprintf(stdout, "%d %d\n", A*B, 2*(A+B));
	
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i <= n;++i)
#define REPR(i, n) for(int i = n-1;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 SORT(v, n) sort(v, v+n)
#define VSORT(v) sort(begin(v), end(v))
#define REV(v) reverse(begin(v), end(v))
#define VI vector<int>
#define PB(x) push_back(x)
#define SZ(x) end(x) - begin(x)
#define DEBUG(x) cerr << __LINE__ << ":" << #x << ": " << x << "\n";
//#define int long long
using namespace std;
using lint = long long;
struct Fast{Fast(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};} fast;
const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
inline void CO(auto &a) {REP(i, SZ(a)) cout << i << ": " << a[i] << "\n";}
//if (IO > 1e5){lint a;	scanf(%lld, &a);	printf("%lld\n", a);}

signed main(){
	int n,k;	cin >> n >> k;
	string s; cin >> s;
	s[k-1] += 32;
	cout << s << endl;
return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int n, Max = 0;
	map<string, int> mp;
	string s;
	scanf("%d", &n);
	for(int i=0; i<n; ++i)
	{
		cin >> s;
		mp[s]++;
		Max = max(Max, mp[s]); 
	}
	map<string, int>::iterator it;
	for(it=mp.begin(); it!=mp.end(); ++it)
	{
		if(it->second == Max)
			cout << it->first << endl;
	} 
	return 0;
}

Measured memory_bytes: 25216
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int total = 0;
        for (int i = 0; i < 5; i++) {
            total += Math.max(40, sc.nextInt());
        }
        System.out.println(total / 5);
    }
}


Measured memory_bytes: 26220
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()
#define fi first
#define se second
#define sqrt(x) sqrt(abs(x))
#define sqr(x) ((x) * (x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define fill(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb emplace_back
#define popcnt __builtin_popcount
#define ctz __builtin_ctz

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
using ll = long long;
using ld = long double;
template <class T> using indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;

template <class T>
istream& operator >> (istream &in, vector <T> &a) {
    for (T &i: a) in >> i;
    return in;
}

template <class T>
ostream& operator << (ostream &out, vector <T> &a) {
    for (T &i: a) out << i << ' ';
    return out;
}

template <class T>
ostream& operator << (ostream &out, set <T> &a) {
    for (auto &i: a) out << i << ' ';
    return out;
}

template <class T, class U>
istream& operator >> (istream &in, pair <T, U> &p) {
    in >> p.first >> p.second;
    return in;
}

template <class T, class U>
ostream& operator << (ostream &out, pair <T, U> &p) {
    out << p.first << ' ' << p.second;
    return out;
}

void fastIO() {
    ios_base:: sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
}

bool pal(string s) {
    string t = s;
    reverse(all(t));

    return s == t;
}

string s;

signed main() {
    fastIO();

    cin >> s;
    if (pal(s) && pal(s.substr(0, (sz(s) - 1) / 2)) && pal(s.substr(sz(s) / 2 + 1, sz(s) - sz(s) / 2 - 1))) cout << "Yes";
    else cout << "No";

    return 0;
}

/// ЗАПУСКАЕМ ГУСЯ:
/*
     ▄▀▀▀▄
▄███▀░◐░░░▌
    ▌░░░░░▐
    ▐░░░░░▐
    ▌░░░░░▐▄▄
    ▌░░░░▄▀▒▒▀▀▀▀▄
   ▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
   ▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
    ▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
      ▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
           ▌▌░▌▌
           ▌▌░▌▌
         ▄▄▌▌▄▌▌        */



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

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){cin >> A.at(i);}
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    ans = ans + (D-1)/A.at(i) + 1;}
  
  ans += X;
  
  cout << ans << endl;
    
}

Measured memory_bytes: 3520
MOD = 10**9 + 7
S = input()

cur = [0] * 13
cur[0] = 1
r = 1
base = 0
for i in range(len(S)):
    s = S[-(i+1)]
    if s == '?':
        prev = cur
        cur = [sum(prev)] * 13
        for m in range(13):
            for d in range(10,13):
                cur[(m + r*d) % 13] -= prev[m]
        for m in range(13):
            cur[m] %= MOD
    else:
        base = (base + r*int(s)) % 13

    r = (10 * r) % 13

print(cur[(5-base) % 13])

Measured memory_bytes: 46044
def init(n):
    global par, rank
    par = [i for i in range(n)]
    rank = [0] * n

def find(x):
    global par
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, y):
    global par, rank
    x = find(x)
    y = find(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

def same(x, y):
    return find(x) == find(y)

N, M = map(int, input().split())
init(N)
p = list(map(int, input().split()))
for _ in range(M):
    x, y = map(int, input().split())
    unite(x - 1, y - 1)
ans = 0
for i in range(N):
    if same(i, p[i] - 1):
        ans += 1
print(ans)

Measured memory_bytes: 18608
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string w, s;
	cin >> w;

	std::string::size_type p;
	size_t ws = w.size();
	for(p = 0; p < ws; ++p )
		w[p] = tolower(w[p]);

	int t = 0;
	while( cin >> s )
	{
		if( s == "END_OF_TEXT" ) 
			break;
		
		if( ws != s.size() )
			continue;

		for(p = 0; p < ws; ++p ){
			if( w[p] != tolower(s[p]) )
				break;

			if( p == ws - 1 )
				++t;
		}	
	}

	cout << t << "\n";

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int H, W;
string S[2005];

int U[2005][2005];
int D[2005][2005];
int L[2005][2005];
int R[2005][2005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> H >> W;
    for(int i = 0; i < H; i++)
        cin >> S[i];


    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = 0; j < W; j++) {
            cnt = S[i][j] == '.' ? cnt + 1 : 0;
            L[i][j] = cnt;
        }
    }

    for(int i = 0; i < H; i++) {
        int cnt = 0;
        for(int j = W - 1; j >= 0; j--) {
            cnt = S[i][j] == '.' ? cnt + 1 : 0;
            R[i][j] = cnt;
        }
    }

    for(int i = 0; i < W; i++) {
        int cnt = 0;
        for(int j = 0; j < H; j++) {
            cnt = S[j][i] == '.' ? cnt + 1 : 0;
            U[j][i] = cnt;
        }
    }

    for(int i = 0; i < W; i++) {
        int cnt = 0;
        for(int j = H - 1; j >= 0; j--) {
            cnt = S[j][i] == '.' ? cnt + 1 : 0;
            D[j][i] = cnt;
        }
    }
    int ans = 0;
    for(int i = 0; i < H; i++)
        for(int j = 0; j < W; j++)
            ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
    cout << ans;
}

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

int main()
{
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << mp.size() << endl;
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int W[N];
  
  int w_sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> W[i];
    w_sum += W[i];
  }
  
  int l_sum = 0;
  int ans = 1000000;
  for (int i = 0; i < N; i++) {
    l_sum += W[i];
    int r_sum = w_sum - l_sum;
    
    if (abs(l_sum - r_sum) < ans) {
      ans = abs(l_sum - r_sum);
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        int[] list = new int[N];
        for (int i = 0; i <N; i++) {
            list[i] = Integer.parseInt(scanner.next());
        }

        int ans = 0;
        while (true) {
            int left = 0;
            while (left < N && list[left] == 0) {
                left++;
            }
            if (left == N) {
                break;
            }

            int right = left;
            int min = list[left];
            while (right < N && list[right] > 0) {
                min = Math.min(min, list[right]);
                right++;
            }
            for (int i = left; i < right; i++) {
                list[i] -= min;
            }
            ans += min;
        }
        System.out.println(ans);
    }
}



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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define repp(i, n) rep(i, n)
#define reppp(i, n) repp(i, n)
#define rrepp(i, n) rrep(i, n)
#define repss(i, n) reps(i, n)
#define repcc(i, n) repc(i, n)
#define repii(i, a, b) repi(i, a, b)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n;
  while (cin >> n) {
    i64 ans = 1;
    reps(i, n) ans += i;
    cout << ans << '\n';
  }
}



Measured memory_bytes: 3164
#include <stdio.h>
#include <iostream>

using namespace std;

long long k,a,b;
long long int bis=1, mon=0;

int main() {
	cin >> k>>a>>b;
	long long kk=k;
	if(a>=b){
		cout<<1+k<<endl;return 0;
	}
	if(k<a){
		cout<<1+k<<endl;return 0;
	}
	k-=a;bis=0;mon=1;
	if(k%2==1){
		bis=(b-a)*(k/2)+b;
	}
	if(k%2==0) {
		bis=(b-a)*(k/2)+a+1;
	}
	if(bis<kk+1)bis=kk+1;
	cout<<bis<<endl;return 0;
}


Measured memory_bytes: 888
#include <iostream>

#include <vector>
#include <queue>
#include <algorithm>
using namespace std;

typedef pair<int, int> Pair;

bool pair_compare(const Pair& a, const Pair& b)
{
	return a.second > b.second;
}

int main()
{
	int n, m;
	priority_queue<long, vector<long>, greater<long> > queue;

	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		queue.push(a);
	}

	vector<Pair> bc(m);

	for (int i = 0; i < m; i++) {
		int b, c;
		cin >> b >> c;
		bc.push_back(Pair(b, c));
	}

	sort(bc.begin(), bc.end(), pair_compare);

	/*
	for (int i = 0; i < bc.size(); i++) {
		cout <<bc.at(i).first << " " << bc.at(i).second << endl;
	}
	*/
	for (auto itr = bc.begin(); itr != bc.end(); ++itr) {
		int b = itr->first;
		int c = itr->second;
		for (int j = 0; j < b; j++) {
			if (queue.top() < c) {
				queue.push(c);
				queue.pop();
			}
			else{
				break;
			}
		}
	}



	long  sum = 0;
	while (!queue.empty()) {
		sum += queue.top();
		queue.pop();
	}
	

	cout << sum << endl;
}


Measured memory_bytes: 2676
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      		int N = sc.nextInt();
      		int answer = 1000 - N;
      		while(answer < 0){
            	answer += 1000;
            }
      		System.out.println(answer);
    }
}

Measured memory_bytes: 35836
h, w = map(int, input().split())
s = ['.' * (w+2)] + ['.' + input() + '.' for _ in [0]*h] + ['.' * (w+2)]
a = 'Yes'
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
            if s[i-1][j] == '.' and s[i+1][j] == '.' and s[i][j-1] == '.' and\
               s[i][j+1] == '.':
                a = 'No'
print(a)

Measured memory_bytes: 3064
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define rep(i, a, b) for (int i = a; i < b; i++)
#define ff first
#define pii pair<int, int>
#define vii vector< pair<int,int> >
#define vi vector<int>
#define vvi vector< vector< int> >
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define ull unsigned long long
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace4(x, y, z, d)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#d<<": "<<d<<endl

#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1, 0};int dy[]={0,1,0, -1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
bool compare(const pair<int,int> &a,
             const pair<int,int> &b)
{
    if(a.ff == b.ff) {
        return (b.ss < a.ss);
    }
    return (a.ff<b.ff);
}
bool prime[1000001];
void SieveOfEratosthenes(int n) 
{
    // Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.

    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
int dp[3003][3003];
int32_t main()
{
    IOS;
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    /********************* From here ***********************/
    
    string s,t;
    cin >> s >> t;
    
    rep(i, 0, 3003){
        rep(j, 0, 3003){
            if(i==0 || j==0){
                dp[i][j] = 0;
            }
        }
    }
    
    rep(i, 1, s.length()+1){
        rep(j, 1, t.length()+1){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            }
            else{
                
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int n = s.length();
    int m = t.length();
    vector<char> ans(dp[n][m]);
    int i = n, j = m;
    int sz = dp[n][m]-1;
    while(i>0 && j>0){
        if(s[i-1]==t[j-1]){
            ans[sz] = s[i-1];
            sz--;
            i--;
            j--;
        }
        else if(dp[i-1][j] > dp[i][j-1]){
            i--;
        }
        else{
            j--;
        }
    
    }

    rep(i, 0 ,dp[n][m]){
        cout << ans[i];
    }
}



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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    ll n; cin >> n;
    V<ll> t(n);
    for(ll i = 0; i < n; i++) cin >> t[i];

    ll l = t[0];
    for(ll i = 1; i < n; i++){
        l = lcm(l, t[i]);
    }
    cout << l << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

    char[] ns = scanner.next().toCharArray();
    int N = ns.length;
    for (int i = 0; i < N; i++) ns[i] = (char) (ns[i] - '0');
    int K = scanner.nextInt();

    long[][] dp1 = new long[N + 1][K + 1];
    long[][] dp2 = new long[N + 1][K + 1];
    dp1[1][1] = ns[0] - 1;
    dp1[1][0] = 1;
    dp2[1][1] = 1;
    for (int i = 2; i <= N; i++) {
      dp1[i][0] = 1;
      for (int j = 1; j <= K; j++) {
        dp1[i][j] = dp1[i - 1][j] + 9 * dp1[i - 1][j - 1];
        if (ns[i - 1] != 0) dp1[i][j] += dp2[i - 1][j] + (ns[i - 1] - 1) * dp2[i - 1][j - 1];
        if (ns[i - 1] == 0) dp2[i][j] = dp2[i - 1][j];
        else dp2[i][j]= dp2[i - 1][j - 1];
      }
    }
    System.out.println(dp1[N][K] + dp2[N][K]);
  }
}


Measured memory_bytes: 21972
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back

main(){
  int w,h;
  while(cin>>h>>w){
    if(h==0 && w==0)break;
    string kukaku[h];
    rep(i,h)cin>>kukaku[i];

    int wake[h][w];
    memset(wake,0,sizeof(wake));
    int ans=0;
    rep(i,h){
      rep(j,w){
        if(wake[i][j])continue;
        ++ans;
        queue<PI> Q;
        Q.push(mp(i,j));
        wake[i][j]=ans;
        while(!Q.empty()){
          int x=Q.front().first,y=Q.front().second;
          Q.pop();
          int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
          rep(k,4){
            int nx=x+dx[k],ny=y+dy[k];
            if(nx<0 || nx>=h || ny<0 || ny>=w || wake[nx][ny] || kukaku[nx][ny]!=kukaku[x][y])continue;
            Q.push(mp(nx,ny));
            wake[nx][ny]=ans;
          }
        }
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 0
A = int(input())
B = int(input())
C = int(input())
X = int(input())

total=0
count=0

for l in range(A+1):
    for m in range(B+1):
        for n in range(C+1):
            total=500*l + 100*m + 50*n
            if(total==X): count += 1
                
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, q = map(int, input().split())
 
stack = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  stack[a].append(b)
  stack[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for c in stack[cur]:
      if c == par:
        continue
      ans[c] += ans[cur] 
      dfs(c, cur)
dfs(0, -1)
print(*ans)

Measured memory_bytes: 230960
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

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

const int maxn=105;
const int inf=2139062143;

int n,m,f[maxn][maxn][2];
char mp[maxn][maxn];

int main()
{
	scanf("%d %d",&n,&m);
	fo(i,1,n) scanf("%s",mp[i]+1);
	
	memset(f,127,sizeof(f));
	f[1][1][mp[1][1]=='#']=0;
	fo(i,1,n)
		fo(j,1,m) if (i>1 || j>1)
		{
			int *p=&f[i][j][mp[i][j]=='#'];
			if (i>1 && f[i-1][j][0]<inf) *p=min(*p,f[i-1][j][0]);
			if (i>1 && f[i-1][j][1]<inf) *p=min(*p,f[i-1][j][1]+(mp[i][j]=='.'));
			if (j>1 && f[i][j-1][0]<inf) *p=min(*p,f[i][j-1][0]);
			if (j>1 && f[i][j-1][1]<inf) *p=min(*p,f[i][j-1][1]+(mp[i][j]=='.'));
		}
	
	printf("%d\n",min(f[n][m][0],f[n][m][1]+1));
}

Measured memory_bytes: 384
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))

n = onem()
l = l()
co = 0
for i in range(1,n-1):
    a = l[i-1]
    b = l[i]
    c = l[i+1]
    k = [a,b,c]
    k.sort(reverse = True)
    if k[1] == b and k[0] != k[1]:
        co += 1
print(co)



Measured memory_bytes: 38256
#include <stdio.h> 
int main() {
  int n,a,max,min;
  max = (-999999999);
  scanf("%d", &n);
  scanf("%d", &min);
  for (int i = 0; i < n-1; i++){
    scanf("%d", &a);
    max = max >= a-min ? max : a-min;
    min = min <= a ? min : a;
  }
  printf("%d\n", max);
}



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

void fail(){
    cout << "Impossible" << endl;
    exit(0);
}

int main(){
    int N;
    cin >> N;
    int num[101] = {0};
    int mx = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        mx = max(mx, a);
        num[a]++;
    }
    if(num[mx] < 2) fail();
    int mn = N;
    for(int i=0; i<=mx; i++){
        int a = max(i, mx-i);
        mn = min(mn, a);
        if(num[a] == 0) fail();
        num[a]--;
    }
    for(int i=1; i<=mn; i++) if(num[i] > 0) fail();
    cout << "Possible" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define RSORT(x) sort((x).rbegin(), (x).rend())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ld L;
    cin>>L;
    L/=3;
    cout<< L*L*L <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n; char buf[10];
  scanf("%d",&n);
  scanf("%s",buf);
  int cur = buf[0]=='T';
  FOR(i,1,n){
    scanf("%s",buf);
    int x = buf[0]=='T';
    if(cur==1 && x==0){
      cur = 0;
    }else{
      cur = 1;
    }
  }
  puts(cur ? "T" : "F");
  return 0;
}



Measured memory_bytes: 3160