akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 500001
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);

vector<ll> factorize(ll num) {
    
    vector<ll> res;
    for(ll i=1;i<=sqrt(num);i++) {
        if((num%i)==0) { 
            if(i*i==num) {
                res.push_back(i);
            }
            else {
                res.push_back(i);
                res.push_back(num/i);
            }
        }
    }

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

    // for(auto i:res)
    //  printf("%lld ",i);
    // printf("\n");

    return res;
}

int main() {

    get(n);
    vector<ll> facts = factorize(n);

    ll res = 1e18;
    for(int i=0;i<facts.size();i++)
        res = min(res, facts[i]+n/facts[i]);
    cout<<res-2<<endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        out.println((N-2)*180);
        out.flush();
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}


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

using namespace std;
typedef long long ll;
const ll N= 1e5+7;
ll l, n , r ,t ,k , ans , x , y , a, b, c ,d,sum , cntr, now , xnum;
int arr[N];
vector<pair<int,int> >v;
ll LCM( ll num1 , ll num2)
{
    if(max(num1, num2)%min(num1 , num2)==0)
    {
        return max(num1, num2);
    }
    return num1*num2;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >>n;
    for(int i = 0 ; i < n ;i++)
    {
        cin >> x >> y;
        v.push_back({y,x});
    }
    sort(v.begin(),v.end());
    x=0;
    for(int i = 0 ; i < n ;i++)
    {
        if(i==0)
        {
            x=v[i].second;
        }
        else
        {
            x+=v[i].second;
        }
        if(x>v[i].first)
        {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 2420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[][] a = new int[n][2];
		for (int i = 0; i < n; i++) {
			a[i][0] = sc.nextInt();
			a[i][1] = sc.nextInt();
		}
		double sum = 0;
		for (int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(j != i) {
					sum += Math.sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]));
				}
			}
		}
		System.out.println(sum/n);
		sc.close();
	}
}

Measured memory_bytes: 23124
N = int(input())
if N%2==0:
  print(N*(N-2)//2)
  ans = []
  for i in range(1,N+1):
    for j in range(1,N+1):
      if i>=j or i+j==N+1:
        continue
      ans += [(i,j)]
  for a in ans:
    print(*a)
else:
  n = N-1
  print(n*(n-2)//2 + n)
  ans = []
  for i in range(1,n+1):
    for j in range(1,n+1):
      if i>=j or i+j==n+1:
        continue
      ans += [(i,j)]
  for a in ans:
    print(*a)
  for i in range(1,N):
    print(i,N)

Measured memory_bytes: 3996
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int k = Integer.parseInt(sc.next());
    
    int s = 0;
    int t = 0;
    double p = 0;
    
    for (int i=1; i<=n; i++){
      s = i;
      
      if (s>=k) {
        p += 1d/n;
        continue;
      }
      
      for (int j=1; j<21; j++){
        s = s*2;
        
        if (s>=k) {
          p += (1d/n) * Math.pow(0.5d, j);
          break;
        }
        
      }
    }
    
    System.out.println(p);
  }
}


Measured memory_bytes: 21204
import numpy as np
from functools import *
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline


def array(size, init=0):
    return [[init for j in range(size[1])] for i in range(size[0])]


def acinput():
    return list(map(int, input().split(" ")))


def II():
    return int(input())


N, K = acinput()
A = acinput()


for i in range(K, N):
    if A[i] > A[i - K]:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 49588
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int a, b;
   cin >> a >> b;
   string s;
   if (a < b) {
      rep(i, 0, b) s += (char)a + '0';
   } else if (a > b) {
      rep(i, 0, a) s += (char)b + '0';
   } else {
      rep(i, 0, b) s += (char)a + '0';
   }
   cout << s << endl;
   return 0;
}

Measured memory_bytes: 256
/*input
2 10
20 20
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MX = 100 + 100;
int v[MX];
main () {
    int n, x; cin >> n >> x;
    for(int i = 1; i <= n; i ++) {
        cin >> v[i];   
    }
    sort(v + 1, v + 1 + n);
    int ans = 0;
    for(int i = 1; i <= n; i ++) {
        if(i == n) ans += x == v[i];
        else if(x >= v[i]) {
            x -= v[i];
            ans ++;
        }
        else break;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz = 5e5+5;

char s[sz];

int main() {
   int n;
   cin >> n;
   scanf("%s", s);
   int red = 0;
   for(int i=0; s[i]; i++) if(s[i] == 'R') red++;

   int ans = 0;
   for(int i=0; i<red; i++) if(s[i] == 'W') ans++;

   cout << ans << endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};

void func(long long N, long long M, std::vector<long long> p, std::vector<long long> x, std::vector<long long> y){

    UnionFind uf(N);

    REP(i,0,M){
        uf.unite(x[i],y[i]);
    }

    lli ans = 0;
    REP(i,0,N){
        lli target = p[i];
        if(uf.same(target,i))ans++;
    }
    cout<<ans<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
        p[i]--;
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        x[i]--,y[i]--;
    }
    func(N, M, std::move(p), std::move(x), std::move(y));
    return 0;
}


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

int main(){
    int N = 0;
    cin >> N;
    vector<int> A(N);
    int flag = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < N-1; i++)
    {
        if (A[i] == A[i + 1])
        {
            flag = 1;
        }
    }
    if(flag == 1){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }
}

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

int main() {
	size_t N;
	cin >> N;
	int C, K;
	cin >> C >> K;
	vector<int> T(N);
	for (int& i : T) cin >> i;
	sort(T.begin(), T.end());
	int tmp1 = 0, tmp2 = T[0], ans = 1;
	for (int& i : T) {
		++tmp1;
		if (C < tmp1 || i - K > tmp2) {
			tmp1 = 1;
			tmp2 = i;
			++ans;
		}
	}
	cout << ans;
}

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

int main()
{
 long long n,k;
 cin>>n>>k;
  long long count=0;
  while(n>0)
  {
    count++;
    n=n/k;
  }
  cout<<count<<"\n";
  
  return 0;
 }

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

int main(){

  int N;
  cin >> N;

  int count = 0;
    for(int n = 1; n < 10000; n++){
  for(int i = 1; i < 10000; i++){
    if(n%i == 0)count++;

  }
  if(N == count){
    cout << n << endl; return 0;
  }
  count = 0;
}

  return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int N, W;
ll w[105];
ll v[105];

ll dp[105][100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> N >> W;

  REP(i, N) cin >> w[i] >> v[i];
  REP(i, N + 1) REP(j, 100001) dp[i][j] = INF + 100;
  dp[0][0] = 0;
  REP(i, N) REP(j, 100001) {
    if(j < v[i]) {
      dp[i + 1][j] = dp[i][j];
    } else {
      dp[i + 1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
    }
  }

  ll ans = 0;
  REP(i, 100001) {
    if(dp[N][i] <= W) ans = i;
  }

  cout << ans << endl;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(c-(a-b), 0) << endl;
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

const int NMAX = 200000;

vector<pair<int,int>> G[NMAX+2];
int d[NMAX+2], viz[NMAX+2];
int N, M;

void DFS(int nod, int dist = 0)
{
    viz[nod] = 1;
    d[nod] = dist;
    for( auto& pp : G[nod] ) {
        int x = pp.first;
        int delta = pp.second;
        if( viz[x] ) continue;
        DFS(x, dist + delta);
    }
}

int main()
{
    cin >> N >> M;
    for( int i = 1;  i <=M;  ++i ) {
        int x,y,dist;
        cin >> x >> y >> dist;
        G[x].push_back( {y,dist} );
        G[y].push_back( {x,-dist} );
    }
    for( int i = 1;  i <= N;  ++i  ) {
        if( viz[i] ) continue;
        DFS(i);
    }
    for( int nod = 1;  nod <= N;  ++nod ) {
        for( auto& pp : G[nod] ) {
            int dist = pp.second;
            int x = pp.first;
            if( d[x] - d[nod] != dist ) {
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int n = S.size();
  long long sum = 0;
  
  
  for(int b = 0;b < (1 << (n - 1)); b++){
    long long t = S.at(0) - '0';
    
    for(int i = 0; i < n - 1; i++){

      if(b & (1 << i)){
        sum += t;
        t = S.at(i + 1) - '0';
      }
      else{
        t *= 10;
        t += S.at(i + 1) - '0';
      }
    }
    
    sum += t;
  }
  
  cout << sum << endl;
  return 0;
}  

Measured memory_bytes: 256
X, K, D = map(int, input().split())

n, x= divmod(abs(X), D)
if n > K:
  print(min(abs(X - D * K), abs(X + D * K)))
  exit()
K = K - n

if K % 2 == 0:
  print(abs(x))
else:
  print(min(abs(D - x), abs(D + x)))

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

int main() { 
  int N, K;
  cin >> N >> K;
  
  vector<int> point(N);
  for(int i=0; i<N; i++){
    cin >> point[i];
  }
  
  vector<string> judge(N-K);
  
  for(int i=0; i<N-K; i++){
    if(point[i] < point[i+K]) judge[i] = "Yes";
    else judge[i] = "No";
  }
  
  for(int i=0; i<N-K; i++){
    cout<< judge[i] << endl;
  }
  
  
}

Measured memory_bytes: 10316
from math import gcd
n = int(input())
ab = [list(map(int, input().split())) for _ in range(n)]
mod = 1000000007

#%%

kai = [1]*(n+1)
gyaku = [1]*(n+1)

for i in range(2, n+1):
    kai[i] = kai[i-1]*i % mod
    gyaku[i] = gyaku[i-1]*pow(i, mod-2, mod) %mod

azero = 0
bzero = 0
zerozero = 0
dict_patterns = {}
dict_patterns_minus = {}
all_effective = 0
answer = 0
dict_patterns["1,0"] = 0
dict_patterns["0,-1"] = 0

for i in range(n):
    minus = False
    a, b = ab[i]
    if a == 0 and b == 0:
        zerozero += 1
        continue
    elif b == 0:
        dict_patterns["1,0"] += 1
        continue
    elif a == 0:
        dict_patterns["0,-1"] += 1
        continue
    common = gcd(a,b)
    a, b = int(a//common), int(b//common)
    if a < 0 and b < 0:
        a,b = -a,-b
    elif a < 0:
        a,b = -a,-b
        minus = True
    elif b<0:
        minus = True
    
    to_str = str(a)+","+str(b)
    if to_str not in dict_patterns:
        if minus == False:
            dict_patterns[to_str] = 1
        else:
            dict_patterns[to_str] = 1
    else:
        if minus == False:
            dict_patterns[to_str] += 1
        else:
            dict_patterns[to_str] += 1

#%%

keys = list(dict_patterns.keys())
patterns = []
test = []
for i in range(len(keys)):
    pattern_A = dict_patterns[keys[i]]
    dict_patterns[keys[i]] = 0
    pattern_B = 0
    a, b = map(int, keys[i].split(","))
    if str(b)+","+str(-a) in dict_patterns:
        pattern_B += dict_patterns[str(b)+","+str(-a)]
        dict_patterns[str(b)+","+str(-a)] = 0
    elif str(-b)+","+str(a) in dict_patterns:
        pattern_B += dict_patterns[str(-b)+","+str(a)]
        dict_patterns[str(-b)+","+str(a)] = 0
    if pattern_A != 0 or pattern_B != 0:
        patterns.append(max(2**pattern_A-1,0) + max(2**pattern_B-1,0) + 1)  
    test.append([pattern_A, pattern_B])
#%%
answer = 1
for i in range(len(patterns)):
    answer = answer*patterns[i] % mod

print((answer-1+zerozero)%mod)


Measured memory_bytes: 177752
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    string s = read!string;

    int ans = 0;
    int x = 0;
    foreach (c; s) {
        switch (c) {
            case 'I': x++; break;
            case 'D': x--; break;
            default: break;
        }
        ans = max(ans, x);
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    ll sum = abs(a[0])+abs(a[n-1]);
    rep(i,n-1)sum += abs(a[i]-a[i+1]);

    cout<<sum - (abs(a[0])+abs(a[0]-a[1])) + abs(a[1]) <<" ";
    repi(i,1,n-1){
        int bef = abs(a[i]-a[i-1])+abs(a[i]-a[i+1]),aft = abs(a[i-1]-a[i+1]);
        cout<<sum - bef + aft<<" ";
    }
    cout<<sum - (abs(a[n-1])+abs(a[n-1]-a[n-2]))+abs(a[n-2])<<endl;
    
}




Measured memory_bytes: 1664
import math
from itertools import permutations as perm

ii = lambda:int(input())
li = lambda:list(map(int,input().split()))
lix = lambda x:list(li() for _ in range(x))
##########
def main(n,x):
    res = 0
    count = 0
    for item in perm(x,n):
        res += calc(item)
        count += 1
    return res / count
    
def calc(item):
    res = 0
    for i in range(1,len(item)):
        st,ed = item[i-1], item[i]
        res += math.sqrt((ed[0]-st[0])**2 + (ed[1]-st[1])**2)
    return res

n = ii()
x = lix(n)
print(main(n,x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define forn(i, n) for (llong i = 0ll; i < (llong) n; ++i)
#define fornn(i, l, r) for (llong i = (llong) l; i < (llong) r; ++i)
#define size(x) ((int) (x.size()))
 
using namespace std;
 
typedef long long llong;
const llong inf = (llong) 1e+9 + 7ll;
const llong linf = (llong) 1e+18 + 7ll;
const long double eps = (long double) 1e-9;
const long double pi = acosl((long double) -1.0);
const int alph = 26;

mt19937 mrand(random_device{} ()); 

template<typename T, typename U> inline llong umin(const T& a, const U& b) { return a < b ? a : b; }
template<typename T, typename U> inline llong umax(const T& a, const U& b) { return a > b ? a : b; }
 
static char buff[(int) 2e6 + 17]; // reads std::string
const int maxn = (int) 3e6 + 17;

struct pt
{
	int x, y;
	pt() { }
};

struct fenwick
{
	int n;
	unordered_map<int, int> F;

	fenwick()
	{
		n = inf;
		F.rehash(4000000);
	}

	void upd(int i, int x)
	{
		for (; i < n; i |= i + 1)
			F[i] = max(F[i], x);
	}

	int get(int i)
	{
		int res = 0;

		for (; i >= 0; i &= i + 1, --i)
			res = max(res, F[i]);

		return res;
	}
};

int n;
pt s, f;
pt p[maxn];

bool read()
{
	if (scanf("%d %d %d %d %d", &s.x, &s.y, &f.x, &f.y, &n) != 5)
		return false;

	forn (i, n)
		scanf("%d %d", &p[i].x, &p[i].y);

	return true;
}

bool cmp(pt a, pt b) { return make_pair(a.x, a.y) < make_pair(b.x, b.y); }

void solve()
{
	if (s.x > f.x)
		swap(s, f);

	if (s.y > f.y)
	{
		f.y = 2 * s.y - f.y;

		forn (i, n)
			p[i].y = 2 * s.y - p[i].y;
	}

	vector<pt> pp;

	forn (i, n)
		if (s.x <= p[i].x && p[i].x <= f.x && s.y <= p[i].y && p[i].y <= f.y)
			pp.push_back(p[i]);

	sort(pp.begin(), pp.end(), cmp);
	fenwick dp;

	forn (i, size(pp))
		dp.upd(pp[i].y, dp.get(pp[i].y) + 1);

	int lis = dp.get(inf);
	long double ans = 0;

	if (lis != min(f.y - s.y, f.x - s.x) + 1)
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * lis;
	else
		ans = 100.0 * (f.y - s.y + f.x - s.x) - 20.0 * lis + 5 * M_PI * (lis - 1) + 10 * M_PI;

	printf("%.15f\n", (double) ans);
}

int main()
{
#if SEREZHKA
	freopen("file.in", "r", stdin);
#endif

	while (read())
		solve();

	return 0;
}


Measured memory_bytes: 85488
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int x[5];
int main(void){
    REP(i, 5) cin >> x[i];
    REP(i, 5){
        if (x[i] == 0) cout << i+1 << endl;
    }
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int> As(n);
    for (int i=0; i<n; i++){
        cin >> As.at(i);
    }
    int ans = 1;
    int flag = 0;
    for (int i=0; i<n-1; i++){
        if (flag == 1){
            if(As[i]<=As[i+1]) continue;
            else {
                ans ++;
                flag =0;
            }
        }
        else if(flag == -1){
            if(As[i]>=As[i+1]) continue;
            else {
                ans ++;
                flag =0;
            }
        }
        else{
           if (As[i]<As[i+1]) flag =1;
           else if (As[i]>As[i+1]) flag = -1; 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
"""
 - https://atcoder.jp/contests/abc168/tasks/abc168_d
 - 幅優先探索
 - 部屋(d+1)の道しるべが部屋(d)を指すように設定すれば目標を達成できる
"""
from collections import deque
n, m = map(int, input().split()) 
list_init = [0]*(n+1)
c = [[] for i in range(n+1)]

for i in range(m):
    a, b = map(int, input().split())
    c[a].append(b)
    c[b].append(a)
    
que = deque([1])
check = [0 for i in range(n+1)]
check[1] = 1
while que:
    now = que.popleft()
    nx = c[now]
    for i in nx:
        if check[i] == 1:
            continue
        check[i] = 1
        list_init[i] = now
        que.append(i)
if 0 in list_init[2:]:
    print("No")
else:
    print("Yes")
    print("\n".join(map(str, list_init[2:])))

Measured memory_bytes: 42472
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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




int main(int argc, const char * argv[]){
    
    //Input
    int i, j , n ,m , frm, to;
    
    scanf("%d", &n);
    
    int ans[n][n];
    
    memset(ans, 0x00, sizeof(ans));
    
    for(i = 0; i < n; i++){
        
        scanf("%d", &frm);
        scanf("%d", &m);
        
        for (j=0; j<m; j++) {
            scanf("%d", &to);
            ans[frm - 1][to - 1] = 1;
        }
        
    }
    
    for (i=0; i<n; i++) {
        for (j=0; j<n; j++) {
            printf("%d", ans[i][j]);
            if(j != n-1) printf(" ");
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 1072
#include<iostream>
#include<vector>

using namespace std;

vector<string> V;

bool find(string in){
  for(int i = 0; i < V.size(); i++)
    if(V[i] == in) return true;

  return false;
}

int main(){
  int n,m;
  

  cin >> n;
  while(n--){
    string in;
    cin >> in;
    V.push_back(in);
  }

  bool open = false;

  cin >> m;
  while(m--){
    string in;
    cin >> in;
    if(find(in)){
      if(open) cout << "Closed by ";
      else cout << "Opened by ";
      open = !open;
    }else cout << "Unknown ";

    cout << in << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    B = [list(map(int, input().split())) for _ in range(H)]

    dp = [[set() for _ in range(W)] for _ in range(H)]
    dp[0][0] = {abs(A[0][0] - B[0][0])}
    for h in range(H):
        for w in range(W):
            a, b = A[h][w], B[h][w]
            if w - 1 >= 0:
                for num in dp[h][w - 1]:
                    dp[h][w].add(abs(num + a - b))
                    dp[h][w].add(abs(-num + a - b))
            if h - 1 >= 0:
                for num in dp[h - 1][w]:
                    dp[h][w].add(abs(num + a - b))
                    dp[h][w].add(abs(-num + a - b))

    res = f_inf
    for num in dp[-1][-1]:
        res = min(res, abs(num))
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 545628
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define Set set<int>
#define int long long
#define P pair<int,int>
const int maxn = 1005;
const int INF = 1e17 +6;
using namespace std;
int n,m,a[maxn],b[maxn],c[maxn];
int t[maxn][maxn];
int32_t main() {
    IOS;
    cin>>n>>m;
    fu(i,1,m)
    {
        int x;
        cin>>b[i];
        fu(j,1,b[i])
        {
            cin>>t[i][j];
        }
    }
    fu(i,1,m)cin>>a[i];
    int ans=0;
    fu(i,0,(1<<n)-1)
    {
        if(i==5)
        {
            1;
        }
//        cout<<"i:"<<i<<endl;
        int key=1;
        fu(u,1,m) {//第u个灯泡
            int ji=0;
            fu(j, 1, b[u]) {//有b[u]个开关
                if ((1 << (t[u][j] - 1)) & i)ji++;
            }
            if(ji%2!=a[u])key=0;
        }
        if(key) {
//            cout<<"yes_I:"<<i<<endl;
            ans++;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
N=int(input())#入力回数を決める
lis=[]
mins = []
for i in range(N):
  lis.append(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'
for charas in alpha:
  counts = []
  for words in lis:
    d = words.count(charas)
    counts.append(d)
  mins.append(min(counts))
i = 0
ans = ''
while i < 26:
  ans += alpha[i]*mins[i]
  i += 1
print(ans)

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

l = [0] * 10000
for i in range(0, 100 + 1):
  for j in range(0, 100 + 1):
    # print(f"{i} {j}")
    val = (4 * i) + (7 * j)
    # l.append(val)
    l[val] += 1
# print(max(l))

if l[n] == 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9140
#include <stdio.h>

int main() {

    int W, H, x, y, r;

    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if (W < x + r || H < y + r) {
    	printf("No\n");
    } else if (x < 0 || y < 0) {
    	printf("No\n");
    } else {
    	printf("Yes\n");
    }

    return 0;
}

   


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
#define P pair<int,int>

int main() {
  int H, W;
  long long INF = 1000000000;
  char a[1005][1005];
  int S[1005][1005];
  queue<P>que;
  int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
  cin >> H >> W;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
		S[i][j] = INF;
    }
  }
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
	  cin >> a[i][j];
	  if (a[i][j] == '#') {
	  	S[i][j] = 0;
		que.push({ i,j });
      }
	}
  }
  while (que.size()) {
	P p = que.front(); 
    que.pop();
	for(int i = 0; i < 4; i++) {
		int nx = p.first + dx[i], ny = p.second + dy[i];
		if (nx < 0 || nx >= H || ny < 0 || ny >= W)continue;
		if (S[nx][ny] == INF) {
			S[nx][ny] = S[p.first][p.second] + 1;
			que.push({ nx,ny });
		  }
	  }
  }
  int ans = 0;
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
  	ans = max(ans, S[i][j]);
    }
  }
  cout << ans;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    if(S.size() == 26) {
        string temp = S;
        if(next_permutation(temp.begin(), temp.end())) {
            auto iter = temp.begin();
            iter(c, S) if(*iter++ != c) break;
            temp.erase(iter, temp.end()); 
            cout << temp << endl;
        } else {
            cout << -1 << endl;
        }
    } else {
        set<char> chars;
        iter(c, S) chars.insert(c);
        repi2(c, 'a', 'z') {
            if(chars.find(c) == chars.end()) {
                S.push_back(c);
                cout << S << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll n=in();
    vector<ll>p(n),q(n);
    for(ll i=0;i<n;++i)p[i]=in();
    for(ll i=0;i<n;++i)q[i]=in();
    vector<ll>r(n);iota(r.begin(),r.end(),1);
    ll a,b,cnt=0;
    do{
        bool foo=true;
        for(ll i=0;i<n;++i)foo&=p[i]==r[i];
        if(foo)a=cnt;
        foo=true;
        for(ll i=0;i<n;++i)foo&=q[i]==r[i];
        if(foo)b=cnt;
        ++cnt;
    }while(next_permutation(r.begin(),r.end()));
    cout<<abs(a-b)<<endl;
}


Measured memory_bytes: 256
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>	tree_set;
typedef long long ll;
typedef long double ld;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

ll mod=1e9 + 7;

int main()
{
    fast();

    ll n;
    cin>>n;
    ll arr[n+1];
    for(ll i=1;i<=n;i++)
        cin>>arr[i];

    vector<ll> ans(n+1,0);
    ll cnt=0;
    for(ll i=n;i>=1;i--)
    {
        ll sum = 0;
        for(ll j=2*i;j<=n ; j+=i)
            sum+=ans[j];

        if( (sum%2==0 && arr[i]==1) || (sum%2==1 && arr[i]==0) )
        {
            ans[i]=1;
            cnt++;
        }
    }

    cout<<cnt<<endl;
    for(ll i=1;i<=n;i++)
    {
        if(ans[i]==1)
            cout<<i<<" ";
    }

}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    set<array<int, 2>> s;
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin >> t;
        s.insert({t, i});
    }
    for (auto a : s)
    {
        cout << a[1] << " ";
    }
}

Measured memory_bytes: 8192
N = int(input())
C = list(map(int, input().split()))
MOD = 1_000_000_007

B = [0 for _ in range(N+1)]#2べきmod
B[0] = 1
for i in range(1,N+1):
  B[i] = B[i-1] * 2
  B[i] %= MOD  

C.sort()

ans = 0
for n in range(1,N+1):
  ans += C[n-1] * ((N-n) * B[N-n-1] + B[N-n]) * B[n-1]
  ans %=  MOD
  
ans *= B[N]
ans %= MOD

print(ans)

"""
D = [0 for _ in range(N)]#累積和
D[0] = C[0]
for i in range(1,N):
  D[i] = D[i-1] + C[i]
print(C)

  
ans = 0
for j in range(1,N+1):
  ans += D[j-1] * B[j-1]  
  print(D[j-1] * B[j-1]  
  
"""

Measured memory_bytes: 31556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");

		long a[] = new long[n];

		long x[] = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = Long.parseLong(str[i]);

			if (i % 2 == 0)
				x[0] += a[i];
			else
				x[0] -= a[i];
		}

		for (int i = 1; i < n; i++) {
			x[i] = 2 * a[i - 1] - x[i - 1];
		}

		System.out.print(x[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " + x[i]);
		}
		System.out.println();
	}
}


Measured memory_bytes: 57852
from copy import deepcopy
h,w,k = map(int, input().split())
strawberry_count = [0 for i in range(h)]
cakes = []
for i in range(h):
    cakes.append(list(input()))
    strawberry_count[i] = cakes[i].count('#')
ans = []
first_index = 10000
use_number = 0
for i in range(h):
    append_array = []
    if strawberry_count[i] >= 2:
        first_index = min(first_index,i)
        use_number += 1
        first = True
        for j in range(w):
            if cakes[i][j] == '#':
                if first:
                    first = False
                else:
                    use_number += 1
            append_array.append(use_number)
    elif strawberry_count[i] == 1:
        use_number += 1
        first_index = min(first_index,i)
        append_array = [use_number for i in range(w)]
    else:
        append_array = []
    ans.append(append_array)
print_count = 0
pre_array = []
for i in range(h):
    if len(ans[i]) == 0:
        if print_count > 0:
            print(" ".join(map(str,pre_array)))
        else:
            print(" ".join(map(str,ans[first_index])))
            pre_array = ans[first_index]
            print_count += 1
    else:
        print(" ".join(map(str, ans[i])))
        pre_array = ans[i]
        print_count += 1



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


int main()
{
    int n;
    string a,b,c;cin >> n >> a >> b >> c;
    int sum = 0;
    for(int i = 0; i<n;i++){
        if(a[i] == b[i] && b[i] == c[i])continue;
        else if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
            sum += 2;
        }else sum++;
    }
    cout << sum << endl;
    
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll h, a;
	cin >> h >> a;
	ll ans = h / a;
	if (h % a != 0)
		ans += 1;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
s = int(input())

l = [s]

def f(n):
    if n % 2 == 0:
        a = n // 2
    else:
        a = 3 * n + 1
    if a in l:
        return
    l.append(a)
    f(a)

f(s)
print(len(l) + 1)


Measured memory_bytes: 3060
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#include <iomanip>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll mod = 1e9 + 7;

string S;
ll N, ans[100005];
bool flag = false;
ll H[100005];

int main() {

	cin >> S;

	ll left = 0,right=0,RL=0;
	bool  state = false;//falseでR、trueでL
	FOR(i, 1, S.length()+1) {
		if (!state) {
			if (S[i] == 'L') {
				RL = i-1;
				state = true;
			}
			
		}
		else {
			if (i==S.length()||S[i] == 'R'){
				ans[RL + 1] += (RL - right + 1) / 2 +1;
				ans[RL] += (RL - right) / 2 +1;
				ans[RL] += (i - 1 - (RL + 1) + 1) / 2;
				ans[RL+1] += (i - 1 - (RL + 1) ) / 2;

				

				right = i;
				state = false;
			}
			
		}
	}

	FOR(i, 0, S.length()) {
		cout << ans[i] << " ";
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct ABC{
int a,b,c;
};
int main(){
int i,j,l,n,d,t[200],p[201][200]={0};
struct ABC q[200];
scanf("%d%d",&d,&n);
for(i=0;i<d;i++)
scanf("%d",&t[i]);
for(i=0;i<n;i++)
scanf("%d%d%d",&q[i].a,&q[i].b,&q[i].c);
for(i=1;i<d;i++){
	for(j=0;j<n;j++){
		if(t[i-1]>=q[j].a&&t[i-1]<=q[j].b){
			for(l=0;l<n;l++){
				if(t[i]>=q[l].a&&t[i]<=q[l].b){
					int absl=max(q[j].c-q[l].c,q[l].c-q[j].c);
					p[i][l]=max(p[i][l],p[i-1][j]+absl);
				}
			}
		}
	}
}
int ans=0;
for(i=0;i<n;i++)
ans=max(ans,p[d-1][i]);
printf("%d\n",ans);
return 0;
}



Measured memory_bytes: 3396
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from heapq import heappush, heappop
import sys
from collections import defaultdict
INF = 10**6
def main(H, W, AB):
    cur = list(range(W))
    cur_f = BinaryIndexedTree(initial_values=[1] * W)
    rt = [0] * W
    rt_c = defaultdict(int)
    rt_c[0] = W
    for i, (a, b) in enumerate(AB):
        a -= 1
        mr = -1
        while True:
            j = cur_f.bisect(lambda x: x <= cur_f.query(a - 1))
            if j >= W or j > b: break
            mr = cur[j]
            cur_f.add(j, -1)
            v = j - cur[j]
            if rt_c[v] > 1: rt_c[v] -= 1
            else: rt_c.pop(v)
        if mr >= 0 and b < W:
            cur_f.add(b, 1)
            cur[b] = mr
            v = b - mr
            heappush(rt, v)
            rt_c[v] += 1
        ans = -1
        if rt:
            c = defaultdict(int)
            while rt:
                c[rt[0]] += 1
                if c[rt[0]] > rt_c[rt[0]]:
                    heappop(rt)
                else:
                    ans = rt[0] + i + 1
                    break
        print(ans)

class BinaryIndexedTree:
    def __init__(self, n=None, f=lambda x, y: x + y, identity=0, initial_values=None):
        assert(n or initial_values)
        self.__f, self.__id, = f, identity
        self.__n = len(initial_values) if initial_values else n
        self.__d = [identity] * (self.__n + 1)
        if initial_values:
            for i, v in enumerate(initial_values): self.add(i, v)

    def add(self, i, v):
        n, f, d = self.__n, self.__f, self.__d
        i += 1
        while i <= n:
            d[i] = f(d[i], v)
            i += -i & i

    def query(self, r):
        res, f, d = self.__id, self.__f, self.__d
        r += 1
        while r:
            res = f(res, d[r])
            r -= -r & r
        return res

    def bisect(self, func):
        '''func()がFalseになるもっとも左のindexを探す
        '''
        n, f, d, v = self.__n, self.__f, self.__d, self.__id
        x, i = 0, 1 << (n.bit_length() - 1)
        while i > 0:
            if x + i <= n and func(f(v, d[x + i])): v, x = f(v, d[x + i]), x + i
            i >>= 1
        return x

if __name__ == '__main__':
    input = sys.stdin.readline
    H, W = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(H)]
    main(H, W, AB)


Measured memory_bytes: 140660
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;
bool prime_number(int x){
    int y=sqrt(x);
    if(x==2) return true;
    if(x==1) return false;
    for(int i=2; i<=y; i+=1){
        if(x%i==0) return false;
    }
    return true;
}
int main(){
    int n,sum=0;
    cin >> n;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
        if(prime_number(a[i])){
            sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3116
using System;
namespace _0007
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int syakkin = 100000;
            for(int i=0;i<n;i++)
            {
                syakkin = syakkin / 20 * 21;
                if(syakkin%1000!=0)
                {
                    syakkin = (syakkin / 1000 + 1) * 1000;
                }
            }
            Console.WriteLine(syakkin);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9164
#include "bits/stdc++.h"
using ll = long long;
using namespace std;

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  string s;
  cin >> s;

  int x = 0;
  for(auto c : s) {
    x += (c - '0');
  }

  cout << (x % 9 == 0 ? "Yes" : "No");
}


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

int main() {
  int a, b, c; cin >> a >> b >> c;
  int k;
  if( a == b & b == c )
    k = 1;
  else if( a == b or b == c or c == a )
    k = 2;
  else
    k=3;
  cout << k;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a;
	int b;
	scanf("%d %d",&a,&b);
	if(a<b){
		printf("a < b\n");
	}
	else if(a>b){
		printf("a > b\n");
	}
	else if(a==b){
		printf("a == b\n");
	}
	return 0;
	
}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
    return s << "(" << p.first << ", " << p.second << ")";
}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s << "[";
    for (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

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

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

    sort(ALL(a));

    int min_a = a[0],
        max_a = a[N - 1];
    if (max_a - min_a > 1) {
        cout << "No" << endl;
        return 0;
    }

    int p = 0, q = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] == min_a) p++;
        else q++;
    }

    if (min_a == max_a) {
        if (min_a == N - 1 || min_a <= N / 2) cout << "Yes" << endl;
        else cout << "No" << endl;
    } else {
        if (p + q / 2 >= max_a && p + 1 <= max_a) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int area = a*b;
    int length = 2*(a+b);
    System.out.println(area+" "+length);
    sc.close();
  }
}



Measured memory_bytes: 26112
import sys
import heapq
from collections import defaultdict


def main():
    input = sys.stdin.readline
    
    N, M = map(int, input().split())

    table = defaultdict(list)
    for i in range(N):
        A, B = map(int, input().split())
        table[A].append(-B)

    candidate = []
    heapq.heapify(candidate)

    ret = 0

    for i in range(1, M+1):
        for value in table[i]:
            heapq.heappush(candidate, value)
        if len(candidate) > 0:
            ret -= heapq.heappop(candidate)

    print(ret)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 73052
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;
	cin>>a>>b;
	if(a==1||b==1){
		cout<<"1"<<endl;
		return 0;
	}
	ll k=(a+1)/2;
	ll an=k*((b+1)/2);
	an+=(a/2)*(b/2);
	cout<<an;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S(vector).size()
using namespace std;
typedef long long ll;

int serch(vector<int> &a, int n, int key){
	int i = 0;
	a[n] = key;
	while(a[i] != key) i++;
	if(i != n) return i; else return MOD;
}


int main(void){
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	rep(i, m) cin >> x[i];

	if(n >= m) cout << 0 << endl;
	else {

	SORT(x);

	ll cnt = 0;

	vector<int> dis(m - 1), disCopy(m - 1);
	rep(i, m - 1) {
		dis[i] = x[i + 1] - x[i];
		disCopy[i] = dis[i];
	}

	SORT(dis);

	int hozon[n - 1];
	vector<int> hozon_ite;
	for(int i = n - 2; i >= 0; i--){
		hozon[i] = dis[dis.size() - i - 1];
	}

	disCopy.push_back(0);
	for(int i = 0; i < n - 1; i++)
		hozon_ite.push_back( serch(disCopy, m - 1, hozon[i]) );

	vector<int> comaPos;
	comaPos.push_back(0);
	rep(i, n - 1) comaPos.push_back(hozon_ite[i] + 1);

	rep(i, n - 1) cnt += x[comaPos[i + 1] - 1] - x[comaPos[i]];
	cnt += x[m - 1] - x[comaPos[n - 1]];

	cout << cnt << endl;

  }

	return 0;
}


Measured memory_bytes: 2936