akhauriyash/Code-Regression huggingface dataset:
using namespace std; 
#include<bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vect vector<ll>
#define maap map<ll,ll>  
#define MOD 1000000007
#define mit map::iterator
#define pii pair<ll,ll>
#define rep(i,a,b)	for(ll i=a;i< b;i++)
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
typedef  long long   int  ll;
//stringstream convert; 
  //  convert << number; 
  //  string s = convert.str();
 ll fact[500005],invfact[500005]; 
 ll power(ll x, ll y)
{
	ll z = 1;
	while(y > 0)
	{
		if(y % 2 == 1)
			z = (z*x)%MOD;
		x = (x*x)%MOD;
		y /= 2;
	}
	return z;
}
 ll inv(ll x)
{
	return power(x,MOD-2);
}
ll divide(ll x, ll y)
{
	return (x*inv(y))%MOD;
}
ll C(ll n, ll k)
{
	if(k > n) return 0;
	return divide(fact[n], (fact[n - k]*fact[k])%MOD);
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool isPrime(int n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
} 
void init(){
	ll p=MOD;
	fact[0]=1;
	ll i;
	for(i=1;i<500005;i++){
		fact[i]=(i*fact[i-1])%p;
	}
	i--;
	invfact[i]=power(fact[i],p-2);
	for(i--;i>=0;i--){
		invfact[i]=(invfact[i+1]*(i+1))%p;
	}
}
ll s;
ll fun(ll a)
{
	if(a==0)
	return 0;
	return a+fun(a-1);
}
priority_queue < pair<ll,ll> , vector<pair<ll,ll> >,greater<pair<ll,ll> > > gq;

#define MAXN   10000001 
ll spf[MAXN]; 
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
    for (ll i=3; i*i<MAXN; i++) 
    {
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
set<ll> getFactorization(ll x) 
{ 
    set<ll> ret; 
    while (x != 1) 
    { 
        ret.insert(spf[x]); 
        x = x / spf[x]; 
    } 
    return ret; 
} 
void ghost()
{   
  	ll i=0,j=0,k=0,l=0,n,r=-10000000000,q=0,t,y=100000000000,m;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    k=a[n-1];
    l=n-1;
    t=0;
    if(l%2==0)
    {
    for(i=n-2;i>=0&&(t<l/2-1);i--)
    {
    k=k+2*a[i];
    t++;
}
k=k+a[i];
}
else
{
	for(i=n-2;i>=0&&t<l/2;)
	{
		k=k+2*a[i];
		t++;
		i--;
	}
}
    cout<<k<<endl;
  	}
signed main()
{int test=1;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
fast
//cin>>test;
while(test--)
ghost();
return 0;
}

  

Measured memory_bytes: 5224
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <bitset>
#include <functional>
#include <set>
#include <map>
#include <array>

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define fst first
#define snd second
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cout << #x << ": " << x << endl
#define int long long int
const int MOD = 1000000007;
const int INF = 100100100;
const double EPS = 0.000000001;

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

bool pairCompare(const P& pair1, const P& pair2) {
    return pair1.second > pair2.second;
}
int par[100002];
int drank[100002];
int chi[100002];

void init(int n) {
  for(int i = 0; i < n; i++) {
    chi[i] = 1;
    par[i] = i;
    drank[i] = 0;
  }
}

int find(int x) {
  if(par[x] == x) {
    return x;
  }
  else {
    return par[x] = find(par[x]);
  }
}

void unite(int x, int y) {
  int parx = find(x);
  int pary = find(y);
  if(parx == pary) return;

  if(drank[parx] < drank[pary]) {
    chi[pary] += chi[parx];
    par[parx] = pary;
  }
  else {
    chi[parx] += chi[pary];
    par[pary] = parx;
    if(drank[parx] == drank[pary]) drank[parx]++;
  }
}

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


signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  int a[100002], b[100002];
  cin >> n >> m;

  int ans[m+1];
  REP(i, m){
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  ans[m-1] = (n * (n - 1) / 2);
  init(n);
  for(int i = m-1; i >= 1; i--) {
    if(same(a[i], b[i])){
      ans[i-1] = ans[i];
    }
    else{
      ans[i-1] = ans[i] - chi[find(a[i])] * chi[find(b[i])];
      unite(a[i], b[i]);
    }

  }

  REP(i, m) {
    cout << ans[i] << endl;
  }

  return 0;
}


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

int main(){

  int a, b, c, n;
  int p[1111], m[1111], k[1111], q[1111];
  int data[333];

  while(cin >> a >> b >> c, a){
    for(int i=332;i;) data[i--] = 2;
    
    cin >> n;
    for(int i=0;i<n;i++) cin >> p[i] >> m[i] >> k[i] >> q[i];
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	if(q[j]) data[p[j]] = data[m[j]] = data[k[j]] = 1;
	else{
	  if(data[p[j]] == 1 && data[m[j]] == 1) data[k[j]] = 0;
	  if(data[m[j]] == 1 && data[k[j]] == 1) data[p[j]] = 0;
	  if(data[p[j]] == 1 && data[k[j]] == 1) data[m[j]] = 0;
	}
      }
    }
    for(int i=1;i<=a+b+c;i++) cout << data[i] << endl;
  }
  
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm>

int main(int argc, char const* argv[])
{
    int cardSum, tmp;
    std::vector<int> card;
    std::cin >> cardSum;
    while (std::cin >> tmp) {
        card.push_back(tmp);
    }
    std::sort(card.begin(), card.end());

    int aliceScore = 0;
    int bobScore = 0;

    for (int i=cardSum-1; i>=0; i--) {
        aliceScore += card[i];
        i --;
        if (i < 0) {
            break;
        }
        bobScore += card[i];
    }
    std::cout << (aliceScore - bobScore) << std::endl;
    return 0;
}


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


def check(x):
    cnt = 0
    for a in A:
        if a % x == 0:
            cnt += a//x-1
        else:
            cnt += a//x
    return k < cnt


L = 0
R = 10**10
while L != R-1:
    M = (L+R)//2
    if check(M):
        L = M
    else:
        R = M
print(R)


Measured memory_bytes: 30752
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
int gcd(int a,int b){
	if(a < b)swap(a,b);
	int r = a%b;
	while(r!=0){
		a=b;
		b=r;
		r=a%b;
	}
	return b;
}

int main(){
	int a, b, k;
	cin >> a >> b >> k;
	int pre = 0;
	int big = gcd(a, b);
	for(int i = big; i; i--){
		if(a%i == 0 && b%i == 0)pre++;
		if(pre == k){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	long long A, B;
	cin >> A >> B;
	long long D = 1, ans = 0;
	while (D <= B) {
		long long Anum = (A-1) / (D * 2) * D + max(0ll, (A-1) % (D * 2) - (D - 1));
		long long Bnum = B / (D * 2) * D + max(0ll, B % (D * 2) - (D - 1));
		ans += D * ((Bnum - Anum) % 2);
		D *= 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define lP pair<ll,ll>
#define iP pair<int,int>

typedef long long ll;
using namespace std;
const int mod = 1e9 + 7;

int N, A, s, MAX;

int main(){
	cin >> N >> s;
	MAX = s;
	for (int i = 2; i != N+1; ++i) {
		cin >> A;
		s += A;
		if (i*MAX > s) {
			MAX = s / i;
		}
	}
	cout << MAX << endl;
	return 0;
}



Measured memory_bytes: 3108
#include<cstdio>
#include<cmath>
#define M 1000000007
bool f[100005];
int c[50005],dp[100050][35];
int main(){
	int n,m,i,j,k,l,cnt=0,ans=1;
	scanf("%d%d",&n,&m);
	k=sqrt(m+0.5);l=sqrt(k+0.5);
	for(i=2;i<=l;i++)
		for(j=i*i;j<=k;j+=i)f[j]=1;
	l=k;k=0;
	for(i=2;i<=l;i++)if(!f[i]){
		cnt++;
		while(!(m%i)){
			m/=i;
			c[cnt]++;
		}
		if(c[cnt]>k)k=c[cnt];
	}
	if(m!=1){
		c[++cnt]=1;
		if(!k)k=1;
	}
	dp[0][0]=1;
	for(i=1;i<=n;i++){
		dp[i][0]=1;
		for(j=1;j<=k;j++)
			for(l=0;l<=j;l++)dp[i][j]=(dp[i][j]+dp[i-1][j-l])%M;
	}
	for(i=1;i<=cnt;i++)if(c[i])ans=(long long)ans*dp[n][c[i]]%M;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 13824
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

const Mod = 1000000007

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	sc.Split(bufio.ScanWords)

	n := readInt()
	factorList := primeFactorization(n)

	ans := 0
	for _, f := range factorList {
		x := f
		b := 1
		for x-b >= 0 {
			x -= b
			b++
			ans++
		}
	}
	fmt.Println(ans)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}


Measured memory_bytes: 1768
import std.stdio;

void main() {
	int n, m;
	readf("%s %s", &n, &m);

	auto r = 0;

	if (n >= 2) {
		r += (n * (n - 1)) / 2;
	}
	if (m >= 2) {
		r += (m * (m - 1)) / 2;
	}

	writeln(r);
}


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

int main() {
    int N;
    cin >> N;
    vector<int> B(N-1);
    for (int i=0; i<N-1; i++) {
        cin >> B.at(i);
    }

    vector<int> A(N,0);
    A.at(0) = B.at(0);
    A.at(N-1) = B.at(N-2);
    for (int i=1; i<N-1; i++) {
        A.at(i) = min(B.at(i),B.at(i-1));
    }
    int result = 0;
    for (int i=0; i<N; i++) {
        result += A.at(i);
    }

    cout << result << endl;
}

Measured memory_bytes: 3636
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    auto S = sread();
    auto SS = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"];
    long i;
    while (SS[i] != S)
        i++;
    foreach (j; 1 .. 8)
    {
        if (SS[(i + j) % 7] == "SUN")
        {
            writeln(j);
            return;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
    int a, b ,c ,max,min,middle;
     
    scanf("%d %d %d", &a, &b, &c);
    
    max = a; 

    if (b >= max) {
      middle = a;
      max = b;
    } else {
        middle = b;
    }

    if (c >= max) {
       min = middle;
       middle = max;
       max = c;
    } else if (c >= middle) {
         min = middle;
         middle = c;
    } else {
         min = c;
    }

    printf("%d %d %d\n", min, middle, max);
     
    return 0;
}
	

Measured memory_bytes: 1748
#include <stdio.h>
#include <stdlib.h>

#define MAX(A,B) \
  ( (B) > (A) ? (B) : (A) )

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int err = 0;
  int n, m;
  int res;
  int i;

  scanf ( "%d%d", &n, &m );
  res = m;
  for ( i = 0; i < n; ++i )
  {
    int in, out;

    scanf ( "%d%d", &in, &out );
    m = m + in - out;
    if ( m < 0 )
      err = 1;
    res = MAX( res, m );
  }

  printf ( "%d\n", err ? 0 : res );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 596
n = int(input())
a = [int(i) for i in input().split()]

import statistics
check = []
for i in range(n):
    check.append(a[i] - (i+1))
b = statistics.median(sorted(check))

ans = 0
for i in range(n):
    ans += abs(check[i] - b)
print(int(ans))

Measured memory_bytes: 26360
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int n;  cin >> n;
    vector<int>a(n);
    rep(i, n)   cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    vector<int>c(1000000+10);
    for(int x : a){
        if(c[x]){
            c[x]++;
            continue;
        }
        for(int i = x; i < c.size(); i += x)    c[i]++;
    }
    rep(i, n)   if(c[a[i]] == 1)    ans++;
    cout << ans << endl;
}


Measured memory_bytes: 8000
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n , a , s=0;
    cin>>n>>a;
    if(a >= 2*n) {
        s = n;
        a -= 2*n;
        s += a / 4;
        cout << s << "\n";
    }
    else {
        cout << a / 2 << "\n";
    }

}


Measured memory_bytes: 3640
#include <stdio.h>

int main(void) {
	char b;
	scanf("%c",&b);
	if(b=='A')
	printf("T\n");
	else if(b=='T')
	printf("A\n");
	else if(b=='C')
	printf("G\n");
	else if(b=='G')
	printf("C\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct ios_accelerate { ios_accelerate() { ios::sync_with_stdio(false); cin.tie(nullptr); } } CALL;

#define REP(i, n) for(auto (i) = (n)*0; (i) < (n); (i)++)
#define RNG(i, a, b) for(auto (i) = (a); (i) < (b); (i)++)
#define RBF(i, v) for(auto& (i) : (v))
#define ALL(x) (x).begin(), (x).end()

using LL = long long;
using UL = unsigned long;
using ULL = unsigned long long;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
template<typename T> using P = pair<T, T>;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const LL INF64 = static_cast<LL>(1e18) + 2;
const int INF = static_cast<int>(1e9) + 2;

template<typename T> inline void upsort(vector<T>& x) { sort(x.begin(), x.end()); }
template<typename T> inline void downsort(vector<T>& x) { sort(x.begin(), x.end(), greater<T>()); }
template<typename T> inline void col(T x) { cout << x << '\n'; }
template<> inline void col(double x) { cout << fixed << setprecision(12) << x << '\n'; }

signed main() {
	int n;
	string s;
	cin >> n >> s;
	const string abc("ABC");
	
	int ans = 0;
	REP(i, n - 2) {
		string part = s.substr(i, 3);
		if (part == abc) {
			ans++;
		}
	}

	col(ans);
	return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,k,i;
    cin>>n>>k;
    int l[n];
    for (i=0;i<n;i++)
        cin>>l[i];
    sort(l,l+n,greater<int>());
    int sum=0;
    for (i=0;i<k;i++)
        sum+=l[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;

int n,m;
set<int> child[maxn];
pii edge[maxn];

bool used[maxn];

int dfs(int u){
	used[u]=1;
	int ret=1;
	for(int i:child[u]){
		if(used[i]) continue;
		ret+=dfs(i);
	}
	return ret;
}

int main()
{
	cin>>n>>m;
	REP(i,m){
		int x,y;
		cin>>x>>y;
		child[x].insert(y);child[y].insert(x);
		edge[i]={x,y};
	}
	int ans=0;
	for(int i=0;i<m;i++){
		debug(i);
		child[edge[i].F].erase(edge[i].S);
		child[edge[i].S].erase(edge[i].F);
		REP(i,maxn) used[i]=0;
		if(dfs(1)!=n) ans++;
		debug(i);
		child[edge[i].F].insert(edge[i].S);
		child[edge[i].S].insert(edge[i].F);
		
	}
	cout<<ans;
	return 0;
}












Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {//A ~Z 65~90
		
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			String S = scan.next();
			char []s = new char[N];
			s = S.toCharArray();
			
			 
			StringBuffer sb = new StringBuffer();
			
			for(int i = 0;i<S.length();i++) {
				int k = (int)s[i]+N;
				if(k>90) {
					k = (k-90)+64;
				}
				
				s[i] = (char)k;
				sb.append(s[i]);
			}
			
			
			System.out.println(sb.toString());
			
			
			
			
		}
		
		
		
		
	}
	
}


Measured memory_bytes: 23764
#include<iostream> 
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int n, k;
	cin >> n >> k;
	int x = 1;
	for (int i = 0;i < n;i++) {
		x = min(x*2,x+k);
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 3632
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.shift();
  
var bfr=[];
for(var i=0;i<4;i++){
   bfr.push([]);
   for(var j=0;j<3;j++){
      bfr[i].push([]);
      for(var k=0;k<10;k++)bfr[i][j].push(0);
   }
}
  
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   var b=arr[0]-1;
   var f=arr[1]-1;
   var r=arr[2]-1;
   var v=arr[3];
   bfr[b][f][r]=bfr[b][f][r]+v;
   if(bfr[b][f][r]>9)bfr[b][f][r]=9;
   if(bfr[b][f][r]<0)bfr[b][f][r]=0;
}

for(var i=0;i<4;i++){
   for(var j=0;j<3;j++){
      console.log(" "+bfr[i][j].join(" "));
   }
   if(i!==3)console.log("####################");
}

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

class UnionFind{
public:
  vector<int> uni;
  UnionFind(int s) : uni(s, -1) {}

  int root(int a){
    if(uni[a] < 0) return a;
    return uni[a] = root(uni[a]);
  }

  bool connect(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(uni[a] > uni[b]){
      a ^= b;
      b ^= a;
      a ^= b;
    }
    uni[a] = uni[a] + uni[b];
    uni[b] = a;
    return true;
  }

  bool isConnect(int a, int b){
    return root(a) == root(b);
  }

  int size(int a){
    return -uni[root(a)];
  }
};

int main(){
  int N,M;
  cin>>N>>M;
  vector<ll> A(M),B(M);
  for(int i=0;i<M;i++){
    cin>>A[i]>>B[i];
    A[i]--, B[i]--;
  }
  vector<ll> ans(M);
  UnionFind uf(N);
  for(int i=M-1;i>=0;i--){
    if(uf.isConnect(A[i],B[i])) continue;
    ans[i] = (ll)uf.size(A[i]) * uf.size(B[i]);
    uf.connect(A[i],B[i]);
  }
  for(int i=1;i<M;i++) ans[i] += ans[i-1];
  for(int i=0;i<M;i++) cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long N, K;
	cin >> N >> K;
	long long A[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	for(int i=0;K+i<N;i++){
		if(A[i] < A[K + i]) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 5188
#include<iostream>
using namespace std;
int N,H[1<<17];
main()
{
	cin>>N;
	for(int i=0;i<N;i++)cin>>H[i];
	for(int i=N-1;i--;)
	{
		if(H[i]>H[i+1])H[i]--;
		if(H[i]>H[i+1])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}


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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;
constexpr int dx[2] = {0, 1};
constexpr int dy[2] = {1, 0};

int bfs(const vvi& a, int maxv) {
    int h = a.size(), w = a[0].size();

    vector<vector<bool>> seen(h, vector<bool>(w, false));

    queue<pair<int, int>> q;
    q.emplace(0, 0);

    vector<vvi> sets(h, vvi(w));
    sets[0][0].push_back(a[0][0]);

    // O(H * W * log(80 * 80) * 80 * 80)
    while (!q.empty()) {  // H * W iterations.
        pair<int, int> cord = q.front();
        q.pop();

        int curr_y = cord.first;
        int curr_x = cord.second;

        if (seen[curr_y][curr_x]) { continue; }
        seen[curr_y][curr_x] = true;

        // O(log(80 * 80) * 80 * 80)
        rep(i, 0, 2) {  // 2 iterations.
            int next_y = curr_y + dy[i];
            int next_x = curr_x + dx[i];

            if (next_y >= h || next_x >= w) { continue; }
            q.emplace(next_y, next_x);

            vector<bool> curr_seen(maxv * (h + w) / 2, false);

            for (int curr : sets[curr_y][curr_x]) {
                if (curr_seen[curr]) { continue; }
                curr_seen[curr] = true;

                if (curr + a[next_y][next_x] <= maxv * (h + w) / 2) {
                    sets[next_y][next_x].push_back(curr + a[next_y][next_x]);
                }
                if (abs(curr - a[next_y][next_x]) <= maxv * (h + w) / 2) {
                    sets[next_y][next_x].push_back(abs(curr - a[next_y][next_x]));
                }
            }
        }
    }
    sort(sets[h - 1][w - 1].begin(), sets[h - 1][w - 1].end());
    return sets[h - 1][w - 1][0];
}

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

    int h, w;
    cin >> h >> w;

    vvi a(h, vi(w));
    rep(y, 0, h) {
        rep(x, 0, w) { cin >> a[y][x]; }
    }

    int maxv = 0;
    rep(y, 0, h) {
        rep(x, 0, w) {
            int b;
            cin >> b;
            a[y][x] = abs(a[y][x] - b);
            maxv = max(maxv, a[y][x]);
        }
    }

    cout << bfs(a, maxv) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;

    for(int i = 0;i <= 3000;i++){
        for(int j = 0;j <= 3000;j++){
            if((n - (i * r) - (j * g)) / b >= 0 && (n - (i * r) - (j * g)) % b == 0){
                ans++;
            }
        }
    }
    
    cout << ans;

    return 0;
}

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

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int i;
    for (i=sy+1 ; i<=ty ; i++)
    {
        cout << "U";
    }
    for (i=sx+1 ; i<=tx ; i++)
    {
        cout << "R";
    }
    for (i=ty-1 ; i>=sy ; i--)
    {
        cout << "D";
    }
    for (i=tx-1 ; i>=sx ; i--)
    {
        cout << "L";
    }
    cout << "L";
    
    for (i=sy ; i<=ty ; i++)
    {
        cout << "U";
    }
    for (i=sx ; i<=tx ; i++)
    {
        cout << "R";
    }
    cout << "DR";
    for (i=ty ; i>=sy ; i--)
    {
        cout << "D";
    }
    for (i=tx ; i>=sx ; i--)
    {
        cout << "L";
    }
    cout << "U" << endl;
    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

signed main() {
   int x, y;
   cin >> x >> y;
   cout << x + y/2 << endl;

   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int start = 0,end = 0;
    vector<P> lake;
    rep(i,n){
        if(!i) continue;
        int now = s[i] - '0';
        int pre = s[i-1] - '0';
        // cout << now  << ' ' << pre<< endl;
        if(!now && pre){
            start = i;
        }
        if(now && !pre || (i == n-1 && !now)){
            end = i-1;
            lake.push_back(P(start,end));
        }
    }
    int lsize = lake.size();
    int ans = 0;
    rep(i,lsize-k+1){
        int one_start,one_end;
        if(lake[i].first == 0 || i == 0)one_start = 0;
        else one_start = lake[i-1].second + 1;
        if(lake[i+k-1].second == n-1 || i+k-1 == lsize-1)one_end = n-1;
        else one_end = lake[i+k].first - 1;
        ans = max(ans, one_end - one_start + 1);
    }
    // rep(i,lake.size()) cout << lake[i].first  << ' ' << lake[i].second << endl;
    // cout << lake.size() << endl;

    if(lsize > k)cout << ans << endl;
    else cout << n << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main() {
    long long a, b;
    cin >> a >> b;
    if (abs(a + b) % 2 == 0) {
        cout << abs(a + b) / 2 << endl;
    }
    else {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int N;
  while(cin >> N, N){
    int info[100][100];
    int M[100];
    for(int i = 0; i < N; i++){
      cin >> M[i];
      for(int j = 0; j < M[i]; j++) cin >> info[i][j];
      sort(info[i], info[i] + M[i]);
    }
    int K;
    cin >> K;
    int leak[100];
    for(int i = 0; i < K; i++) cin >> leak[i];
    sort(leak, leak + K);
    int ans = -1;
    for(int i = 0; i < N; i++){
      if(M[i] < K) continue;
      int cnt = 0;
      for(int j = 0; j < K; j++){
	for(int k = 0; k < M[i]; k++){
	  if(leak[j] == info[i][k]){
	    cnt++;
	    break;
	  }
	}
      }
      if(cnt == K){
	if(ans != -1){
	  ans = -1;
	  break;
	} else {
	  ans = i + 1;
	}
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
fun main(args: Array<String>) {
    val s = readLine()!!
    var ans = Int.MAX_VALUE
    for (last in 'a'..'z') {
        ans = Math.min(ans, solve(s, last))
    }
    println(ans)
}

fun solve(S: String, last: Char): Int {
    if (!S.contains(last)) {
        return Int.MAX_VALUE
    }
    var res = 0
    var s = S
    while (true) {
        if (s == last.toString().repeat(s.length)) {
            return res
        }
        s = (0 until s.length - 1).map {
            when (last) {
                s[it], s[it + 1] -> last
                else -> s[it]
            }
        }.joinToString("")
        res++
    }
}


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

int main() {
  int N,T,c,t,mini=10000;
  cin >> N >> T;
    for(int i = 0; i < N; i += 1){
      cin >> c >> t;
      if(t <= T && c  < mini){
        mini = c;
      }
    }
  if(mini == 10000){
    cout << "TLE" << endl;
  }else{
    cout << mini << endl;
  }
  return 0;
}

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

using ll = long long int;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()


bool my_cp(pair<int, int> a, pair<int, int> b){
  return (double)b.first / (double)(b.second+1) < (double)a.first / (double)(a.second+1);
}

ll cnt_rep = 0;
ll powmod(ll N, ll P, ll M){
  cnt_rep++;
  if(P == 0) return 1;
  if(P%2 == 0){
    ll t = powmod(N, P/2, M);
    return t*t % M;
  }
  return (N * powmod(N, P-1, M)) % M;
}

int N;

void dfs(string s, char m, int N){

  if(s.length() == N){
    cout << s << endl;
  }else{
    for(char c = 'a'; c <= m; c++){
      dfs(s + c, ((c == m)? (m + 1) : m), N);
    }
  }
}





// substr(start, len)

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

  long double l = (long double)L;

  long double ans = l*l*l/27;

  cout << fixed;

  cout << setprecision(8) << ans << endl;
// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
#include <cstdio>

int map[110][110];
int a[10010];
int plus[] = {1,-1};

int main()
{
	int h,w,n;
	scanf("%d%d",&h,&w);
	scanf("%d",&n);

	for (int i = 1; i<=n; i++)
		scanf("%d",&a[i]);

	int i = 1,j = 1;
	int k = 1;
	int t = 0;
	while (i<=h)
	{
		if (a[k]>0)
		{
			//printf("! %d %d",k,a[k]);
			a[k]--;
			map[i][j] = k;
			j += plus[t];
		}else k++;

		if (j>w || j<=0)
		{
			t = t==0?1:0;
			j += plus[t];
			i++;
		}
	}

	for (i = 1; i<=h; i++)
	{
		for (j = 1; j<=w; j++)
			printf("%d ",map[i][j]);
		printf("\n");
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
void dfs(string s, char now) {
  if(s.size()==n) {
    cout<<s<<endl;
    return;
  }
  for(char i='a';i<now;i++) {
    dfs(s+i,now);
  }
  dfs(s+now,now+1);
}
 
int main() {
  cin>>n;
  dfs("",'a');
}

Measured memory_bytes: 1536
/*
Problem : https://atcoder.jp/contests/abc125/tasks/abc125_d
Algorithm :
Status :
*/
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

int n,mi = INF,flag;
ll sum;
int a[MAXN];

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%d",&n);
	for(int i = 1;i <= n;i++)
	    scanf("%d",&a[i]);
	for(int i = 1;i <= n;i++){
		sum += abs(a[i]);
		if(a[i] < 0)
		    flag ^= 1;
		mi = min(mi,abs(a[i]));
	}
	printf("%lld\n",(flag ? sum - mi * 2 : sum));
	return 0;
}


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

int main() {
	double a, b, C;
	cin >> a >> b >> C;
	double PI = acos(-1);
	printf("%.10f\n", a * b * sin(C * PI / 180) / 2);
	printf("%.10f\n", a + b + sqrt( a * a + b * b - 2 * a * b * cos(C * PI / 180)));
	printf("%.10f\n", b * sin(C * PI / 180));
}



Measured memory_bytes: 3512
let sec_low_cos a b rad =
  let sqr x = x *. x in
  sqrt (sqr a +. sqr b -. 2.*.a*.b*.(cos rad))

let area a height =
  (1./.2.) *. a*.height

let height b rad =
  b*.(sin rad)

let () =
  let a,b,ang = Scanf.scanf "%f %f %f\n" (fun x y z -> x,y,z) in
  let pi = 4.0 *. atan 1.0 in
  let rad = pi*.ang/.180. in
  let h = height b rad in
  let s = area a h in
  let l = a+.b+.(sec_low_cos a b rad) in
  Printf.printf "%f\n%f\n%f\n" s l h

Measured memory_bytes: 2604
/*#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    bool b = false;
    if(n%10 == 9)
        b = true;
    n /= 10;
    if(n == 9)
        b = true;
    if(b)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}
*/
/*#include <bits/stdc++.h>

using namespace std;

pair <int,int> p[1003];
int main()
{
  int n;
  cin >> n;
  for(int i=0 ; i<n ; i++)
    scanf("%d%d" , &p[i].first , &p[i].second);
  sort(p , p+n);
  int res = p[0].second - p[0].first + 1;
  for(int i=1 ; i<n ; i++)
  {
    if(p[i].first <= p[i-1].second && p[i].second <= p[i-1].second)
    {
      p[i].second = p[i-1].second;
      continue;
    }
    if(p[i].first <= p[i-1].second)
      res += p[i].second - p[i-1].second + 1;
    else
      res += p[i].second - p[i].first + 1;
  }
  printf("%d" , res);
}
*/
#include <bits/stdc++.h>

using namespace std;

map <int,bool> m;
int main()
{
  int n;
  scanf("%d" , &n);
  int res = 0;
  for(int i=0 ; i<n ; i++)
  {
    int x;
    scanf("%d" , &x);
    if(m[x])
    {
      res--;
      m[x] = false;
    }
    else
    {
      m[x] = true;
      res++;
    }
  }
  printf("%d" , res);
  return 0;
}



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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define itrdebug(x)
#define dassert(...)
#endif
#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void dfs(int current, vector<bool> & visited, vector<int> & dp, ll N, vector<vector<int>> & edges, std::vector<long long> & a, vector<int> & answer) {
    int prev;
    visited[current] = true;
    auto itr = lower_bound(all(dp), a[current]);
    prev = *itr;
    *itr = a[current];
    auto itr2 = lower_bound(all(dp), INT_MAX);
    answer[current] = distance(dp.begin(), itr2) - 1;
    for (const auto next : edges[current]) {
        if (visited[next]) continue;
        dfs(next, visited, dp, N, edges, a, answer);
    }
    *itr = prev;
}

void solve(long long N, std::vector<long long> a, std::vector<long long> u, std::vector<long long> v){
    // dp[length of LIS] = minimum number of last element
    vector<int> dp(N+1,INT_MAX);
    dp[0] = 0;
    vector<vector<int>> edges(N+1);
    rep(i,0,N-1) {
        edges[u[i]].push_back(v[i]);
        edges[v[i]].push_back(u[i]);
    }
    vector<bool> visited(N+1, false);
    vector<int> answer(N+1);
    dfs(1, visited, dp, N, edges, a, answer);
    rep(i,1,N+1) {
        cout << answer[i] << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N+1);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i+1]);
    }
    std::vector<long long> u(N-1);
    std::vector<long long> v(N-1);
    for(int i = 0 ; i < N-1 ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    solve(N, std::move(a), std::move(u), std::move(v));
    return 0;
}


Measured memory_bytes: 42004
import collections
n = int(input())
s = [str(input()) for i in range(n)]
m = int(input())
t = [str(input()) for i in range(m)]
set_s = set(s)
set_t = set(t)
blue = set(s) - set(t)
ss = collections.Counter(s)
tt = collections.Counter(t)
set_s_t = set(s) & set(t)
Max = -999999999
for i in set_s_t:
    Max = max(Max,ss[i]-tt[i])
for i in blue:
    Max = max(Max,ss[i])
if Max < 0:
    Max = 0
print(Max)

Measured memory_bytes: 38488
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;
typedef long long ll;

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

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

        bool ok = true;

        rep(i, N)
        {
                int t, x, y, s;
                cin >> t >> x >> y;
                s = x + y;

                if (t >= s && t % 2 == s % 2)
                {
                        continue;
                }
                else
                {
                        ok = false;
                }

                if (!ok)
                {
                        break;
                }
        }
        if (ok)
                cout << "Yes" << endl;

        else
                cout << "No" << endl;

        return 0;
}


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

int main(){
    int a;
    cin >> a;
    cout << a + pow(a,2) + pow(a,3);
}

Measured memory_bytes: 4092
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

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

    ll n,d;cin>>n>>d;
    vll x(n),y(n);

    ll ans=0;
    rep(i,n){
        cin>>x[i]>>y[i];
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d) ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6380
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c=0;
    scanf("%d%d",&a,&b);
    if(a>b)
    {
        for(int i=a;i>0;i--)
        {
            if(abs(a-i)==abs(b-i))
            {
                c=i;
            }
        }
    }
    else if(a<b)
    {
        for(int j=b;j>0;j--)
        {
            if(abs(a-j)==abs(b-j))
            {
                c=j;
            }
        }
    }
    if(c==0)
        printf("IMPOSSIBLE");
    else
        printf("%d",c);
}


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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



int main(void){
    int x, a, b;
    scanf("%d %d %d", &x, &a, &b);
    if (a >= b){
        printf("delicious\n");
    }else if (b - a <= x){
        printf("safe\n");
    }else{
        printf("dangerous\n");
    }

    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	int N;
	cin >> N;
	ll ans;
	cin >> ans;
	rep( i, 1, N ){
		ll input;
		cin >> input;
		ans *= (input/ __gcd( ans, input ));
	}
	cout << ans << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S,T,U;
    int A,B;
    cin >> S >> T >> A >> B >> U;
    if(S==U) A--;
    else B--;
    cout << A << " " << B << endl;



}


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

int main() {
	int N, A, B, C, D, dif;
	cin >> N >> A >> B >> C >> D;
	N --;
	dif = B - A;
	for (int i = 0;i < N;i ++) {
		if ((int64_t)i * C - (int64_t)(N - i) * D <= dif && 
			(int64_t)i * D - (int64_t)(N - i) * C >= dif) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
// #define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

ll dp[1001][1001];
char a[1001][1001];
ll H,W;
const ll MOD = 1e9 + 7;

ll rec(ll x,ll y){
    if(x < 0 || y < 0) return 0;
    if(x == 1 && y == 1) return 1;

    if(a[x][y] == '#') return 0;
    
    ll &ans = dp[x][y];
    if(ans != -1) return ans;

    ans = 0;
    ans = (ans + rec(x-1,y))%MOD;
    ans = (ans + rec(x,y-1))%MOD;

    return ans;
}

void solve(){
    cin>>H>>W;

    FOR(i,1,H) FOR(j,1,W) cin>>a[i][j];
    memset(dp,-1,sizeof(dp));

    ll ans = rec(H,W);
    cout<<ans<<endl;
}

signed main(){


    FastRead;    

    ll t;
    t = 1; 
    // cin>>t;
    while(t--) solve();
    
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n - 1) / (2 * d + 1) + 1 << endl;
    return 0;
}

Measured memory_bytes: 3620
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {

      public static void main(String[] args) {

            Scanner sc = new Scanner(System.in);
            int h = sc.nextInt();
            int w = sc.nextInt();
            boolean[][] hasBomb = new boolean[h+2][w+2];
            for(int i = 1 ;i<=h;i++){
                  String line = sc.next();
                  for(int j = 1;j<=w;j++){
                        hasBomb[i][j] = line.charAt(j-1)=='#';
                  }
            }
            for(int i = 1;i<=h;i++){
                  StringBuffer bf = new StringBuffer();
                  for (int j = 1;j<=w;j++){
                        bf.append(searchBomb(hasBomb,i,j));
                  }
                  System.out.println(bf.toString());
            }
            


            System.out.println();
      }
      public static char searchBomb(boolean[][] hasBomb,int i,int j){

            if(hasBomb[i][j]){
                  return '#';
            }
            int ans = 0;
            if (hasBomb[i-1][j-1]){
                  ans++;
            }
            if (hasBomb[i-1][j]){
                  ans++;
            }
            if (hasBomb[i-1][j+1]){
                  ans++;
            }
            if (hasBomb[i][j-1]){
                  ans++;
            }
            if (hasBomb[i][j+1]){
                  ans++;
            }
            if (hasBomb[i+1][j-1]){
                  ans++;
            }
            if (hasBomb[i+1][j]){
                  ans++;
            }
            if (hasBomb[i+1][j+1]){
                  ans++;
            }

            return Integer.toString(ans).charAt(0);
      }


}


Measured memory_bytes: 27200
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
a = na()
f = [0]*8
sp = 0
for v in a:
    if v >= 3200:
        sp += 1
    else:
        f[v//400] = 1
if sum(f) > 0:
    print("{} {}".format(sum(f), sum(f)+sp))
else:
    print("{} {}".format(sum(f)+min(sp,1), sum(f)+sp))



Measured memory_bytes: 3064