akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using ll = long long;
const int INF_INT = 100000000;
const ll INF_LL = 1000000000000;
#define fir first
#define sec second


int main()
{
    int n,k;
    std::cin >> n >> k;
    std::cout << ((n + k - 1) / k) - (n / k) << std::endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			long a = in.nextLong(), b = in.nextLong();

			out.println(Math.max(a+b, Math.max(a-b, a*b)));

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 21460
w,h,n = map(int,input().split())

x_min = 0
x_max = w
y_min = 0
y_max = h

for i in range(n):
    x,y,a = map(int,input().split())
    if a == 1:
        if x > x_min:
            x_min = x
    elif a == 2:
        if x < x_max:
            x_max = x
    elif a == 3:
        if y > y_min:
            y_min = y
    else:
        if y < y_max:
            y_max = y

if x_min > x_max or y_min > y_max:
    print(0)
else:
    print((x_max-x_min)*(y_max-y_min))

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

using namespace std;

typedef vector<int> vi;
typedef long long ll;
typedef vector<pair<int, int>> vii;
typedef pair<int, int> ii;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	ll m = 1000;
	int mn = arr[0];
	for(int i=1;i<n;i++){
		if(arr[i]<=mn)
			mn = arr[i];
		else{
			ll candy = m/mn;
			m%=mn;
			m+=candy*arr[i];
			mn = arr[i];
		}
	}
	cout<<m;
	return 0;
}


Measured memory_bytes: 3656
xx=[]
yy=[]
n=int(input())
for ii in range(n):
    x,y=map(int,input().split())
    xx.append(x)
    yy.append(y)

dd=0.
for i1 in range(n):
    for i2 in range(n):
        dd=dd+((xx[i1]-xx[i2])**2+(yy[i1]-yy[i2])**2)**(0.5)
avedd=dd/n/(n-1)

dd2=avedd*(n-1)
print(dd2)


Measured memory_bytes: 3064
H, W = map(int, input().split())

S = []

for i in range(H):
    S.append(list(input()))

flag = True

for i in range(H):
    for j in range(W):
        s_list = []
        if S[i][j] == "#":
            # right
            if j + 1 < W:
                s_list.append(S[i][j + 1])
            # left
            if j - 1 >= 0:
                s_list.append(S[i][j - 1])
            # up
            if i - 1 >= 0:
                s_list.append(S[i - 1][j])
            # down
            if i + 1 < H:
                s_list.append(S[i + 1][j])
            if "#" not in s_list:
                # print(i, j, s_list)
                flag = False


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


Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int N =scan.nextInt();
		int L =scan.nextInt();
		int T =scan.nextInt();
		int[] X=new int[N];
		int[] W=new int[N];

		int[] x=new int[N];


		for(int i=0;i<N;i++){
			X[i]=scan.nextInt();
			W[i]=scan.nextInt();
			x[i]=X[i]+T*(3-2*W[i]);
			while(true)
			{
				if(x[i]>0)break;
				x[i]+=L;
			}
			x[i]%=L;

		}
		int x0 = x[0];
		Arrays.sort(x);

		long cnt=0;
		if(W[0]==1){
			for(int i=1;i<N;i++){
				if(W[i]==1){continue;}
					cnt+=(2*T-X[i]+X[0])/L+1;
				}
					cnt%=N;
		}else{
			for(int i=N-1;i>0;i--){
				if(W[i]==2){continue;}
					cnt-=(2*T-X[0]+X[i])/L;
				}
			while(true)
			{
				if(cnt>0)break;
				cnt+=N;
			}
			cnt%=N;
			}

		int ini=0;
		for(int i=0;i<N;i++){
			if(x[i]==x0){
				if(i<N-1&&x[i+1]==x0&&W[0]==1){
					ini = i+1 - (int)cnt;
					break;
				}
				ini = i-(int)cnt;
				break;
			}
		}

		for(int i=0;i<N;i++){
			System.out.println(x[(ini+i+N)%N]);
		}



	}

}


Measured memory_bytes: 74024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

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;
}

ll mod(ll val, ll M) {
    ll res = val % M;
    if(res < 0) {
        res += M;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int R,C,K;
ll maze[3030][3030];
ll ret[3030][3030][4];

int main() {
    cin >> R >> C >> K;
    for(int i = 0;i <= R;i++) {
        for(int j = 0;j <= C;j++) {
            maze[i][j] = 0;
        }
    }
    for(int i = 0;i < K;i++) {
        int A,B;
        ll C;
        cin >> A >> B >> C;
        maze[A][B] = C;
    }
    for(int i = 0;i <= R;i++) {
        for(int j = 0;j <= C;j++) {
            for(int k = 0;k < 4;k++) {
                ret[i][j][k] = -INF;
            }
        }
    }
    for(int i = 0;i <= C;i++) {
        ret[0][i][0] = 0;
    }
    for(int i = 0;i <= R;i++) {
        ret[i][0][0] = 0;
    }
    ret[1][1][0] = 0;
    for(int i = 1;i <= R;i++) {
        for(int j = 1;j <= C;j++) {
            for(int k = 0;k < 4;k++) {
                chmax(ret[i][j][k],ret[i - 1][j][k]);
                chmax(ret[i][j][k],ret[i][j - 1][k]);
                if(maze[i][j] != 0) {
                    chmax(ret[i][j][1],ret[i - 1][j][k] + maze[i][j]);
                    if(k != 3) {
                        chmax(ret[i][j][k + 1],ret[i][j - 1][k] + maze[i][j]);
                    }
                }
            }
        }
    }
    ll ret2 = 0;
    for(int i = 0;i < 4;i++) {
        chmax(ret2,ret[R][C][i]);
    }
    cout << ret2 << endl;
}

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

typedef long long ll;

int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,k,c=1,sp,t=0;
    cin>>n>>k;
    ll arr[n+1];
    map <int,int> m;
    for(int i=1;i<=n;i++)
        cin>>arr[i];
    for(int i=1;i<=n;)
    {
        if(m[i])
        {
            sp=i;
            break;
        }
        m[i]=1;
        i=arr[i];
        t++;
    }
    for(int i=sp;i<=n;)
    {
        if(arr[i]==sp)
            break;
        c++;
        i=arr[i];
    }
    ll j=0,i;
    if(k>t)
    {
        for(i=sp;i<=n&&j<(k-t)%c;j++)
            {
                i=arr[i];
            }
        cout<<i;
    }
    else
    {
        for(i=1;j<k;j++)
        {
            i=arr[i];
        }
        cout<<i;
    }
    
    
    return 0;
}

Measured memory_bytes: 14416
#include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
using W = long double;
typedef complex<W> P;
typedef pair<P,P> L;
typedef pair<P,W> C;
typedef vector<P> Poly;
#define X real()
#define Y imag()
const W EPS = (1e-6), INF = (1e15);

W dot(P a, P b){ return a.X * b.X + a.Y * b.Y; }
W cross(P a, P b){ return a.X * b.Y - a.Y * b.X; }

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if( cross(b,c) > EPS ) return +1;
  if( cross(b,c) < -EPS ) return -1;
  if( dot(b,c) < 0 ) return +2;
  if( abs(b) + EPS < abs(c) ) return -2;
  return 0;
}

W ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 && dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf), abs(a-ss));
}

bool intersect(C a, C b){
  W d = abs(a.first-b.first);
  W ra = a.second, rb = b.second;
  return d-EPS < ra+rb;
}

int in_poly(P a, const Poly &p){
  int n = p.size(), c = 0;
  for(int i = 0; i < n; ++i){
    P s = p[i]-a, t = p[(i+1)%n]-a;
    if(!ccw(s,t,P(0,0))) return 1;//辺上
    if(s.Y > t.Y + EPS) swap(s,t);
    if((s.Y*t.Y < 0 || (s.Y*t.Y < EPS && t.Y > EPS)) && cross(s,t) < EPS) ++c;
  }
  if(c%2) return 2;//内部
  return 0;//外部
}

int main(){
  int N;
  cin >> N;
  vector<vector<P>> ST(N,vector<P>(2));
  vector<W> R(N);
  for(int i = 0; i < N; ++i){
    cin >> R[i];
    for(int j = 0; j < 2; ++j){
      W x, y;
      cin >> x >> y;
      ST[i][j] = P(x,y);
    }
  }
  vector<int> dp(1<<N,-1);
  dp[0] = 0;
  for(int i = 0; i < 1<<N; ++i){
    if(dp[i] < 0) continue;
    for(int j = 0; j < N; ++j){
      if((i>>j)&1) continue;
      int i_ = i|(1<<j);
      if(dp[i_] == dp[i]+1) continue;
      P s = ST[j][0], t = ST[j][1];
      W r = R[j];
      C cs(s,r), ct(t,r);
      P d = s-t;
      d /= abs(d);
      P n = d*P(0,1);
      vector<P> rec = {s+n*r,s-n*r,t-n*r,t+n*r};
      bool f = true;
      for(int k = 0; k < N; ++k){
        if(k == j) continue;
        P c = ST[k][i>>k&1];
        C ck(c,R[k]);
        f &= (not intersect(ck,cs));
        f &= (not intersect(ck,ct));
        f &= (not in_poly(c,rec));
        for(int a = 0; a < 4; ++a){
          int a_ = (a+1)%4;
          f &= (ps_dist(c,L(rec[a],rec[a_])) >= R[k]-EPS);
        }
      }
      if(f) dp[i_] = max(dp[i_],dp[i]+1);
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}



Measured memory_bytes: 3360
n=int(input())
s=[]
for i in range(n):
	s.append(input())
a=0
b=0
c=0
d=0
for i in range(n):
	if s[i]=="AC":
		a+=1
	elif s[i]=="WA":
		b+=1
	elif s[i]=="TLE":
		c+=1
	else:
		d+=1

print("AC x "+str(a))
print("WA x "+str(b))
print("TLE x "+str(c))
print("RE x "+str(d))

Measured memory_bytes: 16320
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
#include <random>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<bool> vbool;
typedef vector<string> vstr;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
template <typename _Ty> _Ty ipow(_Ty x, _Ty n) { _Ty ret = _Ty(1); for (_Ty i = _Ty(0); i < n; i++) ret *= x; return ret; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false




int main()
{
	//clock_t start, end;
	//start = clock();

	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;

		double ex2 = 0, ex = 0;
		for (int i = 0; i < n; i++) {
			double s;
			cin >> s;

			ex2 += s * s; ex += s;
		}
		ex2 /= n; ex /= n;

		double var = ex2 - ex * ex;

		printf("%.10f\n", sqrt(var));
	}

	//end = clock();
	//printf("%d msec.\n", end - start);

	return 0;
}



Measured memory_bytes: 3212
a[3];main(i,m,n){for(scanf("%d",&i);~scanf("%d%d%d",a,a+1,a+2);puts(a[0]*a[0]+a[1]*a[1]+a[2]*a[2]-m?"NO":"YES"))for(m=i=0;i<3;i++)if(n=2*a[i]*a[i],m<n)m=n;exit(0);}

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

int main(){
    string s;
    cin>>s;
    for(;;){
        s.pop_back();
        s.pop_back();
        for(int j=0;;j++){
            if(s[j]!=s[j+s.size()/2]) break;
            if(j==s.size()/2-1){
                cout<<s.size()<<endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
# Python3 program to find prime factorization 
# of a number n in O(Log n) time with 
# precomputation allowed. 
import math as mt 

MAXN = 1000001

# stores smallest prime factor for 
# every number 


# Calculating SPF (Smallest Prime Factor) 
# for every number till MAXN. 
# Time Complexity : O(nloglogn) 
def sieve(): 
    spf = [0 for i in range(MAXN)] 
    spf[1] = 1
    for i in range(2, MAXN): 
		
		# marking smallest prime factor 
		# for every number to be itself. 
        spf[i] = i 

	# separately marking spf for 
	# every even number as 2 
    for i in range(4, MAXN, 2): 
        spf[i] = 2

    for i in range(3, mt.ceil(mt.sqrt(MAXN))): 
		
		# checking if i is prime 
        if (spf[i] == i): 
			
			# marking SPF for all numbers 
			# divisible by i 
            for j in range(i * i, MAXN, i): 
				
				# marking spf[j] if it is 
				# not previously marked 
                if (spf[j] == j): 
                    spf[j] = i 
    return spf

# A O(log n) function returning prime 
# factorization by dividing by smallest 
# prime factor at every step 
def getFactorization(x,spf): 
	ret = set()
	while (x != 1): 
		ret.add(spf[x]) 
		x = x // spf[x] 

	return ret 

# # Driver code 

# # precalculating Smallest Prime Factor 
# sieve() 
# x = 12246
# print("prime factorization for", x, ": ", 
# 								end = "") 

# # calling getFactorization function 
# p = getFactorization(x) 

# for i in range(len(p)): 
# 	print(p[i], end = " ") 

# This code is contributed 
# by Mohit kumar 29 


def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor,gcd
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N = II()
    A = LMIIS()
    # from random import random
    # N = int(random()*10**6)
    # A = []
    # for i in range(N):
    #     A.append(1+int(random()*10**6))

    spf = sieve()
    primes = set()
    PairWise = True
    for a in A:
        p = getFactorization(a,spf)
        if len(p & primes) > 0:
            PairWise = False
            break
        primes |= p
    else:
        print('pairwise coprime')
        return

    all_gcd = A[0]
    for a in A:
        all_gcd = gcd(all_gcd,a)
        if all_gcd == 1:
            print('setwise coprime')
            return
    print('not coprime')

    


    
main()

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    vector<string> A(N);
    vector<string> B(M);

    REP(i, N){
        cin >> A[i];
    }
    REP(i, M){
        cin >> B[i];
    }

    ll K = N-M;

    REP(s, K+1){
        REP(t, K+1){
            bool flag = true;
            REP(i, M){
                REP(j, M){
                    if(A[s+i][t+j] != B[i][j]){
                        flag = false;
                        break;
                    }
                }
                if(flag == false) break;
            }
            if(flag == true){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

typedef long long Weight;
struct Edge {
	int src, dst;
	Weight weight;
	Edge(int src, int dst, Weight weight) :
		src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

static const Weight INF = 1LL << 60;

void shortestPath(const Graph &g, int s,
	vector<Weight> &dist/*, vector<int> &prev*/) {
	int n = g.size();
	dist.assign(n, INF); dist[s] = 0;
	//prev.assign(n, -1);
	priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
	for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
		Edge e = Q.top(); Q.pop();
		//if (prev[e.dst] != -1) continue;
		//prev[e.dst] = e.src;
		for (const auto &f : g[e.dst]) {
			if (dist[f.dst] > e.weight + f.weight) {
				dist[f.dst] = e.weight + f.weight;
				Q.push(Edge(f.src, f.dst, e.weight + f.weight));
			}
		}
	}
}

int main()
{
	int n, m, s, t;
	cin >> n >> m >> s >> t;
	--s;
	--t;
	Graph g_yen(n), g_snk(n);
	for (int i = 0; i < m; ++i) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		--u;
		--v;
		g_yen[u].push_back(Edge(u, v, a));
		g_yen[v].push_back(Edge(v, u, a));
		g_snk[u].push_back(Edge(u, v, b));
		g_snk[v].push_back(Edge(v, u, b));
	}

	vector<Weight> dist_yen;
	vector<Weight> dist_snk;

	shortestPath(g_yen, s, dist_yen);
	shortestPath(g_snk, t, dist_snk);

	vector<Weight> best(n);
	best[n - 1] = dist_yen[n - 1] + dist_snk[n - 1];
	for (int i = n - 2; i >= 0; --i) {
		best[i] = min(best[i + 1], dist_yen[i] + dist_snk[i]);
	}

	for (int i = 0; i < n; ++i) {
		cout << 1000000000000000LL - best[i] << endl;
	}
}

Measured memory_bytes: 19012
#include <iostream>

int main(){
    int ans = 0;
    int A, B, C, K;
    std::cin >> A >> B >> C >> K;

    int An = A;
    int Bn = B;
    int Cn = C;
    int Kn = K;

    if((A - K) >= 0){
        ans = K;        
        std::cout << ans << std::endl;

        return 0;
    }

    // else Bでとどまる場合 
    Kn = K - A;
    if(B > Kn){
        ans = A;        
        std::cout << ans << std::endl;

        return 0;
    }

    // else Cに入っちゃう場合 
    Kn = Kn - B;
    ans = A - (Kn);
    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 3572
#include <stdio.h>

int a,b,c,d;
int min (int a,int b){
  if (a<b)return a;  
   return b;
}
int main() {
 scanf("%d%d%d%d",&a,&b,&c,&d);
 printf("%d\n",min(a,b)+min(c,d));
 return 0;
}

Measured memory_bytes: 128
w = int(input())
n = int(input())
nums = list(range(1, w + 1))
for i in range(n):
    a, b = map(int, input().split(","))
    c = nums[a - 1]
    nums[a - 1] = nums[b - 1]
    nums[b - 1] = c

for i in range(w):
    print(nums[i])

Measured memory_bytes: 7608
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>

typedef long long ll;
using std::vector;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

int main() {
    //std::ifstream in("0_normal_2");
    //std::cin.rdbuf(in.rdbuf());
    
    int N, K;
    std::cin >> N >> K;
    std::string S;
    std::cin >> S;
    //各向きの塊=向きの入れ替わり回数+1で考える
    //塊の向きにかかわらず、N-塊の数がスコアになる
    //一回の操作で端っこの塊以外を選べば塊の数は-2される
    //端っこを選ぶのは最後の最後で、その場合全て揃うのでmin(N-1, )すればよい
    int num = 0;
    char before = 'a';
    for (int i = 0; i < N; i++) {
        if (S[i] != before) {
            num += 1;
        }
        before = S[i];
    }
    int ans = std::min(N-1,N-num+2*K);
    
    std::cout << ans << std::endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    ll x, y;
    REP(i, n) { 
        cin >> x >> y;
        if (x * x + y * y <= d * d) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
H, W = map(int, input().split())
matrix1 = []
matrix2 = []
for i in range(H):
    matrix1.append(list(input()))
for i in range(H):
    matrix3 = []
    for j in range(W):
        bomb = 0
        if i - 1 >= 0 and j - 1 >= 0 and matrix1[i-1][j-1] == "#":
            bomb += 1
        if i - 1 >= 0 and matrix1[i-1][j] == "#":
            bomb += 1
        if i - 1 >= 0 and j + 1 <= W-1 and matrix1[i-1][j+1] == "#":
            bomb += 1
        if j - 1 >= 0 and matrix1[i][j-1] == "#":
            bomb += 1
        if j + 1 <= W-1 and matrix1[i][j+1] == "#":
            bomb += 1
        if i + 1 <= H-1 and j - 1 >= 0 and matrix1[i+1][j-1] == "#":
            bomb += 1
        if i + 1 <= H-1 and matrix1[i+1][j] == "#":
            bomb += 1
        if i + 1 <= H-1 and j + 1 <= W-1 and matrix1[i+1][j+1] == "#":
            bomb += 1
        if matrix1[i][j] == "#":
            matrix3.append("#")
        else:
            matrix3.append(str(bomb))
    print(''.join(matrix3))

Measured memory_bytes: 3064
import sys

stdinr = sys.stdin.readline

ns = lambda: stdinr().rstrip()
ni = lambda: int(stdinr().rstrip())
nm = lambda: map(int, stdinr().split())
nl = lambda: list(map(int, stdinr().split()))

h,w = nm()
g = [list(map(lambda s:s=='#', list(input()))) for _ in range(h)]
dp = [[h*w]*w for _ in range(h)]
dp[0][0] = g[0][0]
for i in range(h):
    for j in range(w):
        if i < h-1:
            d = dp[i][j] + (g[i][j] < g[i+1][j])
            if dp[i+1][j] > d: dp[i+1][j] = d
        if j < w-1:
            d = dp[i][j] + (g[i][j] < g[i][j+1])
            if dp[i][j+1] > d: dp[i][j+1] = d
print(dp[-1][-1])


Measured memory_bytes: 3188
<?php
while (true) {
    $rep_words = [];
    $string = [];
    $rep_count = trim(fgets(STDIN));
    if (0 == $rep_count) break;
    for ($i = 0; $i < $rep_count; $i++) {
        list($before, $after) = explode(' ', trim(fgets(STDIN)));
        $rep_words[] = array('before' => $before, 'after' => $after);
    }
 
    $string_count = trim(fgets(STDIN));
    for ($i = 0; $i < $string_count; $i++) {
        $string[] = trim(fgets(STDIN));
    }
 
    $done = array_fill(0, count($string), false);
    foreach ($rep_words as $rep) {
        for ($i = 0; $i < count($done); $i++) {
            if ($done[$i] == true) continue;
            if ($string[$i] == $rep['before']) {
                $string[$i] = $rep['after'];
                $done[$i] = true;
            }
        }
    }
 
    echo implode($string) . PHP_EOL;
}


Measured memory_bytes: 46312
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll X;

int main() {
    cin >> X;
    float f = 1.01;
    ll okane = 100;
    //float F = f;
    REP(i, INF) {
        okane += okane / 100;
        if (okane >= X) {
            cout << i + 1 << endl;
            return 0;
        }
        //F *= f;
    }
    
}

/*
10 10 2
1 10 9 1
2 10 9 2
*/

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n, k; cin >> n >> k;
        vector<int> a(n); cin >> a;


        int ans = 0;
        for (int left = 0; left <= k; left++) {
                for (int right = 0; right + left <= min(n, k); right++) {
                        vector<int> hand;
                        for (int i = 0; i < left; i++) {
                                hand.emplace_back(a[i]);
                        }
                        for (int i = n - 1; i >= n - right; i--) {
                                hand.emplace_back(a[i]);
                        }
                        sort(all(hand), greater<>());
                        for (int i = 0; i < k - left - right; i++) {
                                if (hand.size() && hand.back() < 0) hand.pop_back();
                                else break;
                        }

                        ans = max(ans, accumulate(all(hand), 0));
                }
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int n,l,r,i,x,s1=0,s2=0,s3=0;
int main()
{
	scanf("%d",&n);
	scanf("%d%d",&l,&r);
	for (i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if (x<=l) s1++;
			else if (x<=r) s2++;
				else s3++;
	}
	printf("%d",min(min(s1,s2),s3));
	return 0;
}

Measured memory_bytes: 256
cards = list()
suit = ['S', 'H', 'C', 'D']
n = int(input())
for i in range(n):
    s,r = input().split()
    r = int(r)
    if s == "S": cards.append(0 + r)
    elif s == "H": cards.append(13 + r)
    elif s == "C": cards.append(26 + r)
    elif s == "D": cards.append(39 + r)
for i in range(1,53):
    if not (i in cards):
        print(suit[(i-1)//13], (i-1)%13+1)
        
        


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  vector<pair<int, int> > v;
  for(int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    v.pb(mp(a, b));
  }

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

  for(auto u : v){
    if(u.second >= k){
      cout << u.first << endl;
      break;
    }
    k -= u.second;
  }

  return 0;
}


Measured memory_bytes: 1400
n,k = gets.split.map(&:to_i)
m = gets.split.map(&:to_i)
cumsum = []
cumsum[0] = 0
n.times do |i|
  cumsum[i+1] = cumsum[i] + (m[i] + 1) / 2.0
end
ans = 0
(n-k+1).times do |i|
  tmp = cumsum[i+k] - cumsum[i]
  ans = [ans, tmp].max
end
p ans

Measured memory_bytes: 20300
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
#ifdef _debug
#define dout(i) cout << #i << ' ' << i << ' '
#else 
#define dout(i) //
#endif
using ll = long long;
using ull = unsigned long long;
using ul = unsigned;
const int maxn = 50;
int n;
int main(){	
	ios_base::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	priority_queue<double,vector<double>,greater<double>>v;
	for(int i = 0;i < n;++i){
		int a;cin >> a;
		v.push(a);
	}
	while(v.size() > 1){
		double a = v.top();
		v.pop();
		double b = v.top();
		v.pop();
		v.push((a+b)/2);
	}
	printf("%.10f\n", v.top());
}

Measured memory_bytes: 384
#include <iostream>
#include <set>

std::set<char> has;

int main(){
  std::string str;
  std::cin>>str;
  for(char c:str){
    has.insert(c);
  }
  if((has.count('N')^has.count('S'))||(has.count('W')^has.count('E'))){
    std::cout<<"No"<<std::endl;
  }else{
    std::cout<<"Yes"<<std::endl;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  cout<<(n/3)<<endl;
  return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
	#define SAY(X) cout << (X) << '\n';
#else
	#define DBG(X)
	#define SAY(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const ll C = 1000;

struct Tree {
	vector<ll> a;

	Tree() {
		a.resize(C, 0);
	}

	void add(ll pos, ll val) {
		a[pos] += val;
	}

	ll get(ll l, ll r) {
		if(l < 0) l = 0;
		ll rez = 0;
		for(int i = l; i <= r; ++i) {
			rez += a[i];
		}

		return rez;
	}
};

const int MAXN = (int)1e5 + 777;
ll a[MAXN];
int n, p;
ll m, v;

int check(int pos) {
	ll to_add = m * v - m;
	ll x = a[pos] + m;

	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		if(i != pos) {
			cnt += a[i] > x;
		}
	}

	if(cnt >= p) {
		return 0;
	}

	for(int i = n - 1; i >= 0; --i) {
		if(i != pos) {
			if(a[i] > x) {
				ll take = min(to_add, m);
				to_add -= take;
			} else {
				ll take = min(to_add, m);

				if(a[i] + take > x) {
					if(cnt + 1 < p) {
						++cnt;
					} else {
						take = min(take, x - a[i]);
					}
				}

				to_add -= take;
			}
		}
	}

	return to_add == 0;
}

void solve() {
	cin >> n >> m >> v >> p;
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	sort(a, a + n);
	int low = 0, high = n - 1;
	if(check(low)) {
		cout << n << '\n';
	} else if(!check(high)) {
		cout << "0\n";
	} else {
		while(high - low > 1) {
			int mid = (low + high) / 2;
			if(check(mid)) {
				high = mid;
			} else {
				low = mid;
			}
		}

		cout << n - high << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<limits>
#include<math.h>

using namespace std;

int ans[100001];
int main(){
    string s; cin >> s;

    for(int i=0; i<s.size(); ++i){
        if(s[i] == 'R'){
            int k = 0, g = 0;
            int d = 0;
            while(s[i + d] == 'R'){
                if(d%2 == 0) ++g;
                else ++k;
                ++d;
            }
            ans[i+d] += k;
            ans[i+d-1] += g;
            i += d-1;
            continue;
        }
        if(s[i] == 'L'){
            int k = 0, g = 0;
            int d = 0;
            while(s[i + d] == 'L'){
                if(d%2 == 0) ++g;
                else ++k;
                if(i + (++d) == s.size()) break;
            }
            ans[i-1] += k;
            ans[i] += g;
            i += d-1;
            continue;
        }
    }

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



Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long Inf = (long) 2e18;
		long[][][] dp = new long[H][][];
		for(int i=0;i<H;i++){
			dp[i] = new long[W][];
			for(int j=0;j<W;j++){
				dp[i][j] = new long[4];
				for(int k=0;k<4;k++){
					dp[i][j][k] = -Inf;
				}
			}
		}
		
		long[][] VV = new long[H][];
		for(int i=0;i<H;i++) VV[i] = new long[W];
		for(int i=0;i<K;i++) VV[R[i]][C[i]] = V[i];
		
//for(int i=0;i<H;i++) Console.WriteLine(String.Join(" ",VV[i]));
		
		
		dp[0][0][0] = 0;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				for(int k=0;k<4;k++){
					if(dp[i][j][k] == -Inf) continue;
//Console.WriteLine("i:{0} j:{1}, k:{2}",i,j,k);
					if(i + 1 < H){
						dp[i+1][j][0] = Math.Max(dp[i+1][j][0], dp[i][j][k]);
//Console.WriteLine("dp[i+1][j][0]:{0}",dp[i+1][j][0]);
						if(k < 3){
							dp[i+1][j][0] = Math.Max(dp[i+1][j][0], dp[i][j][k] + VV[i][j]);
//Console.WriteLine("i dp[i+1][j][0]:{0}",dp[i+1][j][0]);
						}
					}
					if(j + 1 < W){
						dp[i][j+1][k] = Math.Max(dp[i][j+1][k], dp[i][j][k]);
//Console.WriteLine("dp[i][j+1][k]:{0}",dp[i][j+1][k]);
						if(k < 3){
							dp[i][j+1][k+1] = Math.Max(dp[i][j+1][k+1], dp[i][j][k] + VV[i][j]);
//Console.WriteLine("i:dp[i][j+1][k]:{0}",dp[i][j+1][k]);
						}
					}
				}
/*				
				for(int k=0;k<4;k++){
					for(int ii=0;ii<H;ii++){
						for(int jj=0;jj<W;jj++) Console.Write("{0} ", dp[i][j][k]);
						Console.WriteLine();
					}
					Console.WriteLine();
				}
*/				
			}
		}
		

		
		long ans = dp[H-1][W-1][3];
		for(int i=0;i<3;i++){
			ans = Math.Max(ans, dp[H-1][W-1][i] + VV[H-1][W-1]);
		}
		Console.WriteLine(ans);
		
	}
	int H,W,K;
	int[] R,C;
	long[] V;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; K = d[2];
		R = new int[K];
		C = new int[K];
		V = new long[K];
		for(int i=0;i<K;i++){
			d = ria();
			R[i] = d[0] - 1;
			C[i] = d[1] - 1;
			V[i] = d[2];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 670332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};


int main(){
  int n,q;cin>>n>>q;
  vector<tuple<int,int,int>> ev(n*2);
  rep(i,n){
    int s,t,x;scanf("%d %d %d",&s,&t,&x);
    ev[i]=make_tuple(s-x,1,x);
    ev[n+i]=make_tuple(t-x,-1,x);
  }
  set<int> xset;
  sort(all(ev));
  int now=0;
  rep(i,q){
    int d;scanf("%d",&d);
    while(now!=2*n){
      if((get<0>(ev[now]))>d)break;
      auto forset=ev[now];
      now++;
      if(get<1>(forset)==1){
        xset.insert(get<2>(forset));
      }
      else{
        xset.erase(*xset.find(get<2>(forset)));
      }
    }
    if(xset.empty())printf("%d\n",-1);
    else printf("%d\n",*xset.begin());
  }
}


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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef string ss;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    //y /= gcd(x,y);
    return (x*y);
}

#define WA printf("WA\n");
int main()
{
    ll max=0,count=0;
    ss s;
    cin >> s;
    rep(i,SIZE(s)){
        if(s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G'){
            count=0;
            //cout << "000" << endl;
            for(int j=i;j<SIZE(s);j++){
                if(s[j] == 'A' || s[j] == 'T' || s[j] == 'C' || s[j] == 'G'){}
                else break;
                count++;
                //cout << "111" << endl;
            }
            if(count >= max)max = count;
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,c,d,h1,h2,k1,k2,e,f,g,h,i,j,k,l,m,n,o,p,q,r;
	scanf("%d",&h1);
	scanf("%d",&h2);
	scanf("%d",&k1);
	scanf("%d",&k2);
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	e=h1*a;
	f=h2*b;
	g=k1*a;
	h=k2*b;
	i=h1/10;
	j=i*c;
	k=k1/10;
	l=k*c;
	m=h2/20;
	n=m*d;
	o=k2/20;
	p=o*d;
	q=e+f+n+j;
	r=g+h+l+p;
	if(q>r){
		printf("hiroshi\n");
	}
	if(q<r){
		printf("kenjiro\n");
	}
	if(q==r){
		printf("even\n");
	}
	return 0;
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;

int N;

int main()
{
    cin >> N;
    ll sum = 0;
    for (int i = 1; i <= N; i++)
    {
        if (i % 3 != 0 && i % 5 != 0)
        {
            sum += i;
        }
    }
    cout << sum << endl;
    // system("pause");
}

Measured memory_bytes: 3676
N = int(input())
A = list(map(int, input().split()))

def hantei(L):
  for i in range(len(L)):
    if L[i] % 2 != 0:
      return(1)
  return(0)

count = 0
while hantei(A) == 0:
  for j in range(N):
    A[j] = A[j] / 2
  count = count + 1
  
print(count)

Measured memory_bytes: 3060
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=1003;
const int N=1000005;
bool s[M][M];
bool vis[M][M];
int c[M][M];
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};
int px[]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,0,1,2};
int py[]={2,2,2,2,2,1,1,1,1,1,0,0,0,0,0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2};
int h,w;
int rong_vis[N];
vector<pi>adj[N];
void dfs(int x,int y,int rong)
{
    vis[x][y]=1;
    c[x][y]=rong;
    adj[rong].pb(mp(x,y));
    for(int i=0;i<4;i++)
    {
        int nx=x+dx[i];
        int ny=y+dy[i];
        if(x<1 || x>h || y<1 || y>w)continue;
        if(s[nx][ny]==1 && vis[nx][ny]==0)
        {
            dfs(nx,ny,rong);
        }
    }
}
 main()

{
    fast
    cin>>h>>w;
    int ch,cw,dh,dw;
    cin>>ch>>cw;
    cin>>dh>>dw;
    f(i,1,h)
    {
        string tmp;
        cin>>tmp;
        f(j,1,w)
        {
           if(tmp[j-1]=='.')s[i][j]=1;
        }
    }
    int cur=0;
    f(i,1,h)
    {
        f(j,1,w)
        {
            if(s[i][j]==1 && vis[i][j]==0)
            {
                cur++;
                dfs(i,j,cur);

            }

        }
    }
    queue<pi>q;
    q.push(mp(c[ch][cw],0));
    rong_vis[c[ch][cw]]=1;
    while(!q.empty())
    {
        int r=q.front().fi;
        int lvl=q.front().si;
        q.pop();
        if(r==c[dh][dw])
        {
            cout<<lvl<<"\n";
            return 0;
        }
        for(auto z:adj[r])
        {
           int x=z.fi;
           int y=z.si;
           for(int k=0;k<25;k++)
           {
               int nx,ny;
               nx=x+px[k];
               ny=y+py[k];
               if(nx<1 || nx>h || ny<1 || ny>w)continue;
               if(s[nx][ny]==0)continue;
               if(rong_vis[c[nx][ny]]==1)continue;
               q.push(mp(c[nx][ny],lvl+1));
               rong_vis[c[nx][ny]]=1;

           }
        }
    }
    cout<<"-1\n";
    return 0;

}





































Measured memory_bytes: 49016