akhauriyash/Code-Regression huggingface dataset:
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

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

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	vector<ll> a(n);
	rep(i, n)scanf("%lld", &a[i]);
	sort(all(a), greater<int>());
	k = min(k, n);
	printf("%lld\n", accumulate(a.begin() + k, a.end(), 0LL));

	Please AC;
}


Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Test[] tests = new Test[N];
    for (int i = 0; i < N; i++) tests[i] = new Test();
    for (int i = 0; i < N; i++) tests[i].a = scanner.nextInt();
    for (int i = 0; i < N; i++) tests[i].b = scanner.nextInt();
    Arrays.sort(tests, Comparator.comparingInt(test -> test.a > test.b ? test.a - test.b : 1_000_000_000));
    long[] casum = new long[N];
    casum[N - 1] = tests[N - 1].a;
    for (int i = N - 2; i >= 0; i--) casum[i] = casum[i + 1] + tests[i].a;
    long[] cbsum = new long[N];
    cbsum[N - 1] = tests[N - 1].b;
    for (int i = N - 2; i >= 0; i--) cbsum[i] = cbsum[i + 1] + tests[i].b;
    if (casum[0] < cbsum[0]) {
      System.out.println(-1);
      return;
    }
    int i = 0;
    while (i < N && tests[i].a >= tests[i].b && casum[i] >= cbsum[i]) i++;
    if (i == N) System.out.println(0);
    else System.out.println(N - i + 1);
  }

  private static class Test {
    private int a;
    private int b;
  }
}


Measured memory_bytes: 96760
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int h[]=new int[N];
        int m[]=new int[N];
        int sum[]=new int[200];
    	for(int i=0;i<200;i++){
    	    sum[i]=14400;
    	}
        int x=0;
        for(int i=0;i<N;i++){
            h[i]=sc.nextInt();
            m[i]=sc.nextInt();
            sum[x]=h[i]*60+m[i];
            x++;
        }
	    
        int M=sc.nextInt();
        int k[]=new int[M];
        int g[]=new int[M];
        for(int i=0;i<M;i++){
            k[i]=sc.nextInt();
            g[i]=sc.nextInt();
            int cnt2=0;
            for(int j=0;j<x;j++){
                if(sum[j]==k[i]*60+g[i]){
                    cnt2++;
                }
            }
            if(cnt2==0){
                sum[x]=k[i]*60+g[i];
                x++;
            }
        }
        Arrays.sort(sum);
        for(int i=0;i<x-1;i++){
            System.out.print(sum[i]/60+":");
            sum[i]=sum[i]%60;
            if(sum[i]/10==0){
                System.out.print("0"+sum[i]+" ");
            }else{
                System.out.print(sum[i]+" ");
            }
        }
        System.out.print(sum[x-1]/60+":");
        sum[x-1]=sum[x-1]%60;
        if(sum[x-1]/10==0){
            System.out.print("0"+sum[x-1]);
        }else{
            System.out.print(sum[x-1]);
        }
        System.out.println();
    }
}


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

int main()
{
  int n,a,b;
  cin >> n >> a >> b;
  
  int ans = 0;
  for(int i = 1; i <= n; i++){
    int x = i;
    int sum = 0;
    while(x > 0){
      sum += x % 10;
      x /= 10;
    }
    if(sum >= a && sum <= b){
      ans += i;
    }
  }
  
  cout << ans << endl;
      
}


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


int main(){
   string str="YES";
   int N;
   cin >> N;
   vector<int> A(N,0);
   for(int i=0;i<N;i++){cin>>A[i]
   ;}
   vector<bool> check(1000000001,0);
   for(int i=0;i<N;i++){
      int j=A[i];
      if(check[j]){str="NO";break;}
      else check[j]=1
   ;}
   cout<<str<<endl;
   //cout<<check.size()<<endl;

   return 0;
}

Measured memory_bytes: 123136
fun main(args: Array<String>) {
  readLine()
  val array = readLine()
    ?.split("\\s+".toRegex())
    ?.map(String::toInt)
    ?.toIntArray()
    ?:intArrayOf()
  var cnt = 0
  for (i in array.indices) {
    for (j in array.size - 2 downTo i) {
      if (array[j] > array[j+1]) {
        array.swap(j, j+1)
        cnt++
      }
    }
  }
  println(array.joinToString(" "))
  println(cnt)
}

fun IntArray.swap(i: Int, j: Int) {
  val tmp = this[i]
  this[i] = this[j]
  this[j] = tmp
}


Measured memory_bytes: 29588
#include "bits/stdc++.h"
#define MOD 1000000007
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

LL N, T[112];
std::vector<LL>o, m;

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

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

int main()
{
	in >> N;
	rep(i, N) { in >> T[i]; }

	rep(i, N) { o.push_back(T[i]); }
	while (o.size() > 1)
	{
		for (int i = 0; i + 1 < o.size(); i += 2)
		{
			m.push_back(lcm(o[i], o[i + 1]));
		}
		if (o.size() % 2 == 1) { m.push_back(o[o.size() - 1]); }
		o.clear();
		o = m;
		m.clear();
	}

	out << o[0] << std::endl;
	return 0;
}

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

using namespace std;

int main() {
	vector<int> v(4);
	for (int i = 0; i < 6; ++i) {
		int input;
		cin >> input;
		++v[input - 1];
	}
	
	sort(begin(v), end(v), greater<int>());
	
	cout << (v[1] >= 2 ? "YES" : "NO")<< endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s; cin >> s;
    ll ans = 0;

    int n = s.size();
    rep(bit, 1<<(n-1)){
        // string t = s;
        ll tmp = ans;
        // pr(bitset<2>(bit));
        ll k = 0;
        rep(i, n){
            k *= 10;
            k += s[i] - '0';
            if(i==n-1){
                ans += k;
            }else if((bit>>i) & 1){
                ans += k;
                k = 0;
            }
        }
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 3620
N = int(input())
A = [0] * N
xy = [[] for _ in range(N)]
for i in range(N):
  A[i] = int(input())
  xy[i] = [list(map(int, input().split())) for _ in range(A[i])]
  
def nasu(n):
  D = [0] * N
  x = n
  for i in range(N):
    if x & 1:
      D[i] = 1
    x >>= 1
  for i in range(N):
    if D[i] == 0: continue
    for j in range(A[i]):
      if D[xy[i][j][0] - 1] != xy[i][j][1]:
        return False
  return True

ans = 0
for i in range(1, N + 1):
  n = (1 << i) - 1
  while n < (1 << N):
    if nasu(n):
      ans = i
      break
    x = n & -n
    y = n + x
    n = ((n & ~y) // x >> 1) | y
    
print(ans)

Measured memory_bytes: 3064
import scala.io.StdIn.{readInt, readLine}

object Main extends App {
  val n = readInt
  val numbers = readLine.split(" ").map(_.toInt)
  val q = readInt
  var ans = 0
  readLine.split(" ").foreach( key => {
    ans += binarySearch(numbers, key.toInt)
  })
  println(ans)

  def binarySearch(numbers: Array[Int], key: Int): Int = {
    var start = 0
    var end = numbers.length - 1
    while (true) {
      val mid = (start + end) / 2
      if (numbers(mid) == key) {
        return 1
      }
      if (numbers(mid) < key) {
        start = mid + 1
      } else {
        end = mid - 1
      }
      if (start > end || start < 0 || end > numbers.length - 1) {
        return 0
      }
    }
    0
  }
}



Measured memory_bytes: 72584
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st A, B, C;
  ci(A, B, C);
  st a = "";
  a += A.at(0) - 32;
  a += B.at(0) - 32;
  a += C.at(0) - 32;
  co(a);
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a , b ; cin >> a >> b ;
    string c = a + b ;
    int num = stoi(c);
    bool check = false ;
    for(int i = 1 ; i <= 1000 ; i++)   
    {
        if(i*i==num)
        {
            cout << "Yes" << endl;
            check = true ;
        } 
    }
    if (!check) cout << "No" << endl;
    return 0 ;
}

Measured memory_bytes: 3552
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        end:{
            for(int i = 0; i < n; i++){
                int a = sc.nextInt();
                if(a % 2 == 0){
                    if(!(a % 3 == 0 || a % 5 == 0)){
                        System.out.println("DENIED");
                        break end;
                    }
                }
            }
            System.out.println("APPROVED");
        }
    }
}


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

int dp[100005][3];

int main(void){
    int N;
    cin >> N;
    vector<int> a(N),b(N),c(N);
    for(int i=0;i<N;i++) cin >> a[i] >> b[i] >> c[i];

    for(int i=0;i<N;i++) for(int j=0;j<3;j++) dp[i][j] = 0;
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    
    for(int i=1;i<=N;i++){
        dp[i][0] = max(dp[i][0],max(dp[i-1][1]+a[i-1], dp[i-1][2]+a[i-1]));
        dp[i][1] = max(dp[i][1],max(dp[i-1][0]+b[i-1], dp[i-1][2]+b[i-1]));
        dp[i][2] = max(dp[i][2],max(dp[i-1][0]+c[i-1], dp[i-1][1]+c[i-1]));
    } 

    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int pos = 0;

    vector<char> x(15);

    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i++) {
        if(s[i] == 'B') {
            if(pos > 0) pos--;
        } else {
            x[pos] = s[i];
            pos++;
        }
    }

    for(int i = 0; i < pos; i++) cout << x[i];
    cout << endl;
}

Measured memory_bytes: 3600
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;


struct SegmentTree{
    int n;
    vector<int> value; //0始まりのインデックス
    int SIJK;

    SegmentTree(int N){
        SIJK = INF; // compareの内容に応じて変える
        n = 1;
        while(n < N) n *= 2;
        value.assign(2 * n - 1, SIJK);
        rep(i, N) value[i + n - 1] = i;
        for(int i = n - 2; i >= 0; i--){
            value[i] = compare(value[2 * i + 1], value[2 * i + 2]);
        }
    }

    int compare(int a, int b){
        return min(a, b); //問題に応じて変える
    }

    void update(int i, int x){
        i += n - 1;
        value[i] = x;
        while(i > 0){
            i = (i - 1)/2; // 親のノード
            value[i] = min(value[2 * i + 1], value[2 * i + 2]);
        }
    }

    int find(int a, int b, int k = 0, int l = 0, int r = -1){
        // [a, b) の区間に対するクエリについて
        // ノード k （区間 [l, r) 担当）が答える
        if(r < 0) r = n;
        if(r <= a || b <= l) return SIJK;
        if(a <= l && r <= b) return value[k];
        else{
            int m = (l + r) / 2;
            int tmp1 = find(a, b, 2 * k + 1, l, m);
            int tmp2 = find(a, b, 2 * k + 2, m, r);
            return compare(tmp1, tmp2);
        }
    }


};


int main(){
    int N, M;
    cin >> N >> M;
    SegmentTree sg(M + 1);
    priority_queue<P> que;
    rep(i, N){
        P tmp;
        cin >> tmp.second >> tmp.first;
        que.push(tmp);
    }

    int sum = 0;
    while(!que.empty()){
        P tmp = que.top();
        que.pop();
        int a = tmp.second, b = tmp.first;
        int f = sg.find(a, M + 1);

        if(f == INF) continue;
        else{
            sg.update(f, INF);
            sum += b;
        }
    }

    cout << sum << endl;

}

Measured memory_bytes: 2424
// AOJ ALDS1_1_B Greatest Common Divisor
// 2018.4.26 bal4u

#include <stdio.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

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

int main()
{
	int a, b;

	a = in(), b = in();
	printf("%d\n", gcd(a, b));
	return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <sstream>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int MAXN = (int)2e+5 + 5;

int fen[MAXN];

int pref(int x) {
	int res = 0;
	for (int i = x; i > 0; i = (i & (i + 1)) - 1)
		res += fen[i];
	return res;
}

int get(int l, int r) {
	if (l > r)
		return 0;
	return pref(r) - pref(l - 1);
}

void add(int x, int k) {
	for (int i = x; i < MAXN; i |= (i + 1))
		fen[i] += k;
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, ans = 0;
	cin >> n;

	vector <int> arr(n);
	forn(i, n)
		cin >> arr[i];

	forn(i, n) {
		if (get(arr[i], n) == i)
			ans++;
		add(arr[i], 1);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
long long n,a,b,h[100005],l=0,r=1e9,cnt,mid;
int main(){
	cin>>n>>a>>b;
	for(int i=0;i<n;i++)
	    cin>>h[i];
	while(l+1<r)
	{
		mid=(l+r)/2;
		cnt=0;
		for(int i=0;i<n;i++)
		{
			if(b*mid<h[i]) cnt+=(h[i]-mid*b+a-b-1)/(a-b);
		}
		if(cnt<=mid) r=mid;
		else l=mid;
	}
	cout<<r;
	return 0;
}

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

typedef long long ll;

ll n, a, b, k;

template<int m>
struct modint {

	unsigned x;

	modint() : x(0) {}

	modint(long long arg) {
		arg %= m;
		if (arg < 0) {
			x = arg + m;
		} else {
			x = arg;
		}
	}	

	modint& operator+= (const modint& other) {
		x += other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint& operator*= (const modint& other) {
		x = (x * 1ll * other.x) % m;
		return *this;
	}

	modint& operator-= (const modint& other) {
		x += m - other.x;
		if (x >= m) {
			x -= m;
		}
		return *this;
	}

	modint operator+ (const modint& other) const {
		modint tmp = *this;
		tmp += other;
		return tmp;
	}

	modint operator- (const modint& other) const {
		modint tmp = *this;
		tmp -= other;
		return tmp;
	}

	modint operator* (const modint& other) const {
		modint tmp = *this;
		tmp *= other;
		return tmp;
	}

	explicit operator int () const {
		return x;
	}

	modint& operator++ () {
		++x;
		if (x == m) {
			x = 0;
		}
		return *this;
	}

	modint& operator-- () {
		if (x == 0) {
			x = m-1;
		} else {
			--x;
		}
		return *this;
	}

	modint operator++ (int) {
		modint tmp = *this;
		++*this;
		return tmp;
	}

	modint operator-- (int) {
		modint tmp = *this;
		--*this;
		return tmp;
	}

	bool operator== (const modint& other) const {
		return x == other.x;
	}

	bool operator!= (const modint& other) const {
		return x != other.x;
	}

	template<class T>
	modint operator^ (T arg) const {
		if (arg == 0) {
			return 1;
		}
		if (arg == 1) {
			return x;
		}
		auto t = *this ^ (arg >> 1);
		t *= t;
		if (arg & 1) {
			t *= *this;
		}
		return t;
	}

	modint inv() const {
		return *this ^ (m-2);
	}
};

const int MOD = 998244353;
typedef modint<MOD> mint;

mint f[300005], finv[300005];

mint bk(int x, int y) {
	return f[x+y] * finv[x] * finv[y];
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.tie(nullptr);

	cin >> n >> a >> b >> k;

	f[0] = 1;
	finv[0] = 1;
	for (int i=1; i<=n; i++) {
		f[i] = f[i-1] * i;
		finv[i] = f[i].inv();
	}

	mint sol;

	for (int i=0; i<=n; i++) {
		ll j = k - i*a;
		if (j < 0)
			continue;
		if (j % b)
			continue;
		j /= b;
		if (j > n)
			continue;

		cerr << i << ' ' << j << '\n';

		sol += bk(n-i, i) * bk(n-j, j);
	}
	cout << (int)sol;

}

Measured memory_bytes: 2560
#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>;
using pil = pair<pii,int>;


int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i,n-2){
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
                i++;
                if(s[i+1] == 'C'){
                  	i++;
                  	ans++;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int a[105],n,ans;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++)
    	if(a[i]>a[i+1]) ans+=a[i]-a[i+1];
    cout<<ans+a[n];
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
a = -1
b = -1
count = 0
for per in permutations(range(1,n+1)):
    count += 1
    arr = [i for i in per]
    if arr==p:
        a = count
    if arr==q:
        b = count

print(abs(a-b))

Measured memory_bytes: 73848
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int mx = (n-1)*(n-2)/2;

    if(mx < k) {
        cout << -1 << endl;
        return 0;
    }

    vector<pair<int, int>> ans;
    rep(i, n-1) {
        ans.push_back(make_pair(i+1, n));
    }

    int add = mx - k;

    vector<pair<int, int>> edge;
    rep(i, n-1) {
        rep(j, i) {
            edge.push_back(make_pair(i+1, j+1));
        }
    }

    rep(i, add) {
        ans.push_back(edge[i]);
    }

    cout << ans.size() << "\n";
    rep(i, ans.size()) {
        cout << ans[i].first << " " << ans[i].second << "\n";
    }

    return 0;
}

Measured memory_bytes: 384
using System;

namespace A___Bichrome_Cells
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow(N, 2) - A);
        }
    }
}


Measured memory_bytes: 13140
fun main(args: Array<String>){
    val N = nextInt()
    val A = listOfInt().toLongArray()
    val B = listOfInt().toLongArray()
    val M = A.sum()
    for (n in 0 until N) {
        val a = A[n]
        A[n]   = a - Math.min(A[n]  , B[n])
        val b = A[n+1]
        A[n+1] = b - Math.min(A[n+1], B[n] - (a - A[n]))
    }
    println(M - A.sum())
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toLong() }


Measured memory_bytes: 66072
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main(void) {
    io;
    int a,b,c;
    cin >> a >> b >> c;
    if ((a+b == c) || (a+c == b) || (b+c == a)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}



Measured memory_bytes: 3548
# -*- coding: utf-8 -*-
#https://mathtrain.jp/tyohukuc

n, m, k = map(int,input().split())

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = n+1 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0
beki = [1,m-1]
for i in range(2,N+1):
    beki.append(((beki[-1]*(m-1)) % p))

for x in range(k+1):
    ans += m * beki[n-x-1] %p * cmb(n-1,x,p) %p
    ans = ans % p
print(ans)


Measured memory_bytes: 40592
n = int(input())
ans = 0
#count = 0

for i in range(1, n+1, 2):
#    print("\n\n# i: " + str(i))
    count = 0
    for j in range(1, i+1):
        if i % j == 0:
            count += 1

#    print(count)
    if count == 8:
        ans += 1

print(ans)


Measured memory_bytes: 38768
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,i,j,t,p,mx,viz[25][25],dx[5],dy[5];
char c[25][25];
queue<pair<pair<int,int>,int> >q;
pair<pair<int,int>,int>x;
bool ok(int x,int y)
{
	if(x>=1 && x<=n && y>=1 && y<=m && !viz[x][y] && c[x][y]=='.')return 1;
	return 0;
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	dx[0]=1,dy[0]=0,dx[1]=-1,dy[1]=0,dx[2]=0,dy[2]=1,dx[3]=0,dy[3]=-1;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			cin>>c[i][j];
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(c[i][j]=='#')continue;
			for(t=1;t<=n;t++)for(p=1;p<=m;p++)viz[t][p]=0;
			q.push(mkp(mkp(i,j),0));
			viz[i][j]=1;
			while(!q.empty())
			{
				x=q.front();
				q.pop();
				mx=max(mx,x.sc);
				for(t=0;t<4;t++)
				{
					if(ok(x.fr.fr+dx[t],x.fr.sc+dy[t]))
					{
						q.push(mkp(mkp(x.fr.fr+dx[t],x.fr.sc+dy[t]),x.sc+1));
						viz[x.fr.fr+dx[t]][x.fr.sc+dy[t]]=1;
					}
				}
			}
		}
	}     
	cout<<mx<<endl;                                                  
	return 0;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
int w[105];
int ans[10005];
int main ()
{
    int n;
    scanf("%d",&n);
    int sum=0;
    for (int i=1; i<=n; i++)
    {
        scanf("%d",&w[i]);
        sum=sum+w[i];
    }
    int d=0;
    int sum1=0,sum2=0;
    for (int i=1; i<=n; i++)
    {
        sum1=sum1+w[i];
        sum2=sum-sum1;
        ans[d++]=fabs(sum1-sum2);
    }
    int t;
    for (int i=1;i<=n-1;i++)
    {
        for (int j=i+1;j<=n-1;j++)
        {
            if (ans[i]>=ans[j])
            {
                t=ans[i];
                ans[i]=ans[j];
                ans[j]=t;
            }
        }
    }
  printf("%d\n",ans[1]);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
ll X, Y;

void solve(){
	int ans = 0;
	while(X <= Y){
		X *= 2;
		ans++;
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec; typedef pair<int, int> pi;
int dd[] = { 0, 1, 0, -1, 0 };

vector<int> G[114514];
stack<int> S;
queue<int> Q;
bool B[114514] = { 0 };
int N, M;
void dfs(int u, int mode)
{
	for (auto i: G[u])
	{
		if (B[i])continue;
		else
		{
			if (mode)
			{
				S.push(i);
			}
			else
			{
				Q.push(i);
			}
			B[i] = true;
			dfs(i, mode);
			break;
		}
	}
}

int main()
{
	scanf("%d%d", &N, &M);

	int s = -1, t = -1;
	for (int i = 0; i < M; i++)
	{
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
		s = a;
		t = b;
	}
	B[s] = true; B[t] = true;
	Q.push(s);
	dfs(s, 0);
	S.push(t);
	dfs(t, 1);

	printf("%d\n", Q.size() + S.size());
	while (!S.empty())
	{
		printf("%d ", S.top()+1);
		S.pop();
	}
	while (!Q.empty())
	{
		if (Q.size() == 1)printf("%d\n", Q.front()+1);
		else printf("%d ", Q.front()+1);
		Q.pop();
	}

	return 0;
}


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

using namespace std;

int main(){
    int n,m,c;
    cin>>n>>m>>c;
    vector<int> b(m);
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    vector<vector<int>> a(n,vector<int>(m));
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }

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

    cout<<cnt;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=100001;

int s[maxn],t[maxn],c[maxn];
P b[maxn];
int main(){
  int n;
  cin>>n;
  cout<<n/3<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    ll N,K;
    cin >> N >> K;
    ll A[N],C[N];
      ll i;
    for(i=0;i<N;i++){
      cin >> A[i];
      C[i]=0;
    }
    sort(A,A+N);
    ll tcnt=0,t=A[0];
    for(i=0;i<N;i++){
      if(t==A[i]){
        C[tcnt]+=1;
      }else{
        t=A[i];
        tcnt+=1;
        C[tcnt] =1;
      }
    }
    sort(C,C+N);
    ll ans=N;
    for(i=0;i<K;i++){
      ans-=C[N-1-i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int c[3][3] = {0};
    REP(i,3){
        REP(j,3){
            cin >> c[i][j];
        }
    }

    REP(i,101){
        REP(j,101){
            REP(k,101){
                bool flag = true;
                REP(l,3){
                    if(c[l][0]-i != c[l][1]-j || c[l][1]-j != c[l][2]-k){
                        flag = false;
                    }
                }
                if(flag){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3620
import math
n, d = map(int, input().split())
dat_x = []
for i in range(n):
    l = map(int, input().split())
    l = list(l)
    dat_x .append((l))
res = 0
for i in range(n):
    for j in range(n):
        if i == j:
            break
        s = 0
        for k in range(d):
            s += (dat_x[i][k] - dat_x[j][k]) * (dat_x[i][k] - dat_x[j][k])
        #print(s)
        t = math.sqrt(s)
        if t.is_integer():
            #print("{0} {1}".format(i, j))
            res += 1
print(res)


Measured memory_bytes: 38384
n, x = map(int, input().split())
l = list(map(int, input().split()))

ans = 0
for i in range(n-1):
  s = l[i]+l[i+1]
  if s > x:
    if l[i+1] >= (s-x):
      l[i+1] -= (s-x)
      ans += (s-x)
    else:
      l[i+1] = 0
      ans += (s-x)
print(ans)
  

Measured memory_bytes: 14132
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m; cin>>n>>m;
    vector<int> g[n+1];
    for(int i=0;i<m;i++)
    {
        int u,v; cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> dis(n+1,0);
    vector<int> par(n+1,-1);
    vector<bool> vis(n+1,false);
    queue<int> Q;
    Q.push(1);
    vis[1]=true;
    while(!Q.empty())
    {
        int i=Q.front();Q.pop();
        for(int j=0;j<g[i].size();j++)
        {
            if(!vis[g[i][j]])
            {
                vis[g[i][j]]=true;
                dis[g[i][j]]=dis[i]+1;
                par[g[i][j]]=i;
                Q.push(g[i][j]);
            }
        }
    }
    bool st=true;
    for(int i=1;i<=n;i++)
    if(!vis[i])
    {
        st=false; break;
    }
    if(st)
    {
        cout<<"Yes\n";
        for(int i=2;i<=n;i++)
            cout<<par[i]<<"\n";
    }
    else
        cout<<"NO";
}


Measured memory_bytes: 10644
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int t,p,r,ha[51][10],tt,mm,ti;
  vector<pair<int,pair<int,int> > > v;
  pair<int,pair<int,int> > vv[50];
  string h;
  while(1){
    cin>>t>>p>>r;
    if(t==0)break;

    for(int i=0;i<=t;i++){
      for(int j=0;j<=p;j++){
	ha[i][j]=0;
      }
    }
    v.clear();
    for(int i=0;i<=t;i++){
      vv[i].first=0;
      vv[i].second.first=0;
      vv[i].second.second=i;
    }

    for(int i=0;i<r;i++){
      cin>>tt>>mm>>ti>>h;
      if(h=="WRONG"){
	ha[tt][mm]++;
      }else {
	vv[tt].second.first+=ha[tt][mm]*1200+ti;
	vv[tt].first--;
      }
    }
    vv[0].first=100;
    for(int i=1;i<=t;i++)v.push_back(vv[i]);
    sort(v.begin() , v.end());
    
    for(int i=0;i<t;i++){
      cout<<v[i].second.second<<" "<<v[i].first*-1<<" "<<v[i].second.first<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3156
N = int( input())
H = [ list( map( int, input().split())) for _ in range(N)]
dp = [ [0]*3 for _ in range(N)]
dp[0][0], dp[0][1], dp[0][2] = H[0]
for i in range(1,N):
    a, b, c = H[i]
    dp[i][0] = max( dp[i-1][1]+a, dp[i-1][2]+a)
    dp[i][1] = max( dp[i-1][0]+b, dp[i-1][2]+b)
    dp[i][2] = max( dp[i-1][0]+c, dp[i-1][1]+c)
print( max( dp[-1]))


Measured memory_bytes: 76888
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, k, ans=0;
	cin >> a >> b >> c >> k;

	for(int i=0; i<=k; i++){
		for(int j=0; i+j<=k; j++){
			int sum = a*pow(2,i) + b*pow(2,j) + c*pow(2,k-i-j);
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

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

#define ll long long
#define str string

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

vector <ll> v;
ll Y[10000000] = {}, X[10000000] = {},m = 0,a = 0,b = 0,n = 0, x = 0,y = 0,sum = 0;
char H[100][100] = {};
str S,Sa;
bool ans = true;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
		//Code Line
cin >> x >> y;
for(int i = 0;i < x;i++){
	int e = 0;
for(int j = 0;j < y;j++){
cin >> H[i][j];
if(H[i][j] != '.')e++;
}
if(e == 0)Y[i] = 500;
}
for(int j = 0;j < y;j++){
	int e = 0;
for(int i = 0;i < x;i++){
if(H[i][j] != '.')e++;
}
if(e == 0)X[j] = 500;
}
for(int i = 0;i < x;i++){
if(Y[i] == 0){
for(int j = 0;j < y;j++){
if(X[j] == 0)cout << H[i][j];
 
} 
  cout << endl;
}
}
		//Code Line
return 0; 
}


Measured memory_bytes: 2304
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	string O, E;	cin >> O >> E;
	for (int i = 0; i < E.size(); ++i) {
		cout << O[i] << E[i];
	}
	if (O.size() > E.size()) {
		cout << O[O.size() - 1];
	}
	cout << endl;
	cin >> O;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, S[202020];
ll i, j, k, l,ans;
ll mk[202020];

int main(){
    scanf("%lld", &N);
    fornum(i,0,N){
        scanf("%lld", &S[i]);
    }
    ans = 0;
    fornum(i,1,N){
        ll li = 0,ri=N-1;
        ll ct = 0;
        while(i<=ri+i&&li<N-i&&li!=ri&&mk[li]!=i&&mk[ri]!=i){
            ct += S[li];
            ct += S[ri];
            mk[li] = i;
            mk[ri] = i;
            li += i;
            ri -= i;
            if(ct>ans){
                ans = ct;
            }
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#define mem(a, b) memset(a, b, sizeof(a))
#define inf (1e9 + 7)
using namespace std;

int n, nn = 0, egn = 0, pre[100005];
map<pair<long, long>, int> mps;

struct node
{
    long long x, y;
    int id;
}nd[100005];

struct edge
{
    long long w;
    int u, v;
}eg[300005];

bool cmp(const struct node & a, const struct node & b)
{
    return a.x < b.x;
}

bool cmp2(const struct node & a, const struct node & b)
{
    return a.y < b.y;
}

bool cmp3(const struct edge & a, const struct edge & b)
{
    return a.w < b.w;
}

int pr(int a)
{
    if(a == pre[a])
        return a;
    pre[a] = pr(pre[a]);
    return pre[a];
}

void con(int u, int v)
{
    if(u < v)
        pre[u] = v;
    else
        pre[v] = u;
}

int main()
{
    long long a, b;
    scanf("%d", &n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%lld%lld", &a, &b);
        if(!mps[{a, b}])
        {
            mps[{a, b}] = 1;
            nn++;
            pre[nn] = nn;
            nd[nn].x = a;
            nd[nn].y = b;
            nd[nn].id = nn;
        }
    }
    sort(nd + 1, nd + 1 + nn, cmp);
    for(int i = 1;i < nn;i++)
    {
        egn++;
        eg[egn].w = nd[i + 1].x - nd[i].x;
        eg[egn].u = nd[i].id;
        eg[egn].v = nd[i + 1].id;
    }
    sort(nd + 1, nd + 1 + nn, cmp2);
    for(int i = 1;i < nn;i++)
    {
        egn++;
        eg[egn].w = nd[i + 1].y - nd[i].y;
        eg[egn].u = nd[i].id;
        eg[egn].v = nd[i + 1].id;
    }
    sort(eg + 1, eg + 1 + egn, cmp3);
    long long ans = 0;
    int tmp = 0;
    for(int i = 1;i <= egn;i++)
    {
        if(tmp >= nn - 1)
            break;
        int u = pr(eg[i].u);
        int v = pr(eg[i].v);
        long long w = eg[i].w;
        if(u != v)
        {
            con(u, v);
            ans += w;
            con(u, v);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 13952
#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,K,X,Y;
    cin >> N >> K >> X >> Y;
    if(N<=K) cout << N*X << endl;
    else cout << K*X+(N-K)*Y << endl;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list
#from itertools import combinations # (string,3) 3回

mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def main():
    import fractions
    n,x = readInts()
    X = readInts()
    ans = abs(X[0] - x)
    for i in range(1,n):
        ans = fractions.gcd(ans,abs(X[i] - x))
    print(ans)

if __name__ == '__main__':
  main()


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


int main()
{
	char ch;
	int a[26] = {};
	while (cin >> ch) {
		if ('a' <= ch && ch <= 'z') {
			int x = ch - 'a';
			a[x]++;
		}
		else if ('A' <= ch && ch <= 'Z') {
			int y = ch - 'A';
			a[y]++;
		}

		
	}for (int i = 0;i < 26;i++) {
			cout << char('a' + i) << " : " <<a[i]<< endl;
		}
    return 0;
}



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

using namespace std;

typedef long long int LL;

#define st first
#define nd second
#define PLL pair <LL, LL>
#define PII pair <int, int>

const int N = 1e6 + 7;
const int MX = 1e9 + 7;
const LL INF = 1e18 + 9LL;

int n;
char in[N];

int main(){
	scanf("%s", in + 1);
	n = strlen(in + 1);
	
	int ans = 0;
	for(int i = 1; i <= n; ++i){
		if(in[i] == '?')
			in[i] = 'D';
		
		if(in[i] == 'D'){
			++ans;
			if(in[i - 1] == 'P')
				++ans;
		}
	}
	
	printf("%s\n", in + 1);
	return 0;
}

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

int main() {
  int N; cin >> N;
  string S; cin >> S;

  string X, Y;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (j <= i) X.push_back(S[j]);
      else Y.push_back(S[j]);
    }

    int X_kind[26] = {}, Y_kind[26] = {};
    for (int j = 0; j < X.size(); j++) X_kind[X[j] - 97]++;
    for (int j = 0; j < Y.size(); j++) Y_kind[Y[j] - 97]++;

    int same_kind = 0;
    for (int j = 0; j < 26; j++) if (X_kind[j] && Y_kind[j]) same_kind++;
    if (same_kind > ans) ans = same_kind;

    X.erase(X.begin(), X.end()); Y.erase(Y.begin(), Y.end());
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        final Scanner scanner = new Scanner(System.in);
        final int a = scanner.nextInt();
        final int b = scanner.nextInt();
        final int c = scanner.nextInt();
        final int d = scanner.nextInt();
        final int e = scanner.nextInt();
        final int k = scanner.nextInt();

        final int min = Math.min(Math.min(Math.min(Math.min(a, b), c), d), e);
        final int max = Math.max(Math.max(Math.max(Math.max(a, b), c), d), e);

        System.out.println(max - min <= k ? "Yay!" : ":(");
    }
}


Measured memory_bytes: 21844
import java.util.*;
import java.io.*;
import java.math.*;

public class Main 

{ 
static int mod=1000000007;
static int MAX = 1000001; 
static int factor[];
	 static FastReader sc=new FastReader(); 
	 
		  public static void main(String[] args) 
    {
			  String s=s();
			  int n=s.length()-1;
			  if(s.charAt(n)!='s') {
				  s+='s';
			  }
			  else
				  s+="es";
			  System.out.println(s);
			  
			  
			  
    }

		  
		  
		  
static int[] input(int n) {
	int A[]=new int[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextInt();
	   }
	   return A;
   }
static long[] inputL(int n) {
	long A[]=new long[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.nextLong();
	   }
	   return A;
   }
static String[] inputS(int n) {
	String A[]=new String[n];
	   for(int i=0;i<n;i++) {
		   A[i]=sc.next();
	   }
	   return A;
   }


static void input(int A[],int B[]) {
	   for(int i=0;i<A.length;i++) {
		   A[i]=sc.nextInt();
		   B[i]=sc.nextInt();
	   }
}
static long mod(long x) {
	  return ((x%mod + mod)%mod);
}

     static int i() {
    	 return sc.nextInt();
     }
     static String s() {
    	 return sc.next();
     }
     static long l() {
    	 return sc.nextLong();
     }  
     static void sort(int[] arr){
        int n = arr.length;
        Random rnd = new Random();
        for(int i=0; i<n; ++i){
            int tmp = arr[i];
            int randomPos = i + rnd.nextInt(n-i);
            arr[i] = arr[randomPos];
            arr[randomPos] = tmp;
        }
        Arrays.sort(arr);
     }
  
        
        
    static class FastReader 
    { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
} 




Measured memory_bytes: 36372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const int mod = 1000000007;
struct mint {
ll x;
mint(ll 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 {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};

int main(){
    int n,k;cin >> n >> k;
    combination c(3000);
    for(int i=1; i<=k; i++){
        mint ans;
        ans=c(k-1,i-1)*c(n-k+1,i);
        cout << ans.x << endl;
    }
    return 0;
}

Measured memory_bytes: 256