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

using namespace std;

static std::array<int, 8> candidates{0};
static std::array<std::vector<int>, 10001> caches{};

const std::vector<int>* solve(int nn) {
  if (nn < 2) {
    return nullptr;
  }
  auto& cache = caches[nn];
  if (!cache.empty()) {
    return &cache;
  }
  if (nn <= 9 && candidates[nn] > 0) {
    cache.push_back(candidates[nn]);
    if (nn == 2) {
      return &cache;
    }
  }
  for (int i = 2; i <= 9; ++i) {
    int const candidate = candidates[i];
    if (candidate == 0) {
      continue;
    }
    auto previous = solve(nn - i);
    if (previous == nullptr) {
      continue;
    }
    if (previous->size() + 1 < cache.size()) {
      continue;
    }
    if (previous->size() + 1 == cache.size() &&
        previous->front() < cache.front() && candidate < cache.front()) {
      continue;
    }
    if (previous->size() + 1 > cache.size()) {
      if (!cache.empty()) {
        cache.clear();
      }
      cache.push_back(candidate);
      cache.insert(cache.end(), previous->begin(), previous->end());
      std::sort(cache.begin(), cache.end(), std::greater<int>());
    }
    std::vector<int> ccc(previous->begin(), previous->end());
    ccc.push_back(candidate);
    std::sort(ccc.begin(), ccc.end(), std::greater<int>());
    bool replace = false;
    for (int j = 0; j < cache.size(); j++) {
      if (ccc[j] < cache[j]) {
        replace = false;
        break;
      }
      if (ccc[j] > cache[j]) {
        replace = true;
        break;
      }
    }
    if (replace) {
      cache = ccc;
    }
  }
  if (!cache.empty()) {
    return &cache;
  }
  return nullptr;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  int m;
  std::cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a;
    std::cin >> a;
    switch (a) {
      case 1:
        candidates[2] = std::max(a, candidates[2]);
        break;
      case 2:
        candidates[5] = std::max(a, candidates[5]);
        break;
      case 3:
        candidates[5] = std::max(a, candidates[5]);
        break;
      case 4:
        candidates[4] = std::max(a, candidates[4]);
        break;
      case 5:
        candidates[5] = std::max(a, candidates[5]);
        break;
      case 6:
        candidates[6] = std::max(a, candidates[6]);
        break;
      case 7:
        candidates[3] = std::max(a, candidates[3]);
        break;
      case 8:
        candidates[7] = std::max(a, candidates[7]);
        break;
      case 9:
        candidates[6] = std::max(a, candidates[6]);
        break;
      default:
        assert(false);
        break;
    }
  }
  for (auto& cache : caches) {
    cache.reserve(5000);
  }
  for (auto const v : *(solve(n))) {
    std::cout << "0123456789"[v];
  }
  std::cout << std::endl;
  return 0;
};


Measured memory_bytes: 134784
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const double pi = 3.14159265358979323846;
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
  speed;
  ll a;
  cin>>a;
  
  cout<<a+a*a+a*a*a;
  return 0;
}

Measured memory_bytes: 3584
#include <iostream>

int main(void){
    using namespace std;
    constexpr int KMAX = 10000;
    static int s[KMAX+1][2*KMAX+1];
    char c;
    int n, k, x, y;
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(int i=0; i<n; i++){
        cin >> x >> y >> c;
        y %= 2*k;
        if(c=='W'){
            x += k;
        }
        if(y>=k){
            y-=k;
            x+=k;
        }
        x %= 2*k;
        s[y+1][x+1]++;
    }
    for(int y=0; y<k; y++){
        for(int x=0; x<2*k; x++){
            s[y+1][x+1] += s[y][x+1] + s[y+1][x] - s[y][x];
        }
    }
    int max = 0;
    int v = s[0][0] - s[0][2*k];
    for(int y=0; y<k; y++){
        int u = v - s[y][0] + s[y][2*k];
        for(int x=0; x<k; x++){
            int t = u - s[0][x] - s[k][x] + s[0][x+k] + s[k][x+k] + 2*s[y][x] - 2*s[y][x+k];
            t = t<n/2 ? n-t : t;
            max = t>max ? t : max;
        }
    }
    cout << max;
    return 0;
}


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

import sys
input = sys.stdin.readline

def io_generator():
	return input()

#+++++++++++++++++++

def main(io):
	w,h,x,y = map(int, io().split())
	s=(w*h)/2.0
	dd= 1 if (w/2==x and h/2 == y) else 0
	print('{:.2f}'.format(s) + ' ' + str(dd))
	#return ss, dd

#++++++++++++++++++++

if __name__ == "__main__":
	io= lambda : io_generator()
	main(io)
	#print (main(io))
	

Measured memory_bytes: 2940
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	int h, w;
	cin >> h >> w;
	vector<string> vs;
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		vs.push_back(s);
	}
	unordered_map<int, unordered_map<int, int>> um;
	if (vs[0][0] == '.') 
		um[0][0] = 0;
	else
		um[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i == 0 && j == 0) continue;
			um[i][j] = 0x3f3f3f3f;
			if (i > 0) {
				if (vs[i - 1][j] == '.' && vs[i][j] == '#')
					um[i][j] = min(um[i][j], um[i - 1][j] + 1);
				else
					um[i][j] = min(um[i][j], um[i - 1][j]);
			}
			if (j > 0) {
				if (vs[i][j - 1] == '.' && vs[i][j] == '#')
					um[i][j] = min(um[i][j], um[i][j - 1] + 1);
				else
					um[i][j] = min(um[i][j], um[i][j - 1]);
			}

		}
	}
	cout << um[h - 1][w - 1] << endl;
}









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

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
#define mk make_pair
#define f first
#define s second

const int N = 2e5 + 7;
int t, n, m;
int a[N], dad[N];
ll num[N], res;
deque<int> now;
ii val[N];

int root(int u){ return (u == dad[u] ? u : dad[u] = root(dad[u])); }

main()
{
#define file "r"
//    freopen(file".inp", "r", stdin);
//  freopen(file".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin >> n;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
        val[i] = mk(a[i], i);
        dad[i] = i; now.push_back(i); num[i] = 1;
    }
    sort(val + 1, val + n + 1);
    for(int i = 1; i <= n; i ++)
    {
        t = root(val[i].s);
        while(1)
        {
            int tmp = root(now.front()); now.pop_front();
            if(t == tmp) break;
            if(num[t] > num[tmp])
            {
                num[t] += num[tmp]; num[tmp] = 0; dad[tmp] = t;
            }
            else
            {
                swap(t, tmp);
                num[t] += num[tmp]; num[tmp] = 0; dad[tmp] = t;
            }
        }
        res = res + 1LL*num[t] - 1LL; num[t] --;
//        cout << i << "  " << t << " " << num[t] << "\n";
        if(num[t] > 0) now.push_back(t);
//        cout << i << "  " << res << "  " << t << "\n";
    }
    cout << res << "\n";
    return 0;
}



Measured memory_bytes: 8340
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    HashMap<HashMap<String,Integer>,Integer> maps = new HashMap<HashMap<String,Integer>,Integer>();
    int n = sc.nextInt();
    String s[] = new String[n];
    int p[] = new int[n];
    int a[] = new int[n];
    String stmp="";
    int ptmp = -1;
    int atmp =0;
    for(int i=0;i<n;i++){
      s[i]=sc.next();
      p[i]=sc.nextInt();
      a[i]=i+1;
    }
    for(int j=0;j<n-1;j++){
    for(int i=0;i<n-1;i++){
      if(s[i].compareTo(s[i+1])>0){
        atmp = a[i];
        a[i] = a[i+1];
        a[i+1] = atmp;
        stmp = s[i];
        s[i] = s[i+1];
        s[i+1] = stmp;
        ptmp = p[i];
        p[i] = p[i+1];
        p[i+1] = ptmp;  
      }else if(s[i].compareTo(s[i+1])==0){
        if(p[i]<p[i+1]){
        atmp = a[i];
        a[i] = a[i+1];
        a[i+1] = atmp;
        stmp = s[i];
        s[i] = s[i+1];
        s[i+1] = stmp;
        ptmp = p[i];
        p[i] = p[i+1];
        p[i+1] = ptmp;
        }
      }else{
      }
    }

    }
    for(int k =0;k<n;k++){
      
    System.out.println(a[k]);
    }
    
  }
}

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

int main() {
  int N;
  cin >> N;
  int ans{};
  for (int i{1}; i <= N; ++i) {
    int num = static_cast<int>(log10(i) + 1);
    if (num % 2 == 1)
      ++ans;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3864
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    long long n, a, b;

    cin >> n >> a >> b;
    if((b - a) % 2 == 0)
        cout << (b - a) / 2 << endl;
    else
    {
        cout << min(a + (b - a - 1) / 2, n - b + 1 + (b - a - 1) / 2) << endl;
    }

    return 0;
}


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

int main()
{
    int n, k; cin >> n >> k;
    int a[n], dp[n];

    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            if(i-j >= 0)
                dp[i] = min(dp[i], abs(a[i]-a[i-j])+dp[i-j]);
        }
    }
    cout << dp[n-1] << endl;
    return 0;
}



Measured memory_bytes: 1024
import heapq
N,M = map(int,input().split())
pq = [-i for i in list(map(int,input().split()))]
heapq.heapify(pq)

for _ in range(M):
  i = heapq.heappop(pq)
  i *= -1
  i //= 2
  heapq.heappush(pq, -i)

print(-sum(pq))

Measured memory_bytes: 73196
n, p = map(int, input().split())
a = list(map(int, input().split()))
mod = {0:0, 1:0}
for i in a:
    mod[i % 2] += 1
ans = 0
for i in range(p, mod[1] + 1, 2):
    temp = 1
    for j in range(i):
        temp *= mod[1] - j
        temp //= j + 1
    ans += temp
for i in range(mod[0]):
    ans *= 2
print(ans)

Measured memory_bytes: 9148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1<<19;
const ll INF=1LL<<40;
struct edge{
    int to;
    ll dis;
};

vector<edge> G[MAX];
int n;
int fi[MAX],la[MAX],vs[MAX],depth[MAX];
ll bit[MAX+1];

ll sum(int i){
    int s=0;
    while(i>0){
        s+=bit[i];
        i-=i&-i;
    }
    return s;
}

//sからtの和=sum(t)-sum(s-1)

void add(int i,ll x){
    while(i<=n){
        bit[i]+=x;
        i+=i&-i;
    }
}

void DFS(int v,int p,int d,int &k){
    fi[v]=k;
    la[v]=k;
    vs[k+n-1]=v;
    depth[k+n-1]=d;
    k++;
    
    for(int i=0;i<G[v].size();i++){
        edge E=G[v][i];
        if(E.to!=p){
            add(k-1,E.dis);
            
            DFS(G[v][i].to,v,d+1,k);
            
            add(k-1,-E.dis);
            
            la[v]=k;
            vs[k+n-1]=v;
            depth[k+n-1]=d;
            k++;
        }
    }
}//1が最初...fi[root]=1になる

void rmq_init(){
    for(int i=n-2;i>=0;i--){
        if(depth[i*2+1]<depth[i*2+2]){
            depth[i]=depth[i*2+1];
            vs[i]=vs[i*2+1];
        }else{
            depth[i]=depth[i*2+2];
            vs[i]=vs[i*2+2];
        }
    }
}

void init(int n_){
    n=1;
    while(n<n_) n*=2;
    int k=1;
    DFS(0,-1,0,k);
    rmq_init();
}//2*N+1ぐらいやっとくとよい、配列サイズも2倍とる

int query(int a,int b,int k,int l,int r){
    
    if(r<=a||b<=l) return -1;
    if(a<=l&&r<=b) return k;
    else{
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        if(vl==-1) return vr;
        if(vr==-1) return vl;
        if(depth[vl]<depth[vr]) return vl;
        return vr;
    }
}

int lca(int u,int v){
    int a=min(fi[u],fi[v]),b=max(fi[u],fi[v]);
    return vs[query(a,b+1,0,0,n)];
}

int main(){

    int N;cin>>N;
    for(int i=0;i<N;i++){
        int k;cin>>k;
        for(int j=0;j<k;j++){
            int c;cin>>c;
            G[i].push_back({c,0});
            G[c].push_back({i,0});
        }
    }
    
    init(2*N+1);
    
    int Q;cin>>Q;
    
    while(Q){
        int k;cin>>k;
        if(k==0){
            int a,b;cin>>a>>b;
            add(fi[a],b);
            add(la[a]+1,-b);
        }else{
            int a;cin>>a;
            cout<<sum(fi[a])+sum(fi[0])-2*sum(fi[lca(a,0)])<<endl;
        }
        
        Q--;
    }
    
    
}

//sum(fi[a]-1)+sum(fi[b]-1)-2*sum(fi[lca(a,b)]-1)が長さ変更前の長さ




Measured memory_bytes: 35864
#include<bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

int main() {
    int N;
    int sum=0;
    cin >> N;
    long long L[N];
    for(int i=0;i<N;i++){
      cin >> L[i];
    }
    int memo[N*N*N][3]={0};
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        for(int k=0;k<N;k++){
          if(i<j && j<k){
            int vec[3]={L[i],L[j],L[k]};
            sort(vec,vec+3);
            if(vec[0]==vec[1])continue;
            if(vec[1]==vec[2])continue;
            if(vec[0]==vec[2])continue;
            if(vec[2]<vec[0]+vec[1])sum++;
            }
          }
        }
      }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 15352
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, ans, cnt = 0;
string s;

int main(){
    //cin >> ;
    //cout << ans << endl;
    cin >> K;

    FOR(i, 1, K){
        FOR(j, 1, K){
            FOR(k, 1, K){
                ans += gcd(i, gcd(j, k));
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define MAX 105

int n, d[MAX];
vector<vector<int> > vec;
vector<int> ve;
queue<int> Q;

void bfs(int s) {
	for (int i = 1; i <= n; i++) {
		d[i] = -1;
	}
	d[s] = 0;
	Q.push(s);
	int now, cnt;
	while (!Q.empty()) {
		now = Q.front();
		Q.pop();
		for (cnt = 1; cnt <= vec[now][0]; cnt++) {
			if (d[vec[now][cnt]] == -1) {
				Q.push(vec[now][cnt]);
				d[vec[now][cnt]] = d[now] + 1;
			}
		}
	}
}

int main(void) {
	vec.push_back(ve);
	int u, k, v, i;
	cin >> n;
	for (i = 0; i < n; i++) {
		ve.clear();
		cin >> u >> k;
		ve.push_back(k);
		while (k--) {
			cin >> v;
			ve.push_back(v);
		}
		vec.push_back(ve);
	}

	bfs(1);

	for (i = 1; i <= n; i++) {
		cout << i << " " << d[i] << endl;
	}
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    ll N;
    cin >> N;
    ll tmp1, tmp2, tmp;
    ll v, e;
    v = 0;
    e = 0;
    for (ll i = 1; i <= N; i++) {
        v += i * (N - i + 1);
    }
    for (ll i = 0; i < N-1; i++) {
        cin >> tmp1 >> tmp2;
        if(tmp1 > tmp2){
            tmp = tmp1;
            tmp1 = tmp2;
            tmp2 = tmp;
        }
        e += tmp1 * (N - tmp2 + 1);
    }

    printf("%lld\n", v-e);

    

}   

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

int main(){
  int a, b;
  cin >> a >> b;
  int ans = 0;
  for(int i=a; i<=b; i++){
    string s = to_string(i);
    bool ok = true;
    rep(j,s.size()/2){
      if(s[j] != s[s.size()-1-j]){
        ok = false;
        break;
      }
    }
    if(ok) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,arr[100003][3];
int dp[100003][3];
int f(int day,int x)
{
    if(day==-1) return 0;
    if(dp[day][x]!=-1) return dp[day][x];
    if(x==0) return dp[day][x]=max(f(day-1,1),f(day-1,2))+arr[day][x];
    else if(x==1) return dp[day][x]=max(f(day-1,0),f(day-1,2))+arr[day][x];
    else if(x==2) return dp[day][x]=max(f(day-1,1),f(day-1,0))+arr[day][x];
}

int main()
{
    memset(dp,-1,sizeof(dp));
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%d %d %d",&arr[i][0],&arr[i][1],&arr[i][2]);
    printf("%d",max(f(n-1,2),max(f(n-1,0),f(n-1,1))));
}


Measured memory_bytes: 5760
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

x0, y0, x1, y1 = map(int, raw_input().split())
a1, b1 = [x1 - x0, y1 - y0]
q = input()

for loop in range(q):
    x2, y2 = map(int, raw_input().split())
    a2, b2 = [x2 - x0, y2 - y0]

    if a1 * b2 - b1 * a2 > 0:
        print "COUNTER_CLOCKWISE"
    elif a1 * b2 - b1 * a2 < 0:
        print "CLOCKWISE"
    elif a1 * a2 + b1 * b2 < 0:
        print "ONLINE_BACK"
    elif abs(a2) <= abs(a1) and abs(b2) <= abs(b1):
        print "ON_SEGMENT"
    else:
        print "ONLINE_FRONT"



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

int A, B, C, D;

int main() {
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;
	return 0;
}

Measured memory_bytes: 256
/**
Code by Nitin1184
**/
# include <bits/stdc++.h>
# define ll long long
# define pi 3.14159265358979323846
# define M 1000000007
# define pb push_back
# define mp make_pair
# define ff first
# define ss second
 
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    char a[26]={'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y'};
    string ans="";
    while(n)
    {
        ans=char(a[n%26])+ans;
        if(n%26==0)
            n=(n-26)/26;
        else
            n=n/26;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3652
import sys

def L(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI():return list(map(int,sys.stdin.readline().rstrip().split()))
def LS():return list(sys.stdin.readline().rstrip().split())

def solver(N):
    ans = 0

    list = [0] * (10**4+1)
    for x in range(1,101):
        for y in range(1,101):
            for z in range(1,101):
                n = x*x+y*y+z*z+x*y+y*z+z*x
                if n <= 10**4:
                    #print(x,y,z,'=',n)
                    list[n] += 1
    for i in range(1,N+1):
        print(list[i])

def main():

    N = I()

    solver(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9428
#include <stdio.h>
#include <string.h>
#include <limits.h>

int main(void) {
    int n;
    char s[300001] = {};
    scanf("%d %s", &n, s);
    size_t l = strlen(s);
    int e[300001] = {};
    int w[300001] = {};
    for (size_t i = 0; i < l; i++) {
        if (s[i] == 'E') {
            e[i + 1] = e[i] + 1;
            w[i + 1] = w[i];
        } else {
            e[i + 1] = e[i];
            w[i + 1] = w[i] + 1;
        }
    }
    for (size_t i = 0; i < l; i++) {
        // printf("%d %d\n", e[i], w[i]);
    }
    int ret = INT_MAX;
    for (size_t i = 0; i < l; i++) {
        int tmp = 0;
        tmp += w[i] - w[0];
        if (i < l) {
            tmp += e[l] - e[i + 1];
        }
        if (tmp < ret) {
            ret = tmp;
        }
    }
    printf("%d\n", ret);
    return 0;
}

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

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int money = 1000;
    rep(i,n - 1){
        if(a[i] < a[i+1]){
            int stock = money / a[i];
            money += (a[i+1] - a[i]) * stock;
        }
    }
    cout << money << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define read(num) scanf("%d", &num)
#define readll(num) scanf("%lld", &num)
#define read2(num1, num2) scanf("%d%d", &num1, &num2)
#define read3(num1, num2, num3) scanf("%d%d%d", &num1, &num2, &num3)
#define reads(str) scanf("%s", str)
#define readc(ch) scanf("%c", &ch)
#define f first
#define se second
#define M 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<long long, long long>
#define vi vector<int>
#define ll long long


int x1,y11,x2,y2;

bool check(int x,int y){
    if(x>=x1&&x<=x2&&y>=y11&&y<=y2){
        return true;
    }
    return false;
}
int main(){
   ll n,k;
   cin>>n>>k;
   if(n>k){
       n-=k*(n/k);
   }
   cout<<min(n,k-n);
} 


Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define pi pair<int,int> 
#define pii pair<pi,int>
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a >= mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	ll n,j;
	cin>>n>>j;
	ll ans;
	// n++;
	ll res = 0;
	for(ll k = j;k<=n+1;k++){
		ans = n*(n+1)/2;
		ans %= mod;
		ll temp = (n-k)*(n-k+1)/2;
		temp %= mod;
		sub(ans,temp);
		// cout<<ans<<'\n';
		temp = (k-1)*(k)/2;
		temp %= mod;
		sub(ans,temp);
		add(ans,1ll);
		add(res,ans);
		// cout<<k<<" "<<res<<'\n';
	}
	cout<<res;
	return 0;
}

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

int k,n,ans;
int a[200005];

int main(){
    cin>>k>>n;
    for(int i=0; i<n; ++i){
        cin>>a[i];
        if(i){
            ans=max(ans,a[i]-a[i-1]);
        }
    }
    ans=max(ans,a[0]+k-a[n-1]);
    cout<<k-ans;
    return 0;
}


Measured memory_bytes: 1024
def isValid(n,l):
    s = str(n)
    for c in s:
        if c in l:
            return False
    return True

n,k = map(int, raw_input().split())
dls = raw_input().split()
for i in range(n,100000):
    if isValid(i,dls):
        print i
        break


Measured memory_bytes: 5764
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vivi;
typedef vector<ll> vll;
typedef vector<vll> vllvll;
typedef pair<int, int> Pi;
typedef queue<Pi> QPi;
typedef pair<ll, ll> Pll;
typedef queue<Pll> QPll;
typedef vector<vi> Graph;
const int mod = 1000000007;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main() {
  char s[11];
  cin >> s;
  int n=strlen(s);
  int ans=0,temp=0;
  REP(i,n) {
    if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C') {
      temp++;
      ans=max(temp,ans);
    } else {
      temp=0;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
	}

	public void run() {
		FastScanner scan = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = scan.nextInt();

		String ret = "No";
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= 9; j++) {
				if (i * j == n) {
					ret = "Yes";
					break;
				}
			}

		}

		out.println(ret);
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24660
N,T=map(int,input().split())
x=[]
for i in range(N):
  c1=list(map(int,input().split()))
  x.append(c1)
  
x.sort()
for i in range(N):
  if x[i][1]<=T:
    print(x[i][0])
    break
  elif i==N-1:
    print('TLE')
  else:
    continue
    

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

using ll=long long;



void solve(){
    int n;
    cin>>n;
    if(n/10==9||n%10==9){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

signed main(){
    //while(1)
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
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 <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
    int c[10][10];
    rep(i,10) rep(j,10) cin >> c[i][j];
    rep(k,10) rep(i,10) rep(j,10) mins(c[i][j], c[i][k] + c[k][j]);
    int ans = 0;
    rep(i,h) rep(j,w) {
        int a;
        cin >> a;
        if(a==-1) continue;
        ans += c[a][1];
    }
	cout << ans << "\n";
	return 0;
}


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

inline int calc(int p, int x) {
  return p * (100 + x) / 100;
}

int main() {
  for(int x, y, s; cin >> x >> y >> s && (x|y|s);) {
    int res = 0;
    for(int a = 1; a < s; ++a) {
      for(int b = 1; b < s; ++b) {
        if(calc(a, x) + calc(b, x) != s) continue;
        res = max(res, calc(a, y) + calc(b, y));
      }
    }
    cout << res << endl;
  }
  return 0;
}

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

int main() {
  int n;cin>>n;
  vector<vector<int>> vec(n,vector<int>(n,-1));
  rep(i,n){
    int a;cin>>a;
    rep(j,a){
      int x,y;cin>>x>>y;
      x--;
      vec[i][x]=y;
    }
  }
  int ans=0;
  rep(bit,1<<n){
    vector<int> d(n);
    rep(i,n)if(bit&(1<<i))d[i]=1;
    bool ok=true;
    rep(i,n)if(d[i])rep(j,n){
      if(vec[i][j]==-1)continue;
      if(vec[i][j]!=d[j])ok=false;
    }
    if(ok)ans=max(ans,__builtin_popcount(bit));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
 
int main() {

    int n,m;
    cin>>n>>m;
    vector<int> l(m);
    vector<int> r(m);
    rep(i,m)    cin>>l.at(i)>>r.at(i);

    int lmax=0;
    int rmin=100000000;
    rep(i,m) {
        lmax=max(lmax,l[i]);
        rmin=min(rmin,r[i]);
    }
    int ans=rmin-lmax+1;
    if(ans<0)   ans=0;

    cout<<ans<<endl;
    
 return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int can;
	int i;
	
	while (scanf("%d", &can) != EOF){
		if (can % 39 == 0){
			printf("3C39\n");
		}
		else if (can % 39 < 10){
			printf("3C0%d\n", can % 39);
		}
		else {
			printf("3C%d\n", can % 39);
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
#include <stdio.h>
#include <string.h>
#define SIZE 110
int main(void){
    //各文字の箱を作って読み取り
    char inputs[SIZE];
    fgets(inputs,SIZE,stdin);//改行コードまでの文字列の入力を代入
    printf("%c",inputs[0]);//最初の文字の出力
    printf("%d",strlen(inputs)-3);//前後及び最後の改行コードをなくしたもの
    printf("%c",inputs[strlen(inputs)-2]);//最後の文字の出力
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	houses := scanIntSlice(n)

	sort.Ints(houses)
	fmt.Printf("%d\n", houses[n-1]-houses[0])
}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 512
#coding: UTF-8

from bisect import bisect_right

max = 1000000
pflist = [True] * max

pflist[0] = False
pflist[1] = False

pflist[4::2] = [False] * len(pflist[4::2])

for i in range(3, int(max**0.5) + 1, 2):
    pflist[i*i::i] = [False] * len(pflist[i*i::i])

prime_list = [i for i in range(2, max) if pflist[i]]

while True:
    try:
        input = int(raw_input())
    except EOFError:
        break
    print bisect_right(prime_list, input)

Measured memory_bytes: 44456
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	if (N % K) cout << 1 << endl;
	else cout << 0 << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#ifdef LOCAL_DEBUG
#define DEBUG 1
#define CERR if(DEBUG) cerr
#define MACRO(_1,_2,_3,_4,_5,_6,_7,_8,_9,_10,NAME,...) NAME
#define pr(...) CERR<<MACRO(__VA_ARGS__,pr10,pr9,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)<<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define pr9(a,b,c,d,e,f,g,h,i) pr1(a)<<pr8(b,c,d,e,f,g,h,i)
#define pr10(a,b,c,d,e,f,g,h,i,j) pr1(a)<<pr9(b,c,d,e,f,g,h,i,j)
#define prArr(a){CERR<<(#a)<<"={";int i=0;for(auto t:(a))CERR<<(i++?", ":"")<<t;CERR<<"}"<<endl;}
#else
#define DEBUG 0
#define pr(...)
#define prArr(a)
#endif
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int N;
vector<vector<Int> > G;

vector<Int> bfs(){
  vector<Int> ans(N, -1);
  queue<P> Q;
  vector<Int> D(N, INF);
  vector<Int> visited(N, 0);
  Q.push(P(0, 0));
  D[0] = 0;
  while(!Q.empty()){
    Int pos, pre; tie(pos, pre) = Q.front(); Q.pop();
    if(visited[pos]++) continue;
    ans[pos] = pre;
    for(Int to:G[pos]){
      if(visited[to]) continue;
      Int ncost = D[pos] + 1;
      if(D[to] <= ncost) continue;
      D[to] = ncost;
      Q.push(P(to, pos));
    }
  }
  return ans;
}


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int M;
  cin>>N>>M;
  G.resize(N);
  for(Int i=0;i<M;i++){
    Int a, b;
    cin>>a>>b; a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  auto ans = bfs();
  pr(ans);
  for(Int a:ans) if(a == -1){cout<<"No"<<endl;return 0;}

  cout<<"Yes"<<endl;
  for(Int i=1;i<N;i++) cout<<ans[i]+1<<endl;


  return 0;
}


Measured memory_bytes: 15220
#include<stdio.h>
#include<math.h>
int main(){
  double a,b,x,ans=0;
  scanf("%lf%lf%lf",&a,&b,&x);
  if(x>=a*a*b/2){
    ans=atanf(2*(a*a*b-x)/(a*a*a));
  }
  else{
    ans=atanf((a*b*b)/(2*x));
  }
  printf("%lf\n",ans*180/M_PI);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(n) for (int i = 0; i < (n); ++i)
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(n){
        cin>>a[i];
    }
    vector<int> b(n);
    rep(n){
        cin>>b[i];
    }
    vector<int> c(n);
    rep(n-1){
        cin>>c[i];
    }
    int ans=0;
    rep(n){
        ans+=b[a[i]-1];
    }
    rep(n-1){
        if(a[i]+1==a[i+1]) ans+=c[a[i]-1];
    }

    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(){
  int day, work, i, sum=0, fun;
  int *d;
  
  d=(int *)malloc(sizeof(int)*work);
  
  scanf("%d %d", &day, &work);
  
  for(i=0;i<work;i++){
  	scanf("%d", d);
    sum+=*d;
    d++;
  }
  
  fun=day-sum;
  if(fun<0){
  	printf("-1\n");
  }
  else{
  	printf("%d", fun);
  }
  
  return 0;
}


Measured memory_bytes: 1776
#include<iostream>
#include<string>
#include<complex>
#include<vector>
#include<algorithm>
#include<functional>
#include<array>
#include<map>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define INF 1e+9


int main() {
	string s;
	ull k,p;
	cin >> s;
	cin >> k;
	p = 0;
	char ans;
	for (ull i = 0; i < s.length(); i++) {
		if (s[i] != '1') { ans = s[i]; p = i + 1; break; }
	}
	if (k < p||p==0) cout << 1 << endl;
	else cout << ans << endl;

	return 0;
}

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int n;cin>>n;
    int max=0,x=0;

    rep(i,n){
        int a,b;cin>>a>>b;
        if(a>max){
            max=a;x=b;
        }
    }
    cout<<max+x<<endl;

}


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

int main()
{
  string s;
  cin>>s;
  for(int i=0;i<3;i++)
  {
    if(s.at(i)=='1')
      s.at(i)='9';
    else
      s.at(i)='1';
  }
  cout<<s<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define INF 10000000000
#define PI 3.141592653589793

int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double l_deg, l_rad, s_deg, s_rad, lx, ly, sx, sy, ans;

	l_deg = 30 * h + 0.5 * m;
	l_rad = l_deg*(PI/180);
	s_deg = 6 * m;
	s_rad = s_deg*(PI/180);
	
	lx = a * cos(l_rad);
	ly = a * sin(l_rad);
	sx = b * cos(s_rad);
	sy = b * sin(s_rad);

	ans = sqrt((lx-sx) * (lx-sx) + (ly-sy) * (ly-sy));

	cout << fixed << setprecision(15) << ans;
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 100000000000000000

int beki(int a,int b){
	int x = 1;
	while(b!=0){
		if(b&1){
			x=mod(x*a);
		}
		a=mod(a*a);
		b>>=1;
	}
	return x;
}

template <typename T>
struct BIT{
	vector<T> v;
	int n;
	
	const T init_value = 0;
	
	BIT(int sz){
		n=sz+1;
		v.resize(n,init_value);
	}
	
	BIT(vector<T> &x){
		n=x.size()+1;
		v.resize(n,init_value);
		
		for(int i=0;i<x.size();i++){
			add(i,x[i]);
		}
		
	}

	void add(int x,T val){
		x++;
		while(x < n){
			v[x] = func(v[x],val);
			x += x & (-x);
		}
	}
	
	//区間[0,r)におけるクエリ処理
	T query(int r){
		T ret = init_value;
		r++;
		
		while(r>0){
			ret = func(v[r],ret);
			r -= r & (-r);
		}
		
		return ret;
	}
	
	T query(int l,int r){
		return mod(query(r-1) - query(l-1));
	}
	
	T func(T a,T b){
		return mod(a+b);
	}
	
};

int main(){
	int N;
	cin>>N;
	map<int,int> mp;
	vector<pair<long long,long long>> V(N);
	for(int i=0;i<N;i++){
		cin>>V[i].first>>V[i].second;
		mp[V[i].second]=-1;
	}
	
	sort(V.begin(),V.end());
	
	int cnt = 0;
	for(auto &a:mp){
		a.second=cnt;
		cnt++;
	}
	
	vector<int> x(N,0);
	BIT<int> S1(x);
	for(int i=0;i<N;i++)x[i]=1;
	BIT<int> S2(x);
	
	int ans = mod(beki(2,N)*N);
	for(int i=0;i<N;i++){
		
		S2.add(mp[V[i].second],-1);
		
		int RU = S2.query(mp[V[i].second],N);
		int RD = S2.query(0,mp[V[i].second]);
		int LU = S1.query(mp[V[i].second],N);
		int LD = S1.query(0,mp[V[i].second]);
		
		ans = mod(ans - beki(2,RU+RD));
		ans = mod(ans - beki(2,RU+LU));
		ans = mod(ans - beki(2,LU+LD));
		ans = mod(ans - beki(2,RD+LD));
		
		ans = mod(ans + beki(2,RU));
		ans = mod(ans + beki(2,RD));
		ans = mod(ans + beki(2,LU));
		ans = mod(ans + beki(2,LD));
		
		S1.add(mp[V[i].second],1);
		
		ans = mod(ans-1);
		
	}
	if(N==1)ans = 1;
	cout<<ans<<endl;
	
	
	return 0;
}




Measured memory_bytes: 15104
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [input().split() for _ in range(M)]
ans_list = [1] * (N)

for i in range(M):
    if H[int(AB[i][0]) - 1] > H[int(AB[i][1]) - 1]:
        ans_list[int(AB[i][1]) - 1] = 0
    elif H[int(AB[i][0]) - 1] < H[int(AB[i][1]) - 1]:
        ans_list[int(AB[i][0]) - 1] = 0
    elif H[int(AB[i][0]) - 1] == H[int(AB[i][1]) - 1]:
        ans_list[int(AB[i][0]) - 1] = 0
        ans_list[int(AB[i][1]) - 1] = 0

print(sum(ans_list))


Measured memory_bytes: 43008
#include <iostream>
#include <vector>
#include <memory>
#include <cmath>
#include <algorithm>
std::vector<int> PRIMES;
void init_primes(int max)
{
  if (max < 2) return;
  std::unique_ptr<bool[]> is_prime(new bool[max + 1]);
  for (int i = 3;i <= max; i+=2) {
    is_prime[(i - 1) / 2] = true;
  }
  is_prime[0] = false;
  for (int i = 3; i < std::sqrt(max); i+=2) {
    if (is_prime[(i - 1) / 2] == true) {
      int not_prime = i + i;
      while (not_prime <= max) {
        if (not_prime % 2) is_prime[(not_prime - 1) / 2] = false;
        not_prime += i;
      }
    }
  }
  PRIMES.push_back(2);
  for (int i = 3; i <= max; i+= 2) {
    if (is_prime[(i - 1) / 2]) PRIMES.push_back(i);
  }
}

int main() {
  const unsigned int max = std::pow(2, 15);
  init_primes(max);
  int n;
  while (std::cin >> n) {
    if (n == 0) break;
    int count = 0;
    for (auto it = PRIMES.cbegin(); it != PRIMES.cend(); ++it) {
      if (*it > n / 2) break;
      if (*it == n - *it ||
          std::find(PRIMES.cbegin(), PRIMES.cend(), n - *it) != PRIMES.cend()) count++;
    }
    std::cout << count << std::endl;
  }
}

Measured memory_bytes: 1272
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

template <typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template <long long MOD = 1000000007LL>
long long powmod(long long x, long long n) {
    long long ret = 1LL;
    long long t = x % MOD;
    while (n > 0) {
        if (n & 1LL) {
            ret *= t;
            ret %= MOD;
        }
        t *= t;
        t %= MOD;
        n >>= 1;
    }
    return ret;
}

inline vector<pair<long long, long long>> factorize(const long long n) {
    vector<pair<long long, long long>> factors;
    long long i = 2;
    long long j = n;
    while (i * i <= n && j != 1) {
        long long cnt = 0;
        while (j % i == 0) {
            ++cnt;
            j /= i;
        }
        if (cnt > 0)
            factors.push_back(make_pair(i, cnt));
        ++i;
    }
    if (j > 1)
        factors.push_back(make_pair(j, 1));
    return factors;
}

constexpr ll mod = inf;

int main() {
    int n; cin >> n;
    vector<ll> a(n), b(1000001);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        auto fact = factorize(a[i]);
        for (auto f : fact) {
            b[f.first]  = max(b[f.first], f.second);
        }
    }
    ll lcm = 1;
    for (int i = 2; i <= 1000000; ++i) {
        lcm *= powmod(i, b[i]);
        lcm %= mod;
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ans += lcm * powmod(a[i], mod - 2LL) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8192
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
int dy[8]={-1,-1,0,1,1,1,0,-1};
int dx[8]={0,1,1,1,0,-1,-1,-1};
char t[20][20];
map<string,int> u;
int h,w;
bool visited[20][20];

void func(int y,int x,int d){
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      visited[i][j]=false;
  string str="";
  while(!visited[y][x]){
    visited[y][x]=true;
    str.push_back(t[y][x]);
    u[str]++;
    int ny=y+dy[d],nx=x+dx[d];
    if(ny<0)ny=h-1;
    if(ny>=h)ny=0;
    if(nx<0)nx=w-1;
    if(nx>=w)nx=0;
    y=ny;x=nx;
  }
}

int main(){
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    u.clear();
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	cin>>t[i][j];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<8;k++)
	  func(i,j,k);
    string ans="";
    map<string,int> :: iterator it;
    for(it=u.begin();it!=u.end();it++){
      if(it->second<2)continue;
      if(it->first.size()>ans.size())ans=it->first;
      else if(it->first.size()==ans.size()&&it->first<ans)ans=it->first;
    }
    if((int)ans.size()<2)cout<<0<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 36032
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect
import re


ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))



def main():

    n,k = map(int,input().split())
    h = list(map(int,input().split()))

    cnt = 0

    for i in h:
        if i >= k:
            cnt+=1

    print(cnt)




main()


Measured memory_bytes: 21912
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;


template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
    arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
    for (auto& i : arr) {
        fill_all(i, v);
    }
}
std::string N;
int dp[2000000][2];
int func(int i, bool over) {
    if (i == N.size()) {
        return over ? 20000000 : 0;
    }
    auto& memo = dp[i][over ? 1 : 0];
    if (memo != -1) {
        return memo;
    }

    const auto ni = N[i] - '0';
    memo = 20000000;
    if (over) {
        for (int c = 0; c < 10; c++)
        {
            if (ni <= c) { break; }
            memo = std::min(memo, c + (10 - ni + c) + func(i + 1, false));
            memo = std::min(memo, c + (10 - ni + c - 1) + func(i + 1, true));
        }
    }
    else {
        int c = ni;
        memo = std::min(memo, c + 0 + func(i + 1, false));
        c = ni+1;
        memo = std::min(memo, c + 0 + func(i + 1, true));
    }
    return memo;
}


int main()
{
    using std::endl;
    in.sync_with_stdio(false);
    out.sync_with_stdio(false);
    in.tie(nullptr);
    out.tie(nullptr);
    fill_all(dp, -1);
    in >> N;
    N = "0" + N;
    out << func(0, false) << endl;

    return 0;
}
#endif


Measured memory_bytes: 63904
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int mx,n,i,cnt[3];
char s[100005];
int main()
{
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)cnt[s[i]-'a']++;
	mx=max(cnt[0],max(cnt[1],cnt[2]));
	if(min(cnt[0],min(cnt[1],cnt[2]))>=mx-1)printf("YES\n");
	else printf("NO\n");
	return 0;
} 

Measured memory_bytes: 256