akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

void print_array(int *a, int n)
{
	for(int i = 0; i < n - 1; ++i)
	{
		printf("%d ", a[i]);
	}
	printf("%d\n", a[n-1]);
}

int main()
{
	int n, a[100];
	int loop = 1, cnt = 0;;

	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}

	while(loop)
	{
		loop = 0;
		for(int i = n - 1; i > 0; --i)
		{
			if(a[i] < a[i-1])
			{
				int temp = a[i];
				a[i] = a[i-1];
				a[i-1] = temp;

				++cnt;
				loop = 1;
			}
		}
	}
	print_array(a, n);
	printf("%d\n", cnt);
}



Measured memory_bytes: 2112
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int n,r;
    cin>>n>>r;
    if(n>=10){
        cout<<r<<endl;
    }else{
        cout<<r+(100*(10-n))<<endl;
    }





return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
ll ans = 0, sum = 0, n, k, cnt = 0, w, h;
string s;
vector<ll> v;
vector<ll> v1;
vector < pair<ll, ll > > vp;
vector<vector<ll> > vv(50, vector<ll>(50, INF));
vector<string> vs;
vector<char> vc;
set<ll> st;
map<char, ll> mp;

/*--------------------template--------------------*/

int main()
{
	cin >> n;
	REP(i, n)
	{
		cin >> k;
		v.push_back(k);
	}
	sort(ALL(v));
	REP(i, n - 1)
	{
		sum += v[i];
		if (2 * sum < v[i + 1])w = i + 1;
	}
	cout << n - w << endl;
}


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

/**
 * 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);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] v = new int[8];
            for (int i = 0; i < 3; ++i) v[in.nextInt()]++;
            if (v[5] == 2 && v[7] == 1) {
                out.println("YES");
            } else {
                out.println("NO");
            }
        }

    }

    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 int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21332
//
#include <atcoder/fenwicktree>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
#include <atcoder/string>
#include <atcoder/math>
#include <atcoder/convolution>
#include <atcoder/modint>
#include <atcoder/dsu>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/scc>
#include <atcoder/twosat>
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1000000007L;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    rep(i, K)
    {
        cout << "ACL";
    }
    return 0;
}

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

int main(){
  int n,m,x,y;
  cin>>n>>m>>x>>y;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    x=max(x,a);
  }
  for(int i=0;i<m;i++){
    int a;
    cin>>a;
    y=min(y,a);
  }
  cout<<(x<y?"No ":"")<<"War"<<endl;
  return 0;
}


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

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

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

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

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

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

int main() {

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

	int H, W;
	cin >> H >> W;

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> B[i][j];

	const int offset = 6500;
	auto dp = make_vec(W + 1, offset * 2 + 1, 0);
	dp[0][offset] = 1;
	for (int i = 0; i < H; i++) {

		for (int j = 0; j < W; j++) {

			for (int k = 0; k <= 2 * offset; k++) {

				if (0 <= k + A[i][j] - B[i][j] && k + A[i][j] - B[i][j] <= 2 * offset) {
					dp[j + 1][k] |= dp[j][k + A[i][j] - B[i][j]];
				}
				if (0 <= k - A[i][j] + B[i][j] && k - A[i][j] + B[i][j] <= 2 * offset) {
					dp[j + 1][k] |= dp[j][k - A[i][j] + B[i][j]];
				}
				
			}

		}
		DMP(dp);

		if (i == H - 1) break;
		auto tmp = make_vec(W + 1, offset * 2 + 1, 0);
		for (int j = 1; j <= W; j++) {
			for (int k = 0; k <= 2 * offset; k++) {
				if (0 <= k + A[i + 1][j - 1] - B[i + 1][j - 1] && k + A[i + 1][j - 1] - B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] |= dp[j][k + A[i + 1][j - 1] - B[i + 1][j - 1]];
				}
				if (0 <= k - A[i + 1][j - 1] + B[i + 1][j - 1] && k - A[i + 1][j - 1] + B[i + 1][j - 1] <= 2 * offset) {
					tmp[j][k] |= dp[j][k - A[i + 1][j - 1] + B[i + 1][j - 1]];
				}
			}
		}
		swap(tmp, dp);
		DMP(dp);

	}

	int ans = INF;
	for (int i = 0; i <= 2 * offset; i++) {
		if(dp[W][i]) chmin(ans, abs(i - offset));
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 10592
import sys
input = sys.stdin.readline

N = int(input())
x = list(map(int, input().split()))
mod = 10**9 + 7

fact = [1] * (N+1)
fact_inv = [1] * (N+1)
for i in range(1, N+1):
    fact[i] = i * fact[i-1] % mod
fact_inv[N] = pow(fact[N], mod-2, mod)
for i in range(1, N+1)[::-1]:
    fact_inv[i-1] = i * fact_inv[i] % mod

cnt = 0
ans = 1
take = False
for a in x:
    if take:
        ans = ans * cnt % mod
        cnt -= 1
        take = False
    if 2 * cnt == a:
        take = True
        cnt += 1
        continue
    if 2 * cnt > a:
        ans = ans * cnt % mod
        cnt -= 1
        take = False
    cnt += 1
ans = ans * fact[cnt] % mod
print(ans)


Measured memory_bytes: 58864
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(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)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<pair<int, int>, int>> coord(n);
    REP(i, n) {
        int x, y, h;
        cin >> x >> y >> h;
        coord[i].first.first = x;
        coord[i].first.second = y;
        coord[i].second = h;
    }

    REP(cx, 101)REP(cy, 101) {
        int std_index = 0;
        REP(i, n) {
            if(coord[i].second == 0) continue;
            std_index = i;
            break;
        }
        int x = coord[std_index].first.first;
        int y = coord[std_index].first.second;
        int ch = coord[std_index].second + abs(cx - x) + abs(cy - y);
        REP(i, n) {
            int x = coord[i].first.first;
            int y = coord[i].first.second;
            int h = coord[i].second;
            if(max(ch - abs(x - cx) - abs(y - cy), 0) != h) break;
            if(i == n - 1) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
from sys import stdin
a = stdin.readline().strip()
b = stdin.readline().strip()
ans = 'Yes'
di = {} 
hi = {}
n = len(a)
for i in xrange(n):
    if a[i] in di and di[a[i]]!=b[i]:
        ans = 'No'
        break 
    if b[i] in hi and hi[b[i]]!=a[i]:
        ans = 'No'
        break 
    hi[b[i]] = a[i]
    di[a[i]] = b[i] 
print ans

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

int main() {
  int n;
  string a, b, c;
  cin >> n >> a >> b >> c;
  int result = 0;
  int i;
  for (i = 0; i < n; i++) {
    if (a.at(i) != b.at(i) && b.at(i) != c.at(i) && c.at (i) != a.at(i)) {
      result += 2;
    } else if (a.at(i) != b.at(i) || b.at(i) != c.at(i)) {
      result++;
    }
  }
  cout << result << endl;
  return 0;
}


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

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N + 2, 0);
  for (int i = 1; i <= N; ++i) {
    std::cin >> A[i];
  }
  long long base = 0;
  for (int i = 0; i <= N; ++i) {
    base += std::abs(A[i + 1] - A[i]);
  }
  for (int i = 1; i <= N; ++i) {
    std::cout << base - std::abs(A[i + 1] - A[i]) - std::abs(A[i] - A[i - 1]) + std::abs(A[i + 1] - A[i - 1])
              << std::endl;
  }
  return 0;
}

Measured memory_bytes: 2048
n,x=map(int,input().split())

arr=[1]*(n+1)
patty=[1]*(n+1)
for i in range(n):
    arr[i+1]=3+2*arr[i]
    patty[i+1]=1+2*patty[i]

def f(n,x):
    
    if n==0:
        return 1
    elif x==1:
        return 0
    elif x==arr[n] or x==arr[n]-1:
        return patty[n]
    elif x<arr[n]//2+1:
        return f(n-1,x-1)
    elif x==arr[n]//2+1:
        return patty[n-1]+1
    else:
        return patty[n]-f(n-1,arr[n]-x-1)

print(f(n,x))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

const int MAXN = 500500;
int n, q;
string s;
int fen[MAXN][26];

int ctoi(char c) {
    return (int) c - (int) 'a';
}

void add(int i, char c) {
    while (i < MAXN) {
        fen[i][ctoi(c)]++;
        i += i & (-i);
    }
}

void subtract(int i, char c) {
    while (i < MAXN) {
        fen[i][ctoi(c)]--;
        i += i & (-i);
    }
}

vector<int> pref(int i) {
    vector<int> ans(26, 0);
    while (i) {
        fo (j, 26) ans[j] += fen[i][j];
        i -= i & (-i);
    }
    return ans;
} 

int query(int el, int r) {
    vector<int> rd = pref(r);
    vector<int> ld = pref(el-1);
    
    int ans = 0;
    fo(i, 26) if (rd[i] > ld[i]) ans++;
    return ans;
}

void solve() {
    cin >> n >> s >> q;
    int type, i, el, r; char c;
    fo(i, n+1){
        fo(j, 26) fen[i][j] = 0;
    }
    fo(i, n) add(i+1, s[i]);
    while (q--) {
        cin >> type;
        if (type == 1) {
            cin >> i >> c;
            subtract(i, s[i-1]);
            s[i-1] = c;
            add(i, c);
        }
        else {
            cin >> el >> r;
            pld(query(el, r));
        }
    }
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 51716
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
																													   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////


///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////

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

LL f(LL x, LL c, LL d){
	
	LL ans = x;
	ans -= x/c;
	ans -= x/d;
	ans += x/lcm(c, d);
	
	return ans;
}
/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	LL a, b, c, d;
	cin >> a >> b >> c >> d;
	
	LL ans = f(b, c, d) - f(a-1, c, d);
	cout << ans << endl;
	
	
	

	
	
	
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int h[n];
  for (int i=0; i<n; ++i) {
    cin >> h[i];
  }
  
  for (int i=1; i<n; ++i) {
    int last_h = h[i-1];
    int& cur_h = h[i];
    int dif = cur_h - last_h;
    if (0 < dif) {
      --cur_h;
    }
  }
  bool flg = true;
  for (int i=0; i<n-1; ++i) {
    int cur_h = h[i];
    int next_h = h[i+1];
    int dif = next_h - cur_h;
    if (dif < 0) {
      flg = false;
      break;
    }
  }
  if (flg) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N,A,B;
  cin >> N >> A >> B;

  int t = B - A - 1;
  if(t % 2 != 0) cout << "Alice" << endl;
  else cout << "Borys" << endl;
}


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


int main(){
	int N,ans,c=0,t=0; cin >> N;
	ans=N;
	for(int i=0; i<N+1; i++){
		t=i,c=0;
		while(t>0){
			c+=t%6;
			t/=6;
		}t=N-i;
		while(t>0){
			c+=t%9;
			t/=9;
		}if(ans>c) ans=c;
	}
	cout << ans << endl;
}

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

#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() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int result = 1; // 一番西のは必ず海が見える
  int maxHeight = h[0];
  for (int i = 1; i < n; ++i) {
    if (h[i] >= maxHeight) {
      result++;
      maxHeight = h[i];
    }
  }
  cout << result << endl;

  return 0;
}


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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define debug if(true)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int x;
	cin>>x;
	ll ans = (x/500)*1000;
	x %= 500;
	while(x >= 5){
		ans += 5;
		x-=5;
	}
	printf("%lld\n",ans);
	return 0;
};

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

const MOD: usize = 1e9 as usize + 7;

fn main() {
    input!{
      n: usize,
      m: usize,
      ss: [usize; n],
      ts: [usize; m],
    }
    let mut dp = vec![0usize; n+1];
    dp[0] = 1;
    for i in 0..m {
        let t = ts[i];
        let mut acm = dp[0];
        for i in 0..n {
            let s = ss[i];
            acm += dp[i+1];
            acm %= MOD;
            if s == t {
                dp[i+1] = acm;
            }
        }
    }
    let mut ans = 0;
    for v in dp {
        ans += v;
        ans %= MOD;
    }
    println!("{}", ans);
}


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

int main()
{
    int n; cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    rep(i, n) cin >> b[i];
    sort(b.begin(), b.end());
    rep(i, n) cin >> c[i];
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, n) {
        ans +=  (lower_bound(a.begin(), a.end(), b[i]) - a.begin())
            * (c.end() - upper_bound(c.begin(), c.end(), b[i]) );
    };
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
import math
N = int(input())
A = list(map(int, input().split()))

answer = A[0]
Sum = 0

def gcd(A,B):
    if(B == 0):
        return A
    else:
        return gcd(B, A%B)

#最小公倍数-1がfに入る数なはず
for i in range(1, N):
    answer = answer * A[i] // gcd(answer, A[i])
    
for i in range(N):
    Sum += (answer-1) % A[i]

print(Sum)

Measured memory_bytes: 50032
n = int(input())
strings = [''.join(sorted(list(input()))) for i in range(n)]
dictionary = {}
ans = 0
for i in range(n) :
    if strings[i] in dictionary :
        ans += dictionary[strings[i]]
        dictionary[strings[i]] += 1
    else :
        dictionary[strings[i]] = 1
print(ans)

Measured memory_bytes: 66904
P,M,*d='x+y,','x-y,',[],[],[],[]
for t in[*open(0)][1:]:*z,u=t.split();d[ord(u)%5]+=[*map(int,z)],
I=N=9**9
for*A,S in(3,0,'x,y,'),(1,2,'y,x,'),(0,2,P+M),(1,3,P+M),(1,0,M+P),(3,2,M+P):
 n=p=-I
 for x,y,r in eval('sorted((%sQ)for Q,P in enumerate(A)for x,y in d[P])'%S):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(N%I*5or'SAFE')

Measured memory_bytes: 71496
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k,a0,a1,ans;
int main()
{
	cin>>n>>k;
	a1=0;
	ans=0;
	/*
	for(int i=1;i<=n;i++)if(!(i%k))a1++;
	//*/
	///*
	a1+=n/k;
	//*/
	ans+=(a1*a1*a1);
	if(!(k&1))
	{
		a0=(k>>1);
		a1=0;
		///*
		for(int i=0;i<=(n-a0);i++)if(!(i%k))a1++;
		//*/
		/*
		a1+=((n-a0)/k);
		//*/
		ans+=(a1*a1*a1);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    long long n;
    string ff;
    cin >> n >> ff;
    vector <int> qw (n);
    vector <int> qw1 (n);
    long long f=0;
    for (int i=0; i<n; ++i)
        if (ff[i]=='R')
        {
            f+=1;
            qw[i]=1;
        }
    long long t=0;
    long long tt=min(f, n-f);
    for (int i=0; i<f; ++i)
        qw1[i]=1;
    for (int i=0; i<n; ++i)
        if (qw[i]!=qw1[i])
            t+=1;
    cout << min(t/2, tt) << endl;
}


Measured memory_bytes: 5244
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define mp make_pair
#define pii pair<int, int>
#define PB push_back
#define F first
#define S second
#define Task ""
using namespace std;
long long a, b;
int c[41], cnt[41];

long long calc(long long n) {
    if(n<=0) return 0;
    if(n==1) return 1;
    int last=-1;
    memset(c, 0, sizeof c);
    for(int i=39 ; i>=0 ; --i) {
        if((n>>i)&1) {
            ++c[i];
            if(last==-1) last=i;
        }
    }
    rep(i, 1, last) c[i]+=c[i-1];
    long long ans=0;
    memset(cnt, 0, sizeof cnt);

    if(last==1) cnt[0]=1;
    if(c[0]) cnt[0]^=1;
    for(int i=last-1 ; i ; --i) {
        if(c[i]-c[i-1]==0) continue;
        cnt[0]=(0ll+cnt[0]+(1ll<<(i-1)))%2;
    }

    rep(i, 1, last) {
            if(c[i]-c[i-1]==0) continue;
            cnt[i]=1;
            int xx=0;
            for(int j=last-1 ; j>i ; --j) {
                if(c[j]-c[j-1]==0) continue;
                xx=(0ll+xx+(1ll<<(j-1)))%2;
            }
            for(int j=i-1 ; j>=0 ; --j) {
                if(c[j]-c[j-1]==0) continue;
                xx=(0ll+xx+(1ll<<j))%2;
            }
            if(xx) cnt[i]=0;
    }
    rep(i, 0, last) {
        if(cnt[i]&1) ans+=(1ll<<i);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> a >> b;
    long long ans=(calc(b)^calc(a-1));
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
using namespace std;
using ll = long long;

int main(){
        ll K,n;
        cin >> K;
        queue<ll> q;
        for(int i=1;i<10;++i) q.push(i);
        while(1){
                n = q.front();
                q.pop(); --K;
                if(K==0){
                        cout << n << endl;
                        return 0;
                }
                if(n%10!=0) q.push(n*10+n%10-1);
                q.push(n*10+n%10);
                if(n%10!=9) q.push(n*10+n%10+1);
        }
}

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


void solve() {
  int W, H, N;
  cin >> W >> H >> N;
  int x1 = 0, y1 = 0;
  int x , y , a;
  for (int i = 1; i <= N; i++) {
    cin >> x >> y >> a;
    if(a == 1 && x1 < x) {
      x1 = x;
    }
    else if (a == 2 && W > x) {
      W = x;
    }
    else if (a == 3 && y1 < y) {
      y1 = y;
    }
    else if (a == 4 && H > y) {
      H = y;
    }
  }
  W -= x1;
  H -= y1;
  if(W <= 0 || H <= 0) {
    cout << 0;
  }
  else {
  cout << W*H;
  }

}

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


Measured memory_bytes: 256
from heapq import heapify, heappush, heappop

def main():
    X, Y, A, B, C = map(int, input().split())
    P = list(map(int, input().split()))
    Q = list(map(int, input().split()))
    R = list(map(int, input().split()))

    P.sort(reverse=True)
    Q.sort(reverse=True)
    PQR = P[:X] + Q[:Y] + R
    PQR.sort(reverse=True)    
    print(sum(PQR[:X+Y]))
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 23456
n = int(input())
h = list(map(int,input().split()))
for i in range(1, n):
    if h[i] -h[i - 1] < 0:
        h[i] += 1
    if h[i] - h[i - 1] >= 0:
        continue
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 20652
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

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

using namespace std;
typedef pair<int, int> pint;

int main() {
    string s; cin >> s;
    int n = s.length();
    int iter = n / 2;
    int ans = 0;
    rep(i, iter) {
        if (s[i] == s[n - i - 1]) {
            continue;
        }   
        else {
            ans++;
        }   
    }   
    cout << ans << endl;
}


Measured memory_bytes: 256
N=int(input())
S=[]
C=[0]*4

for i in range(N):
    s=input()
    if s=="AC":
        C[0]+=1
    if s=="WA":
        C[1]+=1
    if s=="TLE":
        C[2]+=1
    if s=="RE":
        C[3]+=1
print("AC","x",C[0])
print("WA","x",C[1])
print("TLE","x",C[2])
print("RE","x",C[3])

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n, a, b;
    cin >> n >> a >> b;

    // 処理
    // 出力
    cout << min(n * a, b) << endl;

    return 0;
}


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

int main(){
  int h,w;

  while(1){
  cin >> h >>w;
  if (( h == 0 && w == 0)||( 300 < h || 300 < w) )break;
    for (int i = 0; i < h; i++ ){
      for (int j = 0; j < w; j++ ){
        if(( 0 < i && i < h-1) && ( 0 < j && j < w-1) ){
	  cout << ".";
        } else {
	  cout << "#";
	}

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

Measured memory_bytes: 1152
from bisect import bisect_left
import sys

input = sys.stdin.buffer.readline

n = int(input())
A = [0] + list(map(int, input().split()))
graph = [[] for _ in range(n + 1)]
for _ in range(n - 1):
    u, v = map(int, input().split())
    graph[v].append(u)
    graph[u].append(v)

start = 1

stack = [1]
par = [-1] * (n + 1)
ans = [0] * (n + 1)
used = [False] * (n + 1)
infi = 10 ** 20
LIS = [infi] * (n + 1)
LIS[0] = -infi
position = [(-1, -1)] * (n + 1)


def hantei(val, L):
    pos = bisect_left(L, val)
    pre = L[pos]
    L[pos] = val
    cnt = bisect_left(L, infi)
    return L, pos, pre, cnt


while stack:
    v = stack[-1]
    if not used[v]:
        LIS, pos, pre, cnt = hantei(A[v], LIS)
        position[v] = (pos, pre)
        ans[v] = cnt - 1
    used[v] = True
    if not graph[v]:
        _ = stack.pop()
        basho, atai = position[v]
        LIS[basho] = atai
        continue
    u = graph[v].pop()
    if u == par[v]:
        continue
    par[u] = v
    stack.append(u)

print(*ans[1:], sep="\n")


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int MOD2 = 1007681537;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-12;
inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll fpow(ll n, ll k, int p = MOD) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = r * n % p; n = n * n % p;} return r;}
template<class T> inline int chkmin(T& a, const T& val) {return val < a ? a = val, 1 : 0;}
template<class T> inline int chkmax(T& a, const T& val) {return a < val ? a = val, 1 : 0;}
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}
inline int inv(int a, int p = MOD) {return fpow(a, p - 2, p);}
inline int sign(ld x) {return x < -EPS ? -1 : x > +EPS;}
inline int sign(ld x, ld y) {return sign(x - y);}
#define db(x) cerr << #x << " = " << (x) << " ";
#define endln cerr << "\n";

void solve() {
    string s; cin >> s;
    cout << s.substr(0, sz(s) - 8) << "\n";
}

int main() {
    int JUDGE_ONLINE = 1;
    if (fopen("in.txt", "r")) {
        JUDGE_ONLINE = 0;
        assert(freopen("in.txt", "r", stdin));
        //assert(freopen("out.txt", "w", stdout));
    }
    else {
        ios_base::sync_with_stdio(0), cin.tie(0);
    }
    solve();
    if (!JUDGE_ONLINE) {
        //cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int K;
ull A[100000 + 5];
int main() {
  ios::sync_with_stdio(false);
  cin >> K;
  int ind = 0;
  for (int i = 0; i < K; ++i) {
    ull c;
    cin >> c;
    A[ind++] = c;
  }
  K = ind;
  ull low = 2;
  ull up = 2;
  // cerr << K << endl;
  if (A[K - 1] != 2) {
    cout << -1;
    return 0;
  }
  for (int i = K - 1; i >= 0; --i) {
    ull lo2 = ((low - 1) / A[i] + 1) * A[i];
    ull up2 = ((up) / A[i]) * A[i] + A[i] - 1;
    
    if (lo2 > up || lo2 > up2) {
      cout << -1;
      return 0;
    }
    low = lo2;
    up = up2;
    // cerr << low << ' ' << up << endl;
  }
  cout << low << " " << up;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
	int n,d[101],i,j,s=0;

	scanf("%d",&n);
	for(i=0;i<n;i++)
		scanf("%d",&d[i]);
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
			s+=d[i]*d[j];
	printf("%d",s);
	return 0;
}

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

bool judge(ll a,ll b,ll c){
    if(a%2==1 || b%2==1 || c%2==1){return false;}
    if(a==b && b==c){return true;}
    return true;
}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2==1 || b%2==1 || c%2==1){cout<<0<<endl;}
    else if(a==b && b==c){cout<<-1<<endl;}
    else{
        ll count=0;
        while(judge(a,b,c)){
            ll ad,bd,cd;
            ad=b/2+c/2;
            bd=a/2+c/2;
            cd=a/2+b/2;
            a=ad; b=bd; c=cd;
            count++;
        }
        if(a==b && b==c){cout<<-1<<endl;}
        else{cout<<count<<endl;}
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;

static const int  MAX_INT = std::numeric_limits<int>::max();
static const long MAX_LONG = std::numeric_limits<long>::max();
static const ll   MAX_LL = std::numeric_limits<long long>::max();

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


///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
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; }

// auto mod int
struct mint {
    static const int mod = 1000000007;
    long long x; // typedef long long ll;
    mint(long long x = 0) :x((x%mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x; }
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
    ll N; cin >> N;
    ll pten = 10, pnine = 9, peight = 8;
    rep(i, N-1) {
        pten   = (pten * 10) % MOD;
        pnine  = (pnine * 9) % MOD;
        peight = (peight * 8) % MOD;
    }
    ll res = (pten - 2 * pnine + peight) % MOD;
    if (res < 0) res += MOD;
    cout << res << endl;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout << std::fixed << std::setprecision(15);
    Main();

    double tmp;
    cin >> tmp;

    return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <algorithm>
#include <cmath>
#define ll long long
 
using namespace std;
 
ll gcd(ll a,ll b){
  if(a<b) return gcd(b,a);
  if(b==0) return a;
  return gcd(b,a%b);
}
 
ll cnt=1;
int main(){
 
 ll a,b; 
 cin>>a>>b;
 
 ll G;
 G=gcd(a,b);
 ll dv=2;
 while(G>1){
  if(G%dv==0){
   while(G%dv==0){
     G/=dv;
   }
   cnt++;
  }
  dv++;
  if(dv>1000000) break;
 }
 
 if(G>1) cnt++;
 cout<<cnt<<endl;
 return 0;
}

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

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

using namespace std;
using ll = long long;
using P = pair<int, int>;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<ll> d(n+1, 0);
    rep(i, n) {
        cin >> a[i];
        d[a[i]]++;
    }
    ll sum = 0;
    rep(i, n+1) {
        if (d[i] >= 2) {
            sum += (d[i] * (d[i] - 1)) / 2;
        }
    }
    rep(i, n) {
        cout << sum - (d[a[i]] - 1) << endl;
    }
    return 0;
}

Measured memory_bytes: 5520
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;

// to container
template <class C>
void input(C &c)
{
    for_each(c.begin(), c.end(), [](auto &i) { cin >> i; });
}

// to number, string
template <class T>
T input()
{
    T data;
    cin >> data;
    return data;
}

int main()
{
    ll N = input<ll>();
    vector<ll> a(N, 0);
    input(a);

    double res = 0;
    for_each(a.begin(), a.end(), [&](auto x) { res += 1 / (double)x; });
    cout << fixed;
    cout << setprecision(10) << 1 / res << endl;

    return 0;
}

Measured memory_bytes: 256
use proconio::{input, marker::Usize1};

fn main() {
    input!(n: usize, q: usize, c: [Usize1; n], lr: [(Usize1, usize); q]);
    let mut queries: Vec<_> = lr
        .into_iter()
        .enumerate()
        .map(|(i, (l, r))| (l, r, i))
        .collect();
    let k = (n as f64).sqrt() as usize;
    queries.sort_by_key(|&(l, r, _)| (l / k, if l / k % 2 == 0 { r } else { n - r }));
    let mut mul = vec![0; n];
    let mut kind = 0;
    #[inline]
    fn add(i: usize, c: &[usize], kind: &mut usize, mul: &mut [usize]) {
        if mul[c[i]] == 0 {
            *kind += 1;
        }
        mul[c[i]] += 1;
    }
    #[inline]
    fn sub(i: usize, c: &[usize], kind: &mut usize, mul: &mut [usize]) {
        mul[c[i]] -= 1;
        if mul[c[i]] == 0 {
            *kind -= 1;
        }
    }
    let mut i = 0;
    let mut j = 0;
    let mut ans = vec![None; q];
    for (l, r, query_id) in queries {
        while j < r {
            add(j, &c, &mut kind, &mut mul);
            j += 1;
        }
        while l < i {
            i -= 1;
            add(i, &c, &mut kind, &mut mul);
        }
        while r < j {
            j -= 1;
            sub(j, &c, &mut kind, &mut mul);
        }
        while i < l {
            sub(i, &c, &mut kind, &mut mul);
            i += 1;
        }
        ans[query_id] = Some(kind);
    }
    for x in ans.iter().copied().map(Option::unwrap) {
        println!("{}", x);
    }
}


Measured memory_bytes: 39188
#include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>

using namespace std;

//0016
int main(){
	const double PI = M_PI;
	double x=0.0, y=0.0;
	int deg;
	int acc=90;
	int f=0;

	while(1){
		scanf("%d,%d", &f, &deg);
		if(!f && !deg)break;

		double rad = (double)acc/180*PI;
		x += f * cos(rad);
		y += f * sin(rad);
		acc = (acc - deg);

	}

	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}

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

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

    ll sum = 0;
    for (ll i = k; i <= n+1; i++) {
        ll minv = (i * (i - 1) / 2);
        ll maxv = ((2 * n - i + 1) * i / 2 + 1);
        sum += maxv - minv;
    }

    cout << sum % M << endl;

    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=100+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("in","r",stdin);
	freopen("out","w",stdout);
#endif
}
ll A,B,C,K;
void work()
{
	A=read<ll>(),B=read<ll>(),C=read<ll>(),K=read<ll>();
	write((A-B)*(K&1?-1:1),'\n');
}
int main()
{
	//file();
	work();
	return 0;
}


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

const int Inf = 1000000000;
const int Maxn = 305;

string S;
int k;
int dp[Maxn][Maxn][Maxn];
int res;

int main()
{
	cin >> S;
	cin >> k;
	fill((int*)dp, (int*)dp + Maxn * Maxn * Maxn, -Inf);
	dp[0][int(S.length()) - 1][0] = 0;
	for (int i = 0; i < S.length(); i++)
		for (int j = int(S.length()) - 1; j >= 0; j--)
			for (int l = 0; l <= k; l++) if (dp[i][j][l] >= 0) {
				if (i == j) { res = max(res, dp[i][j][l] + 1); continue; }
				else if (i > j) { res = max(res, dp[i][j][l]); continue; }
				if (S[i] == S[j]) dp[i + 1][j - 1][l] = max(dp[i + 1][j - 1][l], dp[i][j][l] + 2);
				dp[i + 1][j][l] = max(dp[i + 1][j][l], dp[i][j][l]);
				dp[i][j - 1][l] = max(dp[i][j - 1][l], dp[i][j][l]);
				if (l + 1 <= k) dp[i + 1][j - 1][l + 1] = max(dp[i + 1][j - 1][l + 1], dp[i][j][l] + 2);
			}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 111104
//??????????????°???????????\??????????§£???
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

int powmod(int a, int n, int mod) {
	int ret = 1;
	for (int i = 0; i < 60; i++) {
		if ((n >> i) & 1) { ret *= a; ret %= mod; }
		a *= a;
		a %= mod;
	}
	return ret;
}

void setRollingHash(string &s, int rolling[], int base, int mod) {
	int n = s.length();
	rolling[0] = 1;
	for (int i = 1; i <= n; i++) {
		rolling[i] = (rolling[i - 1] + s[i - 1] * powmod(base, i, mod)) % mod;
	}
}

int base = 114514901;
int mod[3] = {1000000007, 500000003, 1145141923};
int rolling[3][300001];

int n, m;
string s;
string query;
int l, r;		//[l, r), 0-indexed

int getHash(int l, int r, int type) {
	//(rolling[type][r] - rolling[type][l]) / base^l
	int x = (rolling[type][r] - rolling[type][l] + mod[type]) % mod[type];
	return (x * powmod(base, l * (mod[type] - 2), mod[type])) % mod[type];
}

signed main() {
	cin >> n >> m >> s;
	l = 0, r = 1;
	
	for (int type = 0; type < 3; type++) setRollingHash(s, rolling[type], base, mod[type]);
	
	vector<vector<int>> hashs;
	hashs.resize(m);
	for (int i = 0; i < m; i++) {
		cin >> query;
		if (query == "L++") l++;
		if (query == "L--") l--;
		if (query == "R++") r++;
		if (query == "R--") r--;
		for (int j = 0; j < 3; j++) {
			hashs[i].push_back(getHash(l, r, j));
		}
	}
	
	sort(hashs.begin(), hashs.end());
	hashs.erase(unique(hashs.begin(), hashs.end()), hashs.end());
	cout << hashs.size() << endl;
	return 0;
}

Measured memory_bytes: 31340
#include<iostream>
#include<string>

using namespace std;

int main(){
    string s;
    cin >> s;
    string A[3] = {"Sunny", "Cloudy", "Rainy"};
    for (int i = 0; i < 3; i++)
    {
        if(s==A[i])
        {
            cout << A[(i + 1) % 3] << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;


    class Program
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());

            List<string> input = new List<string>();
            input.AddRange(Console.ReadLine().Split(' '));
            
            List<int> Height=new List<int>();

            int current=0;
            int Max=0;

            foreach(string s in input)
            {
                Height.Add(int.Parse(s));
            }

            for(int i=0; i<N-1; i++)
            {
               if(Height[i]<Height[i+1])
                {
                    current=0;
                }
                else
                {
                    current++;
                    if(Max<current)
                    {
                        Max=current;
                    }
                }
            }
        Console.WriteLine(Max);
        }
    }


Measured memory_bytes: 29276