akhauriyash/Code-Regression huggingface dataset:
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const ll mod = ((ll)1e9 + 7);
// loop
#define rep(i, n) for(ll i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(ll i = b; i < e; i++)
#define erep(i, b, e) for(ll i = b; i <= e; i++)
#define rrep(i, b, e) for(ll i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(), (v).end()
// sort
#define vsort(v, b) sort(all(v), [](auto l, auto r){return (b);})
// access
#define gt(i, n) get<n>(i)
// debug
#define debug(x) cout << (#x) << ": " << x << endl;
// function
ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
void prime(vll& v, ll n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}
ll egcd(ll a, ll b, ll& x, ll& y){if(b == 0){x = 1; y = 0; return a;} ll d = egcd(b, a % b, y, x); y -= a / b * x; return d;}

signed main(){
    int n;
    cin >> n;
    
    int cnt[60] = {0};
    ll a;
    rep(i, n){
        cin >> a;
        rep(j, 60){
            cnt[j] += a % 2;
            a /= 2;
        }
    }
    
    ll ans = 0;
    ll base = 1;
    rep(j, 60){
        ans += base * cnt[j] % mod * (n - cnt[j]) % mod;
        ans %= mod;
        base *= 2;
        base %= mod;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split()))
N = a[0]
Q = a[1]
numofac = [0 for i in range(N)]
S = input()
appear = 0
index = 1
while index < N:
    if S[index-1] == "A" and S[index] == "C":
        appear += 1
        numofac[index] = appear
        if index != N-1:
            numofac[index+1] = appear
        index += 2
    else:
        numofac[index] = appear
        index += 1
for i in range(Q):
    q = list(map(int,input().split()))
    print(str(numofac[q[1]-1] - numofac[q[0]-1]))

Measured memory_bytes: 6148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
template<typename T> using vec = vector<T>;
template<typename T> using uset = unordered_set<T>;
template<typename T,typename U> using umap = unordered_map<T,U>;
template<typename T> using pq = priority_queue<T, vector<T>, std::greater<T>>;
template<typename T> using mxpq = priority_queue<T>;
template<typename A, typename B>
A& operator--(pair<A,B>& t, int) {
    return t.first;
}
template<typename A, typename B>
B& operator++(pair<A,B>& t, int) {
    return t.second;
}
template<typename A, typename B>
istream& operator>>(istream& s, pair<A,B>& p) {
    return s>>p.first>>p.second;
}
template<typename T>
istream& operator>>(istream& s, vec<T>& p) {
    for (T& t : p) s >> t;
    return s;
}

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

    int r=7%K;
    int i=1;
    for(;i<=K&&r!=0;i++){
        r=(r*10+7)%K;
    }
    cout<<(r==0?i:-1);
}


Measured memory_bytes: 3604
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	int N;
	cin >> N;
	string S;
	cin >> S;
	S += "****";

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
	}

	cout << ans << "\n";

	return 0;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

template <typename Arg1>
void bug(Arg1&& arg1)
{ cout<<"->"<<arg1<<endl; }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll powmod(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return powmod(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

void yes(){pn("Yes");}
void no(){pn("No");}
void bug(){cout<<"here"<<endl;}

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vs vector<string>
#define vvl vector<vl>
#define vvs vector<vs>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);
#define maxpq(v) priority_queue<v>
#define minpq(v) priority_queue<v,vector<v>,greater<v>>

void solve()
{
	ll i,j;
	ll n;
	double k;
	cin>>n>>k;
	ll ans=0;
	while(n--)
	{
		ll x,y;
		cin>>x>>y;
		double temp = (double)pow(x,2)+(double)pow(y,2);
		if(temp<=(k*k))
			ans++;
	}
	pn(ans);
}

int main()
{
	#ifdef Deeksha
		// freopen("../Downloads/validation_input.txt", "r", stdin);
		freopen("../Downloads/_input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		// cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 3768
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        String dance = scan.nextLine();

        String[] ki = {"R","U","D"};
        String[] gu = {"L","U","D"};

        boolean g = false;
        for(int i=0;i<dance.length();i++){
            String step = String.valueOf(dance.charAt(i));
            if(!Arrays.asList(g?gu:ki).contains(step)){
                System.out.println("No");
                return;
            }
            g=!g;
        }
        System.out.println("Yes");
    }
}


Measured memory_bytes: 21844
N = int(input())
a = [int(i) for i in input().split()]
P=0
Q=0
R=0
for i in range(N):
    if a[i]%4==0:
        P+=1
    elif a[i]%4==2:
        Q+=1
    else:
        R+=1
if (Q==0 and R>P+1) or (Q!=0 and R>P):
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14252
class DSU:
    def __init__(self, n):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a, b):
        x, y = self.leader(a), self.leader(b)
        if x == y:
            return x
        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x
        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x
        return x

    def same(self, a, b):
        return self.leader(a) == self.leader(b)

    def leader(self, a):
        while self.parent_or_size[a] >= 0:
            a = self.parent_or_size[a]
        return a

    def size(self, a):
        return -self.parent_or_size[self.leader(a)]

    def groups(self):
        leader_buf = [self.leader(i) for i in range(self._n)]
        group_size = [0] * self._n
        for i in leader_buf:
            group_size[i] += 1
        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)
        result = [i for i in result if i]
        return result


n, q = map(int, input().split())
dsu = DSU(n)

for _ in range(q):
    t, u, v = map(int, input().split())
    if t == 0:
        dsu.merge(u, v)
    else:
        print(1 if dsu.same(u, v) else 0)


Measured memory_bytes: 76220
n = int(input())
xs = []
ys = []
for _ in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

s = 0
c = 0
for i in range(n):
    for k in range(i + 1, n):
        s += ((xs[i] - xs[k]) ** 2 + (ys[i] - ys[k]) ** 2) ** 0.5
a = s / n * 2
print(a)

Measured memory_bytes: 3064
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define roop(a,t) for(int a=0;a<t;a++) 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
int a[101];
for(int i=0;i<101;i++){a[i]=0;}
int n;
while(cin>>n){
a[n]++;
}
int ans=0;
for(int i=1;i<101;i++){
ans=max(ans,a[i]);
}
for(int i=1;i<101;i++){
if(a[i]==ans){cout<<i<<endl;}
}
	return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

  ll n, x;
  cin >> n >> x;
  ll ans = n;
  ll a = n - x, b = x;
  if (a < b) swap(a, b);
  while (b != 0) {
    ans += 2 * (a / b) * b;
    a %= b;
    swap(a, b);
  }
  cout << ans - a << endl;
}

Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

s = ns()
n = len(s)

sel = ["dreameraser", "dreamerase", "dreamer", "dream", "eraser", "erase"]
i = 0
ans = True
while i < n:
    flag = False
    for p in sel:
        if i + len(p) <= n:
            if s[i:i + len(p)] == p:
                flag = True
                i += len(p)
                break
    if not flag:
        ans = False
        break

print("YES" if ans else "NO")

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int R;
    double answer;
    cin >> R;
    const double PI = acos(-1.0);
    answer = 2*PI*R;
    cout.fixed;
    cout.precision(3);
    cout << answer;
}

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

using namespace std; 

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

	int a, b;
	cin >> a >> b;

	if(a < 10 and b < 10) {
		cout << a * b << '\n';
	}
	else {
		cout << -1 << '\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++)
#define all(x) (x).begin(), (x).end()
#define INF 1e9
typedef long long ll;

int N;
vector<ll> A, A_sort;

void solve(){
  rep(i, N){
    ll a = A[i];
    vector<ll>::iterator Amax = A_sort.end();
    if(a == *(Amax-1)){
      cout << *(Amax - 2) << endl;
    }else{
      cout << *(Amax - 1) << endl;
    }
  }
}

int main(){
  cin >> N;
  rep(i, N){
    ll a;
    cin >> a;
    A.push_back(a);
    A_sort.push_back(a); 
  }
  sort(all(A_sort));

  solve();
}

Measured memory_bytes: 4964
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  int N,K;
  while(cin>>N>>K){
    cout<<endl;
    if(N/2 < K){
      cout<<-1<<endl;
      continue;
    }
    int to[10001] = {};
    vector<int> v(N);
    REP(i,N)v[i] = i+1;
    REP(i,K){
      memset(to, -1, sizeof(to));
      int now = v[0];
      REP(j,N/2){
        to[v[j]] = v[N-1-j];
      }
      REP(j,(N-1)/2){
        to[v[N-1-j]] = v[j+1];
      }
      while(true){
        if(to[now] == -1){
          break;
        }
        printf("%d %d\n",now, to[now]);
        now = to[now];
      }
      rotate(v.begin(), v.begin()+1, v.end()); 
    }
  }
  return 0;
}

Measured memory_bytes: 996
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N;
    cin >> N;
    vector<int> A(N);
    map<int, int> mp;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        mp[A[i]] = i;
    }

    sort(A.begin(), A.end());
    int cnt = 0;
    vector<bool> mov(N);
    for (int i = 0; i < N; ++i)
        if ((mp[A[i]] ^ i) & 1)
            cnt++;

    cout << cnt / 2 << endl;

    return 0;
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <stdlib.h>
int main()
{
	char s[4];
	
	scanf("%s",s);
	
	if(s[0] == '7'||s[1] == '7'||s[2] == '7')
		printf("Yes\n");
	else printf("No\n");
	
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;vector<pair<int,int> > fri;
  for(int i=0;i<N;i++){
    int f1,f2;
    cin>>f1>>f2;
    fri.push_back(make_pair(f1,f2));
  }
  for(int i=0;i<N;i++){
    if(fri[i].first%100==0&&fri[i].second%30==0){
      cout<<((((fri[i].second)/30)+1)*5-((500-fri[i].first)/100))<<endl;
    }else if(fri[i].first%100!=0&&fri[i].second%30==0){
      cout<<((((fri[i].second)/30)+1)*5-((600-fri[i].first)/100))<<" "<<((((fri[i].second)/30)+1)*5-((500-fri[i].first)/100))<<endl;
    }else if(fri[i].first%100==0&&fri[i].second%30!=0){
      cout<<((((fri[i].second)/30)+1)*5-((500-fri[i].first)/100))<<" "<<((((fri[i].second+30)/30)+1)*5-((500-fri[i].first)/100))<<endl;
    }else if(fri[i].first%100!=0&&fri[i].second%30!=0){
      cout<<((((fri[i].second)/30)+1)*5-((600-fri[i].first)/100))<<" "<<((((fri[i].second)/30)+1)*5-((500-fri[i].first)/100))<<" "<<((((fri[i].second+30)/30)+1)*5-((600-fri[i].first)/100))<<" "<<((((fri[i].second+30)/30)+1)*5-((500-fri[i].first)/100))<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3080
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    int N;
    int[] a;

    private void solve() {
        N = nextInt();

        a = new int[N];
        for(int i = 0;i < N;i++) {
            a[i] = nextInt();
        }

        int ans = 0;
        for(int i = 0;i < N;i++) {
            ans += a[i] - 1;
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

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

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

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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


Measured memory_bytes: 23764
"""
双対セグ木
アクセスは0-indexed, 内部のツリーは 1-indexed
関数は閉区間
作用素は右から作用とする

引数：
    N: 処理する区間の長さ
    compose: 作用素を合成させる関数 (max, min, __add__,ラムダ式,関数定義など)
    UNIT: 恒等作用素
    funcval(x,f) = f(x)
"""

class segment_tree_dual:
    def __init__(self, N, compose, funcval, UNIT=None):
        self.compose = compose
        self.UNIT = UNIT
        self.funcval = funcval

        self.height = (N-1).bit_length() #木の高さ
        self.N0 = 1<<self.height #木の横幅 >= N
        self.laz = [self.UNIT]*(2*self.N0) #作用素の木
        self.val = None #値の配列

    #初期値の配列を作る
    def build(self,initial):
        self.val = initial[:]

    #laz[k] を子に伝える、
    def propagate(self,k):
        if self.laz[k] == self.UNIT: return;
        if self.N0 <= k:
            self.val[k-self.N0] = self.funcval(self.val[k-self.N0], self.laz[k])
            self.laz[k] = self.UNIT
        else:
            self.laz[(k<<1)  ] = self.compose(self.laz[(k<<1)  ],self.laz[k]);
            self.laz[(k<<1)+1] = self.compose(self.laz[(k<<1)+1],self.laz[k]);
            self.laz[k] = self.UNIT;
    
    # laz[k]およびその上に位置する作用素をすべて伝播
    def thrust(self,k):
        for i in range(self.height,-1,-1): self.propagate(k>>i)
    
    def thrust_for_update(self,k):
        while k&1 == 0: k//=2
        for i in range(k.bit_length()-1,-1,-1): self.propagate(k>>i)

    # 区間[L,R]に関数 f を作用
    def update(self, L,R,f):
        """まず伝播させる（オペレータが可換なら必要ない）"""
        L += self.N0; R += self.N0+1
        self.thrust_for_update(L)
        self.thrust_for_update(R-1)
        
        #[L,R)に対応する区間たちに関数 f を合成
        while L < R:
            if R & 1:
                R -= 1
                self.laz[R] = self.compose(self.laz[R],f)
            if L & 1:
                self.laz[L] = self.compose(self.laz[L],f)
                L += 1
            L >>= 1; R >>= 1
    
    # values[k] を取得。
    def point_get(self, k):
        res = self.val[k]
        k += self.N0
        while k:
            res = self.funcval(res, self.laz[k])
            k //= 2
        return res
    
    # values[k] = x 代入する
    def point_set(self, k): 
        self.thrust(k)
        self.val[k] = x



###########################################################################
#日経2020予選D
#https://atcoder.jp/contests/nikkei2019-2-qual/submissions/8384133 (伝播あり)
#https://atcoder.jp/contests/nikkei2019-2-qual/submissions/8384138 (伝播なし)
###########################################################################

# coding: utf-8
# Your code here!
 
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n,m = [int(i) for i in readline().split()]
lrc = [tuple(int(i) for i in readline().split()) for _ in range(m)]
lrc.sort()

compose = lambda f,g: min(f,g)
funcval = lambda x,f: min(x,f)
UNIT = INF = 10**18

seg = segment_tree_dual(n, compose, funcval, UNIT)
seg.build([0]+[INF]*(n-1))

for l,r,c in lrc:
    l -= 1
    r -= 1
    v = seg.point_get(l)
    seg.update(l+1,r,v+c)

ans = seg.point_get(n-1)

if ans != INF:
    print(ans)
else:
    print(-1)





Measured memory_bytes: 85724
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return input()
import sys
sys.setrecursionlimit(10 ** 6)
n=I()
nl=[[] for i in range(n)]
used=[False for i in range(n)]
for i in range(n-1):
    a,b,c=IL()
    nl[a-1].append([b-1,c])
    nl[b-1].append([a-1,c])
d=[None for i in range(n)]
def dfs(now,pre,dis):
    used[now]=True
    d[now]=dis
    for i in nl[now]:
        if i[0]!=pre and not used[i[0]]:
            dfs(i[0],now,dis+i[1])
    
    return
q,k=IL()
dfs(k-1,-1,0)
for i in range(q):
    x,y=IL()
    print(d[x-1]+d[y-1])

Measured memory_bytes: 140308
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return dividend / divisor;
}

inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

inline bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    
    ll res = 0;
    vector<ll> answers;
    ll count = 1;
    For(i, 1, s.length()){
        if(s[i-1] == s[i]){
            count ++;
        }else{
            answers.push_back(count);
            count = 1;
        }
    }
    if(s[s.length()-1] == s[s.length()-2]){
        answers.push_back(count);
    }else{
        answers.push_back(1);
    }
    
    rep(i, answers.size()){
//        cout << answers[i] << endl;
        rep(j, answers[i]+1){
            res += j;
        }
    }
//    cout << res << endl;
    
    int i = 0;
    if(s[0] == '>'){
        i++;
    }
    for(; i < answers.size() - 1; i += 2){
        res -= min(answers[i], answers[i+1]);
//        cout << "min:" << min(answers[i], answers[i+1]) << endl;
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define pl pair<ll,ll>
#define TC int t;cin>>t;while(t--)
#define in(n) ll n;cin>>n;
#define inarr(n) ll n;cin>>n;vector<ll>arr;
int main(void){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    in(n);in(W);
    vl w,v;
    vl dp(100004,1e18);
    for(int i=0;i<n;i++){
        in(t1);in(t2);
        w.push_back(t1);v.push_back(t2);
    }
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=100003;j>=0;j--){
            if(j>=v[i]){
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            }
        }
    }
    ll ans=0;
    for(ll i=0;i<100004;i++){
        if(dp[i]<=W){
            ans=max(ans,i);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    double res = 0;
    for(int i=0; i<N; ++i) {
        double x;
        string u;
        cin >> x >> u;
        if(u == "JPY") res += x;
        else res += x * 380000;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
  

int task = 1;
const int mxN = 2e5 + 1;
const ll mod=1000000007;

const ll modi = 998244353; 



void solve(){
  int w,s;
  cin >> s >> w;
  if(w>=s){
    cout << "unsafe" << endl;
  }
  else
    cout << "safe" << endl;

}
 
 
int main() {
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output1.txt","w",stdout);
    #endif
    // int t;cin >> t;while(t--)
        // cout << "Case #" << task << ": " ;
        solve();
        // task++;
    // }

}

Measured memory_bytes: 3636
while True:
	try:
		n=list(map(int, input().split()))#ファイルの読み込み --.py <--.txt
	except EOFError:
		break
	if n[0]>n[1]:#なくてもいいなあ
		l=n[0]
		s=n[1]
	else:
		l=n[1]
		s=n[0]
	a=l
	b=s
	r=a%b
	while r!=0:
		a=b
		b=r
		r=a%b
	GCD=int(b)
	LCM=int(l*s/b)
	print(GCD, LCM)


Measured memory_bytes: 5600
h, w = map(int,input().split())
#alist = list(map(int, input().split()))

road=[]

for i in range(h):
    row=input()
    road.append(row)

ikel=0

for i in range(h):
    for j in range(w):
        if road[i][j]=='.':
            ikel+=1

maxrecord=0

for i in range(h):
    for j in range(w):
        turn=1
        ima=1
        now=[[i, j]]
        rlist=[]
        for hh in range(h):
            rlist.append([999]*w)
        rlist[i][j]=0
        if road[i][j]=='.':
            while ima<ikel:
                koho=[]
                for nw in now:
                    if nw[0]>0:
                        koho.append([nw[0]-1, nw[1]])
                    if nw[0]<h-1:
                        koho.append([nw[0]+1, nw[1]])
                    if nw[1]>0:
                        koho.append([nw[0], nw[1]-1])
                    if nw[1]<w-1:
                        koho.append([nw[0], nw[1]+1])
                now=[]
                for kh in koho:
                    if road[kh[0]][kh[1]]=='.':
                        if rlist[kh[0]][kh[1]]>turn:
                            rlist[kh[0]][kh[1]]=turn
                            now.append([kh[0], kh[1]])
                            ima+=1
                            record=turn
                turn+=1
            if record>maxrecord:
                maxrecord=record

print(maxrecord)

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

int main() {
  int A,B,now=1;
  cin >> A >> B;
  for(int i=0;;i++){
    if(now>=B){
      cout << i << endl;
      break;
    }
    now += A-1;
  }
  return 0;
}


Measured memory_bytes: 256
a=[]
for i in range(3):
    a.append(list(map(str,input().split())))
n = int(input())
b = []
for i in range(n):
    b.append(str(input()))

for c in b:
    for i in range(3):
        for j in range(3):
            if a[i][j] == c:
                a[i][j] = 0

ans = False
for i in range(3):
    if all(a[i][j] == 0 for j in range(3)) or all(a[j][i] == 0 for j in range(3)):
        ans = True
if a[0][0] == a[1][1] == a[2][2] or a[2][0] == a[1][1] == a[0][2]:
    ans = True

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

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int func(long long j) {
  if (j < 10) return 1;

  for (int i=1;;i++) {
    j/=10;
    if (j==0) return i;

  }
}

int main()
{
  long long i,j;
  int ans = (1<<29);
  long long N;
  cin >> N;

  for (i = 1; i*i <= N; i++) {
    if (N%i == 0) {
      j = N / i;
      ans = min(ans, func(j));
    }
  }
  cout << ans;
}


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

int main() {
  int num, k;
  int tmp;
  cin >> num >> k;
  
  if(num <= k){
    cout << 1;
  }else if(k == 2){
    cout << num-1;
  }else{
    // (num -1) / (k - 1) -> 切り上げする(x + y - 1) / y
    // -> (num - 1) + (k - 1) - 1 / y -> (num - 1 + k - 2) / (k - 1)
    cout << (num - 1 + k - 2) / (k-1); 
  }
}


Measured memory_bytes: 256
//14
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    int t[100]={},s[100];
    for(int i=0;i<n;i++){
      int m;
      cin>>m>>s[i];
      while(m--){
	int s,e;
	cin>>s>>e;
	t[i]|=~0<<s-6&~(~0<<e-6);
      }
    }
    int dp[1<<16]={};
    for(int i=0;i<1<<16;i++){
      for(int j=0;j<n;j++){
	if(!(i&t[j])){
	  dp[i|t[j]]=max(dp[i|t[j]],dp[i]+s[j]);
	}
      }
    }
    cout<<*max_element(dp,dp+(1<<16))<<endl;
  }
  return 0;
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, m, d[33][33], c[505][505], f[3][33], res = inf;

signed main() {
	cin >> n >> m;
	rep(i,m) rep(j,m) cin >> d[i][j];
	rep(i,n) rep(j,n) {
		cin >> c[i][j];
		c[i][j]--;
		f[(i+j+2)%3][c[i][j]]++;
	}
	rep(i,m) rep(j,m) rep(k,m) if (i!=j && j!=k && k!=i) {
		int t = 0;
		rep(a,m) t += d[a][i] * f[0][a] + d[a][j] * f[1][a] + d[a][k] * f[2][a];
		chmin(res,t);
	}
	cout << res << ln;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a<=5){
    cout<<0;
  }
  else if(a>=6&&a<=12){
    cout<<b/2;
  }
  else{
    cout<<b;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int x,y,i,z;
    cin >> x >> y;
    
    for(i=1;i<=10000;i++){
        if(x==0 && y==0){
            break;
        }
        if(x>y){
        cout << y <<" "<< x<<endl;
        cin >> x >> y;
       
        }
        else{
          cout << x <<" "<< y<<endl;
          cin >> x >> y;
        }
    }
    
}


Measured memory_bytes: 3096
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (group, mapAccumL, intercalate)

main :: IO ()
main = do
  (h : w : k :_) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  sijs <- sequence . replicate h $ map (== '#') <$> getLine :: IO [[Bool]]
  putStrLn . intercalate "\n" . map (intercalate " " . map show) . f $ sijs

f :: [[Bool]] -> [[Int]]
f = map (concatMap (uncurry . flip $ replicate)) . col

col :: [[Bool]] -> [[(Int, Int)]]
col = col' . map g . group . snd . mapAccumL row 1
  where
    g :: [Maybe [(Int, Int)]] -> Either Int [(Int, Int)]
    g = uncurry (maybe Left (const . Right)) . ((,) <$> head <*> length)
    col' :: [Either Int [(Int, Int)]] -> [[(Int, Int)]]
    col' ((Left l0) : (Right r) : (Left l1) : rest) = replicate (l0 + 1 + l1) r ++ col' rest
    col' ((Left l0) : (Right r) : rest) = replicate (l0 + 1) r ++ col' rest
    col' ((Right r) : (Left l0) : rest) = replicate (1 + l0) r ++ col' rest
    col' ((Right r) : rest) = [r] ++ col' rest
    col' _ = []

row :: Int -> [Bool] -> (Int, Maybe [(Int, Int)])
row n = row' n . concatMap (g . ((,) <$> head <*> length)) . group
  where
    g :: (Bool, Int) -> [(Bool, Int)]
    g (True, l) = replicate l (True, 1)
    g p = [p]
    row' :: Int -> [(Bool, Int)] -> (Int, Maybe [(Int, Int)])
    row' n ((False, l0) : (_, l1) : (False, l2) : rest) = (((n, l0 + l1 + l2) :) <$>) <$> row' (succ n) rest
    row' n ((False, l0) : (_, l1) : rest) = (((n, l0 + l1) :) <$>) <$> row' (succ n) rest
    row' n ((False, _) : _) = (n, Nothing)
    row' n ((_, l0) : (False, l1) : rest) = (((n, l0 + l1) :) <$>) <$> row' (succ n) rest
    row' n ((_, l0) : rest) = (((n, l0) :) <$>) <$> row' (succ n) rest
    row' n _ = (n, Just [])

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

const int N = 108;

int n;
int a[N], b[N];

int main() {
	int i, mid;
	scanf("%*d%d", &n);
	for (i = 0; i < n; ++i) scanf("%d", a + i);
	if (n == 1) return *a == 1 ? puts("1\n1\n1") : printf("%d\n2\n1 %d\n", *a, *a - 1), 0;
	mid = std::partition(a, a + n, [] (const int x) -> bool {return x % 2;}) - a;
	if (mid > 2) return puts("Impossible"), 0;
	a[n] = *a;
	for (i = 1; i <= n; ++i) printf("%d%c", a[i], i == n ? 10 : 32);
	memcpy(b + 1, a + 1, n << 2), ++b[1], --b[n], n -= !b[n];
	printf("%d\n", n);
	for (i = 1; i <= n; ++i) printf("%d%c", b[i], i == n ? 10 : 32);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  //入力を受け取る
  int n,i,j,min=101,max=-101,sum=0,ans=1000000;
  scanf("%d",&n);
  int a[n];
  for(i=0;i<n;++i){
    scanf("%d",&a[i]);
  }
  //最小値計算,最大値計算
  for(i=0;i<n;++i){
    if(a[i]>max)max=a[i];
    if(a[i]<min)min=a[i];
  }
  //全探索（最小値から最大値までに解は必ずある）
  for(i=min;i<=max;i++){//i=解
    for(j=0;j<n;j++){//解との差の絶対値をそれぞれに対して計算(n回繰り返し)
      sum+=abs(i-a[j])*abs(i-a[j]);
    }
    if(sum<ans){
      ans=sum;
    }
    sum=0;
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define  ll   long long int
#define  sz   20010

using namespace std;

ll num[10];

int main()
{


    ll a,b,c,x,y,n,m,i,j,k,p,s,d;

    cin>>a>>b>>c>>x>>y;

    p=a+b;

    d=min(x,y);

    n=d*2*c;
    m=(a*d)+(b*d);
    s=min(n,m);

    //cout<<s<<endl;


    if(x>y)
    {
        d=x-y;

        n=d*a;
        m=(d*c*2);
        s+=min(n,m);

    }
    else if(y>x)
    {
        d=y-x;

        n=d*b;
        m=(d*c*2);
        s+=min(n,m);

    }
    cout<<s<<endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=2e5+10;
char s[maxn];
int sta[maxn];
int main()
{
	int n,v,pre;
	scanf("%d",&n);
	scanf("%s",s+1);
	pre=0;
	for(int i=1;i<=n+n;i++)
	{
		v=s[i]=='B';
	//	cout<<v<<" "<<pre<<endl;
		if(v^pre)
		{
			sta[i]=1;
		}
		else
		{
			sta[i]=0;
		}
		pre=!pre;
	}
	for(int i=1;i<=n+n;i++)
	{
		if(!sta[i])sta[i]=sta[i-1]-1;
		else sta[i]=sta[i-1]+1;
	//		cout<<i<<" "<<sta[i]<<endl;
		if(sta[i]<0)
		{
			printf("0\n");
			return 0;
		}
	}
//	cout<<"here\n";
	if(sta[n+n]!=0)
	{
		printf("0\n");
		return 0;
	}
	ll ans=1;
	int cnt=0;
	for(int i=1;i<=n+n;i++)
		if(sta[i]==sta[i-1]-1)
		{
			ans=ans*1ll*sta[i-1]%MOD;
			cnt++;
			ans=ans*1ll*cnt%MOD;
		}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1280
import math

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y
    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)
    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)
    def __mul__(self, other):
        return Point(self.x * other, self.y * other)
    def __floordiv__(self, other):
        return Point(self.x / other, self.y / other)
    def __repr__(self):
        return str(self.x) + ' ' + str(self.y)

class Vector(Point):
    pass

class Line:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2

class Segment(Line):
    pass

def points_to_vector(p1, p2):
    x = p1.x - p2.x
    y = p1.y - p2.y
    return Vector(x, y)

def vector(p):
    return Vector(p.x, p.y)

def dot(v1, v2):
    return v1.x * v2.x + v1.y * v2.y

def cross(v1, v2):
    return v1.x * v2.y - v1.y * v2.x

def norm(v):
    return v.x**2 + v.y**2

def distance(v):
    return math.sqrt(norm(v))

def project(s, p):
    base = points_to_vector(s.p1, s.p2)
    hypo = points_to_vector(p, s.p1)
    r = dot(hypo, base) / norm(base)
    return s.p1 + base * r

def reflect(s, p):
    return p + (project(s, p) -p) * 2

def ccw(p0, p1, p2):
    EPS = 1e-10
    v1 = p1 - p0
    v2 = p2 - p0
    if cross(v1, v2) > EPS:
        return 'COUNTER_CLOCKWISE'
    elif cross(v1, v2) < -EPS:
        return 'CLOCKWISE'
    elif dot(v1, v2) < -EPS:
        return 'ONLINE_BACK'
    elif norm(v1) < norm(v2):
        return 'ONLINE_FRONT'
    else:
        return 'ON_SEGMENT'

import sys
# sys.stdin = open('input.txt')

temp = list(map(int, input().split()))
p0 = Point(temp[0], temp[1])
p1 = Point(temp[2], temp[3])
q = int(input())
for i in range(q):
    x, y = map(int, input().split())
    p2 = Point(x, y)
    print(ccw(p0, p1, p2))



Measured memory_bytes: 5728
N,M=map(int,input().split())
AB=[[int(i) for i in input().split()] for i in range(N)]
ans=0
m=0

AB.sort()

for i in range(N):
  if m==M:
    break
  if m+AB[i][1]>=M:
    for j in range(AB[i][1]):
      ans +=AB[i][0]
      m +=1
      if m==M:
        break
  else:
    ans += AB[i][0]*AB[i][1]
    m=m+AB[i][1]
    
print(ans)

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

class Main{
    public static void main(String args[])throws IOException{
        try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))){
            String s = br.readLine();
            String t = br.readLine();

            t = t.substring(0, t.length()-1);
            //System.out.println(t);

            if(s.equals(t)){
              System.out.println("Yes");
            }else{
              System.out.println("No");  
            }
        }

    }
}

Measured memory_bytes: 32576
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

class UnionFind {
    int cnt;
    vector<int> par, rank, size;
public:
    UnionFind() {}
    UnionFind(int _n) :cnt(_n), par(_n), rank(_n), size(_n, 1) {
        for (int i = 0; i<_n; ++i) par[i] = i;
    }
    int find(int k) {
        return (k == par[k]) ? k : (par[k] = find(par[k]));
    }
    int operator[](int k) {
        return find(k);
    }
    int getSize(int k) {
        return size[find(k)];
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        --cnt;
        if (rank[x] < rank[y]) {
            par[x] = y;
            size[y] += size[x];
        } else {
            par[y] = x;
            size[x] += size[y];
            if (rank[y] == rank[x]) ++rank[x];
        }
    }
    int count() {
        return cnt;
    }
};

template<class Weight>
struct KruskalMST {
    using Edges = vector<tuple<Weight, int, int>>;
    Weight sum;
    Edges mst;
    KruskalMST(int V, Edges edges) :sum(0) {
        sort(edges.begin(), edges.end());
        UnionFind uf(V);
        each(e, edges) {
            Weight w;
            int u, v;
            tie(w, u, v) = e;
            if (uf[u] != uf[v]) {
                mst.emplace_back(e);
                uf.unite(u, v);
                sum += w;
            }
        }
    }
};

int N, M, ma[4001][4001];
vector<pii> G[4001];

void dfs(int u, int s, int p=-1, int x=0) {
    ma[s][u] = x;
    each(e, G[u]) {
        if (e.first != p) {
            dfs(e.first, s, u, max(x, e.second));
        }
    }
}

void solve() {
    cin >> N >> M;

    vector<tuple<ll, int, int>> E(M);
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        E[i] = tie(c, a, b);
    }

    auto mst = KruskalMST<ll>(N, E);
    each(e, mst.mst) {
        ll ww;
        int w, u, v;
        tie(ww, u, v) = e;
        w = (int)ww;
        G[u].emplace_back(v, w);
        G[v].emplace_back(u, w);
    }

    rep(i, N)dfs(i, i);

    int Q;
    cin >> Q;
    rep(i, Q) {
        int s, t;
        cin >> s >> t;
        --s; --t;
        ll ans = mst.sum - ma[s][t];
        cout << ans << endl;
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 70548
def count(s):
    if s == 'SUN': return 7
    if s == 'MON': return 6
    if s == 'TUE': return 5
    if s == 'WED': return 4
    if s == 'THU': return 3
    if s == 'FRI': return 2
    if s == 'SAT': return 1

s = input()
print(count(s))

Measured memory_bytes: 3060
#pragma region RegionDefs
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,l,r) for(int i=(l),i##_len=(r);i<i##_len;++i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using V = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
template<class T>bool chmax(T &a, const T &b) {if (a<b) {a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if (a>b) {a=b; return 1;} return 0;}
#define y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#define YN(e) cout << ((e) ? "YES" : "NO") << endl
#define yn(e) cout << ((e) ? "Yes" : "No") << endl
#pragma endregion RegionDefs

void solve()
{
    IN(n, m);
    vector<ll> h(n);
    rep(i, n)
        cin >> h[i];
    vector<bool> g(n);
    rep(i, m)
    {
        IN(a, b); --a; --b;
        if (h[a] <= h[b]) g[a] = true;
        if (h[b] <= h[a]) g[b] = true;
    }
    ll s = 0;
    rep(i, n)
        if (!g[i])
            s++;
    cout << s << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 3992
#include<iostream>
#include<string>
#include<iomanip>

using namespace std;
int main(void) {
	int a, b, t;
	int x = 0;
	cin >> a >> b >> t;
	int i;
	for (i = 1; i <= t; i++) {
		if (i%a == 0) {
			x++;
		}

	}
	cout << b * x;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007
#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a;i<b;i++)

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

int main(){
    FASTIO
    ll n,t;
    cin>>n;
    string s;
    while(n>26){
        t=(n%26==0)?25:(n%26-1);
        s+='a'+t;
        n/=26;
        if(t==25) n--;
    }
    if(n){
    t=(n%26==0)?25:(n%26-1);
    s+='a'+t;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
    return 0;
}


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

import sys

sys.setrecursionlimit(10 ** 9)
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
INF=float('inf')

def dot(a, b):
    x1, y1 = a
    x2, y2 = b
    return x1*x2 + y1*y2

def norm(a):
    x, y = a
    return x**2 + y**2

def add(a, b):
    x1, y1 = a
    x2, y2 = b
    return (x1+x2, y1+y2)

def sub(a, b):
    x1, y1 = a
    x2, y2 = b
    return (x1-x2, y1-y2)

def mul(a, b):
    x1, y1 = a
    if not isinstance(b, tuple):
        return (x1*b, y1*b)
    x2, y2 = b 
    return (x1*x2, y1*y2)

# 線分segに対する点pの射影
def project(seg, p):
    p1, p2 = seg
    base = sub(p2, p1)
    r = dot(sub(p, p1), base) / norm(base)
    return add(p1, mul(base, r))

x1, y1, x2, y2 = MAP()
seg = ((x1, y1), (x2, y2))
Q = INT()
for i in range(Q):
    x, y  = MAP()
    res = project(seg, (x, y))
    print(*res)



Measured memory_bytes: 5732