akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Hamadneh
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BMinorChange solver = new BMinorChange();
        solver.solve(1, in, out);
        out.close();
    }

    static class BMinorChange {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String r = in.next();
            long c = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) != r.charAt(i))
                    c++;
            }
            out.print(c);
        }

    }
}



Measured memory_bytes: 41188
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2e5 + 30, Mod = 1e9 + 7;
const ll SQ = 330;

int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    ll n;
    cin >> n;
   	ll s= 0 ;
   	for (int i = 1; i <= n; i ++) {
   		if (i % 3 && i % 5)
   			s += i;
	}
	cout << s;
    return (0);
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    int n;
    cin >> n >> s;
    for(int i=0; i<s.length(); i++){
        int c = s[i]-'A';
        c = (c+n)%26;
        c+='A';
        s[i] = (char)c;
    }
    cout << s;
    return 0;
}


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

int main(){
    string c;
    cin >> c;
    if(c == "a" || c == "e" || c == "i" || c == "o" || c == "u"){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int pos[5000];
long long dp[6000][6000];
int main(){
  int n;
  long long a,b;
  scanf("%d%lld%lld",&n,&b,&a);
  for(int i=0;i<n;i++){
    int p;
    scanf("%d",&p);
    pos[p]=i+1;
  }
  for(int i=0;i<n+1;i++){
      if(i<pos[1])
        dp[1][i]=a;
      else
        dp[1][i]=0ll;
  }
  for(int x=2;x<=n;x++){
    for(int i=0;i<n+1;i++){
      dp[x][i] = (long long)1e18;
      if(i<pos[x])
        dp[x][i] = min(dp[x][i],a+dp[x-1][i]);
      else{
          dp[x][i] = min(dp[x][i], dp[x-1][pos[x]-1]);
          dp[x][i] = min(dp[x][i], b+dp[x-1][i]);
      }
    }
  }
  printf("%lld\n",dp[n][n]);
}


Measured memory_bytes: 235648
K = int(input());
A,B = list(map(int, input().split()))

res = "NG"

if A % K == 0 or B % K == 0:
  res = "OK"
else:
  for i in range(A, B+1):
    if(i % K == 0):
      res = "OK"
      break

print(res)



Measured memory_bytes: 9196
import math
M = 1000000007
T = int(input())
for i in range(T):
	n = int(input())
	r = 0
	for i in range((n-5)%2,12,2):
		r+=math.comb(11,i)%M*math.comb((n-i+25)//2,15)%M;
	print(r%M)

Measured memory_bytes: 9148
#include <stdio.h>

#define MAX 1000

int main() {

  int A[MAX],n,i;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(i!=1) printf("parent key = %d, ",A[i/2]);
    if(i*2<=n) printf("left key = %d, ",A[i*2]);
    if(i*2+1<=n) printf("right key = %d, ",A[i*2+1]);
    printf("\n");
  }

  return 0;

}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9
typedef long long ll;
using VI = vector<int>;
using VS = vector<string>;
using graph = vector<vector<int>>;
int main()
{
string a;
cin>>a;
if (a.at(0)=='7'||a.at(1)=='7'||a.at(2)=='7')
{
    cout<<"Yes"<<endl;
}
else
{
    cout<<"No"<<endl;
}

    return 0;
}

Measured memory_bytes: 3624
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n))
        self.ranks = [0 for _ in range(n)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


n, m = ril()
uf = UnionFind(n)
for _ in range(m):
    x, y, z = ril()
    uf.merge(x - 1, y - 1)
res = set()
for i in range(n):
    res.add(uf.get_root(i))
print(len(res))

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

typedef unsigned long long ull;

bool isValid(ull v){
    while(v>=10){
        int diff = v%100/10 - v%10;
        if(abs(diff) > 1) return false;
        v /= 10;
    }
    return true;
}

void update_candidates(ull n, map<ull, ull>& candidates){
    ull c = 0;
    ull prev = 0;
    while(c < n*10){
        ull r = c%n;
        if(n==1 || r==n-1) c++;
        else               c += candidates[r] - r;
        if(isValid(c)){
            candidates[prev] = c;
            prev = c;
        }
    }
}

int main()
{
    ull K;
    cin >> K;
    map<ull, ull> cand;
    for(ull n=1; n < 1e+11; n *= 10){
        update_candidates(n, cand);
    }
    auto res = (*next(cand.begin(), K)).first;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 36608
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=100005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	double A,B,H,M; cin>>A>>B>>H>>M;
	double angle1 = 30 * (H + M/60);
	double angle2 = 6 * M;
	//db(angle1), db(angle2);
	double PI = 3.141592653589793238462643383279502884;
	double rad = PI * (angle1-angle2) / 180;
	cout.precision(17);
	double ans = sqrt(A*A+B*B-2*A*B*cos(rad));
	cout<<ans;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s;
    cin >> s;
    for(char c = 'a'; c <= 'z';c++){
        bool flag = true;
        rep(i, s.size())
        {
            if(s[i]==c)
                flag = false;
        }
        if(flag){
            cout << c << endl;
            return 0;
        }
    }
    cout << "None" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define mii map<int, int>
#define msi map<string, int>
#define pb push_back
#define mp make_pair
#define coutp cout<<fixed<<setprecision
#define FOR(n) for(int i=0;i<n;i++)
#define M 1000000007
#define imin INT_MIN
#define imax INT_MAX
#define SIEVE 100000

int n,m,k,a,b,mx=imin,mn=imax,mxi,mni;
double x,y;
string s,s1,s2;
vector<bool> prime(SIEVE+1,1);
vi primes;

void precomputation();
void solve();
void solvecase();
void sieve();
int pow(int, unsigned int, int);
bool miillerTest(int, int);
bool isPrime(int, int);


int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	clock_t start_time = clock();
	precomputation();
	solve();
	clock_t end_time = clock();
  	double elapsed_secs = double(end_time - start_time) / CLOCKS_PER_SEC;
	cerr<<elapsed_secs<<"\n";
	return 0;

}

void solvecase(){
    cin>>a;
    cout<<a+pow(a,2)+pow(a,3);
}

void solve(){
	int T=1;
	//cin>>T;
	for(int i=1;i<=T;i++)
	{
		//cout<<"Case #"<<i<<":"<<" ";
		solvecase();
		cout<<"\n";
	}
}

void precomputation(){
}

void sieve(){
	prime[0]=0;
	prime[1]=0;
	for(int i=2;i<=SIEVE;i++){
		if(prime[i]){
			primes.pb(i);
			for(int j=i+i;j<=SIEVE;j+=i){
				prime[j]=0;
			}
		}
	}
	sort(primes.begin(),primes.end());
}

int pow(int X, unsigned int Y, int P)
{
	int res = 1;
	X = X % P;
	while (Y > 0)
	{
		if (Y & 1)
			res = (res*X) % P;
		Y = Y>>1;
		X = (X*X) % P;
	}
	return res;
}

bool miillerTest(int D, int N)
{
	int A = 2 + rand() % (N - 4);
	int X = pow(A, D, N);
	if (X == 1 || X == N-1)
	return true;
	while (D != N-1)
	{
		X = (X * X) % N;
		D *= 2;
		if (X == 1)	 return false;
		if (X == N-1) return true;
	}
	return false;
}

bool isPrime(int N, int K)
{
	if (N <= 1 || N == 4) return false;
	if (N <= 3) return true;
	int D = N - 1;
	while (D % 2 == 0)
		D /= 2;
	for (int i = 0; i < K; i++)
		if (!miillerTest(D, N))
			return false;
	return true;
}


Measured memory_bytes: 4180
#include<map>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
long long i,n,m,sum;
int main(){
	scanf("%lld %lld",&n,&m);
	for(i=n;i<=m;i*=2){
		sum++;
	}
	printf("%lld",sum);
}

Measured memory_bytes: 256
n, x = map(int, input().split())
xs = list(map(int, input().split()))
ds = []
for i in range(n):
  if xs[i]-x < 0:
    ds.append((xs[i]-x)*(-1))
  else:
    ds.append(xs[i]-x)
nums = sorted(list(set(ds)))
if n==1 or len(nums)==1:
  print(nums[0])
  quit()
else:
  cnd = []
  for j in range(len(nums)-1):
    a = nums[j+1]
    b = nums[j]
    while b>0:
      a,b = b, a%b
    cnd.append(a)
  print(min(cnd))

Measured memory_bytes: 17836
/*
g++ -std=c++11 -Wall -O2 -o main.exe main.cpp
./main.exe
*/

#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <climits>
//intの最大値: INT_MAX
//longの最大値: LONG_MAX
//long longの最大値: LLONG_MAX
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
#include <complex>
#include <numeric>
//最大公約数: gcd()
//最小公倍数: lcm()

#define ll long long int

using namespace std;

template <typename T>
string itos(T val){ //数値を文字列(string)に変換
	stringstream ss;

	ss << val;
	return ss.str();
}

int stoi(string s){ //文字列(string)を数値に変換
	stringstream ss;
	int val = 0;

	ss << s;
	ss >> val;
	return val;
}

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::less<T>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::greater<T>());
    return;
}

//------------------------------------------------------------------------------

int main(){
	int h, w;
	cin >> h >> w;

	vector<string> s(h);
	vector<bool> flag(w, true);
	bool flag2 = true;

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

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] != '.'){
				flag2 = false;
				break;
			}
		}
		if(flag2){
			s.erase(s.begin() + i);
			h--;
			i--;
		}
		flag2 = true;
	}

	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			if(s[i][j] != '.'){
				flag[j] = false;
			}
		}
	}

	for(int i = 0; i < w; i++){
		if(flag[i]){
			flag.erase(flag.begin() + i);

			for(int j = 0; j < h; j++){
				s[j].erase(i, 1);
			}

			i--;
			w--;
		}
	}

	for(int i = 0; i < s.size(); i++){
		cout << s[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using i64 = int64_t;

constexpr i64 inf = 987654321987654321LL;
              // 0  1  2  3  4  5  6  7  8  9
vector<int> v = {0, 1, 2, 3, 4, 5, 5, 4, 3, 2};

int cmp(int x, int y) {
  if(x <  y) { return 0; }
  if(x == y) { return 1; }
  return 2;
}

i64 f(string s) {
  s = "0" + s;
  int n = static_cast<int>(s.size());
  // dp[未満/丁度/超過][繰り上がったか] := 最小枚数
  vector<vector<i64>> dp(3, vector<i64>(2, inf));
  dp[1][0] = 0;
  for(int i=n-1; i>=0; --i) {
    vector<vector<i64>> ndp(3, vector<i64>(2, inf));
    for(int flag=0; flag<3; ++flag) {
      for(int carry=0; carry<2; ++carry) {
        if(dp[flag][carry] == inf) { continue; }
        for(int yd=0; yd<10; ++yd) { // X - N を決める
          int nflag = cmp(yd, s[i] - '0');
          if(nflag == 1) { nflag = flag; }
          int xd     = (yd + carry + (s[i] - '0')) % 10, // X が決まる
              ncarry = (yd + carry + (s[i] - '0')) / 10;
          ndp[nflag][ncarry] = min(ndp[nflag][ncarry], dp[flag][carry] + v[yd] + v[xd]);
        }
      }
    }
    dp = ndp;
  }
  i64 res = inf;
  for(int flag=0; flag<2; ++flag) {
    res = min(res, dp[flag][0]);
  }
  return res;
}

int main(void) {
  string s; cin >> s;
  i64 res = f(s);
  printf("%ld\n", res);
  return 0;
}

Measured memory_bytes: 2308
#include <stdio.h>

int main(void)
{
	int N;
	int a[2000];
	int b[2000];
	int c[2000];
	int i;
	int sanhei[2000];
	int syahen[2000];
	
	scanf("%d", &N);
	
	for (i = 0; i < N; i++){
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
		
		if ((a[i] - b[i] >= 0) && (a[i] - c[i] >= 0)){
			syahen[i] = a[i];
			sanhei[i] = b[i] * b[i] + c[i] * c[i];
		}
		else if ((b[i] - a[i] > 0) && (b[i] - c[i] >= 0)){
			syahen[i] = b[i];
			sanhei[i] = a[i] * a[i] + c[i] * c[i];
		}
		else if ((c[i] - b[i] > 0) && (c[i] - a[i] > 0)){
			syahen[i] = c[i];
			sanhei[i] = a[i] * a[i] + b[i] * b[i];
		}
		
		if (sanhei[i] == syahen[i] * syahen[i]){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
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  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n, m;
    cin >> n >> m;
    VVL xyz(n, VL(3));
    rep(i,n) cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];

    ll ans = 0;
    rep(i, 1<<3){
        VI sgn(3, 1);
        rep(j, 3) if (i>>j & 1) sgn[j] *= -1;

        VL sums(n);
        rep(j,n){
            rep(k,3) sums[j] += xyz[j][k] * sgn[k];
        }
        sort(rall(sums));
        ll sum = 0;
        rep(j,m) sum += sums[j];

        ans = max(ans, sum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3656
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x:i64  = read();
    println!("{}", if x >= 30 {"Yes"} else {"No"});
}


Measured memory_bytes: 2140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int n;
    int k;
    cin >> n >> k;
    vector<int> l(n);
    int result = 0;
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    sort(l.begin(), l.end(), greater<int>());
    for(int i = 0; i < k; i++){
        result = result + l[i];
    }
    cout << result << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)


def dfs(v):
    if cache[v] > -1:
        return cache[v]
    lv = links[v]
    cache[v] = ret = max(map(dfs, lv)) + 1 if lv else 0
    return ret


n, m = map(int, input().split())
links = [set() for _ in range(n)]
cache = [-1] * n
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    links[x - 1].add(y - 1)

print(max(map(dfs, range(n))))


Measured memory_bytes: 100488
#include<iostream>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  int n,m; cin >>n >>m;
  
  dsu g(n);
  rep(i,m){
    int a,b; cin >>a >>b;a--; b--;
    if(df)print(a,b);
    g.merge(a,b);
  }
  vector<vector<int>> s=g.groups();
  print(s.size()-1);
}


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

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(ll i=0; i<n; i++)
        cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    ll mi = n&1 ? a[n/2] : (a[n/2] + a[(n-1)/2]);
    sort(b.begin(), b.end());
    ll ma = n&1 ? b[n/2] : (b[n/2] + b[(n-1)/2]);
    cout << ma - mi + 1 << endl;
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  string ans="APPROVED";
  for(int i=0; i<N; i++){
  	int a;
    cin >> a;
    if((a%2==0)&&(a%3!=0)&&(a%5!=0))ans="DENIED";
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
# define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
const ll MOD = 998244353;
int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll N,S;
    cin>>N>>S;
    vector<ll> A(N);

    rep(i,N){
        cin>>A[i];
    }

    vector<unordered_map<ll,ll>> mp_v(N);
    ll ans=0;
    rep(i,N){
        if(i==0){
            mp_v[0][0]=1;
            if(A[i]<=S){
                ++mp_v[0][A[i]]=1;
            }
        }else{
            for(auto v :mp_v[i-1]){
                if(v.first==0){
                    mp_v[i][v.first]+=v.second;
                    if(v.first+A[i]<S){
                        mp_v[i][v.first+A[i]]+=v.second;
                        mp_v[i][v.first+A[i]]+=i;
                    }
                    if(v.first+A[i]==S){
                        ans += (i+1)*(N-i);
                        ans = ans%MOD;
                    }
                }else{
                    mp_v[i][v.first]+=v.second;
                    if(v.first+A[i]<S){
                        mp_v[i][v.first+A[i]]+=v.second;
                        mp_v[i][v.first+A[i]]%=MOD;
                    }
                    if(v.first+A[i]==S){
                        ans += (v.second*(N-i))%MOD;
                        ans%=MOD;
                    }
                }
            }    
        }
        if(mp_v[i].find(S)!= mp_v[i].end()){
            ans += mp_v[i][S]*(N-i);
        }
        
    }
    
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 367232
#include <bits/stdc++.h>
 
using namespace std;
 
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
 
class Point {
public:
    double x, y;
 
    Point(double x = 0, double y = 0) : x(x), y(y) {}
 
    Point operator + (Point p)
    {
	return Point(x + p.x, y + p.y);
    }
 
    Point operator - (Point p)
    {
	return Point(x - p.x, y - p.y);
    }
 
    Point operator * (double k)
    {
	return Point(x * k, y * k);
    }
 
    double norm()
    {
	return x * x + y * y;
    }
};
 
struct Segment {
    Point p1, p2;
};
 
typedef Point Vector;
 
double dot(const Point &a, const Point &b)
{
    return a.x * b.x + a.y * b.y;
}
 
Point project(Segment s, Point p)
{
    Vector base = s.p2 - s.p1;
    double t = dot(p - s.p1, base) / base.norm();
    return s.p1 + base * t;
}
 
Point reflect(Segment s, Point p)
{
    return p + (project(s, p) - p) * 2.0;
}
 
int main()
{
    Point p1, p2, q;
 
    while (scanf("%lf,%lf,%lf,%lf,%lf,%lf"
		,&p1.x ,&p1.y, &p2.x ,&p2.y ,&q.x ,&q.y) != EOF) {
 
	Segment s = {p1, p2};
	Point p = reflect(s, q);
 
	printf("%.6f %.6f\n", p.x, p.y);
    }
    return 0;
}

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

using namespace std;

const int maxh = 2e5+10;
const int maxn = 3e3+10;
const int mod = 1e9+7;

int h, w, n;
long long int dp[maxn], fact[maxh], frev[maxh];

long long int power(long long int b, long long int p){
	if (p == 0)
		return 1;
	if (p == 1)
		return b;
	if (p == 2)
		return b*b%mod;
	if (p & 1)
		return power(power(b, p/2), 2) * b % mod;
	return power(power(b, p/2), 2);
}

long long int comb(int r, int n){
	return (frev[r] * frev[n-r] % mod) * fact[n] % mod;
}

int main(){
	cin >> h >> w >> n;
	fact[0] = 1;
	frev[0] = 1;
	for (int i = 1; i < maxh; i++){
		fact[i] = fact[i-1] * i % mod;
		frev[i] = power(fact[i], mod-2);
	}

	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++){
		int x, y;
		cin >> x >> y;
		v.push_back(make_pair(x-1, y-1));
	}

	v.push_back(make_pair(h-1, w-1));
	sort(v.begin(), v.end());

	for (int i = 0; i < v.size(); i++){
		int x = v[i].first;
		int y = v[i].second;
		dp[i] = comb(x, x+y);
		for (int j = 0; j < i; j++){
			int xt = v[j].first;
			int yt = v[j].second;
			if (xt <= x && yt <= y){
				dp[i] = ((dp[i] - dp[j] * comb(x-xt, x+y-xt-yt) % mod) + mod) % mod;
			}
		}
	}

	cout << ((dp[v.size()-1] % mod) + mod) % mod << endl;
	return 0;
}


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

using namespace std;

int main(){
  
  string s;
  cin>>s;
  string t = "ACGT";
  int ans = 0;
  int count = 0;
  for(int i=0;i<s.size();i++){
    
    bool ok = false;
    for(int j=0;j<t.size();j++){
      if(s.at(i)==t.at(j)){
        ok = true;
      }
    }
    
    if(ok){
      count++;
      ans = max(ans,count);
    }
    else{
      count = 0;
    }
  }
  cout<<ans<<endl;
      
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
typedef double dd;
#define For(i,j,k) for (int i=(int)j;i<=(int)k;++i)
#define Forr(i,j,k) for (int i=(int)j;i>=(int)k;--i)
#define Set(a,p) memset(a,p,sizeof(a))
using namespace std;

template<typename T>bool chkmax(T &a,T b) { return a<b?a=b,1:0; }
template<typename T>bool chkmin(T &a,T b) { return a>b?a=b,1:0; }

const int maxn=3e5+1e2;
const int N=3e5;
const int modd=998244353;
int n;
int Ans;
ll a,b,k;
int fac[maxn],inv[maxn];

inline void file() {
	freopen("AGC025B.in","r",stdin);
	freopen("AGC025B.out","w",stdout);
}

inline int quick(int a,int b) {
	int s=1;
	while (b) {
		if (b%2==1) s=1ll*s*a%modd;
		a=1ll*a*a%modd; b/=2;
	}
	return s;
}

inline void init() {
	fac[0]=inv[0]=1;
	For (i,1,N) fac[i]=1ll*fac[i-1]*i%modd;
	inv[N]=quick(fac[N],modd-2);
	Forr (i,N-1,1) inv[i]=1ll*inv[i+1]*(i+1)%modd;
}

inline void Add(int &a,int b) {
	a+=b;
	a=(a>=modd?a-modd:a); a=(a<0?a+modd:a);
}

inline int C(int n,int m) {
	if (n<m) return 0;
	return 1ll*fac[n]*inv[m]%modd*inv[n-m]%modd;
}

int main() {
//	file();
	init();
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	For (i,0,n) {
		if (a*i>k) break;
		if ((k-a*i)%b!=0) continue;
		int j=(k-a*i)/b;
//		For (l,0,min(i,j))
//			if (i+j-l<=n)
//				Add(Ans,1ll*C(n,i+j-l)*fac[i+j-l]%modd*inv[i-l]%modd*inv[j-l]%modd*inv[l]%modd);
		Add(Ans,1ll*C(n,i)*C(n,j)%modd);
	}
	printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する


int main() {
  ll n,k,h,w;
  ll a,b;
  cin >> a ;
  // string s;
  // cin >> s;
  // vector<ll> a(n,0);
  // cin >> a;

  ll ans = 180 * (a-2);




  cout << ans <<endl;

  
  // cout << (true? "Yes":"No");


}




















Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"


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

	int n;
	cin>>n;
	vi d(10010);
	loop(i,1,110)loop(j,1,110)loop(k,1,110){
		int a=i*i+j*j+k*k+i*j+j*k+k*i;
		d[min(a,10009ll)]++;
	}
	rep(i,n)cout<<d[i+1]<<endl;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  string s,t;
  cin>>s;
  cin>>t;
  int r=0;
  REP(i,3) {
    if(s[i]==t[i]) r+=1;
  }
  pr(r);
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, raw_input().split())
a = map(int, raw_input().split())

a.sort()

sum = 0
itr = 0
for i in range(N):
  sum = sum+a[i]
  if sum >= M:
    itr = i
    break
    
    
if sum < M:
  print N-1
elif sum == M:
  print itr+1
elif sum > M:
  print itr

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;
/*}}}*/


void solve(){

    int n;
    cin >> n;

    float ans = (n+1)/2;
    double ans1 = ans/n;

    printf("%.10f\n", ans1);

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,i,ans=1e9;
  cin>>n>>k;
  vector<int> h(n);
  for(i=0;i<n;i++) cin>>h.at(i);
  sort(h.begin(),h.end());
  for(i=0;i<=n-k;i++) if(h.at(i+k-1)-h.at(i)<ans) ans=h.at(i+k-1)-h.at(i);
  cout<<ans<<endl;
}

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

li = list(input())

r_count = li.count('R')

ideal_li = list('W' for _ in range(len(li)))

for i in range(r_count):
    ideal_li[i] = 'R'

unmatch_count = 0
for i in range(len(li)):
    if li[i] != ideal_li[i]:
        unmatch_count += 1

print(unmatch_count // 2)


Measured memory_bytes: 12100
#include<stdio.h>

int n,A[2000];

int main(){
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&M);
    if(solve(0,M)==1)printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i,int m){
  int answer;
  if(m==0)return 1;
  if(i>=n)return 0;
  answer = solve(i+1,m) || solve(i+1,m-A[i]);
  return answer;
}

Measured memory_bytes: 580
#include<iostream>

using namespace std;

int main(void) {

	int h, w, x, y;

	while (1)
	{
		cin >> h >> w;

		if (h == 0 && w == 0)
			break;

		for (x = 0; x < w; x++)
			cout << "#";

		cout << endl;
		
		for (y = 0; y < h-2; y++)
		{
			cout << "#";
			for (x = 0; x < w -2; x++)
			{
				cout << ".";
			}
			cout << "#";
			cout << endl;
		}
		for (x = 0; x < w; x++)
			cout << "#";

		cout << endl << endl;

	}


	return 0;
}


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

namespace ABC168
{
    class Program
    {
        static void Main(string[] args)
        {
            b();
        }

        public static void b()
        {
            int k = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            if(s.Length <= k)
            { Console.WriteLine(s);}
            else
            {
                for(int i = 0; i < k; i++)
                {
                    Console.Write(s[i]);
                }
                Console.WriteLine("...");
            }
        }
    }
}


Measured memory_bytes: 27532
until (m = $<.gets.to_i).zero?
  poly1 = (m - 1).times.map {$<.gets.to_i}
  poly1 << 360 - poly1.sum
  n = $<.gets.to_i
  poly2 = (n - 1).times.map {$<.gets.to_i}
  poly2 << 360 - poly2.sum
  
  area1 = poly1.map {|i| Math.sin(i / 180.0 * Math::PI)}.sum
  area2 = poly2.map {|i| Math.sin(i / 180.0 * Math::PI)}.sum
  
  result = if area1 == area2
    0
  elsif area1 > area2
    1
  else
    2
  end
  puts result
end


Measured memory_bytes: 6936
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>

using namespace std;
const int mod = 1e9 + 7;
class Matrix{
public:
	int m[3][3];
	Matrix () {memset(m , 0 , sizeof m);}
};

Matrix mul(const Matrix m1 , const Matrix m2){
	Matrix ret;
	for(int k = 0 ; k < 3 ; ++ k)
		for(int i = 0 ; i < 3 ; ++ i){
			int d = m1.m[i][k];
			for(int j = 0 ; j < 3 ; ++ j)
				ret.m[i][j] = (ret.m[i][j] + 1ll * d * m2.m[k][j]) % mod;
		}
	return ret;
}

const int maxn = 1e5 + 10;
int imp[maxn] , n , m;

Matrix tran1 , tran2 , st , tran , O;
void init(){
	tran1.m[0][0] = tran1.m[2][0] = 1;
	tran1.m[0][1] = tran1.m[1][1] = tran1.m[2][1] = 1;
	tran1.m[0][2] = 1;
	tran1.m[1][2] = tran1.m[2][2] = 2;
	tran2 = tran1;
	for(int i = 0 ; i < 3 ; ++ i)
		tran2.m[2][i] --; 
	st.m[0][0] = 1;
	for(int i = 0 ; i < 3 ; ++ i)
		O.m[i][i] = 1;
}

Matrix pw(Matrix t , int c){
	Matrix ret = O;
	while(c){
		if(c & 1)
			ret = mul(ret , t);
		t = mul(t , t);
		c >>= 1;
	}
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1 ; i <= m ; ++ i)
		cin >> imp[i];
	int last = 0;
	init();
	imp[0] = -1;
	for(int i = 1 ; i <= m ; ++ i){
		if(imp[i] != last){
			tran = tran1;
			st = mul(st , pw(tran , imp[i] - last));
		}
		last = imp[i] + 1;
		st = mul(st , tran2);
	}
	if(last != n){
		tran = tran1;
		st = mul(st , pw(tran , n - imp[m] - 1));
	}
	cout << st.m[0][2] << endl;
	return 0;
}

Measured memory_bytes: 640
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,m,w[N],ans;
struct edge{int y,next;}a[N<<1];int len,last[N];
void ins(int x,int y) {a[++len]=(edge){y,last[x]};last[x]=len;}

int main() {
	qr(n); qr(m);
	for(int i=1;i<=n;i++) qr(w[i]);
	for(int i=1,x,y;i<=m;i++) {
		qr(x); qr(y);
		ins(x,y);ins(y,x);
	}
	for(int i=1;i<=n;i++) {
		bool f=1;
		for(int k=last[i];k;k=a[k].next)
			if(w[i]<=w[a[k].y]) {f=0;break;}
		ans+=f;
	} pr2(ans);
	return 0;
}



Measured memory_bytes: 5976
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    ll n; cin >> n;
    string c; cin >> c;

    ll left = n - 1;
    rep(i, n){
        if(c[i] == 'W'){
            left = i;
            break;
        }
    }

    ll right = 0;
    repr(i, n){
        if(c[i] == 'R'){
            right = i;
            break;
        }
    }

    ll cnt = 0;
    bool is_finished = false;
    while(left < right){
        cnt++;
        c[left] = 'R';
        c[right] = 'W';
        
        while(c[left] == 'R'){
            left++;
            if(left == n){
                is_finished = true;
            }
        }

        while(c[right] == 'W'){
            right--;
            if(right < 0){
                is_finished = true;
            }
        }

        if(is_finished){
            break;
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    vector<int> v(N, 0);
    for(auto& e : v)
        cin >> e;
    sort(v.begin(), v.end());

    int ans = v[0];
    int i = 0;
    while(i < N)
    {
        if(ans <= v[i])
        {
            int t = v[i] % ans;
            if(t)
            {
                v[i] = ans;
                ans = t;
            }
            else
            {
                i++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int n, m ,x;
    cin >> n >> m >> x;
    vector<int> a(m);
    for(int i=0;i<m;i++){cin >> a[i];}
    int count = 0;
    int j=0;
    while(j < m){
        if(a[j] < x){
            count++;
            j++;
        }
        else{
            break;
        }
    }
    if(count <= m/2){
        cout << count << endl;
    }
    else{
        cout << m-count << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		int D = sc.nextInt();
		int cnt = 0;
		for(int m = 1 ; m <= M ; ++m){
			for(int d = 1 ; d <= D ; ++d){
				int d0 = d % 10;
				int d1 = d / 10;
				if(d0 * d1 == m && d0 >= 2 && d1 >= 2){
					++cnt;
				}
			}
		}
		System.out.println(cnt);
	}
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,a;
LL ans=0;
LL f[N],sum;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>a;
	for(int i=0;i<a&&i<=n;i++){
		if(i==0)f[0]=n/a;
		else f[i]=(n-i)/a+1;
		sum+=f[i];
	}
	if(f[0]>=3)ans+=f[0]*(f[0]-1)*(f[0]-2);
	if(f[0]>=2)ans+=3*(f[0]-1)*f[0];
	ans+=f[0];
	if(a%2==0){
		if(f[a/2]>=3)ans+=f[a/2]*(f[a/2]-1)*(f[a/2]-2);
		if(f[a/2]>=2)ans+=3*(f[a/2]-1)*f[a/2];
		ans+=f[a/2];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

struct edge{
    int to;
    ll cost;
};
vector<vector<edge>> graph(100001);
vector<ll> dp(100001,-1);

void dfs(int now, ll depth){
    if(dp[now] != -1) return;
    dp[now] = depth;
    rep(i,graph[now].size()){
        int next = graph[now][i].to;
        dfs(next,depth+graph[now][i].cost);
    }
}

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

    int n; cin >> n;
    int a,b; ll c;
    rep(i,n-1){
        cin >> a >> b >> c;
        a--; b--;
        graph[a].push_back({b,c});
        graph[b].push_back({a,c});
    }
    int q,k; cin >> q >> k;
    k--;
    dfs(k,0LL);
    vector<int> x(q),y(q);
    rep(i,q){
        cin >> x[i] >> y[i];
        x[i]--; y[i]--;
    }
    rep(i,q){
        cout << dp[x[i]] + dp[y[i]] << "\n";
    }
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int64_t MOD_NUM = 1000000000 + 7;
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    int64_t sum_ = 0;
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
        sum_ += vec[i];
        sum_ %= MOD_NUM;
    }

    int64_t ans = 0;
    for (int64_t i=0; i<N; i++) {
        sum_ -= vec[i];
        if (sum_ < 0) sum_ += MOD_NUM;
        ans += vec[i] * sum_;
        ans %= MOD_NUM;
    }

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

Measured memory_bytes: 4760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <functional>
#include <math.h>
using namespace std;

#define ll long long
//#define int long long
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

#define dump(x)  cerr << #x << " = " << (x) << endl; 
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


typedef pair<int, int> P;
struct Point{
	int x, y;
};
int dx[4] = { 0, 1, 0, -1 };
int dy[4] = {1,0,-1,0};



int main(){

	int N, M;

	cin >> N >> M;

	for (int i = M / N; i >= 1; i--){
		if (M%i == 0){
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

int main() {
  ll r, g;
  cin >> r >> g;

  cout << 2 * g - r << endl;


  return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e5+7;
const ll mod = 1e9 + 9;
#define afdafafafdafaf y1;
int ar[maxn], n, m;
int ans[maxn];
int f[maxn];

int num[maxn<<2];
ll s[maxn<<2];
void add(int x, int val){
    while(x > 0){
        s[x] += val;
        num[x]++;
        x -= x & (-x);
    }
}
pair<ll, ll> que(int x){
    ll a1 = 0, a2 = 0;
    while(x <= n){
        a1 += s[x];
        a2 += num[x];
        x += x & (-x);
    }
    return make_pair(a1, a2);
}
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        int x;
        scanf("%d", &x);
        f[x]++;
    }
    sort(f+1, f+n+1);
    //for(int i=1;i<=n;i++)cout<<f[i]<<" ";cout<<"\n";
    for(int i=1;i<=n;i++){
        add(f[i], f[i]);
    }
    for(int i=1;i<=n;i++){
        int l = 0, r = n;
        while(l < r){
            //cout<<l<<" " << r << '\n';
            int mid = l + r + 1 >> 1;
            pair<ll,ll> p = que(mid);
            ll k = n - (p.first - p.second * mid);
            //cout<<mid<<" "<<k<<"\n";
            if(k / mid >= i)l = mid;
            else r = mid - 1;
        }
        printf("%d\n", l);
    }

    return 0;
}


Measured memory_bytes: 8960
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e12;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

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

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll N;

double solve(ll A, ll B, ll C, vvvd& dp){
    if(dp[A][B][C] > 0.0) return dp[A][B][C];
    if(A == 0 && B == 0 && C == 0) return 0.0;
    
    double val = 0.0;
    double unit = 1.0 * N / (A+B+C);
    if(A > 0){
        val += 1.0 * (unit + solve(A-1, B+1, C, dp)) * A / (A+B+C);
    }
    if(B > 0){
        val += 1.0 * (unit + solve(A, B-1, C+1, dp)) * B / (A+B+C);
    }
    if(C > 0){
        val += 1.0 * (unit + solve(A, B, C-1, dp)) * C / (A+B+C);
    }
    dp[A][B][C] = val;
    return val;
}

int main(){
    cin >> N;
    vl a(N, 0); REP(i, N) cin >> a[i];
    vvvd dp(N+1, vvd(N+1, vd(N+1, 0.0)));
    vl cnt(4, 0);
    REP(i, N){
        cin >> a[i];
        cnt[a[i]]++;
    }
    solve(cnt[3], cnt[2], cnt[1], dp);
    cout << fixed << setprecision(10) << dp[cnt[3]][cnt[2]][cnt[1]] << endl;
    return 0;
}


Measured memory_bytes: 216960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

const int MAXN=1e5+5;
ll dp[MAXN];

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

    int n,W; cin>>n>>W;
    fill(dp, dp+MAXN, 1e9+5);
    dp[0] = 0;

    FOR(i,n) {
        ll w,v; cin>>w>>v;

        for(int j=MAXN-1-v; j>=0; j--) {
            dp[j+v] |= MIN(dp[j]+w);
        }
    }

    for(int j=MAXN-1; j>=0; j--) {
        if(dp[j]<=W) {
            cout<<j<<endl;
            break;
        }
    }
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h> 
 
int main() 
{ 
  int hp, at; 
  scanf("%d %d", &hp, &at); 
  
  if(hp%at == 0) 
  { 
    printf("%d\n", hp/at); 
  } 
  else 
  { 
    printf("%d\n", (hp/at)+1); 
  } 
  return 0; 
}

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

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

    vector<int> ti(n);

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

    int ans = t;
    for (int i = 0; i < n - 1; i++)
    {
        if(ti[i + 1] - ti[i] <= t)
        {
            ans += ti[i + 1] - ti[i];
        }
        else
        {
            ans += t;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import collections
import math
import operator as op
from functools import reduce
import numpy as np
import math
import bisect
import heapq


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def get_inputs(cast_func=None):
    if cast_func is None:
        return input().split()
    else:
        return list(map(cast_func, input().split()))


def get_input(cast_func=None):
    if cast_func is None:
        return input()
    else:
        return cast_func(input())


def is_prime(n):
    if n == 1:
        return False
    for i in range(2, int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


def main():
    N = get_input(int)
    A = np.zeros((10, 10), dtype=np.int32)
    for i in range(1, N+1):
        A[int(str(i)[0]), int(str(i)[-1])] += 1

    # print(A.sum())
    # print(A)
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += A[i, j] * A[j, i]

    print(ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 14468