akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>

using namespace std;

const int N = 2e6;
const int maxn = N + 10;
const int Mod = 1e9 + 7;
const int val[4][4] = 
{
{1, -1, -1, 1},
{-1, 1, 1, -1},
{-1, 1, 1, -1},
{1, -1, -1, 1},
};

int Power(int a, int k)
{
	int x = 1;
	for (; k; k >>= 1)
	{
		if (k & 1) x = 1ll * x * a % Mod;
		a = 1ll * a * a % Mod;
	}
	return x;
}

int fac[maxn], inv[maxn];

void Prepare(int n)
{
	fac[0] = 1;
	for (int i = 1; i <= n; ++ i)
		fac[i] = 1ll * fac[i - 1] * i % Mod;
	inv[n] = Power(fac[n], Mod - 2);
	for (int i = n; i >= 1; -- i)
		inv[i - 1] = 1ll * inv[i] * i % Mod;
}

int CC(int n, int m)
{
	if (n < 0 || m < 0) return 0;
	return 1ll * fac[n + m] * inv[n] % Mod * inv[m] % Mod;
}

typedef pair<int, int> PI;
#define vx first
#define vy second

int C(PI s, PI t)
{
	return CC(t.vx - s.vx, t.vy - s.vy);
}

int Calc(int xl, int xr, int yl, int yr, PI s, PI t)
{
	int ans = 0;
	for (int x = xl; x <= xr; ++ x)
	{
		(ans -= 1ll * C(s, PI(x, yl - 1)) * C(PI(x, yl), t) % Mod * (x + yl) % Mod) %= Mod;
		(ans += 1ll * C(s, PI(x, yr)) * C(PI(x, yr + 1), t) % Mod * (x + yr + 1) % Mod) %= Mod;
	}
	for (int y = yl; y <= yr; ++ y)
	{
		(ans -= 1ll * C(s, PI(xl - 1, y)) * C(PI(xl, y), t) % Mod * (xl + y) % Mod) %= Mod;
		(ans += 1ll * C(s, PI(xr, y)) * C(PI(xr + 1, y), t) % Mod * (xr + y + 1) % Mod) %= Mod;
	}
	return ans;
}

PI ps[4], pt[4];

int main()
{
	int x1, x2, x3, x4, x5, x6;
	scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
	int y1, y2, y3, y4, y5, y6;
	scanf("%d%d%d%d%d%d", &y1, &y2, &y3, &y4, &y5, &y6);
	Prepare(N);
	ps[0] = PI(x1 - 1, y1 - 1);
	ps[1] = PI(x1 - 1, y2);
	ps[2] = PI(x2, y1 - 1);
	ps[3] = PI(x2, y2);
	pt[0] = PI(x5, y5);
	pt[1] = PI(x5, y6 + 1);
	pt[2] = PI(x6 + 1, y5);
	pt[3] = PI(x6 + 1, y6 + 1);
	int ans = 0;
	for (int i = 0; i < 4; ++ i)
		for (int j = 0; j < 4; ++ j)
			(ans += val[i][j] * Calc(x3, x4, y3, y4, ps[i], pt[j])) %= Mod;
	printf("%d\n", (ans + Mod) % Mod);
	return 0;
}


Measured memory_bytes: 15744
/* HEADERS & NAMESPACES */
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;

/* MACROS */
#define fastIO() ios_base:: sync_with_stdio(false); cin.tie(NULL)
#define fill(v, x) memset(v, x, sizeof(v))
#define rep(i, a, b) for(__typeof(b) i = (a)-((a)>(b)); i != (b)-((a)>(b)); i += 1-2*((a)>(b)))
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define int long long
#define ii pair<int, int>
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl;
#define CHK(x, y) cerr << "\n" << #x << "=" << (x) << ", " << #y << "=" << (y) << "\n"
// #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define INF (1ll)<<60
#define MOD 1000000007
#define N 200005

/* TEMPLATES */
template<class T> ostream& operator<<(ostream &os, vector<T> V) {
    os << "[ ";
    for(auto v: V) os << v << " ";
    return os << "]\n";
}
template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) {
    return os << "(" << P.ff << ", " << P.ss << ")\n";
}
template<class T> ostream& operator<<(ostream &os, set<T> S) {
    os << "{ ";
    for(auto s: S) os << s << " ";
    return os << "}\n";
}
template<class L, class R> ostream& operator<<(ostream &os, map<L, R> M) {
    os << "{ ";
    for(auto m: M) os << "(" << m.ff << ":" << m.ss << ") ";
    return os << "}\n";
}

/* GLOBAL */
/* FUNCTIONS */

void solve() {
    int n; cin >> n;
    int a[n], ans = 0;
    map<int, int> mp, mq;
    rep(i, 0, n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    for(auto x: mp) ans += (x.ss * (x.ss - 1)) / 2;
    rep(i, 0, n) cout << ans - mp[a[i]] + 1 << endl;
}

signed main() {
    fastIO();
    solve();
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod=1e9+7;
int main(){
string s;
cin>>s;int res=0;
vector<int>dp(2019);
for(char&c:s){
	vector<int>dp1(2019);
	for(int i=0;i<2019;i++){
		
		dp1[(i*10+(c-'0'))%2019]	+=dp[i];
	}
	dp1[c-'0']++;
	res+=dp1[0];
	dp.swap(dp1);
	
	

}
cout<<res;

return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
using namespace std;
typedef long long ll;

int main(){
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    int sum = 0;
    rep(i,n) sum += a[i];
    if(h<=sum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2E5+7;
const ll INF=1e9+7;
ll dp[N];
ll a[N],b[N];
int main(){
    ll h,c;
    cin>>h>>c;
    for(ll i=1;i<=c;i++) cin>>a[i]>>b[i];
    for(ll i=1;i<=2*h;i++) dp[i]=INF;
    for(ll i=1;i<=c;i++){
        for(ll j=1;j<=2*h;j++){
            dp[j]=min(dp[j],dp[max((ll)0,j-a[i])]+b[i]);
        }
    }
    ll ans=INF;
    for(ll i=h;i<=h*2;i++){
        ans=min(ans,dp[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2304
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] a = new int[N];
        int res = 0;

        for (int i = 0; i < N; i++) {
            res += sc.nextInt() - 1;
        }
        
        System.out.println(res);


    }

}


Measured memory_bytes: 40472
# D - Replacing
from collections import defaultdict


def main():
    N, *X = map(int, open(0).read().split())
    A, BC = X[:N], X[N + 1 :]
    cnt = defaultdict(int)
    for a in A:
        cnt[a] += 1
    total = sum(A)
    res = []
    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * cnt[b]
        res.append(total)
        cnt[c] += cnt[b]
        cnt[b] = 0
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 43936
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define pb push_back
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);

using namespace std;

signed main()
{

 	FLASH

 	int n;
 	cin>>n;
 	int g= 0;
 	fr(i,1,n + 1)
 	{
 		int a;
 		cin>>a;

 		g = __gcd(a,g);
 	}

 	cout<<g<<'\n';


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int x[100010], l[100010];
signed main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> v(n),p(n),q(n);
    REP(i, n)
    cin >> v[i].first >> v[i].second;

    for (int i = 0; i < n; i++)
    {
        p[i].first = v[i].first + v[i].second;
        p[i].second = v[i].first;
    }

    for (int i = 0; i < n; i++)
    {
        q[i].first = v[i].first - v[i].second;
        q[i].second = v[i].first;
    }
    sort(ALL(p));
    sort(ALL(q));
    sort(ALL(v));
    int maxl = q[0].second + q[0].second - q[0].first;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        if(maxl > q[i].first ){
            ans++;
            maxl = min(maxl, q[i].second + q[i].second - q[i].first);
        }
        else{
            maxl = q[i].second + q[i].second - q[i].first;
        }
    }
    cout << n - ans << endl;

    return 0;
}

Measured memory_bytes: 4992
n = int(input())
a = [int(i) for i in input().split(" ")]
s = [a[0]] + [0 for i in range(1,n)]
su = sum(a)
c = su
for i in range(1,n):
  s[i] = s[i-1]+a[i]
  te = abs(su-2*s[i])
  if te > c:
    break
  else:
    c = te
print(c)

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

int main()
{
	int A, B;
	cin >> A >> B;

	string S;
	cin >> S;

	bool flag = false;

	for (int loop = 0; loop < A; ++loop) {
		if ('-' == S[loop]) {
			flag = true;
		}
	}
	for (int loop = A + 1; loop < A + B; ++loop) {
		if ('-' == S[loop]) {
			flag = true;
		}
	}

	if (!flag && S[A] == '-') {
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


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

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

    int x = 0, ans;
    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        x += a;
    }
    if (x <= n) {
        ans = n-x;
    }
    else {
        ans = -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
#n,k=gets.split(' ').map(&:to_i)
#h=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
x=gets.to_i
serch_leng=1
serch_sum=0
while x>(26**serch_leng+serch_sum)
  serch_sum+=26**serch_leng
  serch_leng+=1
end
#puts serch_leng
x-=serch_sum
serch_start=+1
serch_end=serch_sum+26**serch_leng
#puts x
abc=('a'..'z').to_a
#puts abc
str=[]
#puts x
#puts serch_start
#puts serch_end
for i in 1..serch_leng
  #str.push(abc[x/26*i])
  count=0
  i_rever=serch_leng-i
  while x>26**i_rever*(count+1)
    count+=1
  end
  str.push(abc[count])
  #puts 26**i_rever*count
  x-=(26**i_rever*count)
  #puts x
end
puts str.join


Measured memory_bytes: 14360
N = int(input())
A = []
my_max = 0
for _ in range(N):
    a = int(input())
    A.append(a)
    my_max = max(my_max, a)

max_count = A.count(my_max)

if max_count > 1:
    [print(my_max) for _ in range(N)]
else:
    my_next_max = max([a for a in A if a != my_max])
    [print(my_max) if a != my_max else print(my_next_max) for a in A]

Measured memory_bytes: 14176
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int d[N][N], f[N][N];
struct data {
  int x, y, w;
} g[N * N * 10];
int dx[N], dy[N];

int check(int x, int y) {
  int ans = 1e9;
  for(int i = 0; i <= 100; ++i)
   for(int j = 0; j <= 100; ++j)
    ans = min(ans, i * x + j * y + f[i][j]);
  return ans;
}

int main() {
  int A, B;
  cin >> A >> B;
  for(int i = 1; i <= A; ++i)
    for(int j = 1; j <= B; ++j)
      scanf("%d", &d[i][j]);
  for(int i = 0; i <= 100; ++i)
    for(int j = 0; j <= 100; ++j) {
      for(int k = 1; k <= A; ++k)
       for(int t = 1; t <= B; ++t)
        f[i][j] = max(f[i][j], d[k][t] - i * k - j * t);
    }
  for(int i = 1; i <= A; ++i)
    for(int j = 1; j <= B; ++j) {
      if(check(i, j) != d[i][j]) {
        puts("Impossible");
        exit(0);
      }
    }
  puts("Possible");
  int tot = 0, res = 0;
  int S = ++tot;
  dx[0] = S;
  for(int i = 1; i <= 100; ++i) {
    dx[i] = ++tot;
    g[++res] = (data){dx[i - 1], dx[i], -1};
  }
  int T = ++tot;
  dy[0] = T;
  for(int i = 1; i <= 100; ++i) {
    dy[i] = ++tot;
    g[++res] = (data){dy[i], dy[i - 1], -2};
  }
  for(int i = 0; i <= 100; ++i)
    for(int j = 0; j <= 100; ++j) {
      g[++res] = (data){dx[i], dy[j], f[i][j]};
    }
  printf("%d %d\n", tot, res);
  for(int i = 1; i <= res; ++i) {
    printf("%d %d ", g[i].x, g[i].y);
    if(g[i].w < 0) {
      if(g[i].w == -1) puts("X");
      else puts("Y");
    } else printf("%d\n", g[i].w);
  }
  printf("%d %d\n", S, T);
  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
vl topsort(vvl &g){
    ll n=g.size();
    vl ans,ind(n);
    rep(i,n)for(auto e:g[i])ind[e]++;
    queue<ll> que;
    rep(i,n)if(!ind[i])que.push(i);
    while(!que.empty()){
        ll v=que.front();que.pop();
        ans.pb(v);
        for(auto nv:g[v]){
            ind[nv]--;if(!ind[nv])que.push(nv);
        }
    }
    return ans;
}
int main(){
    ll n,m;cin >> n >>m;
    vvl g(n);rep(i,n+m-1){
        ll a,b;cin >> a >> b;a--;b--;
        g[a].pb(b);
    }
    vl pls=topsort(g);
    vl ans(n,-1);
    rep(i,n){
        ll v=pls[i];
        for(auto p:g[v])ans[p]=v;
    }
    rep(i,n)cout << ans[i]+1 <<endl;
} 

Measured memory_bytes: 10476
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


def resolve():
    a, b, c, d = map(int, input().split())

    l = lcm(c, d)

    def calc(n):
        res = n // c + n // d - n // l
        return n - res

    print(calc(b) - calc(a - 1))


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>  
#include <set>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <cmath>
#include <cstdio>
#include<unordered_set>
#include <cstring>
#include <iomanip>
#include <list>
typedef long long ll;
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define MAX 1000000 
using namespace std;


int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;cin >> n;
  bool f = true;
  for (int i = 0; i < n; i ++) {
  	int x; cin >> x;
    if (x % 2 == 0) {
    	if (x % 3 != 0 && x % 5 != 0) f = false;
    }
  }
  if (f) cout << "APPROVED";
  else cout << "DENIED";

}    
                

Measured memory_bytes: 256
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-21 16:00:36
 **/

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

using int64 = long long;

template <class T>
using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << '}';
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

#pragma endregion kyomukyomupurin

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

  int n; cin >> n;
  vector<int> cnt(202020, 0);

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

  for (int i = 1; i <= n; ++i) {
    cout << cnt[i] << '\n';
  }

  return 0;
}

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

int main () {
  long long n;
  cin >> n;
  long long m = n / 11;
  long long ans = m * 11;
  if (ans >= n) {
    cout << m * 2 << endl;  
    return 0;  
  }  
  ans = m * 11 + 6;
  if (ans >= n) {
    cout << m * 2 + 1 << endl;  
    return 0;
  }
  cout << m * 2 + 2 << endl;
}

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

#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <climits>
using Graph = vector<vector<int>>;
const double PI = 3.14159265358979323846;



long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}


//約数をベクトル形式で返す
vector<int> vect_yakusuu(int n) {
	vector<int> ret;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			ret.push_back(i);
			if (i*i != n) ret.push_back(n / i);
		}
	}
	sort(begin(ret), end(ret));
	return ret;
}



int main() {

	long long ans;
	int a;
	string s, t;

	const int size = 200200;

	long long N, M, K;
	int A[size], B[size];
	long long sumA[size], sumB[size];


	cin >> N >> M >>K;

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

	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}

	sumA[0] = 0;
	sumB[0] = 0;

	int limA = 0;
	int limB = 0;
	
//sumA[i]にはi番目の本までの合計を入力(いつもと1つずれてる)
	for (int i = 1; i < N+1; i++) {
		sumA[i]=sumA[i-1]+A[i-1];
		if (sumA[i] <= K) {
			limA = i;
		}
	}

	for (int i = 1; i < M + 1; i++) {
		sumB[i] = sumB[i - 1] + B[i - 1];
		if (sumB[i] <= K) {
			limB = i;
		}
	}

	ans = 0;

	int sum;

	for (int i = 0; i < limB + 1; i++) {
		while (1) {
			if (sumA[limA] + sumB[i] <= K) {
				break;
			}
			limA--;
		}
		sum = limA + i;
		if (sum >= ans) {
			ans = sum;
		}
	}


	cout << ans << endl;

	cin >> ans;

	return 0;


}

Measured memory_bytes: 8324
#include <iostream>

using namespace std;

void No() {
    cout << "No" << endl;
    exit(0);
}

void Yes() {
    cout << "Yes" << endl;
    exit(0);
}

int main() {
    int n;
    cin >> n;
    int m[4] = {};
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        m[x & 0b11]++;
    }

    if (m[2] == 0) {
        if (m[1] + m[3] <= m[0] + 1) {
            Yes();
        } else {
            No();
        }
    } else {
        if (m[1] + m[3] <= m[0]) {
            Yes();
        } else {
            No();
        }
    }
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
inline long long read()
{
	long long x=0;bool f=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-'){f=1;ch=getchar();break;}ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
	if(f) x=-x;return x;
}
long long poww(long long a,long long b){long long c=1;while(b){if(b&1) c=c*a%mod;a=a*a%mod;b>>=1;}return c;}
long long n,k,dp[2010][2010],jc[5000000]={1},inv[5000000]={1};
long long C(long long x,long long y){return jc[x]*inv[y]%mod*inv[x-y]%mod;}
int main()
{
	for(long long i=1;i<=4000000;i++) jc[i]=jc[i-1]*i%mod;
	inv[4000000]=poww(jc[4000000],mod-2);
	for(long long i=3999999;i>=1;i--) inv[i]=(inv[i+1]*(i+1))%mod;
	n=read();k=read();
	if(k==1){puts("1");return 0;}
	dp[0][0]=1;
	for(long long i=1;i<=n;i++)
		for(long long j=0;j<=i;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j) dp[i][j]=(dp[i][j]+dp[i][j-1]*C(n-i+(n-j+1)*(k-1)-1,k-2)%mod)%mod;
		}
	printf("%lld",dp[n][n]*jc[n]%mod);
}

Measured memory_bytes: 92928
A,B,C,X,Y=map(int,input().split())
L=[]
L.append(A*X+B*Y)
for i in range(min(X,Y)+1):
    L.append(A*X+B*Y-A*i-B*i+2*C*i)
ans=min(L)
if max(X,Y)*2*C<ans:
    ans=max(X,Y)*2*C
print(ans)

Measured memory_bytes: 7048
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const lint INF = 1LL << 60;

const double PI = acos(-1);
const double Rad2Deg = 180.0 / PI;
const double Deg2Rad = PI / 180.0;

int main() {
    int M1, M2, D1, D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if (M1 != M2) cout << "1" << endl;
    else cout << "0" << endl;
    return 0;
}


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

using namespace std;
long long a[10001];
long long x;
int main(){
    cin >> x;
    long long n = pow(1e11,1.0/5);
    for (long long i = 1; i <= n; i++) a[i] = i*i*i*i*i;
    for (long long i = n + 1; i <= 2*n; i++){
        long long temp = i - n;
        a[i] = - (temp*temp*temp*temp*temp);
    }
    long long p , q;
    for (int i = 0; i <= 2*n; i++)
        for (int j = 0; j <= 2*n; j++)
            if (a[i] - a[j] == x){
                p = ((i <= n) ? i : -(i - n)) , q = ((j <= n) ? j : -(j - n));
                //cout << p << " " << q << "\n";
            }
    cout << p << " " << q;
    return 0;
}

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 1e9 )+7;
const int oo   = INT_MAX;

int n;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( ".in", "r", stdin );
    //freopen( ".out", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n ) {
    ll ans = 0;
    for( int i = 0; i < n; ++i ) {
      ll x; cin >> x;
      if( ans == 0 ) {
        ans = x;
      } else {
        ans = ans/__gcd( ans, x )*x;
      }
    }
    cout << ans << '\n';
  }

  return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		--a[i];
	}

	for (int i = 0; i < 1000; i++) {
		string s = to_string(i);
		if (s.length() != n) continue;

		bool ok = true;
		for (int j = 0; j < m; j++) {
			if (s[a[j]] - '0' != b[j]) {
				ok = false;
				break;
			}
		}

		if (ok) {
			cout << s << "\n";
			return 0;
		}
	}

	cout << "-1\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;

typedef pair<int, int> P;

const int MAX_N = 1005;
const int MAX_V = MAX_N*(MAX_N-1)/2;

vector<int> to[MAX_V];
int id[MAX_N][MAX_N];
// 自分と対戦相手の行う試合の頂点番号を返す
int toId(int i, int j){
    if (i > j) swap(i,j);
    return id[i][j];
}
bool visited[MAX_V];
bool calculated[MAX_V];
// vからスタートした時の最長経路を格納
int dp[MAX_V];
int dfs(int v){
    if (visited[v]) {
        // 計算済みではないのに訪問済みの場合は
        // ループが検出されたとして-1とする。
        if (!calculated[v]) return - 1;
        return dp[v];
    }
    visited[v] = true;
    dp[v] = 1;
    for (int u : to[v]){
        int res = dfs(u);
        // ループ検出された場合は-1を返して終了
        if (res == -1) return -1;
        dp[v] = max(dp[v], res+1);
    }
    calculated[v] = true;
    return dp[v];
}

int main(){
    int N; cin >> N;
    // N人がN-1回試合をする。
    // Aに入るのは対戦相手
    vector<vector<int>> A(N,vector<int>(N-1));
    rep(i,N){
        rep(j,N-1){
            cin >> A[i][j];
            A[i][j]--;
        }
    }
    int v = 0;
    // 1つの試合を一つの頂点とみなす。
    // i,jの組み合わせにすべて頂点番号を付与
    rep(i,N){
        rep(j,N){
            if (i < j){
                id[i][j] = v++;
            }
        }
    }

    rep(i,N){
        rep(j,N-1){
            // A[i][j]を対戦相手から
            // 頂点番号に書き換え
            A[i][j] = toId(i,A[i][j]);
        }
        // 頂点がN-1個あるので、N-2個辺を張る。
        // 逆向きに辺を張る(逆じゃなくともいいらしい)
        rep(j,N-2){
            to[A[i][j+1]].push_back(A[i][j]);
        }
    }
    int ans = 0;
    rep(i,v){
        int res = dfs(i);
        if (res == -1){
            puts("-1");
            return 0;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 41808
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + list(accumulate(a))
b = [0] + list(accumulate(b))
ans = 0
j = m
for i in range(n+1):
    if a[i] > k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)


Measured memory_bytes: 41208
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n,m; cin >>n >>m;
  printf("%s",(n==m)?"Yes":"No");
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stdio.h>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
using namespace std;

int main(){
	char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
	set <char> s;
	string a;
	int n;
	cin>>a;
	n=a.size();
	for(int i=0;i<n;i++){
		s.insert(a[i]);
	}
	if(s.size()!=n||a=="zyxwvutsrqponmlkjihgfedcba"){
		cout<<-1<<endl;
	}
	else{
		if(n<=25){
			for(int i=0;i<26;i++){
				if(s.count(alphabet[i])==0){
					cout<<a+alphabet[i]<<endl;
					return 0;
				}
			}
		}
		else{
			s.clear();
			int index;
			for(int i=0;i<n-1;i++){
				if(a[i]<a[i+1]){
					index=i;	
				}
				
			}
			for(int i=0;i<index;i++){
					s.insert(a[i]);
					cout<<a[i];			
			}
			for(int i=0;i<26;i++){
				if(s.count(alphabet[i])==0&&alphabet[i]>a[index]){
					cout<<alphabet[i];
					return 0;
				}
			}
			
			
		}
	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

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

  puts(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 ? "Possible"
                                                    : "Impossible");

  return 0;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>

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

using namespace std;

int n,T,talk[1000],call[1000],wait[1000];

bool solve(int p){
	priority_queue<int> pq;
	rep(i,p) pq.push(0);

	int n_cus=0;
	bool cus[1000]={};
	while(!pq.empty()){
		int t=-pq.top(); pq.pop();

		int i,next=T+1;
		for(i=0;i<n;i++) if(!cus[i]) {
			int total=call[i]+wait[i];
			if(t%total<=call[i]) break;
			else next=min(next,t+total-t%total);
		}
		if(i<n){
			n_cus++;
			cus[i]=true;

			if(t+talk[i]<=T) pq.push(-(t+talk[i]));
			else return false;

			if(n_cus==n) return true;
		}
		else{
			if(next<=T) pq.push(-next);
			else return false;
		}
	}

	return false;
}

int main(){
	for(;scanf("%d%d",&n,&T),n;){
		rep(i,n) scanf("%d%d%d",talk+i,call+i,wait+i);

		int p;
		for(p=1;!solve(p);p++);

		printf("%d\n",p);
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
    #include <vector>
    #include <algorithm>
    #include <string>
    #include <cmath>
    #include <iomanip>
    #include <queue>
    #include <climits> 
    #include <time.h>
     
    int main(void){
        long A,B,H,M;
        std::cin >> A >> B >> H >> M;
        double pi=3.14159265358979;
        double kakudo=(pi*M)/(double)30;
        double kakudo2=pi*(60*H+M)/(double)360;
        double kakudo3=std::abs(kakudo-kakudo2);
        if(2*pi-kakudo3>kakudo3){
            kakudo3=2*pi-kakudo3;
        }
        std::cout << std::setprecision(15) << std::sqrt(A*A+B*B-2*A*B*cos(kakudo3)) << std::endl;
        return 0;
    }

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

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

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

    x += A;
  }

  if (x >= H) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

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

	int N,M; lglg L; cin >> N >> M >> L;
	lglg adj[N+1][N+1];
	for (int i=1; i<=N; ++i) {
		for (int j=1; j<=N; ++j) {
			if (i==j) adj[i][j] = 0;
			else adj[i][j] = 1e17;
		}
	}
	for (int i=0; i<M; ++i) {
		int a,b,c; cin >> a >> b >> c;
		adj[a][b] = c;
		adj[b][a] = c;
	}
	for (int k=1; k<=N; ++k) {
		for (int i=1; i<=N; ++i) {
			for (int j=1; j<=N; ++j) {
				adj[i][j] = min(adj[i][j], adj[i][k]+adj[k][j]);
			}
		}
	}
	lglg newadj[N+1][N+1];
	for (int i=1; i<=N; ++i) {
		for (int j=1; j<=N; ++j) {
			if (i==j) newadj[i][j] = 0;
			else if (adj[i][j] <= L) newadj[i][j] = 1;
			else newadj[i][j] = 1e17;
		}
	}
	for (int k=1; k<=N; ++k) {
		for (int i=1; i<=N; ++i) {
			for (int j=1; j<=N; ++j) {
				newadj[i][j] = min(newadj[i][j], newadj[i][k]+newadj[k][j]);
			}
		}
	}
	int T; cin >> T;
	while (T--) {
		int s, t; cin >> s >> t;
		if (newadj[s][t]-1 > 1e14) cout << "-1\n";
		else cout << newadj[s][t]-1 << '\n';
	}
}

Measured memory_bytes: 1920
get_string(String) :-
  current_input(Input),
  read_string(Input, ' \n', '', _, String).

get_number(Number) :-
  get_string(String),
  number_string(Number, String).

main :-
  get_number(X1),
  get_number(X2),
  get_number(X3),
  get_number(X4),
  get_number(X5),
  Ans is 15 - X1 - X2 - X3 - X4 - X5,
  write(Ans).
:- main.

Measured memory_bytes: 8048
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 2つの文字の固まりを整数値と想定して読み込む
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }

    }
}


Measured memory_bytes: 26280
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}








int main(){
    int D; std::cin >> D;
    std::vector<int> c(26), t(D+1);
    std::vector<std::set<int>> days(26);
    for(int i(0); i < 26; ++i){
        days[i].emplace(0);
        days[i].emplace(D+1);
    }
    std::vector<std::vector<int>> s(D+1, std::vector<int>(26));
    for(int i(0); i < 26; ++i) std::cin >> c[i];
    for(int i(1); i <= D; ++i){
        long long mx(-LINF); int id(-1);
        for(int j(0); j < 26; ++j){
            std::cin >> s[i][j];
            auto itr(days[j].find(i));
            long long d1(*(--itr));
            if(chmax(mx, s[i][j] + c[j]*((d1-i)*(i-D) + i - d1))) id = j;
        }
        t[i] = id;
        days[t[i]].emplace(i);
    }

    long long v(0);
    for(int i(1); i <= D; ++i){
        long long dcr(0);
        for(int j(0); j < 26; ++j){
            auto itr(std::upper_bound(std::begin(days[j]), std::end(days[j]), i));
            dcr += c[j] * (i - *(--itr));
        }
        v += s[i][t[i]] - dcr;
    }
    int M(100000);
    srand((unsigned int)time(NULL));
    {
        int d, q;
        for(int qq(0); qq < M; ++qq){
            d = rand() % D + 1;
            q = rand() % 26;

            long long oldv(v);

            auto itr(days[t[d]].find(d));
            long long d1(*(--itr));
            itr = std::upper_bound(std::begin(days[t[d]]), std::end(days[t[d]]), d);
            long long d2((*itr)-1);
            v -= c[t[d]] * ((d1-d)*(d-d2) + d - d1);

            itr = std::lower_bound(std::begin(days[q]), std::end(days[q]), d);
            d1 = *(--itr);
            itr = std::upper_bound(std::begin(days[q]), std::end(days[q]), d);
            d2 = (*itr)-1;
            v += c[q] * ((d1-d)*(d-d2) + d - d1);

            v += s[d][q] - s[d][t[d]];
            if(oldv <= v){
                days[t[d]].erase(d);
                days[q].emplace(d);
                t[d] = q;
            }else{
                v = oldv;
            }
        }
    }
    for(int i(1); i <= D; ++i){
        std::cout << t[i] + 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3648
/*---------------------------------

 @Author:   Dicer
 @DateTime: 2019-05-12 15:12:22

---------------------------------*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
inline ll qpow(ll a,ll b,ll mod){ll res=1;while(b){if(b&1)res = (res*a)%mod;a=(a*a)%mod;b>>=1;}return res;}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int MAXN = 2e5 + 7;

int main(int argc, char const *argv[])
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	vector<int> v;
	int cnt = 1, head = s[0]-'0';
	for(int i = 1; i < n; ++i){
		if(s[i] == s[i-1])	cnt++;
		else{
			if(head)	v.push_back(cnt);
			else	v.push_back(-cnt);
			cnt = 1;
			head = s[i]-'0';
		}
	}
	if(head)	v.push_back(cnt);
	else	v.push_back(-cnt);
	// for(int p: v)	cout << p << endl;
	n = v.size();
	int i = 0, j = 0, cur = 0, ans = 0, sum = 0;
	while(j < n){
		if(v[j] < 0){
			cur++;
			sum -= v[j];
		} else	sum += v[j];
		while(cur > k){
			if(v[i] < 0)	cur--;
			sum -= abs(v[i]);
			i++;
		}
		ans = max(ans, sum);
		j++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static int MOD = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = 1LL << 31;
const static int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    cin >> a >> b;
    if ((a + b) % 2 == 0) cout << (a + b) / 2 << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
if a == 1:
    if b == 2:
        print(3)
    else:
        print(2)
elif a == 2:
    if b == 1:
        print(3)
    else:
        print(1)
elif a == 3:
    if b == 1:
        print(2)
    else:
        print(1)

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

using namespace std;

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

	for(int i = 1; i <= 10; i++) {
		if(1000*i >= N) {
			cout << 1000*i-N << endl;
			break;
		}
	}
	return 0;
}

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

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

    int numOfColor = 0;
    if (a == b && b == c) {
        numOfColor = 1;
    } else if (a != b && a != c && b != c) {
        numOfColor = 3;
    } else {
        numOfColor = 2;
    }

    cout << numOfColor << endl;
    
    return 0;
}

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

int main(){
    int N, M, X;
    cin >> N >> M >> X;
    int A[110];
    for(int i = 0; i < M; ++i) cin >> A[i];
    int plus = 0;
    int minus = 0;
    for(int i = X; i <= N; ++i){
        for(int j = 0; j < M; ++j){
            if (i == A[j]) plus += 1;
        }
    }
    for(int i = X; i >= 0; --i){
        for(int j = 0; j < M; ++j){
            if (i == A[j]) minus += 1;
        }
    }
    if(plus >= minus) cout << minus << endl;
    else  cout << plus << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<iostream>
using namespace std;
int main(){
	int n,ans=0,m;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>m;if(m%2==1)ans++;
	}
	if(ans%2==1)cout<<"NO";
	else cout<<"YES";
	return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    vec a(N); rep(i, N) cin >> a[i];
    int res=0;
    rep(i, N){
        Rep(j, i+1, N){
            res = max(res, abs(a[i]-a[j]));
        }
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

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

  vector<int>a(n);
  rep(i, n) cin >> a[i];
  ll sum = 0;
  rep(i, n) sum += a[i];
  set<ll> candidates;
  for (int i = 1; i*i <= sum; i++) {
    if (sum%i == 0) {
      candidates.insert(i);
      candidates.insert(sum/i);
    }
  }
  ll ans = 1;
  for (ll x : candidates) {
    ll need;
    {
      vector<ll> r(n);
      rep(i, n) r[i] = a[i]%x;
      sort(r.begin(), r.end());
      ll B = 0;
      rep(i, n) B += x-r[i];
      ll A = 0;
      need = 1e18;
      rep(i, n) {
        A += r[i];
        B -= x-r[i];
        need = min(need, max(A, B));
      }
    }
    if (need <= k) ans = max(ans, x);
  }
  cout << ans << endl;
  return 0;
} 

Measured memory_bytes: 3680
import numpy as np

n, k = map(int, input().split())
xs = np.array([0] + list(map(int, input().split())))

ps = np.clip(xs, 0, np.inf).astype(np.int64)
ns = -np.clip(xs, -np.inf, 0).astype(np.int64)
ps_cumsum = np.cumsum(ps)
ns_cumsum = np.cumsum(ns)

compromise = min(min(ps_cumsum[i+k]-ps_cumsum[i] for i in range(n-k+1)), min(ns_cumsum[i+k]-ns_cumsum[i] for i in range(n-k+1)))
print(ps_cumsum[-1] - compromise)


Measured memory_bytes: 23204
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

a,b = inpl()
# print(str(a) + str(b))
if math.sqrt(int(str(a) + str(b))).is_integer(): 
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <stack>
#include <queue>

using namespace std;
#define Fill(a, b) memset(a, b, sizeof(a))
#define Debug(x) cout << #x << "=" << (x) << endl;
typedef long long LL;
const LL inf = 1LL << 61;
const LL mod = 1000000007;
#define DEBUG
#ifdef DEBUG
#endif
const int maxn = 2e5+10;


map<int, int> mymap;
int main()
{
    std::ios::sync_with_stdio(false);
    int n, m, d;
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
    	scanf("%d", &d);
    	mymap[d]++;
    }
    scanf("%d", &m);
    for(int i = 0; i < m; i++)
    {
    	scanf("%d", &d);
    	if(mymap[d]==0)
    	{
    		puts("NO");
    		return 0;
    	}
    	mymap[d]--;
    }
    puts("YES");






















    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
const int N=2000000;
int n,a[N+1],k,b[N+1];
int main()
{
	cin>>k>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	b[1]=k-a[n]+a[1];
	for(int i=2;i<=n;i++)b[i]=b[i-1]+a[i]-a[i-1];
	//for(int i=1;i<=n;i++)cout<<b[i]<<" ";
	//cout<<endl;
	int sum=0,sum2=0x7fffffff;
	for(int i=1;i<=n;i++)
	{
		//cout<<sum2<<' ';
		sum2=min(b[i]+b[n]-b[i+1],sum2);
	}
//	cout<<endl;
//	cout<<b[n]-b[1]<<endl<<sum2<<endl;
	cout<<min(b[n]-b[1],sum2);
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int i, j, x, y, z, r, H, W;
	cin >> W >> H >> x >> y >> r;
	if (W >=x + r&&x >= 0 && y >= 0 && H >= y + r) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}

Measured memory_bytes: 3064
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

bool isPal(string s){
    int n = s.length();
    int b = 0, e = n-1;
    int flag = 0;
    while (b <= e){
        if (s[b] != s[e]){
            flag = 1;
            break;
        }
        else {
            b++;
            e--;
        }
    }
    return !flag;
}

int main(){
    string s;
    getline(cin, s);
    int n = s.length();
    string s1 = s.substr(0, (n-1)/2);
    string s2 = s.substr((n+1)/2, (n-1)/2);
    if (isPal(s)&&(isPal(s1)&&(isPal(s2)))) puts("Yes");
    else puts("No");
    return 0;
}




Measured memory_bytes: 256
n=int(input())
num=[0]+[int(i)  for i in input().split()]

ans=[]
for i in range(n,0,-1):
  cnt,j=0,2
  while i*j<=n:
    cnt+=num[i*j]
    j+=1
  if cnt%2==num[i]:
    num[i]=0
  else:
    num[i]=1
    ans.append(i)
print(len(ans))
print(*ans)

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

using namespace std;

int main(){
        char x, y;
        cin>>x>>y;
        if(x<y){
                cout<<"<"<<endl;
        }
        else if(x==y){
                cout<<"="<<endl;
        }
        else{
                cout<<">"<<endl;
        }
        return 0;
}


Measured memory_bytes: 256
n=int(input());
ans=0;
p=[0]*22222;
for w,s,v in sorted([list(map(int,input().split()))for _ in[0]*n],key=lambda a:a[0]+a[1]):
 for j in range(s,-1,-1):
  p[j+w]=max(p[j+w],p[j]+v);
  ans=max(ans,p[j+w]);
print(ans)


Measured memory_bytes: 42604