akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    ll n; cin >> n;
    if(n==1) puts("Hello World");
    else{
        ll a,b; cin >> a >> b;
        cout << a+b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

#define int long long

using namespace std;

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

        vector<int> v(n, 0), w(n, 0);
        int ac = 0;
        int wa = 0;
        for(int i = 0; i < m; i++) {
                int p; cin >> p; p--;
                string s; cin >> s;
                if(v[p] == 1) {
                        continue;
                } else if(s == "AC" && v[p] == 0) {
                        v[p]++; 
                        ac++;
                } else {
                        w[p]++;
                        wa++;
                }
        }

        for(int i = 0; i < n; i++) {
                if(v[i] == 0 && w[i] > 0) {
                        wa -= w[i];
                }
        }

        cout << ac << " " << wa << endl;
        return 0;       
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long   // aaaaaaaaaaaaaaaaaa
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
template<typename T, typename U>ostream& operator << (ostream& os, pair<T, U>& pair_var)
{os << "(" << pair_var.first << ", " << pair_var.second << ")";return os;}
// head

int n,w,l,q,res;
int a[800][1000] = {};
int c[1000][1000] = {};
int dp[2020][2020] = {};
int hidari[2][2020] = {};
int wpos[2020][2020] = {};
int bpos[2020][2020] = {};
string s;
vector<pair<char,int> > vec;
signed main() {
	std::cin >>n;
	vec.resize(n*2);
	rep(i,0,2*n){
		std::cin >> vec[i].first >> vec[i].second;
		--vec[i].second;
	}
	rep(i,0,2*n){
		rep(j,i+1,2*n){
			if(vec[i].first != vec[j].first){
			if(vec[j].first == 'B'){
				if(vec[i].second>=0){
				bpos[vec[i].second][vec[j].second] += 1;}
			}
			else{
				if(vec[i].second>=0){
				wpos[vec[i].second][vec[j].second] += 1;}
			}	
			}
			else if(vec[i].second > vec[j].second){
				if(vec[j].first == 'B'){
					bpos[2010][vec[j].second] += 1;
				}
				else{
					wpos[2010][vec[j].second] += 1;
				}				
			}
		}
	}
	per(i,0,2011){
		per(j,0,2011){
			bpos[i][j] += bpos[i+1][j];
			wpos[i][j] += wpos[i+1][j];
		}
	}
	rep(i,0,2020){
		rep(j,0,2020){
			dp[i][j] =  1LL<<29;
		}
	}
	dp[0][0] = 0;
	rep(i,0,n+1){
		rep(j,0,n+1){
			dp[i+1][j] = min(dp[i+1][j],dp[i][j] + bpos[j][i]);
			dp[i][j+1] = min(dp[i][j+1],dp[i][j] + wpos[i][j]);
		}
	}
	std::cout << dp[n][n] << '\n';
}


Measured memory_bytes: 96512
#include <iostream>
#include <cmath>

using namespace std;

int main(){

	int m;
	
	cin>>m;

	while(m--){
			
		double amo, ma = -1.0;
		int y, n;
		
		cin >> amo >> y >> n;

		for(int k=0; k<n; ++k){
			
			bool mul;
			double tmp = amo, simbuf = 0;
			double rat, tesuu;
		
			cin >> mul >> rat >> tesuu;
			
			for(int a = 0; a < y; ++a){
				
				if(mul){
					tmp += floor(rat*tmp);
				}
				else{
					simbuf += floor(rat*tmp);
				}

				tmp -= tesuu;
			}

			ma = max(ma, tmp+simbuf);
		}
		
		cout << (int)(floor(ma)) << endl;
	}
	
	return 0;
}

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

using namespace std;

using int64 = long long;

vector<int> ReadIntVector(int n) {
  vector<int> xs(n);
  for (int i = 0; i < n; i++) cin >> xs[i];
  return xs;
}

int Sum(const vector<int>& xs) {
  int sum = 0;
  for (int x : xs) sum += x;
  return sum;
}

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

  int n;
  cin >> n;
  vector<int> xs = ReadIntVector(n);
  int sum = Sum(xs);
  int sum2 = 0;
  int answer = sum - sum2;
  for (int i = 0; i < n; i++) {
    sum -= xs[i];
    sum2 += xs[i];
    answer = min(answer, abs(sum - sum2));
  }
  cout << answer << endl;
}


Measured memory_bytes: 256
#include <cstdio>  
#include <iostream>  
#include <cstring>  
#include <string>  
#include <cmath>  
#include <algorithm>  
#include <cstdlib>  
#include <utility>  
#include <map>  
#include <stack>  
#include <set>  
#include <vector>  
#include <queue>  
#include <deque>  
#include <sstream>  
#include <bitset>
#include<bits/stdc++.h>      
using namespace std;
int main()
{
	int n,a;
	cin>>n>>a;
	if (n%500>a) cout<<"No";
	else
	cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

const int N = 2e5+5;
ll cmp1[N],cmp2[N];

int main()
{
   IOS;
   int n;
   cin >> n;
   rep(i,1,n)
   {
       ll x,y;
       cin >> x >> y;
       cmp1[i] = x+y;
       cmp2[i] = x-y;
   }
   sort(cmp1+1,cmp1+1+n);
   sort(cmp2+1,cmp2+1+n);
   cout << max(cmp1[n]-cmp1[1],cmp2[n]-cmp2[1]);
}


Measured memory_bytes: 6784
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  uint64_t n, k;
  cin >> n >> k;
  vector<int> a(n);
  cin >> a;

  for(auto & i: a) i %= 2;
  const uint64_t odd = count(begin(a), end(a), 1);
  DEBUG(a);
  DEBUG(odd);
  // uint64_t out = 1;

  uint64_t val = k == 0 ? 1 : odd;
  uint64_t out = val;
  for(uint64_t i = k + 2; i < odd + 1; i += 2)
  {
    val *= odd - i + 2;
    val /= i - 1;
    val *= odd - i + 1;
    val /= i;
    out += val;
  }

  for(uint64_t i = 0; i + odd < n; ++i)
    out *= 2;

  cout << out;
  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <stdio.h>
int N, M, Q, p, r, a, prv[200007], nxt[200007];
int main() {
	scanf("%d%d%d", &N, &M, &Q);
	for (int i = 0; i < N; i++) prv[i] = (i + N - 1) % N, nxt[i] = (i + 1) % N;
	for (int i = 0; i < M; i++) {
		scanf("%d", &a);
		for (int j = 0; j < a; j++) p = a % 2 ? prv[p] : nxt[p];
		nxt[prv[p]] = nxt[p], prv[nxt[p]] = prv[p];
		r = nxt[p], prv[p] = nxt[p] = -1, p = r;
	}
	for (int i = 0; i < Q; i++) scanf("%d", &a), puts(prv[a] != -1 ? "1" : "0");
	return 0;
}

Measured memory_bytes: 4152
#include<cstdio>
#include<algorithm>

using namespace std;

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

struct edge{
	int from, to, cost;
};

int main(){
	int n, m; scanf("%d %d", &n, &m);
	int d[100][100]; edge e[1000];
	fill(d[0], d[100], INF);
	rep(i, n) d[i][i] = 0;
	rep(i, m){
		int a, b, c; scanf("%d %d %d", &a, &b, &c);
		a--; b--; d[a][b] = d[b][a] = c; e[i] = (edge){a, b, c};
	}
	rep(k, n) rep(i, n) rep(j, n) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
	int res = 0;
	rep(i, m){
		int t = 1;
		rep(j, n) if(d[j][e[i].from] + e[i].cost == d[j][e[i].to]) t = 0;
		if(t) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(lambda x: int(x) - 1, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
for i in range(N):
    ans += B[A[i]]
    if i < N - 1 and A[i + 1] == A[i] + 1:
        ans += C[A[i]]
print(ans)


Measured memory_bytes: 3060
from itertools import combinations_with_replacement
n,m,q = map(int, input().split())

x = list(combinations_with_replacement(range(1,m+1),n))
y = []
for _ in range(q):
  a,b,c,d = map(int, input().split())
  y.append([a,b,c,d])
  
ans = 0
for i in x:
  k = 0
  for j in y:
    if i[j[1]-1] - i[j[0]-1] == j[2]:
      k += j[3]
  ans = max(ans,k)
print(ans)

Measured memory_bytes: 21636
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())
b = [int(input()) for _ in range(N)]

L = [[0] * 3 for _ in range(3)]
for i in range(3):
  for j in range(3):
    for k in b:
      if A[i][j] == k:
        L[i][j] = 1

flag = False
if L[0][0] & L[1][1] & L[2][2]:
  flag = True
if L[0][2] & L[1][1] & L[2][0]:
  flag = True
for i in range(3):
  if L[i][0] & L[i][1] & L[i][2]:
    flag = True
  if L[0][i] & L[1][i] & L[2][i]:
    flag = True

if flag:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

signed main(void) {
    int n;
    cin >> n;
    int m = 1;
    rep(i,n)m *= 2;
    vi a(m);
    rep(i,m)cin >> a[i];
    sort(all(a));
    vi done;
    done.push_back(a.back());
    a.back() = -1;
    int t = 1;
    rep(i,n){
        sort(all(a));
        reverse(all(a));
        sort(all(done));
        int ind = 0;
        rep(j,1<<i){
            int v = t-j-1;
            while(a[ind] != -1 && done[v] <= a[ind])ind++;
            if(a[ind] == -1){
                cout << "No" << endl;
                return 0;
            }
            done.push_back(a[ind]);
            a[ind] = -1;
            ind++;
        }
        t *= 2;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N;
int cnt[10][10];

void _main() {
    cin >> N;
    FOR (i, 1, N + 1) {
        string s = to_string(i);
        cnt[s.front() - '0'][s.back() - '0']++;
    }
    int ans = 0;
    FOR (i, 1, 10) FOR (j, 1, 10) {
        ans += cnt[i][j] * cnt[j][i];
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

struct node{
  struct node *right;
  struct node *left;
  struct node *oya;
  int key;
};

typedef struct node *Node;

Node root;

Node min(Node a){
  while(a -> left != NULL){
    a = a -> left;
  }
  return a;
}

Node search(Node i, int k){
  if(i -> key > k){
    if(i -> left == NULL){
      return NIL;
    }
    return search(i -> right, k);
  }
  return i;
}

Node successor(Node x){
  Node y;
  if(x -> right != NIL){
    return min(x -> right);
  }
  y = x -> oya;
  while( y != NIL && x == y -> right){
    x = y;
    y = y -> oya;
    return y;
  }
}

void delete(Node d){
  Node x, y;
  if(d != NIL){
    if(d -> left == NIL || d -> right == NIL){
      y = d;
      if(d -> left != NIL){
	x = y -> right;
      }else{
	x = y -> right;
      }
    }else if( x != NIL){
      x -> oya = y -> oya;
      if (y -> oya == NIL){
	root = x;
      } else if(y = y -> oya -> left){
	y -> oya -> left = x;
      } else {
	y -> oya -> right = x;
      }
      
    }
  }
  
  if(y != d){
    d -> key = y -> key;
    d -> oya = y -> oya;
    d -> left = y -> left;
    d -> right = y -> right;
  }
}

void insert(int k){
  Node x = root;
  Node y = NIL;
  Node z;
  
  z = malloc(sizeof(struct node));
  z -> key = k;
  z -> left = NIL;
  z -> right = NIL;
  
  while(x != NIL){
    y = x;
    if(z -> key < x -> key){
      x = x -> left;
    } else {
      x = x -> right;
    }
  }
  z -> oya = y;
  if(y == NIL){
    root = z;
  } else if (z -> key < y-> key){
    y -> left = z;
  } else {
    y -> right = z;
  }
}

void inorder(Node n){
  if(n != NIL){
    inorder(n -> left);
    printf(" %d", n -> key);
    inorder(n -> right);
  }
}

void preorder(Node n){
  
  if(n != NIL){
    printf(" %d", n -> key);
    preorder(n -> left);
    preorder(n -> right);
  }
}

int main(){
  int i, n, x;
  char p[20];
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", p);
    if(p[0] == 'f'){
      scanf("%d", &x);
      Node s = search(root, x);
      if(s != NIL)
	printf("yes\n");
      else
	printf("no\n");
    } else if(p[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }else if(p[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(p[0] == 'd'){
      scanf("d", &x);
      delete(search(root, x));
    }
  }
  
  return 0;
}

Measured memory_bytes: 24040
#include <iostream>
#include <string>
#define FOR(a, b, c, d) for (int a = b; a < c; a += d)
#define ull unsigned long long
#define MOD 1000000007
using namespace std;

int main() {
    int w = 0, h = 0;
    cin >> h >> w;
    ull dp[h+1][w+1];
    FOR(i, 0, h+1, 1)
        FOR(j, 0, w+1, 1)
            dp[i][j] = 0;
    dp[0][1] = 1;
    string buf;
    FOR(i, 1, h+1, 1) {
        cin >> buf;
        FOR(j, 1, w+1, 1)
            if (buf[j-1] == '.')
                dp[i][j] = (dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
    }
    cout << dp[h][w];
    return 0;
}


Measured memory_bytes: 11424
// #include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min, std::next_permutation, std::lower_bound
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil
#include <numeric> // std::gcd, std::lcm
#include <limits> // std::numeric_limits<long int>::max()
#include <unordered_map>
#include <map>
#include <cmath> // std::atan2
#include <deque>
#include <queue>
#include <bitset>
#include <functional>
#include <cassert>

using namespace std;
typedef long long ll;
#define INF 1999999999
#define MODA 1000000007 
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename T = long long, typename T2 = long long>
std::vector<std::vector<T>> convert_rooted_tree(const std::vector<std::vector<T>> &tree, T2 root = 0) {
  T N = tree.size();
  std::vector<std::vector<T>> rooted_tree(N);
  vector<bool> foundflag(N);
  foundflag[root] = true;
  queue<T> que;
  que.emplace(root);
  while(!que.empty()) {
    auto p = que.front();
    que.pop();
    for(auto &to : tree[p]) { 
      // The case using vector<vector<pair<ll, ll> > > as tree 
      // (ex, need to set the cost of links to pair.second),
      // replace index of foundflag and que from to -> to.first
      if(foundflag[to] == false) {
        foundflag[to] = true;
        que.emplace(to);
        rooted_tree[p].emplace_back(to);
      }
    }
  }
  return rooted_tree;
}

vector<vector<ll>> rtree;
vector<ll> counter;

void sumup(ll ind, ll cursum) {
  counter[ind] += cursum;
  for (auto node : rtree[ind]) {
    sumup(node, counter[ind]);
  }
}

int main() {
  ll N, Q;
  cin >> N >> Q;
  vector<ll> a(N), b(N);
  for(ll i=1; i < N; ++i) cin >> a[i] >> b[i];
  vector<ll> p(Q), x(Q);
  rep(i, Q) cin >> p[i] >> x[i];

  vector<vector<ll> > tree(N+1);
  for (ll i = 1; i < N+1; ++i) {
    tree[a[i]].emplace_back(b[i]);
    tree[b[i]].emplace_back(a[i]);
  }
  // vector<vector<ll>> rtree = convert_rooted_tree(tree, static_cast<ll>(1));
  rtree = convert_rooted_tree(tree, 1);
  counter.resize(N+1, 0);
  rep(i, Q) {
    counter[p[i]] += x[i];
  }
  sumup(1, 0);
  for (ll i = 1; i < counter.size(); ++i) {
    cout << counter[i] <<" ";
  }
  return 0;
}


Measured memory_bytes: 39092
import sys
x, k, d = map(int,input().split())
x = abs(x)
num = abs(x // d)
if k <= num:
    ans = x - k*d
else:
    num2 = k-num
    if num2 %2 ==0:
        ans = x - num*d
    else:
        ans = abs(x-(num+1)*d)

print(ans)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n, c;
    scanf("%d%d", &n, &c);
    lint d[c][c];
    int col[n][n];
    rep(i, c)rep(j, c) scanf("%lld", &d[i][j]);
    rep(i, n)rep(j, n){
        scanf("%d", &col[i][j]);
        --col[i][j];
    }

    lint sum[3][c];
    rep(i, 3)rep(j, c) sum[i][j] = 0;
    rep(i, n)rep(j, n)rep(k, c){
        sum[(i+j)%3][k] += d[col[i][j]][k];
    }
    lint ans = INF;
    rep(i, c)rep(j, c)rep(k, c)if(i!=j && j!=k && k!=i){
        chmin(ans, sum[0][i] + sum[1][j] + sum[2][k]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
using System.Linq;
class ilds1_2_c{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String[] str = Console.ReadLine().Split(' ');
    String[] temp = new String[n];
    for(int i=0; i<n; i++){
      temp[i] = str[i];
    }
    BubbleSort(temp, n);
    Console.WriteLine(string.Join(" ",temp));
    Console.WriteLine(check(str,temp,n));
    for(int i=0; i<n; i++){
      temp[i] = str[i];
    }
    SelectionSort(temp, n);
    Console.WriteLine(string.Join(" ",temp));
    Console.WriteLine(check(str,temp,n));
  }
  public static string check(String[] cmp, String[] arr, int max){
    List<string> t = new List<string>();
    int cur = int.Parse(arr[0].Substring(1,arr[0].Length-1));
    for(int i=0; i<max; i++){
      //Console.WriteLine("cur: {0}",cur);
      if(int.Parse(arr[i].Substring(1,arr[i].Length-1)) == cur){
        t.Add(arr[i]);
        continue;
      }
      else{
        int p = 0;
        for(int j=0; j<max; j++){
          if(cmp[j].Equals(t[p])){
            p++;
          }
          if(p == t.Count){
            break;
          }
        }
        if(p != t.Count){
          return "Not stable";
        }
        t.Clear();
        cur = int.Parse(arr[i].Substring(1,arr[i].Length-1));
        t.Add(arr[i]);
      }
    }
    if(t.Count != 0){
      int p = 0;
      for(int j=0; j<max; j++){
        if(cmp[j].Equals(t[p])){
          p++;
        }
        if(p == t.Count){
          break;
        }
      }
      if(p != t.Count){
        return "Not stable";
      }
    }
    return "Stable";
  }
  public static bool compare(String s1, String s2){
    String t1 = s1.Substring(1,s1.Length-1);
    String t2 = s2.Substring(1,s2.Length-1);
    return int.Parse(t1) < int.Parse(t2);
  }
  public static void BubbleSort(String[] s, int n){
    for(int i=0; i<n; i++){
      for(int j=n-1; j>i; j--){
        if(compare(s[j],s[j-1])){
          String t = s[j];
          s[j] = s[j-1];
          s[j-1] = t;
        }
      }
    }
  }
  public static void SelectionSort(String[] s, int n){
    int min;
    for(int i=0; i<n; i++){
      min = i;
      for(int j=i; j<n; j++){
        if(compare(s[j],s[min])){
          min = j;
        }
      }
      String t = s[min];
      s[min] = s[i];
      s[i] = t;
    }
  }
}



Measured memory_bytes: 17772
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n;
    cin >> n;
    vector<int> arr(n+2, 0);
    for(int i = 1; i <= n; i++) {
        cin >> arr[i];
    }
    int dis = 0;
    for(int i = 1; i < arr.size(); i++) {
        dis += abs(arr[i] - arr[i-1]);
    }
    for(int i = 1; i < arr.size()-1; i++) {
        int ab = abs(arr[i]-arr[i-1]);
        int bc = abs(arr[i+1]-arr[i]);
        int ac = abs(arr[i+1]-arr[i-1]);
        cout << dis - ab - bc + ac  << endl;
    }
    return 0;
}




Measured memory_bytes: 1664
def main():
    n,m,q = map(int,input().split())
    a = [list(map(int, input().split())) for _ in range(q)]
    #a = sorted(a, key=lambda x:-x[3])
    ans = 0
    from itertools import combinations_with_replacement
    for i in combinations_with_replacement(range(1,m+1),n):
        dp = i
        res = 0
        for j in range(q):
            if dp[a[j][1]-1] - dp[a[j][0]-1] == a[j][2]:
                res += a[j][3]
        ans = max(res,ans)
    print(ans)
    
if __name__ == '__main__':
    main()



Measured memory_bytes: 73568
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static void Main(string[] args)
        {
          //入力を受け取る
          //var ABC = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var N = int.Parse(Console.ReadLine());
          var A1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var A2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
          var max = 0;
          for(int i = 0; i < N ; i++){
            var goukei = CumulativeSum(A1,0,i)+CumulativeSum(A2,i,N-1);
            if(max < goukei){
              max = goukei;
            }
          }
          Console.WriteLine(max);
        }
  
  //配列のheadからtailまでの累積和を計算
  static int CumulativeSum(int[] A,int tail,int head){
    int[] B = new int[A.Length+1];
    //累積和の配列を初期化
    B[0] = 0;
    for(int i = 1; i < A.Length+1 ; i++){
      B[i] = B[i-1]+A[i-1];
    }
    return B[head+1]-B[tail];
  }
  
}


Measured memory_bytes: 13396
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var t = l[0];
        l[0] = l[1];
        l[1] = t;
        var s = l[0];
        l[0] = l[2];
        l[2] = s;
        Console.WriteLine($"{l[0]} {l[1]} {l[2]}");
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int flag=0,pd;
int main()
{
    int k,t;
    int a[1001];
    cin>>k>>t;
    for(int i=0;i<t;i++) 
	cin>>a[i],flag+=a[i];
    for(int i=0;i<t;i++)
	{
        pd=a[i]*2-flag-1;         
        if(pd>=0)
		{
            cout<<pd<<endl;
            return 0;
        }
    }
    cout<<"0"<<endl;
    return 0;
} 

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)


class UnionFindTree:
    """Disjoint-Set Data Structure
       Union-Find Tree
       complexity:
          init: O(n)
          find, unite, same: O(alpha(n))
       used in SRM505 div.2 900, ATC001 A, DSL1A(AOJ)
    """
    def __init__(self, n):
        self.par = list(range(n))  # parent
        self.rank = [0] * n  # depth of tree

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)

V, E = map(int, input().split())
uf = UnionFindTree(V)
for _ in range(E):
    uf.unite(*map(int, input().split()))
for _ in range(int(input())):
    print('yes' if uf.same(*map(int, input().split())) else 'no')

Measured memory_bytes: 12572
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

n = int(input())
s = input()

for i in range(len(s)):
    temp = ord(s[i]) + n
    if (temp > 90):
        temp = 64 + (temp - 90)
    print(chr(temp), end="")



Measured memory_bytes: 9292
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
  vector<int> n(100003);
  for (int i = 0; i < N; i++)
  {
    n[a[i]]++;
    n[a[i] + 1]++;
    n[a[i] + 2]++;
  }
  int ans = 0;
  for (int i = 1; i <= 100002; i++)
  {
    if (ans < n[i])
      ans = n[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n][3];
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    int dp[n][3];
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0]) + a[i][2];
    }
//    for(int i=0;i<n;i++)
//    cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    cout<<max( dp[n-1][0] , max( dp[n-1][1] , dp[n-1][2] ) )<<endl;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;
int beki(int n){
  if(n==0)return 1;
  int x=beki(n/2);
  if(n%2==0)return x*x;
  return 2*x*x;
}
int a[310];
signed main(){
  int n;cin>>n;
  int c=0;
  rep(i,n)cin>>a[i];
  int x=a[0],y=a[1];
  for(int i=2;i<n;i++)c^=a[i];
  
  if(c>x+y || (x+y-c)%2!=0){
    cout<<-1<<endl;
    return 0;
  }
  int po=(x+y-c)/2;
  if((po & c)!=0){
    cout<<-1<<endl;
    return 0;
  }
  if(y<po)x-=(po-y),y=po;
  if(x<po){
    cout<<-1<<endl;
    return 0;
  }
  x-=po,y-=po;
  //cout<<x<<" "<<y<<" "<<po<<endl; 
  int res=0;
  for(int i=60;i>=0;i--){
    int nue=beki(i);
    int hoge=(x+y)/nue;
    if(hoge%2==1 && res+nue<=x)res+=nue;
  }
  //cout<<res<<endl;
  if(po+res==0){
    cout<<-1<<endl;
    return 0;
  }
  cout<<a[0]-po-res<<endl;
    
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    long double a, b, c;
    cin >> a >> b >> c;
    bool ans = (c - a - b - 2 * sqrtl(a * b)) > 0;

    cout << (ans ? "Yes\n" : "No\n");
    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll nCr (int n, int r){
    ll ans =1;
    for(int i=0; n-i>r; i++){
        ans *= n-i;
        ans = ans/(i +1);
    }
    return ans;
}


int main (){
    ll n ; cin >> n;
    ll m=0, a=0, r=0, c=0, h=0;
    string s;
    rep(i,n){
        cin >> s ;
        if (s[0] == 'M') m++;
        if (s[0] == 'A') a++;
        if (s[0] == 'R') r++;
        if (s[0] == 'C') c++;
        if (s[0] == 'H') h++;
    }
    ll ret =0;
    ret = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h ;
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/practice2/tasks/practice2_g
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

void solve() {
    int N, M;
    cin >> N >> M;
    scc_graph g(N);
    REP(i, M) {
        int u, v;
        cin >> u >> v;
        g.add_edge(u, v);
    }
    auto scc = g.scc();
    cout << scc.size() << "\n";
    for (auto &x : scc) {
        cout << x.size();
        for (auto &y : x) {
            cout << " " << y;
        }
        cout << "\n";
    }
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    solve();
}


Measured memory_bytes: 40124
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	double x1;
	while(cin>>x1){
		double x[3],y[3],px,py;
		x[0]=x1;
		cin>>y[0]>>x[1]>>y[1]>>x[2]>>y[2]>>px>>py;
		double c[3];
		for(int i=0;i<3;i++){
			double vx1 = x[(i+1)%3]-x[i],vy1 = y[(i+1)%3]-y[i];
			double vx2 = px-x[i],vy2 = py-y[i];
			c[i] = vx1*vy2-vy1*vx2;
		}
		if((c[0]>0&&c[1]>0&&c[2]>0)||(c[0]<0&&c[1]<0&&c[2]<0)) out("YES");
		else out("NO");
	}

	return 0;
}


Measured memory_bytes: 3036
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); ++i) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

using namespace std;

int main(){
  ll x[5],y[5];
  cin >> x[1] >> y[1] >> x[2] >> y[2];

  x[3] = x[2] - (y[2] - y[1]);
  y[3] = y[2] + (x[2] - x[1]);

  x[4] = x[1] - (y[2] - y[1]);
  y[4] = y[1] + (x[2] - x[1]);

  cout << x[3] << " " << y[3] << " ";
  cout << x[4] << " " << y[4] << " " << endl;

  return 0;
}


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

int main() {

    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    double n;
    cin>>n;
    double x = floor(n/1.08);
    double y = ceil(n/1.08);
    if(floor(x * 1.08) == n)
    	cout << x;
    else if(floor(y * 1.08) == n)
    	cout<< y;
    else
    	cout << ":(";
	return 0;		
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin >> N >> K;
    int x[N];
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    int sum = 0;
    for(int i = 0; i < N; i++){
        sum += min(2*x[i],2*(abs(x[i]-K)));
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  int N; cin >> N;
  int a=0, b=0, ba = 0, ans=0;
  for(int i=0; i<N; i++) {
    string s_hold;
    cin >> s_hold;
    if (s_hold[0] == 'B') {
      b++;
    }
    for (int p = 0; p < s_hold.length() - 1; p++) {
      if (s_hold[p] == 'A') {
        if (s_hold[p+1] == 'B') {
          ans++;
        }
      }
    }
    if (s_hold[s_hold.length() - 1] == 'A') {
      a++;
    }
    if (s_hold[s_hold.length() - 1] == 'A' && s_hold[0] == 'B') ba++;
  }

  if (a==N && b==N) {
    ans = ans + N - 1;
  }else if(ba>0&&a==ba&&b==ba) ans = ans + ba - 1;
  else {
    ans = ans + min(a, b);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n; cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    deque<int> dq;
    for(int i=0;i<n;i++){
        if(i%2==0) dq.push_back(a[i]);
        else dq.push_front(a[i]);
    }
    for(int i=0;i<n;i++){
    if(n%2==0) {
        cout<<dq.front()<<' ';
        dq.pop_front();
        }else{
        cout<<dq.back()<<' ';
        dq.pop_back();
        }
    }
    
    cout<<endl;
}


Measured memory_bytes: 3840
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int tax8(int n) {
  return n * 8 / 100;
}

int tax10(int n) {
  return n * 10 / 100;
}

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

  int ans = -1;
  rep(i,1,1009) {
    if (tax8(i) == A && tax10(i) == B) {
      ans = i;
      break;
    }
  }

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


Measured memory_bytes: 256
from collections import Counter
while True:
    n = int(input())
    if n == 0:
        quit()
    elif n == 1:
         print(input(), 1)
    else:
        c = list(input().split())
        h = [0 for i in range(26)]
        flag = 0
        for i in range(n):
            h[ord(c[i])-65] += 1
            if sorted(h)[-1] - sorted(h)[-2] >= (n-i):
                print(chr(h.index(max(h))+65), i+1)
                flag = 1
                break
        if flag == 0:
            print('TIE')



Measured memory_bytes: 5996
#include<stdio.h>

int main(void){

    int X,Y,result = 0;

    scanf("%d %d",&X,&Y);

    for(int i = 0;i < 2;i++){
        if(X > Y){
            result += X;
            X--;
        }else{
            result += Y;
            Y--;
        }
    }

    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
assign = []
for index in range(1,N+1):
    S, P = map(str, input().split())
    P = int(P)
    assign.append([S, P, index])

assign = sorted(assign, key=lambda x:(x[0], -x[1]))

for i in range(N):
    print(assign[i][2])


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

int main() {
  int H, W;
  cin >> H >> W;
  string a;
  
  for(int i = 0; i < W+2; i++) cout << '#';
  cout << endl;
  
  for(int i = 0; i < H; i++) {
    cout << '#';
    cin >> a;
    cout << a << '#' << endl;
  }

  for(int i = 0; i < W+2; i++) cout << '#';
  cout << endl;

}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

#define ll long long int

int main(){
  int N,M;
  cin >> N >> M;
  int wa[N+1],ac[N+1];
  for(int n=0;n<N+1;n++){
    wa[n]=0;
    ac[n]=0;
  }
  int wa_cnt=0,ac_cnt=0;
  for(int i=0;i<M;i++){
    int p;
    string s;
    cin >> p >> s;
    if(s=="AC") {
      if(ac[p]>0) continue;
      ac_cnt++;
      ac[p]++;
      wa_cnt+=wa[p];
    }
    if(s=="WA") {
      wa[p]+=1;
    }
  }
  cout << ac_cnt << " " << wa_cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int n;

int main() {
    cin >> n;
    int cnt_A=0, cnt_Un=0;
    bool ok=true;
    for(int i=0; i<n; ++i){
        string str; cin >> str;
        if(str=="A") cnt_A++;
        else cnt_Un++;
        if(cnt_Un>cnt_A) {
            ok = false;
            break;
        }
    }
    if(cnt_A-cnt_Un!=0||!ok) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3152
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect

def f(a,b,N):
    return min(a,b)*(N-max(a,b)+1)

N = int(input())

p = 0
for i in range(1,N+1):
    p += f(i,i,N)

for i in range(N-1):
    u, v = list(map(int, input().split()))
    p -= f(u,v,N)

print(p)


Measured memory_bytes: 76392
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int[] V = new int[N];

		for (int i = 0; i < N; i++) {
			V[i] = sc.nextInt();
		}

		int ans = 0;
		for (int i = 0; i < N; i++) {
			int c = sc.nextInt();
			if (V[i] - c > 0) {
				ans += V[i] - c;
			}
		}

		out.println(ans);

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23124
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream &operator << (ostream& out,const pair<S,T>& o){
    out << "(" << o.first << "," << o.second << ")"; return out;
}

/*
アな問題が多いので,まとめる
*/
// https://abc042.contest.atcoder.jp/tasks/abc042_a
void abc042_a(){ ll A,B,C; cin >> A >> B >> C; if(A == 5 && B == 5 && C == 7){ cout << "YES" << endl; return;} if(A == 5 && B == 7 && C == 5){ cout << "YES" << endl; return;} if(A == 7 && B == 5 && C == 5){ cout << "YES" << endl; return;} cout << "NO" << endl; return ; }
// https://abc043.contest.atcoder.jp/tasks/abc043_a
void abc043_a(){ ll N; cin >> N; cout << N*(N+1)/2 << endl; }
// https://abc046.contest.atcoder.jp/tasks/abc046_a
void abc046_a(){ ll a,b,c; cin >> a >> b >> c; set<ll> s; s.insert(a); s.insert(b); s.insert(c); cout << s.size() << endl; }
// https://abc048.contest.atcoder.jp/tasks/abc048_a
void abc048_a(){string s1,s2,s3;cin>>s1>>s2>>s3;cout<<"A"<<s2[0]<<"C"<<endl;}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    abc048_a();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

int main() {
  string s;
  cin >> s;
  deque<char> dq(s.begin(), s.end());
  int q;
  cin >> q;
  bool flip = false;
  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      flip = !flip;
    } else {
      int x;
      cin >> x;
      char ch;
      cin >> ch;
      if (x == 1) {
          if (!flip)
            dq.push_front(ch);
          else
            dq.push_back(ch);
      } else {
          if (!flip)
            dq.push_back(ch);
          else
            dq.push_front(ch);
      }
    }
  }
  if (flip) {
    reverse(dq.begin(), dq.end());
  }
  for (auto x : dq)
    cout << x;
  return 0;
}


Measured memory_bytes: 896
#include "bits/stdc++.h"
using namespace std;
int main(){
	int N;
	string S;
	cin >> N >> S;
	int sum = 0;
	for(int i = 0; i < N-2; i++)
		if(S[i] == 'A')
			if(S[i+1] == 'B')
				if(S[i+2] == 'C')
					sum++;
	cout << sum << endl;
	return 0;
}


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

using namespace std;

int main(){
    int n, sum = 0;
    cin >> n;
    int w[n];
    for (int i = 0; i < n; i++){
        cin >> w[i];
        sum += w[i];
    }
    int sum_tmp = 0;
    int ans = INT_MAX;
    for (int i = 0; i < n; i++){
        sum_tmp += w[i];
        ans = min(ans, abs(sum_tmp * 2 - sum));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        String[] number = line.split(" ");
        int x = Integer.parseInt(number[0]);
        int a = Integer.parseInt(number[1]);
        int b = Integer.parseInt(number[2]);
        if(a >= b) {
            System.out.println("delicious");
        } else if(a + x >= b) {
            System.out.println("safe");
        } else {
            System.out.println("dangerous");
        }
    }
}

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

int N,A[100010];
int main(){
	cin >> N;
	for(int i=1;i<=N;i++){
		cin >> A[i];
		if(A[i]%2==1){
			cout << "first" << endl;
			return 0;
		}
	}
	cout << "second" << endl;
}

Measured memory_bytes: 640
S = list(map(str, input()))
humiyasui = 1
for i in range(len(S)):
	if i % 2 == 0:
		if S[i] == "L":
			humiyasui = 0
			break
	else:
		if S[i] == "R":
			humiyasui = 0
			break
if humiyasui:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 38524
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
using namespace std;
typedef complex<double> xy;
double eps = 1e-9;
double dot_product(xy a,xy b) {return (conj(a)*b).real();}
double cross_product(xy a,xy b) {return (conj(a)*b).imag();}
bool comp(xy a,xy b){
    return (a.real()!=b.real()? a.real()<b.real() : a.imag()<b.imag());
}
struct point{
    xy place;
    int id;
    bool operator<(const point& right)const{
        return comp(place,right.place);
    }
};

vector<point> convex_hull(vector<point> v){
    int n = v.size();
    vector<point> res;
    sort(v.begin(),v.end());
    for(int i=0;i<n;i++){
        if(i<2){
            res.push_back(v[i]);
            continue;
        }
        while(true){
            int s = res.size();
            if(s<2){
                res.push_back(v[i]);
                break;
            }
            double c = cross_product(res[s-1].place-res[s-2].place,v[i].place-res[s-2].place);
            if(c<-eps){
                res.pop_back();
            }else{
                res.push_back(v[i]);
                break;
            }
        }
    }
    reverse(v.begin(),v.end());
    for(int i=0;i<n;i++){
        while(true){
            int s = res.size();
            if(v[i].place==res.back().place) break;
            if(s<2){
                res.push_back(v[i]);
                break;
            }
            double c = cross_product(res[s-1].place-res[s-2].place,v[i].place-res[s-2].place);
            if(c<-eps){
                res.pop_back();
            }else{
                res.push_back(v[i]);
                break;
            }
        }
    }
    res.pop_back();
    return res;
}


int N;
double ans[110] = {};
vector<point> v;

int main(){
    cin >> N;
    double x,y;
    for(int i=0;i<N;i++){
        cin >> x >> y;
        v.push_back({xy(x,y),i});
    }
    vector<point> res = convex_hull(v);
    int n = res.size();
    for(int i=0;i<n;i++){
        xy now = res[i].place,pre = res[(i-1+n)%n].place,ne = res[(i+1)%n].place;
        double alpha = arg(pre-now),beta = arg(ne-now);
        if(alpha<eps) alpha += 2*M_PI;
        if(beta<eps) beta += 2*M_PI;
        double dtheta = M_PI-(alpha-beta);
        ans[res[i].id] = dtheta/(2*M_PI);
        if(ans[res[i].id]>=1) ans[res[i].id] -= 1.0;
    }
    cout << fixed;
    for(int i=0;i<N;i++) cout << setprecision(10) << ans[i] << endl;
}

Measured memory_bytes: 256
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    chains = list(map(string_to_int, inputs))
    nodes_chain = {i+1: set() for i in range(N)}

    for c in chains:
        [a, b] = c
        nodes_chain[a].add(b)
        nodes_chain[b].add(a)

    modified = True
    count = 0
    while modified:
        modified = False
        for node1 in nodes_chain.keys():
            target_nodes = nodes_chain[node1]
            if len(target_nodes) == 1:
                node2 = target_nodes.pop()
                nodes_chain[node2].remove(node1)
                count += 1
                modified = True
    return count


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(M))
    print(ret)


Measured memory_bytes: 38256