akhauriyash/Code-Regression huggingface dataset:
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.*;

public class Main {

static int mod=(int)1e9+7;
 public static void main(String[] $) {

  Scanner sc=new Scanner(System.in);
  try {
    
    int n=sc.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++) {
      a[i]=sc.nextInt();
    }
    ArrayList<pair> al=new ArrayList<>();
    int x=1;
    int y=399;
    pair p=new pair(x,y);
    al.add(p);
    for(int i=1;i<8;i++) {
      x=y+1;
      y=y+400;
      pair pp=new pair(x,y);
      al.add(pp);
    }
  
    int count=0;
    int special=0;
    HashSet<Integer> aa=new HashSet<>();
    for(int i=0;i<n;i++) {
      if(a[i]<3200) {
        for(pair j:al) {
          if(j.x<=a[i]&&j.y>=a[i]) {
            aa.add(j.y);
          }
        }
      }else {
        special++;
      }
    }
    if(special==n) {
      System.out.println(1+" "+(aa.size()+special));
    }else
    System.out.println(aa.size()+" "+(aa.size()+special));
 
    
  }catch(Exception e) {
    return;
  }
  
}
static long pow(long x,long y) {
  long res=1l;
  while(y!=0) {
    if(y%2==1) {
      res=x*res%mod;
    }
    y/=2;
    x=x*x%mod;
  }
  return res;
}
}
class pair{
  int x,y;
  pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}

Measured memory_bytes: 27116
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll N, D; cin >> N >> D;
	int ans = 0;
	rep(i, 0, N) {
		ll a, b; cin >> a >> b;
		ll dist = a * a + b * b;
		if (D * D >= dist)++ans;
	}
	cout << ans << "\n";

	return 0;
}

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

int main() {
  ll N,K,ans=0;
  cin >> N >> K;
  if (N==1) cout << K << endl;
  else {
    ll ans_ = K;
    for (ll p = 1; p <= N-1; ++p) ans_ *= K-1;
    ans += ans_;
    cout << ans << endl;
  }
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;
constexpr int kMax = 55556;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vs){
  for (const T& v : vs) os << v << " ";
  return os;
}

int main() {
  int N; cin >> N;
  bool b[kMax] = {};
  vector<int> primes;
  for (int i = 2; i <= kMax; ++i) {
    if (primes.size() >= N) break;
    if (b[i]) continue;

    if (i % 5 == 1) primes.push_back(i);
    for (int j = 2; i * j <= kMax; ++j) {
      b[i*j] = true;
    }
  }
  cout << primes << endl;
}


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

int main(void){
  string s;
  while(cin>>s){
    if(s[0]==s[1] && s[1]==s[2] && s[0]!='s')cout<<s[0]<<endl;
    else if(s[3]==s[4] && s[4]==s[5] && s[3]!='s')cout<<s[3]<<endl;
    else if(s[6]==s[7] && s[7]==s[8] && s[6]!='s')cout<<s[6]<<endl;
    else if(s[0]==s[3] && s[3]==s[6] && s[0]!='s')cout<<s[0]<<endl;
    else if(s[1]==s[4] && s[4]==s[7] && s[1]!='s')cout<<s[1]<<endl;
    else if(s[2]==s[5] && s[5]==s[8] && s[2]!='s')cout<<s[2]<<endl;
    else if(s[0]==s[4] && s[4]==s[8] && s[0]!='s')cout<<s[0]<<endl;
    else if(s[2]==s[4] && s[4]==s[6] && s[2]!='s')cout<<s[2]<<endl;
    else cout<<'d'<<endl;
  }
  return 0;
}



Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long int a,b,c,d,ans,ac,ad,bc,bd;
    cin >> a>>b>>c>>d;
    
    ac=a*c;
    ad=a*d;
    bc=b*c;
    bd=b*d;
    ans=ac;
    if(ans<ad)ans=ad;
    if(ans<bc)ans=bc;
    if(ans<bd)ans=bd;
    cout << ans;
}

Measured memory_bytes: 3600
D = int(input())
c = list(map(int, input().split()))
s = []
for d in range(D):
	s.append(list(map(int, input().split())))
last = [0 for i in range(26)]
v = 0
for d in range(1, D+1):
  i = int(input())
  last[i-1] = d
  v += s[d-1][i-1]
  for k in range(26):
    v -= c[k] * (d - last[k])
  print(v)

Measured memory_bytes: 69916
n = list(input())
a=int(n[0]+n[1]) #4桁の数値の前2桁
b=int(n[2]+n[3]) #4桁の数値の後2桁

if 1<= a <=12:
    if 1<= b <=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
elif 1<= b <=12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
//package beginner163.b;

import java.io.*;
import java.util.StringTokenizer;

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

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            int totalAssignmentTime = 0;
            for (int i = 0; i < m; ++i) {
                totalAssignmentTime += in.nextInt();
            }

            out.println(n - totalAssignmentTime >= 0 ? n - totalAssignmentTime : -1);
        }
    }

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

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

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

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

    }
}

Measured memory_bytes: 27228
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    S = input()

    if N % 2:
        ans = 'No'
    else:
        n = N // 2
        if S[:n] == S[n:]:
            ans = 'Yes'
        else:
            ans = 'No'
    print(ans)


main()


Measured memory_bytes: 2940
n = int(input())
a = list(map(int,input().split()))
q = int(input())

d = {}
sum = sum(a)

for i in a:
  if i in d:
    d[i] += 1
  else:
    d[i] = 1

for i in range(q):
  b, c = list(map(int, input().split()))
  if b in d:
    sum = sum + (c - b) * d[b]
    if c in d:
      d[c] += d[b]
    else:
      d[c] = d[b]
    d[b] = 0
  print(sum)


Measured memory_bytes: 20872
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef pair<int, int> pii;

// const ll inf = INT_MAX;
const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){

	int r;
	double x=0, y=0;
	double ini = pi/2, alpha, theta;
	while(scanf("%d,%lf\n", &r, &theta)){
		if(r == 0 && std::abs(theta - 0.0) < eps){
			// printf("finished\n");
			break;
		}
		else{
			x += r*cos(ini);
			y += r*sin(ini);
			alpha = pi*theta/180;
			ini -= alpha;
		}
	}
	printf("%d\n", (int)x);
	printf("%d\n", (int)y);
	return 0;
}

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
 
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if(A + B == C + D){
    cout << "Balanced" << endl;
  }
  else
    cout << "Right" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    int ans=inf;
    rep(i,n+1){
        int cnt=0;
        int u=i,v=n-i;
        int num=n;
        for(int i=7;i>0;i--){
            cnt+=u/(int)pow(6,i)+v/(int)pow(9,i);
            u%=(int)pow(6,i);
            v%=(int)pow(9,i);
        }
        chmin(ans,cnt+u+v);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define RALL(X) (X).rbegin(), (X).rend()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int r,c;
    cin>>r>>c;
    vector<VI> a(r+1,VI(c+1,0));
    vector<VI> b(r+1,VI(c+1,0));
    REP(i,r){
        string s;
        cin>>s;
        REP(j,c){
            a[i+1][j+1]=(s[j]=='#')?1:0;
            if (i and j){
                int fromtop=b[i][j+1] + ((a[i][j+1]==0 and a[i+1][j+1]==1)?1:0);
                int fromleft=b[i+1][j] + ((a[i+1][j]==0 and a[i+1][j+1]==1)?1:0);
                b[i+1][j+1]=min(fromtop,fromleft);
            }
            else{
                if (i){
                    int fromtop=b[i][j+1] + ((a[i][j+1]==0 and a[i+1][j+1]==1)?1:0);
                    b[i+1][j+1]=fromtop;
                }
                if (j){
                    int fromleft=b[i+1][j] + ((a[i+1][j]==0 and a[i+1][j+1]==1)?1:0);
                    b[i+1][j+1]=fromleft;
                }
                if (not (j+i)){
                    b[i+1][j+1]=a[i+1][j+1];
                }
            }
        }
    }
    /*for (auto i:b){
        for (auto j:i){
            cout<<j<<" ";
        }
        cout<<endl;
    }*/
    cout<<b[r][c]<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main (){
  vector<bool> v(1000000010);
  fill(v.begin(), v.end(), false);
  int N;
  cin >> N;
  int n;
  bool ans = true;
  for (int i = 0; i < N; ++i) {
    cin >> n;
    if (v[n]) {
      ans = false;
    }
    v[n] = true;
  }

  if (ans) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 122368
/*************************************
 * problem:      ABC127 problem B.
 * user name:    hkxadpall.
 * time:         2019-05-25.
 * language:     C++.
 * upload place: AtCoder.
*************************************/ 

#include <bits/stdc++.h>
using namespace std;

template <typename Int>
inline Int read()       
{
    Int flag = 1;
    char c = getchar();
    while ((!isdigit(c)) && c != '-') c = getchar();
    if (c == '-') flag = -1, c = getchar();
    Int init = c & 15;
    while (isdigit(c = getchar())) init = (init << 3) + (init << 1) + (c & 15);
	return init * flag;
}

template <typename Int>
inline void write(Int x)
{
    if (x < 0) putchar('-'), x = ~x + 1;
    if (x > 9) write(x / 10);
    putchar((x % 10) | 48);
}  

template <typename Int>
inline void write(Int x, char nextch)
{
    write(x);
    putchar(nextch);
}  

long long r, D, x;
int cases = 10;

int main()
{
    r = read<long long>();
    D = read<long long>();
    x = read<long long>();
    while (cases--) {
        x = x * r - D;
        write(x, 10);
    }
    return 0;
}

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

using namespace std;

int main()
{

	int S[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;

	cout << S[K - 1] << endl;
	

	
}


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

int main(void){
    ll l, r;
    ll mi = 2019;

    cin >> l >> r;
    for(ll i = l; i <= r; i++){
        for(ll j = i + 1; j <= r; j++){
            mi = min(mi, (i * j) % 2019);
            if(mi == 0){
                cout << mi << endl;
                return 0;
            }
        }
    }
    cout << mi << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int a,b,c,d; cin >> a >> b >> c >> d;

	cout << max(a*b, c*d) << endl;
	return (0);
}


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

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

    int ans = 0;
    int s = 0, e = n - 1;
    while (1)
    {
        if (s >= e)
            break;
        if (c[s] == 'W')
        {
            if (c[e] == 'R')
            {
                swap(c[s], c[e]);
                ++s;
                --e;
                ++ans;
            }
            else
            {
                --e;
            }
        }
        else
        {
            ++s;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3748
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn

object Main extends App {
  
  sealed abstract class Node {
    val key: Int
    var prev:Node
    var next: Node
  }

  case class Elements(key: Int, var prev:Node, var next: Node) extends Node {
    override def toString: String = s"Elements($key)"
  }

  case object MyNil extends Node{
    val key: Int = 0
    var prev: Node = MyNil
    var next: Node = MyNil
    override def toString: String = s"MyNil"
  }

  def insert(newVal: Int): Unit = {
    var x = Elements(newVal, MyNil, MyNil.next)
    MyNil.next.prev = x
    MyNil.next = x
  }

  def listSearch(searchVal: Int): Node = {
    var target = MyNil.next
    while(target.key != searchVal && target != MyNil){
      target = target.next
    }
    target
  }
  
  // nullを設定可能か？
  def deleteNode(target: Node): Unit = {
    if(target != MyNil){
      target.prev.next = target.next
      target.next.prev = target.prev
    }
  }

  def deleteFirst(): Unit = deleteNode(MyNil.next)

  def deleteLast(): Unit = deleteNode(MyNil.prev)

  def deleteKey(target: Int): Unit = deleteNode(listSearch(target))


  val n = StdIn.readLine().trim.toInt
  (0 until n).foreach{ _ =>
    val cmd = StdIn.readLine().trim.split(' ')
    if (cmd(0) == "deleteFirst") deleteFirst()
    else if(cmd(0) == "deleteLast") deleteLast()
    else if(cmd(0) == "insert") insert(cmd(1).toInt)
    else if(cmd(0) == "delete") deleteKey(cmd(1).toInt)
  }
  
  //println(commandList)
  val buff = ArrayBuffer.empty[Int]
  //val buff = ListBuffer.empty[Int]
  var current = MyNil.next
  while(current != MyNil){
    buff += current.key
    current = current.next
  }
  println(buff.mkString(" "))
}


Measured memory_bytes: 467304
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	std::string s; cin >> s;
	
	std::stack<char> st;
	for(int i = 0; i < s.size(); i++) {
		if(st.empty()) st.push(s[i]);
		else {
			if(st.top() != s[i]) st.pop();
			else st.push(s[i]);
		}
	}
	
	printf("%d\n", s.size() - st.size());
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<cmath>
#include<queue>
#include<limits>
#include<cassert>
#include<set>
#include<tuple>
#include<map>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	deque<ll> b;
	REP(i, n) cin >> a[i];
	REP(i, n) {
		if (i % 2 == (n - 1) % 2) {
			b.push_front(a[i]);
		}
		else {
			b.push_back(a[i]);
		}
	}
	REP(i, n) cout << b[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>

using int64 = long long;

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int N, H, W;
    std::cin >> N >> H >> W;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int A, B;
        std::cin >> A >> B;

        if (A >= H and B >= W) ans++;
    }
    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
    int r, g, b, n;
    cin >> r;
    cin >> g;
    cin >> b;
    cin >> n;
    int s = 0;
    for (int i = 0; i <= n / r; i++) {
        for (int j = 0; j <= n / g; j++) {
            int x = i * r + j * g;
            if (x <= n && (n - x) % b == 0) {
                s++;
            }
        }
    }
    cout << s << endl;

	return 0;
}


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

int main() {
	int num[14] = {1,5,10,50,100,500,1000,0,3,8,30,80,300,800};
	int nownum;
	int sum;
	char broma;
	char roma;
	string hoge;
	
	while ( cin >> hoge ) {
		sum = 0;
		broma = 10;
		for ( int i = 0; i < hoge.length(); i++ ) {
			roma = hoge[i];
			nownum = string("IVXLCDM").find(roma);
			if ( broma < nownum )
				sum = sum + num[nownum + 7];
			else
				sum = sum + num[nownum];
			broma = nownum;
		}
		cout << sum << endl;
	}
	
}

Measured memory_bytes: 1188
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ2013().doIt();
	}
	
	class AOJ2013{
		int n;
		ArrayList<Data> list;
		
		void solve(){
			int result = 0;
			int[] map = new int[25*60*60];
			for(int i=0;i<list.size();i++)for(int s=list.get(i).start;s<list.get(i).end;s++)map[s]++;
			for(int i=0;i<map.length;i++)result = Math.max(result, map[i]);
			System.out.println(result);
		}
		
		void doIt(){
			while(in.hasNext()){
				n = in.nextInt();
				if(n==0)break;
				list = new ArrayList<Data>();
				for(int i=0;i<n;i++)list.add(new Data(in.next(), in.next()));
				solve();
			}
		}
		class Data{
			int start,end;
			public Data(String a,String b){
				String[] input = a.split(":");
				start = getTime(Integer.parseInt(input[0]), Integer.parseInt(input[1]), Integer.parseInt(input[2]));
				input = b.split(":");
				end = getTime(Integer.parseInt(input[0]), Integer.parseInt(input[1]), Integer.parseInt(input[2]));
//				System.out.println(start+" "+end);
			}
			
			int getTime(int h,int m,int s){
				int result = s;
				result += m*60;
				result += h*60*60;
				return result;
			}
			
		}
	}
	
}

Measured memory_bytes: 70636
N = int(input())
K = int(input())
x = list(map(int, input().split()))

result = 0

for i in range(len(x)):
  if x[i] * 2 <= abs((x[i] - K) * 2):
    result += x[i] * 2
  else:
    result += abs((x[i] - K) * 2)

print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define x first
#define y second
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pie   3.141592653589793238462643383279502884L
ll mod = 998244353;
ll powerMod(ll a,ll n){
  if(n==0)
    return 1;
  ll res = powerMod((a%mod*a%mod)%mod,n/2)%mod;
  if(n%2)
  return (a%mod*res%mod)%mod;
  return res; 
} 

int main(){
  ll n;
  cin >> n;
  ll h[101] = {0};
  bool prime[101]={0};
  for(ll i = 1; i <= n ;i ++){
    ll temp = i;
    for(ll j = 2; j * j <= temp; j++)
      while(temp%j==0){
        h[j]++;
        temp/=j;
      }
    if(temp == i)
      prime[i] = 1;  
    h[temp]++;
  }
 
ll ans = 0;

for(ll i = 2; i <= n; i++)
  if(prime[i]){
    if(h[i]>=74)
        ans++;
    for(ll j = i+1; j < n + 1; j++)
      if(prime[j]){
        
        if(h[i] >= 2 && h[j] >= 24)
          ans++;
        if(h[i] >= 4 && h[j] >= 14)
          ans++;
      
        if(h[j] >= 2 && h[i] >= 24)
          ans++;
        if(h[j] >= 4 && h[i] >= 14)
          ans++;
      }
    }  
for(ll i = 2; i < n+1; i++)
  if(prime[i] != 0)
    for(ll j = i + 1; j <n + 1; j++ )
      if(prime[j] != 0)
        for(ll k = j + 1; k < n + 1; k++)
          if(prime[k] != 0){
            if(h[i] >= 2 && h[j] >= 4 && h[k] >= 4)
              ans++;
            if(h[j] >= 2 && h[i] >= 4 && h[k] >= 4)
              ans++;
            if(h[k] >= 2 && h[j] >= 4 && h[i] >= 4)
              ans++;
          } 
cout << ans;
  return 0;   
}

Measured memory_bytes: 256
public class Main {
  private static void solve() {
   String s = next();
   if (s.contains("AC")) {
     System.out.println("Yes");
   } else {
     System.out.println("No");
   }
    
    
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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


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

	int x=0,ans=0;
	for (int i = 0; i < n; i++){
			if(s[i]=='D'){
				x--;
			}else{
				x++;
			}
			if(ans<x){
				ans=x;
			}
		}
		cout<<ans<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int D[22][22];
ll dp[(1 << 21)];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		rep(j, 0, N) cin >> D[i][j];
	}
	dp[0] = 1;
	rep(bit, 0, (1 << N)) {
		int i = __builtin_popcount(bit);
		rep(j, 0, N) {
			if(D[i][j] && !(bit & (1 << j))) ADD(dp[bit | (1 << j)], dp[bit]);
		}
	}
	// debug(vi(dp, dp + 8));
	cout << dp[(1 << N) - 1] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 16640
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	ll h; cin >> h;
	ll d = 1;
	while (h > 1)
	{
		++d;
		h /= 2;
	}
	ll res = pow(2, d) - 1;
	cout << res << endl;
}

Measured memory_bytes: 384
#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;

int n, s;
int a[10];

int combi(int i, int s, int t)
{
    if (s == 0 && t == n)
        return 1;
    if (i == 10 || t == n)
        return 0;

    return combi(i + 1, s, t) + combi(i + 1, s - a[i], t + 1);
}
int main()
{
    rep(i, 10) a[i] = i;

    while (cin >> n >> s, n)
    {

        OP(combi(0, s, 0));
    }

    return 0;
}


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

public class Main{
  static final int INF = Integer.MAX_VALUE / 2;
  static int n, m, r;
  static int[] p;
  static int[] a, b, c;

  static final boolean DEBUG = false;

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

    n = sc.nextInt();
    m = sc.nextInt();
    r = sc.nextInt();
    p = new int[r];
    for(int i = 0; i < r; i++){
      p[i] = sc.nextInt() - 1;
    }
    a = new int[m];
    b = new int[m];
    c = new int[m];
    for(int i = 0; i < m; i++){
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
      c[i] = sc.nextInt();
    }

    int[][] dist = new int[n][n];
    for(int i = 0; i < n; i++){
      Arrays.fill(dist[i], INF);
    }
    for(int i = 0; i < n; i++){
      dist[i][i] = 0;
    }
    for(int i = 0; i < m; i++){
      dist[a[i]][b[i]] = dist[b[i]][a[i]] = c[i];
    }
    for(int k = 0; k < n; k++){
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          dist[i][j] = Math.min(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    int ans = backTrack(0, new int[r], new boolean[r], dist);

    System.out.println(ans);
  }

  static int backTrack(int i, int[] perm, boolean[] used, int[][] dist){
    if(i == r){
      int sum = 0;
      for(int j = 0; j + 1 < r; j++){
        sum += dist[perm[j]][perm[j + 1]];
      }
      return sum;
    }
    int min = INF;
    for(int j = 0; j < r; j++){
      if(!used[j]){
        perm[i] = p[j];
        used[j] = true;
        min = Math.min(min, backTrack(i + 1, perm, used, dist));
        used[j] = false;
      }
    }
    return min;
  }
}


Measured memory_bytes: 47868
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a-b)%c<<endl;
}








Measured memory_bytes: 256
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
#define PB push_back
#define MP make_pair
#define FST first
#define SND second
#define SZ(a) (signed)((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int MOD = 1000000007;
const char ENDL = '\n';

#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")"  << " " << __FILE__ << endl;

signed main(void) {
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed, ios::floatfield);
    cout.precision(10);
    cin.tie(0);

    int n;
    cin >> n;
    VI t(n+2,0),a(n+2,0);
    FOR(i,1,n+1){
        cin >> t[i];
    }
    FOR(i,1,n+1){
        cin >> a[i];
    }

    int ans = 1;
    FOR(i,1,n+1){
        if(t[i-1]<t[i] && a[i]>a[i+1]){
            if(a[i]!=t[i]){
                ans = 0;
            }
        }else if(t[i-1]<t[i]){
            if(a[i]<t[i]){
                ans = 0;
            }
        }else if (a[i]>a[i+1]){
            if(a[i]>t[i]){
                ans = 0;
            }
        }else{
            ans*=min(a[i],t[i]);
            ans%=MOD;
        }
    }

    cout << ans << ENDL;
    
    return 0;
}

Measured memory_bytes: 1792
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}
use input::*;
use std::cmp;

fn count2(mut x: usize) -> usize {
    let mut ans = 0;
    while x % 2 == 0 {
        x >>= 1;
        ans += 1;
    }
    ans
}

fn main() {
    let n: usize;
    input!(n);
    let v = input_vector::<usize>();
    let mut ans = usize::max_value();
    for z in v {
        ans = cmp::min(count2(z), ans);
    }
    p(ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n;
	cin >> n;
	int odd=0;
	for (int i = 0; i < n; i++) {
		int tmp;
	        cin >> tmp;
		if (tmp%2==1) {
			odd++;
		}
	}

	if (odd%2!=1) {
		cout << "YES" << "\n";
	} else {
		cout << "NO" << "\n";
	}

}


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

int main(){
    int a,b;
    
    while(1){
    cin >>a >>b;
    
    if (a == 0 && b ==0){
        break;
    }
    
    for(int i=0; i < a; i++){
        for (int j=0; j < b; j++){
            cout << '#';
        }
        cout << endl;
    }
    cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
import sys
N, X = map(int, input().split())
m = sorted([int(i) for i in sys.stdin.readlines()])
X -= sum(m)

cnt = 0
for i in range(len(m)):
    cnt += X//m[i]
    X -= m[i] * cnt
    if X <= 0:
        break
print(cnt + N)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d,s=0;
	cin>>a>>b>>c>>d;
	if(a>=b)
	s+=b;
	else
	s+=a;
	if(c>=d)
	s+=d;
	else
	s+=c;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


bool check(int y, int m, int d)
{
  if (y < 2019)
    return false;

  if (y > 2019)
    return true;

  if (m < 4)
    return false;

  if (m > 4)
    return true;

  if (d <= 30)
    return false;

  return true;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int y, m, d;
  
  scanf("%d/%d/%d", &y, &m, &d);

  std::cout << (check(y, m, d) ? "TBD" : "Heisei") << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cctype>
#define rep(i, m, n) for(int i = m;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define ll long long
#define ull unsigned long long
#define push(a) push_back(a)
#define pop(a) pop_back(a)
#define debug(x) cout<<#x<<": "<<x<<endl
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
      long H = sc.nextLong();
      long W = sc.nextLong();

      if(W==1||H==1){
        System.out.println("1");
        return;
      }
      if(W%2==0||H%2==0){
        System.out.println(W*H/2);
        return;
      }
      System.out.println(W*H/2+1);

    }
  
  private static long lcm(long m, long n) {
    return m * n / gcd(m, n);
}
  
  private static long gcd(long m, long n) {
    if(m < n) return gcd(n, m);
    if(n == 0) return m;
    return gcd(n, m % n);
}
}


Measured memory_bytes: 22100
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ans = int(1)

N = I()
AB = [LI() for _ in range(N)]

AB = sorted(AB, key=lambda x: x[1])
T = int(0)
for i in range(N):
    T += AB[i][0]
    if T>AB[i][1]:
        ans = -1

if ans>0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55236
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using Debug = System.Diagnostics.Debug;

class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select((x, y) => new Tuple<int, int>(int.Parse(x), y)).OrderBy(x => x.Item1).Select(x => x.Item2).ToList();
        Console.WriteLine(string.Join(" ", Enumerable.Range(1, n).Select(x => x * 20000).Zip(a, (x, y) => x + y)));
        Console.WriteLine(string.Join(" ", Enumerable.Range(1, n).Select(x => x * 20000).Reverse()));
    }
}


Measured memory_bytes: 20576
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <vector>
#include <algorithm>
#include <map>

int N;
long long M;
std::vector<long long > A(100000);
std::vector<long long > kumisuu(200000, 0); // A_i>=x を満たすiの数
std::vector<long long > souwa(200000, 0); // A_i>=x を満たすiについてA_iの総和

long long get_possible_count(int value){ // 値がvalue以上となる組み合わせ総数を求める
  long long count = 0;
  for (int i=0; i<N; i++){
    count += kumisuu[std::max(value-A[i], (long long)0)];
  }
  return count;
}

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

  for (int i=0; i<N; i++){
    scanf("%lld",&A[i]);
    kumisuu[A[i]]++;
  }
  sort(A.begin(), A.end(), std::greater<long long>());

  for (int i=0; i<N; i++){
    souwa[i+1] = souwa[i] + A[i];
  }

  /*  累積和を求める */
  for (int i=200000; i>0; i--){
    kumisuu[i-1] += kumisuu[i];
  }

  int left = 0;
  int right = 200001;
  int mid;
  long long ans;
  std::map<long long, long long > mp;
  while(right-left>1){
    ans = 0;
    mid = (left+right)/2;
    if (get_possible_count(mid)>=M){ // 
      left = mid;
    } else {
      right = mid;
    }
    mp[mid] = get_possible_count(mid);
    for (int i=0; i<N; i++){
      ans += souwa[kumisuu[std::max(mid-A[i],(long long)0)]];
      ans += A[i]*kumisuu[std::max(mid-A[i],(long long)0)];
    }
  }

  if (left == mid){
    std::cout << ans-abs(M-mp[left])*left << std::endl;
  } else if (right==mid){
    /*long long ans;
    for (int i=0; i<N; i++){
      ans += souwa[kumisuu[std::max(right-A[i],(long long)0)]];
      ans += A[i]*kumisuu[std::max(right-A[i],(long long)0)];
      }*/
    std::cout << ans+abs(M-mp[right])*left << std::endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  map<int, int> mp;
  rep(i, n) ++mp[a[i]];
  int cnt = 0;
  bool exist = false;
  for (auto itr = mp.begin(); itr != mp.end(); ++itr) ++cnt;
  if (cnt == 1 && mp[0] > 0) exist = true;
  if (cnt == 2 && 3 * mp[0] == n) exist = true;
  if (cnt == 3) {
    auto itr = mp.begin();
    int a1 = itr->first;
    int n1 = (itr++)->second;
    int a2 = itr->first;
    int n2 = (itr++)->second;
    int a3 = itr->first;
    int n3 = (itr++)->second;
    if ((a1 ^ a2) == a3 && n1 == n2 && n1 == n3) exist = true;
  }
  
  if (exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    vector<int> v(26, INF);
    string s;
    REP(i, n) {
        vector<int> w(26, 0);
        cin >> s;
        REPS(c, s) w[(int)(c - 'a')]++;
        REP(i, 26) chmin(v[i], w[i]);
    }
    REP(i, 26) REP(j, v[i]) cout << (char)(i + 'a'); cout << endl;
}
// 75 = 3 * 5 * 5


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

int main() {
    string s;
    cin >> s;
    string t;
    for (int i = 1; i < s.size(); i++) {
        if (s[i] == 'C' && s[i - 1] == 'B') {
            t.push_back('D');
            i++;
        } else {
            t.push_back(s[i - 1]);
        }
    }

    long long res = 0, cnt = 0;
    for (int i = 0; i < t.size(); i++) {
        if (t[i] == 'B' || t[i] == 'C') {
            cnt = 0;
        } else if (t[i] == 'A') {
            cnt++;
        } else {
            res += cnt;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 776
fun main(args: Array<String>) {
    val (a, b, c, x, y) = readLine()!!.split(" ").map(String::toInt)
    if (a + b < c * 2) {
        println(a * x + b * y)
    } else {
        when {
            (x <= y) -> {
                if (b < c * 2) {
                    println(c * x * 2 + b * (y - x))
                } else {
                    println(c * y * 2)
                }
            }
            (x > y) -> {
                if (a < c * 2) {
                    println(c * y * 2 + a * (x - y))
                } else {
                    println(c * x * 2)
                }
            }
        }
    }
}

Measured memory_bytes: 37904
import bisect
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S = sys.stdin.buffer.readline().decode().rstrip()

t = S.replace('x', '')
if t != t[::-1]:
    print(-1)
    exit()

l = 0
r = len(S) - 1
ans = 0
while l < r:
    while S[l] != S[r]:
        if S[l] != 'x':
            r -= 1
        else:
            l += 1
        ans += 1
    l += 1
    r -= 1

print(ans)


Measured memory_bytes: 13832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
 
 
using namespace __gnu_pbds;
using namespace std;
 
 
typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;
 
      a=a*a%mod;
      b/=2;
 
      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
 
 
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    // ifstream fin(".in");
    // ofstream fout(".in");
 
 
i64 a,b,c,d;
cin>>a>>b>>c>>d;
    int t=1;
while(a>0&&c>0)
{
  if(t)c-=b;
  else a-=d;
  t^=1;
}
    if(a<=0)cout<<"No";
    else cout<<"Yes";
 
    return 0;
  }

Measured memory_bytes: 3640