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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line


const int mod = 1e9+7;
int main()
{
	int N;
	cin >> N;
	vector<int> t(N), a(N);
	rep(i,N) cin >> t[i];
	rep(i,N) cin >> a[i];

	rep(i,N-1) {
		if(t[i] > t[i+1] || a[i] < a[i+1]){
			cout << 0 << endl;
			return 0;
		}
	}
	if(t[N-1] != a[0]){
		cout << 0 << endl;
		return 0;
	}

	vector<P> left(N);
	vector<P> right(N);
	int m = 0;
	map<int,int> rock;
	rep(i,N){
		int l, r;
		if(t[i] > m){
			l = r = t[i];
			m = t[i];
			rock[i] = m;
		} else {
			l = 1;
			r = m;
		}
		left[i] = P(l,r);
	}
	m = 0;
	for(int i = N-1; i>=0; i--){
		int l, r;
		if(a[i] > m){
			l = r = a[i];
			m = a[i];
			rock[i] = m;
		} else {
			l = 1;
			r = m;
		}
		right[i] = P(l,r);
	}
	ll ans = 1;
	rep(i,N){
		// 山が確定しているときに、矛盾している記録があったらダメ
		if(rock[i]){
			if(left[i].second < rock[i] || right[i].second < rock[i]){
				//debug(rock[i]);
				cout << 0 << endl;
				return 0;
			}
		}
		int l = max(left[i].first,right[i].first);
		int r = min(left[i].second, right[i].second);
		ans *= (r-l + 1);
		ans %= mod;
	}
	cout << ans << endl;
}


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

int main()
{
    int N, A;
    int buka[2*100000+1];
    int i;
    cin >> N;
    for(i = 1; i <= N; i++) {
        buka[i] = 0;
    }
    for(i = 0; i < N-1; i++) {
        cin >> A;
        buka[A] += 1;
    }
    for(i = 1; i <= N; i++) {
        cout << buka[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4372
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    
    string ans = "";
    rep(i,n) {
        ans += s1[i];
        ans += s2[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int             long long
#define ld              long double
#define fi              first
#define se              second
#define pb              push_back
#define mp              make_pair
#define mt              make_tuple
#define sq(a)           (a)*(a)
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define rep(i,a,b)      for(i=a;i<=b;i++)
#define Fo(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(x)          x.begin(),x.end()
#define rall(x)         x.rbegin(),x.rend()
#define sortall(x)      sort(all(x))
#define sortrall(x)     sort(rall(x))
#define clr(x)          memset(x,0,sizeof(x))
#define tr(it, a)       for(auto it=a.begin();it!=a.end();it++)
#define pii             pair<int,int>
#define mk(arr,n,type)  type *arr=new type[n];
#define vi              vector<int>
#define si              set<int>
#define usi             unordered_set<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define trailzrobits(x) __builtin_ctzll(x)
#define leadzrobits(x)  __builtin_clzll(x)
#define paritybits(x)   __builtin_parityll(x)
#define gcd             __gcd
#define lcm(x, y)       (x * y)/gcd(x,y)
#define mod             1000000007
#define endl            '\n'
#define PI              3.1415926535897932384626
#define inf             1e18
#define sp(x,y)         fixed<<setprecision(y)<<x
void __print(int32_t x) {cout<<x;}
void __print(int x) {cout<<x;}
void __print(ld x) {cout<<x;}
void __print(double x) {cout<<x;}
void __print(float x) {cout<<x;}
void __print(bool x) {cout<<(x?"true":"false");}
void __print(char x) {cout <<'\''<<x<<'\'';}
void __print(const char *x) {cout <<'\"' <<x<<'\"';}
void __print(const string &x) {cout<<'\"'<<x<<'\"';}
template<typename T,typename V>     void __print(const pair<T,V> &x) {cout<<'{';__print(x.first);cout<<',';__print(x.second);cout<<'}';}
template<typename T>                void __print(const T &x) {int f=0;cout<<'{';for(auto &i:x)cout<<(f++?",":""),__print(i);cout<<"}";}void _print(){cout<<"]\n";}
template <typename T,typename... V> void _print(T t, V... v) {__print(t);if(sizeof...(v))cout<<", ";_print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_print(x)
#else 
#define dbg(x...)
#endif
int power(int base,int exp) {int res=1;base%=mod;while(exp>0){if(exp&1)res=(res*base)%mod;base=(base*base)%mod;exp=exp>>1;}return res;}
int inv(int x) {return power(x,mod-2)%mod;}
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++




const int N=1e6+6,M=N;
int i,j;

void solve() {
    
    int l,r,d; cin>>l>>r>>d;
    cout<<(r/d-(l-1)/d);
    
    
    
    
}




int32_t main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3560
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$X = $in->nextInt();
$A = $in->nextInt();
$B = $in->nextInt();
if ($B - $A <= 0) {
	$out->println('delicious');
}
else if ($B - $A <= $X) {
	$out->println('safe');
} else {
	$out->println('dangerous');
}

?>


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
struct UnionFind{
vector<int> par,depth,Size;
UnionFind(int n){
par.resize(n); depth.resize(n); Size.resize(n);
for(int i=0; i<n; i++){
par[i]=i;
depth[i]=0;
Size[i]=1;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
return par[x]=find(par[x]);
}
}
bool same(int x, int y){
return find(x)==find(y);
}
void unite(int x, int y){
x=find(x); y=find(y);
if(x==y) return;
if(depth[x]<depth[y]) swap(x,y);
if(depth[x]==depth[y]) depth[x]++;
par[y]=x;
Size[x]+=Size[y];
}
int size(int x){
return Size[find(x)];
}
};
int main(){
    int n,m,k;cin >> n >> m >> k;
    vector<int> g[n+1];
    vector<int> minus(n+1);
    UnionFind uf(n+1);
    for(int i=0;i<m;i++){
        int a,b;cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
        uf.unite(a,b);
    }
    for(int i=0;i<k;i++){
        int c,d;cin >> c >> d;
        if(uf.same(c,d)){
            minus[c]++;
            minus[d]++;
        }
    }
    for(int i=1;i<=n;i++){
        cout << uf.size(i)-1-g[i].size()-minus[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 8312
// #pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;
template <typename T = vii>
using vec = vector<T>;

const ll INF = 1e18, MOD = 1e9 + 7;

const int MAX = 1e6;

vec<> adj;
vll lazy, res;

void dfs(const int u = 0, const int p = -1, ll cur = 0) {
    cur += lazy[u];
    res[u] = cur;
    for (int v : adj[u]) {
        if (v == p) continue;
        dfs(v, u, cur);
    }
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);

    int n, q;
    cin >> n >> q;
    adj.resize(n);
    lazy.resize(n);
    res.resize(n);
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    while (q--) {
        int u, x;
        cin >> u >> x;
        u--;
        lazy[u] += x;
    }
    dfs();
    for (ll e : res) {
        cout << e << ' ';
    }
    cout << '\n';
}

Measured memory_bytes: 25856
s = input()
q = int(input())
fstr = []
bstr = []
bstr.extend(s)


sta = 0
for i in range(q):
  buff = input()
  if(buff[0] == "2"):
    tmp = buff[4]
    if(buff[2] == "2"):
      
      if(sta == 0):
        
        bstr.append(tmp)  
      else:
        fstr.append(tmp)
    else:
      if(sta == 1):
        bstr.append(tmp)  
      else:
        fstr.append(tmp)
  else:
    if(sta == 0):
      sta = 1
    else:
      sta = 0

fstr.reverse()
fstr.extend(bstr)
if(sta == 1):
  fstr.reverse()

print(''.join(fstr))

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

using namespace std;

int main() {
  int a[3] = {0};

  cin >> a[0] >> a[1] >> a[2];
  sort(a, a + 3);

  if (a[0] + a[1] == a[2])
    cout << "Yes\n";
  else
    cout << "No\n";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
	ll n,c; cin>>n>>c;
	vector<ll> x(n+2),v(n+1);
	vector<ll> a(n+1),b(n+1),g(n+1);
	x[0]=v[0]=0;
	x[n+1]=c;
	a[0]=b[0]=g[0]=0;
	for(ll i=1;i<=n;i++) {
		cin>>x[i]>>v[i];
		a[i]=a[i-1]+v[i]-(x[i]-x[i-1]);
		g[i]=(max(a[g[i-1]],a[i])==a[g[i-1]])?g[i-1]:i;
	}
	for(ll i=1;i<=n;i++){
		b[i]=b[i-1]+v[n+1-i]-(x[n+2-i]-x[n+1-i]);
	}

	ll ans=0;
	for(ll i=0;i<=n;i++) {
		ll best=g[n-i];
		ll temp;
		temp=a[best]+(b[i]-(c-x[n+1-i]));
		ans=max(temp,ans);
	}
	for(ll i=1;i<=n;i++) {
		g[i]=(max(b[g[i-1]],b[i])==b[g[i-1]])?g[i-1]:i;
	}
	for(ll i=0;i<=n;i++) {
		ll best=g[n-i];
		ll temp;
		temp=b[best]+(a[i]-x[i]);
		ans=max(temp,ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 4224
let a = read_line ()
let b = read_line ()
let c = read_line ()

let f s =
  let len = String.length s in
  if len = 0 then None
  else Some (s.[0], String.sub s 1 (len - 1))

let rec main who a' b' c' =
  match who with
  | 'a' ->
    (match f a' with | None -> "A" | Some (x, s) -> main x s b' c')
  | 'b' -> 
    (match f b' with | None -> "B" | Some (x, s) -> main x a' s c')
  | _ ->  
    (match f c' with | None -> "C" | Some (x, s) -> main x a' b' s)


let () = print_endline (main 'a' a b c)

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

int main() {
  int n;
  cin >> n;
  map<string, int> s{};
  int max_el = 0;
  rep(i,n) {
    string x;
    cin >> x;
    if (s.count(x)) {
      s[x] += 1;
    } else {
      s.insert(std::make_pair(x,1));
    }
    max_el = max(s[x], max_el);
  }
  
  for (auto i = s.begin(); i != s.end(); ++i) {
    if (i->second == max_el) {
      cout << i->first << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main() {
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans=0;
    if(a>=k) {
        ans=k;
    }
    else if(a<k&&k<=a+b) {
        ans=a;

    }
    else {
        ans=a-(k-a-b);
    }
    cout <<ans<<endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,a,b;
  cin >> n >> a >> b;

  ll diff = abs(a-b);
  ll ans = diff/2;
  if(diff%2==1)
    ans += min(min(a, b)-1, n-max(a,b))+1;
  cout << ans << endl;
}


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

using namespace std;

const int maxn = 100;

int n,m;
char a[maxn][maxn];

int main() {
   // freopen("out.txt","w",stdout);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m;
    cout<<maxn<<" "<<maxn<<endl;
    int ei=-1;
    for (int i=0;i<maxn;i++)
        for (int j=0;j<maxn;j++) a[i][j]='.';
    for (int i=0;i<maxn;i++) {
        if (ei!=-1) break;
        for (int j=0;j<maxn;j++) {
            if (i%2==0 && j%2==0) {
                if (m>1) {
                    a[i][j]='#';
                    m--;
                } else ei = i+1;
            } else a[i][j]='.';
        }
    }
    for (int i=ei+1;i<maxn;i++) {
        for (int j=0;j<maxn;j++) {
            if ((i-ei-1)%2==1 && j%2==1) {
                if (n>1) {
                    a[i][j]='.';
                    n--;
                } else a[i][j]='#';
            } else a[i][j]='#';
        }
    }
    for (int i=0;i<maxn;i++) {
        for (int j=0;j<maxn;j++) cout<<a[i][j];
        cout<<endl;
    }
}


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

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

    vector<vector<int>> alphabet(26);
    for(int i=0; i<s.length(); i++){
        alphabet[s[i] - 'a'].push_back(i);
    }

    long long int ans = 0;
    int current = 0;
    for(int i=0; i<t.length(); i++){
        //cout << i << " : s[" << current << "] = " << s.substr(current) << endl;
        if(alphabet[t[i] - 'a'].size() == 0){
            cout << -1 << endl;
            return 0;
        }

        auto pos = lower_bound(alphabet[t[i] - 'a'].begin(), alphabet[t[i] - 'a'].end(), current);
        if(pos == alphabet[t[i] - 'a'].end()){
            ans += s.length();
            current = 0;
        }
        
        //cout << *lower_bound(alphabet[t[i] - 'a'].begin(), alphabet[t[i] - 'a'].end(), current) << endl;
        if(i == t.length() - 1){
            ans += *lower_bound(alphabet[t[i] - 'a'].begin(), alphabet[t[i] - 'a'].end(), current) + 1;
        }
        current = *lower_bound(alphabet[t[i] - 'a'].begin(), alphabet[t[i] - 'a'].end(), current) + 1;
        //cout << ans << ", " << current << endl;
    }
    cout << ans << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> B(N);
    for(int i=0;i<N-1;i++){
        cin >> B[i];
    }
    int res = 0;
    for(int i=0;i<N;i++){
        if(i==0){
            res += B[i];
        }else if(i==N-1){
            res += B[i-1];
        }else{
            res += min(B[i-1], B[i]);
        }
    }
    cout<<res<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <limits.h>
#include <map>
#include <numeric>

namespace test {
	std::string to_string (char val) {
		return std::string (1, val);
		// return std::string{val};
	}
	//if( str.find ("r") != string::npos)
}

using namespace std;
typedef long long int llint;

int main (void) {
	int a,b,c; cin >> a >> b >> c;
	cout << a + b + c - max( max(a,b) , c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n,p;
  int w[SIZE], b[SIZE];
  ll sumb = 0, sumw = 0;
  pair<ll,int> member[SIZE]; 
  
  scanf("%d%d",&n,&p);

  for(int i=0;i<n;i++){
    scanf("%d%d",w+i, b+i);
    sumb += b[i];
    
    member[i] = {(ll)w[i] * (100-p) + (ll)b[i] * p, i};
  }

  sort(member, member+n);

  
  for(int i=n-1;i>=0;i--){
    int id = member[i].second;
    sumb -= b[id];
    sumw += w[id];

    if(sumw * 100 >= p * (sumw + sumb)){
      printf("%d\n",n-i);
      break;
    }
  }
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long


int main() {
  int a;
  cin >> a;
 
  cout << 48-a << endl;

  
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <iterator>
using namespace std;

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

typedef long long ll;

int main() {
    string s;
    cin >> s;
    int n = s.size() - 1;
    for (int i = 0; i < pow(2, n); i++) {
        int ans = s[0] - '0';
        for (int j = 0; j < 3; j++) {
            if ((i / (1 << j)) % 2 == 0) ans -= (s[j + 1] - '0');
            else ans += s[j + 1] - '0';
        }
        if (ans == 7) {
            for (int j = 0; j < 3; j++) {
                cout << s[j];
                if ((i / (1 << j)) % 2 == 0) cout << "-";
                else cout << "+";
            }
            cout << s[3];
            cout << "=7" <<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
n = int(input())
job = {}
for i in range(n):
    a, b = map(int, input().split())
    job[i] = (a, b)
job = sorted(job.items(), key=lambda k: k[1][1], reverse=True)
t = 1000000000
for k, v in job:
    c, d = v
    t = min(t, d) - c
if t < 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 62976
#include <iostream>

using namespace std;

int main() {
    int N, M, P;
    while (cin >> N >> M >> P) {
        if (N == 0 && M == 0 && P == 0) break;
        int nocards = 0;
        int player[N];
        for (int i = 0; i < N; i++) {
            cin >> player[i];
            nocards += player[i];
        }
        if (player[M-1] == 0) cout << 0 << endl;
        else cout << nocards * (100 - P) / player[M-1] << endl;
    }
    return 0;
}
            

Measured memory_bytes: 0
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextLong();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) a[i] = sc.nextInt();
		long [] sum = new long[n + 1];
		for(int i = 0; i < n; i++) sum[i + 1] = (sum[i] + a[i]) % m;
		Map<Long, Integer> map = new HashMap<>();
		for(int i = 0; i < n + 1; i++) {
			if(map.containsKey(sum[i])) map.put(sum[i], map.get(sum[i]) + 1);
			else map.put(sum[i], 1);
		}
		long ans = 0;
		for(long key : map.keySet()) {
			if(map.get(key) >= 2) {
				long x = map.get(key);
				ans += x * (x - 1) / 2;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 59348
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>

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

using namespace std;

typedef long long ll;

int main(int argc, char const *argv[])
{
  int m, k;
  cin >> m >> k;
  if (k == 0)
  {
    REP(i, pow(2, m))
    cout << i << " " << i << " ";
    return 0;
  }
  if (k < pow(2, m) && m >= 2)
  {
    REP(i, pow(2, m))
    if (i != k)
      cout << i << " ";
    cout << k << " ";
    for (int i = pow(2, m) - 1; i >= 0; i--)
      if (i != k)
        cout << i << " ";
    cout << k << " ";
    return 0;
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 1792
import sys

def suicide(sentence):
    string = ''
    for c in sentence:
        string += dic[c]
    lis = []
    while string:
        lis.append(string[:5])
        string = string[5:]
    for i in range(5-len(lis[-1])):
        lis[-1] = lis[-1] + '0'
    absolutely_fantastic(lis)
        
def absolutely_fantastic(lis):
    ans = ''
    for v in lis:
        a = 0
        for i in range(5):
            a += 2**(4-i)*int(v[i])
        else:
            ans += mathematics[a]
    else:
        print ans

dic = {' ':'101', "'":'000000', ',':'000011', '-':'10010001', '.':'010001', '?':'000001', 'A':'100101', 'B':'10011010', 'C':'0101',
       'D':'0001', 'E':'110', 'F':'01001', 'G':'10011011', 'H':'010000', 'I':'0111', 'J':'10011000', 'K':'0110',
       'L':'00100', 'M':'10011001', 'N':'10011110', 'O':'00101', 'P':'111', 'Q':'10011111', 'R':'1000',
       'S':'00110', 'T':'00111', 'U':'10011100', 'V':'10011101', 'W':'000010', 'X':'10010010', 'Y':'10010011', 'Z':'10010000'}

mathematics = {0:'A', 1:'B', 2:'C', 3:'D', 4:'E', 5:'F', 6:'G', 7:'H', 
               8:'I', 9:'J', 10:'K', 11:'L', 12:'M', 13:'N', 14:'O', 15:'P', 
               16:'Q', 17:'R', 18:'S', 19:'T', 20:'U', 21:'V', 22:'W', 23:'X',
               24:'Y', 25:'Z', 26:' ', 27:'.', 28:',', 29:'-', 30:"'", 31:'?',}

if __name__ == '__main__':
    for line in sys.stdin:
        suicide(line.rstrip('\n'))

Measured memory_bytes: 4348
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()
#define MP make_pair

int main() {
	string s;
	bool a = {};
	cin >> s;
	REPO(i, s.size() - 1) if (s[i] != '9') a = true;
	if (a) cout << (s.size() - 1) * 9 + s[0] - '0' - 1 << endl;
	else cout << (s.size() - 1) * 9 + s[0] - '0' << endl;
}

Measured memory_bytes: 256
def bb
    n,t = gets.chomp.split(/\s/).map{|x| x.to_i}

    im = -1
    cm = 1000
    tm = 1000
    for i in 1..n
        ci,ti = gets.chomp.split(/\s/).map{|x| x.to_i}
        next if ti > t

        if ci <= cm# and ti <= tm
            im = i
            cm = ci
            tm = ti
            #p i
        end
    end

    puts im == -1 ? 'TLE' : cm
end

bb

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

// #define int long long
#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 SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

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 pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(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] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll q; cin>>q;
  vll s(100005);
  reps(i,100000){
    s[i]=s[i-1];
    if(i%2) if(is_prime(i)&&is_prime((i+1)/2)) s[i]++;
  }
  rep(i,q){
    ll l,r; cin>>l>>r;
    cout<<s[r]-s[l-1]<<endl;
  }
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> x;
    map <ll,ll> s;
    map <ll,ll> :: iterator itr;
    while(1){
        a = pow(i,5);
        b = -1*a;
        if(i == 0){
            s.insert({0,0});
        }
        else{
            s.insert({a,i});
            s.insert({b,i*(-1)});
        }
        itr = s.find(b+x);
        if(itr != s.end()){
            cout << itr -> second << " " << -1*i;
            return 0;
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 4100
#include <bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define PI acos(-1.0)

typedef long long ll;
const int maxn=110;
char s[maxn][maxn];

int main()
{
    int n,m;
    cin >> n >> m;
    for(int i=0;i<50;i++)
        for(int j=0;j<100;j++)
            s[i][j]='#';
    for(int i=50;i<100;i++)
        for(int j=0;j<100;j++)
            s[i][j]='.';
    for(int i=0;i<n-1;i++)
        s[i/50*2][i%50*2]='.';
    for(int i=0;i<m-1;i++)
        s[100-i/50*2-1][i%50*2]='#';
    printf("100 100\n");
    for(int i=0;i<100;i++)
        printf("%s\n",s[i]);
    return 0;
}


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

struct point{
    int num;
    int a;
    int b;
};

int main(){
    int H,W,D;cin>>H>>W>>D;
    vector<point> S(H*W+1);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            int c;cin>>c;
            S[c].num=c;
            S[c].a=i;
            S[c].b=j;
        }
    }
    vector<int> dis(H*W-D+1);
    vector<int> T(H*W+1,0);
    for(int i=1;i<=H*W-D;i++){
        dis[i]=abs(S[i+D].a-S[i].a)+abs(S[i+D].b-S[i].b);
    }
    for(int i=1;i<=H*W;i++){
        if(i<=D) T[i]=0;
        else T[i]=T[i-D]+dis[i-D];
    }
    int Q;cin>>Q;
    for(int i=0;i<Q;i++){
        int l,r;cin>>l>>r;
        cout<<T[r]-T[l]<<endl;
    }
}



Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<stack>
using namespace std;
int n;

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }
    }
    cout<<"-1"<<" "<<"-1"<<endl;
	return 0;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main(){
	int n;

	cin >> n;
	int ans = 0;
	for(int i = 0;i < n;i++){
		long long int ai;
		cin >> ai;
		while(ai % 2 == 0){
			ai /= 2;
			ans++;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    bool d = (a+b+c)>=22;
    if(d) cout << "bust";
    else cout << "win";
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

sum_pair = 0

for a in range(A + 1):
    for b in range(B + 1):
        c = (X - a * 500 - b * 100) / 50
        if c >= 0 and c <= C:
            sum_pair += 1

print(sum_pair)


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, k;
int a[5252], dp[5252];

bool is_need(int mid){
	REP(i, k){
		dp[i]=0;
	}
	int cnt=0;
	dp[0]=1;
	REP(i, n){
		if(i==mid){
			continue;
		}
		FORR(j, 0, k){
			if(dp[j] && j+a[i]<k){
				dp[j+a[i]]=1;
			}
		}
	}
	// DEBUG(mid);
	// REP(i, k){
	// 	DEBUG(dp[cnt][i]);
	// }
	FOR(i, max(0, k-a[mid]), k){
		if(dp[i]){
			return true;
		}
	}
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	// cout<<setprecision(10)<<fixed;
	cin>>n>>k;
	REP(i, n){
		cin>>a[i];
	}
	if(n==1){
		cout<<(a[0]>=k ? 0 : 1)<<'\n';
		return 0;
	}
	sort(a, a+n);
	int lb=-1, ub=n;
	while(ub-lb>1){
		int mid=(lb+ub)/2;
		if(is_need(mid)){
			ub=mid;
		}
		else{
			lb=mid;
		}
	}
	cout<<ub<<'\n';
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

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

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int x = in.nextInt(), y = in.nextInt();
			out.println(x + y/2);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public int[] nextIntArray1Index(int n) {
			int[] res = new int[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public long[] nextLongArray1Index(int n) {
			long[] res = new long[n + 1];
			for (int i = 0; i < n; i++) {
				res[i + 1] = nextLong();
			}
			return res;
		}

		public double[] nextDoubleArray(int n) {
			double[] res = new double[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextDouble();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define lb(arr,n,x) lower_bound(arr,arr+n,x)-arr
#define ub(arr,n,x) upper_bound(arr,arr+n,x)-arr
#define endl "\n"
#define PI 3.14159265358979323846  /* pi */
#define sqr(x) (x)*(x)
#define sign(x) (x>0)-(x<0)
#define is_poweroftwo(n) (n&& !(n&(n-1)))
#define all(v)  ((v).begin()),((v).end())
#define degreesToRadians(angleDegrees) (angleDegrees * PI / 180.0) // Converts degrees to radians.
#define radiansToDegrees(angleRadians) (angleRadians * 180.0 / PI) // Converts radians to degrees.
#define int long long
#define debug(x) cout<<(#x)<<" is "<<(x)<<endl
#define AagLgaDe ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;
typedef long double ld;
 
//Calculation of (x^y)%mm
ll mod_exp(ll x,ll y,ll mm)
{
    if(y==0)
        return(1);
    else if(y%2==0)
        return(mod_exp((x*x)%mm,y/2,mm));
    else
        return((x*mod_exp((x*x)%mm,(y-1)/2,mm))%mm);
}
bool isPowerOfTwo(int n) 
{ 
   if(n==0) 
   return false;
   return (ceil(log2(n)) == floor(log2(n))); 
}
 
//int x1[]={+1,-1,+0,+0};
//int y1[]={+0,+0,+1,-1};
//int x2[]={+0,+0,+1,-1,-1,+1,-1,+1};
//int y2[]={-1,+1,+0,+0,+1,+1,-1,-1};
//int x3[]={-2,-2,-1,-1,+1,+1,+2,+2};
//int y3[]={-1,+1,-2,+2,-2,+2,-1,+1};
 
int solve()
{
	int n;
	cin>>n;
	
	vector<int> arr(n, 0);
	for(int i=0;i<n;i++)
		cin>>arr[i];
	// int ans=0;
	vector<int> dp(n, 0);
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++)
	{
		dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]), dp[i-2]+abs(arr[i-2]-arr[i]));
	}
	return dp[n-1];
 
}
 
signed main() {
  	AagLgaDe
    //int t;cin>>t;while(t--)
	    cout<<solve()<<endl;
 
 
return 0;
}

Measured memory_bytes: 4792
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

const int mod = 1e9+7;

long long inv[N];
long long fac[N];
long long finv[N];

void cominit(){
    fac[0] = fac[1] =1;
    finv[0] = finv[1] =1;
    inv[1] = 1;
    for(int i = 2; i < N; 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 nCr(long long n , long long r){
    if(n == r)
        return 1;
    if(r == 0)
        return 1;
    if(n < r)
        return 0;
    if(n < 0 || r < 0)
        return 0;
    return fac[n] * (finv[r] * finv[n - r] % mod) %mod;
}

void add_self(int & ans , int add){
    long long tmp = ans;
    tmp += add;
    tmp %= mod;
    ans = tmp;
}

int main(){
    cominit();
    int n , k;
    scanf("%d%d" , &n , &k);
    int ans = 0;
    for(int i = 0; i <= min(n-1 , k); i++){
        add_self(ans , nCr(n , i) * nCr(n - 1 , n - i - 1) % mod);
    }
    printf("%d\n" , ans);
}

Measured memory_bytes: 4992
/*
    Author:    DreamCat4er
    Created:   22.08.2020 18:20:37
*/
#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector <long long> a(n);
    for (long long &i : a)
        cin >> i;

    long long mx = a[0], ans = 0;
    for (int i = 1; i < n; ++i) {
        ans += max(0ll, mx - a[i]);
        mx = max(mx, a[i]);
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
                
    #ifdef _LOCAL
        int t;
        cin >> t;
        for (int _t = 0; _t < t; ++_t) {
            cout << "Case " << _t << " :\n";
            solve();
            cout << "\n";
        }
    #else
        solve();
    #endif // _LOCAL

    return 0;
}

Measured memory_bytes: 4680
N,K = map(int,input().split())
x = list(map(int,input().split()))
xp = [i for i in x if i >= 0]
xn = [i for i in x if i < 0]
xn.reverse()
lp = len(xp)
ln = len(xn)
if lp == 0:
    print(-xn[K-1])
    exit()
if ln == 0:
    print(xp[K-1])
    exit()
pc = min(K,lp)
pp = xp[pc-1]
if K>lp:
    nc = K-lp
    np = -xn[nc-1]
else:
    nc = 0
    np = 0
ans = pp + np + min(pp,np)
for i in range(pc-1):
    if nc == ln:
        break
    pp = xp[pc-i-2]
    np = -xn[nc]
    nc += 1
    ans = min(ans,pp + np + min(pp,np))
print(ans)

Measured memory_bytes: 20368
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int s = 0;

    int v[50];
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        int c;
        cin >> c;
        s += max(v[i] - c, 0);
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

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

int main()
{
    ll n,m;
    cin >> n >> m;
    cout << (n-1)*(m-1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n;
    string s;
    cin>>n>>s;
    bool flag = true;
    if(n%2==1) cout<<"No"<<endl;
    else{
        rep(i,0,n/2-1){
            if(s[i]!=s[n/2+i]){
                flag = false;
                break;
            }
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  string s, t; cin >> s >> t;
  int n = s.length();
  int m = t.length();
  if(n > m) {
    printf("GREATER");
  }
  else if(n < m) {
    printf("LESS");
  }
  else {
    if(s > t) {
      printf("GREATER");
    }
    else if(s < t) {
      printf("LESS");
    }
    else {
      printf("EQUAL");
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
#define INF (1<<29)
	
int main(){
	int n,p;
	int a[50];
	while(cin>>n>>p,p|n){
		int m = p;
		memset(a,0,sizeof(a));
		int i;
		for(i=0;;i=(i+1)%n){
			if(m){
				a[i]++;
				m--;
				if(a[i]==p)break;
			}else{
				if(a[i]){
					m += a[i];
					a[i]=0;
				}
			}
		}
		cout<<i<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = int(input())
    a = sorted(list(map(int, input().split())), reverse=True)
    ans = a[0]

    if n % 2 == 0:
        m = (n - 1) // 2
    else:
        m = (n - 2) // 2

    for i in range(m):
        ans += a[i + 1] * 2

    if n % 2 == 1:
        ans += a[m + 1]

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31244
import itertools 
import math
from functools import reduce


num = int(input())

def gcd_list(numbers):
        return reduce(math.gcd, numbers)

if num<=2:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.product(a_list, repeat=3))
    print(sum([gcd_list(x) for x in comb_list]))

else:
    a_list = [i for i in range(1,num+1)]
    comb_list = list(itertools.combinations_with_replacement(a_list, 3))
    test = sum([gcd_list(x) for x in comb_list])*3

    comb_list_dup = [[i, i, i] for i in a_list]
    duplica = sum([gcd_list(x) for x in comb_list_dup])*2

    comb_list_unique = list(itertools.combinations(a_list, 3))
    unique = sum([gcd_list(x) for x in comb_list_unique])*3
    print(test-duplica+unique)

Measured memory_bytes: 215140
#include <stdio.h>
#include <math.h>


typedef struct{
    double x,y;
}koch;

void kock(int,koch,koch);

int main()
{
    int a;
    koch p1,p2;

    p1.x = p1.y = p2.y = 0;
    p2.x = 100;

    scanf("%d",&a);

    printf("%lf %lf\n", p1.x, p1.y);
	kock(a,p1,p2);
	printf("%lf %lf\n", p2.x, p2.y);

    return 0;
}

void kock(int n,koch p1,koch p2)
{
    koch s,t,u;
    if(n==0) return;

    s.x = (2.0*p1.x + p2.x) / 3.0;
	s.y = (2.0*p1.y + p2.y) / 3.0;
	t.x = (p1.x + 2.0* p2.x) / 3.0;
	t.y = (p1.y + 2.0* p2.y) / 3.0;
	u.x = (t.x - s.x)*cos(M_PI / 3) - (t.y - s.y)*sin(M_PI / 3) + s.x;
	u.y = (t.x - s.x)*sin(M_PI / 3) + (t.y - s.y)*cos(M_PI / 3) + s.y;

    kock(n-1, p1, s);
    printf("%lf %lf\n",s.x,s.y);
    kock(n-1, s, u);
    printf("%lf %lf\n",u.x,u.y);
    kock(n-1, u, t);
    printf("%lf %lf\n",t.x,t.y);
    kock(n-1, t, p2);
}


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

int main() {
	string a, b;
	cin >> a >> b;
	if (a.size() < b.size()) {
		cout << "LESS" << endl;
	} else if (a.size() > b.size()) {
		cout << "GREATER" << endl;
	} else {
		for (int i = 0; i < a.size(); i++) {
			if (a[i] == b[i]) {
				continue;
			}
			if (a[i] < b[i]) {
				cout << "LESS" << endl;
			} else {
				cout << "GREATER" << endl;
			}
			return 0;
		}
		cout << "EQUAL" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
int a,b,c,d,e,f;
cin>>a>>b>>c>>d>>e>>f;
  cout<<a+b+c+d+e+f-min(min(a,b),min(c,d))-min(e,f)<<endl;
return 0;
}

Measured memory_bytes: 3092
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, h, w;
  cin >> n >> h >> w;
  int a = n - h == 0 ? 1 : n - h + 1;
  int b = n - w == 0 ? 1 : n - w + 1;
  cout << a * b << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		double W = 0;
		double H = 0;
		double x = 0;
		double y = 0;
		Scanner sc = new Scanner(System.in);
		W = Integer.parseInt(sc.next());
		H = Integer.parseInt(sc.next());
		x = Integer.parseInt(sc.next());
		y = Integer.parseInt(sc.next());
		int flag = 0;
		if (W / 2 == x && H / 2 == y)
			flag = 1;
		System.out.println(W * H / 2 + " " + flag);
		sc.close();
	}

}

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

int main(){
    int n, l; cin >> n >> l;
    int r = l + n - 1;
    int eaten = 0;
    if(l >= 0) eaten = l; if(r <= 0) eaten = r;
    int ans = (r+l)*(r-l+1)/2 -eaten;
    cout << ans << endl;
    return 0;
}


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

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

  vector<int> a(N);
  rep(i, N) cin >> a[i];

  int sum = 0;
  rep(i, N) sum += a[i];
  int avg = sum / N;

  int c1 = 0;
  rep(i, N) {
    int n = a[i] - avg;
    c1 += n * n;
  }

  int c2 = 0;
  rep(i, N) {
    int n = a[i] - (avg + 1);
    c2 += n * n;
  }

  cout << min(c1, c2) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=0;
    cin>>n;
    int i,a[n];
    for(i=0;i<n;i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        sum=sum+a[i];
        sum=sum-n;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256