akhauriyash/Code-Regression huggingface dataset:
#AGC013A

n=int(raw_input())
a=map(int,raw_input().split())
cnt=0
ff=0
for i in xrange(1,n):
 if a[i-1]<a[i]:
  if ff<0:
   cnt+=1
   ff=0
  else:
   ff=1
 elif a[i-1]>a[i]:
  if ff>0:
   cnt+=1
   ff=0
  else:
   ff=-1
print cnt+1


Measured memory_bytes: 11296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll dfs(ll x){
  if(x==1)return 1;
  return 1+2*(dfs(x/2));
}

int main(){
  ll h;
  cin >> h;
  cout << dfs(h) << endl;
return 0;}

Measured memory_bytes: 256
n,W=[int(x) for x in input().split()]

t=[0 for i in range(W+1)]

for i in range(n):
  v,w=[int(_) for _ in input().split()]
  
  for j in range(W-w+1):
    t[j+w]=max(t[j]+v,t[j+w])
print(max(t))
#print(t)


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

class union_find{
public:
    union_find(int N){
        parent = new int[N];
        rank = new int[N];
        for(int i = 0; i < N; i++){
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x){
        if(parent[x] == x) return x;
        else return parent[x] = root(parent[x]);
    }

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

    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x != y){
            if(rank[x] < rank[y]){
                parent[x] = y;
            }else{
                parent[y] = x;
            }
        }else{
            parent[y] = x;
            rank[x]++;
        }
    }

private:
    int *parent;
    int *rank;
};

int main(){
    int n, m;
    cin >> n >> m;
    union_find data(n+1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        data.unite(a, b);
    }

    vector<int> size(n+1, 0);
    for(int i = 1; i <= n; i++) size[data.root(i)]++;

    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(ans < size[i]) ans = size[i];
    }

    cout << ans << endl;

    return 0;
}

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

int cnt;

void selectionSort(vector<int>& a, int n) {
	for (int i = 0; i < n; i++) {
		int minj = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[minj])
				minj = j;
		}
		if (i != minj) {
			swap(a[i], a[minj]);
			cnt++;
		}
	}
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	selectionSort(a, n);
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i < n - 1)
			cout << " ";
		else
			cout << endl;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

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

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  if ( N % 2 == 0 ) std::cout << N/2 - 1 << std::endl;
  else std::cout << (N-1)/2 << std::endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
x=[]
for i in range(N):
    x.append(list(map(int,input().split())))
for i in range(N-2):
    if x[i][0]==x[i][1] and x[i+1][0]==x[i+1][1] and x[i+2][0]==x[i+2][1]:
        print("Yes")
        break
else:
     print("No")

Measured memory_bytes: 9192
#include <iostream>
#include <vector>
#include <cstring>
#include <list>
using namespace std;
const int mod=1e9L+7;
int n,x,y;
list<int>nodes[100000];
long long int dp[100000][2];

void dfs(int _node, int prev){
    if(nodes[_node].size()>1||prev==-1){
        dp[_node][0]=1;
        dp[_node][1]=1;
        for(auto ele:nodes[_node]){
            if(ele==prev){
                continue;
            }
            dfs(ele,_node);
            dp[_node][0]=(dp[_node][0]*dp[ele][1])%mod;
            dp[_node][1]=(dp[_node][1]*(dp[ele][1]+dp[ele][0]))%mod;
        }
    }
    else{
        dp[_node][0]=1;
        dp[_node][1]=1;
    }
    return;
}
int main() {
    scanf("%d",&n);
    for(int i=0;i<n-1;i+=1){
        scanf("%d%d",&x,&y);
        nodes[x-1].push_back(y-1);
        nodes[y-1].push_back(x-1);
    }
    dfs(0,-1);
    printf("%lld",(dp[0][0]+dp[0][1])%mod);
	return 0;
}


Measured memory_bytes: 16512
n = int(input())

a = list(map(int,input().split()))

ans = 0
b = 0
for i in range(0,n):
    if i % 2 == 1:
        if b+a[i] <1:
            ans += abs(b+a[i])+1
            b = 1
        else:
            b+=a[i]
    else:
        if b+a[i] >-1:
            ans += abs(b+a[i])+1
            b = -1
        else:
            b+=a[i]
ansa= 0
bb = 0
for i in range(n):
    if i % 2 == 0:
        if bb+a[i] <1:
            ansa += abs(bb+a[i])+1
            bb = 1
        else:
            bb+=a[i]
    else:
        if bb+a[i] >-1:
            ansa += abs(bb+a[i])+1
            bb = -1
        else:
            bb+=a[i]
print(min(ans,ansa))

Measured memory_bytes: 14508
n=int(input())
li = list(map(int,input().split()))
ans=0
for i in range(n):
    ans+=li[i]

ansb=ans
ansa=ans-2*li[0]
for i in range(n-1):
    if ansa<=0:
        if abs(ansa)>ansb:
            print(ansb)
            break
        else:
            print(abs(ansa))
            break
    ansb=ansa
    ansa-=2*li[i+1]

Measured memory_bytes: 3064
x1, y1, x2, y2 = map(int, input().split())

(dx, dy) = (x2 - x1, y2 - y1)
(x3, y3) = (x2 - dy, y2 + dx)
(x4, y4) = (x3 - dx, y3 - dy)
print("%d %d %d %d" % (x3, y3, x4, y4))

Measured memory_bytes: 40492
#include <stdio.h>
int main(void){
  int A,B;
  scanf("%d",&A);
  scanf("%d",&B);
  int q=A+B;
  int w=A-B;
  int e=A*B;
  int s=(q>w)?q:w;
  int max=(s>e)?s:e;
  printf("%d",max);
}

Measured memory_bytes: 128
using System;

public class AOJ2544
{
	static void Main()
	{
        string[] names = new string[50];
        string[] setup = Console.ReadLine().Split(' ');
        names[0] = "kogakubu10gokan";
        {
            int cy = 1;
            int n=int.Parse(setup[0]);
            for (int i = 0; i < n; i++)
            {
                string[] line = Console.ReadLine().Split(' ');
                int ty= int.Parse(line[0])-1;
                for(;cy<ty;cy++)names[cy]=names[cy-1];
                names[ty]=line[1];
                cy++;
            }
            for (; cy < 50; cy++) names[cy] = names[cy - 1];
        }
        Console.WriteLine(names[int.Parse(setup[1])-1]);
	}
}

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

ll f3(ll c, ll d) { return d ? f3(d, c % d) : c; }

ll f2(ll c, ll d) {
	return(c / f3(c, d) * d);
}

ll f(ll x, ll c, ll d) {
	ll res = x;
	res -= x / c;
	res -= x / d;
	res += x / f2(c, d);
	return res;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	ll ans = f(b, c, d) - f(a - 1, c, d);
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
d_i = [0] * n
for x in range(n):
    d_i[x] += int(input())
list.sort(d_i, reverse = True)
ans = 0
preVal = 101
for d in d_i:
    if d < preVal:
        ans += 1
        preVal = d
print(ans)

Measured memory_bytes: 9036
// AOJ 2164 Revenge of the Round Table
// 2018.3.22 bal4u

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int gcd(int a, int b)
{
	int r;
	while (b != 0) r = a % b, a = b, b = r;
	return a;
}

#define M 1000003

int n, k;
int inv[1002];
int dpa[1002][1002], dpb[1002][1002], dp[1002];

void calc()
{
	int i, j, t, sa, sb;

    memset(dpa, 0, sizeof(dpa));
    memset(dpb, 0, sizeof(dpb));
    memset(dp, 0, sizeof(dp));

    sa = 1, sb = 0;
    dpa[1][1] = 1;
    dpb[1][1] = 0;
 
    for (i = 2; i <= n; i++) {
        dpa[i][1] = sb, dpb[i][1] = sa;
		t = sa, sa = sb, sb = t;
        for (j = 2; j <= k; j++) {
            dpa[i][j] = dpa[i-1][j-1];
            sa = sa + dpa[i][j]; if (sa >= M) sa -= M;
            dpb[i][j] = dpb[i-1][j-1];
            sb = sb + dpb[i][j]; if (sb >= M) sb -= M;
        }
    }

    for (i = 1; i <= n; i++) for (j = 1; j <= k; j++) {
		dp[i] += dpb[i][j]; if (dp[i] >= M) dp[i] -= M;
	}
 
    for (i = 1; i <= n; i++) for (j = 1; j < k; j++) {
		dpb[i][j+1] += dpb[i][j]; 
		if (dpb[i][j+1] >= M) dpb[i][j+1] -= M;
    }
 
    for (i = 1; i <= n; i++) {
		t = i; if (t > k) t = k; 
        for (j = 1; j <= t; j++) {
            dp[i] += dpb[i-j][k-j]; if (dp[i] >= M) dp[i] -= M;
        }
    }
}

int main()
{
	int s, i;
	long long ans;

    inv[1] = 1; for (i = 2; i <= 1000; i++)
		inv[i] = M - (long long)(M/i) * inv[M%i] % M;

	while (n = in()) {
		k = in();

		s = 0;
	    if (k >= n) k = n-1, s = 2;
		calc();
		ans = 0; for (i = 0; i < n; i++) ans = (ans + (dp[gcd(i, n)] << 1)) % M;
        printf("%d\n", (int)((s + ans * inv[n]) % M));
	}
	return 0;
}


Measured memory_bytes: 9556
mat = 3.times.map{ gets.split.map(&:to_i) }
def check(mat)
    mat[0][0] - mat[1][0] == mat[0][1] - mat[1][1] &&
    mat[0][1] - mat[1][1] == mat[0][2] - mat[1][2] &&
    mat[1][0] - mat[2][0] == mat[1][1] - mat[2][1] &&
    mat[1][1] - mat[2][1] == mat[1][2] - mat[2][2]
end

if check(mat) && check(mat.transpose) then puts "Yes"
else puts "No"
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n,q; cin>>n>>q;
    string s; cin>>s;
    vector<ll> x(n, 0);
    rep(i,n){
        if(i==0) continue;
        x[i]=x[i-1];
        if(s[i-1]=='A' && s[i]=='C') x[i]++;
    }
    rep(i,q){
        ll l,r; cin>>l>>r;
        cout<<x[r-1]-x[max(0ll, l-1)]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  string s;cin >> s;
  if(s == "A")cout << "T" << endl;
  else if(s == "T") cout << "A" << endl;
  else if(s == "C") cout << "G" << endl;
  else cout << "C" << endl;
 }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}



int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll a,b;cin>>a>>b;
  ll n;cin>>n;
  ll ans = b/n+1;
  ans -= (a-1 != -1)?(a-1)/n+1:0;
  print(ans);
  return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Info{
	void set(ll arg_x1,ll arg_y1,ll arg_x2,ll arg_y2){
		x1 = arg_x1;
		y1 = arg_y1;
		x2 = arg_x2;
		y2 = arg_y2;
	}
	ll x1,y1,x2,y2;
};

Info info[2001];


int main(){

	int N;
	scanf("%d",&N);

	vector<ll> X,Y;

	X.push_back(-BIG_NUM);
	X.push_back(BIG_NUM);

	Y.push_back(-BIG_NUM);
	Y.push_back(BIG_NUM);

	for(int i = 0; i < N; i++){
		scanf("%lld %lld %lld %lld",&info[i].x1,&info[i].y1,&info[i].x2,&info[i].y2);
		X.push_back(info[i].x1);
		X.push_back(info[i].x2);
		Y.push_back(info[i].y1);
		Y.push_back(info[i].y2);
	}

	sort(X.begin(),X.end());
	sort(Y.begin(),Y.end());

	X.erase(unique(X.begin(),X.end()),X.end());
	Y.erase(unique(Y.begin(),Y.end()),Y.end());

	map<ll,int> X_INDEX,Y_INDEX;

	for(int i = 0; i < X.size(); i++){
		X_INDEX[X[i]] = i;
	}
	for(int i = 0; i < Y.size(); i++){
		Y_INDEX[Y[i]] = i;
	}

	int H = (int)Y.size(),W = (int)X.size();

	int** table = new int*[H];
	for(int row = 0; row < H; row++){
		table[row] = new int[W];
		for(int col = 0; col < W; col++){
			table[row][col] = 0;
		}
	}

	ll new_x1,new_y1,new_x2,new_y2;

	for(int i = 0; i < N; i++){
		new_x1 = X_INDEX[info[i].x1];
		new_y1 = Y_INDEX[info[i].y1];
		new_x2 = X_INDEX[info[i].x2];
		new_y2 = Y_INDEX[info[i].y2];

		for(int row = new_y1; row < new_y2; row++){
			table[row][new_x1]++;
			table[row][new_x2]--;
		}
	}

	for(int row = 0; row < H; row++){
		for(int col = 1; col < W; col++){
			table[row][col] += table[row][col-1];
		}
	}

	ll ans = 0;

	for(int row = 0; row < H; row++){
		for(int col = 0; col < W; col++){
			if(table[row][col] != 0){
				ans += (X[col+1]-X[col])*(Y[row+1]-Y[row]);
			}
		}
	}

	printf("%lld\n",ans);

	return 0;
}



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

int main(){
	int second;
	int h,m,s;
	int amari1, amari2;

	cin >> second;

	h = second/3600;
	amari1 = second%3600;
	m = amari1/60;
	amari2 = amari1%60;
	s = amari2;

	cout << h << ":" <<  m << ":" << s << endl;


}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Set<Integer> finished = new HashSet<>();

        Map<Integer, Integer> map = new HashMap<>();
        int cnt = 0;
        for(int i = 0; i < m; i++) {
        	int p = sc.nextInt();
        	String res = sc.next();
        	if(finished.contains(p))
        		continue;
        	if(res.equals("AC")) {
        		finished.add(p);
        		cnt += map.getOrDefault(p, 0);
        	} else {
        		map.put(p, map.getOrDefault(p, 0) + 1);
        	}
        }
        System.out.println(finished.size() + " " + cnt);
    }
}


Measured memory_bytes: 68572
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

vector<vector<int>> lookup;
int L;

void build_sparse_table(int N, vector<ll>& a) {
    int n = 1;
    L = 0;
    while (n <= N) {
        n <<= 1;
        L++;
    }
    lookup = vector<vector<int>>(N, vector<int>(L));
    REP(i, N) {
        lookup[i][0] = a[i];
    }
    for (int j = 1; j < L; j++) {
        REP(i, N - (1 << j) + 1) {
            lookup[i][j] = min(lookup[i][j-1], lookup[i + (1 << (j-1))][j-1]);
        }
    }
}

int query(int l, int r) {
    int lb = 0, ub = L + 1;
    while (ub - lb > 1) {
        int m = (lb + ub) / 2;
        if ((1 << m) < r - l) lb = m;
        else ub = m;
    }
    return min(lookup[l][lb], lookup[r - (1 << lb)][lb]);
}

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

    int N;
    cin >> N;
    vector<ll> a(N);
    REP(i, N) cin >> a[i];
    build_sparse_table(N, a);

    vector<ll> left(N);
    REP(i, N) {
        int lb = -1, ub = i;
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (query(m, i) < a[i]) lb = m;
            else ub = m;
        }
        left[i] = i - lb;
    }
    vector<int> right(N);
    REP(i, N) {
        int lb = i, ub = N+1;
        while (ub - lb > 1) {
            int m = (lb + ub) / 2;
            if (query(i, m) < a[i]) ub = m;
            else lb = m;
        }
        right[i] = lb - i;
    }
    ll ans = 0;
    REP(i, N) ans += left[i] * right[i] * a[i];
    cout << ans << endl;
}

Measured memory_bytes: 24448
#include <stdio.h>

#define LIM 1000000
int sieve[LIM], primes[LIM], pcnt = 0;

int main(void) {
	long long int n;
	scanf("%lld", &n);

	sieve[0] = sieve[1] = 1;
	primes[pcnt++] = 2;
	for (int i = 3; (long long int) i*i <= n; i += 2) {
		if (sieve[i])
			continue;
		primes[pcnt++] = i;
		for (long long int j = (long long int) i*i; j < LIM; j += i)
			sieve[j] = 1;
	}

	int ans = 0;
	for (int i = 0; i < pcnt && n > 1; i++) {
		int cnt = 0;
		while (n % primes[i] == 0) {
			cnt++;
			n /= primes[i];
		}
		if (!cnt)
			continue;

		for (int j = 1; j <= cnt; j++) {
			cnt -= j;
			ans++;
		}
	}

	if (n > 1)
		ans++;
	printf("%d\n", ans);
}


Measured memory_bytes: 5940
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    long long a, b, c, d; cin >> a >> b >> c >> d;
    cout << max({a*c, a*d, b*c, b*d}) << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3644
N = int(input())

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

A_dict = {}

for i in A:
  A_dict.setdefault(i,0)
  A_dict[i]+=1
  
for i in range(1,N+1):
  if i in A_dict:
    print(A_dict[i])
  else:
    print(0)


Measured memory_bytes: 33504
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial, std.numeric;

void main(){
    auto nm=readln.split.map!(to!int).array;
    int[][] abs;
    foreach(i;0..nm[1])abs~=readln.split.map!(to!int).array;
    foreach(n;1..nm[0]+1)writeln(abs.count!(ab=>ab[0]==n||ab[1]==n));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n, k, s;
    cin >> n >> k >> s;
    ll ma = 1e9;
    vl ans(n);
    rep(i, k) ans[i] = s;
    REP(i, k, n) ans[i] = (s == ma ? ma-1 : s+1);
    rep(i, n) {
        cout << ans[i] << (i +1 == n ? '\n' : ' ');
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

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

    int N;
    cin >> N;
    vector<Pll> robots(N);
    for (int i = 0; i < N; ++i) {
        ll x, l;
        cin >> x >> l;
        robots[i].first = x - l;
        robots[i].second = x + l;
    }

    sort(robots.begin(), robots.end(), [](Pll& l, Pll& r) {
        if (l.second < r.second) {
            return true;
        }
        else {
            return false;
        }
    });

    ll bou = -L_INF;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (robots[i].first >= bou) {
            ++ans;
            bou = robots[i].second;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+10;
int n;
long long k;
int a[N],las[N],pos[N],b[N],len[N];
bool c[N];
int main() {
	scanf("%d%lld",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--) las[i]=pos[a[i]],pos[a[i]]=i;
	for (int i=1;i<=n;i++) if (!las[i]) las[i]=pos[a[i]],len[i]=1;
	for (int i=1;i<=n;i++) if (las[i]==n) len[i]++;
	for (int i=1;i<=n;i++) las[i]=las[i]%n+1;
	int now=1,l=0; k--;
	while (k>0) {
		k-=(ll)len[now]; now=las[now];
		if (c[now]) break;
		c[now]=1; b[++l]=now;
	}
	if (k<0) return 0;
	if (k>0){
		int s=0;
		for (int i=1;i<=l;i++) if (b[i]==now) {
			for (int j=i;j<=l;j++) s+=len[b[j]]; break;
		}
		k=k%(ll)s;
		while (k>0) {
			k-=(ll)len[now]; now=las[now];
		}
		if (k<0) return 0;
	}
	memset(pos,0,sizeof(pos)); l=0;
	for (int i=now;i<=n;i++) if (!pos[a[i]]) {
		pos[a[i]]=i; b[++l]=a[i];
	} else {
		while (b[l]!=a[i]) pos[b[l]]=0,l--;
		pos[a[i]]=0; l--;
	}
	for (int i=1;i<=l;i++) printf("%d ",b[i]);
} 

Measured memory_bytes: 5376
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<usize>();
    let mut v = vec![];

    for i in 0..n {
        let a = read_vec::<i64>();
        match a[0] {
            0 => v.push(a[1]),
            1 => println!("{}", v[a[1] as usize]),
            _ => {
                v.pop().unwrap();
            }
        }
    }
}



Measured memory_bytes: 7080
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if(s[0] == '0' || s[s.size()-1] == '1' || s[s.size()-2] == '0')
    {
        cout << -1 << endl;
        return 0;
    }
    int j = s.size() - 3;
    for(int i = 1; i < j; i++)
    {
        if(s[i] != s[j])
        {
            cout << -1 << endl;
            return 0;
        }
        j--;
    }
    int now = 1;
    for(int i = 0; i < s.size()-1; i++)
    {
        cout << now << " " << i+2 << endl;
        if(s[i] == '1')
        {
            now = i+2;
        }
    }
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
ll dp[100002][2];
int main(){
	string L;
	scan(L);
	ll MOD=1e+9+7;
	int N=L.size();
	ll twoth[100002]={};
	twoth[0]=1;
	rep(i,N){
		twoth[i+1]=twoth[i]*2%MOD;
	}
	dp[0][0]=1;
	rep(i,N){
		rep(j,2){
			int lim;
			if(j==1) lim=1;
			else lim=L[i]-'0';
			rep(k,lim+1){
				dp[i+1][j||k<lim]+=dp[i][j]*(k+1)%MOD;
				dp[i+1][j||k<lim]%=MOD;
			}
		}
	}
	prin((dp[N][0]+dp[N][1])%MOD);
	return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<ll,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define eps 10E-10
#define mod 1000000007
#define pai acos(-1)
#define N 25

vector<int>hst[N],dishst[N];

bool check_bit(int mask,int k){
   return (mask>>k)&1;
}

int main ()
{
//   ios_base::sync_with_stdio(false);
//   cin.tie(NULL);
   int n;
   cin>>n;
   for(int i=1;i<=n;i++){
      int m;cin>>m;
      while(m--){
         int x,y;cin>>x>>y;
         if(y) hst[i].pb(x);
         else dishst[i].pb(x);
      }
      sort(hst[i].begin(),hst[i].end());
      sort(dishst[i].begin(),dishst[i].end());
   }
   int ans=0;
   for(int mask=0;mask<(1<<n);mask++){
      set<int>sth,stdh;
      for(int i=0;i<n;i++){
         if(check_bit(mask,i)) sth.insert(i+1);
         else stdh.insert(i+1);
      }
      bool ok=1;
      for(int i=1;i<=n;i++){
         if(check_bit(mask,i-1)){
            for(int v:hst[i]){
               if(stdh.find(v)!=stdh.end()) ok=0;
            }
            for(int v:dishst[i]){
               if(sth.find(v)!=sth.end()) ok=0;
            }
         }
      }
      if(ok) ans=max(ans,(int)sth.size());
   }
   cout<<ans<<endl;
   return 0;
}


Measured memory_bytes: 256
import numpy as np

n=int(input())
S=[]
for i in range(0,n):
    s=str(input())
    S.append(s)
SSS=''
alpha=list('abcdefghijklmnopqrstuvwxyz')
c=np.zeros((n,26))
for i in range(0,26):
    for j in range(0,n):
        c[j,i]=S[j].count(alpha[i])
    if np.min(c[:,i])>0.5:
        SSS=SSS+alpha[i]*int(np.min(c[:,i]))
print(SSS)

Measured memory_bytes: 12492
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);
 
struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

int main(void){
    int n, m; cin >> n >> m;

    UnionFind uf(n);
    set<int> used;
    rep(loop, m){
        int a, b; cin >> a >> b;
        a--, b--;
        used.insert(a), used.insert(b);

        uf.unionSet(a, b);
    }

    set<int> roots;
    rep(i, n){
        if(used.find(i) == end(used)) continue;
        roots.insert(uf.root(i));
    }

    int res = abs(n - (int)used.size() - (int)roots.size());
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3208
use std::collections::BinaryHeap;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a: Vec<u64> = sc.vec(n);
    let mut b: Vec<u64> = sc.vec(n);
    let mut q = BinaryHeap::new();
    for i in 0..n {
        if b[i] < a[i] {
            println!("-1");
            return;
        }

        add(&a, &b, &mut q, i);
    }

    let mut ans = 0;
    while let Some((_, i)) = q.pop() {
        let prev = if i == 0 { b[n - 1] } else { b[i - 1] };
        let next = if i == n - 1 { b[0] } else { b[i + 1] };
        ans += (b[i] - a[i]) / (prev + next);
        b[i] = (b[i] - a[i]) % (prev + next) + a[i];
        add(&a, &b, &mut q, (i + 1) % n);
        add(&a, &b, &mut q, (n + i - 1) % n);
    }

    if a == b {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}

fn add(a: &Vec<u64>, b: &Vec<u64>, q: &mut BinaryHeap<(u64, usize)>, i: usize) {
    let n = a.len();
    let prev = if i == 0 { b[n - 1] } else { b[i - 1] };
    let next = if i == n - 1 { b[0] } else { b[i + 1] };

    if b[i] - a[i] >= prev + next {
        q.push(((b[i] - a[i]) / (prev + next), i));
    }
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
#include <stdio.h>
     
    int main(void) {
      int n,t,c[200000],i,ans = 0;
      scanf("%d %d",&n,&t);
      for (i = 0;i < n;i++) {
        scanf("%d",&c[i]);
      }
      for (i = 1;i < n;i++) {
        if (c[i] < c[i - 1] + t) {
          ans += c[i] - c[i - 1];
        } else {
          ans += t;
        }
      }
      ans += t;
      printf("%d\n",ans);
      return 0;
    }

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

int n, t, tmp1, tmp2;

int main() {
    int min_cost = 10000;
    std::cin >> n >> t;
    for (int i = 0; i < n; i++) {
        std::cin >> tmp1 >> tmp2;
        if (tmp2 <= t) {
            if (tmp1 < min_cost) {
                min_cost = tmp1;
            }
        }
    }
    if (min_cost == 10000) {
        std::cout << "TLE" << std::endl;
        return 0;
    }
    std::cout << min_cost << std::endl;
}


Measured memory_bytes: 256
#コンビネーション
def cmb(n, r):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % mod

N = pow(10, 6) + 10  # N は必要分だけ用意する
mod = pow(10, 9) + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % mod)
    inv.append((-inv[mod % i] * (mod // i)) % mod)
    factinv.append((factinv[-1] * inv[-1]) % mod)


x,y = map(int,input().split())
ans = 0
if (x + y) % 3 == 0:
    a = (2 * y - x) // 3
    b = (2 * x - y) // 3
    ans = cmb(a + b, min(a, b))
print(ans)


Measured memory_bytes: 122048
#include<bits/stdc++.h>
using namespace std;
int n,s;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		s^=a;
	}
	if(s)puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
using ull=unsigned long long;
constexpr auto inf=static_cast<ll>(1e18);
template<typename T=ll>inline T in(){T ret;cin>>ret;return ret;}
template<typename T=ll>inline auto vec2(size_t h,size_t w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
inline void setp(int n){cout<<fixed<<setprecision(n);}
inline void delnl(){cin.ignore(numeric_limits<streamsize>::max(),'\n');}

int main()
{
    ll x=in();
    vector<bool>foo(x+1,false);
    queue<ll>q;
    int p[]={100,101,102,103,104,105};
    for(auto pp:p){
        foo[pp]=true;
        q.push(pp);
    }
    while(!q.empty()){
        ll f=q.front();
        for(auto pp:p){
            if(f+pp<=x&&!foo[f+pp]){
                foo[f+pp]=true;
                q.push(f+pp);
            }
        }
        q.pop();
    }
    cout<<(foo[x]?1:0)<<endl;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
   

}

Node treeMaximum(Node x){


}

Node treeSearch(Node u, int k){


}

Node treeSuccessor(Node x){


}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(x->key > k) x=x->left;
    else x=x->right;
  }

  z->parent=y;

  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;

}

void inorder(Node u){

  if(u!=NIL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }

}
void preorder(Node u){

  if(u!=NIL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25208
#define _USE_MATH_DEFINES
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<vector>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const long long int INF=1001001001001001001;
int N,K;
vector<int> D;
long long int A[100002],B[100002];
long long int C[100002];
int main(){
	scanf("%d",&N);
	rep(i,N){
		scanf("%lld %lld",&A[i],&B[i]);
		long long int w=A[i]/B[i];
		C[i]=max( ((w+1)*B[i] )-A[i] ,(long long int)0);
	}
	long long int sum=0;
	for(int i=N-1;i>-1;i--){
				long long int a=(sum+A[i])/B[i];
				if((sum+A[i])%B[i])a++;
				sum=(a*B[i]-A[i]);
	}
	printf("%lld\n",sum);
	return 0;
}

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

using namespace std;

int h, w, m, x[300005], y[300005], p[300005], q[300005], ans;
vector<int> A, B;
set<pair<int, int>> S;

int main() {
    scanf("%d%d%d", &h, &w, &m);
    for (int i = 1; i <= m; i++) {
        scanf("%d%d", &x[i], &y[i]);
        S.insert({x[i], y[i]});
        ++p[x[i]], ++q[y[i]];
    }
    int mx = *max_element(p + 1, p + h + 1), my = *max_element(q + 1, q + w + 1);
    for (int i = 1; i <= h; i++)
        if (mx == p[i])
            A.push_back(i);
    for (int i = 1; i <= w; i++)
        if (my == q[i])
            B.push_back(i);
    for (int i:A)
        for (int j:B)
            if (!S.count({i, j})) {
                printf("%d", mx + my);
                return 0;
            }
    printf("%d", mx + my - 1);
    return 0;
}

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

typedef struct{
  double x;
  double y;
}point;

void koch(int n, point p1, point p2){
  point s,t,u;

  if(n==0){
    return;
  }

  //s,t,uの算出
  //----------------------
  s.x = (2*p1.x+1*p2.x)/3;
  s.y = (2*p1.y+1*p2.y)/3;
  //----------------------
  t.x = (1*p1.x+2*p2.x)/3;
  t.y = (1*p1.y+2*p2.y)/3;
  //----------------------
  u.x = (t.x-s.x)*cos(60*M_PI/180)-(t.y-s.y)*sin(60*M_PI/180)+s.x;
  u.y = (t.x-s.x)*sin(60*M_PI/180)+(t.y-s.y)*cos(60*M_PI/180)+s.y;

  koch(n-1, p1, s);
  printf("%lf %lf\n",s.x,s.y );
  koch(n-1, s, u);
  printf("%lf %lf\n",u.x,u.y);
  koch(n-1, u, t);
  printf("%lf %lf\n",t.x,t.y);
  koch(n-1, t, p2);
}

int main() {
  int n;
  point p1,p2;

  scanf("%d",&n);
  p1.x = 0.0;
  p1.y = 0.0;
  p2.x = 100.0;
  p2.y = 0.0;

  printf("%lf %lf\n", p1.x, p2.y);
  koch(n,p1,p2);
  printf("%lf %lf\n", p2.x, p2.y);
  return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		char A[] = new char[200000];
		A = sc.next().toCharArray();
		int max=1;
		int count=0;
		boolean flag=false;
		for(int i=0;i<A.length;i++){
			if(A[i]=='A'){
				flag=true;
			}
			
			if(A[i]=='Z' && flag){
				count++;
				if(max<count)
				max=count;
			}
			else if(flag){
				count++;
			}
		}
		if(max<=1){System.out.println("0");}
		else{System.out.println(max);}
	
	}
}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,m;cin>>n>>m;
  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> z(n);
  int i,j;
  ll ans=0;
  rep(i,n)cin>>x[i]>>y[i]>>z[i];
  rep(i,1<<3)
  {
    vector<ll> val(n,0);
    rep(j,n)
    {
      if(i&1<<0)val[j]+=x[j];
      else val[j]-=x[j];
      if(i&1<<1)val[j]+=y[j];
      else val[j]-=y[j];
      if(i&1<<2)val[j]+=z[j];
      else val[j]-=z[j];
    }
    sort(all(val));
    reverse(all(val));
    ll kans=0;
    rep(j,m)kans+=val[j];
    ans=(kans>ans)?kans:ans;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
N=int(input())
list1=list(map(int,input().split()))
dp=[[0,-2**32]]+[[0,0] for i in range(N)]
for i in range(0,N):
    dp[i+1][0]=max(dp[i][0]+list1[i],dp[i][1]-list1[i])
    dp[i+1][1]=max(dp[i][0]-list1[i],dp[i][1]+list1[i])
print(dp[N][0])

Measured memory_bytes: 26384
n, k = list(map(int, input().split()))
d_list = []
for i in range(k):
  _ = input()
  d_list.append(list(map(int, input().split())))

sunukes = []
for i in range(n):
  sunukes.append(0)

for d in d_list:
  for a in d:
    sunukes[a-1] += 1

count = 0
for s in sunukes:
  count += 0 if s else 1
print(count)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


pair<ld,ld> chu(ld a, ld b, ld c, ld d,ld dis){
  ld len2 = (a-c)*(a-c) + (b-d)*(b-d);
  ld mx=(a+c)/2,my=(b+d)/2;
  ld dx=c-a,dy=d-b;
  ld vx=-dy/sqrt(len2),vy=dx/sqrt(len2);
  ld t=sqrt(4*dis*dis-len2)/2;
  auto z=mp(mx+t*vx,my+t*vy);
  return z;
}

pair<ld,ld> chu2(ld a, ld b, ld c, ld d,ld dis){
  ld len2 = (a-c)*(a-c) + (b-d)*(b-d);
  ld mx=(a+c)/2,my=(b+d)/2;
  ld dx=c-a,dy=d-b;
  ld vx=-dy/sqrt(len2),vy=dx/sqrt(len2);
  ld t=sqrt(4*dis*dis-len2)/2;
  auto z=mp(mx-t*vx,my-t*vy);
  return z;
}


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

  int n;
  cin>>n;

  vector<ld> p(n);
  vector<ld> q(n);
  rep(i,n){
    cin>>p[i]>>q[i];
  }

//————————————————二分探索——————————————————————————

  ld ng = 0;
  ld ok = 1000;
  while (abs(ok - ng) / ok > 0.00000000001) {
    ld mid = (ng + ok) / 2;

    bool good=false;

    rep(i,n){
      rep(j,n){
        if(i>=j) continue;
        if((p[i]-p[j])*(p[i]-p[j])+(q[i]-q[j])*(q[i]-q[j])>4*mid*mid) continue;
        bool ma=true;
        auto z=chu(p[i],q[i],p[j],q[j],mid);
        ld cx=z.fi,cy=z.se;
        rep(k,n){
          if(k==i || k==j) continue;
          if((p[k]-cx)*(p[k]-cx)+(q[k]-cy)*(q[k]-cy)>mid*mid) ma=false;
        }
        if(ma) good=true;
        else {
          ma=true;
          z=chu2(p[i],q[i],p[j],q[j],mid);
          cx=z.fi,cy=z.se;
          rep(k,n){
            if(k==i || k==j) continue;
            if((p[k]-cx)*(p[k]-cx)+(q[k]-cy)*(q[k]-cy)>mid*mid) ma=false;
          }
          if(ma) good=true;
        }
      }
    }

    if(good) ok=mid;
    else ng=mid;
  }

  cout << fixed << setprecision (20);
  cout << ok << endl;

//——————————————————————————————————————————




}

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

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

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

/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}

__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    auto score = [&](int bit) {
        ll res = 0;
        rep(i, n) {
            if ((a[i] | bit) == bit) res += b[i];
        }
        return res;
    };

    ll ans = 0;
    chmax(ans, score(k));

    for (int i = 0; i < 30; ++i) {
        if (k >> i & 1) {
            int bit = k;
            bit >>= i + 1;
            bit <<= i + 1;
            bit |= (1 << i);
            bit--;
            chmax(ans, score(bit));
        }
    }

    cout << ans << '\n';
}


Measured memory_bytes: 4028
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import deque
def main():
    n=int(input())
    graph=[[]for _ in range(n)]
    for _ in range(n-1):
        u,v,w=map(int,input().split())
        graph[u-1].append((v-1,w))
        graph[v-1].append((u-1,w))
    D=[-1]*n
    D[0]=0
    que=deque([0])
    while que:
        q=que.popleft()
        qw=D[q]
        for nn,w in graph[q]:
            if D[nn]==-1:
                D[nn]=qw+w
                que.append(nn)
    for d in D:
        if d%2==0:
            print(0)
        else:
            print(1)


if __name__=='__main__':
    main()

Measured memory_bytes: 69680
#include <bits/stdc++.h>
//Remove below header file if c++ version greater than 14
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>

#define ll long long int
#define pb push_back
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define endl '\n'
#define deb(x) cout << #x << " "<< x << endl;
#define fo(i, n) for(i=0; i<n; i++)
#define Fo(i, k, n) for(i=k; i<n; i++)

using namespace std;
using mii=map<int, int>;
using mll=map<ll, ll>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
const int mod = 2019;

ll desc(ll x, ll y)
{
    return x > y;
}

int main() {
    fastIO
    ll l, r, i, j;
    cin >> l >> r;
    ll ans = -1;
    if(r < 2019)
    {
        ans = (l * r) % 2019;
        Fo(i, l, r + 1)
        {
            Fo(j, i + 1, r + 1)
            {
                ll temp = (i * j) % 2019;
                if(temp < ans)
                    ans = temp;
            }
        }
        cout << ans << endl;
    }
    else{
        ll templ = l / 2019;
        ll tempr = r / 2019;
        if(templ == tempr)
        {
            ans = INT_MAX;
            Fo(i, l, r + 1)
            {
                Fo(j, i + 1, r + 1)
                {
                    ll temp = (i * j) % 2019;
                    if(temp < ans)
                        ans = temp;
                }
            }
            cout << ans << endl;
        }
        else
            cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256