akhauriyash/Code-Regression huggingface dataset:
from collections import deque, defaultdict as ddic
from itertools import combinations, permutations, product
from heapq import heappush, heappop, heapify
import sys
stdout = sys.stdout
rr = lambda: input().strip()
rri = lambda: int(rr())
rrm = lambda: list(map(int, rr().split()))

from itertools import groupby
def solve(L, R):
    if L == R: return 0
    L-=1;R-=1
    
    return P[R+1] - P[L+1]

N, Q = rrm()
S = rr()
queries = [rrm() for _ in range(Q)]
# preprocess
P = [0]
for i, c in enumerate(S):
    x = +(c == 'C' and i > 0 and S[i-1] == 'A')
    P.append(P[-1] + x)

#print(P)

for L, R in queries:
    print(solve(L, R))


Measured memory_bytes: 32632
from math import gcd

a, b, c, d = map(int, input().split())
cd = (c * d) // gcd(c, d)
aa = (a - 1) - (((a - 1) // c) + ((a - 1) // d) - ((a - 1) // cd))
bb = b - ((b // c) + (b // d) - (b // cd))
print(bb - aa)


Measured memory_bytes: 9052
import java.util.Scanner;

public class Main {

	public static void main(String args[]){
		
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			
			int h = Integer.parseInt(sc.next());
			int w = Integer.parseInt(sc.next());
			
			if(h == 0 && w == 0){
				break;
			}
			
			for(int i = 1; i<= h ;i++){
				
				for(int j = 1; j<=w; j++){
					
					String  frame= drawWindow(i,j,h,w);
					System.out.print(frame);
				}
				
				System.out.println("");
			}
			
			System.out.println("");
			
		}
		
		
		sc.close();
		
	}

	private static String drawWindow(int row, int column, int h, int w) {
		
		// first row and last row
		if(row == 1 || row == h){
			return "#";
		}
		
		if(column == 1 || column == w){
			return "#";
		}
		
		return ".";
	}

}


Measured memory_bytes: 33996
#include <bits/stdc++.h>
//#include <iostream>
//#include <string>
//#include <algorithm>
//#include <stdio>
using namespace std;
typedef long long ll;
const int maxn = (int)1e5 +10;

int arr[maxn];
int brr[maxn];

int main()
{
    int n;
    cin>>n;
    ll ans = 0;
    for(int i = 0; i <= n; i++)
    {
        cin>>arr[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin>>brr[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(brr[i]>arr[i])
        {
            ans+=arr[i];
            brr[i]-=arr[i];
            if(brr[i]>=arr[i+1])
            {
                ans += arr[i+1];
                arr[i+1] = 0;
            }
            else
            {
                ans += brr[i];
                arr[i+1] -= brr[i];
            }
        }
        else
        {
            ans += brr[i];
        }
    }
    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 1024
import sys
import heapq

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7
depth = [[] for _ in range(10 ** 5)]

def resolve():
    n = int(input())

    edge = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        edge[a - 1].append([c, b - 1])
        edge[b - 1].append([c, a - 1])

    q, k = map(int, input().split())
    Query = [list(map(int, input().split())) for _ in range(q)]

    def dfs(v, p, d):
        depth[v] = d
        for c, u in edge[v]:
            if u == p:
                continue
            dfs(u, v, d + c)

    # 各頂点からkまでの最短距離を計算
    dfs(k - 1, -1, 0)

    # xからk,kからyの最短距離を足す
    for x, y in Query:
        res = depth[x - 1] + depth[y - 1]
        print(res)


if __name__ == '__main__':
    resolve()


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

int main(){
  ll N;
  cin >> N;
  ll A[N];
  rep(i, N) cin >> A[i];
  sort(A, A+N, greater<>());

  ll ans = A[0];
  rep(i, (N-2)/2) ans += A[i+1] * 2;
  if(N % 2) ans += A[N/2];

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



Measured memory_bytes: 5156
import sys

readline = sys.stdin.readline

N = int(readline())

A = list(map(int, readline().split()))
B = list(map(int, readline().split()))
# g, s b

def nap(A, B, N):
    dp = [0] * (N + 1)

    # A -> B
    # dp[i] = max(dp[i - 1], dp[i - a] + diff[a], ...)
    for i in range(1, N + 1):
        dp[i] = max(
            dp[i - 1] + 1,
            dp[i - A[0]] + B[0] if i - A[0] >= 0 else -1,
            dp[i - A[1]] + B[1] if i - A[1] >= 0 else -1,
            dp[i - A[2]] + B[2] if i - A[2] >= 0 else -1
        )
    return dp[N]

A_to_B = nap(A, B, N)

B_to_A = nap(B, A, A_to_B)

print(B_to_A)


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

int main()
{
    int n;
    cin >> n;
    map<int,int> mp;
    rep(i, n){
        int num;
        cin >> num;
        mp[num] = i+1;
    }


    for(int i = 1; i <= n; ++i){
        if( i != 1) cout << " ";
        cout << mp[i];
    }
    return 0;

}

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

int main(){
  vector <vector<int>> c(3,vector<int>(3));
  for (int i=0; i<3; i++){
    for (int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  vector <vector<int>> dif_a(3,vector<int>(2)),dif_b_T(3, vector<int>(2)); 
  for (int i=0; i<3; i++){
    for (int j=0; j<2; j++){
      dif_a[i][j] = c[i][j+1]-c[i][j];
    }
  }
  for (int j=0; j<3; j++){
    for (int i=0; i<2; i++){
      dif_b_T[j][i]=c[i+1][j]-c[i][j];
    }
  }
  if (dif_a[0]==dif_a[1] && dif_a[1]==dif_a[2] && dif_b_T[0]==dif_b_T[1] && dif_b_T[1]==dif_b_T[2]){
    cout <<"Yes"<<endl;
  }
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <stdio.h>

#define Max_N 100

using namespace std;

int V[Max_N];
int top = 0;

int pop(int *array){
    return V[--top];
}

void push(int *array, int value){
    V[top] = value;
    ++top;
}

int main(){

    char s[Max_N];
    int v1, v2;
    while (scanf("%s", s) != EOF){
        if(s[0] == '+'){
            v1 = pop(V);
            v2 = pop(V);
            push(V, v1 + v2);
        }else if(s[0] == '-'){
            v1 = pop(V);
            v2 = pop(V);
            push(V, v2 - v1);
        }else if(s[0] == '*'){
            v1 = pop(V);
            v2 = pop(V);
            push(V, v1 * v2);
        }else{
            push(V, atoi(s));
        }
    }

    printf("%d\n", pop(V));
}

Measured memory_bytes: 3156
#include<iostream>
#include<string.h>
using namespace std;
int h,n;
const int N=1e5+10;
int a[N],b[N],dp[N];
int main()
{
    while(cin>>h>>n)
    {
        memset(dp,0x3f3f3f3f,sizeof(dp));
        dp[0]=0;
        int sum=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i]>>b[i];
            sum=max(sum,a[i]);
        }
        for(int i=1;i<=n;i++)
        {
            for(int j=a[i];j<=sum+h;j++)
            {
                dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
               // printf("%d %d  ",j,dp[j]);
            }
           // printf("\n");
        }
        int res=dp[h];
        for(int i=h;i<=sum+h;i++)
        {
            res=min(res,dp[i]);
        }
        printf("%d\n",res);
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305;
ll sum;
int a[N][N],p[N][N];
int n;
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            cin>>a[i][j],sum+=a[i][j];
    for(int k=1; k<=n; k++)
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                if(a[i][k]+a[k][j]<a[i][j])
                {
                    cout<<-1;
                    return 0;
                }
    for(int k=1; k<=n; k++)
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                if(a[i][k]+a[k][j]==a[i][j]&&i!=k&&k!=j&&i!=j)
                    p[i][j]=1;
        for(int i=1; i<=n; i++)
            for(int j=1; j<=n; j++)
                if(p[i][j])
                    sum-=a[i][j];
    cout<<sum/2;
    return 0;
}


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

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double s;

	if (x <= a * a * b / 2) {
		s = atan(a * b * b / (2 * x)) * 180 / 3.141592653589793238462643383279;
	}
	else {
		s = 90 - atan(a * a * a / (2 * a * a * b - 2 * x)) * 180 / 3.141592653589793238462643383279;
	}
	cout << setprecision(10) << fixed;
	cout << s << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<list>

using namespace std;

int main(){
		int n;
		scanf("%d",&n);
		list<int> v;
		char aa[20];
		int i;
		for(i=0;i<n;i++){
		scanf("%s",aa);
		if(aa[0]=='i'){ 
			int a;
			scanf("%d",&a);
			v.push_front(a);
		}
		else if(aa[0]=='d'&&aa[6]=='\0') {
			int a;
			scanf("%d",&a);
			for(list<int>::iterator it=v.begin(); it!=v.end();it++){
				if(*it==a) {
					v.erase(it);
					break;
				}
			}
		}
		else if(aa[0]=='d' && aa[6]=='F') v.pop_front();
		else  v.pop_back();
	}
	
	i=0;
for(list<int>::iterator it=v.begin(); it != v.end();it++){
	if(i++) printf(" ");
	printf("%d",*it);
	}
	printf("\n");
	return 0;
	}

Measured memory_bytes: 32364
//#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<string>
#include<cstdlib>
#include<bitset>
#include<sstream>
#include<queue>
#include<stack>
#include<list>
#include<limits>
#include<iomanip>

using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pt;
typedef pair<ll,ll> pll;

#define Max 1000001
#define intinf 2147483647
#define longlonginf 9223372036854775807
#define MOD 998244353
#define MOD2 1000000007
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define vint vector<int>
#define vll vector<long long>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define F(i,n) for(int i = 0;i<n;i++)
#define Fr(i,l,r) for(int i = l;i <= r;i++)
#define rF(i,n) for(int i = n-1;i>=0;i--)


//#define min(a,b) a>b?b:a
//#define max(a,b) a>b?a:b
#define all(arr) arr.begin(),arr.end()
//#define sort(vec) sort(vec.begin(),vec.end())
//#define reverse(vec) reverse(vec.begin(),vec.end())

const ll m = 1e9 + 9;


ll Lpow(ll a,ll b)
{
    ll ans = 1;
    while(b > 0)
    {
        if(b%2)
            ans = (ans*a)%m;
        a = (a*a)%m;
        b = b/2;
    }
    return ans;
}

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


signed main()
{
    fastio;
    
    string s;
    cin >> s;
    
    for(int i = 0;i<s.length();i++)
    {
        if(s[i] == '?')
            s[i] = 'D';
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>

using namespace std;
int main(){
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int s[n], i, sum = 0, ave = 0;
		for(i = 0;i < n;i++){
			cin >> s[i];
		}
		sort(s, s+n);
		s[0] = 0;
		s[n-1] = 0;

		for(i = 0;i < n;i++){
			sum += s[i];
		}
		ave = sum / (n-2);

		cout << ave << endl;
	}
	return 0;
}

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

int main() {

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

    int n, l ;
    cin >> n >> l ;

    int ans = 1e9 ;
    int otans = -1e9 ;
    int sum = 0;
    for(int i = 1; i <= n; i++){

        if (i+l-1 >= 0)
            ans = min(ans, i+l-1) ;
        else
            otans = max(otans, i+l-1) ;
        sum += i+l-1 ;

    }
    if ( ans < -otans )
        cout << sum - ans ;
    else
        cout << sum - otans ;

}


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

using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    int ans;
    if (a == 1 && b == 2) ans = 3;
    else if (a == 1 && b == 3) ans = 2;
    else ans = 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	double a, b, c, d, x,y;
	cin >> a >> b >> c >> d;
	x = (c - a) * (c - a) + (d - b) * (d - b);
	y = sqrt(x);
	cout << fixed;
	cout<<setprecision(5)<< y << endl;
}




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

using namespace std;

int main() {
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  if (s[0] == s[1] && s[2] == s[3] && s[0] != s[3]) {
    cout << "Yes\n";
  } else {
    cout  << "No\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int H, W;
    while(cin >> H >> W){
        vector<string> str(H);
        REP(i, H) cin >> str[i];

        const int MAXS = 1 << W;
        vector<int> dp(MAXS, -INF);
        dp[0] = 0;
        for(int y = 0; y < H; y++){
            for(int x = 0; x < W; x++){
                vector<int> next(MAXS, -INF);
                for(int s = 0; s < MAXS; s++) if(dp[s] >= 0){
                    int cu = __builtin_popcount(s >> x); // count of upper
                    int cl = __builtin_popcount(s & ((1 << x) - 1)); // count of lower
                    assert(cu + cl == __builtin_popcount(s));

                    if(cl + (W - 1 - x) >= str[y].size())
                        next[s << 1 & (MAXS - 1)] = max(next[s << 1 & (MAXS - 1)], dp[s]); // path through

                    if(cl == str[y].size()) continue;

                    int add = 0;
                    if(cl > 0 && str[y][cl] == str[y][cl - 1] && (s & 1)){
                        add += 2;
                    }
                    if(y > 0 && (s >> (W - 1) & 1) && str[y - 1][str[y - 1].size() - cu] == str[y][cl]){
                        add += 2;
                    }
                    next[(s << 1 & (MAXS - 1)) | 1] = max(next[(s << 1 & (MAXS - 1)) | 1], dp[s] + add);
                }
                dp.swap(next);
            }
        }
        int ans = 0;
        for(int s = 0; s < MAXS; s++) ans = max(ans, dp[s]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1684
fun solve(N: Int, A: List<Int>) {
    var ans = "APPROVED"
    for (a in A) {
        if (a % 2 == 0) {
            if (!(a % 3 == 0 || a % 5 == 0)) {
                ans = "DENIED"
                break
            }
        }
    }
    println(ans)
}

fun main() {
//    val S = readLine()!!
    val N = readLine()!!.toInt()
//    val (N, M) = readLine()!!.split(" ").map { it.toInt() }
    val A = readLine()!!.split(" ").map { it.toInt() }
    solve(N, A)
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> P(n);
    for (int &i: P) cin >> i;
    vector<int> Q(n);
    for (int &i: Q) cin >> i;

    vector<int> per(n);
    for (int i = 0; i < n; i++) per[i] = i + 1;
    int cnt = 0;
    int timeP = 0;
    int timeQ = 0;
    
    do{
        cnt++;
        if (per == P) timeP = cnt;
        if (per == Q) timeQ = cnt;
    }
    while (next_permutation(per.begin(),per.end()));
    cout << abs(timeQ - timeP);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());

        // 主処理
        int result = k;
        for (int i = 0; i < n - 1; i++) {
            result *= k - 1;
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}

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

int a[3][3], n, b[10];
bool seen[3][3];

int main() {
	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 < 3; i++) {
		for (int j = 0; j < 3; j++) {
			seen[i][j] = false;
			for (int k = 0; k < n; k++) 
				if (a[i][j] == b[k]) seen[i][j] = true;
		}
	}
	bool ans = false;
	for (int i = 0; i < 3; i++)
		if (seen[i][0] && seen[i][1] && seen[i][2]) ans = true;

	for (int i = 0; i < 3; i++)
		if (seen[0][i] && seen[1][i] && seen[2][i]) ans = true;

	if (seen[0][0] && seen[1][1] && seen[2][2]) ans = true;
	if (seen[0][2] && seen[1][1] && seen[2][0]) ans = true;

	cout << (ans ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <cstdio>
#include <map>
#include <vector>
const int HASH = 131;
const int MAXN = 5005;
const int MOD = 1e9+7;
char S[MAXN];
int H[MAXN];
int N;

std::map<int, std::vector<int>> D;

bool matches(int j, int i, int len) {
  for (int k = 0; k < len; ++k) {
    if (S[j-k] != S[i-k]) return false;
  }
  return true;
}

bool find(int len) {
  D.clear();
  int sum = 0;
  for (int i = 0; i < N; ++i) {
    sum = (1LL * HASH * sum + S[i]) % MOD;
    if (i >= len) {
      int old = 1LL * H[len] * S[i-len] % MOD;
      sum = (sum - old + MOD) % MOD;
    }
    if (i+1 < len) continue;
    if (D.count(sum)) {
      for (int j: D.at(sum)) {
        if (j + len > i) break;
        if (matches(j, i, len)) {
          return true;
        }
      }
    }
    D[sum].push_back(i);
  }
  return false;
}

void init() {
  H[0] = 1;
  for (int i = 1; i <= N; ++i) {
    H[i] = 1LL * H[i-1] * HASH % MOD;
  }
}

int solve() {
  int lo = 0;
  int hi = N/2;
  while (lo < hi) {
    int x = (lo + hi + 1) / 2;
    if (find(x)) {
      lo = x;
    } else {
      hi = x-1;
    }
  }
  return lo;
}

int main() {
  scanf(" %d%s", &N, S);
  init();
  printf("%d\n", solve());
  return 0;
}

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

int dp[3030][3030];

int main(){
    string s,t;
    cin >> s >> t;
    s = "+" + s;
    t = "-" + t;

    for(int i=0;i<s.size();i++){
        for(int j=0;j<t.size();j++){
            if(s[i]==t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else{
                dp[i+1][j+1] = max(dp[i][j+1],dp[i+1][j]);
            }
        }
    }
    /*rep(i,s.size()){
        rep(j,t.size()){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/

    string ans ="";
    int x = s.size();
    int y = t.size();

    while(x > 0 && y > 0){
        if(dp[x][y]==dp[x-1][y]){
            x--;
        }
        else if(dp[x][y]==dp[x][y-1]){
            y--;
        }
        else{
            x--;
            y--;
            //cout << "x--y--" << endl;
            ans += s[x];
        }
    }
    //cout << ans << endl;
    reverse(ans.begin(),ans.end());
    cout << ans << endl;

    //cout << dp[s.size()][t.size()] << endl;
}

Measured memory_bytes: 35840
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        int length = 0;
        for(int i = 1;i < n;i++){
            if((n-i) % 2 != 0){
                continue;
            }
            String first = s.substring(0,(n-i)/2);
            String last = s.substring((n-i)/2,n-i);
            //System.out.println("first = "+ first);
            //System.out.println("last = "+last);
            if(first.equals(last)){
                length = first.length() + last.length();
                break;
            }
        }
        System.out.println(length);
    }
}


Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
int sumofdigit(int a)
{
	int sum=0;
	while(a!=0)
	{	
		sum+=a%10;
		a/=10;
	} 
	return sum;
}
int main()
{
	int n,a,b,sum=0,tmp,i;
	scanf("%d %d %d",&n,&a,&b);
	for(i=1;i<=n;i++)
	{
		tmp=sumofdigit(i);
		if(tmp>=a&&tmp<=b)
		{
			sum+=i;
		}
	}
	printf("%d\n",sum);
	return 0;
}

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

int main() {
  int N, K, s = 0;
  cin >> N >> K;

  for ( int i = 0; i < N; i++ ) {
    int x;
    cin >> x;

    if ( abs( K - x ) < x ) s += 2*abs( K - x );
    else s += 2 * x;
  }

  cout << s << endl;
}

Measured memory_bytes: 256
import java.util.*;

class Graph {
	private int totalVertex, totalEdges;
	private int[] degree;
	private LinkedList<LinkedList<Integer>> adjList;
	public Graph() {
		totalVertex = 0;
		totalEdges = 0;
	}
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		totalEdges = in.nextInt();
		degree = new int[totalVertex];
		adjList = new LinkedList<LinkedList<Integer>>();
		
		for(int i = 0; i < totalVertex ; i++) {
			LinkedList<Integer> vert = new LinkedList<Integer>();
			adjList.add(vert);
			degree[i] = 0;
		}
		
		int row, col;
		for (int i = 0; i < totalEdges; i++) {
			row = in.nextInt();
			col = in.nextInt();
			adjList.get(row).add(col);
			degree[col] += 1;
		}
		in.close();
	}
	
	public void print() {
		Queue<Integer> vert = new LinkedList<Integer>();
		for(int i = 0; i < totalVertex; i++) {
			if(degree[i] == 0) {
				vert.add(i);
			}
		}
		while(!vert.isEmpty()) {
			int num = vert.poll();
			System.out.println(num);
			for(Integer n : adjList.get(num)) {
				degree[n] -= 1;
				if(degree[n] == 0) {
					vert.add(n);
				}
			}
		}
	}
}

public class Main {
	public static void main(String[] args) {
		Graph g = new Graph();
		g.loadAdjList();
		g.print();
	}
}


Measured memory_bytes: 73576
/******************************************************************************

рассвет.

*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define all(a) (a).begin(),(a).end()
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int>
#define vplli vector <pair <lli,lli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s)
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i];
using namespace std;

const lli MOD=1e9+7;
const lli MAXN=5e4+1;
const ld PI=acos(-1);

int main(){
    rapgame
    //freopen("bridges.in", "r", stdin);
    //freopen("bridges.out", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--){
         read2(n,m);
         cout << max(0,n-2*m);
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,m;
    cin >> n >> m;
    Vi a(n),sum(n+1);
    sum[0]=0;
    rp(i,n){
        cin >> a[i];
    }
    Sort(a);
    rp(i,n) sum[i+1]=sum[i]+a[i];
    ll mid, ok = a[0]*2+1, ng = a[n-1]*2-1;
    reverse(all(a));
    while(abs(ok-ng)>1){
        mid = (ok+ng)/2;
        bool which=true;
        ll ctr=0;
        rp(i,n){
            ll res=a.end()-lower_bound(all(a),mid-a[i]);
            ctr += res;
            if(ctr>m) which=false;
        }
        if(which)ok = mid;
        else ng = mid;
    }//midではなくokを使わないとバグる!
    ll ct=0, ans=0;
    rp(i,n){
        ll r=a.end()-lower_bound(all(a),ok-a[i]);
        ct+=r;
        ans+=sum[r]+a[i]*r;
    }
    ans+=(ok-1)*(m-ct);
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

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

int main(){

	int n;
	cin >> n;

	vector<double> a(n+1);

	for(int i=1;i<=n;i++){
		cin >> a[i];
	}

	vector< vector<double> > dp( n+1,vector<double>(n+1,0) );

	for(int i=1;i<=n;i++){
		if(i==1){
			dp[i][0]=1-a[i];
		}else{
			dp[i][0] = dp[i-1][0]*(1-a[i]);
		}
	}
	dp[1][1]=a[1];

	for(int i=2;i<=n;i++){
		for(int j=1;j<=i;j++){
			dp[i][j] = dp[i-1][j]*(1-a[i]) + (dp[i-1][j-1])*(a[i]);
		}
	}

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

	double ans = 0;

	for(int i=1+(n)/2;i<=n;i++){
		ans+= dp[n][i];
	}

	printf("%.10f\n",ans);



	return 0;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string str;
  int n=0;
  cin>>str;
  string ans="Yes";
  for(int i=0;i<str.length();i++)
  {
    n+=str[i]-'0';
  }
  if(n%9)
    ans="No";
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <stdlib.h>
using namespace std;
int compare_int(const void* a, const void* b)
{
	return *(int*)a - *(int*)b;
}
int main() {
	long long int h[200000],count;
	int n,k;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	qsort(h, n, sizeof(long long int), compare_int);
	for (int i = n - 1 - k; i >= 0; i--) {
		count += h[i];
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    map<int, int> a; // ??´???????????¨??£?§£??°????????????
    map<int ,int> m; // ??£?§£??°??¨??????????????????
    int x, y;
    while(~scanf("%d,%d\n", &x, &y)) {
        if(x == 0 && y == 0) break;
        a[x] = y; m[y];
    }

    int j = 1;
    for(auto &s : m) s.second = j++;

    int n;
    while(cin >> n) cout << j - m[a[n]] << endl;
    return 0;
}

Measured memory_bytes: 3248
#include <iostream>
#include <queue>
#include <vector>
#include <functional>
#include <utility>
#include <algorithm>
#include <set>

using P = std::pair<int, int>;

const int INF = 1e9;

int n, m;
std::vector<std::vector<P>> edges;
std::set<P> used;
int D[110];
std::vector<std::set<P>> us;

inline
P mp(int x, int y) {
    if(x > y) {
        std::swap(x, y);
    }
    return {x, y};
}

void dijkstra(int s) {
    for(int i = 0; i < n; ++i) {
        D[i] = INF;
    }
    us.clear();
    us.resize(n);
    D[s] = 0;
    
    std::priority_queue<P, std::vector<P>, std::greater<P>> que;
    
    que.push({0, s});
    
    while(!que.empty()) {
        auto p = que.top(); que.pop();

        if(p.first > D[p.second]) {
            continue;
        }
        
        for(auto& q : edges[p.second]) {
            if(D[q.first] > D[p.second] + q.second) {
                us[q.first].clear();// = decltype(us[q.first]){};
                us[q.first].insert(mp(p.second, q.first));
                D[q.first] = D[p.second] + q.second;
                que.push({D[q.first], q.first});
            }else if(D[q.first] == D[p.second] + q.second) {
                us[q.first].insert(mp(p.second, q.first));
            }
        }
    }
    
    for(int i = 0; i < n; ++i) {
        for(auto& p : us[i])
            used.insert(p);
    }
}

int main() {
    std::cin >> n >> m;
    
    edges.resize(n);
    
    for(int i = 0; i < m; ++i) {
        int x, y, z;
        std::cin >> x >> y >> z;
        
        edges[--x].push_back({--y, z});
        edges[y].push_back({x, z});
    }
    
    for(int i = 0; i < n; ++i) {
        dijkstra(i);
    }
    
    std::cout << m - used.size() << std::endl;
}

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

#define M_PI 3.14159265358979323846

using namespace std;

//typedef
//-------------------------#include <bits/stdc++.h>

#define M_PI 3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}
inline int readInt()
{
    int x;
    scanf("%d", &x);
    return x;
}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
//#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-8;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const int INF = 2147483647;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    string s;
    cin >> s;
    string t = "0123456789";

    int N = s.size();

    ll val1 = 0;
    for (int i = 0; i < s.size(); i++)
    {
        val1 = val1 * 10 + s[i] - '0';
    }

    string ans = "";
    ll mx = 0;
    do
    {
        string tt = "";
        ll val2 = 0;
        for (int i = 0; i < N; i++)
        {
            tt += t[i];
            val2 = val2 * 10 + t[i] - '0';
        }

        if (mx < min(abs(val1 - val2), (ll)pow(10, N) - abs(val1 - val2)))
        {
            mx = min(abs(val1 - val2), (ll)pow(10, N) - abs(val1 - val2));
            ans = tt;
        }

    } while (next_permutation(all(t)));

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



Measured memory_bytes: 3372
#include <iostream>

using namespace std;

long long int n,k;
long long int a[100000009];
bool check(int m)
{
    long long int sl = 0;
    for (long long int i = 1; i<= n ; i++ )
    {
        sl += (a[i]/m);
        if(a[i]%m == 0) sl --;
    }
    return (sl <= k);
}
int main()
{
    cin >> n >> k;
    long long int d = 1, c = -1 , g, m = -1;
    for (long long int i = 1; i <= n ; i ++ )
        {
            cin >> a[i];
            c = max(c,a[i]);}

    while ( d <= c )
    {
        g = (d+c)/2;
        if (check(g))
        {
            m = g;
            c = g - 1;
        }
        else
            d = g + 1;
    }
    cout << m;
    return 0;
}


Measured memory_bytes: 5032
#バブルソート
def BubbleSort(C,N):
    for i in range (0,N,1):
        for j in range(N-1,i,-1):
            if int(C[j][1:2]) < int(C[j-1][1:2]):
                tmp = C[j]
                C[j] = C[j-1]
                C[j-1] = tmp
    print(' '.join(C))

    
                
#選択ソート
def SelectionSort(C,N):
    for i in range(0,N,1):
        minj = i
        for j in range(i,N,1):
            if int(C[j][1:2]) < int(C[minj][1:2]):
                minj = j
        tmp = C[i]
        C[i] = C[minj]
        C[minj] = tmp
    print(' '.join(C))



N = int(input())
A = list(input().split())
Bubble_A = A.copy()
Selection_A = A.copy()

BubbleSort(Bubble_A,N)
print("Stable")
SelectionSort(Selection_A,N)
flag = True
for Bubble,Selection in zip(Bubble_A,Selection_A):
    if Bubble != Selection:
        flag = False
if flag :
    print("Stable")
else:
    print("Not stable")



Measured memory_bytes: 5608
import java.nio.file.*;
import java.nio.charset.*;
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        if(sc.next().indexOf('9')==-1){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}

Measured memory_bytes: 21588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task2 solver = new Task2();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long k = in.nextLong();
            long a1[] = new long[n + 1];
            long a2[] = new long[m + 1];
            a1[0] = 0;
            a2[0] = 0;
            for (int i = 1; i <= n; ++i) {
                a1[i] = a1[i - 1] + in.nextLong();
            }
            for (int i = 1; i <= m; ++i) {
                a2[i] = a2[i - 1] + in.nextLong();
            }
            long ans = 0;
            for (int i = 0; i <= n && a1[i] <= k; ++i) {
                while (a1[i] + a2[m] > k) m--;
                ans = Math.max(ans, i + m);
            }
            out.println(ans);
        }

    }
}



Measured memory_bytes: 53824
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        while (true) {
            int w = sc.nextInt();
            int h = sc.nextInt();
            if (w == 0 && h == 0) {
                break;
            }
            char[][] field = new char[h][];
            int ww = 0;
            int hh = 0;
            for (int i = 0; i < h; i++) {
                field[i] = sc.next().toCharArray();
                for (int j = 0; j < w; j++) {
                    if (field[i][j] == '@') {
                        ww = j;
                        hh = i;
                        field[i][j] = '.';
                    }
                }
            }
            Counter cn = new Counter();
            search(hh, ww, field, cn);
            sb.append(cn.count).append("\n");
        }
        System.out.print(sb);
    }
    
    static void search(int hh, int ww, char[][] field, Counter cn) {
        if (hh < 0 || hh >= field.length || ww < 0 || ww >= field[hh].length || field[hh][ww] != '.') {
            return;
        }
        cn.up();
        field[hh][ww] = '#';
        search(hh - 1, ww, field, cn);
        search(hh + 1, ww, field, cn);
        search(hh, ww - 1, field, cn);
        search(hh, ww + 1, field, cn);
    }
    
    static class Counter {
        int count = 0;
        
        public void up() {
            count++;
        }
    }
}



Measured memory_bytes: 37348
import numpy as np
 
n,X = map(int,input().split())
xs = np.array(list(map(int,input().split())))
cumsumx =np.insert(np.cumsum(xs),0,0)
 
cut = np.int_(1000000000000000)
 
def cutsum(array):
    acm = np.int_(0)
    for i in array:
        if acm <= cut:
            acm += i
        else:
            acm = cut
            break
    return(acm)
 
def energy(k):
    nok = n//k
    offset = (n+k)*X
    acm = (n+k)*X + 3*cumsumx[-1] - 2*cumsumx[-k-1]
    acm += 2*cutsum(cumsumx[::-k])
    return(acm)
 
ans = (n+1)*X+2*cutsum(cumsumx)+3*cumsumx[-1]-2*cumsumx[-2]
for j in range (2,min(n//2+4,n+1)):
    tmp = energy(j)
    if tmp < ans:
        ans =tmp
 
print(ans)
 

Measured memory_bytes: 34776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
ll mod = 1000000007;
ll INF = 1000000099;

int h,w;
vector<vector<char>> v;
vector<vector<vector<ll>>> u;

ll usear(ll x,ll y){
    if(x<0 || v.at(x).at(y)=='#'){
        return 0;
    }else{
        return 1+usear(x-1,y);
    }
}
ll dsear(ll x,ll y){
    if(x==h || v.at(x).at(y)=='#'){
        return 0;
    }else{
        return 1+dsear(x+1,y);
    }
}
ll lsear(ll x,ll y){
    if(y<0 || v.at(x).at(y)=='#'){
        return 0;
    }else{
        return 1+lsear(x,y-1);
    }
}
ll rsear(ll x,ll y){
    if(y==w || v.at(x).at(y)=='#'){
        return 0;
    }else{
        return 1+rsear(x,y+1);
    }
}



signed main(){
    ll h,w,ans=0;
    cin>>h>>w;
    v= vector<vector<char>>(h+2,vector<char>(w+2));
    u=vector<vector<vector<ll>>>(h+2,vector<vector<ll>>(w+2,vector<ll>(4,-1)));
    
    for(int i=0;i < h+2;i++)
    {
        for(int j=0;j < w+2;j++)
        {
            if(i==0 || i==h+1 || j==0 || j==w+1){
                v.at(i).at(j)='#';
            }else{
                cin>>v.at(i).at(j);
            }
        }
    }

    for(int i=1;i < h+1;i++)
    {
        for(int j=1;j < w+1;j++)
        {
            ll sum=0;
            if(v.at(i).at(j)=='.'){
                if(0<=i-1 && u.at(i-1).at(j).at(0)>=0){
                    u.at(i).at(j).at(0)=1+u.at(i-1).at(j).at(0);
                }else{
                    u.at(i).at(j).at(0)=usear(i,j);
                }
                sum+= u.at(i).at(j).at(0);

                if(u.at(i-1).at(j).at(1)>=0){
                    u.at(i).at(j).at(1)=-1+u.at(i-1).at(j).at(1);
                }else{
                    u.at(i).at(j).at(1)=dsear(i,j);
                }
                sum+=u.at(i).at(j).at(1);

                if(0<=j-1 && u.at(i).at(j-1).at(2)>=0){
                    u.at(i).at(j).at(2)=1+u.at(i).at(j-1).at(2);
                }else{
                    u.at(i).at(j).at(2)=lsear(i,j);
                }
                sum+=u.at(i).at(j).at(2);

                if(u.at(i).at(j-1).at(3)>=0){
                    u.at(i).at(j).at(3)=-1+u.at(i).at(j-1).at(3);
                }else{
                    u.at(i).at(j).at(3)=rsear(i,j);
                }
                sum+=u.at(i).at(j).at(3);

            }
            ans=max(ans,sum-3);
        }
    }
    cout << ans << endl;

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};

mint c[4005][4005];
void init() {
  c[0][0] = 1;
  for (int i = 0; i <= 4000; i++) {
    for (int j = 0; j <= i; j++) {
      c[i+1][j] += c[i][j];
      c[i+1][j+1] += c[i][j];
    }
  }
}
mint comb(int n, int k) {
  return c[n][k];
}

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}

map<ll, ll> primeFact(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n]++;
  return res;
}

void printv(vi& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
void printv(vll& v){
  rep(i,v.size()) cout << v[i] << " ";
  cout << endl;
}
int vtotal(vi& v){
  int total=0;
  rep(i,v.size()) total+=v[i];
  return total;
}

int main()
{
  //init(); // mint初期化
  cin.tie( 0 );
  ios::sync_with_stdio( false );

  int a,b,c;cin>>a>>b>>c;
  int ans=0;
  if(b/a>c)ans=c;
  else ans=b/a;

  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

typedef long long ll;

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

    int a;

    cin>>a;

    vector<ll> b;

    for(int i = 0; i < a; i++){
        ll c;
        cin>>c;
        b.push_back(c);
    }

    int zero = 0;

    for (int i =0; i< a; i++)
    {
        if(b[i] == 0){
            zero++;
        }
    }

    if (zero > 0){
        cout << 0<<endl;
        return 0;
    }

    ll res = 1;
    for(auto it = b.begin(); it != b.end(); ++it){
        if (*it <= 1000000000000000000 / res)
        {
            res = res * *it;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }
    printf("%lld\n", res);
   

    return 0;
}

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

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

int main() {
  int N , X ;
  cin >> N >> X ;
  int A[N] ;
  rep(i,N) cin >> A[i] ;
  int ans = abs( A[0] - X ) ;
  rep(i,N) {
    if(ans > abs(A[i] - X ) ) ans = gcd( ans , abs(A[i] - X ) ) ;
    else if(ans < abs(A[i] - X )) ans = gcd(abs(A[i] - X) , ans ) ;
    else continue ;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    
//-----------------------------------------------------------------------------------------------------------//

    READV(N);
    READV(M);
    if (N==M)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    
    

//-----------------------------------------------------------------------------------------------------------//


   
    return 0;
}

Measured memory_bytes: 256