akhauriyash/Code-Regression huggingface dataset:
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.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.function.BiConsumer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

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

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int k = in.nextInt();
			List<Double> list = new ArrayList<Double>();
			list.add(0.0);
			for (int i = 1; i <= 1000; i++) {
				double tmp = 0;
				for (int j = 1; j <= i; j++) {
					tmp += j / (double) i;
				}
				list.add(tmp);
			}
			double ans = 0;
			double tmp = 0;
			int[] arr = new int[n + 1];
			for (int i = 1; i <= n; i++) {
				arr[i] = in.nextInt();
				tmp += list.get(arr[i]);
				if (i >= k) {
					ans = Math.max(ans, tmp);
					tmp -= list.get(arr[i - k + 1]);
				}
			}
			out.println(ans);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public char nextChar() {
			return next().charAt(0);
		}

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

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

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

	}
}


Measured memory_bytes: 43732
N,M=map(int,input().split())
G=[[] for _ in range(N)]

for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

seen=[0]*N
ans=[]

def DFS(x,n):
    if len(n)==N:
        return True
    for a in G[x]:
        if seen[a]==0:
            seen[a]=1
            if DFS(a,n+str(a)):ans.append(n+str(a))
            seen[a]=0
seen[0]=1
DFS(0,"0")

print(len(ans))




Measured memory_bytes: 9164
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define R register
int n, m;
int main()
{
	scanf("%d %d", &n, &m);
	if(n > m) swap(n, m);
	if(n == 1 && m == 1) puts("1");
	else if(n == 1) printf("%d\n", m - 2);
	else printf("%lld\n", 1ll * n * m - n - m - n - m + 4);
	return 0;
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    bool f = false;
    for (int i = 0; i < 3; i++) {
        if (s[i] == s[i + 1]) f = true;
    }
    cout << (f ? "Bad" : "Good") << endl;
    return 0;
}

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

using namespace std;
const int N = 1e5 + 5;

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	long long x, y;
	scanf("%lld %lld", &x, &y);
	if(abs(x - y) <= 1){
		puts("Brown");
	}else{
		puts("Alice");
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s; cin >> s;
  for (auto i : s) {
    if (i == '1') cout << '9';
    if (i == '9') cout << '1';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
#define F first
#define S second
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
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;
}
int main() {
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  int sum = 0;
  rep(i,s.size()){
    sum+=s.at(i)-'0';
    sum%=9;
  }
  if(sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  if (S.length() == 3)
    reverse(S.begin(), S.end());
  cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	long long N, M;
	cin >> N >> M;
	if (N == M && M == (long long)1)
	{
		cout << 1 << "\n";
		return 0;
	}
	if (N != (long long)1 && M != (long long)1)
	{
		cout << (N - (long long)2)*(M - (long long)2) << "\n";
		return 0;
	}
	cout << N + M - (long long)3 << "\n";
}

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

using namespace std;

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

	vector<int> a;
	a.resize(n);

	int sum = 0;

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

		sum += a[i];
	}

	int cnt = 0;

	for(int i = 0; i < n; ++i) {
		if(a[i] * 4 * m >= sum) {
			++cnt;
		}
	}

	if(cnt >= m) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}

	return 0;
}


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

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

    long long max_count = 0;
    long long count = 0;
    long long H;
    for(int i=0; i<N; i++){
        long long H_tmp;
        cin >> H_tmp;
        if(i==0){H = H_tmp;continue;}

        if(H_tmp <= H){
            count +=1;
        }else{
            if(max_count < count){
                max_count = count;
            }
            count =0;
        }

        H = H_tmp;
    }

    if(max_count < count){
        max_count = count;
    }

    cout << max_count << endl;
    return 0;
}

Measured memory_bytes: 3536
n,k = map(int,input().split())
d = list(map(str,input().split()))
while True:
  sn = str(n)
  l = len(sn)
  flag = True
  for i in range(l):
    if sn[i] in d:
      flag = False
      break
  if flag:
    print(n)
    exit()
  n += 1
  
     
  
    
  

Measured memory_bytes: 73308
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

void solve(long long H, long long W, long long M, std::vector<long long> h, std::vector<long long> w){
    vll sumh(H, 0), sumw(W, 0);
    REP(i, M){
        sumh[h[i]]++;
        sumw[w[i]]++;
    }
    ll maxh = 0, maxw = 0;
    REP(x, H) chmax(maxh, sumh[x]);
    REP(y, W) chmax(maxw, sumw[y]);
    ll cnth = 0, cntw = 0;
    REP(x, H) if(sumh[x]==maxh) cnth++;
    REP(y, W) if(sumw[y]==maxw) cntw++;
    ll ans = maxh + maxw;
    ll cnt = 0;
    REP(i, M) if(sumh[h[i]]==maxh && sumw[w[i]]==maxw) cnt++;
    if(cnt < cnth*cntw) cout<<ans<<endl;
    else cout<<ans-1<<endl;

}
int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> h(M);
    std::vector<long long> w(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&h[i]);
        scanf("%lld",&w[i]);
        h[i]--; w[i]--;
    }
    solve(H, W, M, std::move(h), std::move(w));
    return 0;
}


Measured memory_bytes: 12500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main
{
	public static void main(String[] Arguments) throws IOException 
	{
		BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
		int K = Integer.parseInt(BR.readLine());
		StringTokenizer ST = new StringTokenizer(BR.readLine());
		int a = Integer.parseInt(ST.nextToken()), b = Integer.parseInt(ST.nextToken());
		boolean Possible = false;
		for (int i = a; i <= b; i++)
		{
			if (i % K == 0)
			{
				Possible = true;
				break;
			}
		}
		System.out.println((Possible) ? "OK" : "NG");
	}
}


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

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define fm(i, a, b, c) for (long long i = a; i > b; i--)
#define vi vector<i>
#define vl vector<long long>
#define vs vector<string>
#define t     \
    ll t;     \
    cin >> t; \
    while (t--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)
int main()
{
    int n, m;
    cin >> n >> m;
    ll ways = 0;
    ways += (n * (n - 1)) / 2;
    ways += (m * (m - 1)) / 2;
    cout << ways << endl;
    return 0;
}

Measured memory_bytes: 256
/*
ID: tohoast1
TASK: gymnastics
LANG: C++
*/
#include <bits/stdc++.h>
#define speedup ios_base::sync_with_stdio(NULL)
#define fin freopen("gymnastics.in", "r", stdin)
#define fout freopen("gymnastics.out", "w", stdout)
#define FILENAME
#define PUBG push_back
#define p_b pop_back
#define mp make_pair
#define fi first
#define se second
#define cls clear
#define INF const int ci = 1e6 + 100
#define K_INF 1e9 + 7
#define time cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"
#define MIN_INT -999999999
#define MOD 1000000007
#define d109 1000000000
# define basay break
using namespace std;
typedef long long LL;
typedef long L;
typedef unsigned long long ULL;
typedef unsigned long UL;
typedef string STR;
int N, cnt;
STR s;

int main() {
    #ifdef FILENAMEs
        fin;
        fout;
    #endif // FILENAME
    cin >> N >> s;
    for (int i = 0 ; i < N - 2 ; ++ i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
            cnt ++;
        }
    }
    cout << cnt;
    ///time;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<char, int> P;

vector<P> sort_v(vector<P> &v, vector<int> &used, int now){
  vector<P> res;
  REP(i, now + 1) REP(j, 9) if(used[j] == i) res.push_back(v[j]);
  return res;
}

bool check(vector<P> &vv, vector<int> &used, int now){
  vector<P> v = sort_v(vv, used, now);
  for(int i = 0; i + 2 < v.size(); i += 3){
    if(!(v[i].first == v[i + 1].first && v[i + 1].first == v[i + 2].first)) return 0;
    if(!(v[i].second == v[i + 1].second && v[i + 1].second == v[i + 2].second) && !(v[i].second == v[i + 1].second - 1 && v[i + 1].second == v[i + 2].second - 1)) return 0;
  }
  return true;
}

bool dfs(vector<P> &v, vector<int> &used, int now){
  if(now >= 9) return 1;
  bool res = 0;
  REP(i, 9){
    if(used[i] != -1) continue;
    used[i] = now;
    if(check(v, used, now)) res = max(res, dfs(v, used, now + 1));
    used[i] = -1;
  }
  return res;
}

int main() {
  int T; cin >>T;
  REP(t, T){
    vector<P> v(9);
    REP(i, 9) cin >>v[i].second;
    REP(i, 9) cin >>v[i].first;
    vector<int> used(9, -1);
    cout <<dfs(v, used, 0) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdlib>
#include <cstring>
 
const int N = 100010;
const int M = 500010;
const int inf = 0x3fffffff;
 
struct Edge {
    int to, len, next;
} es[M];
 
int SIZE = 0; // number of edges
int h[N]; // pointer to edge list
int dist[N], queue[N], inq[N]; // for calculating shortest path
 
inline void add(int u, int v, int w) {
    int i = ++SIZE;
    es[i].to = v;
    es[i].len = w;
    es[i].next = h[u];
    h[u] = i; 
}
 
inline int inc(int x) {
    return (x == N - 1 ? 0 : x + 1);
}
 
void sssp(int r) {
    int front = 0, back = 0;
    queue[back++] = r;
    while (front != back) {
        int x = queue[front];
        inq[x] = 0;
        front = inc(front);
        for (int i = h[x]; i; i = es[i].next) {
            int y = es[i].to;
            int new_d = dist[x] + es[i].len;
            if (new_d < dist[y]) {
                dist[y] = new_d;
                if (!inq[y]) {
                    queue[back] = y;
                    inq[y] = 1;
                    back = inc(back);
                }
            }
        }
    }
}
 
void run() {
    int n, m, r, x, y, w;
    scanf("%d%d%d", &n, &m, &r);
    memset(h, 0, sizeof(h));
    for (int i = 0; i < m; i++) {
        scanf("%d%d%d", &x, &y, &w);
        add(x, y, w);
    }
    for (int i = 0; i < n; i++) {
        dist[i] = (i == r ? 0 : inf);
        inq[i] = 0;
    }
    sssp(r);
    for (int i = 0; i < n; i++)
        if (dist[i] == inf)
            printf("INF\n");
        else
            printf("%d\n", dist[i]);
}
 
int main() {
    run();
}

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

const long long INF = 1LL << 60;

template<class T> inline bool chmin(T& a, T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

int main(){
  int N; cin >> N;
  vector<int>h(N);
  for(int i=0;i<N;i++){
    cin >> h.at(i);
  }
  vector<long long>dp(N,INF);
  dp.at(0) = 0;
  for(int i=1;i<N;i++){
    chmin(dp.at(i),dp.at(i-1) + abs(h.at(i) - h.at(i-1)));
    if(i>1) chmin(dp.at(i),dp.at(i-2) + abs(h.at(i) - h.at(i-2)));
  }
  cout << dp.at(N-1) << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<map>
using namespace std;

int n;
int p[30];
int ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (i > 1) {
			if (p[i - 2] < p[i - 1] ) {
				if (p[i - 1] < p[i])ans++;
			}
			else if (p[i] < p[i - 1]) {
				if (p[i - 1] < p[i - 2])ans++;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

int N, Y;

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

    rep(i, 0, N + 1) {
        rep(j, i, N + 1) {
            int a = j - i, b = N - j;
            if (10000 * i + 5000 * a + 1000 * b == Y) {
                printf("%d %d %d\n", i, a, b);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
using namespace std;

//#define FILE_INPUT
//#define DEBUG_MODE

void DebugPrint(vector<int> &a, int n)
{
#ifdef DEBUG_MODE
	for (int i = 0; i < min(20, n); ++i) {
		cout << a[i] << ",";
	}
	cout << endl;
#endif
}

int main()
{
#ifdef FILE_INPUT
	ifstream in("test3.txt");
	cin.rdbuf(in.rdbuf());
#endif	/* FILE_INPUT */  

	int h, w;
	cin >> h >> w;
	vector<int> dp(w, 0);

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

	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (i == 0 && j == 0) {
				if (map[i][j] != '#') {
					dp[0] = 1;
					continue;
				}
			}
			long long int sum = 0;
			if (map[i][j] != '#') {
				if (j > 0 && map[i][j - 1] != '#') {
					sum += dp[j - 1];
				}
				if (i > 0 && map[i - 1][j] != '#') {
					sum += dp[j];
				}
			}
			dp[j] = (int)(sum % 1000000007);
		}
		//DebugPrint(dp, w);
	}

	cout << dp[w - 1] << endl;

	return 0;
}


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

int main( ) {
  string S;
  cin >> S;
  
  if(S[0]!=S[1] && S[1]!=S[2] && S[2]!=S[0]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import math

dim = int(input().strip())
vec_x = list(map(int,input().strip().split(" ")))
vec_y = list(map(int,input().strip().split(" ")))

dist_1 = 0
dist_2 = 0
tmp_dist_2 = 0
dist_3 = 0
tmp_dist_3 = 0
dist_infinite = 0
abs_xy = [0 for i in range(dim)]
for i in range(dim):
    abs_xy[i]= abs(vec_x[i]-vec_y[i])
    
    dist_1 = dist_1 + abs_xy[i]
    tmp_dist_2 = tmp_dist_2 + abs_xy[i] ** 2
    tmp_dist_3 = tmp_dist_3 + abs_xy[i] ** 3
    
dist_2 = math.sqrt(tmp_dist_2)
dist_3 = tmp_dist_3 ** (1/3)
dist_infinite = max(abs_xy)

print("{:.5f}\n{:.5f}\n{:.5f}\n{:.5f}".format(dist_1,dist_2,dist_3,dist_infinite))

Measured memory_bytes: 7832
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;


int N,M,Q;
vct<int> tr[501];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M >> Q;
	rep(i,M){
		int l,r;
		cin >> l >> r;
		rep1(j,l) tr[j].pub(r);
	}
	rep(i,501) sort(all(tr[i]));
	rep(i,Q){
		int p,q;
		cin >> p >> q;
		cout << u_bnd(all(tr[p]),q) - tr[p].begin() << endl;
	}
}




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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, M; cin >> N >> M;
  if (N == M) Yes();
  else No();


  return 0;
}


Measured memory_bytes: 3564
H, N = map(int, input().split())

A=[]
B=[]
for _ in range(N):
	a, b = map(int, input().split())
	A.append(a)
	B.append(b)

dp=[[float("inf")]*(H+1) for _ in range(N+1)]
dp[0][0]=0
for i in range(N):
	a, b = A[i], B[i]
	for j in range(H+1):
		if a>=j:
			dp[i+1][j] = min(dp[i][j], b)
		else:
			dp[i+1][j] = min(dp[i][j], dp[i+1][j-a]+b)
print(dp[-1][-1])


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

namespace ConsoleApp15
{
    class Class49
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var ans = new int[N];
            
            for(int i = N-1; i >= 0; i--)
            {
                int k = 0, l = i+1;
                while (l <= N)
                {
                    k += ans[l-1];
                    l +=i+1;
                }
                ans[i] = k % 2 == a[i] ? 0 : 1;
            }
            int c = ans.Count(x => x == 1);
            Console.WriteLine(c);
            if (c != 0)
            {
                List<int> b = new List<int>();
                for (int i = 0; i < N; i++)
                    if (ans[i] == 1) b.Add(i+1);

                Console.WriteLine(string.Join(" ", b));
            }
            
        }
    }
}


Measured memory_bytes: 34264
<?php

fscanf(STDIN, "%d %d", $X, $Y);

if (($Y - 2 * $X) % 2 !== 0) {
    echo 'No', PHP_EOL;
    exit;
}

$b = intdiv($Y - 2 * $X, 2);
$a = $X - $b;
if ($a < 0 or $b < 0) {
    echo 'No', PHP_EOL;
    exit;
}

echo 'Yes', PHP_EOL;


Measured memory_bytes: 16096
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>


int main()
{
	int i,j,k;
	int n,m;
	int a[10]={0}; //押された回数
	int b[10]={0,5,3,3,3,3,3,4,3,4}; //割り算	 
	int c; //押されたボタン
	char d[5][10]={
	{'0',' ','c','f','i','l','o','s','v','z'},
	{'0','.','a','d','g','j','m','p','t','w'},
	{'0',',','b','e','h','k','n','q','u','x'},
	{'0','!','0','0','0','0','0','r','0','y'},
	{'0','?','0','0','0','0','0','0','0','0'}};
	char e[1025];
	
	scanf("%d",&n);

	for(i=0;i<n;i++)
	{
		scanf("%s",e);
		c=0;
		for(j=0;j<strlen(e);j++)
		{
			if(e[j]=='0'){
				if(c!=0)
				{
					printf("%c",d[a[c]%b[c]][c]);
					a[c]=0;
					c=0;
				}
			}else
			{
				if(e[j]=='1')c=1;
				else if(e[j]=='2')c=2;
				else if(e[j]=='3')c=3;
				else if(e[j]=='4')c=4;
				else if(e[j]=='5')c=5;
				else if(e[j]=='6')c=6;
				else if(e[j]=='7')c=7;
				else if(e[j]=='8')c=8;
				else if(e[j]=='9')c=9;
				a[c]++;
			}
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 1000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        String s = sc.next();

        int[] l = new int[q];
        int[] r = new int[q];
        for (int i = 0 ; i < q ; i++) {
            l[i] = sc.nextInt();
            r[i] = sc.nextInt();
        }

        int[] a = new int[n];
        int[] b = new int[n + 1];
        int sum = 0;
        for (int i = 0 ; i < n ; i++) {
            if (i < n - 1 && s.substring(i, i + 2).equals("AC")) {
                a[i + 1] = 1;
                sum += a[i + 1];

            }
            b[i + 1] = sum;
        }

        for (int i = 0 ; i < q ; i++) {
            System.out.println(b[r[i] -1 ] - b[l[i] -1]);
        }



    }

}

Measured memory_bytes: 90808
#include <bits/stdc++.h>
using namespace std;
int main(){
  string t[4] = {"dream","dreamer","erase","eraser"};
  for(int i=0 ; i<4 ; i++){
    reverse(t[i].begin(),t[i].end());
  }
  string s; cin >> s;
  reverse(s.begin(),s.end());
  int now = 0;
  while(true){
    bool update = false;
    for(int i=0 ; i<4 ; i++){
      if(s.substr(now, t[i].size()) == t[i]){
        now += t[i].size();
        update = true;
        break;
      }
    }
    if(!update)break;
  }
  if(now == s.size()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 512
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
 
using namespace std;
 
const int N = (int)2e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c >= 22) cout << "bust";
	else cout << "win";
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//  cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 256
from math import sqrt

n=100001
prime=[1 for i in range(n)]
prime[0]=0
prime[1]=0
for i in range(2,int(sqrt(n))):
    if prime[i]:
        j=0
        while i*(j+2)<n:
            prime[i*(j+2)]=0
            j+=1

resemble=[0 for i in range(n)]
for i in range(3,n):
    if i%2:
        if prime[i] and prime[int((i+1)/2)]:
            resemble[i]+=1
    resemble[i]+=resemble[i-1]

q=int(input())
for i in range(q):
    l,r=map(int,input().split())
    print(resemble[r]-resemble[l-1])


Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sz(a) (int)(a.size())
const ll mod = 1000 * 1000 * 1000 * (ll) 1000 * 939+ 7;
const int N = 500005;
int n;
pair<int , int> per(pair<int , int> a , pair<int , int> b)
{
	return {max(a.x , b.x) , min(a.y , b.y)};
}
int f(vector<pair<int , int> > v)
{
	vector<pair<int , int> > pp(n) , ps(n);
	pp[0] = v[0];
	for(int i = 1; i < n; i++)
		pp[i] = per(v[i] , pp[i - 1]);
	ps[sz(v) - 1] = v[sz(v) - 1];
	for(int i = n - 2; i >= 0; i--)
		ps[i] = per(v[i] , ps[i + 1]);
	int res = 0;
	for(int i = 0; i < n - 1; i++)
		res = max(res , pp[i].y - pp[i].x + 1 + ps[i + 1].y - ps[i + 1].x + 1);
	for(int i = 1; i < n - 1; i++)
	{
		auto z = per(pp[i - 1] , ps[i + 1]);
		res = max(res , z.y - z.x + 1 + v[i].y - v[i].x + 1);
	}
	return res;
}
bool cmp(pair<int , int> a , pair<int , int> b)
{
	if(a.y != b.y)
	{
		return a.y < b.y;
	}
	return a.x < b.x;
}
bool cmp2(pair<int , int> a , pair<int , int> b)
{
	if(a.x != b.x)
	{
		return a.x < b.x;
	}
	return a.y > b.y;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int ans = 0;
	cin >> n;
	vector<pair<int , int> > v(n);
	for(auto &x : v) {cin >> x.x >> x.y; ans = max(ans , x.y - x.x + 1);}
	sort(v.begin() , v.end());
	ans = max(ans , f(v));
	sort(v.begin() , v.end() , cmp);
	ans = max(ans , f(v));
	sort(v.begin() , v.end() , cmp2);
	ans = max(ans , f(v));
	cout << ans;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define forn(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;


void solve(){
    int n; cin >> n;
    vi v(n);
    for(int i = 0; i < n; i++)
        cin >> v[i];

    sort(all(v));

    int sum = 0;
    for(int i = 0 ; i < n-1; i++)
        sum += v[i];

    if( sum <= v[n-1] ) 
        cout << "No\n";
    else
        cout << "Yes\n";
}

int main(){
    //int t; cin >> t;
    //while(t--) solve();

    solve();
    return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    restaurants = []
    for i in range(N):
        si, pi = input().split()
        restaurants.append([i+1, si, int(pi)])
    cities = sorted(set([restaurant[1] for restaurant in restaurants]))

    for city in cities:
        same_cities = []
        for restaurant in restaurants:
            if restaurant[1] == city:
                same_cities.append(restaurant)
        sorted_restaurants = sorted(same_cities, key=lambda restaurant: restaurant[2], reverse=True)
        [print(restaurant[0]) for restaurant in sorted_restaurants]


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)

	if a == b {
		fmt.Println(c)
	} else if a == c {
		fmt.Println(b)
	} else {
		fmt.Println(a)
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

int main(){
  double ln,cta,x=0,y=0,angle=90.0;

  while(1){

  scanf("%lf,%lf",&ln ,&cta);
  if(ln==0&&cta==0)break;

  x += ln*cos((angle/180)*M_PI);
  y += ln*sin((angle/180)*M_PI);
  angle-=cta;
  }
  cout<< (int)x <<"\n"<< (int)y <<endl;

  return 0;
}

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

typedef pair<int,int> ii;

int main(){
	int N; cin>>N;
	vector<int> A;
	vector<int> X;	
	for (int i = 0; i<N; i++){
		int x; cin>>x;
		A.push_back(x);
		X.push_back(x);
	}

	sort(X.begin(),X.end());
	int l = X[N/2-1];
	int r = X[N/2];

	for (int i = 0; i<N; i++){
		if (A[i]<=l){
			cout<<r<<"\n";
		} else{
			cout<<l<<"\n";
		}
	}
}
	

Measured memory_bytes: 3948
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
			
		int count = n / x;
		int answer = 0;
		
		if(n % x == 0) answer = count;
		else answer = count + 1;
			
		System.out.println(answer * t);
			
		
	
		
		
		
	}

}


Measured memory_bytes: 35728
#include <bits/stdc++.h>
using namespace std;
  
int main(){
  int64_t N;
  cin >> N;
  int64_t ans = 10000000000000;
  for(int64_t i=1; i*i <= N; i++){
    if(N%i == 0) if(i + N/i < ans) ans = i + N/i;
  }
  ans -= 2;
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
sh = math.pi * (H + M / 60) / 6
sm = math.pi * M / 30
s = abs(sh - sm)
C = math.sqrt(A ** 2 + B ** 2 - 2 * A * B * math.cos(s))
print(C)

Measured memory_bytes: 61816
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <ctype.h>
using namespace std;
int a,b;
char s[50];
int main(){
    cin>>a>>b;
    cin>>s;
    bool flg=true;
    for(int i=0;i<a;i++)if(isdigit(s[i])==false){flg=false;break;}
    if(flg){
        if(s[a]!='-')flg=false;
        else{
            for(int i=1;i<=b;i++)if(isdigit(s[a+i])==false){flg=false;break;}
        }
    }
    puts(flg?"Yes":"No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main() {
	string s; cin >> s;
	ll ans = 0;
	rep(i, 0, s.size()) {
		if (!(i & 1)) {
			ans += s[i] == 'g' ? 0 : -1;
		}
		else {
			ans += s[i] == 'p' ? 0 : 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
	string S;
	cin >> S;
	cout << ( S.find( "F", S.find( "C" ) ) != string::npos ? "Yes" : "No" ) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb(a) push_back(a)
#define lint long long

const int INF = 1e9;
const int MOD = 1e9+7;
const lint LINF = 1e18;



using namespace std;
lint n,y;
lint a,b,c;


int main(){
  cin >> n >> y;
  REP(i,9){
    lint zan = y - 5000*i;
    lint mai = n-i;
    a = (zan-1000*mai)/9000;
    c = mai-a;
    b = i;
    //dump(a);
    //dump(b);
    //dump(c);
    if(a>=0&&b>=0&&c>=0&&a*10000+b*5000+c*1000==y){
      cout << a << " " << b << " " << c << endl;
      return 0;
    }
  }
  cout << "-1 -1 -1" <<endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var table = new Dictionary<string, int>()
            {
                {"SUN", 7},
                {"MON", 6},
                {"TUE", 5},
                {"WED", 4},
                {"THU", 3},
                {"FRI", 2},
                {"SAT", 1},
            };

            var S = Console.ReadLine();
            var answer = table[S];
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    
    string s;
    cin >> s;
    
    int sie = s.size() - 2;
    string size = to_string(sie); 
    
    cout << s.replace ( 1, sie, size ) << endl;
    

}


Measured memory_bytes: 3696
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;


namespace AtCoder
{
    class AtCoderrr
    {
        static void Main(string[] args)
        {
            int[] dn = ReadLine().Split(' ').Select(int.Parse).ToArray();


            if (dn[0] == 0)
            {
                if (dn[1] == 100)
                {
                    WriteLine(101);
                }
                else {
                    int[] tmp = Enumerable.Range(1, 100).ToArray();
                    WriteLine(tmp[dn[1] - 1]);
                }
            }
            else if (dn[0] == 1)
            {
                if(dn[1] == 100)
                {
                    WriteLine(10100);
                }
                else
                {
                    int[] tmp = Enumerable.Range(100, 10000).Where(x => x % 100 == 0).ToArray();
                    WriteLine(tmp[dn[1] - 1]);
                }
            }
            else
            {
                if (dn[1] == 100)
                {
                    WriteLine(1010000);
                }
                else
                {
                    int[] tmp = Enumerable.Range(10000, 1000000).Where(x => x % 10000 == 0).ToArray();
                    WriteLine(tmp[dn[1] - 1]);
                }
            }
        }
        
    }
}


Measured memory_bytes: 13396
#9_C
class player:
    def __init__(self):
        self.my_cards=[]
        self.point=0
    def draw(self,letter):
        self.my_cards.append(letter)

    def open(self,num):
        return self.my_cards[num]
    
    def buttle(self,letter,num):
        if(self.my_cards[num]>letter):
            self.point+=3
        elif(self.my_cards[num]==letter):
            self.point+=1
            
    def show(self):
        return self.point
    def check(self):
        return self.my_cards

##main##
n=int(input())
taro=player()
hanako=player()
for i in range(n):
    val=input().split()
    taro.draw(val[0])
    hanako.draw(val[1])
for i in range(n):
    taro.buttle(hanako.open(i),i)
    hanako.buttle(taro.open(i),i)
    
print(taro.show(),hanako.show())
    


Measured memory_bytes: 5620
N, W = map(int, input().split())
ITEM = []
vmax, wmax = 0,0
for _ in range(N):
  w,v = map(int, input().split())
  ITEM.append((v,w))
  vmax = max(vmax,v)
  wmax = max(wmax,w)

INF = 10**18
    
def solve2():
  #dp[i][w] i個目までを選んで、重さW以下で実現できる最大の価値
  # TLEしたらiを消す。
  dp = [0] * (wmax*N+1)
  dp[0] = 0
  for i in range(1,N+1):
    v1,w1 = ITEM[i-1]
    # dp[i]消すなら、wは大きい方から探索する
    for w in range(wmax*i,-1,-1):
      if w-w1>=0:
        dp[w] = max(dp[w], dp[w-w1]+v1)
  ret = max(dp[:W+1])
  
  #for d in dp:
    #print(dp[0:20])
  return ret

ans = solve2()
  
print(ans)

Measured memory_bytes: 142352
fun main(args: Array<String>) {
    abc084c()
}

fun abc084c() {
    val n = readLine()!!.toInt()
    val stations = mutableListOf<Station>()
    for (i in 0 until n - 1) {
        val (c, s, f) = readLine()!!.split(" ").map { it.toInt() }
        stations.add(Station(c, s, f))
    }
    val arrivedAt = IntArray(n) { 0 }
    for (i in 0 until n - 1) {
        val time = stations[i].run { cost + start }
        arrivedAt[i] = time
        for (j in 0 until i) {
            if (arrivedAt[j] < stations[i].start) {
                arrivedAt[j] = time
            } else {
                val nextTrain = Math.ceil(arrivedAt[j] / stations[i].interval.toDouble()).toInt() * stations[i].interval
                arrivedAt[j] = nextTrain + stations[i].cost
            }
        }
    }
    for (t in arrivedAt) {
        println(t)
    }
}

data class Station(val cost: Int, val start: Int, val interval: Int)

Measured memory_bytes: 38340
use std::collections::VecDeque;

fn get_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().to_string()
}

fn main() {
    let nl: Vec<_> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();

    let mut q = VecDeque::new();
    let mut sum = 0f64;

    for _ in 0..nl[0] {
        let tv: Vec<f64> = get_line().split(' ').map(|x| x.parse().unwrap()).collect();

        let mut nv = tv[1];
        while let Some((t, v)) = q.pop_front() {
            let mv = if v < nv {
                v
            }
            else {
                nv
            };

            sum -= t * mv;

            if v >= nv {
                q.push_front((t, v - nv));
                break;
            }
            else {
                nv -= v;
            }
        }

        sum += tv[0] * tv[1];
        println!("{:.7}", sum / nl[1] as f64);

        let mut nt = tv[0];
        let mut nv = tv[1];
        while let Some(&(t, v)) = q.back() {
            if t < nt {
                break;
            }

            nt = (nt * nv + t * v) / (nv + v);
            nv += v;
            q.pop_back();
        }

        q.push_back((nt, nv));
    }
}


Measured memory_bytes: 20040
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())  # S += [input()] とも書ける

A = []

d = collections.Counter(S)
max_v = max(d.values())

for k, v in d.items():
    if v == max_v:
        A.append(k)

A.sort()

for result in A:
    print(result)

Measured memory_bytes: 35572
#include <iostream>

using namespace std;

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

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
map <int, int> mp;
int M, T;

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    int D; cin >> D;
    mp[D]++;
  }
  cin >> M;
  for (int i = 0; i < M; i++){
    int T; cin >> T;
    if (mp[T] == 0){
      NO(); return 0;
    }
    mp[T]--;
  }
  YES();
  return 0;
}


Measured memory_bytes: 12972
#include <iostream>
using namespace std;
int main()
{
    int x[100000];
    int H, N, a=0;
    cin>>H>>N;
    for (int i=0;i<N;i++)
    {
        cin>>x[i];
        a=a+x[i];
    }
    if (a>=H) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define BE(x) x.begin(), x.end()

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

    vector<int> a(n+2), b(n+1);
    int sum = 0;
    a[0] = 0, a[n+1] = 0;
    for (int i = 1; i <= n+1; i++) {
        if (i < n+1) cin >> a[i];
        b[i-1] = abs(a[i-1]-a[i]);
        sum += b[i-1];
    }

    for (int i = 1; i <= n; i++) {
        int ans = sum - b[i-1] - b[i];
        ans += abs(a[i-1]-a[i+1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3976
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
  unsigned int N;
  std::cin >> N;

  std::vector<unsigned int> A_array(N + 1);
  for (unsigned int i = 0; i < N + 1; ++i) {
    std::cin >> A_array.at(i);
  }

  std::vector<unsigned int> B_array(N);
  for (unsigned int i = 0; i < N; ++i) {
    std::cin >> B_array.at(i);
  }

  unsigned long sum = 0;

  if (N == 1) {
    sum += std::min(A_array.at(0) + A_array.at(1), B_array.at(0));
    std::cout << sum << std::endl;
    return 0;
  }

  // left
  const unsigned int left_val = std::min(A_array.at(0), B_array.at(0));
  sum += left_val;
  B_array.at(0) -= left_val;
  // right
  const unsigned int right_val = std::min(A_array.at(N), B_array.at(N - 1));
  sum += right_val;
  B_array.at(N - 1) -= right_val;

  for (unsigned int i = 1; i < N; ++i) {
    const unsigned int first = std::min(A_array.at(i), B_array.at(i - 1));
    sum += first;
    A_array.at(i) -= first;
    const unsigned int second = std::min(A_array.at(i), B_array.at(i));
    sum += second;
    B_array.at(i) -= second;
  }

  std::cout << sum << std::endl;

  return 0;
}


Measured memory_bytes: 1024
// 2020-09-18 18:44:41
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
const int MX = 100010;
int in[MX], ans[MX];
vector<int> G[MX];
void answer() {
  int n, m;
  cin >> n >> m;
  rep(i, n - 1 + m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    in[b]++;
  }
  memset(ans, -1, sizeof ans);
  int s = -1;
  rep(i, n) if (in[i] == 0) {
    s = i;
    break;
  }
  queue<P> que;  // u, p
  que.emplace(s, -1);
  while (!que.empty()) {
    auto [u, p] = que.front();
    que.pop();
    ans[u] = p;
    for (int v : G[u]) {
      in[v]--;
      if (in[v] == 0) {
        que.emplace(v, u);
      }
    }
  }
  rep(i, n) { cout << ans[i] + 1 << '\n'; }
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

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

int main(){
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a.begin(),a.end());
  sort(f.rbegin(),f.rend());
  ll l = -1, r = 1e12;
  while(l+1<r){
    ll mid = (l+r)/2;
    ll s = 0;
    bool ok = [&]{
      rep(i,n){
      s += max(0ll,a[i]-mid/f[i]);
      }
      return s<=k;
    }();
    if(ok) r = mid; else l = mid;
  }
  cout << r << endl;
}


Measured memory_bytes: 1920
#include<cstdio>
#define For(i,A,B) for(i=(A);i<=(B);++i)
const int N=100050;
int a[N],b[N];
template<typename T> inline void chkmin(T &a,const T &b){if(b<a)a=b;}
int main(){
    int A,B,m,i,x,y,c,ans=0x3f3f3f3f,minn=0x3f3f3f3f;
    scanf("%d%d%d",&A,&B,&m);
    For(i,1,A){
        scanf("%d",a+i);
        chkmin(ans,a[i]);
    }
    For(i,1,B){
        scanf("%d",b+i);
        chkmin(minn,b[i]);
    }
    ans+=minn;
    while(m--){
        scanf("%d%d%d",&x,&y,&c);
        chkmin(ans,a[x]+b[y]-c);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
q = int(input())
for i in range(q):
    b, m, e = map(int, input().split())
    tmp = a[b:e]
    a = a[:b] + tmp[m-b:] + tmp[:m-b] + a[e:]
print(*a)


Measured memory_bytes: 5832