akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define maxn 15

using namespace std;
const long long inf=5000005;
long long n,e,q,dis[maxn][maxn],prevv[maxn][maxn],edge[maxn][maxn];
void init()
{
    //memset(dis,inf,sizeof(dis));
    //memset(prevv,-1,sizeof(prevv));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            dis[i][j]=edge[i][j];
            //if(dis[i][j]!=0&&dis[i][j]!=inf)
              //  prevv[i][j]=i;
        }
    }
}
void floyd()
{
    init();
    //for(int i=1;i<=n;i++)
      //  for(int j=1;j<=n;j++)
        //cout<<dis[i][j]<<endl;
    for(int k=0;k<n;k++)
        for(int j=0;j<n;j++)
           for(int i=0;i<n;i++)
              if(dis[i][j]>dis[i][k]+dis[k][j])
              {
                  dis[i][j]=dis[i][k]+dis[k][j];
                //  prevv[i][j]=prevv[k][j];
                //cout<<k<<" "<<j<<" "<<i<<" "<<dis[i][j]<<" "<<dis[i][k]<<" "<<dis[k][j]<<endl;
              }
}
int h,w;
int main()
{

    while(cin>>h>>w)
    {   n=10;
        for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            edge[i][j]=inf;
        for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
        {
            cin>>edge[i][j];
        }

        floyd();
        int sum=0;
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
        {
            int num;
            cin>>num;
            if(num!=-1) sum+=dis[num][1];
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 256
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif
 
void Main() {
  int n; cin >> n;
  map<string, int> mp;
  int a = 0;
  for(int i = 0; i < n; i++) {
    string t; cin >> t;
    mp[t]++;
    a = max(a, mp[t]);
  }
  vector<string> v;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    if(it->second == a) {
      v.push_back(it->first);
    }
  }
  sort(v.begin(), v.end());
  for(auto &x: v) {
    cout << x << "\n";
  }
}

Measured memory_bytes: 25584
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int seq=1;
	for(int i=0;i<n;i++){
		if(a[i]==seq)
			seq++;
	}
	if(n-seq+1==n)
	cout<<-1<<endl;
	else
	cout<<n-seq+1<<endl;
}



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

int main() {
	int e;
	int x, y, z;
	while (1) {
		cin >> e;
		if (e == 0) {
			break;
		}
		int m = e;
		for (z = 0; z*z*z <= e; z++) {
			for (y = 0; y*y + z*z*z <= e; y++) {
				x = e - y*y - z*z*z;
				if (m > x + y + z) m = x + y + z;
			}
		}
		cout << m << endl;
	}

}

Measured memory_bytes: 1160
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) throws Exception{
	       BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	       int N = Integer.parseInt(br.readLine());
	       int[] line = new int[N];
	       int sum = 0;
	       for(int i=0;i<N;i++){
	    	   line[i]=Integer.parseInt(br.readLine());
	    	   sum+=line[i];
	       }
	       Arrays.sort(line);
	       if(sum%10==0){
	    	   for(int i=0;i<N;i++){
	    		   if((sum-line[i])%10!=0){
	    			   sum-=line[i];
	    			   break;
	    		   }
	    		   if(i==N-1){
	    			   sum=0;
	    		   }
	    	   }
	       }
	       System.out.println(sum);
	}
}


Measured memory_bytes: 22996
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N, K;
	cin >> N>>K;
	ll an = K;
	rep(i,N-1) {
		an *= (K-1);
	}
	cout << an << endl;
}

Measured memory_bytes: 256
io = STDIN
s=io.gets.chomp
if s[0]=='A' &&
   s[2..-2].split(//).select{|x|x=="C"}.size==1 &&
   s.split(//).reject{|x|x=="C"||x=="A"}.all?{|x|x.downcase==x}
   puts 'AC'
 else
   puts 'WA'
 end


Measured memory_bytes: 1788
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;
int sum[N];
int main ( ){
  scanf("%d",&n);
   for ( int i = 0; i < n; i++ ){
      scanf("%d",a+i);
      sum[a[i]]++;
   }
   for ( int i = 1 ; i < N ; i++ ) sum[i]+=sum[i-1];
   sort( a , a+n);
   ll ANS = 0;
   for ( int i =0 ; i < n ; i++ )
    for  (int j = i+1 ; j < n ; j++ ) {
       int mx = a[i]+a[j] - 1;
       int mn = a[j]-a[i]+1 ;
       ANS += sum[mx]-sum[mn-1] ;
        if ( a[j] >= mn && a[j] <= mx  ) ANS-- ;
       if ( a[i] >= mn && a[i] <= mx  ) ANS-- ;

    }
    printf("%lld\n",ANS/3);
return 0 ;
}


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

int main() {
  int A, B, X;
  cin >> A >> B;
  for(; A < B + 1; A++) {
    int a, b, c, d, e;
    a = A / 10000;
    b = A % 10000 / 1000;
    c = A % 10000 % 1000 / 100;
    d = A % 10000 % 1000 % 100 / 10;
    e = A % 10000 % 1000 % 100 % 10 / 1;
    if(a != e || b != d) {
    }
    else {
      X++;
    }
  }
  cout << X << endl;
}


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

using namespace std;

int n[123];

struct edge {
    int a, b, c;
};
int N;
vector<edge> e;
void edge(int a, int b, int c) {
    e.push_back({a, b, c});
}

void print() {
    cout << N << " " << e.size() << "\n";
    for(auto x: e) {
        x.a = N - x.a;
        x.b = N - x.b;
        cout << x.a << " " << x.b << " " << x.c << "\n";
    }
}

int main() {
    int L;
    int cs = 0;
    cin >> L;
    N = 1;
    n[0] = 1;
    for(int i = 1; i < 20; i++) {
        n[i] = n[i-1]*2;
        if(n[i] > L) {
            break;
        }
        edge(i, i-1, 0);
        edge(i, i-1, n[i-1]);
        N++;
    }
    L -= n[N-1];
    cs += n[N-1];
    while(L > 0) {
        int i;
        for(i = N-1; n[i] > L; i--) {}
        edge(N-1,i,cs);
        L -= n[i];
        cs += n[i];
    }
    print();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
//manip
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i, n) cout << a[i] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always




int main() {
    
    
    
    
    string s; cin >> s;
    sort(all(s));
    //out(s);
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    
}



Measured memory_bytes: 256
//In the name of ALLAH the most merciful the most beneficial

#include<cstdio>
#include<cstring>
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<fstream>
#define sc(x) scanf("%d",&x)
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORd(i,a,b) for(int i=a;i>b;i--)
#define ff first
#define ss second
#define sz(x) x.size()
#define pb push_back

using namespace std;

typedef pair<int,int> pii;
typedef vector<pii> vii;
const int con = 1e5+7;
static const int INF = 0x3f3f3f3f;
static const int MOD = 1e9+7;


int main(){
/*
    clock_t start,end;
    start = clock();*/
    
    int n;cin >> n;
    int arr[n],sum=0;
    FOR(i,0,n) cin >> arr[i],sum += arr[i];
    
    int avg = ceil((float)sum/n);
    int avg2 = sum/n;
    ll ans = 0,ans1=0;
    FOR(i,0,n){
        
        ans += (avg-arr[i])*(avg-arr[i]);
    }
    FOR(i,0,n){
        ans1 += (avg2-arr[i])*(avg2-arr[i]);
    }
    cout << min(ans,ans1);
/*  end = clock();
    double time = double(end-start)/(double)CLOCKS_PER_SEC;
    cout <<fixed<< time/1000 << "sec";*/
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> v;
    v.push_back(0);
    vector<bool> used(m, false);
    ll a = x;
    v.push_back(x);
    used[a] = true;
    int loop_start = 0;
    for(int i=2;i<=2*m;++i) {
        a = (a * a) % m;
        if(used[a]) {
            break;
        }
        v.push_back(a);
        used[a] = true;
    }
    for(int j=1;j<v.size();++j) {
        if(a == v[j]) {
            loop_start = j;
            break;
        }
    }

    int nv = v.size();
    for(int i=1;i<nv;++i) {
        v[i] += v[i-1];
    }
    
    if(n < nv) {
        cout << v[n] << endl;
        return 0;
    }

    ll ans = v[nv-1];
    n -= nv-1;
    ans += (v[nv-1] - v[loop_start-1]) * (n / (nv - loop_start));
    n %= (nv - loop_start);
    ans += (v[loop_start-1 + n] - v[loop_start-1]);

    cout << ans << endl;
}


Measured memory_bytes: 3852
#include <iostream>
using namespace std;
int main(){
    string N; cin >> N;
    int cnt = 0;
    for (int i = 0; i < N.size(); ++i){
        if (N[i] == N[N.size() - i - 1]){
            ++cnt;
        }
    }
    if (cnt == (int)(N.size() + 1 / 2)){
        cout << "Yes" << endl;
    }else{
        cout <<  "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

int f_dir[2][4] = {{-1, 0, 1, 0}, {0, 1, 0, -1}}; //↑→↓←
int e_dir[2][8] = {{-1, -1, -1, 0, 0, 1, 1, 1}, {-1, 0, 1, -1, 1, -1, 0, 1}};
bool is_in_field(int y, int x, int h, int w){
  return (y >= 0 && y < h && x >= 0 && x < w);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  vi f(n), s(n);
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    f[i] = i + a;
    s[i] = i - a;
  }
  sort(s.begin(), s.end());
  ll ans = 0;
  for(int i = 0; i < n; i++){
    auto s1 = lower_bound(s.begin(), s.end(), f[i]);
    auto s2 = upper_bound(s.begin(), s.end(), f[i]);
    ans += s2 - s1;
  }
  cout << ans << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 4828
#include <iostream>
#include <iomanip>
#include <math.h> 
using namespace std;

#define M_PI 3.14159265358979323846

class Point {
public:
	double x, y;
};

void koch(int n, Point a, Point b)
{
	Point s, t;
	if (n == 0) return;
	s.x = (2 * a.x + b.x) / 3;
	s.y = (2 * a.y + b.y) / 3;
	t.x = (a.x + 2 * b.x) / 3;
	t.y = (a.y + 2 * b.y) / 3;
	Point u;
	double rad = M_PI*(60.0 / 180.0);
	u.x = (t.x - s.x)*cos(rad) - (t.y - s.y)*sin(rad) + s.x;
	u.y = (t.x - s.x)*sin(rad) + (t.y - s.y)*cos(rad) + s.y;
	koch(n - 1, a, s);
	cout << s.x << " " << s.y << endl;
	koch(n - 1, s, u);
	cout << u.x << " " << u.y << endl;
	koch(n - 1, u, t);
	cout << t.x << " " << t.y << endl;
	koch(n - 1, t, b);
}

int main() 
{
	int n;
	cin >> n;
	Point a, b;
	a.x = 0;a.y = 0;
	b.x = 100;b.y = 0;
	cout << fixed << setprecision(8) << a.x << " " << a.y << endl;
	koch(n, a, b);
	cout << fixed << setprecision(8) << b.x << " " << b.y << endl;
}

Measured memory_bytes: 3172
import numpy as np
s,t=(x for x in input().split())
a,b=(int(x) for x in input().split())
u=input()

if s==u:
    a=a-1
else:
    b=b-1

print(a,b,sep=" ")



"""
cd C:/Users/muto/Documents/AtCorder
python


入力
文字列
s=input()
整数
a=int(input())
区切り文字
b,c=(int(x) for x in input().split())

任意の文字数
a = int(input())
b=np.array(a)
b=(int(x) for x in input().split())
c=list(b)

2重ループを抜ける
flag=False
	else:
            flag=True
            break
    if flag:
        break

整数型int
小数型float

出力、区切り文字
print(str(a+b+c),s,sep=" ")
print('Odd')

if文
if a%2==1 and b%2==1:
else:

行列操作
b=np.array(a)
c[i]=int(c[i]/2)


import math
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

#関数定義
def test():
    print('関数：testを呼び出しました')
 
if __name__ == '__main__':
 
    print('python-izm')
    test()

#配列
arr = np.asarray([1,2,3], dtype=np.int32)
np.float64
np.array(range(1, 10))

#行列
arr = np.asarray([[1,2,3], [4,5,6]])
np.zeros((2, 3))

#乱数発生
np.random.rand(2, 3)
np.random.randint(0, 10, size=10)

np.zeros((2, 3))
np.random.shuffle(x)

#行列積
a.dot(b)
np.dot(vecx, vecz)

#各要素ごとの積
np.multiply(x,y)

#結合
np.vstack((x, y))

#平均最大値最小値標準偏差和
np.mean(arr)
np.max(arr)
np.min(arr)
np.std(arr)
np.sum(arr)
np.sqrt
#列ごと
np.sum(arr, axis=0)
#行ごと
np.sum(arr, axis=1)

#ソート
print(np.sort(x)[::-1])

#各値（0始まり）
x[0][1] = 100

#転地行列
arr.T

#画面表示
import tkinter
root = tkinter.Tk()

#リストでグラフ作成
plt.plot([3,4,2,1])
plt.ylabel('some numbers')
plt.show()

#点でグラフ（範囲指定）
plt.plot([1,2,3,4], [1,4,9,16], 'ro')
plt.axis([0, 6, 0, 20])
plt.show()

#関数でグラフ
x = np.arange(0., 5., 0.2)
plt.plot(x**3, 'b--')
plt.show()

#複数グラフ
plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^')
plt.show()

#関数定義
def f(t):
    return t
 
t = np.arange(0., 5., 0.2)
 
plt.plot(t, f(t), 'r--', t, g(t), 'bs', t, h(t), 'g^')
plt.show()

#タブ区切りファイルからグラフ作成
with open("Input.txt", 'r') as inputfile:
    lines = inputfile.readlines()
    x = []
    y = []
    for line in lines:
        value = line.replace('\n', '').split('\t')
        x.append(value[0])
        y.append(value[1]) 
    plt.plot(x, y)
    plt.show()

#png出力
plt.savefig('hoge.png', dpi=300, orientation='portrait', transparent=False, pad_inches=0.0)

#pdf出力
plt.savefig('test.pdf', orientation='portrait', transparent=False, bbox_inches=None, frameon=None)

#utf-8表記（python2で必要）
# -*- coding: utf-8 -*- 

"""


Measured memory_bytes: 12408
class PriorityQueue
  def initialize
    @heap = [nil]
  end

  def up_heap(x, i, j, k)
    @heap << [x, i, j, k]
    idx = @heap.size - 1

    while idx != 1
      parent = idx / 2
      break if @heap[idx][0] < @heap[parent][0]

      @heap[idx], @heap[parent] = @heap[parent], @heap[idx]
      idx = parent
    end
  end

  def down_heap
    size = @heap.size
    return if size == 1
    return @heap.pop if size == 2

    max = @heap[1]
    @heap[1] = @heap.pop
    size -= 1
    idx = 1

    while idx * 2 < size
      l = idx * 2
      r = idx * 2 + 1

      if @heap[r]
        child = @heap[l][0] > @heap[r][0] ? l : r
      else
        child = l
      end

      break if @heap[idx][0] > @heap[child][0]

      @heap[idx], @heap[child] = @heap[child], @heap[idx]
      idx = child
    end

    max
  end

  alias_method :<<, :up_heap
  alias_method :push, :up_heap
  alias_method :shift, :down_heap
end

x, y, z, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort_by { |i| -i }
b = gets.split.map(&:to_i).sort_by { |i| -i }
c = gets.split.map(&:to_i).sort_by { |i| -i }
q = PriorityQueue.new
h = Hash.new(true)

q.push(a[0] + b[0] + c[0], 0, 0, 0)
h[[0, 0, 0]] = nil

k.times do
  ret, i, j, k = q.shift

  if i + 1 < x && h[[i + 1, j, k]]
    q.push(a[i + 1] + b[j] + c[k], i + 1, j, k)
    h[[i + 1, j, k]] = nil
  end

  if j + 1 < y && h[[i, j + 1, k]]
    q.push(a[i] + b[j + 1] + c[k], i, j + 1, k)
    h[[i, j + 1, k]] = nil
  end

  if k + 1 < z && h[[i, j, k + 1]]
    q.push(a[i] + b[j] + c[k + 1], i, j, k + 1)
    h[[i, j, k + 1]] = nil
  end

  puts ret
end

Measured memory_bytes: 3320
import java.io.*;
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = Integer.parseInt(sc.next());
    }
    
    int[] ans = new int[N];
    for (int i = 0; i < N; i++) {
      ans[A[i] - 1] = i + 1;
    }
    
    System.out.print(ans[0]);
    for (int i = 1; i < N; i++) {
      System.out.print(" " + ans[i]);
    }
  }
}

Measured memory_bytes: 46172
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;
typedef long long ll;

int main() {
    int a, b, t;
    cin >> a >> b >> t;

    int res = 0;
    int time = a;

    while (time < t + 1) {
        res += b;
        time += a;
    }

    cout << res << endl;
}


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

using namespace std;

const double PI = 3.141592653589;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define int long long
#define all(c) (c).begin(),(c).end()
#define M 1000000007
#define INF LLONG_MAX
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
// Use pr(a,b,c,d,e) or cerr<<anything or prc(v.begin(),v.end()) or prc(v,v+n)
//  


int32_t main()
{
    fastio;
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    int h, n, s = 0;
    cin >> h >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        s += a[i];
    }
    if(s >= h) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}



Measured memory_bytes: 1024
import java.util.*;
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), X = sc.nextInt(), Y = sc.nextInt();
		int t1 = X*A+Y*B, t2=Math.min(2*C*Math.max(X,Y),  2*C*Math.min(X,Y)+((X>Y) ? (X-Y)*A : (Y-X)*B));
		System.out.println(Math.min(t1, t2));
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35884
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<vector<ll>> f(n ,vector<ll>(10));
  vector<vector<ll>> p(n, vector<ll>(11));
  ll ans = -INF;

  rep(i, n) {
    rep(j, 10) cin >> f[i][j];
  }
  rep(i, n) {
    rep(j, 11) cin >> p[i][j];
  }

  rep(bit, 1<<10) {
    vector<int> d(10);
    rep(i, 10) if (bit & (1 << i)) {
      d[i] = 1;
    }

    if (__builtin_popcount(bit) == 0) continue;

    ll sum = 0;
    rep(i, n) {
      ll cnt = 0;
      rep(j, 10) {
        if (d[j] == f[i][j] && d[j] == 1) cnt++;
      }
      sum += p[i][cnt];
    }

    chmax(ans, sum);
  }

  cout << ans << endl;

  return 0;
}


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

#define FOR(i, j, k) for (int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define RFOR(i, k, j) for (int i = k - 1; i >= j; i--)
#define RREP(i, j) RFOR(i, j, 0)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

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;
}

template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x; 
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;

    vi h(n);
    cin >> h;

    int ans = 0, tmp = 0;
    int l = 0;
    FOR(i, 1, n) {
        if (h[i - 1] >= h[i]) {
            tmp++;
        } else {
            ans = max(ans, tmp);
            tmp = 0;
            l = i;
        }
    }

    ans = max(ans, tmp);

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


Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
int main() {
	string wow;
	cin >> wow;
	for (int i = wow.size() - 1;i >= 0;--i) {
		printf("%c", wow[i]);
	}
	printf("\n");
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)

ll pow(ll _x, ll _n)
{
	ll ret = 1;
	while (0 < _n)
	{
		if ((_n % 2) == 0)
		{
			_x *= _x;
			_n >>= 1;
		}
		else
		{
			ret *= _x;
			--_n;
		}
	}
	return ret;
}



int main() {
	ll h;
	ll res = 0;
	scanf("%lld", &h);
	ll cnt = 0;
	while (h > 0) {
		cnt++;
		h /= 2;
	}
	res = pow(2, cnt) - 1;
	printf("%lld\n", res);
	return(0);
}

Measured memory_bytes: 256
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

def ceil(a,b) :
    return (a + b - 1) // b

time =[A , B , C , D , E]
time.sort()

minTime = time[0]

ans = ceil(N,minTime) + 4

print(ans)


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s,u,x;
  int ns,nu;
  cin>>s>>u;
  cin>>ns>>nu;
  cin>>x;
  if(x==s)ns--;
  else nu--;
  cout<<ns<<" "<<nu<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
void go(ll sx, ll sy, ll tx, ll ty){
    for(ll i=0;i<(tx-sx);i++){
        cout << 'R';
    }
    for(ll i=0;i<(ty-sy);i++){
        cout << 'U';
    }
}
void back(ll sx, ll sy, ll tx, ll ty){
    for(ll i=0;i<(tx-sx);i++){
        cout << 'L';
    }
    for(ll i=0;i<(ty-sy);i++){
        cout << 'D';
    }
}
int main(){
    ll sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    go(sx, sy, tx, ty);
    back(sx, sy, tx, ty);
  	cout << 'D';
    go(sx, sy-1, tx+1, ty);
  	cout << 'L';
  	cout << 'U';
    back(sx-1, sy, tx, ty+1);
  	cout << 'R';

    return 0;
 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<ll> Yes(100001,0);
	FOR(i,0,100001){
		ll x = i*8 + 1;
		ll p = sqrt(x);
		if(p*p==x){
			Yes[i]=(1+p)/2;
		}
	}
	ll N;
	cin >> N;
	if(Yes[N]==0){
		cout << "No" << endl;
		return 0;
	}
	ll K = Yes[N];
	// tyouten -> K
	// hen -> N
	bool same[K+1][K+1]={false};
	vector< vector<ll> > Si;
	Si.resize(K+1);
	ll num=1;
	FOR(i,1,K+1){
		FOR(j,1,K+1){
			if(j==i)continue;
			if(not same[i][j]){
				same[i][j] = same[j][i] = true;
				Si[i].push_back(num);
				Si[j].push_back(num);
				num++;
			}
		}
	}
	cout << "Yes" << endl;
	cout << K << endl;
	FOR(i,1,K+1){
		cout << Si[i].size() << " ";
		FOR(j,0,Si[i].size()){
			cout << Si[i][j] << " ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <set>
#define ll long long

using namespace std;

long long MOD = 1000000007;

template<typename T>
void cout_vec(vector<T> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int ntx=1;

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

    vector<vector<int>> paths(N,vector<int>(0));
    vector<vector<int>> child(1000001,vector<int>(26,0));
    vector<string> in(N);
    vector<int> is_end(1000001,0);

    for(int i=0; i<N; i++){
        string &s=in[i];
        cin >> s;
        reverse(s.begin(),s.end());

        int node=0;
        paths[i].push_back(node);
        for(auto &ch:s){
            if(child[node][ch-'a']==0){
                child[node][ch-'a']=ntx;
                ntx++;
            }
            node=child[node][ch-'a'];
            paths[i].push_back(node);
        }
        is_end[node]=1;
    }

    ll ans=0;
    for(int i=0; i<N; i++){
        string s=in[i];
        set<char> suffix;

        for(int j=(int)s.size()-1; j>=0; --j){
            int node=paths[i][j];
            suffix.insert(s[j]);

            for(auto &ch:suffix){
                ans+=(ll)is_end[child[node][ch-'a']];
            }
        }
    }

    cout << ans-N << endl;
}

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)

using ll = long long;
using P = std::tuple<int,int>;

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

int N, M;
vector<P> G[1010];
ll d[1010];

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int a, b, c;
        std::cin >> a >> b >> c;

        G[a].emplace_back(b, c);
    }

    fill(d, d+1010, 1001001001001001001ll);
    d[1] = 0;

    bool infinityFlag = false;
    for(int i=1;i<=N*3;++i){
        bool flag = false;

        for(int v=1;v<=N;++v){
            for(auto& e : G[v]){
                int w, c;
                tie(w, c) = e;
                
                if(d[w] > d[v] - c){
                    d[w] = d[v] - c;
                    if(w == N){flag = true;}
                }
            }
        }

        if(i > N && flag){infinityFlag = true;}
    }

    if(infinityFlag){
        std::cout << "inf" << std::endl;
    }else{
        std::cout << -d[N] << std::endl;
    }
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


//auto mod int
//https://github.com/atcoder-live/library/blob/master/mint.cpp

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


int main() {
    int n, m;
    cin >> n >> m;
    map<int, bool> a;
    rep(i, m) {
        int a_;
        cin >> a_;
        a[a_] = true;
    }
    
    vector<mint> dp(n+1);
    dp[0] = 1;
    rep(i, n) {
        if(!a[i+1]) {
            dp[i+1] += dp[i];
        }
        if(i != n-1 && !a[i+2]) {
            dp[i+2] += dp[i];
        }
    }

    cout << dp[n] << endl;
}

Measured memory_bytes: 8740
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using INT=mp::cpp_int;
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
INT LCM(INT x,INT y){
  INT z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
INT modinv(INT a, INT m) {
    INT b = m, u = 1, v = 0;
    while (b) {
        INT t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main() {
  cout << fixed << setprecision(30);
  ll n;
  cin>>n;
  vec a(n);
  loop(i,n)cin>>a[i];
  bool check=true;
  loop(i,n)if(a[i]%2==0&&a[i]%3!=0&&a[i]%5!=0)check=false;
  if(check)putout("APPROVED");
  else putout("DENIED");
}

Measured memory_bytes: 256
l = list (map (int, input().strip().split()))
x = l[0]
n = l[1]
if (n==0):
    print(x)
else:
    l2 = list (map (int, input().strip().split()))
    d = 0
    while True:
        if (x-d) not in l2:
            print(x-d)
            break 
        elif (x+d) not in l2:
            print(x+d)
            break
        d+=1

Measured memory_bytes: 9080
#include <stdio.h>
#include <stdlib.h>
int a[100000];

int
main(void)
{
    long n, x;
    long sum = 0;
    scanf("%ld%ld", &n, &x);
    int i;
    for (i = 0; i < n; ++i)
        scanf("%d", &a[i]);

    for (i = 0; i < n; ++i) {
        long dim;
        dim = 0;
        if (i == 0) {
            if (a[0] > x)
                dim = a[0] - x;
        } else {
            if (a[i] + a[i-1] > x)
                dim = a[i] + a[i-1] - x;
        }
        a[i] -= dim;
        sum += dim;
    }
    printf("%ld\n", sum);
    return 0;
}



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

 

int main()
{
    int a ,b, temp, i;
    for(i=1; i<=3000; i++)
    {
        cin >> a >> b;
        if(a==0 && b==0)
            break;
            
        if(a > b)
        {
            temp = a;
            a = b;
            b = temp;
        }
        cout << a << " " << b << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
	int n;
	int q;
	int query;
	int t;
	int x;

	cin >> n >> q;

	vector <int> A[n];


	for (int i = 0; i < q; i++) {
		cin >> query;
		cin >> t;

		if (query == 0) {
			cin >> x;
			A[t].push_back(x);
		}
		else if (query == 1) {
			for (int j = 0; j < A[t].size(); j++) {
				if (j == 0)
					cout << A[t][j];
				else
					cout << " " << A[t][j];
			}

			cout << endl;		
		}
		else {
			A[t].clear();		
		}
	
	}



}




Measured memory_bytes: 5784
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD ((int)1e9 + 7)
#define atoi(x) ((x)-'0')
#define int ll
#define double long double
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

const int MAX = 1e5;
int n, idx, x, m, sum, dp_sum[MAX], dp_idx[MAX];

signed main() {
	ini(dp_sum, -1);
	ini(dp_idx, -1);
	cin >> n >> x >> m;
	for (int i = 0; n > 0; i++) {
		if (dp_sum[x] != -1) {
			sum += n / (i - dp_idx[x]) * (sum + x - dp_sum[x]);
			n %= (i - dp_idx[x]);
			while (n > 0) {
				
				sum += x;
				x = x * x % m;
				n--;
			}
			cout << sum;
			return 0;
		}
		sum += x;
		dp_sum[x] = sum;
		dp_idx[x] = i;
		x = x * x % m;
		n--;
	}
	cout << sum;
}

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

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

using namespace std;

int d,c[26],a[365][26];

int main(){
	scanf("%d",&d);
	rep(j,26) scanf("%d",&c[j]);
	rep(i,d) rep(j,26) scanf("%d",&a[i][j]);

	int score=0;
	vector res(d,0),last(26,0);
	rep(i,d){
		int j_max=0;
		for(int j=1;j<26;j++) if(a[i][j_max]<a[i][j]) j_max=j;
		res[i]=j_max;
		score+=a[i][res[i]];
		last[res[i]]=i+1;
		rep(j,26) score-=c[j]*(i+1-last[j]);
		printf("%d\n",res[i]+1);
	}

	return 0;
}


Measured memory_bytes: 3824
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

ll N,M;
vector<ll> a,b;
bool check(ll x){

	ll c=0;
	for(ll i=0;i<N;i++){
		ll j=lower_bound(a.begin(),a.end(),x-a[i])-a.begin();

		c+=N-j;

	}

	if(c>=M) return true;
	else return false;

}

int main(void){
	          ll i;

	          cin.tie(0);  ios_base::sync_with_stdio(false);


	          cin >> N >> M;
	          for(i=0;i<N;i++){
	        	  ll x;
	        	  cin >> x;
	        	  a.push_back(x);
	          }

	          sort(a.begin(),a.end());
	          b=a;
	          for(i=N-2;i>=0;i--) b[i]+=b[i+1];

	          ll L=2*a[0],R=2*a[N-1];
	          while(R-L>1LL){
	        	  ll m=(L+R)/2;
	        	  if(check(m)) L=m;
	        	  else R=m;
	          }

	      	ll ans=0,c=0;
	      	for(i=N-1;i>=0;i--){
	      	ll j=lower_bound(a.begin(),a.end(),L-a[i])-a.begin();

	      	if(j!=N){
	      		ans+=b[j]+(N-j)*a[i];
	      		c+=N-j;
	      	}

	      	}

	      	ans-=L*(c-M);
	      	cout << ans << endl;

	          return 0;
}


Measured memory_bytes: 1908
import math
import sys
n = int(input())
t = [int(input()) for _ in range(n)]
if n == 1:
  print(t[0])
  sys.exit()
elif n == 2:
  print((t[0]*t[1])//(math.gcd(t[0],t[1])))
  sys.exit()
t.sort()
ans = (t[0]*t[1])//math.gcd(t[0],t[1])
for i in range(2,n-1):
    #print((ans*t[i])//math.gcd(ans,t[i]))
    ans =((t[i]*ans)//math.gcd(t[i],ans))
print((ans*t[-1])//math.gcd(ans,t[-1]))


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

int main()
{
    int N;
  	cin>>N;
  
   string ans = "No";
   while(N > 0){
   	int digit = N%10;
     if(digit == 7)
      ans = "Yes";
     N = N/10;
   }
  
   cout<<ans<<endl;
  
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int r;
	cin >> r;

	if(r < 1200){
		cout << "ABC" << endl;
	}else if(r < 2800){
		cout << "ARC" << endl;
	}else{
		cout << "AGC" << endl;
	}
}

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

int main(){
  int N,M,X,under=0,upper=0;;
  cin >> N >> M >> X;
  rep(i,M){
    int a;
    cin >> a;
    if(a<X){
      ++under;
    }else{
      ++upper;
    }
  }
  cout << min(under,upper) << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a==b && (c!=a && c!=b))
		puts("Yes");
	else if(a==c && (b!=a && b!=c))
		puts("Yes");
	else if(b==c && (a!=b && a!=c))
		puts("Yes");
	else	puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, w;
  cin >> h >> w;
  vector<string> data(h);
  rep(i, h) cin >> data[i];
  vector<ll> r(h, 0), c(w, 0);
  rep(i, h) {
    rep(j, w) {
      if (data[i][j] == '#') {
        r[i]++;
        c[j]++;
      }
    }
  }
  rep(i, h) {
    if (r[i] == 0) continue;
    rep(j, w) {
      if (c[j]) cout << data[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%lld",&x);
vector<ll> divisor(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n / i) res.push_back(n/i);
        }
    }
    return res;
}
int main(){
    ll n, m, ans = 1;
    sc(n) sc(m)
    vector<ll> div = divisor(m);
    for (const auto &x : div){
        if (m / x < n) continue;
        ans = max(ans, x);
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  int n,k;
  cin >> n >> k;
  if(k>(n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  k=(n-1)*(n-2)/2-k;
  cout << n-1+k << endl;
  for(int i=2;i<=n;i++){
    cout << 1 SP i << endl;
  }
  vector<pair<int,int>> p;
  for(int i=2;i<=n;i++){
    for(int j=i+1;j<=n;j++){
      p.push_back({i,j});
    }
  }
  for(int i=0;i<k;i++){
    cout << p[i].first SP p[i].second << endl;
  }
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while(sc.hasNext()){
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();
			if(n*a<b){
				System.out.println(n * a);
			}else{
				System.out.println(b);
			}
		}
	}
}

Measured memory_bytes: 20820
#include <bits/stdc++.h>
#include <atcoder/all>
#define F first
#define S second
using namespace std;
using namespace atcoder;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;

ll op(ll a,ll b) {
  return max(a,b);
}

ll e() {
  return 1LL;
}

ll mapping(ll a,ll b) {
  return max(a,b);
}

ll composition(ll a,ll b) {
  return max(a,b);
}

ll id() {
  return 1LL;
} 

int main() {
  ll N,K;
  cin >> N >> K;
  ll A[N];
  ll DP[N];
  for (int i = 0; i < N; i++) {
    DP[i] = 1;
  }
  vector<ll> S(300001);
  for (int i = 0; i <= 300000; i++) {
    S[i] = 1;
  }
  lazy_segtree<ll,op,e,ll,mapping,composition,id> seg(S);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < N; i++) {
    ll w = seg.get(A[i]);
    DP[i] = w;
    seg.apply(max(A[i]-K,0LL) , min(A[i]+K+1,300001LL) , w + 1);
  }
  ll ans = 1;
  for (int i = 0; i < N; i++) {
    ans = max(DP[i],ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 22568
n = gets.to_i - 1
h = gets.split.map(&:to_i)

=begin

i+1, i+2 なので、一つ前と２つ前のコストだけを覚えていればおｋ
フィボナッチ数列のDPと同じ形

c1: 一つ前
c2: ２つ前

=end


c1, c2 = (h[0] - h[1]).abs, 0
2.upto(n) do |i|
	c = [
		c1 + (h[i-1] - h[i]).abs,
		c2 + (h[i-2] - h[i]).abs
	].min
	c2, c1 = c1, c
end

p c1

Measured memory_bytes: 10628
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int n;
	scanf("%d", &n);
	vector<pii> v(n);
	for(int i = 0; i < n; ++i){
		scanf("%d%d", &v[i].second, &v[i].first);
	}
	sort(ALL(v));
	int s = 0;
	for(cauto p : v){
		s += p.second;
		if(s > p.first){
			puts("No");
			return;
		}
	}
	puts("Yes");
}



}
int main() try{
//	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){
	throw;
}


Measured memory_bytes: 1792