akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){


    int N;
    cin >> N;

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

    int ans = 0;
    for (int i = 0; i < 99999; i++){
        int sum = cnt[i] + cnt[i + 1] + cnt[i + 2];
        if (sum > ans){
            ans = sum;
        }
        
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int check(int rate) {
  if (rate < 400) {
    return 0;
  } else if (rate < 800) {
    return 1;
  } else if (rate < 1200) {
    return 2;
  } else if (rate < 1600) {
    return 3;
  } else if (rate < 2000) {
    return 4;
  } else if (rate < 2400) {
    return 5;
  } else if (rate < 2800) {
    return 6;
  } else if (rate < 3200) {
    return 7;
  }
  return 8;
}

int main() {
  int N;
  int a;
  bool used[8];
  int pool, max_count, min_count;

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

  pool = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    int c = check(a);
    if (c < 8) {
      used[c] = true;
    } else {
      pool++;
    }
  }

  min_count = 0;
  for (int i = 0; i < 8; i++) {
    if (used[i]) min_count++;
  }
  max_count = min_count;
  
  if (min_count == 0) {
    min_count = 1;
  }
  max_count += pool;
  // if (max_count > 8) {
  //   max_count = 8;
  // }

  cout << min_count << ' ' << max_count << endl;

  return 0;
}


Measured memory_bytes: 256
def check(mtx, i, j)
  mtx[i][j] == '#' &&
    (mtx[i][j - 1] == '#' || mtx[i][j + 1] == '#' ||
    mtx[i - 1][j] == '#' || mtx[i + 1][j] == '#')
end

def main
  h, w = gets.split.map(&:to_i)
  mtx = []
  mtx << '.' * (w+2)
  h.times do
    mtx << '.' + gets.chomp + '.'
  end
  mtx << '.' * (w+2)
  mtx_t= Array.new(h) do [] end
  for i in (0...h)
    for j in (0...w)
        mtx_t[i][j] = check(mtx, i+1, j+1)
    end
  end
  r = if mtx_t.flatten.count(true) == mtx.map{|i|i.count('#')}.reduce(:+)
    'Yes'
  else
    'No'
  end
  puts r
end

main

Measured memory_bytes: 1788
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 100000
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,head[MN+5],cnt=0,b[MN+5],d[MN+5],f[MN+5],g[MN+5],Ans,ans[MN+5],q[MN+5],top,h[MN+5];
struct edge{int to,next;}e[MN*2+5];
inline void ins(int f,int t)
{
    e[++cnt]=(edge){t,head[f]};head[f]=cnt;++d[f];
    e[++cnt]=(edge){f,head[t]};head[t]=cnt;++d[t];
}
void dfs(int x,int fa)
{
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa)
        {
            dfs(e[i].to,x);
            if(d[e[i].to]>1) ++f[x];
            if(!h[e[i].to]) ++g[x];
        }
    if(f[x]>1||g[x]) h[x]=0; else h[x]=1;
    //	cout<<x<<" "<<f[x]<<" "<<g[x]<<" "<<h[x]<<endl;
}
void Get(int x,int fa)
{
    int du=d[x]-(fa>0);if(!du) return;
    q[++top]=du-1;
    for(int i=head[x];i;i=e[i].next)
        if(e[i].to!=fa&&d[e[i].to]>1) return Get(e[i].to,x);
}
bool Small()
{
    if(!Ans) return true;
    for(int j=1;j<=Ans;++j)
    {
        if(q[j]<ans[j]) return true;
        if(q[j]>ans[j]) return false;
    }
    return false;
}
void Solve(int x,int fa)
{
    if(f[x]>1||g[x]) h[x]=0; else h[x]=1;
    //	cout<<x<<" "<<h[x]<<endl;
    if(h[x]==1&&d[x]==1&&!b[e[head[x]].to])
    {
        //cout<<"Try"<<x<<endl;
        top=0;Get(x,0);b[e[head[x]].to]=1;
      //  for(int i=1;i<=top;++i) cout<<q[i]<<endl;
        if(Small()) Ans=top,memcpy(ans,q,sizeof(q));
    }
    for(int i=head[x];i;i=e[i].next) if(e[i].to!=fa)
    {
        int gg=g[x]-(!h[e[i].to]),ff=f[x]-(d[e[i].to]>1),hh=gg|(ff>1);
        if(d[x]>1) ++f[e[i].to];
        if(hh) ++g[e[i].to];
        Solve(e[i].to,x);
    }
}
int main()
{
    n=read();
    for(int i=1;i<n;++i) ins(read(),read());
    dfs(1,0);Solve(1,0);
    if(!Ans) return 0*puts("-1");
    //for(int i=1;i<=Ans;++i) printf("%d\n",q[i]);
    for(int i=1,j=1;i<=Ans;j+=ans[i]+1,++i)
    {
        int nxt=j+ans[i];
        for(int k=j+1;k<=nxt;++k) printf("%d ",k);		printf("%d ",j);
    }
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 7680
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    A = list(map(int,input().split()))
    tmp = 0
    for j in range(M):
        tmp += A[j]*B[j]
    tmp += C
    if tmp > 0:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define eoi ios::sync_with_stdio(0),ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int main()
{
    eoi;
    int a,b;
    cin>>a>>b;
    if(a>9 or b>9 or a*b==0){cout<<-1;}
    else{
        cout<<a*b;
    }
}


Measured memory_bytes: 256
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    n = II()
    train = [LI() for _ in range(n - 1)]

    for i in range(n):
        res = 0
        for c, s, f in train[i:]:
            if res <= s:
                res = c + s
            else:
                res += (f - (res - s) % f) % f + c

        print(res)


if __name__ == '__main__':
    main()


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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

class Dice {
    public:
    int x, y, z;
    Dice() : x(3), y(1), z(2) {}
    ~Dice() {}
    void S() {
        int z_ = z;
        z = y;
        y = 7-z_;
    }
    void N() {
        int y_ = y;
        y = z;
        z = 7-y_;
    }
    void W() {
        int y_ = y;
        y = x;
        x = 7-y_;
    }
    void E() {
        int x_ = x;
        x = y;
        y = 7-x_;
    }
    void L() {
        int z_ = z;
        z = x;
        x = 7-z_;
    }
    void R() {
        int x_ = x;
        x = z;
        z = 7-x_;
    }
    void p() {
        cout<<x<<' '<<y<<' '<<z<<endl;
    }
};

int m[6];
int q;

Dice d;

int main(){
	cin.tie(0);
	
	rep(i, 6)cin>>m[i];
	cin>>q;
	rep(i, q) {
	    int u, f;
	    cin>>u>>f;
	    rep(j, 6) {
	        if(u==m[j]) {
	            u = j+1;
	            break;
	        }
	    }
	    rep(j, 6) {
	        if(f==m[j]) {
	            f = j+1;
	            break;
	        }
	    }
	    if(d.y==7-u) {d.N();d.N();
	    }else if(d.x==u)d.W();
	    else if(d.x==7-u)d.E();
	    else if(d.z==u)d.N();
	    else if(d.z==7-u)d.S();
	    
	    if(d.z==7-f) {d.L();d.L();
	    }else if(d.x==f)d.L();
	    else if(d.x==7-f)d.R();
	    
	    cout<<m[d.x-1]<<endl;
	}
	
	return 0;
}



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

int main(void){
        string s;
        cin >> s;
        int k=s.size();
        
      //  printf("%d\n", k);
        int c=0;
        for(int i=0;i<k;i++){
                if(s[i]!=s[k-i-1]){
                        c++;
                }
        }
        printf("%d\n", c/2);

        return 0;
}


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

int binomialCoeff(int n, int k)  
{  
    int res = 1;  
    if ( k > n - k )  
        k = n - k;   
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
    return res;  
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    if(n<2&&m<2)
    cout<<"0";
    else
    {
        int ans=0;
        if(n>=2&&m>=2)
        ans=binomialCoeff(n,2)+binomialCoeff(m,2);
        if(n>=2&&m<2)
        ans=binomialCoeff(n,2);
        if(n<2&&m>=2)
        ans=binomialCoeff(m,2);
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int R = scan.nextInt();
        if (R < 1200) {
            System.out.println("ABC");
        } else if (R < 2800) {
            System.out.println("ARC");
        } else {
            System.out.println("AGC");
        }
    }
}


Measured memory_bytes: 21716
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
ans = 0
for i in b:
    an = bisect.bisect_left(a, i)
    cn = n - bisect.bisect_right(c, i)
    ans += an * cn

print(ans)


Measured memory_bytes: 29212
N = int(input())
A = [int(x) for x in input().split()]
from collections import defaultdict as dd
Sieve = dd(lambda:0)
for a in A:
    Sieve[a] += 1

ans, extra = 0, 0 #extra:同じ数を3枚選んで食べるという操作で「被りカードなし」にできない種類数
for v in Sieve.values():
    ans += 1
    if v > 1 and (v-1)&1:
        extra += 1
#extraから2枚選んで食べれば全体の種類数を減らさずに済む
print(ans if not extra&1 else ans-1)


Measured memory_bytes: 21808
import math

def calc(before, cur):
    sum = 0
    for x, y in zip(before, cur):
        sum += (x-y) ** 2

    return (1 if math.sqrt(sum) % 1 == 0 else 0)

n, d = map(int, input().split())
Xs = [list(map(int, input().split())) for _ in range(n)]

count = 0
for i in range(n-1):
    for j in range(i+1, n):
        count += calc(Xs[i], Xs[j])

print(count)

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

int main(){
    ll M,D;
    cin >> M >> D;
    ll ans = 0;
    for (ll i = 1; i <= D; i++){
        for (ll j = 1; j <= M; j++){
            ll d1 = i % 10;
            ll d2 = i / 10;
            if (d1 >= 2 && d2 >= 2 && d1 * d2 == j) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define PB push_back
#define rep(i,x) for(int i=0;i<(int)(x);++i)

int N, A, B, C;
vector<string> op;
vector<char> ans;

signed main()
{
	cin >> N >> A >> B >> C;
	rep(i, N) {
		string s; cin >> s;
		op.emplace_back(s);
	}

	bool f = false;

	if (op[0] == "AB" and (A > 0 or B > 0)) f = true;
	if (op[0] == "AC" and (A > 0 or C > 0)) f = true;
	if (op[0] == "BC" and (B > 0 or C > 0)) f = true;

	if (!f) {
		puts("No");
		return 0;
	}

	rep(i, N) {
		if (op[i] == "AB") {
			if (A == 0 and B == 0) {
				puts("No");
				return 0;
			}

			if (A * B == 1) {
				if (i + 1 < N) {
					if (op[i + 1] == "BC") {
						B++, ans.PB('B');
						A--;
					} else {
						A++, ans.PB('A');
						B--;
					}
				}

				continue;
			}

			if (A >= B) {
				B++, ans.PB('B');
				A--;
			} else {
				A++, ans.PB('A');
				B--;
			}
		}
		if (op[i] == "AC") {
			if (A == 0 and C == 0) {
				puts("No");
				return 0;
			}

			if (A * C == 1) {
				if (i + 1 < N) {
					if (op[i + 1] == "BC") {
						C++, ans.PB('C');
						A--;
					} else {
						A++, ans.PB('A');
						C--;
					}

					continue;
				}
			}

			if (A >= C) {
				C++, ans.PB('C');
				A--;
			} else {
				A++, ans.PB('A');
				C--;
			}
		}
		if (op[i] == "BC") {
			if (B == 0 and C == 0) {
				puts("No");
				return 0;
			}

			if (B * C == 1) {
				if (i + 1 < N) {
					if (op[i + 1] == "AB") {
						B++, ans.PB('B');
						C--;
					} else {
						C++, ans.PB('C');
						B--;
					}
				}

				continue;
			}

			if (B >= C) {
				C++, ans.PB('C');
				B--;
			} else {
				B++, ans.PB('B');
				C--;
			}
		}
	}

	puts("Yes");
	rep(i, N) printf("%c\n", ans[i]);
}


Measured memory_bytes: 7448
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;
ll gcd( ll a , ll b )  {
    return b ? gcd( b , a % b ) : a;
}
ll lcm( ll a , ll b ) {
    return a / gcd( a , b ) * b;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll a , b = 1;
    cin >> n;
    for ( int i = 0 ; i < n ; i++ ) {
        cin >> a;
        b = lcm( a , b );
    }
    cout << b;
}




Measured memory_bytes: 256
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    dp = [-1]*N
    dp[0] = 0
    dp[1] = abs(A[1] - A[0])
    for i in range(2,N):
        dp[i] = min(dp[i-1] + abs(A[i] - A[i-1]), dp[i-2] + abs(A[i] - A[i-2]))
    print(dp[N-1])
main()

Measured memory_bytes: 13976
d = gets.to_i
c = gets.split.map(&:to_i)
s = Array.new(d){gets.split.map(&:to_i)}
t = Array.new(d){gets.to_i}
last = Array.new(26, 0)
sum = 0
d.times do |i|
  sum += s[i][t[i] - 1]
  last[t[i] - 1] = i + 1
  c.each_with_index do |x, j|
    sum -= c[j] * (i + 1 - last[j])
  end
  puts sum
end

Measured memory_bytes: 14256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

int main() {
	int N;cin>>N;
	vector<int>as(N);

	int ad=0;
	int amax=-1;
	for (int i = 0; i < N; ++i) {
		cin>>as[i];
		if (amax < abs(as[i])) {
			amax=abs(as[i]);
			ad=i;
		}
	}

	vector<pair<int,int>>anss;
	if (as[ad] == 0) {

	}
	else if (as[ad] > 0) {
		for (int i = 0; i < N; ++i) {
			if(i==ad)continue;
			anss.emplace_back(ad,i);
		}
		for (int i = 0; i < N - 1; ++i) {
			anss.emplace_back(i,i+1);
		}
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (i == ad)continue;
			anss.emplace_back(ad, i);
		}
		for (int i = 0; i < N - 1; ++i) {
			anss.emplace_back(N-1-i,N-2-i);
		}
	}
	cout<<anss.size()<<endl;
	for (auto ans : anss) {
		cout<<ans.first+1<<" "<<ans.second+1<<endl;
		as[ans.second]+=as[ans.first];
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define inl(a) cin >> a
#define prl(a) cout << a << " "
#define outl(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define tddd tuple<double,double,double>
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int > >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define N 10005
typedef long long int ll;
ll dp[N];
bool cmp(pair<ii,int> A,pair<ii,int> B)
{
    return min(A.F.S,B.F.S-A.F.F)>min(B.F.S,A.F.S-B.F.F);
}
int main()
{
    int i,j,n,w,c,v;
    int C=0;
    in(n);
    viii ad(n);
    rep(i,n)
    {
        in3(w,c,v);
        C=max(C,c);
        ad[i]={{w,c},v};
    }
    sort(all(ad),cmp);
    ll x,ans=0;
    rep(i,n)
    {
        w=ad[i].F.F,c=ad[i].F.S,v=ad[i].S;
        x=0;
        rep(j,c+1)
            x=max(x,dp[j]);
        ans=max(ans,x+v);
        for(j=min(C,c+w);j>=w;j--)
            dp[j]=max(dp[j],v+dp[j-w]);
    }
    outl(ans);
}








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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>S;
	FOR(y,S.size()) FOR(x,y) if(S[x]=='C' && S[y]=='F') return _P("Yes\n");
	_P("No\n");
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

const int MAX = 1000010;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

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

	COMinit();

	int X, Y;
	cin >> X >> Y;

	int N;
	int onec = 0;
	int ty = 0;
	if (X % 2 == 0)
	{
		N = X / 2;
		onec = 0;
		ty = N;
	}
	else
	{
		N = X / 2 + 1;
		onec = 1;
		ty = N + 1;
	}

	int NN = N;
	bool ok = false;
	rep(i, 0, N)
	{
		if (ty == Y)
		{
			ok = true;
			break;
		}
		onec += 2;
		NN++;
		ty += 3;
		if (ty == Y)
		{
			ok = true;
			break;
		}
	}

	if (!ok)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << COM(NN, onec) << endl;
	}

	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>

using namespace std;

int main(){
    int N, H, W; cin >> N >> H >> W;

    long long ans = 0;
    for (int i = 0; i < N; i++){
        int A, B; cin >> A >> B;

        if (A >= H && B >= W) ans ++;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cmath>
#include<ctime>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<iomanip>
#include<utility>
using namespace std;
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define rg register
#define il inline
#define lch(x) ((x)<<1)
#define rch(x) ((x)<<1^1)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define rep0(i,n) for(register int i=0;i<(n);++i)
#define per0(i,n) for(register int i=(n)-1;i>=0;--i)
#define rep(i,st,ed) for(register int i=(st);i<=(ed);++i)
#define per(i,ed,st) for(register int i=(ed);i>=(st);--i)
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef double dbl;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T> il T qmin(const T &a,const T &b){return a<b?a:b;}
template<typename T> il T qmax(const T &a,const T &b){return a>b?a:b;}
template<typename T> il void getmin(T &a,const T &b){if(a>b) a=b;}
template<typename T> il void getmax(T &a,const T &b){if(a<b) a=b;}
il void fileio(string s){
	freopen((s+".in").c_str(),"r",stdin);
	freopen((s+".out").c_str(),"w",stdout);
}

const int inf=(int)1e9+7;
const ll linf=(ll)1e17+7;
const int N=2e5+7;

int mn[N<<2][2],tag[N<<2][2];
int a[N],cnt0[N],cnt1[N];
pii b[N];
int n,q;

il void init(int u=1,int l=1,int r=n){
	mn[u][0]=mn[u][1]=tag[u][0]=tag[u][1]=inf;
	if(l==r) return;
	int mid=l+r>>1;
	init(lch(u),l,mid);
	init(rch(u),mid+1,r);
}

il void psd(int u,int tp){
	if(tag[u][tp]==inf) return;
	int v=tag[u][tp];tag[u][tp]=inf;
	getmin(mn[lch(u)][tp],v),getmin(tag[lch(u)][tp],v);
	getmin(mn[rch(u)][tp],v),getmin(tag[rch(u)][tp],v);
}

il void ins(int l1,int r1,int v,int tp,int u=1,int l=1,int r=n){
	if(l1>r1) return;
	if(l1<=l&&r<=r1){
		getmin(mn[u][tp],v);
		getmin(tag[u][tp],v);
	}else{
		int mid=l+r>>1;
		psd(u,tp);
		if(l1<=mid) ins(l1,r1,v,tp,lch(u),l,mid);
		if(r1>mid) ins(l1,r1,v,tp,rch(u),mid+1,r);
		mn[u][tp]=qmin(mn[lch(u)][tp],mn[rch(u)][tp]);
	}
}

il int qmin(int l1,int r1,int tp,int u=1,int l=1,int r=n){
	if(l1>r1) return inf;
	if(l1<=l&&r<=r1){
		return mn[u][tp];
	}else{
		int mid=l+r>>1,res=inf;
		psd(u,tp);
		if(l1<=mid) getmin(res,qmin(l1,r1,tp,lch(u),l,mid));
		if(r1>mid) getmin(res,qmin(l1,r1,tp,rch(u),mid+1,r));
		return res;
	}
}


int main(){
//	fileio("test");
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",a+i);
		cnt0[i]=cnt0[i-1],cnt1[i]=cnt1[i-1];
		++(a[i]?cnt1:cnt0)[i];
	}
	scanf("%d",&q);
	rep(i,1,q) scanf("%d%d",&b[i].Y,&b[i].X);
	sort(b+1,b+q+1);
	int ans=cnt1[n];
	init();
	rep(i,1,q){
		int l=b[i].Y,r=b[i].X;
		int mis=cnt0[r]-cnt0[l-1],res=mis+cnt1[l-1];
		getmin(res,mis+cnt1[l-1]+qmin(1,l-1,0));
		getmin(res,mis+cnt0[l-1]+qmin(l,l,1));
		ins(r,r,res-cnt1[r],0);
		ins(l,r,res-cnt0[r],1);
		getmin(ans,res+cnt1[n]-cnt1[r]);
	}
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 14592
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

int N;
char S[1000010];

ll solve(int K) {
    ll ans = 0;
    ll d = 0, m = 0, dm = 0;
    for (int i = 1; i <= N; ++i) {
        if (S[i] == 'D') {
            ++d;
        } else if (S[i] == 'M') {
            ++m;
            dm += d;
        } else if (S[i] == 'C') {
            ans += dm;
        }

        if (i-K+1 >= 1) {
            if (S[i-K+1] == 'D') {
                --d;
                dm -= m;
            } else if (S[i-K+1] == 'M') {
                --m;
            }
        }
    }
    return ans;
}

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int Q;
    scanf("%d %s %d", &N, S+1, &Q);
    for (int i = 0; i < Q; ++i) {
        int K; scanf("%d", &K);
        printf("%lld\n", solve(K));
    }
    return 0;
}


Measured memory_bytes: 1280
import scala.io.StdIn.readLine

object Main extends App {
  val Array(x1, y1, x2, y2) = readLine().split(" ").map(_.toDouble)
  val len1 = (x1 - x2)
  val len2 = (y1 - y2)
  println(Math.sqrt(len1 * len1 + len2 * len2))
}



Measured memory_bytes: 44088
from collections import deque
n=int(input())
a=input().split()
s=deque([])
for i in range(n):
    if i%2:
        s.append(a[i])
    else:
        s.appendleft(a[i])
if n%2==0:
    s.reverse()
print(str(s).replace(' ','').replace(',',' ').replace('deque([','').replace('])','\n').replace("'",''))


Measured memory_bytes: 26172
#include <iostream>
#include <vector>
#include <map>

struct UnionFindTree {
  std::vector<size_t> par;
  std::vector<size_t> rank;

  UnionFindTree(size_t N) : par(N), rank(N) {
    for (size_t i=0; i<N; i++) {
      par[i] = i;
    }
  }

  size_t root(size_t x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = root(par[x]);
    }
  }

  bool same(size_t x, size_t y) {
    return root(x) == root(y);
  }

  void unite(size_t x, size_t y) {
    size_t root_x = root(x);
    size_t root_y = root(y);
    if (root_x == root_y) return;

    if (rank[root_x] < rank[root_y])
      par[root_x] = root_y;
    else
      par[root_y] = root_x;

    if (rank[root_x] == rank[root_y])
      rank[root_x]++;
  }
};

int main() {
  ssize_t H, W;

  std::cin >> H >> W;

  std::vector<bool> grid(H*W);

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      char c;
      std::cin >> c;
      grid[W*i+j] = c == '#';
    }
  }


  UnionFindTree group(H*W);

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      auto self = W*i+j;
      if (i>0) {
        auto up = W*(i-1)+j;
        if (grid[self] != grid[up]) {
          group.unite(self, up);
        }
      }
      if (j>0) {
        auto left = W*i+j-1;
        if (grid[self] != grid[left]) {
          group.unite(self, left);
        }
      }
      if (j+1<W) {
        auto right = W*i+j+1;
        if (grid[self] != grid[right]) {
          group.unite(self, right);
        }
      }
      if (i+1<H) {
        auto down = W*(i+1)+j;
        if (grid[self] != grid[down]) {
          group.unite(self, down);
        }
      }
    }
  }

  std::map<ssize_t, size_t> cnt_b;
  std::map<ssize_t, size_t> cnt_w;

  for (ssize_t i=0; i<H; i++) {
    for (ssize_t j=0; j<W; j++) {
      auto r = group.root(W*i+j);

      if (grid[W*i+j])
        cnt_b[r]++;
      else
        cnt_w[r]++;
    }
  }

  size_t ans = 0;

  for (auto p : cnt_b) {
    auto r = std::get<0>(p);
    auto b = std::get<1>(p);
    auto w = cnt_w[r];

    ans += b*w;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 19968
#include<iostream>

using namespace std;

int main(){
    int a[3][3];
    int b[100];
    int i,j,k,n;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    cin >> n;
    for(k=0;k<n;k++){
    cin >> b[k];
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(a[i][j]==b[k]){
                a[i][j]=0;
            }
        }
    }
    }
    int l=0;
    if((a[0][0]==0) && (a[0][1]==0) && (a[0][2]==0)){
        l=1;
    }else if((a[1][0]==0) && (a[1][1]==0) && (a[1][2]==0)){
        l=1;
    }else if((a[2][0]==0) && (a[2][1]==0) && (a[2][2]==0)){
        l=1;
    }else if((a[0][0]==0) && (a[1][0]==0) && (a[2][0]==0)){
        l=1;
    }else if((a[0][1]==0) && (a[1][1]==0) && (a[2][1]==0)){
        l=1;
    }else if((a[0][2]==0) && (a[1][2]==0) && (a[2][2]==0)){
        l=1;
    }

    if(l!=1){
        if((a[0][0]==0 && a[1][1]==0 && a[2][2]==0) || (a[0][2]==0 && a[1][1]==0 && a[2][0]==0)){
            l=1;
        }
    }
    if(l==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
	#include <iostream>
	#include <string.h>
	#include <cstring>
	#include <cmath>
	#include <math.h>
	#include <algorithm>
	#include <iomanip>
	#include <map>
	#include <set>
	#include <vector>
	#include <sstream>
	#include <queue>	
	#include <bitset>
	using namespace std;	
	#define FOR(i,f_limit) for(long long int i=0;i<f_limit;i++)
	#define FR(i,s_limit,f_limit) for(long long int i=s_limit;i<f_limit;i++)
	typedef long long int llong;
	
	int main()
	{
		
		ios_base::sync_with_stdio(false);
		cin.tie(NULL);
		llong n;
		cin>>n;
		llong s=sqrt(n);
		s+=1;
		llong c,p,mini=100002;
		FR(i,1,s+1)
		{
			c=0;
			if(n%i==0)
			{
				if(i>=n/i) p=i;
				else p=n/i;
				while(p!=0)
				{
					p/=10;
					c++;
				}
				if(c<mini) mini=c;
			}
		}
		cout<<mini;
		return 0;
	}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (a + b == c || b + c == a || c + a == b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)

def main():
    #入力
    readline=stdin.readline
    N=int(readline())
    A=list(map(int,readline().split()))

    mod=10**9+7
    l=1
    for i in range(N):
        l=lcm(l,A[i])

    res=0
    for i in range(N):
        res+=l//A[i]
    
    print(res%mod)
if __name__=="__main__":
    main()

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

int main(void){
   int N;
   cin>>N;
   vector<long long> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   vector<long long> sum(N+1);
   sum[0]=0;
   for(int i=0;i<N;i++){
      sum[i+1]=sum[i]+a[i];
   }
   long long Mini=2000000007;
   for(int i=0;i<N-1;i++){
      Mini=min(Mini,abs(sum[N]-sum[i+1]-sum[i+1]));
   }
   cout<<Mini<<endl;
   return 0;
}

Measured memory_bytes: 3328
S = str(input())
judge = True
for i in range((len(S)-1)//2):
  if not(S[i] == S[len(S)-1-i] == S[(len(S)-1)//2-1-i] == S[(len(S)-1)//2+1+i]):
    judge = False
    break
if judge:
  print('Yes')
else:
  print('No')

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

int  main(void) {
  char a, b;cin>>a>>b;
  int aa, bb;
  aa = a - '0';
  bb = b - '0';

  string sa = "";
  string sb = "";
  rep (i, aa) sa += b;
  rep (i, bb) sb += a;

  //cout << sa << " " << sb << endl;
  cout << (sa < sb ? sa : sb) << endl;
  return 0;
}

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

const int N = 600 + 5;

int n, m, G[N][N], slowest[N];
ld dp[N];

ld DP(int u) {
  if(u == n) return 0;
  if(dp[u] >= 0) return dp[u];
  dp[u] = 0;
  int cc = 0;
  for(int i = 1 ; i <= n ; ++i) if(G[u][i]) {
    cc++;
    dp[u] += DP(i) + 1;
  }
  assert(cc > 0);
  dp[u] /= cc;
  return dp[u];
}

void init() {
  cin >> n >> m;
  for(int i = 0 ; i < m ; ++i) {
    int s, t; cin >> s >> t; G[s][t] = 1;
  }
}
void solve() {
  for(int i = 1 ; i < n ; ++i) dp[i] = -1;
  ld ans = DP(1);
  for(int i = 1 ; i <= n ; ++i) {
    int cc = 0, t = 0; ld mx = 0;
    for(int j = 1 ; j <= n ; ++j) if(G[i][j]) {
      cc++;
      if(dp[j] > mx) {
        mx = dp[j];
        t = j;
      }
    }
    if(cc > 1) slowest[i] = t;
  }
  for(int i = 1 ; i <= n ; ++i) if(slowest[i] != 0) {
    G[i][slowest[i]] = 0;
    for(int j = 1 ; j < n ; ++j) dp[j] = -1;
    ans = min(ans, DP(1));
    G[i][slowest[i]] = 1;
  }
  cout << fixed << setprecision(10) << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  init();
  solve();
}



Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)

scores = {}
penas = {}

m.times do
  inputs = gets.split
  p = inputs[0].to_i
  s = inputs[1]

  if s == 'AC'
    if scores[p] != 'AC'
      scores[p] = 'AC'
    end
  else # WA
    if scores[p] != 'AC'
      if penas[p].nil?
        penas[p] = 1
      else
        penas[p] += 1
      end
    end
  end
end

score_count = 0
pena_count = 0

scores.each do |k,v|
  if v == 'AC'
    score_count += 1
    pena_count += penas[k] unless penas[k].nil?
  end 
end

puts "#{score_count} #{pena_count}"

Measured memory_bytes: 15228
#include<iostream>
using namespace std;
int main() {
	int a[3];
	int count = 0;
	for(int i=0; i<3; i++)
	cin >> a[i];
	for(int i=0; i<3; i++)
	for(int j=i+1; j<3; j++)
	if(a[i]!=a[j]) count++;
	if(count == 0) count = 1;
	cout << count;
}	

Measured memory_bytes: 256
fun main(args:Array<String>?): Unit {
    while(true) {
        val (a, b, c, d, e) = readLine()!!.trim().split(' ').map(String::toInt)
        if (a == 0) return
        val (na, nb, nc) = readLine()!!.trim().split(' ').map(String::toInt)
        val straight = na * a + nb * b + nc * c
        if (nc >= d) {
            println(nc * e + na * a + nb * b)
        } else if (nb + nc >= d) {
            if (d * e < nc * c + (d - nc) * b) println(d * e + na * a + (nb + nc - d) * b)
            else println(straight)
        } else if (na + nb + nc >= d) {
            if (d * e < nc * c + nb * b + (d - nc - nb) * a) println(d * e + (na + nb + nc - d) * a)
            else println(straight)
        } else if (d * e < straight) {
            println(d * e)
        } else {
            println(straight)
        }
    }
}


Measured memory_bytes: 32768
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c,k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    int x = min(a,k);
    int ans = x;
    k -= x;
    x = min(b,k);
    k -= x;
    x = min(c,k);
    ans -= x;
    printf("%d",ans);
}


Measured memory_bytes: 3728
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    if(s[5]=='0' && s[6]<='4') cout<<"Heisei"<<endl;
    else cout<<"TBD"<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
#define vll vector<ll>
constexpr ll INF = 1e9 + 7;
constexpr ll MOD = 1e9 + 7;

template<typename T>
void vecin(vector<T>& v, int n = 0){
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
}
template <typename T>
void vecout(vector<T> &v, int n = 0)
{
    if (n == 0)
        n = v.size();
    for (int i = 0; i < n-1; ++i)
    {
        cout << v[i] << " ";
    }
    cout << v[n - 1] << endl;
}
void print(string s){
    cout << s << endl;
}

int main()
{
    ciosup;
    string s,t;
    cin >> s >> t;
    int ans = 0;
    REP(i, 3)
    {
        if (s[i]==t[i])
            ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

char s[100010];
int n;

bool check(int l){
	for(int a=0; a<2; ++a){
		for(int i=0; i<n; ++i) s[i]=48+49-s[i];
		int cnt[2]={0, 0};
		for(int i=n-l; i<l; ++i) cnt[s[i]-48]++;
		if(!cnt[0] || !cnt[1]) return 1;
	}
	return 0;
}

int main()
{
	scanf("%s", s); n=strlen(s);
	int l=1, r=n+1;
	while(l+1 < r){
		int mid=(l+r)/2;
		if(check(mid)) l=mid; else r=mid;
	}
	printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        while (true) {
            String s = sc.next();
            if (s.equals("0")) break;
            System.out.println(dfs(convert(s)));
        }
    }
    
    String dfs(String str) {
        Set<String> visited = new HashSet<String>();
        visited.add(str);
        
        LinkedList<String> q = new LinkedList<String>();
        LinkedList<Integer> qi = new LinkedList<Integer>();
        q.add(str); qi.add(0);
        
        while (!q.isEmpty()) {
            String s = q.removeFirst();
            int c = qi.removeFirst();  
            if (ok(s)) return "" + c;
            for (int i = 0; i < s.length() - 1; i++) if (s.charAt(i) != s.charAt(i + 1)) {
                int n = s.charAt(i) - '0' + s.charAt(i + 1) - '0';
                n = (3 - n % 3) % 3;
                String next = s.substring(0, i) + n + n + s.substring(i + 2, s.length());
                if (!visited.contains(next)) {
                    q.addLast(next);
                    qi.addLast(c+1);
                    visited.add(next);
                }
            }
        }
        return "NA";
    }
    
    String convert(String str) {
        String ret = "";
        for (int i = 0; i < str.length(); i++) {
            switch (str.charAt(i)) {
            case 'r': ret += "" + 0; break;
            case 'g': ret += "" + 1; break;
            case 'b': ret += "" + 2; break;
            }
        }
        return ret;
    }
    
    boolean ok(String s) {
        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) != s.charAt(i + 1)) return false;
        }
        return true;
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 98064
#include <iostream>
#include <cstring>
#include <climits>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

int main(){
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,x;
	cin>>n;
	map<int,int>a;
	while(n--){
		cin>>x;
		if(a.find(x) != a.end())a.erase(x);
		else a[x];
	}
	cout<<a.size()<<endl;
}



Measured memory_bytes: 4992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var n = cin.nextLong();

            n--;
            Console.WriteLine(((n) / 2));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
import numpy as np

N, W = map(int, input().split())
goods = [tuple(map(int, input().split())) for _ in range(N)]
Mv = 10 ** 5
Mw = 10 ** 11

table = np.full((N + 1, Mv + 1), Mw, dtype=np.int64)
table[0][0] = 0
for n in range(N):
    tmp = np.full(Mv + 1, Mw, dtype=np.int64)
    tmp[goods[n][1]:] = table[n][:Mv + 1 - goods[n][1]] + goods[n][0]
    table[n + 1] = np.minimum(table[n], tmp)

print(np.max(np.where(table[N] <= W, table[N], 0).nonzero()))

Measured memory_bytes: 93888
#include <bits/stdc++.h>
#define ALL(x) x.begin(), x.end()
#define mset(a, b) memset(a, b, sizeof a)
#define rep(i, a, b) for(int i(a), i##_END_(b); i <= i##_END_; i++) 
#define drep(i, a, b) for(int i(a), i##_END_(b); i >= i##_END_; i--)
using namespace std;
template<class T> inline bool tomax(T &a, T b) {return a < b ? a = b, 1 : 0;}
template<class T> inline bool tomin(T &a, T b) {return b < a ? a = b, 1 : 0;}
typedef long long ll;
typedef double db;

const int N = 200005;

int a[N], b[N], c[N];

int main() {
    int n;
    scanf("%d", &n);
    rep(i, 1, n) scanf("%d", a + i);
    rep(i, 1, n) b[i] = max(a[i], b[i - 1]);
    drep(i, n, 1) c[i] = max(a[i], c[i + 1]);
    rep(i, 1, n) printf("%d\n", max(b[i - 1], c[i + 1]));
    return 0;
}


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

typedef long long ll; 

const int N = 6000; 
const int INF = 1<<30;
const int MOD = 1e9+7;

inline int read()
{
	char c = getchar(); int f = 1, x = 0;
	while( c < '0' || c>'9' ) { if(c == '-') f = -1;  c = getchar(); }
	while( c >= '0'&&c<='9' ) { x = x * 10 + c - '0'; c = getchar(); }
	return f * x;
}

int tot = 0, front[N]; 

struct Edge {
	int v, next;
} e[N<<1];

inline void add_edge( int u, int v ) 
{
	e[++tot] = { v, front[u] }; front[u] = tot; 
	e[++tot] = { u, front[v] }; front[v] = tot; 
}

int n, size[N]; 

ll f[N][N], g[N], temp[N]; 

inline ll add( ll a, ll b ) { ll ret = a + b; return ret >= MOD ? ret - MOD : ret; }

inline ll dec( ll a, ll b ) { ll ret = a - b; return ret < 0 ? ret + MOD : ret; }

void dfs( int u, int fa ) 
{
	size[u] = 1; f[u][1] = 1; 
	
	for( int i = front[u]; i; i = e[i].next ) 
	{
		int v = e[i].v; 
		if( v == fa ) continue;
		
		dfs( v, u ); 
		
		for( int j = 1; j <= size[u] + size[v]; j ++ ) temp[j] = 0; 
		
		for( int j = 1; j <= size[u]; j ++ )
			for( int k = 0; k <= size[v]; k ++ )
				temp[j+k] = add( temp[j+k], 1ll * f[u][j] * f[v][k] %MOD );
	
		for( int j = 1; j <= size[u] + size[v]; j ++ )
			f[u][j] = temp[j]; 
			
		size[u] += size[v]; 
	}
	
	for( int i = 2; i <= size[u]; i += 2 )
		f[u][0] = dec( f[u][0], 1ll * f[u][i] * g[i] % MOD );   
}

int main()
{
	n = read(); 
	
	for( int i = 1; i < n; i ++ ) 
		add_edge( read(), read() );
	
	g[0] = 1; 
	for( int i = 2; i <= n; i += 2 )
		g[i] = 1ll * g[i-2] * ( i - 1 ) %MOD; 

	dfs( 1, 0 );
	
	printf( "%d\n", MOD - f[1][0] );  
	
	return 0; 
}

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

int main(){
	int n;
	cin >> n;
	int sum = 0, a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	if(sum % 10 == 0) for(int i = 0; i < n; i++) if(a[i] % 10){
		sum -= a[i];
		break;
	}
	cout << (sum % 10 ? sum : 0) << endl;
}

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

using namespace std;

int main() {
    string a,b;
    cin>>a>>b;
    string str;
    str=a+b;
    int num=stoi(str);
    bool ans=false;
    for(int i=1;i<=330;i++){
        if(num==i*i){
            cout<<"Yes"<<endl;
            ans=true;
            break;
        }
    }
    if(ans==false)cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
const long long MOD = 1000000007;
using namespace std;
typedef long long ll;
map<ll, int> mp;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	vector<int> p(n), tmp(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		tmp[i] = p[i];
	}
	for (int i = 1; i <= n; i++) {
		a[i - 1] = i;
	}
	int j = 0;
	for (int i = n; i >= 1; i--) {
		b[j] = i;
		j++;
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int c = p[i];
			p[i] = p[j];
			p[j] = c;
			if (p == a) {
				cout << "YES" << endl;
				return 0;
			}
			for (int k = 0; k < n; k++) {
				p[k] = tmp[k];
			}
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n, s[1000];
    double total, a;
    while(1) {
        total= 0;
        a = 0;
        s[1000] ={};
        cin >> n;
        if (n==0) break;
        for (int i=0; i<n; i++) {
        cin >> s[i];
        total += s[i];
        }
        total = total / n;
        for (int i=0; i<n; i++) {
            a += pow(s[i]-total, 2)/n;
        }
        a = sqrt(a);
        cout << fixed << a << endl;
    }
    
}


Measured memory_bytes: 3276
import java.util.Scanner;

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

        for (char c : s.toCharArray()){
            if ('A' <= c && c <= 'Z'){
                System.out.print(Character.toLowerCase(c));
            }
            else if ('a' <= c && c <= 'z'){
                System.out.print(Character.toUpperCase(c));
            }
            else {
                System.out.print(c);
            }
        }
        System.out.println();
    }
}

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

using namespace std;

bool happy(int d, int n){
    int i = 0;
    while(n % 100 == 0){
        n /= 100;
        i++;
    }
    return i == d;
}


int main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cout.precision(20);

    int d, n, ans;
    cin >> d >> n;

    vector<int>v;
    for(int i = 1; v.size() <= n; i++)
        if(happy(d, i))
            v.push_back(i);
    sort(v.begin(),v.end());

    cout << v[n-1] << '\n';
}

Measured memory_bytes: 256