akhauriyash/Code-Regression huggingface dataset:
import io.StdIn._

object Main extends App {
  val Seq(a, b, k) = readLine().split(" ").map(_.toInt).toSeq

  require(1 <= a && a <= 100)
  require(1 <= b && b <= 100)
  require(k >= 1)

  println((1 to 100).filter(i => (a % i == 0 && b % i == 0)).reverse.take(k).last)
}


Measured memory_bytes: 54912
def main
  while (n = gets.to_i) != 0
    table = Array.new(n + 1)
    table[n] = Array.new(n + 1, 0)
    n.times do |i|
      table[i] = gets.split(" ").map(&:to_i)
      table[i] << table[i][0..-1].inject{|sum, item|sum + item}
      table[i].each_with_index{|item, idx|table[n][idx] += item}
    end
    puts table.collect{|item|express(item)}
  end      
end
def express(line)
  line.map{|item|sprintf("%#5d", item)}.join("")
end
main

Measured memory_bytes: 6132
#include <stdio.h>
        #include <math.h>
         
        int main(void){
        	int n;
        	scanf("%d",&n);
        	double c[n];
        	scanf("%lf",&c[0]);
        	double sum = 0;
        	for (int i = 1 ; i<n ; i++){
        		scanf("%lf",&c[i]);
        		sum += c[i];
        	}
        	double sa = sum - c[0];
        	double min = fabs(sa);
        	 for (int i = 1; i< n-1;i++){
        	 	sa -= c[i]*2;
        	 	if (min > fabs(sa)){
        	 		min = fabs(sa);
        	 	}
        	 }
        	 printf("%.0lf\n",min);
        	return (0);
        }

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

#define int long long

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

/*
#define cin ifs
#define cout ofs
ifstream ifs("in.txt");
ofstream ofs("out.txt");
//*/

int M, S, T;
vector<int> ns;
int mod = 1e9 + 7;
//ダイクストラ法を用いて単一始点最短路問題を解く
const int MAX_V = 100000;
const int INF = 1e12;

struct edge {
    int to, cost;
};
typedef pair<int, int> P;

int V;
vector<edge> G[MAX_V];
int d1[MAX_V], n1[MAX_V];
int d2[MAX_V], n2[MAX_V];

void dijkstra(int s, int d[MAX_V], int n[MAX_V]) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    n[s] = 1;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        for (int i = 0; i < G[v].size(); i++) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                n[e.to] = n[v];
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            } else if (d[e.to] == d[v] + e.cost) {
                n[e.to] += n[v];
                n[e.to] %= mod;
            }
        }
    }
}

signed main() {
    cin >> V >> M >> S >> T;
    S--;
    T--;
    for (int i = 0; i < M; i++) {
        int U, V, D;
        cin >> U >> V >> D;
        G[U - 1].push_back({V - 1, D});
        G[V - 1].push_back({U - 1, D});
    }
    dijkstra(S, d1, n1);
    dijkstra(T, d2, n2);
    for (int i = 0; i < V; i++) {
        if (d1[i] * 2 == d1[T]) {
            ns.push_back(n1[i] * n2[i] % mod);
        } else if (d1[i] * 2 < d1[T]) {
            for (int j = 0; j < G[i].size(); j++) {
                edge e = G[i][j];
                if (d1[i] + d2[e.to] + e.cost == d1[T] &&
                    d1[e.to] * 2 > d1[T]) {
                    ns.push_back(n1[i] * n2[e.to] % mod);
                }
            }
        }
    }
    int ans = 0, sum = 0;
    for (int i = 0; i < ns.size(); i++) {
        sum += ns[i];
        sum %= mod;
    }
    for (int i = 0; i < ns.size(); i++) {
        ans += ((ns[i] % mod) * ((sum + mod - ns[i]) % mod)) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 18772
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>
#include <iterator>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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

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

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll a, b, m, n, x = 1, y=1;
    cin >> m >> n;

    if (n >= 1000) {
        rep(i, 1000) {
            y = y * m % 1000000007;
        }
        a = n / 1000;
        b = n % 1000;
        rep(i, a) {
            x = x * y % 1000000007;
        }
        rep(i, b) {
            x = x * m % 1000000007;
        }
    }
    else {
        rep(i, n) {
            x = x * m % 1000000007;
        }
    }

    cout << x << endl;

}


Measured memory_bytes: 3168
#include <iostream>
#include <cstdio>
#include <iterator>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

using namespace std;

int N, A[3][3], b[10];
bool appear[3][3];

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

  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
        cin >> A[i][j];
        }
    }
cin >> N;
for(int i = 0; i < N; i++){
    cin >> b[i];
}
for(int i = 0; i < N; i++) {
    for(int j = 0; j < N; j++) { 
        appear[i][j] = false;
        for(int k = 0; k < N; k++) {
        if(A[i][j] == b[k]) appear[i][j] = true; 
            }
        } 
    }
string ANS = "No";
for(int i = 0; i < 3; i++) {
    if(appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes"; 
}
for(int i = 0; i < 3; i++) {
    if(appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
}
if(appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes"; 
if(appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes"; 
cout << ANS << endl;
return 0;
  

}


Measured memory_bytes: 256
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    print('Hello World' if ni() == 1 else ni() + ni())


if __name__ == '__main__':
    main()


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

char str[300005];

int main(){
    int n;
    scanf("%d",&n);
    scanf("%s", str);
    int now = 0, ans = 0;
    for(int i=1;i<n;i++){
        if(str[i] == 'E') now++;
    }
    ans = now;
    for(int i=1;i<n;i++){
        if(str[i] == 'E') now--;
        if(str[i-1] == 'W') now++;
        ans = min(ans, now);
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 512
package main

import (
    "bufio"
    "fmt"
    "math"
    "os"
    "strconv"
)

func main() {

    N := nextInt()
    K := nextInt()

    H := make([]int, N)
    dp := make([]int, N)

    for i := 0; i < N; i++ {
        H[i] = nextInt()
        dp[i] = math.MaxInt32
    }
    dp[0] = 0
    for i := 1; i < N; i++ {
        for k := 1; k <= K; k++ {
            if i-k < 0 {
                continue
            }
            h := abs(H[i] - H[i-k])
            dp[i] = min(dp[i], dp[i-k]+h)
        }
    }
    fmt.Println(dp[N-1])
}

func min(a, b int) int {
    if a < b {
        return a
    }
    return b
}

func abs(a int) int {
    if a > 0 {
        return a
    }
    return -a
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
    bufsize := 1 * 1024 * 1024 // 1 MB
    var stdin = bufio.NewScanner(os.Stdin)
    stdin.Buffer(make([]byte, bufsize), bufsize)
    stdin.Split(bufio.ScanWords)
    return stdin
}

func nextString() string {
    stdin.Scan()
    return stdin.Text()
}

func nextBytes() []byte {
    stdin.Scan()
    return stdin.Bytes()
}

func nextInt() int {
    i, _ := strconv.Atoi(nextString())
    return i
}

func nextInt64() int64 {
    i, _ := strconv.ParseInt(nextString(), 10, 64)
    return i
}


Measured memory_bytes: 3328
while (n = gets.to_i) != 0 do
	t = {}
	n.times do
		k, v = gets.split
		t[k] = v
	end

	r = ""

	m = gets.to_i
	m.times do
		s = gets.chomp
		if t.has_key?(s) then
			r << t[s]
		else
			r << s
		end
	end

	puts r
end

Measured memory_bytes: 6212
#include <stdio.h>

int main(void){
        int i, j, n, m;
        scanf("%d %d", &n, &m);
        int a[n][m], b[m], c[n];
        for(i=0;i<n;i++){
                c[i]=0;
                for(j=0;j<m;j++){
                        scanf("%d", &a[i][j]);
                }
        }
        for(j=0;j<m;j++){
                scanf("%d", &b[j]);
        }
        for(i=0;i<n;i++){
                for(j=0;j<m;j++){
                        c[i]+=(a[i][j]*b[j]);
                }
        }
        for(i=0;i<n;i++)
                printf("%d\n", c[i]);
        return 0;
}



Measured memory_bytes: 2108
let id x = x

let s = 1000000007
let inv2 = 500000004

let repeat f =
  let rec aux accu = function
    | 0 -> accu
    | n -> aux (f () :: accu) (n - 1) in
  aux []

let pow k =
  let rec aux accu k = function
  | 0 -> accu
  | n when n mod 2 == 0 -> aux accu (k*k mod s) (n/2)
  | n -> aux (accu*k mod s) (k*k mod s) (n/2) in
  aux 1 k

let inv k = pow k (s-2)

let () =
  let n = Scanf.scanf "%d\n" id in
  let l = repeat (fun () -> Scanf.scanf "%d %d\n" (fun a b -> (a,b))) n in
  let (maxa, maxb) = List.fold_left (fun (c,d) (a,b) -> (max a c, max d b)) (0, 0) l in
  let factbl = Array.make (2*maxa+2*maxb+1) 1 in
    for i = 1 to 2*maxa+2*maxb do factbl.(i) <- factbl.(i-1)*i mod s done;
  let ifactbl = Array.make (2*maxa+2*maxb+1) 0 in
    ifactbl.(2*maxa+2*maxb) <- inv factbl.(2*maxa+2*maxb);
    for i = 2*maxa+2*maxb-1 downto 0 do ifactbl.(i) <- ifactbl.(i+1)*(i+1) mod s done;
  let bc n k = ((factbl.(n)*ifactbl.(k) mod s) * ifactbl.(n-k)) in
  let sal = List.sort (fun (a,b) (c,d) -> compare c a) l in
  let dp = Array.make (1 + 2 * maxb) 0 in
  let update () = for i = 1 to 2 * maxb do Array.unsafe_set dp i ((Array.unsafe_get dp i + Array.unsafe_get dp (i-1)) mod s) done in
  let solve =
    let rec auxr sl accu m =
      match sl with
      | [] -> accu
      | (a, b) :: tl when a = m-maxa -> auxr tl ((accu+dp.(b+maxb)) mod s) m
      | _ -> update (); auxr sl accu (m+1) in
    let rec auxl sl m =
      if m > maxa then (update (); auxr (List.rev sal) 0 m)
        else match sl with
             | (a, b) :: tl when a = maxa-m -> dp.(maxb-b) <- (dp.(maxb-b) +1) mod s; auxl tl m
             | _ -> update (); auxl sl (m+1) in
    auxl sal 0 in
  let x = List.fold_left (fun x (a,b) -> (x + bc (2*a+2*b) (2*a)) mod s) 0 l in
    if solve < x then print_int ((s+solve - x)*inv2 mod s) else print_int ((solve-x)* inv2 mod s)

Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W, N;
    cin >> H >> W >> N;
    int ans = 0;
    ans = N / max(H, W);
    if (ans * max(H, W) < N)
        ans++;
    cout << ans << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int lim = 1e5+7;


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

	int cnt5 = 0, cnt7 = 0;
	for(int i=0; i<3; i++){
		int a;
		cin >> a;
		if(a==5) cnt5++;
		if(a==7) cnt7++;
	}
	if(cnt5==2 && cnt7==1){
		cout << "YES\n";
	}
	else cout << "NO\n";
	return 0;
}

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

int main() {
  int a[7] = {1, 3, 5, 7, 8, 10, 12}, b[4] = {4, 6, 9, 11}, c=2;
  int x, y; cin >> x >> y;
  char x_res, y_res;
  for(int i = 0; i < 7; i++) {
    if(a[i] == x) x_res = 'a';
    if(a[i] == y) y_res = 'a';
  }
  for(int i = 0; i < 4; i++) {
    if(b[i] == x) x_res = 'b';
    if(b[i] == y) y_res = 'b';
  }
  if(x == c) x_res = 'c';
  if(y == c) y_res = 'c';
  if(x_res == y_res) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<int>st;
int num_of_pf(int n)
{
    int cnt = 0;
    for (int i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            cnt++;
            while(n % i == 0)
                n /= i;
            st.insert(i);
        }
    }
    if (n > 1)
        st.insert(n), cnt++;
    return cnt;
}

int v[1000005];
int main()
{
    int s_c;
    int n;
    cin >> n;
    int cnt = 0;
    set<int> s;
    for(int i=1;i<=n;i++)
    {
        cin >> v[i];
        if (i == 1)
            s_c = v[i];
        s_c = __gcd(s_c, v[i]);
    }
    if (s_c != 1)
    {
        cout << "not coprime" << endl;
        return 0;
    }
    int p_c = 1;
    for(int i=1;i<=n;i++)
    {
        cnt += num_of_pf(v[i]);
        if (cnt !=st.size())
        {
            p_c = 0;
            break;
        }
    }
    if (p_c)
        cout << "pairwise coprime" << endl;
    else
        cout << "setwise coprime" << endl;

}


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

int main()
{
	char a[2][3];
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			cin >> a[i][j];
		}
	}
	if ((a[0][0] == a[1][2]) && (a[0][1] == a[1][1]) && (a[0][2] == a[1][0]))
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}
	return 0;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int N, A, B, C;
int D[102];
int main() {
    cin >> N >> A >> B >> C;
    rep(i, N) cin >> D[i];
    sort(D, D + N);
    reverse(D, D + N);

    int ans = 0;
    int cost = A;
    int cal = C;

    ans = int(1.0 * cal / cost);
    rep(i, N) {
        cal += D[i];
        cost += B;
        // cout <<cal <<", " << cost << endl;
        ans = max(ans, int(1.0 * cal / cost));
    }

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

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
  int d,g,i,j,y,z,ans=1000;
  cin>>d>>g;
  vector<int> p(d),c(d);
  for(i=0;i<d;i++) cin>>p.at(i)>>c.at(i);
  for(i=0;i<(1<<d);i++){
    bitset<10> b(i);
    y=0;z=0;
    for(j=0;j<d;j++){
      if(b.test(j)){
        y+=p.at(j);
        z+=100*(j+1)*p.at(j)+c.at(j);
      }
    }
    for(j=d-1;j>=0;j--){
      if(g<=z) break;
      else if(!b.test(j)){
        if(g-z>100*(j+1)*(p.at(j)-1)){
          y+=p.at(j)-1;
          z+=100*(j+1)*(p.at(j)-1);
        }
        else{
          y+=(g-z)/(100*(j+1));
          if((g-z)%(100*(j+1))>0) y++;
          z=g;
        }
      }
    }
    if(g<=z&&y<ans) ans=y;
  }
  cout<<ans<<endl;
}

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

int n, x, y, t;
int px = 0, py = 0, pt = 0;
string res = "Yes";

int main(){
  cin >> n;
  rep(i, n){
    cin >> t >> x >> y;
    int dx = abs( x - px );
    int dy = abs( y - py );
    int dt = t - pt;
    int sum = dx + dy;
    if( sum > dt ){
      res = "No";
      break;
    }
    //cout << sum <<" "<< dt << endl;
    if( abs(sum - dt) % 2 == 1 ){
      res = "No";
      break;
    }
    px = x; py = y; pt = t;
  }
  //奇数偶数
  //ti - ti-1 が 総移動量🦑
  
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
/*
 * author : anaksoleh
 * 16 september 2019
 */

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

char S[110];

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

	for(int i = 0 ; i < s.length() ; i++){
		S[i+1] = s[i];
	}

	bool ok = true;
	for(int i = 1 ; i <= s.length() ; i++){
		if((i % 2 ) == 0){
			if(S[i] == 'L' || S[i] == 'U' || S[i] == 'D'){
				continue;
			}else{
				ok = false;
				break;
			}
		}else{
			if(S[i] == 'R' || S[i] == 'U' || S[i] == 'D'){
				continue;
			}else{
				ok = false;
				break;
			}
		}
	}

	if(ok){
		cout << "Yes" << '\n';
	}else cout << "No" << '\n';

	return 0;
}

Measured memory_bytes: 256
#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);
}



using Graph = vector<vector<int>>;


int main() {
	ll N,K,M;
	cin >> N >> K;
	rep(i, N) {
		
		cin >> M;
		
	}
	cout <<1+ (N - 2) / (K - 1) << endl;
	}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};
pair<ll,ll> p[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>m;
    rep(i,n){
        cin>>a>>b;
        p[i]=m_p(a,b);
    }
    sort(p,p+n);
    ll now=0;
    rep(i,n){
        if(now==m)break;
        if(now+p[i].se>=m){
            ll sa=m-now;
            now+=sa;
            ans+=sa*p[i].fi;
            break;
        }
        now+=p[i].se;
        ans+=p[i].fi*p[i].se;
        //Cout(ans);
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		String a=sc.next();
		char ch[]=a.toCharArray();
		int c=0;
		for(int i=0;i<3;i++){
			if(ch[i]==ch[i+1]){
				c++;
				break;
			}
		}
			if(c>0)
				System.out.println("Bad");
			else System.out.println("Good");
	}
}

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

const int MOD = (int)1e9 + 7;

int main() {
  int n;
  cin >> n;
  map<int, int> m;
  for (int i = 1; i <= n; i++) {
    int x = i;
    for (int j = 2; j * j <= x; j++)
      while (x % j == 0) {
        m[j]++;
        x /= j;
      }
    if (x > 1) m[x]++;
  }
  ll ans = 1;
  for (auto it : m) ans = (ans * (it.second + 1)) % MOD;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);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;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    string s; cin >> s;
    int n = s.size();
    string t = s.substr(0,(n-1)/2), u = s.substr((n+3)/2-1);
    bool ok = true;
    
    auto func = [&](string a) -> void {
        int len = a.size();
        rep(i,len) {
            if (a[i]!=a[len-1-i]) ok = false;
        }
    };
    func(s);
    func(t);
    func(u);
    // cout << s << endl;
    // cout << t << endl;
    // cout << u << endl;

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#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 <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

ll prime[1000000];
bool is_prime[1000001];

ll sieve(ll n){
	int p = 0;
	for(int i=0;i<=n;i++)is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
		}
	}
	return p;
}



int main() {
    ll N, P;
    cin>>N>>P;

    ll cnt = sieve(1000000);

    if(N==1){
        cout<<P<<endl;
    }else{
        ll ans = 1;
        for (int i = 0; i < cnt; i++) {
            ll t = P, tc = 0;
            while(t!=0&&t%prime[i]==0){
                tc++;
                t/=prime[i];
            }
            if(tc>=N){
                ll x = 1;
                for (int j = 0; j < (tc/N); j++) {
                    x*=prime[i];
                }
                ans*=x;
            }
        }
        cout<<ans<<endl;
    }

    return 0;
}

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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
const int MAX_N=200005;
/**
        http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_2_A&lang=jp
 \                                                                                       **/
struct UFF{
    int par[MAX_N];
    int ran[MAX_N];
    void init(int n){
        rep(i,0,n){
            par[i] = i;
            ran[i] = 0;
        }
    }
    int _find(int x){
        if(par[x] == x){
            return x;
        } else {
            return par[x] = _find(par[x]);
        }
    }
    void unite(int x,int y){
        x = _find(x);
        y = _find(y);
        if(x==y)return;

        if(ran[x] < ran[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if(ran[x] == ran[y]){
                ran[x]++;
            }
        }
    }
    bool same(int x,int y){
        return _find(x) == _find(y);
    }
};\
UFF uf,uuf;
map<pii,int> ans;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k,l;///dot and branch
    cin >> n >> k >> l;
    uf.init(n+1);
    uuf.init(n+1);
    rep(i,0,k){
        int a,b;
        cin >>a >>b;
        uf.unite(a,b);
    }
    rep(i,0,l){
        int a,b;
        cin >> a >> b;
        uuf.unite(a,b);
    }
    rep(i,1,n+1){
        ans[mp(uf._find(i),uuf._find(i))]++;
    }
    rep(i,1,n+1){
        cout << ans[mp(uf._find(i),uuf._find(i))];
        if(i==(n))cout << endl;
        else cout << " ";
    }
    return 0;
}




Measured memory_bytes: 18176
m,n,x=[int(i) for i in input().split()]
k,l,y=[int(i) for i in input().split()]

res=0.5*(1.0+((m**2+n**2)**x)/((m+n)**(2*x)))
res*=0.5*(1.0+((k**2+l**2)**y)/((k+l)**(2*y)))
print(res)




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

int main() {
  int n,m;
  cin >> n >> m;
  int hint[n];
  vector<int> arc[n];

  for(int i=0;i<n;i++)hint[i]=-1;

  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    arc[a].push_back(b);
    arc[b].push_back(a);
  }

  queue<int> room;
  room.push(0);
  while(!room.empty()){
    int r = room.front();room.pop();
    for(int i=0;i<arc[r].size();i++){
      int to = arc[r][i];
      if(hint[to]==-1){
        hint[to]=r;
        room.push(to);
      }
    }
  }

  cout << "Yes" << endl;
  for(int i=1;i<n;i++){
    cout << hint[i]+1 << endl;
  }
}


Measured memory_bytes: 10412
use std::io;


/// https://beta.atcoder.jp/contests/abc088/tasks/abc088_b
fn main() {
    let _n = read_one::<usize>();
    let mut an = read::<isize>();
    an.sort();
    an.reverse();
    let mut alice = 0;
    let mut bob = 0;
    for i in 0..an.len() {
        if i % 2 == 0 { alice += an[i]; }
        else { bob += an[i]; }
    }
    println!("{}", alice - bob);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;

int N, M;
vector<VI> G;
bool vis[100010];
struct edge{
	int to, res;
};

edge dp[100010][2];

int dfs(int now, int pa) {

	if (dp[now][0].res != 0)return dp[now][0].res;

	VP tmp;
	fore(to, G[now]) {
		if (pa == to)continue;
		int ret = dfs(to, now);
		tmp.push_back(pii(1 + ret, to));
		//cout << now << " " << to << " " << ret << endl;
		//vis[to] = 1;
	}
	if (tmp.empty())return 0;
	rSORT(tmp);
	dp[now][0].res = tmp[0].first;
	dp[now][0].to = tmp[0].second;
	if (tmp.size() > 1) {
		dp[now][1].res = tmp[1].first;
		dp[now][1].to = tmp[1].second;
	}

	return dp[now][0].res;


}

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

	cin >> N >> M;
	G.resize(N);
	vector<bool>F(N, false);
	//入次数が0の頂点集合
	REP(i, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		F[b] = 1;
	}

	REP(i, N) {
		if (!F[i]) dfs(i, -1);
	}
	int ans = 0;
	REP(i, N) {
		//cout << dp[i][0].res << " " << dp[i][0].to << endl;
		chmax(ans, dp[i][0].res);
	}
	cout << ans << endl;


	return 0;
}



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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, m, x, y, q, k;
string s, t, s0,s1,s2;



// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n>>y;
	vll a(n);
	k = y;
	for(ll i=0;i<n;i++) {
		cin>>a[i];
	}
	for(ll i=1;i<n;i++) k+=min(y,a[i]-a[i-1]);
	cout<<k;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 4696
#include <iostream>
#include <algorithm>
using namespace std;
    int ans[101],n;

int main(void){
    char s[101];
    cin>>n>>s;
    for(int i=1;i<=n;i++){
        if(s[i-1]=='I')ans[i]=ans[i-1]+1;
        else ans[i]=ans[i-1]-1;
    }
    sort(ans,ans+n+1,greater<int>());
    cout<<ans[0]<<endl;
    
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  rep2(i, a, b+1){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<set>
#include<algorithm>
#include<functional>
using namespace std;

int n,h,a,b,b_max,c=0;
int x[100005],y[100005];
bool j=false;
int main(){
	cin>>n>>h;
	for(int i=0;i<n;i++){
		cin>>x[i]>>y[i];
	}
	sort(x,x+n,greater<int>());
	sort(y,y+n,greater<int>());
	y[n]=0;

	for(int i=0;y[i]>x[0];i++){
		h-=y[i]; c++;
		if(h<=0){j=true; break;}
	}

	if(j==false){
		if(h%x[0]==0)
			c+=h/x[0];
		else
			c+=(h/x[0])+1;
	}

	cout<<c<<endl;

	return 0;
}

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

int main()
{
  int a,b;
  for(;cin>>a>>b,a;)
    {
      int c=b-a,x=0,y=0,z=0;
      for(;c!=0;)
	{
	  if(c>999)
	    c-=1000,x++;
	  else if(c>499)
	    c-=500,y++;
	  else
	    c-=100,z++;
	}
      cout<<z<<" "<<y<<" "<<x<<endl;
    }
}

Measured memory_bytes: 1160
use std::io;
use std::io::prelude::*;

fn run(args: &Vec<String>) -> u32 {
    let n: u32 = args[0].parse().unwrap();
    n * (n + 1) / 2
}

fn main() {
    let stdin = io::stdin();
    let args = stdin.lock().lines().map(|l| l.unwrap()).collect();
    let r = run(&args);
    println!("{}", r);
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(T x,T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> T modinv(T x,const T mod){return modpow(x,mod-2,mod);}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getdiff(const T &a,const T &b,T &c) {
  set_difference(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> T deg2rad(T deg) {return deg*2*M_PI/360;}
template<class T> T rad2deg(T rad) {return rad*360/(2*M_PI);}

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD=1e9+7;
const ll MAX=5e6;


int main() {
  int N,M;cin>>N>>M;
  map<int,vector<int>> mp;
  REP(i,N) {
    int A,B;cin>>A>>B;
    mp[A].push_back(B);
  }

  priority_queue<int> pool;
  ll ans = 0;
  FOR(i,1,M+1) {
    for (int b:mp[i]) pool.push(b);
    if (siz(pool)==0) continue;

    ans += pool.top();
    pool.pop();
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 10880
///                                   ahmocs
#include <bits/stdc++.h>
typedef long long ll;
#define ahmocs  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
const ll N=3e3+5;
long double arr[N],ans[N][N];
using namespace std;
int main()
{
    ahmocs
    int n; cin>>n;
    for (int i=1; i<=n; ++i) cin>>arr[i];
    for (int i=0; i<=n; ++i)
         for (int j=0; j<=n; ++j)
                ans[i][j]=0;
    ans[1][0]=1-arr[1]; ans[1][1]=arr[1];
    for(int i=2; i<=n; ++i)
    {
        for (int j=0; j<= i; ++j)
        {
            ans[i][j]=ans[i-1][j]*(1-arr[i]);
            if (j)
               ans[i][j]+=ans[i-1][j-1]*arr[i];
        }
    }
    long double sol=0;
    for (int i=(n+1)/2; i<= n; ++i)
        sol+=ans[n][i];
    cout<<fixed<<setprecision(12)<<sol;
    return 0;
}


Measured memory_bytes: 141184
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static int64_t A[100000];

int main(void) {
    size_t N;

    scanf("%zu\n", &N);
    for (size_t i = 0; i < N; i++) {
        scanf("%"PRId64, &(A[i]));
        if (i < N - 1) {
            scanf(" ");
        }
    }

    size_t numMinus = 0;
    size_t minIdx = 0;

    for (size_t i = 0; i < N; i++) {
        if (A[i] < 0) {
            numMinus++;
        }

        if (ABS(A[i]) < ABS(A[minIdx])) {
            minIdx = i;
        }
    }

    const bool isMinusNumEven = (numMinus % 2 == 0);

    int64_t sum = 0;

    for (size_t i = 0; i < N; i++) {
        if (!(!isMinusNumEven && i == minIdx)) {
            sum += ABS(A[i]);
        }
        else {
            sum -= ABS(A[i]);
        }
    }

    printf("%"PRId64, sum);

    return 0;
}


Measured memory_bytes: 896
#include "stdio.h"
#include "string.h"

int	main(void)
{
	int i,j;
	int n,m;
	char s[100] = {0};
	char p[100] = {0};
	char q[200] = {0};

	scanf("%s", s);
	scanf("%s", p);

	n = strlen(s);
	m = strlen(p);

	for(i = 0; i < n ; i++)
	{
		
		for(j = 0; j < m; j++)
		{
			if (i + j >= n)
			{
				q[j] = s[i + j - n];
			}else
			{
				q[j] = s[i+j];
			}
		}
		

		if (strcmp(p,q) == 0)
		{
			printf("Yes\n");
			break;
		}
		if (i == n-1)
		{
			printf("No\n");
		}
	}

	return 0;
}

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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    vector<int> dish(5);
    vector<int> dish10(5);
    vector<int> mod(5);

    for(int i=0;i<5;i++) {
        cin >> dish.at(i);
        mod.at(i) = dish.at(i) % 10;
        dish10.at(i) = dish.at(i) - mod.at(i);
        if(mod.at(i)!=0) dish10.at(i) += 10;
    }

    for(int i=0;i<5;i++) {
        if(mod.at(i)==0) mod.at(i) = 99;
    }
    sort(mod.begin(), mod.end());

    int ans=0;
    if(mod.at(0)==dish.at(0)%10) {
        ans = dish10.at(1)+dish10.at(2)+dish10.at(3)+dish10.at(4);
        ans += dish.at(0);
    }
    else if(mod.at(0)==dish.at(1)%10) {
        ans = dish10.at(0)+dish10.at(2)+dish10.at(3)+dish10.at(4);
        ans += dish.at(1);
    }
    else if(mod.at(0)==dish.at(2)%10) {
        ans = dish10.at(0)+dish10.at(1)+dish10.at(3)+dish10.at(4);
        ans += dish.at(2);
    }
    else if(mod.at(0)==dish.at(3)%10) {
        ans = dish10.at(0)+dish10.at(1)+dish10.at(2)+dish10.at(4);
        ans += dish.at(3);
    }
    else {
        ans = dish10.at(0)+dish10.at(1)+dish10.at(2)+dish10.at(3);
        ans += dish.at(4);
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(void){

    string S;
    cin >> S;

    bool yymm = false, mmyy = false;

    int upper = stoi(S.substr(0,2));
    int lower = stoi(S.substr(2,2));

    if(1 <= upper && upper <= 12 && 1 <= lower && lower <= 12){
        cout << "AMBIGUOUS" << endl;
    }else if(1 <= upper && upper <= 12 && (lower > 12 || lower == 0)){
        cout << "MMYY" << endl;
    }else if((upper > 12 || upper == 0) && 1 <= lower && lower <= 12){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

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



int main(){
    int x,n;
    cin >>x >> n;
    set<int> s;

    rep(i,0,n){
	int p;
	cin >> p;
	s.it(p);
    }

    int ans = inf;
    
    rep(i,-200,200){
	if(s.count(i) == 0){
	    if(abs(x-ans) > abs(x-i))ans = i;
	}
    }
    P(ans);
    return  0;
}


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

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

	int ans = 0;
	rep(i, 0, (n / 2) + 1) {
		int p = pow(2, i);
		if (p > n) break;
		ans = p;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int N;
    cin>>N;
    int a[3][101];
    for(int i=1;i<=2;i++){
        for(int j=1;j<=N;j++){
            cin>>a[i][j];
        }
    }

    int m=0,mt=0;
    for(int k=1;k<=N;k++){
        mt=0;
        for(int i=1;i<=N;i++){
            if(i<=k){mt+=a[1][i];}
            if(k<=i){mt+=a[2][i];}
        }
        m=max(m,mt);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < n - 1; ++i) {
    sum += a[i];
  }
  if (sum > a[n - 1]) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 256
import numpy as np
import math
N, D = map(int, input().split())
 
n = [list(map(int, input().split())) for i in range(N)]
n = np.array(n)
ans = 0
for j in range(n.shape[0]):
  for i in range(n.shape[0]):
    length = np.linalg.norm(n[i]-n[j])
    aaa = math.modf(length)[0]
    if aaa < 0.00001:
      ans +=1
ans = ans - n.shape[0]
ans = int(ans/2)
print(ans)

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



int main(){
  int n;
  cin>>n;
  string s;
  cin >> s;
  int sum[n]={};
  for(int i=1;i<n;i++){
    if(s[i]=='E')sum[0]++;
  }
  for(int i=1;i<n;i++){
    sum[i]=sum[i-1];
    if(s[i-1]=='W'){sum[i]++;}
    if(s[i]=='E'){sum[i]--;}
  }

  int ans=n;
  rep(i,n){
    ans=min(ans,sum[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int n;
  cin>>n;
  vector<P> A(n);
  for(int i=0;i<n;i++)cin>>A[i].first,A[i].second = -i;
  sort(A.begin(),A.end(),greater<P>());
  
  vector<ll>ans(n);
  ll idx=-A[0].second,h=A[0].first;
  for(int i=1;i<n;i++){
    int val=A[i].first;
    ans[idx]+=i*(h-val);
    idx=min(idx,-A[i].second);
    h = A[i].first;
  }
  
  ans[0]+=h*n;
  for(int i=0;i<n;i++) cout<<ans[i]<<endl;


  return 0;
}


Measured memory_bytes: 3456