akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;
int main() {
  double w;
  while(~scanf("%lf", &w)) {
	if(w <= 48.00) puts("light fly");
	else if(w <= 51.00) puts("fly");
	else if(w <= 54.00) puts("bantam");
	else if(w <= 57.00) puts("feather");
	else if(w <= 60.00) puts("light");
	else if(w <= 64.00) puts("light welter");
	else if(w <= 69.00) puts("welter");
	else if(w <= 75.00) puts("light middle");
	else if(w <= 81.00) puts("middle");
	else if(w <= 91.00) puts("light heavy");
	else puts("heavy");
  }
  return 0;
}

Measured memory_bytes: 2624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using ll = unsigned long long;
using namespace std;

int main(void) {
    int x,a;
    cin >> x >> a;
    if (x<a) {
        cout << 0 << endl;
    } else if(x >= a) {
        cout << 10 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;

int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll n;
 	cin>>n;
 	ll boss[n+1]={0};
 	for(ll i=2;i<=n;i++)
 	{
 		ll x;
 		cin>>x;
 		boss[x]++;
 	}
 	for(ll i=1;i<=n;i++)
 	{
 		cout<<boss[i]<<endl;
 	}
    return 0;
}

Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

using P = Pa<ll,ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    map<P,ll> mp;
    ll zero = 0;;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >> b;
        if(a==0 && b==0){
            zero++;
        }else if(a==0){
            mp[{0,1}]++;
        }else if(b==0){
            mp[{1,0}]++;
        }else{
            ll g = gcd(abs(a),abs(b));
            a /= g,b /= g;
            if(a<0){
                a *= -1;
                b *= -1;
            }
            mp[{a,b}]++;
        }
    }
    mint res = 1;
    set<P> s;
    for(auto p:mp){
        auto [a,b] = p.first;
        if(s.count(p.first)) continue;
        ll c = -b,d = a;
        if(c<0){
            c *= -1;
            d *= -1;
        }
        if(mp.count({c,d})){
            res *= (mint (2)).pow(p.second)+(mint (2)).pow(mp[{c,d}])-1;
            s.insert({c,d});
        }else{
            res *= (mint (2)).pow(p.second);
        }
    }
    res += zero;
    cout << res-1 << "\n";
}

Measured memory_bytes: 15932
par = [i for i in range(100)]
rank = [0 for i in range(100)]
weight_to_root = [0 for i in range(100)]

def find(x):
    if par[x] == x:
        return x
    else:
        root = find(par[x])
        weight_to_root[x] += weight_to_root[par[x]]
        par[x] = root
        return root

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

def union(x,y,w):
    a = find(x)
    b = find(y)
    if a==b:
        return False
    if rank[a] > rank[b]:
        par[b] = a
        weight_to_root[b] = -w - weight_to_root[y] + weight_to_root[x]
    elif rank[a] < rank[b]:
        par[a] = b
        weight_to_root[a] = w - weight_to_root[x] + weight_to_root[y]
    else:
        par[b] = a
        weight_to_root[b] = -w - weight_to_root[y] + weight_to_root[x]
        rank[a] += 1
    return True

def diff(x,y):
    return weight_to_root[x] - weight_to_root[y]


def main():
    global rank,par,weight_to_root
    n,q = [int(i) for i in input().split()]
    rank = [0 for i in range(n)]
    par = [i for i in range(n)]
    weight_to_root = [0 for i in range(n)]
    for i in range(q):
        s = [int(j) for j in input().split()]
        if s[0] == 0:
            union(s[1],s[2],s[3])
        else:
            if is_same(s[1],s[2]):
                print(diff(s[1],s[2]))
            else:
                print('?')

if __name__ == '__main__':
    main()


Measured memory_bytes: 12104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <bits/stdc++.h>
#include <array>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int main(int argc, const char * argv[]) {
    // source code
    int N;
    cin >> N;
    string s;
    cin >> s;
    int len = s.size();
    if (N % 2 == 1) {
        cout << "No";
        return 0;
    }
    string  s1 = s.substr(0, len/2);
    if (s1 + s1 == s) cout << "Yes";
    else cout << "No";
    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 100005

using namespace std;
typedef long long int ll;

int A[SIZE];
int X[SIZE],T[SIZE];
bool use[SIZE];
int nd[SIZE];

int main()
{
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&A[i]);
	for(int i=0;i<n-1;i++) X[i]=i;
	int m;
	ll K;
	scanf("%d %lld",&m,&K);
	for(int i=0;i<m;i++)
	{
		int a;
		scanf("%d",&a);a--;
		swap(X[a-1],X[a]);
	}
	for(int i=0;i<n-1;i++)
	{
		if(!use[i])
		{
			int now=i;
			int len=0;
			do
			{
				use[now]=true;
				nd[len++]=now;
				now=X[now];
			}while(now!=i);
			for(int j=0;j<len;j++)
			{
				int to=(int) (K%len);
				to=nd[(j+to)%len];
				T[nd[j]]=to;
			}
		}
	}
	ll sum=A[0];
	for(int i=0;i<n;i++)
	{
		printf("%lld\n",sum);
		int pos=T[i];
		sum+=A[pos+1]-A[pos];
	}
	return 0;
}


Measured memory_bytes: 2816
from collections import deque
N, M = map(int, input().split())
route = [[] for _ in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  route[A-1].append(B-1)
  route[B-1].append(A-1)
ans = [-1]*(N)

def bfs():
  tmp = 0
  prv = 0
  visited = [False]*N
  kouho = deque()


  for room in route[0]:
    kouho.append([room,0])
  while True:
    visited[tmp] = True
    ans[tmp] = prv
    for room in route[tmp]:
      if not visited[room]:
        kouho.append([room,tmp])
    if len(kouho) == 0:
      return
    while True:
      tmp_ = kouho.popleft()
      tmp = tmp_[0]
      prv = tmp_[1]
      if not visited[tmp]:
        break
      if len(kouho) == 0:
        return
bfs()
print("Yes")
for n in range(1,N):
  print(ans[n]+1)
  



Measured memory_bytes: 118880
# 1: top, 2: front, 3: right,
# 4: left, 5: back, 6: bottom

class Dice:
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, direction):
        if direction == 'E':
            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right
            return

        if direction == 'N':
            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back
            return

        if direction == 'S':
            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front
            return

        if direction == 'W':
            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left
            return

    def get_top(self):
        return self.top

if __name__ == '__main__':
    nums = [int(i) for i in input().split()]
    directions = input()

    d = Dice(nums)
    for ch in directions:
        d.roll(ch)

    print(d.get_top())

Measured memory_bytes: 6736
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
#include<stdio.h>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}

int main(){
    double A,T;
    int B;
    cin >> A >> B >> T;
    double time=T+0.5;
    int num=0;
    while(time-A>=0){
        num+=B;
        time-=A;
    }
    cout << num;
    }

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

int main(){
	int a[5],i;
	for(i=0;i<5;i++){
		cin >> a[i];
	}
  sort(a,a+5,greater<int>()); 
	for(i=0;i<5;i++){
		cout << a[i];
		if(i<4)cout << ' ';
		else cout << endl;
	}
  return 0;
}

Measured memory_bytes: 0
N = int(input())
values = list(map(int, input().strip().split()))
total = 0
values.sort()
step = 0
#print(values)
while len(values) > 1:
    new = (values[step] + values[step + 1]) / 2
    del values[0]
    del values[0]
    values = [new] + values
    #print(values)
print(values[0])

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=100001;
	int N;
	cin>>N;
	int num=1;
	int A[MAX]={};
	for(int i=0;i<N;i++){
		cin>>A[i];
	}
	int flag=0;
	for(int i=1;i<N;i++){
		//cout<<A[i]<<" "<<num<<" "<<flag<<endl;
		if(A[i]==A[i-1]){

		}
		else if(A[i]<A[i-1]){
			if(flag==0){
				flag=1;
			}
			else if(flag==1);
			else if(flag==2){
				flag=0;
				num++;
			}
		}
		else if(A[i]>A[i-1]){
			if(flag==0){
				flag=2;
			}
			else if(flag==1){
				flag=0;
				num++;
			}
			else if(flag==2);
		}
	}
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
struct pt{
  int x,y,n;
};
vector<pt> dirs = { {0,1,1}, {0,-1,1}, {1,0,1}, {-1,0,1} };
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int h,w,nb = 0;
  cin >> h >> w;
  vector<string> vs(h);
  queue<pt> q;
  for(int i = 0; i < h; ++i){
    cin >> vs[i];
    for(int j = 0; j < w; ++j){
      if(vs[i][j] == '#'){
        vs[i][j] = true;
        q.emplace(pt{i,j,0});
      }
    }
  }
  while(!q.empty()){
    auto p = q.front();
    q.pop();
    for(auto& d : dirs){
      int x=p.x+d.x,y=p.y+d.y,n=p.n+d.n;
      if(0 <= x and x < h and 0 <= y and y < w){
        if(vs[x][y] == '.'){
          vs[x][y] = '#';
          nb = max(nb,n);
          q.emplace(pt{x,y,n});
        }
      }
    }
  }
  cout << nb;
  return 0;
}

Measured memory_bytes: 13456
import itertools
N = int(input())
S = [int(_) for _ in input()]
cum = [[0] * (N + 1) for _ in range(10)]
mina = [10**10] * 10
maxa = [-10**10] * 10
for i, s in enumerate(S):
    cum[s][i + 1] = 1
    mina[s] = min(mina[s], i)
    maxa[s] = max(maxa[s], i)
for i in range(10):
    cum[i] = list(itertools.accumulate(cum[i]))
ans = 0
for l, r in itertools.product(range(10), range(10)):
    if mina[l] + 1 < maxa[r]:
        il, ir = mina[l], maxa[r]
        for m in range(10):
            ans += cum[m][ir] - cum[m][il + 1] > 0
print(ans)


Measured memory_bytes: 54636
#include <iostream>
#include <string>
using namespace std;
string title[101];
string aut[101];
int era[101];

int henkan(string a) {
  int c = 0;
  int sum = 0;
  int cnt =0;
  for(int i=0;i<a.size();i++) {
    if(a[i] == '/') continue;
    c *= 10;
    c += a[i]-'0';
  }
  sum = c;
  return sum;
}

int check(string a,string b) {
  if(a.size() > b.size()) return 1;
  else 
    for(int j=0;j<b.size();j++) {
      if(a[0] == b[j] && a.size() <= b.size()-j) {
	int cnt = 1;
	for(int k=1;k<a.size();k++)
	  if(a[k] == b[j+k])cnt++;
	if(cnt == a.size()) return 0;
      }
    }
  return 1;
}

int main() {

  int n;
  cin >>n;
  for(int i=0;i<n;i++) {
    string a;
    cin >> title[i] >> aut[i] >> a;
    era[i] = henkan(a);
  }


  int m;
  cin >> m;
  for(int i=0;i<m;i++) {
    string t,a,ef,et;
    cin >> t >> a >>ef >>et;
    int ief = henkan(ef),iet = henkan(et);
    if(ef == "*") ief = 0;
    if(et == "*") iet = 1000000000;

    if(i != 0) cout << endl;
    int flg[101] = {};
    for(int j=0;j<n;j++) {
      if(t != "*") flg[j] = check(t,title[j]);
      if(a != "*") if(check(a,aut[j]) == 1) flg[j] = 1;
      //  cout << flg[i] <<endl;
      if(!(ief<=era[j] &&  era[j] <= iet)) flg[j] = 1;  
      if(flg[j] == 0) cout << title[j] <<endl;
    }
  
  
  }

  return 0;
  
} 

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

const int INF = 2*1e9;

int main(){
	
	int n;
	cin >> n;
	
	int arr[n];
	for(int i=0; i<n; i++){
		cin >> arr[i];
	}
	
	
	int dp[n+1]={};
	
	for(int i=2; i<=n; i++){
		
		dp[i] = INF;
		
		for(int j = i-1; j>=max(1,i-2); j-- ){
			
			dp[i] = min( dp[i] , dp[j] + abs(arr[i-1] - arr[j-1]) );
			
		}
//		cout<<dp[i]<<endl;
	}
	cout<<dp[n]<<endl;
}

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

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class ModTools:
    """ 階乗たくさん使う時用のテーブル準備 """

    def __init__(self, MAX, MOD):
        """ MAX：階乗に使う数値の最大以上まで作る """
        
        MAX += 1
        self.MAX = MAX
        self.MOD = MOD
        # 階乗テーブル
        factorial = [1] * MAX
        factorial[0] = factorial[1] = 1
        for i in range(2, MAX):
            factorial[i] = factorial[i-1] * i % MOD
        # 階乗の逆元テーブル
        inverse = [1] * MAX
        # powに第三引数入れると冪乗のmod付計算を高速にやってくれる
        inverse[MAX-1] = pow(factorial[MAX-1], MOD-2, MOD)
        for i in range(MAX-2, 0, -1):
            # 最後から戻っていくこのループならMAX回powするより処理が速い
            inverse[i] = inverse[i+1] * (i+1) % MOD
        self.fact = factorial
        self.inv = inverse
    
    def nCr(self, n, r):
        """ 組み合わせの数 (必要な階乗と逆元のテーブルを事前に作っておく) """

        if n < r: return 0
        # 10C7 = 10C3
        r = min(r, n-r)
        # 分子の計算
        numerator = self.fact[n]
        # 分母の計算
        denominator = self.inv[r] * self.inv[n-r] % self.MOD
        return numerator * denominator % self.MOD

N = INT()
A = LIST()

# 重複している値を見つけて、indexを取る
dup = 0
for k, v in Counter(A).items():
    if v == 2:
        dup = k
        break
st = []
for i, a in enumerate(A):
    if a == dup:
        st.append(i)
# 重複した値より外側にある要素数
M = N - (st[1] - st[0])

mt = ModTools(N+1, MOD)
for i in range(N+1):
    # 全組み合わせから、重複した値の影響を受ける分を引く
    ans = mt.nCr(N+1, i+1) - mt.nCr(M, i)
    print(ans % MOD)


Measured memory_bytes: 19916
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    vector<string> v = {"Sunny", "Cloudy", "Rainy"};

    string s; cin >> s;

    int i = find(v.begin(), v.end(), s) - v.begin();

    cout << v[(i + 1) % 3] << endl;

    return 0;
}


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

int main(){
    int v,s;
    while(1){
        cin>>v>>s;
        if(v==0&&s==0) break;
        for(int i=0;i<v;i++){
            for(int j=0;j<s;j++){
                if(i==0||i==v-1||j==0||j==s-1){
                    cout<<'#';
                }else{
                    cout<<'.';
                }
            }
            cout<<'\n';
        }
        cout<<'\n';
    }
}


Measured memory_bytes: 2992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N; string S; cin >> N >> S;
	int x = 0;
	int ans = 0;
	for (int i = 0; i < N;i++) {
		if (S[i] == 'I') {
			ans = max(ans, ++x);
		}
		else {
			x--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;
ll n, x[N];
ll mi = 1e9;
int main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; i++)
	scanf("%lld", &x[i]);
	for (int i = 1; i <= 100; i++)
	{
		ll sum = 0;
		for (int j = 1; j <= n; j++)
		sum += (x[j] - i) * (x[j] - i);
		mi = min(mi, sum);
	}
	printf("%lld\n", mi);
}


Measured memory_bytes: 256
/*  ex6_2
    pptenshi */

#include<stdio.h>
#include<string.h>
#define LIMIT 110

int main(void) {
    char string[LIMIT];
    int len_str;

    //input
    scanf("%s", string);
  
    len_str = strlen(string);

    //output
    printf("%c%d%c\n", string[0], len_str - 2, string[len_str - 1]);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define MOD 1000000007
#define f(i,a,n) for(lli i = a; i < n; i++)
#define fb(i,a,n) for(lli i=n-1;i>=a;i--)
 
#define p64 pair<lli,lli>
#define v64 vector<lli>
#define p32 pair<int,int>
#define v32 vector<int>
#define vp64 vector<pair<lli , lli >>
#define vp32 vector<pair<int , int>>
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--){
        lli h,n; cin>>h>>n;
        pair<lli,lli>arr[n];
 
        for(lli i=0;i<n;i++){
            lli a,b; cin>>a>>b;
            arr[i]=mp(a,b);
        }

        lli foreachheight[h+1];
        mem(foreachheight,MOD);
        foreachheight[0]=0;
        for(lli i=0;i<=h;i++){
            for(lli j=0;j<n;j++){
                if(i+arr[j].first<h){
                    foreachheight[arr[j].first+i]=min(foreachheight[arr[j].first+i],foreachheight[i]+arr[j].second);
                }
                else
                {
                    foreachheight[h]=min(foreachheight[h],foreachheight[i]+arr[j].second);
                }
                
            }
        }
        cout<<foreachheight[h]<<endl;

        




}
return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
int b[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,ans=0;
    cin>>n;
    for(int i=0;i<n-1;i++) cin>>b[i];
    ans=b[0];
    for(int i=1;i<n-1;i++) ans+=min(b[i],b[i-1]);
    ans+=b[n-2];
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
 
int main(){
  int N,X,T;
  cin>>N>>X>>T;
  if(N%X==0){
    cout<<N/X*T<<endl;
  }
  if(N%X!=0){
    cout<<(N/X+1)*T<<endl;
  }
}

Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		var tmp int
		_, _ = fmt.Scan(&tmp)
		arr[i] = tmp
	}
	count := 0
	for {
		sum := 0
		flg := false
		for i := 0; i < n; i++ {
			if arr[i] > 0 {
				arr[i]--
				if !flg {
					count++
				}
				flg = true
			} else {
				flg = false
			}
			sum += arr[i]
		}
		if sum == 0 {
			break
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 1e18;

ll mpow(ll a, ll b) {
    ll res = 1;
    a %= mod;
    while (b) {
        if (b & 1) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}
#define N 200010
int fac[N], finv[N];
void factorization() {
    fac[0] = finv[0] = 1;
    rep(i, 1, N)fac[i] = 1LL * fac[i - 1] * i % mod;
    finv[N - 1] = mpow(fac[N - 1], mod - 2);
    for (int i = N - 2; i; --i) finv[i] = 1LL * finv[i + 1] * (i + 1) % mod;
}
int nCr(int n, int m) {
    if (m < 0 || n < m) return 0;
    return 1LL * (1LL * fac[n] * finv[m] % mod) * finv[n - m] % mod;
}


int main() {
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	factorization();
	ll ans=0;
	rep(i,b,w+1){
		ans=(ans+1LL*nCr(h-a-1+i,i)*nCr(a-1+w-1-i,w-1-i))%mod;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;

int main() {
    int a, b, c; cin >> a >> b >> c;
    if(a != b && b != c && c != a) cout << "No" << endl;
    else if(a == b && b == c) cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

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

  string s; cin >> s;
  bool flag = true;

  if(s[0]!='A') flag = false;
  if(count(s.begin()+2, s.end()-1, 'C')!= 1) flag = false;
  int cnt = 0;
  rep(i, s.length()) {
    if(s[i] < 'a') ++cnt;
    if(cnt > 2) flag = false;
  }

  cout << (flag ? "AC" : "WA") << '\n';
  return 0;
}


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

const int INF = 1001001001;

int main() {
  int N, W;
  cin>>N>>W;
  int64_t w[N+1], v[N+1], dp[N+1][W+1];
  w[0]=0;
  v[0]=0;
  for(int i=1;i<=N;i++){
    cin>>w[i]>>v[i];
  }
  for(int i=0; i<=N; i++){
    for(int j=0;j<=W;j++){
      dp[i][j]=0;
    }
  }
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
      if(j>=w[i]){
        dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
      }
      else{
        dp[i][j]=dp[i-1][j];
      }
    }
  }
  cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
    if(a>b){
    long long temp=a;
    a=b;
    b=temp;
}
long long r=b%a;   //rは30 b=90 a=60
//aとrのgcd
while(r!=0){
    b=a;   //b60
    a=r;   //a30
    r=b%a;  //r0
}
return a;
}

int main(){
//srandom((unsigned long)time(NULL));

long long x,y;
cin>>x>>y;
cout<<gcd(x,y)<<endl;

return 0;
}




Measured memory_bytes: 3116
let () =
  let (n, k) = Scanf.scanf "%d %d " (fun n k -> (n, k)) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let check p =
    let rec doit i j s =
      if i = n then n
      else if j >= k then i
      else
        let x = s + a.(i) in
        if x > p then doit i (j + 1) 0
        else doit (i + 1) j x
    in
    doit 0 0 0
  in
  let rec bin_search l r =
    if r < l then l
    else
      let m = (l + r) / 2 in
      if check m >= n then bin_search l (m - 1)
      else bin_search (m + 1) r
  in
  Printf.printf "%d\n" (bin_search 0 (100000 * 10000))

Measured memory_bytes: 5332
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define long long int ll
#define endl '\n'


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


const int MOD = 1000000007;

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<double> v(n);



  for(int i = 0; i < n; i++) {

    cin >> v.at(i);
  }

  sort(v.begin(), v.end());

  double in = (v[0] + v[1]) / 2;


  for(int i = 2; i < n; i++) {

       in  = (v[i] + in) / 2;

  }

  cout << in << endl;


}



Measured memory_bytes: 256
from collections import defaultdict
n=int(input())

d=defaultdict(int)
for i in range(n):
    a,b =map(int,input().split())
    d[b]+=a

d_sorted=sorted(d.items(), key=lambda x: x[0])

time=0
finished=True
for i in range(len(d_sorted)):
    time+=d_sorted[i][1]
    if time>d_sorted[i][0]:
        finished=False
        break

if finished:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 48016
n=int(input())
a=[]
x=str(input())
a.append(x)
d=bool(True)

for i in range(1, n):
  y=str(input())
  if x[len(x)-1]!=y[0]:
    d=False
    
  for j in range(len(a)):
    if y==a[j]:
      d=False
  a.append(y)
  x=y

if  d==True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define M 1000005
#define FI first
#define SE second
#define MP std::make_pair
#define PB push_back
#define INF 1000000000
typedef long long ll;
int n, A[M], B[M], X[M], Y[M], cnt[M];
std::mt19937_64 rnd(std::chrono::steady_clock::now().time_since_epoch().count());
int read() {
	int ans = 0; char c = getchar();
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return ans;
}
void Write(int x) {
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
	return;
}
int Random(int l, int r) {return rnd() % (r - l + 1) + l;}
void work() {
	for (int i = 1; i <= n; i++) cnt[i] = 0;
	for (int i = 1; i <= n; i++) cnt[A[i]]++, cnt[B[i]]++;
	for (int i = 1; i <= n; i++)
		if (cnt[i] > n) return puts("No"), void();
	puts("Yes");
	std::reverse(B + 1, B + 1 + n); *X = *Y = 0;
	for (int i = 1; i <= n; i++)
		if (A[i] == B[i]) X[++*X] = i;
	for (int i = 1; i <= n; i++)
		if (!*X || (A[i] != A[X[1]] && B[i] != A[X[1]])) Y[++*Y] = i;
	assert(*X <= *Y);
	while (*X) std::swap(B[X[*X]], B[Y[*Y]]), --*X, --*Y;
	for (int i = 1; i <= n; i++) assert(A[i] != B[i]);
	for (int i = 1; i <= n; i++) Write(B[i]), putchar(' ');
	return putchar('\n'), void();
}
int main() {
	n = read();
	for (int i = 1; i <= n; i++) A[i] = read();
	for (int i = 1; i <= n; i++) B[i] = read();
	return work(), 0;
}


Measured memory_bytes: 6768
n = int(input())
x_list = []
y_list = []
h_list = []

for i in range(n):
    a, b, c = map(int, input().split())
    x_list.append(a)
    y_list.append(b)
    h_list.append(c)

k = h_list.index(max(h_list))

for x in range(101):
    for y in range(101):
        h_max = h_list[k] + abs(x_list[k] - x) + abs(y_list[k] - y)
        
        for j in range(n):
            if h_list[j] == 0 :
                if h_max - (abs(x_list[j] - x) + abs(y_list[j] - y)) > 0 :
                    h_max = -1
            else:
                if h_max != abs(x_list[j] - x) + abs(y_list[j] - y) + h_list[j]:
                    h_max = -1
        
        if h_max != -1:
            print(str(x)+' '+str(y)+ ' '+ str(h_max))
            break


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

#define pb push_back
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define MAXN 10005
#define MAXM 100005
#define pi 3.14159265359

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vpii;
typedef long long ll;
typedef priority_queue<int> pqi;
typedef priority_queue<pii, vpii, greater<pii> > dij;

int N;

bool prime(int x){
	if(x == 1) 
		return false;
	
	for(int i = 2; i*i < x; i++){
		if(x % i == 0){
			return false;
		}
	}

	return true;
}

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

	while(true){
		if(prime(N)){
			cout << N << "\n";
			return 0;
		}
		N++;
	}

	return 0;		
}

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)
#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

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

    vector<vector<p_i>> next_point(n, vector<p_i>());
    int from;
    int to;
    int weight;

    rep(i, n - 1)
    {
        cin >> from >> to >> weight;
        weight %= 2;
        next_point[from - 1].push_back(p_i(to - 1, weight));
        next_point[to - 1].push_back(p_i(from - 1, weight));
    }

    vector<int> color(n, -1);
    color[0] = 0;

    queue<int> que;
    que.push(0);

    int current;
    while (que.size() > 0)
    {
        current = que.front();
        que.pop();
        for (auto point : next_point[current])
        {
            if (color[point.first] == -1)
            {
                que.push(point.first);
                color[point.first] = color[current] ^ point.second;
            }
        }
    }

    rep(i, n)
    {
        cout << color[i] << endl;
    }

    return 0;
}

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

using namespace std;
const int N = 1e5 + 10;

int n, t;
int a[N];
int mx[N];

int main()
{
	cin >> n >> t;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
	}
	mx[n] = a[n];
	for (int i = n - 1; i >= 1; i--) mx[i] = max(mx[i + 1], a[i]);
	
	int x = 0;
	for (int i = 1; i < n; i++) x = max(x, mx[i + 1] - a[i]);
	
	int ans = 0;
	for (int i = 1; i < n; i++) if (mx[i + 1] - a[i] == x) ans++;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a_list = [int(x) for x in input().split()]
b = []
c = []
for i, a in enumerate(a_list):
    if i % 2 == 0:
        b.append(a)
    else:
        c.append(a)
if n % 2 == 0:
    d = list(reversed(c)) + b
else:
    d = list(reversed(b)) + c
print(*d)

Measured memory_bytes: 30900
using System;

namespace ABC105_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = "No";

            for (int i = 0; i * 4 <= 100; i++)
            {
                for (int j = 0; j * 7 < 100; j++)
                {
                    if (i * 4 + j * 7 == N)
                    {
                        r = "Yes";
                    }
                }
            }
            Console.WriteLine(r);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define FOR(i,a,b) for(i=a;i<=b;i++)
#define RFOR(i,a,b) for(i=a;i>=b;i++)
typedef long long ll;
using namespace std;
int main()
{
ll i,n;
cin>>n;
ll a[n],p[n];
FOR(i,0,n-1)
cin>>a[i];
p[0]=a[0];
FOR(i,1,n-1)
p[i]=p[i-1]+a[i];
ll tt=p[n-1];

ll mini=INT_MAX;
FOR(i,0,n-2)
mini=min(abs(2*p[i]-tt),mini);
cout<<mini;
return 0;
}

Measured memory_bytes: 3328
n,m=map(int,input().split())
cnt = [0]*n
total = [0]*n
for i in range(m):
    P=list(input().split())
    p = int(P[0]) - 1
    if P[1] == 'WA' and cnt[p] == 0:
        total[p] += 1
    if P[1] == 'AC' and cnt[p] == 0:
        cnt[p] = True
ans = 0
for i in range(n):
    if cnt[i] == True:
        ans += total[i]
print(sum(cnt),ans)

Measured memory_bytes: 10316
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int maxpri = 10000;
		
		int[] pri = new int[maxpri + 10000];
		for(int i=2;i<=maxpri;i++){
			pri[i] = i;
		}
		for(int i=2;i<=maxpri;i++){
			for(int j=i+i;j<=maxpri;j+=i){
					pri[j]=0;
			}
		}

		while(sc.hasNext()){
			int n = sc.nextInt();
			int count=0;
			for(int i=2;i<n;i++){
				if(pri[i]>0 && pri[n+1-i]>0) count++;
			}
			System.out.println(count);
		}
	}
	
}

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

#define Max 100000

int main(){
	bool visit[Max];
	int cou[Max];
	int n,m;
	cin>>n>>m;
	for(int i=0;i<=n;i++){
		cou[i]=1;
		visit[i]=false;
	}
	visit[1]=true;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(visit[x]==true){
			visit[y]=true;
		}
		cou[x]--;
		cou[y]++;
		if(cou[x]==0){
			visit[x]=false;
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(visit[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <string.h>

#define MOD 1000000007

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

int N;
char K[10002];
int D;
mint dp[10001][2][100];

int main() {
    scanf("%s %d", K, &D);
    N = strlen(K);
    dp[0][0][0] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < D; k++) {
                int x = j ? 9 : K[i] - '0';
                for (int d = 0; d <= x; d++) {
                    dp[i + 1][j || d < x][(k + d) % D] += dp[i][j][k];
                }
            }
        }
    }
    mint ans = dp[N][0][0] + dp[N][1][0] - 1;
    printf("%d\n", ans.n);
    return 0;
}


Measured memory_bytes: 7936
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}

void func(void)
{
	uint32 n;
	cin >> n;
	vector<int> a(n);
	for(uint32 i=0; i<n; i++){
		cin >> a[i];
	}
#if 1
	vector<int> sum(n);
	sum[0] = a[0];
	for(uint32 i=1; i<n; i++){
		sum[i] = sum[i-1] + a[i];
	}
	vector<uint64> diff(n-1);
	for(uint32 i=0; i<n-1; i++){
		int64 s = sum[n-1] >= 0 ? sum[n-1] : -sum[n-1];
		diff[i] = abs((sum[n-1] - sum[i]) - sum[i]);
	}

	sort(diff.begin(), diff.end());

	if(n==2){
		diff[0] = abs(a[0]-a[1]);
	}
	cout << diff[0] << endl;
#else
	uint64 minDiff = UINT64_MAX;
	for(uint32 i=0; i<n-1; i++){
		int64 sum1 = a[0];
		for(uint32 j=1; j<=i; j++){
			sum1 += a[j];
		}
		int64 sum2 = a[i+1];
		for(uint32 j=i+2; j<n; j++){
			sum2 += a[j];
		}
		uint64 diff = abs(sum2 - sum1);
		minDiff = min(minDiff, diff);
	}
	cout << minDiff << endl;
#endif

	return;
}




Measured memory_bytes: 6272
import heapq


n, m = list(map(int,input().split()))
a_arr = list(map(int,input().split()))
a_arr = [ i * -1.0 for i in a_arr]
heapq.heapify(a_arr)
for i in range(m):
    n = heapq.heappop(a_arr)
    n = -n
    n = n / 2.0
    heapq.heappush(a_arr, -n)
s = 0
for a in a_arr:
    a = -a
    a = int(a)
    s += a

print(s)

Measured memory_bytes: 14180
<?php
    list($a,$b) = array_map(null,explode(" ",trim(fgets(STDIN))));
    $ans="";
    if($a<=$b){
        for($i=0;$i<$b;$i++){
            $ans .= $a;
        }
    }else{
        for($i=0;$i<$a;$i++){
            $ans .= $b;
        }
    }
    echo $ans;
?>

Measured memory_bytes: 16072
#include <stdlib.h>
#include <stdio.h>
typedef struct{
    long long pos;
    long long len;
}pair;
int compare(const void *a,const void *b){
    pair x=*(pair *)a,y=*(pair *)b;
    long long p=x.pos+x.len,q=y.pos+y.len;
    return p>q?1:-1;
}
int main()
{   int n;
    scanf("%d",&n);
    pair a[n];
    for(int i=0;i<n;i++){
        scanf("%lld%lld",&a[i].pos,&a[i].len);
    }
    qsort(a,n,sizeof(pair),compare);
    long long max=-2000000005,ans=0;
    //printf("%d %d\n",a[0].pos,a[0].len);
    for(int i=0;i<n;i++){
        //printf("%d %d\n",a[i].pos,a[i].len);
        if(max<=a[i].pos-a[i].len){
            ans++;
            max=(a[i].pos+a[i].len);
        }else{
            continue;
        }
    }
    printf("%lld",ans);

    return 0;
}


Measured memory_bytes: 3324
import bisect

n = int(input())
L = list(map(int, input().split()))

ans = 0
L.sort()

for i in range(n - 2):
    for j in range(i + 1, n - 1):
        idx = bisect.bisect_left(L, L[i] + L[j])
        ans += max(0, idx - j - 1)
print(ans)


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

#define rep(i, n) for (int i=0; i<n; i++)

using LL = long long;
int N;
const LL MOD = 998244353;

LL gcd(LL a, LL b) {
  if (b ==  0) return a;
  return gcd(b, a%b);
}
 
int main() { 
  cin >> N;
  LL ans = 1;
  vector<int> as;
  rep(i, N) {
    int a;
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  rep(i, N) {
    ans *= gcd(as[i], i);
     ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>

using namespace std;

int h, w;
string s[20];

int bfs(int p, int q);

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

	int mx = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '.') {
				mx = max(mx, bfs(i, j));
			}
		}
	}
	cout << mx << endl;

	return 0;
}

int bfs(int p, int q)
{
	int map[20][20];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			map[i][j] = -1;
		}
	}

	queue<pair<pair<int, int>, int>> que;
	que.push(make_pair(make_pair(p, q), 0));
	while (!que.empty()) {
		pair<pair<int, int>, int> t = que.front();
		que.pop();
		if (map[t.first.first][t.first.second] != -1) {
			continue;
		}
		map[t.first.first][t.first.second] = t.second;

		int dx[] = { 0, -1, 0, 1 };
		int dy[] = { -1, 0, 1, 0 };
		for (int i = 0; i < 4; i++) {
			if (t.first.first + dx[i] >= 0 && t.first.first + dx[i] < h &&
				t.first.second + dy[i] >= 0 && t.first.second + dy[i] < w &&
				s[t.first.first + dx[i]][t.first.second + dy[i]] == '.') {
				que.push(make_pair(make_pair(t.first.first + dx[i], t.first.second + dy[i]), t.second + 1));
			}
		}
	}
	
	int mx = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			mx = max(mx, map[i][j]);
		}
	}
	return mx;
}

Measured memory_bytes: 256
import sys
 
def INPUT(): return sys.stdin.readline().strip()
 
sys.setrecursionlimit(10 ** 9)
 
 
def main():
    S = INPUT()
    fall_point = []
    split_point = [0]
    N = len(S)
    last_S = [0] * N
 
    for i in range(N):
        if not i == N - 1:
            if S[i:i+2] == 'RL':
                fall_point.append(i)
            elif S[i:i+2] == 'LR':
                split_point.append(i+1)
        else:
            split_point.append(i+1)
 
    for i in range(len(split_point)-1):
        sub_len = split_point[i+1] - split_point[i]
 
        if sub_len % 2 == 0:
            last_S[fall_point[i]] = sub_len // 2
            last_S[fall_point[i] + 1] = sub_len // 2
        else:
            if (split_point[i+1] - fall_point[i]) % 2 == 0:
                last_S[fall_point[i]] = sub_len // 2
                last_S[fall_point[i] + 1] = sub_len // 2 + 1
            else:
                last_S[fall_point[i]] = sub_len // 2 + 1
                last_S[fall_point[i] + 1] = sub_len // 2
 
    print(" ".join(map(str, last_S)))
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 51440
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        h: usize,
        w: usize,
        a: [chars; h],
    }

    let mut skip_rows = vec![false; h];
    let mut skip_cols = vec![false; w];

    for i in 0..h {
        let mut ok = true;
        for j in 0..w {
            ok &= a[i][j] == '.';
        }
        if ok {
            skip_rows[i] = true;
        }
    }
    for j in 0..w {
        let mut ok = true;
        for i in 0..h {
            ok &= a[i][j] == '.';
        }
        if ok {
            skip_cols[j] = true;
        }
    }
    for i in 0..h {
        if skip_rows[i] {
            continue;
        }
        for j in 0..w {
            if skip_cols[j] {
                continue;
            }
            print!("{}", a[i][j]);
        }
        println!("");
    }
}


Measured memory_bytes: 4352