akhauriyash/Code-Regression huggingface dataset:
use std::io;


fn main() {
    let (n, m) = {
        let i = read::<isize>();
        (i[0], i[1])
    };

    let mut ab = Vec::new();
    let mut cd = Vec::new();

    for _ in 0..n {
        let i = read::<isize>();
        ab.push((i[0], i[1]));
    }

    for _ in 0..m {
        let i = read::<isize>();
        cd.push((i[0], i[1]));
    }

    for &(a, b) in &ab {
        let mut dist = 20isize.pow(9);
        let mut ans = 0;
        for i in 0..cd.len() {
            let (c, d) = cd[i];
            let tmp_dist = (c - a).abs() + (d - b).abs();
            if tmp_dist < dist {
                dist = tmp_dist;
                ans = i + 1;
            }
        }
        println!("{}", ans);
    }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

using namespace std;

using ull = unsigned long long;

// レベルnのx層目までに何枚パティがあるか
ull solve(int n, ull x, vector<ull> &len, vector<ull> &cnts) {
  if (x == 0) {
    return 0;
  }

  if (n == 0) {
    return 1;
  }

  if (x <= len[n - 1] + 1) {
    return solve(n - 1, x - 1, len, cnts);
  } else if (x == len[n - 1] + 2) {
    return cnts[n - 1] + 1;
  } else {
    x -= len[n - 1] + 2;
    ull ans = cnts[n - 1] + 1 + solve(n - 1, x, len, cnts);
    return ans;
  }
}

int main(int argc, const char *argv[]) {
  int n;
  ull x;
  cin >> n >> x;

  vector<ull> len(n + 1);
  len[0] = 1;
  for (int i = 1; i <= n; ++i) {
    len[i] = len[i - 1] * 2 + 3;
  }

  // cnts[i]: レベルiにパティが何枚あるか
  vector<ull> cnts(n + 1);
  cnts[0] = 1;
  for (int i = 1; i <= n; ++i) {
    cnts[i] = cnts[i - 1] * 2 + 1;
  }

  cout << solve(n, x, len, cnts) << '\n';

  return 0;
}

Measured memory_bytes: 3600
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] arr = sc.nextLine().split(" ");
        sc.close();

        Map<Integer, Integer> countMap = new HashMap<>();

        for (String val : arr) {
            Integer count = countMap.get(Integer.parseInt(val));
            if (Objects.isNull(count)) {
                countMap.put(Integer.parseInt(val), 0);
            }else{
            countMap.put(Integer.parseInt(val), count++);
            }
        }

        if (countMap.size() == 2) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }

}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif

using namespace std;

inline bool check(int w, int limit, const vector<int> &x, const vector<int> &sum) {
	const int n = x.size();

	int mn_next = n;
	int mx_next = n;
	int cnt = 0;
	vector<bool> dp(n + 1, false);
	dp[n] = true;

	for(int i = n - 1; i >= 0; --i) {
		if(sum[n] - sum[i] + 1 * (mn_next - i - 1) <= w) {
			dp[i] = true;
			continue;
		}

		while(sum[mn_next - 1] - sum[i] + 1 * (mn_next - i - 2) > w) {
			if(dp[--mn_next]) --cnt;
		}

		while(sum[mx_next - 1] - sum[i] + limit * (mx_next - i - 2) >= w) {
			if(dp[--mx_next]) ++cnt;
		}

		if(cnt) dp[i] = true;
	}

	return dp[0];
}

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

	for(int w, n; cin >> w >> n && w;) {
		vector<int> x(n);
		for(auto &e : x) cin >> e;

		vector<int> sum(n + 1);
		partial_sum(begin(x), end(x), sum.begin() + 1);

		int L = 0, R = w;
		while(L + 1 < R) {
			const int M = (L + R) / 2;
			if(check(w, M, x, sum)) {
				R = M;
			}
			else {
				L = M;
			}
		}

		cout << R << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1588
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

const int NMAX = 8;
bool graph[NMAX][NMAX];

int dfs(int v,int N,bool visited[NMAX]);
int main(){
	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		graph[a - 1][b - 1] = true;
		graph[b - 1][a - 1] = true;
	}

	bool visited[NMAX];
	for (int i = 0; i < N; i++) {
		visited[i] = false;
	}
	visited[0] = true;

	cout << dfs(0,N,visited) << endl;

	return 0;
}

int dfs(int v,int N,bool visited[NMAX]) {

	//cout << "now: " << v+1 << endl;
	bool all_visited = true;
	for (int i = 0; i < N; i++) {
		if (visited[i] == false) {
			all_visited = false;
		}
	}
	if (all_visited) {
		//cout << "return all_visited" << endl;
		return 1;
	}

	int ret = 0;

	for (int i = 0; i < N; i++) {
		//cout << "v, i: " << v << ", " << i << ": " << graph[v][i] << ", " << visited[i] << endl;
		if (graph[v][i] && !visited[i]) {
			visited[i] = true;
			ret += dfs(i, N, visited);
			visited[i] = false;
		}
	}
	//cout << "return ret" << endl;
	return ret;
}


Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(int i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main(){
	int n;cin>>n;
	int f=0;
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			if(i*j==n)f=1;
		}
	}
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

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

int main() {
    int n,t[100],m,p,x,sum=0;
    cin>>n;
    for (int i = 0; i < n; ++i) {cin>>t[i];sum+=t[i];}
    cin>>m;
    for (int i = 0; i < m; ++i) {
        cin>>p>>x;
        cout<<sum-t[p-1]+x<<endl;
    }
}


Measured memory_bytes: 256
n = int(input())
p = []
for i in range(n):
    x,y = map(int,input().split())
    p.append([x,y])
q = []
r = []
for i in range(n):
    q.append(p[i][0]+p[i][1])
    r.append(p[i][0]-p[i][1])
q.sort()
r.sort()
ans = max(abs(q[-1]-q[0]),abs(r[-1]-r[0]))
print(ans)

Measured memory_bytes: 130752
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>
typedef long long ll;

using namespace std;

int main(){
	ll n,k;
	cin>>n>>k;
	n%=k;
	if(n<k){
		if(n<k-n){
			cout<<n;
		}
		else{
			cout<<k-n;
		}
	}
}



Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>
#include<string>

using namespace std;
int main (){
	string s;
	cin>>s;
	if (s.at(0) ==s.at(1) && s.at(1) ==s.at(2)){
		printf("No");
	}
	else{
		printf("Yes");
	}
}


Measured memory_bytes: 256
# cook your dish here
a,b = map(int,input().split())

if b < 0:
    if (b-a)% 2 == 0:
        print("Negative")
    else:
        print("Positive")
elif a == 0 or b == 0:
    print("Zero")
elif a < 0:
    print("Zero")
else:
    print("Positive")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define MOD 998244353
#define MAXN 52
#define MAXH 20
#define MAXM 52
#define INF 100000000
#define ll long long
#define ull unsigned long long
#define RNG rng mt19937(time(NULL))
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	int n;
	cin >> n;
	vector<int> v(n);
	cu(i,0,n)cin >> v[i];
	int ans = MOD;
	cu(i,0,n){
		int lsum = 0;
		cu(j,0,i)lsum +=v[j];
		int rsum = 0;
		cu(j,i,n)rsum +=v[j];
		ans = min(ans, abs(rsum - lsum));
	}
	cout << ans << '\n';
}


Measured memory_bytes: 256
/* ナップザック問題 */

#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

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

  vi v(N+1), w(N+1);
  for(int i=1;i<=N;i++)cin>>v[i]>>w[i];

  vi dp(W+1, 0);

  for(int i=1; i<=N; i++){
    for(int j=1; j<=W; j++){ //j前から
      if(j>=w[i]){
        dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
      }
    }
  }
  cout<<dp[W]<<endl;
}

int _main(){
  int N,W;
  cin>>N>>W;
  vi v(N+1), w(N+1); //価値v 重さw
  for(int i=1; i<=N; i++){
    cin>>v[i]>>w[i];
  }

  vvi dp(N+1, vi(W+1, 0)); //品物iまでで重さj以内で収める時の価値の最大値

  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][j-w[i]]+v[i]);
      }else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }

  int ans = dp[N][W];

  cout<<ans<<endl;
}


Measured memory_bytes: 3148
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
int x[100005], y[100005], t[100005];

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;

    int tim = 0;
    int cx = 0, cy = 0;
    bool flag = true;

    REP(i,0,N){
        cin>>t[i]>>x[i]>>y[i];

        int d = abs(cx - x[i]) + abs(cy - y[i]);
        if(d <= t[i] - tim) {
            if (((t[i] - tim) - d) % 2 == 1) {
                flag = false;
            }
        }else{
            flag = false;
        }

        tim = t[i];
        cx = x[i];
        cy = y[i];
    }

    if(flag) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


Measured memory_bytes: 1408
#include <iostream>


void reverse(int size, int *array) {
  int temp;
  for (int i = 0; i < size / 2; i ++) {
    temp = array[i];
    array[i] = array[size - i - 1];
    array[size - i - 1] = temp;
  }
}


int main() {
  int n;
  int a[1000];

  std::cin >> n;

  for (int i = 0; i < n; i ++) {
    std::cin >> a[i];
  }

  reverse(n, a);


  for (int i = 0; i < n - 1; i ++) {
    std::cout << a[i] << " ";
  }
  std::cout << a[n - 1] << std::endl;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, K, sum = 0;
    cin >> N >> K;
    vector<int> pi(N);
    for (int i=0; i<N; i++){
        cin >> pi.at(i);
    }
    sort(pi.begin(), pi.end());
    for (int j=0; j<K; j++){
        sum += pi.at(j);
    }
    cout << sum << endl;
    return 0;
    

}

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

void setup()
{
    //cinでファイルから読込
    ifstream in("./input.txt");
    cin.rdbuf(in.rdbuf());

    //cinの高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main()
{
    int n;
    cin >> n;
    vector<string> s(n);
    map<string, int> map{};
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        map[s[i]]++;
    }

    long long ans = 0;
    for (auto m : map)
    {
        int num = m.second;
        ans += (long long)num * (num - 1) / 2;
    }

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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

int VMAX = 1000;
ll MAX = 10000000000000;

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

    string s, t;
    cin >> s >> t;
    int N = s.length();
    int M = t.length();

    vi dprow(M+1, 0);
    vvi dp(N+1, dprow);

    // dp[i][j] = longest subseq of s[:i] and t[:j]
    // dp[i][j] = max(dp[i][j-1], dp[i-1][j])

    vvi par_s(N+1, dprow);
    vvi par_t(N+1, dprow);

    for(int i=1;i<=N;i++) {
        for(int j=1;j<=M;j++) {
            if (dp[i-1][j] > dp[i][j]) {
                dp[i][j] = dp[i-1][j];
                
                par_s[i][j] = par_s[i-1][j];
                par_t[i][j] = par_t[i-1][j];
            }

            if (dp[i][j-1] > dp[i][j]) {
                dp[i][j] = dp[i][j-1];

                par_s[i][j] = par_s[i][j-1];
                par_t[i][j] = par_t[i][j-1];
            }
            if(s[i-1] == t[j-1] && dp[i-1][j-1] + 1 > dp[i][j]) {
                dp[i][j] = dp[i-1][j-1] + 1;

                par_s[i][j] = i;
                par_t[i][j] = j;
            }
        }
    }

    vector<char> ans;
    int i = par_s[N][M];
    int j = par_t[N][M];

    while (i!=0 && j!=0) {
        assert(s[i-1] == t[j-1]);
        ans.push_back(s[i-1]);

        int ni = par_s[i-1][j-1];
        int nj = par_t[i-1][j-1];
        i = ni;
        j = nj;
    }

    reverse(ans.begin(), ans.end());

    for (char c : ans) cout << c;
    cout << endl;

    return 0;
}

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

int main() {
    int N, X;
    cin >> N >> X;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    
    vector<int> D(N + 1);
    D[0] = 0;
    REP(i, N + 1) D[i] = D[i - 1] + L[i - 1];
    int cnt = 0;
    rep(i, N + 1) if (D[i] <= X) ++cnt;
    cout << cnt << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N ;
  int j=0;
  for (int i=0; i<N ; i++){
    string s ;
    cin >> s ;
    
    if ( s =="Y" ){
      j++;
    }
  }
    if ( j>0 ) {
    cout << "Four" << endl;
   
    }
    else{
      cout << "Three" << endl;
    }
    
}
    

 








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

public class Main
{
  	int n, d, cnt = 0;
  
    Main(Scanner in, PrintWriter out)
    {
      n = in.nextInt();
      for (int i = 1; i <= n; i += 2)
      {
        d = 0;
        for (int j = 1; j*j <= i; j++)
        {
          if (i % j == 0)
            d += 2;
          if (j*j == i) d--;
        }
        
        if (d == 8) cnt++;
      }
      out.print(cnt);
    }
	
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		new	Main(in, out);
		out.close();
	} 
}

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

a = [0] * n
d = [[] for _ in range(n)]
for i in range(n):
    a[i] = int(input())
    for j in range(a[i]):
        d[i].append(tuple(map(int, input().split())))

def decode(s):
    r = [0] * n
    for i in range(n):
        r[i] = int(bool(s & (1 << i)))
    return r

def validate(s):
    r = decode(s)
    for i in range(n):
        if not r[i]:
            continue
        for x, y in d[i]:
            if r[x - 1] != y:
                return 0
    return sum(r)

def solve():
    ans = 0
    for i in range(2 ** n):
        ans = max(ans, validate(i))
    print(ans)

solve()


Measured memory_bytes: 45404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
int c[500], s[500], f[500]; 
int main() {
	int n;
	cin >> n;
	rep(i,500) f[i] = 1;
	rep(i,n-1) cin >> c[i] >> s[i] >> f[i];
	
	rep(i,n) {
		if (i == n-1) {cout << 0 << endl; continue;}
		int time = s[i] + c[i]; // 今は駅i+1にいる
		if (i == n-2) {cout << time << endl;  continue;}
		
		for (int j = i+1; j < n; j++)
		{
			if (time < s[j]) {
				time = s[j];
			} else if (time % f[j] > 0) {
				int rem = time % f[j];
				time += (f[j]-rem);
			} 
			
			time += c[j];
		}
		cout << time << endl;

	}
	return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
 int gcd(int a, int b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int main(){
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll l=c*d/gcd(c,d);
  if (a%(c)==0||a%d==0)
  {
    /* code */
    cout<<(b-a+1)-((b/c+b/d-b/(l))-(a/c+a/d-a/(l))+1)<<endl;
  }
  else 
  {
    cout<<(b-a+1)-((b/c+b/d-b/(l))-(a/c+a/d-a/(l)))<<endl;
  }

  
  
  
}

Measured memory_bytes: 256
A = [input().split() for i in range(3)]
N = int(input())

B = [input() for _ in range(N)]

result = False

for x in range(len(B)):
    for y in range(3):
        for z in range(3):
            #print(A)
            #print(B[x])
            if A[y][z] == B[x]:
                A[y][z] = 0

for i in range(3):
        if A[i][0] == A[i][1] == A[i][2]:
            result = True
            break

for i in range(3):
        if A[0][i] == A[1][i] == A[2][i]:
            result = True
            break

if A[0][0] == A[1][1] == A[2][2] or A[0][2] == A[1][1] == A[2][0]:
    result = True
    
#print(A)

if result == False:
    print("No")
else:
    print("Yes")


    

Measured memory_bytes: 3064
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr = (input.trim()).split("\n");

const binarySearch = (key, arr, N) => {
  let mid;
  let left = 0;
  let right = N;
  if (key < arr[0] || arr[N-1] < key) return 0;
  while (left < right) {
    mid = Math.floor((left + right) / 2);
    if (key < arr[mid]) right = mid;
    else if (key > arr[mid]) left = mid + 1;
    else return 1;
  }
  return 0;
}


(function main() {
  const N1 = Number(Arr[0]);
  const arr1 = Arr[1].split(" ").map(Number);
  // const N2 = Number(Arr[2]);
  const arr2 = Arr[3].split(" ").map(Number);
  console.log(arr2.map(e => binarySearch(e, arr1, N1)).reduce((a, b) => a + b, 0));
})();



Measured memory_bytes: 34932
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  int N, M;
  cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

bool isPrime(int n){
  for(int i=2; i <= std::sqrt(n); i++){
    if(n%i == 0){ return false; }
  }
  return true;
}

int main()
{
  int n, count = 0;
  int x;
  std::cin >> n;

  for (int i=0; i < n; i++)
    {
      std::cin >> x;
      if( isPrime(x) == true  ){ count++; }
  }
  std::cout << count << std::endl;
}



Measured memory_bytes: 3036
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------
 
double d1,d2;
int X1,Y1,X2,Y2;
int N;
int XX[202020],YY[202020];
 
vector<int> LIS(vector<int>& v) {
	int i,N=v.size();
	vector<int> dp(N,1<<30),id(N);
	FOR(i,v.size()) {
		id[i] = lower_bound(dp.begin(),dp.end(),v[i]) - dp.begin();
		dp[id[i]] = v[i];
	}
	int nl = *max_element(id.begin(),id.end());
	vector<int> ret(nl+1);
	FOR(i,N) if(id[N-1-i] == nl) ret[nl--] = v[N-1-i];
	return ret;
}
 
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	double PI=atan(1)*4;
	d1=20-20*PI/4;
	d2=20*PI/2-20;
	
	cin>>X1>>Y1>>X2>>Y2;
	cin>>N;
	FOR(i,N) {
		cin>>XX[i]>>YY[i];
		if(XX[i]<min(X1,X2) || XX[i]>max(X1,X2) || YY[i]<min(Y1,Y2) || YY[i]>max(Y1,Y2)) i--,N--;
	}
	
	X2-=X1;
	Y2-=Y1;
	vector<pair<int,int>> V;
	FOR(i,N) {
		XX[i]-=X1;
		if(X2<0) XX[i]=-XX[i];
		YY[i]-=Y1;
		if(Y2<0) YY[i]=-YY[i];
		V.push_back({XX[i],YY[i]});
	}
	if(X2<0) X2=-X2;
	if(Y2<0) Y2=-Y2;
	
	double ret=100.0*(X2+Y2);
	if(N) {
		vector<int> V2;
		
		sort(ALL(V));
		FORR(v,V) V2.push_back(v.second);
		auto V3=LIS(V2);
		
		if(V3.size()==min(X2,Y2)+1) {
			ret+=d2-d1*(V3.size()-1);
		}
		else {
			ret-=d1*V3.size();
		}
	}
	_P("%.12lf\n",ret);
	
	
}
 
 
int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}

Measured memory_bytes: 6768
using System;
class Program
 {
        static void Main(string[] args)
        {
          int K,X;
            string[] str = Console.ReadLine().Split(' ');
            K = int.Parse(str[0]);
            X = int.Parse(str[1]);
            if(500*K>=X){
            Console.WriteLine("Yes");
          }else{
            Console.WriteLine("No");
          }
        }
 }

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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> ma;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.at(i) = tmp;
		ma[tmp]++;
	}
	long long ans = 0;
	for (auto x : ma) {
		long long tmp = x.second;
		ans += (tmp * (tmp - 1)) / 2;
	}

	for (int i = 0; i < N; i++) {
		long long tmp = ma.at(A.at(i));
		long long cnt = ans;
		if (tmp == 1) {
			cout << ans << endl;
			continue;
		}
		cnt -= (tmp * (tmp - 1)) / 2;
		cnt += ((tmp - 1) * (tmp - 2)) / 2;
		cout << cnt << endl;
	}
}

Measured memory_bytes: 8320
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        sc.close();

        int ans = (A - 1) * (B - 1);
        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=4e5+5;
int main()
{
	int n,i;
	char s[maxn],t[maxn];
	scanf("%d",&n);
	scanf("%s%s",s+1,t+1);
	for(i=1;i<=n;i++)printf("%c%c",s[i],t[i]);
	puts("");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        int a = 0;
        int z = 0;
        
        while (s.charAt(a) != 'A') {
            a++;
        }
        for (int i = a + 1; i < s.length(); i++) {
            if (s.charAt(i) == 'Z') {
                z = i;
            }
        }
        System.out.println(z-a+1);
    }
}


Measured memory_bytes: 25392
H,W = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(H)]
# a[i][j]としてアクセス
N = 0
t = []

for i in range(H-1):
    for j in range(W):
        if a[i][j]% 2 == 1:
            if j < W-1 and a[i][j+1]%2 == 1:
                a[i][j] -= 1
                a[i][j+1] += 1
                N +=1
                t.append(str(i+1)+" "+str(j+1)+" "+str(i+1)+" "+str(j+2))
            else:
                a[i][j] -= 1
                a[i+1][j] += 1
                N +=1
                t.append(str(i+1)+" "+str(j+1)+" "+str(i+2)+" "+str(j+1))
# flag = Falseなら偶
for j in range(W):
    if a[H-1][j]%2==1 and j < W-1:
        N +=1
        t.append(str(H)+" "+str(j+1)+" "+str(H)+" "+str(j+2))
        a[H-1][j] -= 1
        a[H-1][j+1] += 1

print(N)
for i in range(N):
    print(t[i])


Measured memory_bytes: 16344
#include<cstdio>
#define mod 998244353
typedef long long ll;
ll inv[300005],c[300005];
int main()
{
	ll n,a,b,k,ans=0;scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	inv[1]=1;for(ll i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	c[0]=1;for(ll i=1;i<=n;i++) c[i]=c[i-1]*(n-i+1)%mod*inv[i]%mod;
	for(ll i=0,j;i<=n;i++)
	{
		if(a*i>k) break;
		if((k-a*i)%b==0) j=(k-a*i)/b; else continue;
		if(j>n) continue;
		ans+=c[i]*c[j]%mod,ans%=mod;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N, K; cin >> N >> K;
	vector<int> h(N);
	for(int i = 0; i < N; i++) cin >> h[i];
	vector<int> dp(N, inf);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < N; i++) {
		for(int k = 1; k <= min(i, K); k++) {
			dp[i] = min(dp[i], dp[i - k] + abs(h[i] - h[i - k]));
		}
	}
	cout << dp[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 3968
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

	class Program
	{
		static void Main(string[] args)
		{
			string [] values  = Console.ReadLine().Split(' ');
			double W = double.Parse(values[0]);
			double H = double.Parse(values[1]);
			double x = double.Parse(values[2]);
			double y = double.Parse(values[3]);

			double solution = (W * H)/2;
			int uniqueness = 0;
			if (W/2==x && H/2==y)
			{
				uniqueness = 1;
			}
			Console.WriteLine(solution + " " + uniqueness);

	}
}


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


#define SENTINEL 1000000000

int count = 0;

void mergeSort(int A[], int left, int right) {
	int i, mid;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}



void merge(int A[], int left, int mid, int right) {
	int n1, n2, i, j, k;
	int *L, *R;
	n1 = mid - left;
	n2 = right - mid;
	L = (int *)malloc(sizeof(int)*(n1 + 1));
	R = (int *)malloc(sizeof(int)*(n2 + 1));
	for (i = 0; i <= n1 - 1; i++) {
		L[i] = A[left + i];
	}
	for (j = 0; j <= n2 - 1; j++) {
		R[j] = A[mid + j];
	}
	L[n1] = SENTINEL;
	R[n2] = SENTINEL;
	i = 0;
	j = 0;
	for (k = left; k <= right - 1; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i];
			i++;
			count++;
		}
		else {
			A[k] = R[j];
			j++;
			count++;
		}
	}
	free(L);
	free(R);
}


main() {
	int A[500000];
	int B[500000];
	int C[500000];
	long long int result=0;
	long long int num[500000];
	long long int sum[500000];
	long long int sum2[500000];
	long long int num2[500000];
	int n, k=0;

	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &C[i]);
	}
	mergeSort(A, 0, n);
	mergeSort(B, 0, n);
	mergeSort(C, 0, n);
	for (int i = 0; i < n; i++) {
		for (int j = k; j < n; j++) {
			if (B[i] < C[j]) {
				
					num[i] = n - j ;
					if (i == 0) {
						sum[i] = num[i];
					}
					else {
						sum[i] = sum[i - 1] + num[i];
					}
				break;
			}
          
			k++;
		}
      if (i == 0) {
						sum[i] = num[i];
					}
					else {
						sum[i] = sum[i - 1] + num[i];
					}
	}
	k = 0;
	for (int i = 0; i < n; i++) {
		for (int j = k; j < n; j++) {
			if (A[i] < B[j]) {
				if (j == 0) {
					num2[i] = sum[n - 1];
				}
				else {
					num2[i] = sum[n - 1] - sum[j - 1];
                  	
				}
              
				if (i == 0) {
					sum2[i] = num2[i];
	
				}
				else { sum2[i] = num2[i] + sum2[i - 1]; }
                
				break;
			}
			k++;
		}
          if (i == 0) {
						sum2[i] = num2[i];
					}
					else {
						sum2[i] = sum2[i - 1] + num2[i];
					}
          
          }
	
	printf("%lld", sum2[n-1]);
	return 0;
}


Measured memory_bytes: 19184
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner num = new Scanner(System.in);
        while(true) {
            int m = num.nextInt();
            int f = num.nextInt();
            int r = num.nextInt();

            if (m == -1 && f == -1 && r == -1) break;

            int sum = m + f;

            if(m == -1 || f == -1) System.out.println("F");
            else if(sum >= 80) System.out.println("A");
            else if(sum >= 65) System.out.println("B");
            else if(sum < 30) System.out.println("F");
            else if(sum >= 50 || r >= 50) System.out.println("C");
            else if(sum >= 30) System.out.println("D");
        }
    }
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    char c;
    cin>>c;
    if(c<='Z')
        cout<<'A';
    else
        cout<<'a';
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int ans = 1000;
        for (int i = 0; i <= s.length() - 3; i++) {
            ans = Math.abs(Integer.valueOf(s.substring(i, i + 3)) - 753) < ans
                    ? Math.abs(Integer.valueOf(s.substring(i, i + 3)) - 753)
                    : ans;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
vector<int> dy={-1,0,1,0};
vector<int> dx={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int n;
    cin>>n;
    int ans=0,BA=0,BX=0,XA=0;
    rep(i,n) {
        string s;
        cin>>s;
        int m=sz(s);
        if(s[0]=='B' && s[m-1]=='A') BA++;
        else if(s[0]=='B') BX++;
        else if(s[m-1]=='A') XA++;
        
        rep(j,m-1) {
            if(s[j]=='A' && s[j+1]=='B') ans++;
        }
    }
    
    if(BA>0) {
        ans+=(BA-1);
        if(BX>0) {
            ans++;
            BX--;
        }
        if(XA>0) {
            ans++;
            XA--;
        }
    }
    ans+=min(XA,BX);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 10000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

//////////

signed main()
{
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	string s[n];
	vector<string> v;
	int c=0;
	for(int i=0;i<n;++i){
		cin>>s[i];
		string a="aa";
		a[0]=s[i][0];
		a[1]=s[i][s[i].length()-1];
		v.push_back(a);
		for(int j=1;j<s[i].length();++j)
		{
			if(s[i][j]=='B'&&s[i][j-1]=='A')
				++c;
		}
	}
	int bx=0,xa=0,ba=0;
	for(int i=0;i<v.size();++i)
	{
		if(v[i][1]=='A'&&v[i][0]=='B'){
			++ba;
			continue;
		}
		if(v[i][0]=='B')
			++bx;
		if(v[i][1]=='A')
			++xa;
	}
	c+=min(bx,xa);
	if(ba!=0){
		c+=ba-1;
		if(bx||xa)
			++c;
	}
	cout<<c;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll x;
	cin >> x;
	ll xx = x;
	FOR(i,1,xx+1){
		x -= i;
		if(x<=0){
			cout << i << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

using ll = long long;
using ld = long double;

#ifdef EBUG
#define debug(x) cout << "\033[31m" << #x << ": " << x << "\033[0m\n";
#else
#define debug(x)
#endif

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

ll n, k, d, ta, r;
bool a[105];

int main() {
  cin >> n >> k;
  rep(i, k) {
    cin >> d;
    rep(j, d) {
      cin >> ta;
      a[ta - 1] = true;
    }
  }
  rep(i, n) {
    if (!a[i]) {
      r++;
    }
  }
  cout << r << endl;
}

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

bool check(int x, vi &a, vi &f, int k){
  int n = sz(a);
  int res = 0;
  rep(i, 0, n){
    int l = -1, r = 1e9;
    while(r-l > 1){
      int m = (l+r)/2;
      if(max(0LL, a[i]-m)*f[i] <= x) r = m;
      else l = m;
    }
    res += r;
  }
  return res <= k;
}

signed main(){
  int n, k;
  cin >> n >> k;

  vi a(n), f(n);
  rep(i, 0, n) cin >> a[i];
  rep(i, 0, n) cin >> f[i];

  sort(all(a));
  sort(all(f));
  reverse(all(f));

  int l = -1, r = 1e13;
  while(r-l > 1){
    int m = (l+r)/2;
    if(check(m, a, f, k)) r = m;
    else l = m;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 3328
int n,a,b,M[1<<20]={1},i,k;main(){scanf("%d%d%d",&n,&a,&b);if(n>1L*a*b||n<a+b-1)puts("-1");else{int N=b,C=n;while(1){for(i=N;i>N-b;--i){if(a==C){for(k=0;k<=n;++k)if(!M[k])printf("%d ",k);exit(0);}C--;printf("%d ",i);M[i]=1;}a--;N=n<N+b?n:N+b;}}}

Measured memory_bytes: 2944
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
string A;
int S[200001][26];
int dp[200001];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> A;
  N = A.length();

  rep(i, 26) S[N][i] = N;
  for (int i=N-1; i>=0; i--) {
    rep(j, 26) S[i][j] = S[i+1][j];
    S[i][A[i]-'a'] = i;
  }

  rep(i, N+1) dp[i] = INF;
  dp[N] = 0;
  for (int i=N-1; i>=0; i--) {
    rep(j, 26) {
      //if (A[i]-'a' == j) continue;
      dp[i] = min(dp[i], dp[S[i+1][j]]+1);
    }
  }

  int L = INF;
  rep(i, 26) L = min(L, 1 + dp[S[0][i]]);
  //cout<<"L="<<L<<"\n";
  //rep(i, N)cout<<dp[i]<<",";cout<<"\n";
  string o = "";
  int pos = 0;
  rep(i, L) {
    int t = -1;
    assert(pos <= N);
    rep(j, 26) {
      //assert(S[pos][j] <= N);
      int to = S[pos][j];
      if (dp[min(to, N)] <= L-1-i) {
        pos = min(to+1, N);
        //cout<<"pos="<<pos<<"\n";
        t = j;
        break;
      }
    }
    assert(t != -1);
    o += (char)('a'+t);
  }
  assert(o.size() == L);
  cout << o << "\n";
  return 0;
}


Measured memory_bytes: 21652
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  for(int i=1; i<=N; i++){
    if((i*108)/100 == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it;}cout<<endl;}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {

    ll n;
    cin>>n;
    vector<ll> v(n);
    cin>>v;
    ll sum = 0;
    rep(i, 61){
        ll a=0,b=0;
        for(auto it:v){
            if(it>>i & 1) a++;
            else b++;
        }
        ll tmp = a*b;
        tmp%=1000000007;
        rep(j, i){
            tmp *=2;
            tmp%=1000000007;
        }
        sum+=tmp;
        sum%=1000000007;
    }
    pr(sum);
}


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

using ll = long long;

int n, ans;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	vector <pair<int, int>> seg(n+1);
	int L = 0, R = 1e9;
	for (int i=1; i<=n; i++) {
		cin >> seg[i].first >> seg[i].second;
		ans = max(ans, seg[i].second-seg[i].first+1);
		L = max(L, seg[i].first);
		R = min(R, seg[i].second);
	}
	ans += max(0, R-L+1);
	sort (seg.begin(), seg.end(), 
		[](const pair<int, int>& x, const pair<int, int>& y) {
			return (x.second < y.second);
		}
	);
	vector <int> suff(n+1), pref(n+1);
	L = 0, R = 1e9;
	for (int i=n; i>1; i--) {
		L = max(L, seg[i].first);
		R = seg[i].second;
		suff[i] = max(0, R-L+1);
	}
	R = seg[1].second;
	L = 0;
	for (int i=1; i<n; i++) {
		L = max(seg[i].first, L);
		pref[i] = max(0, R-L+1);
	}
	for (int i=1; i<n; i++) {
		ans = max(ans, pref[i]+suff[i+1]);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1792
N,M = map(int,input().split())
a = [list(map(int,input().split())) for i in range(N)]
c = [list(map(int,input().split())) for i in range(M)]
for i in range(N):
    ans = 0
    now = 10**10
    for j in reversed(range(M)):
        if abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])<=now:
            ans = j+1
            now = abs(a[i][0]-c[j][0])+abs(a[i][1]-c[j][1])
    print(ans)

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int h,w,G[105][105],n;
priority_queue<int> que;
int main()
{
    scanf("%d%d%d",&h,&w,&n);
    for (int i=0;i<n;++i) {
        int t;
        scanf("%d",&t);
        while (t--)
            que.push(i+1);
    }
    for (int i=0;i<h;++i) {
        if (i&1) {
            for (int j=0;j<w;++j) {
                G[i][j]=que.top();
                que.pop();
            }
        } else {
            for (int j=w-1;j>=0;--j) {
                G[i][j]=que.top();
                que.pop();
            }
        }
    }
    for (int i=0;i<h;++i)
        for (int j=0;j<w;++j)
            printf("%d%c",G[i][j],j+1==w?'\n':' ');
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string x;
  cin >> x;// >> a >> b;
  int ans = 0;
  if(x.at(0)=='1'){ans++;}
   if(x.at(1)=='1'){ans++;}
   if(x.at(2)=='1'){ans++;}
  //if(x==1){ans++;}
  //if(b==1){ans++;}
  //else{cout << a << endl;}
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<queue>
#include<set>

typedef std::vector<std::set<int>> graph_t;



int main()
{
	int N, M;
	std::cin >> N >> M;
	graph_t graph(N);
	for (int i{}; i < M; ++i)
	{
		int a, b;
		std::cin >> a >> b;
		--a;
		--b;
		graph[a].emplace(b);
		graph[b].emplace(a);
	}
	int Q;
	std::cin >> Q;

	int rest = N;
	struct data_t
	{
		int vertex;
		int dist;
		int color;
	};
	std::vector<data_t> query(Q);
	struct result_t
	{
		int dist = -1;
		int color = 0;
	};
	std::vector<result_t> result(N);
	std::function<void(int,int,int)> check = [&](int dist,int now,int color)
	{
		if (result[now].dist >= dist)
		{
			return;
		}
		else 
		{
			if (result[now].dist == -1)
			{
				--rest;
				result[now].color = color;
			}
			result[now].dist = dist;
		}
		for (int v : graph[now])
		{
			check(dist - 1, v, color);
		}
	};
	for (int i{}; i < Q; ++i)
	{
		auto& q = query[i];
		std::cin >> q.vertex >> q.dist >> q.color;
		--q.vertex;
	}
	for (int j = 1; j <= Q; ++j)
	{
		int i = Q - j;
		auto const& q = query[i];
		check(q.dist, q.vertex, q.color);
		if (rest == 0)
		{
			break;
		}
	}
	for (auto const& v : result)
	{
		std::cout << v.color << std::endl;
	}
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 998244353;
const ll  maxn = 1e6 + 5;
const int N = 3050;

ll n,s,a[N],f[N];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	ll res=0;
	for(int i=1;i<=n;i++){
		f[0]++;
		for(int j=s;j>=a[i];j--){
			f[j]=(f[j]+f[j-a[i]])%mod;
		}
		res=(res+f[s])%mod;
	}
	cout<<res<<'\n';
	return 0;
}

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

int main() {
    unsigned long long A;
    long double B;
    cin >> A >> B;
    cout << (long long)(A * B) << endl;
    return 0;
}

Measured memory_bytes: 3728
import sys
import numpy as np

def power_table(MOD, w, size):
    w_table = [0] * size
    w_table[0] = 1
    for i in range(1, size):
        w_table[i] = w_table[i - 1] * w % MOD
    return w_table

def numpy_ntt(MOD, w_table, data, scale=None):
    size = data.size
    step = 1
    while step < size:
        batch_size = size // (step * 2)
        data = data.reshape(step * 2, -1)
        odd = data[0::2]
        even = data[1::2]
        w1 = w_table[0:size // 2:batch_size]
        w2 = w_table[size // 2:size:batch_size]
        sub1 = (odd + even * w1) % MOD
        sub2 = (odd + even * w2) % MOD
        data = np.concatenate((sub1, sub2))
        step *= 2
    if scale is not None:
        data = data * scale % MOD
    return data.flatten()

def read_data():
    int_list = [int(s) for s in sys.stdin.read().split()]

    n = int_list[0]

    graph = [[] for _ in range(n)]
    for i in range(0, (n - 1) * 2, 2):
        a = int_list[i + 1] - 1
        b = int_list[i + 2] - 1
        graph[a].append(b)
        graph[b].append(a)

    size_table = [1] * n

    ret = 0
    stack = [None, 0, 0]

    while True:
        node = stack[-1]
        index = stack[-2]
        size_table[node] += ret
        if index < len(graph[node]):
            dtr = graph[node][index]
            stack[-2] += 1
            if dtr != stack[-3]:
                stack.extend((0, dtr))
            ret = 0
        else:
            del stack[-2:]
            if len(stack) <= 1: break
            ret = size_table[node]

    g = [0] * n
    for s in size_table:
        if s != n:
            g[s - 1] += 1
            g[n - s - 1] += 1
    return (n, g)


def solve():
    MOD = 924844033

    def pow_mod(a, n):
        ret = 1
        while n != 0:
            if n % 2 == 1: ret = ret * a % MOD
            a = a * a % MOD
            n //= 2
        return ret

    n, answer = read_data()

    fac = [0] * (n + 1)
    fac[0] = 1
    for i in range(1, n + 1):
        fac[i] = fac[i - 1] * i % MOD

    ifac = [0] * (n + 1)
    ifac[n] = pow_mod(fac[n], MOD - 2)
    for i in range(n, 0, -1):
        ifac[i - 1] = ifac[i] * i % MOD

    def comb(x, y):
        return fac[x] * ifac[y] % MOD * ifac[x - y] % MOD

    for i in range(n):
        answer[i] = answer[i] * fac[i + 1] % MOD
    answer.reverse()

    ntt_size = 1
    while ntt_size <= n * 2: ntt_size *= 2

    w_table = power_table(MOD, pow_mod(5, MOD // ntt_size), ntt_size)

    np_w_table = np.array(w_table).reshape(-1, 1)
    ifac_ntt = numpy_ntt(MOD, np_w_table, np.array(ifac[:n] + [0] * (ntt_size - n)))
    answer_ntt = numpy_ntt(MOD, np_w_table, np.array(answer + [0] * (ntt_size - n)))

    answer_ntt = answer_ntt * ifac_ntt % MOD

    for i in range(1, ntt_size // 2):
        w_table[i], w_table[ntt_size - i] = w_table[ntt_size - i], w_table[i]
    answer = numpy_ntt(MOD, np.array(w_table).reshape(-1, 1), answer_ntt, pow_mod(ntt_size, MOD - 2)).tolist()

    for i in range(1, n + 1):
        a = n * comb(n, i)
        b = answer[n - i] * ifac[i]
        print((a - b) % MOD)

solve()


Measured memory_bytes: 109188
#include <stdio.h>

int main() {
	int i, j, n, m, max = 0;
	int game[1000], judge[1000], ticket[1000] = { 0 };
	scanf("%d %d", &n, &m);
	for( i = 0; i < n; i++) scanf("%d", &game[i]);
	for( i = 0; i < m; i++) scanf("%d", &judge[i]);
	for( i = 0; i < m; i++){
		for( j = 0; j < n; j++) {
			if( game[j] <= judge[i] ) {
				ticket[j]++;
				break;
			}
		}
	}
	for( i = 1; i < n; i++) {
		if( ticket[max] < ticket[i] ) max = i;
	}
	printf("%d\n", max + 1);
	return 0;
}

Measured memory_bytes: 608
n=int(input())  
a=list(map(int, input().split()))
a = [0]+a+[0]
d=[]
sd = 0
for i in range(1,n+2):
  l = abs(a[i]-a[i-1])
  d.append(l)
  sd +=l
for i in range(1,n+1):
  print(sd - d[i-1] - d[i] + abs(a[i+1]-a[i-1]))

Measured memory_bytes: 14048