akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
const int INF = 1e15;

signed main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, 0, n) cin >> a[i];
    int ans = 0;
    rep(i, 0, n){
        rep(j, i + 1, n){
            ans = max(ans, abs(a[i] - a[j]));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "a.cpp"

int main() {
  rep(i, 5) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << i+1 << el;
      return 0;
    }
  }
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(b<a)a=b
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1,  0};
constexpr int dy[] = {0, 1,  0, -1};
constexpr char dir[4] = {'r', 'u', 'l', 'd'};
#define N 4
#define N2 16
#define LIMIT 100
vv(int, MDT, N2, N2, 0);
struct Puzzle {
	vi f;
	int space, MD;
	Puzzle (int s = 0, int m = 0) : space(s), MD(m) {
		vi a(N2, 0);
		f = a;
	}
};
Puzzle state;
int limit;
vi path(LIMIT, 0);
int getAllMD(Puzzle pz) {
	int sum = 0;
	rep(i, 0, N2) {
		if(pz.f[i] == N2) continue;
		sum += MDT[i][pz.f[i] - 1];
	}
	return sum;
}
bool isSolved() {
	rep(i, 0, N2) if(state.f[i] != i + 1) return false;
	return true;
}
bool dfs(int depth, int prev) {
	if(state.MD == 0) return true;
	if(depth + state.MD > limit) return false;
	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;
	int tx, ty;
	rep(r, 0, 4) {
		tx = sx + dx[r];
		ty = sy + dy[r];
		if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
		if(max(prev, r) - min(prev, r) == 2) continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[tx * N + ty], state.f[sx * N + sy]);
		state.space = tx * N + ty;
		if(dfs(depth + 1, r)) { path[depth] = r; return true; }
		state = tmp;
	}
	return false;
}
string iterative_deepening(Puzzle in) {
	in.MD = getAllMD(in);
	string ans = "";
	for(limit = in.MD; limit <= LIMIT; ++limit) {
		state = in;
		if(dfs(0, -100)) {
			ans = "";
			rep(i, 0, limit) ans += dir[path[i]];
			return ans;
		}
	}
	return "unsolvable";
}
int main() {
	rep(i, 0, N2) {
		rep(j, 0, N2) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle in;
	rep(i, 0, N2) {
		cin >> in.f[i];
		if(in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}
	P(len(iterative_deepening(in)));
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}

int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    if (a > b) {
        cout << b << endl;
    }else{
        cout << a <<endl;
    }
    if (a + b - n > 0) {
        cout << a + b - n << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))

L=abs(a[0])+abs(a[N-1])
for i in range(N-1):
    L+=abs(a[i]-a[i+1])


print(L-abs(a[0])-abs(a[0]-a[1])+abs(a[1]))

for i in range(1,N-1):
    print(L-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]) )

print(L-abs(a[N-1])-abs(a[N-2]-a[N-1])+abs(a[N-2]))

Measured memory_bytes: 14176
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  [a,b,c] <- map read . words <$> getLine :: IO [Int]                                                                                                 
  putStrLn $ if (a <= c && c <= b) || (b <= c && c <= a) then "Yes" else "No"

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main()
{
    int n;
    cin >> n;
    vector<P> m[n];

    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        rep(i, k)
        {
            int v, c;
            cin >> v >> c;
            m[u].push_back(make_pair(v, c));
        }
    }

    priority_queue<P, vector<P>, greater<P>> pq;
    int d[n];
    rep(i, n) d[i] = INT_MAX;
    d[0] = 0;
    pq.push(make_pair(0, 0));
    while (!pq.empty())
    {
        P p = pq.top();
        pq.pop();
        int u = p.second;
        if (d[u] < p.first)
            continue;
        rep(j, m[u].size())
        {
            int v = m[u][j].first;
            if (d[v] > d[u] + m[u][j].second)
            {
                d[v] = d[u] + m[u][j].second;
                pq.push(make_pair(d[v], v));
            }
        }
    }

    rep(i, n)
    {
        cout << i << " " << d[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 7760
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
#include <map>
#include <utility>
#include <list>
#include <climits>
#include <bitset>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());
#define ll long long int

int main(){
    int n, m;
    cin >> n >> m;
    set<int> a, o, s, t;
    
    rep(i, n){
        int l;
        cin >> l;
        t.insert(l);
        o.insert(l);
    }
    
    rep(i, m){
        int l;
        cin >> l;
        s.insert(l);
        o.insert(l);
    }
    
    repi(i, s){
        if(t.find(*i) != t.end()){
            a.insert(*i);
        }
    }
    cout << a.size() << " " << o.size() << endl;
    repi(i, a){
        cout << *i << endl;
    }
    repi(i, o){
        cout << *i << endl;
    }
    
    return 0;
}



Measured memory_bytes: 25852
using System;

namespace C_Otoshidama
{
    class Program
    {
        static void Main(string[] args)
        {
            bool hantei = false;
            var line = Console.ReadLine().Split();
            int mai = int.Parse(line[0]);
            int gaku = int.Parse(line[1]);
            // x:10000円札
            int x = -1;
            // y:5000円札
            int y = -1;
            // z:1000円札
            int z = -1;

            // a:10000円の枚数
            for(int a = 0; a <= mai; a ++)
            {
                if (hantei) break;
                // b:5000円札の枚数
                for(int b = 0; b <= mai - a; b++)
                {
                    if (hantei) break;
                    // 枚数から10000円の枚数と5000円の枚数を引いた分が1000円の枚数になる。
                    if(10000 * a + 5000 * b + 1000 * (mai - a - b) == gaku)
                    {
                        x = a;
                        y = b;
                        z = mai - a - b;
                        hantei = true;
                    }
                }
            }

            Console.WriteLine(x.ToString() + " " + y.ToString() + " " + z.ToString());
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
 
using namespace std;
 
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)

long gcd(long a, long b){
	if (a%b==0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}
}

long lcm(long a, long b){
	return (a*b) / gcd(a,b);
}
 
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a < b) { a = b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a > b) { a = b; return 1; } return 0; }
 
typedef long long ll;
 
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;

int a[26];
char str[27];

int main(){
	scanf("%s", str);
	
	int len = strlen(str);
	
	REP(i,len){
		int n = str[i] - 'a';
		a[n]++;
		if (a[n] > 1){
			cout << "no" << endl;
			break;
		}
		if (i == len - 1) cout << "yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXN 100005
#define X first
#define Y second
#define mod 1000000007
#define inf 1e18
#define pb push_back
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);
ll n,i,j,k;

int main()
{
    fastio;
    ll a,b;
    cin>>a>>b;
    ll c=a*b;
    c=c/__gcd(a,b);
    cout<<c<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define st(vvv) sort(vvv.begin(),vvv.end())
#define rvs(vvv) reverse(vvv.begin(),vvv.end())
int inf = 1000000007;
i64 giant = 4000000000000000000;

using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	if (n < 2)ans = n;
	if (n >= 2)ans = 2;
	if (n >= 4)ans = 4;
	if (n >= 8)ans = 8;
	if (n >= 16)ans = 16;
	if (n >= 32)ans = 32;
	if (n >= 64)ans = 64;
	cout << ans << endl;
	return 0;
}

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

int main()
{
int x ,y ,a,b ,c ;
cin>> x>>y >>a>>b>>c ;
int apple[a] ;
int green[b] ;
int col [c] ;
for (int i=0 ;i<a ;i++)
{
    cin>>apple[i] ;

}
sort(apple,apple+a);
for (int i=0 ;i<b ;i++)
{
    cin>>green[i] ;

}
sort(green,green+b) ;
for (int i=0 ;i<c ;i++)
{
    cin>>col[i] ;

}
sort(col,col+c) ;
vector<int>f ;
for (int i=0 ;i<x;i++)
{
    f.push_back(apple[a-1-i]) ;
}
for (int i=0 ;i<y;i++)
{


    f.push_back(green[b-1-i]);

}

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


    long long counter=0 ;
for (int i=0,j=0; i<f.size();i++)
{
    if (f[i]<col[c-j-1]&&c-j-1>=0)
    {


        f[i]=col[c-j-1] ;
        j++ ;
    }
        counter+=f[i] ;
}
cout << counter  ;
}


Measured memory_bytes: 2552
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {
	
	public static void main(String[] args) throws IOException {
		new Main().exec();
	}

	public void exec() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		PriorityQueue pq = new PriorityQueue(2000000);
		String str = null;
		while(true){
			str=br.readLine();
			if(str.charAt(0)=='i'){
				pq.insert(Integer.parseInt(str.substring(7)));
			}else if(str.charAt(1)=='x'){
				out.println(pq.extract());
			}else{
				break;
			}
		}
		out.flush();
	}
}


class PriorityQueue  {
	protected int[] data = null;
	protected int dataPtr = -1;

	public PriorityQueue(int maxNodes) {
		data = new int[maxNodes+1];
		dataPtr = 1;
	}

	public int getParent(int i){
		if(i<=1 || dataPtr<=i) return -1;
		return i/2;
	}

	public int getLeft(int i){
		int leftId = i*2;
		return (i<=0 || dataPtr<=leftId) ? -1 : leftId;
	}

	public int getRight(int i){
		int rightId = i*2 + 1;
		return (i<=0 || dataPtr<=rightId) ? -1 :rightId;
	}
	
	public void insert(int value) {
		int id = dataPtr++;
		data[id] = value;
		for(int pid = getParent(id); pid != -1 && value>data[pid]; pid=getParent(id=pid)){
			data[id] = data[pid];
		}
		data[id]=value;
	}

	public int extract() {
		if(dataPtr <= 1)
			throw new IllegalStateException();
		int ret = data[1];
		data[1] = data[--dataPtr];
		if(dataPtr > 1){
			maxHeapify(1);
		}
		return ret;
	}
	
	protected void maxHeapify(int i) {
		int largest = i,leftId,rightId;
		while(true){
			leftId = getLeft(i);
			rightId = getRight(i);
			if(leftId != -1 && data[largest] < data[leftId]) largest = leftId;
			if(rightId != -1 && data[largest] < data[rightId]) largest = rightId;
			if(largest != i){
				data[0] = data[i]; data[i] = data[largest]; data[largest] = data[0];
				i = largest;
			}else{
				break;
			}
		}
	}
}

Measured memory_bytes: 102628
// 173

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <climits>
#include <string>
#include <cmath>

using namespace std;
using ll = long long int;
#define NUM 1000000007

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> v(n);
    for(int i=0; i<n; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end(), greater<int>());
    auto itr = v.begin();
    for(int i=0; i<n; i++){
        ans += *itr;
        if(i%2 == 1) itr++;
    }
    ans -= *v.begin();
    cout << endl << ans << endl;
    return 0;
}


Measured memory_bytes: 4024
//B - Common Raccoon vs Monster

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    long long h, n;

    cin >> h >> n;

    long long a_sum=0;

    int a;
    bool flag = false;

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

        if (h <= a_sum) {
            flag = true;
            break;
        }
    }

    if (flag){
        cout << "Yes" << endl;

    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
def main():
  N = int(input())
  V = list(map(int, input().split(" ")))
  C = list(map(int, input().split(" ")))
  s = 0
  for i in range(N):
    if V[i] > C[i]:
        s += V[i] - C[i]
  print(s)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

string in1, in2;
string in3;
int main() {
	cin >> in1 >> in2;
	
	string ans;
	ans += (char)('z' + 1);
	int L1 = in1.size(), L2 = in2.size(), i, j, k;
	for (i = 0; i <= L1 - L2; i++) {
		for (j = 0; j < L2; j++) {
			if (in1[i + j] == '?') continue;
			if (in1[i + j] != in2[j]) break;
		}
		if (j < L2) continue;
		in3 = in1;
		for (j = 0; j < L2; j++) in3[i + j] = in2[j];
		for (j = 0; j < L1; j++) if (in3[j] == '?') in3[j] = 'a';
		ans = min(ans, in3);
	}
	if (ans[0] > 'z') return !printf("UNRESTORABLE\n");
	else return !printf("%s\n", ans.c_str());
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

int dxk[] = { 1, 1, 1, 0, -1, 0 };
int dxg[] = { 0, 1, 0, -1, -1, -1 };
int dy[] = { -1, 0, 1, 1, 0, -1 };

int main()
{
	int h, w;
	while (cin >> h >> w && h)
	{
		vector<vector<tuple<int, int, int >>> stage(h + 1, vector<tuple<int, int, int>>(w + 1));
		map<char, tuple<int, int, int>> mp;
		mp['J'] = make_tuple(1, 0, 0);
		mp['O'] = make_tuple(0, 1, 0);
		mp['I'] = make_tuple(0, 0, 1);
		int n; cin >> n;
		rep(i, h) rep(j, w)
		{
			char c; cin >> c;
			stage[i + 1][j + 1] = mp[c];
		}
		function<tuple<int, int, int>(tuple<int, int, int>, tuple<int, int, int>)> add = [](const tuple<int, int, int>& tp1, const tuple<int, int, int>& tp2)
		{
			return make_tuple(get<0>(tp1) +get<0>(tp2), get<1>(tp1) +get<1>(tp2), get<2>(tp1) +get<2>(tp2));
		};
		function<tuple<int, int, int>(tuple<int, int, int>, tuple<int, int, int>)> subt = [](const tuple<int, int, int>& tp1, const tuple<int, int, int>& tp2)
		{
			return make_tuple(get<0>(tp1) -get<0>(tp2), get<1>(tp1) -get<1>(tp2), get<2>(tp1) -get<2>(tp2));
		};
		function<tuple<int, int, int>(int, int, int, int)> getSum = [&](int i, int j, int k, int l)
		{
			return subt(subt(add(stage[k][l], stage[i - 1][j - 1]), stage[i - 1][l]), stage[k][j - 1]);
		};
		rep(i, h + 1) rep(j, w) stage[i][j + 1] = add(stage[i][j + 1], stage[i][j]);
		rep(i, h) rep(j, w + 1) stage[i + 1][j] = add(stage[i + 1][j], stage[i][j]);
		rep(_, n)
		{
			int i, j, k, l; cin >> i >> j >> k >> l;
			int jn, on, in;
			tie(jn, on, in) = getSum(i, j, k, l);
			cout << jn << " " << on << " " << in << endl;
		}
	}
	return 0;
}

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

ll N,x;
vector<ll> V;

int main(void){
    cin >> N;
    x = N;
    if(N==0){cout << 0 << endl;return 0;}
    while(x!=0){
        if(x>0){
            V.push_back(x%(-2));
            x = x/(-2);
        }
        else{
            V.push_back(-x%(-2));
            x = (x-1)/(-2); 
        }
    }
    for(int i=V.size()-1;i>=0;i--){
        cout << V[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
using namespace std;

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    ll i,j,k,x,y,z,p,q;
    ll n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    ll strr[200005];
    char sd;
    cin>>sd;
    sd++;
    cout<<sd<<endl;

    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, a, b;
  cin >> n >> a >> b;
  if (a > b) cout << 0 << '\n';
  else if (n == 1) {
    if (a != b) cout << 0 << '\n';
    else cout << 1 << '\n';
  }
  else {
    cout << (n-2)*(b-a) + 1 << '\n';
  }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define nl ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define all(v) (v).begin(), (v).end()
#define allr(v) (v).rbegin(), (v).rend()
using namespace std;

int main() {
    nl // Lofi songs		

    int n, k, x, y;
    cin >> n >> k >> x >> y;
    
    cout << (n < k ? x*n : (x*k) + (n-k)*y);
    
}	


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

using namespace std;

typedef long long ll;

const ll MAX = 100010;

signed main()
{
    auto f = [&]{
        ll n, a, b, c, d;
        cin >> n >> a >> b >> c >> d;
        --n;
        ll diff = abs(b - a);
        if(diff > d * n){
            return 0;
        }
        if(diff > c * n){
            return 1;
        }
        for(ll i = 0; i <= n; ++i){
            ll move = c * (2 * i - n);
            ll plus = (d - c) * i;
            ll minus = -(d - c) * (n - i);

            if(move + plus >= diff && diff >= move + minus)
                return 1;

        }
        return 0;
    };

    cout << (f() ? "YES" : "NO") << endl;

}


Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline

n,k = map(int,input().split())
a = tuple(map(int,input().split()))


ok = 10**10
ng = 0

while ok-ng > 1:
    m = (ok+ng)//2
    c = 0
    for e in a:
        if e%m == 0:
            c += e//m - 1
        else:
            c += e//m

    if c <= k:
        ok = m
    else:
        ng = m
print(ok)


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

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6+ 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 2e5 + 17;

int n;
int a[2][maxn];

bool read() {
    if (scanf("%d", &n) != 1)
        return false;

    forn (i, n)
        scanf("%d", &a[0][i]);

    forn (i, n)
        scanf("%d", &a[1][i]);

    return true;
}

void solve() {
    for (int i = 1; i < n; ++i)
        a[0][i] += a[0][i - 1];

    int ans = 0;

    for (int i = n - 1; i >= 0; --i) {
        a[1][i] += a[1][i + 1];
        ans = max(ans, a[0][i] + a[1][i]);
    }

    printf("%d\n", ans);
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}

Measured memory_bytes: 256
//Do what you can't.
import java.io.*;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    long a=in.nextLong(),b=in.nextLong(),c=in.nextLong();  // 5 10 15 20 25 30 35 40 45 50
    int i=1;
    while (true){
      if ((a*i)%b==c){
        w.println("YES");
        break;
      }
      else if( (a*i)%b==0){
        w.println("NO");
        break;
      }
      i++;
    }
    w.close();
    }
  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

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

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 23252
N,K,Q=map(int,input().split())
if K>Q:
  for i in range(N):
    print('Yes')
else:
  ctr=[0]*N
  for i in range(Q):
    a=int(input())
    ctr[a-1]+=1
  for i in range(N):
    if ctr[i]>Q-K:
      print('Yes')
    else:
      print('No')


Measured memory_bytes: 4680
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int a[3];

    signed call_of_Cthulhu( signed datum ) {

        int n;
        read n;
        for ( int i = 0; i < n; i++ ) {
            int t;
            read t;
            if ( t % 4 == 0 ) a[2]++;
            elif ( t % 2 == 0 ) a[1]++;
            else a[0]++;
        }

        if ( a[1] ) {
            echo ( a[0] <= a[2] ? "Yes" : "No" ) fin;
        }
        else {
            echo ( a[0] <= a[2] + 1 ? "Yes" : "No" ) fin;
        }


        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

signed main() {
    int n, mi, ma;
    while(cin >> n >> mi >> ma) {
        if(!n && !mi && !ma) break;
        vector<int> v(n), s(n-1);
        rep(i,0,n) cin >> v[i];
        sort(v.begin(), v.end(), greater<int>());
        rep(i,0,n-1) s[i] = v[i] - v[i+1];

        mi--; ma--;
        int gap = 0, ans;
        repq(i, mi, ma) {
            if(gap <= s[i]) {
                gap = s[i];
                ans = i+1;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
   string s,t;cin>>s>>t;
   ll cnt=0;
   f(i,0,s.size()){
       if(s[i]!=t[i])cnt++;
   }
   cout<<cnt;
    return 0;  
} 





Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
bool is_not_out_of_range(size_t now, size_t max_num)
{
	return !(now < 0 || max_num <= now);
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	str s;
	cin >> s;
	map<char, int> m;
	rep(i, s.size())
	{
		m[s[i]]++;
	}
	for (auto itr = m.begin(); itr != m.end(); itr++)
	{
		if (itr->second % 2)
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rank Asdfiasofsad
#define MAX_N N
#define N 12
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
int Max(int &a,int b){return a=max(a,b);}
int Min(int &a,int b){return a=min(a,b);}

class UF{
public:
  vector<int> par;
  UF(){par.resize(MAX_N);for(int i=0;i<MAX_N;i++)par[i]=i;}
  UF(int n){par.resize(n);for(int i=0;i<n;i++)par[i]=i;}

  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){ //????????????????°????????????????????????????
    x=find(x), y=find(y);
    if(x==y)return;
    if(x > y) swap(x,y);
    par[y]=x;
  }

  bool same(int x,int y){return find(x)==find(y);}
};

typedef unsigned long long ull;
ull VtoH(vector<int> &v){
  const int B = 1777771;
  int res = 0;
  for(int a:v) res = res*B + a;
  return res;
}
int h,w;
string mp[N];
int check(int y,int bit){
  int res = 1;
  for(int i=0;i<w;i++){
    if((bit>>i&1) && mp[y][i] != '?' && mp[y][i] != '#') res = 0;
    if(!(bit>>i&1)&& mp[y][i] != '?' && mp[y][i] != '.') res = 0;
    if(i<w-1 && !(bit>>i&1) && !(bit>>(i+1)&1)) res = 0;
  }
  return res;
}

bool check(int y,int ue,int bit){
  if(!check(y,bit)) return 0;
  for(int i=0;i<w;i++)if(!(bit>>i&1) && !(ue>>i&1)) return 0;
  return 1;
}

UF getNx(int y,int ue,UF &T,int bit){
  UF res(w);
  for(int i=0;i<w;i++)
    for(int j=i+1;j<w;j++)
      if((bit>>i&1) && (ue>>i&1) && (bit>>j&1) && (ue>>j&1) && T.same(i,j)) res.unite(i,j);
  
  for(int i=0;i<w;i++){
    if((bit>>i&1) || !(ue>>i&1))continue;
    int ok = 0;
    for(int j=0;j<w;j++)ok |= T.same(i,j) && (bit>>j&1);
    if(!ok) return UF(0); //NG
  }
  
  for(int i=0;i<w-1;i++){
    if(!(bit>>i&1) || !(bit>>(i+1)&1))continue;
    if(res.same(i,i+1)) return UF(0);//NG
    res.unite(i,i+1);
  }
  return res;
}

vector<int>Bit;
unordered_map<ull,int> mem[N][1<<N];
int dfs(int y,int ue,UF &T){
  int hash = VtoH(T.par);
  if(y == h) {
    for(int i=0;i<w;i++) 
      for(int j=i+1;j<w;j++) 
        if((ue>>i&1) && (ue>>j&1) && !T.same(i,j)) return -1e9;
    return 0;
  }

  if(mem[y][ue].count(hash)) return mem[y][ue][hash];  
  
  int res = -1e9;
  if(y == h-1 && w == 1 && mp[y][0] == '.') res = 0;
  for(int bit:Bit){
     int i = bit;
     if(!check(y,ue,i)) continue;
     UF nT = getNx(y,ue,T,i);
     if(!nT.par.empty()) Max(res,dfs(y+1,i,nT) + __builtin_popcount(i));
   }
   return mem[y][ue][hash] = res;
}

signed main(){
  cin>>h>>w;
  for(int i=0;i<h;i++)cin>>mp[i];

  for(int i=0;i<(1<<w);i++){
    int ok = 1;
    for(int j=0;j<w-1;j++) if(!(i>>j&1) && !(i>>(j+1)&1)) ok = 0;
    if(ok)Bit.push_back(i);
  }

  int ans = -1e9;
  for(int bit:Bit){
    if(!check(0,bit))continue;
    UF T(w);
    for(int i=0;i<w-1;i++)if((bit>>i&1) && (bit>>(i+1)&1)) T.unite(i,i+1);
    Max(ans, dfs(1,bit,T) + __builtin_popcount(bit));
  }
  
  cout<<Max(ans,-1)<<endl;
  return 0;
}

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

namespace AOJ1_6_D
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int[] nm = new int[2];
            nm[0] = int.Parse(NM[0]);
            nm[1] = int.Parse(NM[1]);
            string[][] A = new string[nm[0]][];
            string[] b = new string[nm[1]];

            for (int i = 0; i < nm[0]; i++)//行列Aをかたどる
            {
                    A[i] = Console.ReadLine().Split(' ');
            }
            for (int j = 0; j < nm[1]; j++)//行列bをかたどる
            {

                b[j] = Console.ReadLine();
            }
         
            for (int i = 0; i < nm[0]; i++)//行列の積を計算する
            {
                int LastAnswer = 0;
                for (int j = 0; j < nm[1]; j++)
                {
                    int Answer;
                     Answer = int.Parse(A[i][j]) * int.Parse(b[j]);
                    LastAnswer += Answer;
                }
                Console.WriteLine(LastAnswer);
            }
        }
    }
}



Measured memory_bytes: 20012
#!/usr/bin/env python

N, A, B = map(int, input().split())
# print(N, A, B)

ans = 0;
for num in range(1, N+1):
    l = []
    q, r = divmod(num, 10)
    l.append(r)
    while q != 0:
        q, r = divmod(q, 10)
        l.append(r)
    if A <= sum(l) and sum(l) <= B:
        # print(num)
        ans += num

print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#define MAX 10000
#define NIL -1
using namespace std;

struct Node{
    int p;
    int l;
    int r;
};

Node T[MAX];

int n;

//????????????
void preParse(int u){
    if(u == NIL)
        return;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}

//????????????
void inParse(int u){
    if(u==NIL)
        return;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}

//????????????
void postParse(int u){
    if(u==NIL)
        return;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}

int main(){
    int i,v,l,r,root;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        T[i].p=NIL;
    }

    for(i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=NIL)
            T[l].p=v;
        if(r!=NIL)
            T[r].p=v;
    }

    for(i=0;i<n;i++){
        if(T[i].p==NIL)
            root=i;
    }
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
}

Measured memory_bytes: 2756
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<string> s(200001);
  map<string,int> mp;
  int ans=0;
  rep(i,n){
    cin >> s[i];
    decltype(mp)::iterator it = mp.find(s[i]);
    if(it!=mp.end()){
      mp[s[i]]++;
    }else{
      mp[s[i]]=1;
    }
    if(ans<mp[s[i]]){
      ans = mp[s[i]];
    }
  }
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  rep(i,s.size()){
    if(mp[s[i]]==ans){
      cout << s[i] << endl;
  }
  }
  return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
#define print(x) cerr << (#x) << "is "<< x << "\n"
using ll = long long;
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 1e5 + 10;
 
ll power(ll x, ll y){
   ll ans=1;
   if(y==1) return x%MOD;
   x=x % MOD,y=y % (MOD-1);
   while(y){
      if(y & 1) ans = (ans*x) %MOD;
      x *= x;
      x = x % MOD;
      y >>= 1;
   }
   return ans;
}
 
ll inv(ll x){
   return power(x,MOD-2);
}

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<int> a(n);
   f(i,0,n){
      cin >> a[i];
   }
   vector<int> val(n),c1(n);
   f(i,0,n){
      f(j,i+1,n){
         if(a[i] > a[j]){
            val[i]++;
         }
      }
      f(j,0,n){
         if(a[i] > a[j]){
            c1[i]++;
         }
      }
   }
   int ans = 0;
   f(i,0,n){
      // cout  << val[i] << ' ' << c1[i] << '\n';
      ans = ans + k*val[i];
      ans = ans%MOD;
      ans = ans + (((((c1[i]*k)%MOD)*(k-1))%MOD)*inv(2))%MOD;
      ans = ans%MOD;
   }
   cout << ans << '\n';
   return 0;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
S = [input() for i in range(H)]
B = [[0]*W for _ in range(H)]

for i, s in enumerate(S):
    for j, c in enumerate(s):
        if c=="#":
            B[i][j] = 1
        else:
            B[i][j] = 0
#B = [[False]*W for i in range(H)]
from itertools import product
Q = [t for t in product(range(H), range(W))]
Close = set()
from collections import deque
ans = 0
for q in Q:
    if q in Close:
        continue
    Open = deque()
    Open.append(q)
    #print(q)
    bw = [0, 0]
    while len(Open)>0:
        qq = Open.popleft()
        Close.add(qq)
        y, x = qq
        #print(y, x, bw)
        c = B[y][x]
        bw[c] += 1
        if x > 0 and (y, x-1) not in Close and c+B[y][x-1]==1:
            Open.append((y, x-1))
            Close.add((y, x-1))
        if x < W-1 and (y, x+1) not in Close and c+B[y][x+1]==1:
            Open.append((y, x+1))
            Close.add((y, x+1))
        if y > 0 and (y-1, x) not in Close and c+B[y-1][x]==1:
            Open.append((y-1, x))
            Close.add((y-1, x))
        if y < H-1 and (y+1, x) not in Close and c+B[y+1][x]==1:
            Open.append((y+1, x))
            Close.add((y+1, x))

    #print(bw)
    #print(Close)
    ans += bw[0] * bw[1]
print(ans)



Measured memory_bytes: 32364
n,m=map(int,input().split())

import sys
sys.setrecursionlimit(10**9) #再帰の上限をあげる

root=[-1 for i in range(n+1)] #自分が親ならグループの人数のマイナス倍を、そうでないなら（元）親の番号を示す
dep=[1]*(n+1)
def r(x):   #親は誰？
    if root[x]<0:
        return x
    else:
        return r(root[x])

def unite(x,y):
    x=r(x)
    y=r(y)
    if x==y:
        return
    if dep[x]==dep[y]:
        dep[x]+=1
    if dep[x]<dep[y]:
        x,y=y,x
    root[x]+=root[y]
    root[y]=x

for i in range(m):
    x,y,z=map(int,input().split())
    unite(x,y)


g=[0]*(n+1)
for i in range(1,n+1):
    g[r(i)]+=1
ans=0
for i in range(n+1):
    if g[i]>0:
        ans+=1
print(ans)



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

const int INF = 2e9;

int main(){
    ll n;
    cin >> n;
    ll ans = (n-1)*n/2;
    cout << ans << endl;
}

Measured memory_bytes: 3624
from math import sqrt, ceil
X = int(input())

def isprime(x):
    if x <= 1:
        return False
    if x == 2:
        return True
    if x % 2 == 0:
        return False

    for j in range(3, ceil(sqrt(x))+1, 2):
        if x % j == 0:
            return False
    return True

for i in range(10**9):
    if isprime(X+i):
        print(X+i)
        break


Measured memory_bytes: 9168
#include <bits/stdc++.h>
#define PI (atan(1)*4)

using namespace std;

int main()
{
	double a, b, n, i, x;
	double rad;
	cin >> a >> b >> x;
	if(2*x <= a*a*b) {
		rad = atan((a*b*b)/(2*x));
	} else {
		rad = atan(2*((b/a) - x/(a*a*a)));
	}
	// cout << rad*180.0/PI << endl;
	printf("%.7lf\n", rad*180.0/PI); 
	return 0;
}


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

#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++)
#define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--)
#define ll long long
#define st f
#define nd s
#define pb PB
#define eb emplace_back
#define mp make_pair				
#define siz(c) SIZ(c)
const int inf = 1e9 + 7;
const LL INF = 1e18L + 7;
 
#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type
{int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if (p > y) p = y;}
sim, class s> void maxi(n &p, s y) {if (p < y) p = y;}

#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif

#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "

#ifndef LOCAL
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template <typename T>
using ordered_set =
	tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#else
#include</Users/dawid/algo/mac/ordered_set>
#endif

const int N = 507;

int n;

int ans[N][N];

void solve(VI v, int lvl)
{
	if(siz(v)==1)
		return;

	VI l, r;

	for(int i = 0; i < siz(v)/2; ++i)
		l.pb(v[i]);

	for(int i = siz(v)/2; i < siz(v); ++i)
		r.pb(v[i]);

	solve(l, lvl+1);
	solve(r, lvl+1);

	for(auto x:l)
	{
		for(auto y:r)
		{
			ans[x][y] = ans[y][x] = lvl;
		}
	}
}

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

	cin >> n;

	VI s;

	for(int i = 1; i <= n; ++i)
	{	
		s.pb(i);
	}

	solve(s, 1);

	for(int i = 1; i <= n; ++i)
	{
		for(int j = i+1; j <= n; ++j)
		{
			cout << ans[i][j] << " ";
		}

		cout << endl;
	}
}



Measured memory_bytes: 1536
#include <iostream>

using namespace std;

int main(){
	int H, W;

	while (true){
		cin >> H >> W;
		if(H==0 && W==0){
			break;
		}
		for(int i=0;i<H;i++){
			if(i==0||i==H-1){
				for(int j=0;j<W;j++){
					cout << "#";
				}
			}
			else{
				cout << "#";
				for(int j=0;j<W-2;j++){
					cout << ".";
				}
				cout << "#";
			}
			cout << "\n";
		}
		cout<<"\n";
	}
}


Measured memory_bytes: 3032
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))
 
ans = p[-x:] + q[-y:] + sorted(r)

print(str(sum(sorted(ans)[-x-y:])))

Measured memory_bytes: 23200
#include <iostream>
#include <vector>
#include <math.h>
#include <cstdio>

using namespace std;

#define N 20
#define DELTA 0.000001
#define Lab 3

double cl[N][Lab];
int slct[N];
int n,m;
double mx;

void combi(int,int);

int main(int argc, char const *argv[])
{
	cin>>n>>m;
		
	for(int i1=0;i1<n;i1++){
		cin>>cl[i1][0]>>cl[i1][1]>>cl[i1][2];
	}
	mx=0.0;
	combi(0,0);
	printf("%lf\n",mx);
	return 0;
}

void combi(int s,int r)
{	
	if(r==m) {
		double sum=0.0;
		for(int i1=0;i1<m-1;i1++){
			for(int i2=i1+1;i2<m;i2++){
				for(int i3=0;i3<Lab;i3++){
					sum+=((cl[slct[i1]][i3]-cl[slct[i2]][i3])*(cl[slct[i1]][i3]-cl[slct[i2]][i3]));
				}
			}
		}
		if(sum>(mx+DELTA)) mx=sum;
	}
	else {
		for(int i1=s;i1<n;i1++){
			slct[r]=i1;
			combi(i1+1,r+1);
		}
	}
}

Measured memory_bytes: 1244