akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll n, w;
    cin >> n >> w;
    vector<ll> W(110), V(110);                      //余裕をもって　
    vector<vector<ll>> dp(110, vector<ll>(100100)); //価値の最大値はn*10^3=10^5
    rep(i, n) cin >> W[i] >> V[i];

    //INFで初期化
    rep(i, 110) rep(j, 100100) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, n)
    {
        for (int v = 0; v < 100100; v++)
        {
            dp[i + 1][v] = min(dp[i + 1][v], dp[i][v]); //選ばない
            if (v - V[i] >= 0)
                dp[i + 1][v] = min(dp[i + 1][v], dp[i][v - V[i]] + W[i]); //選ぶ
        }
    }

    ll ans = 0;
    rep(i, n + 1)
    {
        rep(v, 100100)
        {
            if (dp[i][v] <= w)
                ans = v;
        }
    }
    cout << ans << endl;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define MOD 1e9+7
#define sp ' '


using ll = long long;


ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}

int main(){

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i, n){
        cin >> a[i];
    }
    vector<ll> sum(n+1, 0LL);
    vector<ll> goodsum(n+1, 0LL);
    ll ans = 0LL;
    rep(i, n){
        sum[i+1] = sum[i] + a[i];
        goodsum[i+1] = goodsum[i] + max(0, a[i]);
    }
    for(int i = 0; i <= n-k; ++i){
        ans = max(ans, goodsum[n]-(goodsum[i+k] - goodsum[i])+(max(0LL,sum[i+k] - sum[i])));

    }

    ppp(ans);

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
 
using namespace std;

#define MOD 1000000007
#define A first
#define B second

typedef long long ll;

inline int mulmd(ll a, ll b){
  ll ret = (a * b) % MOD;
  return (int) ret;
}

inline int power(ll x, ll y, int m){
  ll res = 1;
  x = x % m;
  while(y > 0){
    if(y & 1){
      res = mulmd(res, x);
    }
    y = y >> 1;
    x = mulmd(x, x);
  }
  return (int) res;
}

inline int submd(ll a, ll b){
  ll ret = (a - b);
  if(ret < 0) ret += MOD;
  return (int) ret;
}

inline int addmd(ll a, ll b){
  ll ret = (a + b) % MOD;
  return (int) ret;
}

inline int invPow(ll a){
  return power(a, MOD - 2, MOD);
}

inline int divmd(ll a, ll b){
  ll ret = mulmd(a, invPow(b));
  return (int) ret;
}

const int N = 1e5 + 5;

int arr[N];

void solve(){
  int a, b;
  cin >> a >> b;
  int ans = a / b;
  if(a % b != 0) ans += 1;
  cout << ans;
  


}


int main(){
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  //cin >> t;
  t = 1;
  while(t--){
    solve();
  }
  return 0;
}



Measured memory_bytes: 256
N,K,Q = map(int,input().split())
human_win = [0 for i in range(N)]
win = Q - K

for i in range(Q):
     human_win[int(input())-1] += 1

for i in range(N):
    if human_win[i] > win:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 50720
from sys import stdin
def S(): return stdin.readline().rstrip()

s = S()
ls = list(s)
l = []

tmp = ''
k = 0
for i in ls:
    k += 1
    if len(l)<1:
        l.append(i)
    else:
        tmp += i
        if tmp != l[len(l)-1]:
            l.append(tmp)
            tmp = ''
        else:
            if k == len(ls):
                a = l.pop()
                tmp = a+tmp
                l.append(tmp)

print(len(l))

Measured memory_bytes: 9832
// --https://kenkoooo.com/atcoder/#/table/soma62jp
#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;


int main(int argc, char* argv[]) {

	string S,T;
	int ans = 0;

	cin >> S >> T;

	for (int i=0;i<S.length();i++){
		S = S[S.length()-1] + S;
		S = S.substr(0,S.length()-1);
		if (S == T) {
			ans = 1;
		}
	}

	if(ans){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;

}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
input=sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))

b=[0]*n

for i in range(n-1,-1,-1):
    if sum(b[i:n:i+1]) %2 and a[i] == 0:
        b[i] = 1 
    elif not sum(b[i:n:i+1]) %2 and a[i] == 1:
        b[i] = 1 


print(sum(b))
print(" ".join([str(k+1)  for k,v in enumerate(b)  if v== 1]))

Measured memory_bytes: 14744
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

class modint
{
	public:
		ll val;

		constexpr modint(const ll x = 0) noexcept : val(x % MOD) {}
		constexpr ll &value() noexcept {return (val);}
		constexpr modint operator+(const modint rhs) const noexcept {
			return (modint(*this) += rhs);
		}
		constexpr modint operator-(const modint rhs) const noexcept {
			return modint(*this) -= rhs;
		}
		constexpr modint operator*(const modint rhs) const noexcept {
			return modint(*this) *= rhs;
		}
		constexpr modint operator/(const modint rhs) const noexcept {
			return modint(*this) /= rhs;
		}
		constexpr modint &operator+=(const modint rhs) noexcept {
			val += rhs.val;
			if (val >= MOD) {
				val -= MOD;
			}
			return (*this);
		}
		constexpr modint &operator-=(const modint rhs) noexcept {
			if (val < rhs.val) {
				val += MOD;
			}
			val -= rhs.val;
			return (*this);
		}
		constexpr modint &operator*=(const modint rhs) noexcept {
			val = val * rhs.val % MOD;
			return (*this);
		}
		constexpr modint &operator/=(modint rhs) noexcept {
			ll exp = MOD - 2;
			while (exp) {
				if (exp % 2) {
					*this *= rhs;
				}
				rhs *= rhs;
				exp /= 2;
			}
			return (*this);
		}
};

void init_comb(int size, vector<modint> &fac, vector<modint> &finv)
{
	fac.resize(size);
	finv.resize(size);
	vector<modint> inv(size);
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < size; i++)
	{
		fac[i] = fac[i-1] * i;
		inv[i] = (modint)MOD - inv[MOD%i] * (MOD / i);
		finv[i] = finv[i-1] * inv[i];
	}
}

modint	combination(int n, int k, vector<modint> fac, vector<modint> finv)
{
	if (n < k)
		return (0);
	if (n < 0 || k < 0)
		return (0);
	return (fac[n] * finv[k] * finv[n-k]);
}

int		main(void)
{
	vector<modint> fac, finv;
	init_comb(3000, fac, finv);
	int n, k;
	cin >> n >> k;
	int red = n-k;
	vector<modint> ans(k + 1);
	for (int i = 1; i <= k; i++)
	{
		ans[i] = combination(k-1, i-1, fac, finv) * combination(red + 1, i, fac, finv);
	}
	for (int i = 1; i <= k; i++)
	{
		cout << ans[i].val << endl;
	}
}


Measured memory_bytes: 384
use std::io;
use std::io::*;
 
fn read_input() -> String {
  let mut buffer = String::new();
  let stdin = io::stdin();
  let mut handle = stdin.lock();
  let _ = handle.read_to_string(&mut buffer);
  buffer.clone()
}
 
fn main() {
    let buffer = read_input();
    let mut iter = buffer.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    let c: i32 = iter.next().unwrap().parse().unwrap();
    let d: i32 = iter.next().unwrap().parse().unwrap();
    if (a - c).abs() <= d {
      println!("Yes");
    } else if (b - a).abs() <= d && (c - b).abs() <= d {
      println!("Yes");
    } else {
      println!("No");
    }
}

Measured memory_bytes: 4352
#include <iostream>
using namespace std;
int main()
{
	int total,TotalOfConnectedNode,node,connectednode;
	int AM[101][101];
	for (int i = 0; i < 101; i++)
		for (int j = 0; j < 101; j++)
			AM[i][j] = 0;

	
	cin >> total;
	for (int i = 0; i < total; i++)//有向图
	{
		cin >> node>>TotalOfConnectedNode;
		if (TotalOfConnectedNode == 0) continue;
		for (int i = 0; i < TotalOfConnectedNode; i++)
		{
			cin >> connectednode;
			AM[node][connectednode] = 1;
			//AM[connectednode][node] = 1;无向图

		}
	}
	for (int i = 1; i <= total; i++)
	{		for (int j = 1; j <= total; j++)
			{	
			   if(j>1)
			    cout << " ";
			   cout<< AM[i][j];
			    
			}
		cout << endl;
	}
	return 0;
}




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

using namespace std;

int N, k;
int arr[104];

int main(){
    scanf("%d %d", &N, &k);
    for(int i=0;i<N;++i) scanf("%d", arr+i);
    sort(arr, arr+N);
    int ans = 0, f = 0;
    for(int i=0;i<N&&k>=arr[i];++i){
        k -= arr[i], ++ans;
        if(i==N-1&&k) f = 1;
    }
    printf("%d", ans-f);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int A[N];
	rep(i,N){
		cin >> A[i];
		A[i]--;
	}
	int ans = 0;
	rep(i,N){
		if(A[A[i]] == i) ++ans;
	}
	cout << ans/2 << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5,P=1e9+7;
char a[N]; int n,f[N][3][3];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",a+1); n=strlen(a+1); f[0][0][0]=1;
	for(int i=0;i<n;i++) 
		for(int j=0;j<3;j++) for(int k=0;k<3;k++) if(f[i][j][k]){
			int v=f[i][j][k];
			for(int x=0;x<2;x++) if(x==a[i+1]-'0' || a[i+1]=='?'){
				if(j){
					int y;
					if(!x){
						y=j+1; if(y==3) y=1;
					}
					else y=j-1;
					(f[i+1][y][k]+=v)%=P;
				}
				else{
					if(k==2) (f[i+1][0][2]+=v)%=P;
					else{
						if(!x) (f[i+1][1][k]+=v)%=P;
						else (f[i+1][0][k+1]+=v)%=P;
					}
				}
			}
		}
	int ans=f[n][0][1];
	for(int i=0;i<3;i++) (ans+=f[n][i][2])%=P;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  map<ll, ll> L, R;
  for (int i=0; i<N; i++) {
    if (L.count(i+A[i])) L[i+A[i]]++;
    else L[i+A[i]] = 1;
  }
  for (int i=0; i<N; i++) {
    if (R.count(i-A[i])) R[i-A[i]]++;
    else R[i-A[i]] = 1;
  }
  ll res = 0;
  for (auto p: L) {
    auto key = p.first;
    auto value = p.second;
    res += value*R[key];
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int x, y;
  cin >> x >> y;
  vector<int> num = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
  x = num.at(x);
  y = num.at(y);
  if(x == y){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}


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

using namespace std;

using int64 = long long;

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

  int n, d;
  cin >> n >> d;
  cout << (n + 2 * d) / (2 * d + 1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
//void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////



int main(){fastio
    ll n;cin>>n;
    string s[n];rep(i,0,n-1)cin>>s[i];
    ll ni[n];rep(i,0,n-1)ni[i]=0;
    ni[0]=1;
    queue<ll>q;q.push(0);
    while(!q.empty()){
        ll t=q.front();q.pop();
        rep(i,0,n-1){
            if(s[t][i]=='1'){
                if(ni[i]==0){
                    ni[i]=3-ni[t];
                    q.push(i);
                }else{
                    if(ni[i]+ni[t]!=3){
                        cout<<-1<<endl;return 0;
                    }
                }
            }
        }
    }/*
    rep(i,0,n-1){
        cout<<ni[i]<<" ";
    }cout<<endl;
      */
    while(!q.empty())q.pop();
    ll ans=1;
    rep(sta,0,n-1){
        ll d[n];rep(i,0,n-1)d[i]=inf;
        d[sta]=0;
        q.push(sta);
        while(!q.empty()){
            ll t=q.front();q.pop();
            rep(i,0,n-1){
                if(s[t][i]=='1'){
                    if(d[i]==inf){
                        d[i]=d[t]+1;
                        q.push(i);
                    }
                }
            }
        }
        rep(i,0,n-1)Max(ans,d[i]+1);
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
def maxPoints(a,b,c,N):
    dp = [[0]*3 for _ in range(N)]
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]

    for i in range(1,N):
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2])
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2])
        dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0])
    
    return max(dp[N-1])

n = int(input())
a = [0] * n
b = a.copy()
c = a.copy()
for i in range(n):
    a[i],b[i],c[i] = map(int,input().split())
print(maxPoints(a,b,c,n))

Measured memory_bytes: 92548
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
 
using namespace std;
vector<long long int> ss;
vector<long long int> memo[100005];
vector<long long int> memo2[100005];
 
 
int main() {
	// your code goes here
	int n;
	int U;
	cin>>n;
	memset(memo,0,sizeof(memo));
	memset(memo2,0,sizeof(memo2));
	for(int i=0;i<n;i++){
		long long int s;
		cin>>s;
		ss.push_back(s);
	}
	for(int i=1;i<n;i++){
		for(int k=1;(k*k)<=i;k++){
			if(i%k>0)continue;
			int p=k;
			int s1=memo[p].size();
			if(s1>0){
				memo[p].push_back(ss[i]+memo[p][s1-1]);
			}else{
				memo[p].push_back(ss[i]);
			}
			if(k*k==i)continue;
			p=i/k;
			s1=memo[p].size();
			if(s1>0){
				memo[p].push_back(ss[i]+memo[p][s1-1]);
			}else{
				memo[p].push_back(ss[i]);
			}
		}
	}
	std:reverse(ss.begin(),ss.end());
	for(int i=1;i<n;i++){
		for(int k=1;(k*k)<=i;k++){
			if(i%k>0)continue;
			int p=k;
			int s1=memo2[p].size();
			if(s1>0){
				memo2[p].push_back(ss[i]+memo2[p][s1-1]);
			}else{
				memo2[p].push_back(ss[i]);
			}
			if(k*k==i)continue;
			p=i/k;
			s1=memo2[p].size();
			if(s1>0){
				memo2[p].push_back(ss[i]+memo2[p][s1-1]);
			}else{
				memo2[p].push_back(ss[i]);
			}
		}
	}
	long long int ans=0;
	int count1=0;
	U=n-1;
	//U=50000;
	for(int a=2;a<U;a++){
		int r=U-a;
		for(int k=1;k*k<=r;k++){
			int b=(a-r/k);
			if(r%k==0 && b<a && b>0){
				int c=a-b;
				int t=(U-a)/c-1;
				if(t<0 || memo[c].size()<=t || memo2[c].size()<=t || (U-a)%c!=0 || ((a%c==0)&&(a/c)<=(U-a)/c)){
					//何もしない
				}else{
					long long int sum=memo[c][t]+memo2[c][t];
					//cout<<sum<<" "<<a<<" "<<b<<"\n";
					if(ans<sum)ans=sum;
				}
			}
			b=(a-k);
			if(r%k==0 && b<a && b>0){
				int c=a-b;
				int t=(U-a)/c-1;
				if(t<0)continue;
				if(memo[c].size()<=t)continue;
				if(memo2[c].size()<=t)continue;
				if((U-a)%c!=0)continue;
				if((a%c==0)&&(a/c)<=(U-a)/c)continue;
				long long int sum=memo[c][t]+memo2[c][t];
				//cout<<sum<<" "<<a<<" "<<b<<"\n";
				if(ans<sum)ans=sum;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 33140
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N = sc.nextLine().toLong
    val nums = List.fill(5)(sc.nextLine()).map(_.toLong)

    println(((N + nums.min - 1) / nums.min) + 4)
  }

}


Measured memory_bytes: 27208
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

void solve(){
    int n, m, s, t;
    cin >> n >> m;
    v2<int> adj(n);
    for(int i = 0; i < m; ++i){
        int u, v;
        cin >> u >> v;
        --u, --v;
        adj[u].push_back(v);
    }
    cin >> s >> t;
    --s, --t;

    queue<pair<int, int>> q;
    v2<int> dist = fill(n, 3, -1);
    q.push({s, 0});
    dist[s][0] = 0;
    while(!q.empty()){
        int node = q.front().F;
        int mod = q.front().S;
        q.pop();
        int nextmod = (mod+1)%3;
        for(int nextnode : adj[node]){
            if(dist[nextnode][nextmod]==-1){
                dist[nextnode][nextmod] = 1+dist[node][mod];
                q.push({nextnode, nextmod});
            }
        }
    }

    if(dist[t][0]!=-1){
        cout << dist[t][0]/3 << "\n";
    }
    else{
        cout << "-1\n";
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    int A, B, C;
    cin >> A >> B >> C;
    if (C <= A + B + 1) {
        cout << B + C << "\n";
    } else {
        cout << A + B + B + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <iterator>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int n, m, x,ans=9999999;
	cin >> n >> m >> x;
	vector<vector<int>> A(n, vector<int> (m+1));
	rep(i, n) rep(j, m + 1){
		cin >> A[i][j];
	}
	rep(i, 1 << n) {
		vector<int> B(m, 0);
		int c = 0;
		rep(j, n) {
			if ((i >> j)&1) {
				c += A[j][0];
				rep(k, m) {
					B[k] += A[j][k + 1];
				}
			}
		}
		int count = 0;
		rep(k, m) {
			if (B[k] >= x)count++;
		}
		if (count == m&&c<ans) {
			ans = c;
		}
	}
	if (ans == 9999999)cout << "-1";
	else cout << ans;
}

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

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

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

    unsigned int total_price = 0;
    for (unsigned int i = 0; i < N + 1; ++i) {
        total_price += abs(A[i + 1] - A[i]);
    }

    for (unsigned int i = 1; i <= N; ++i) {
        unsigned int reduced_price_i = abs(A[i] - A[i - 1]) + abs(A[i + 1] - A[i]) - abs(A[i + 1] - A[i - 1]);
        unsigned int total_price_i = total_price - reduced_price_i;
        cout << total_price_i << endl;
    }

    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main(void)
{
	int x,i;
	 i=1;
	 scanf("%d",&x);
	while(x !=0){
	 
	 printf("Case %d: %d\n",i,x);
	 i++;
	 scanf("%d",&x);
	}
	

return 0;
}

Measured memory_bytes: 2556
#include <bits/stdc++.h>
#define INF 1e9
#define MAX_V 10000
using namespace std;

/*?????§?????¢?????´?????????(Ford_Fulerson????????¨)???O(F|E|)*/

//????????¨????§???????(???????????????????????????)
struct edge{int to, cap, rev;};

vector<edge> G[MAX_V]; //??°???????????£??\?????????
bool used[MAX_V];      //DFS??§?????§??????????????????????????°

void init(){
  for(int i=0;i<MAX_V;i++) G[i].clear();
}

//from??????to??????????????????cap???????????°?????????????????????
void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,(int)G[to].size()});
  G[to].push_back((edge){from,0,(int)G[from].size()-1});  
}

//?¢?????????????DFS??§??¢???
int dfs(int v,int t,int f){
  if(v == t)return f;
  used[v]=true;
  for(int i=0; i<G[v].size() ;i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d = dfs(e.to ,t , min(f,e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

//s??????t???????????§???????±???????
int max_flow(int s,int t){
  int flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    int f = dfs(s, t, INF);
    if(f == 0)return flow;
    flow += f;
  }
}

int main(){
  
  int H, W, C, M, Nw, Nc, Nm;
  
  while(1){
    
    cin>>H>>W>>C>>M>>Nw>>Nc>>Nm;
    if(H==-1) break;

    init();
    
    int s=0;
    int Hws=(H+W+C+M)*2+1, Hwt=Hws+1;
    int Hcs=Hwt+1, Hct=Hcs+1;
    int Hms=Hct+1, Hmt=Hms+1;
    int t=Hmt+1;

    for(int i=1;i<=H;i++){
      add_edge(s,i*2-1,1);
      add_edge(i*2-1,i*2,1);
      add_edge(i*2,Hws,1);
    }
    
    for(int i=1;i<=W;i++){
      int n;
      cin>>n;
      add_edge((H+i)*2-1,(H+i)*2,1);
      add_edge((H+i)*2,Hcs,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge(a*2,(H+i)*2-1,1);
      }
    }
    
    for(int i=1;i<=C;i++){
      int n;
      cin>>n;
      add_edge(Hwt,(H+W+i)*2-1,INF);
      add_edge((H+W+i)*2-1,(H+W+i)*2,1);
      add_edge((H+W+i)*2,Hms,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge((H+a)*2,(H+W+i)*2-1,1);
      }
    }
    
    for(int i=1;i<=M;i++){
      int n;
      cin>>n;
      add_edge(Hct,(H+W+C+i)*2-1,INF);
      add_edge((H+W+C+i)*2-1,(H+W+C+i)*2,1);
      add_edge((H+W+C+i)*2,t,1);
      for(int j=0;j<n;j++){
	int a;
	cin>>a;
	add_edge((H+W+a)*2,(H+W+C+i)*2-1,1);
      }
    }

    add_edge(Hws,Hwt,Nw);
    add_edge(Hcs,Hct,Nc);
    add_edge(Hms,Hmt,Nm);
    add_edge(Hmt,t,INF);
    
    cout<<max_flow(s, t)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3392
#include <iostream>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"


template <class T,
         class Container = std::vector<T>,
         class Compare = less<typename Container::value_type>>
         class priority_queue
{
  public:
  Container v;
  int size = 0;
  void push(T val) {
    int index = size;
    ++size;
    v.push_back(val);
    int parent = (index-1) / 2;
    while (parent >= 0 && Compare()(v[parent], v[index])) {
      T tmp = v[index];
      v[index] = v[parent];
      v[parent] = tmp;

      index = parent;
      parent = (index-1)/2;
    }
  }
  T top() {
    return v.front();
  }
  void pop() {
    v[0] = v[size-1];
    v.pop_back();
    --size;

    int index = 0, l = 1, r = 2;
    while (l < size && (Compare()(v[index], v[l]) || Compare()(v[index], v[r]))) {
      int target = 0;
      T tmp = v[index];
      if (Compare()(v[index], v[l]))
        target = l;
      else
        target = r;

      if (Compare()(v[index], v[l]) && Compare()(v[index], v[r])) {
        if (Compare()(v[r], v[l])) target = l;
        else target = r;
      }
      v[index] = v[target];
      v[target] = tmp;
      index = target;
      l = index * 2 + 1, r = index * 2 + 2;
    }
  }
  bool empty() {
    return size == 0;
  }
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N, M; in(N); in(M);

  priority_queue<int> A;
  rep(i, N) {
    int a; in(a);
    A.push(a);
  }
  rep(i, M) {
    int p = A.top(); A.pop();
    A.push(p / 2);
  }
  ll sum = 0;
  while (!A.empty()) {
    int p = A.top(); A.pop();
    sum += p;
  }
  out(sum);

  return 0;
}


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

int main() {
    string S; cin >> S;
    int ans = 10000;
    rep(s, S.size() - 2) {
        string T = S.substr(s, 3);
        int x = 0;
        rep(i, 3) x = x * 10 + (T[i] - '0');
        ans = min(ans, abs(753 - x));
    }
    cout << ans << endl;
    return 0;
}

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

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define forn(i, n) for (int i = 0; i < (int)(n); i++)
#define forrn(i, a, b) for (int i = (a); i < (int)(b); i++)
#define PYMOD(A, M) ((((A) % (M)) + (M)) % (M))
using ll = long long;

using namespace std;

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

    int n, k;
    cin >> n >> k;

    ll ans = 0;

    for (int a = 1; a <= n; a++) {
        int y = a % k;
        if ((2 * k - 2 * y) % k == 0) {
            ll num;
            if (y <= n % k && y != 0)
                num = (n + k - 1) / k;
            else
                num = n / k;
            ans += num * num;
        }
    }

    cout << ans << endl;

    return 0;
}


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));
		char[] s = br.readLine().toCharArray();
		br.close();

		if (s[2] == s[3] && s[4] == s[5]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


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

int main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1; i<n; ++i){
        int a,b;
        a=i;
        b=(n-1)/a;
        ans+=b;
    }
    cout<<ans<<"\n";
}



Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

long long search(vector<vector<int> > &ABC, int n, int min_){
    lower_bound(ABC[n].begin(), ABC[n].end(), min_);
}

void cout_vec(vector<long long> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}
void cout_mat(vector<vector<long long> > &mat){
    for(int i=0; i<mat.size(); i++){
        vector<long long> vec = mat[i];
        cout_vec(mat[i]);
    }
}

int main(){
    int N;
    cin >> N;
    vector<vector<int> > ABC(3, vector<int>(N,0));
    vector<long long> CbiggerB(N,0);
    vector<long long> BCbyB(N+1,0);

    for(int i=0; i<3; i++){
        for(int j=0; j<N; j++){
            cin >> ABC[i][j];
        }
    }
    for(int i=0; i<3; i++){
        sort(ABC[i].begin(), ABC[i].end());
    }
    long long ans = 0;
    for(int i=N-1; i>=0; i--){
        vector<int>::iterator it =lower_bound(ABC[2].begin(), ABC[2].end(), ABC[1][i]+1);
        CbiggerB[i]=(int) N-distance(ABC[2].begin(), it);
        BCbyB[i]+=BCbyB[i+1];
        BCbyB[i]+=(long long) CbiggerB[i];
    }
    for(int i=0; i<N; i++){
        vector<int>::iterator it=lower_bound(ABC[1].begin(), ABC[1].end(), ABC[0][i]+1);
        int bound=(int) distance(ABC[1].begin(), it);
        //cout << bound << endl;
        ans+=BCbyB[bound];
    }
    //cout_vec(CbiggerB);
    //cout_vec(BCbyB);
    cout << ans << endl;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;

signed main()
{
    int N;
    cin >> N;
    vector<ll> place(N + 1); // place[a] := aという値がどのindexにあるか
    for (int i = 1; i <= N; i++) {
        ll a;
        cin >> a;
        place[a] = i;
    }

    ll ans = 0;
    set<ll> used = { 0, N + 1 }; // すでに見た要素のindexを記録


    // ある要素よりも小さい値で,最も近いものを探索する
    // usedには今の要素よりも小さい要素しか入っていない
    for (int i = 1; i <= N; i++) { // i := 要素
        ll r, l;

        auto iter = used.lower_bound(place[i]);
        r = *iter; // 右端を調べる
        l = *(--iter); // その1つ前が左端

        ans += i * (place[i] - l) * (r - place[i]);
        used.insert(place[i]);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n;
	cin >> n;
	string ans = "";
	while (n != 0) {
		if (n % 2 != 0) {
			n--;
			ans = "1" + ans;
		}
		else ans = "0" + ans;
		n /= -2;
	}
	if (ans == "")ans = "0";
	cout << ans << endl;
}


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

using namespace std;
int main()
{
	string S;
	cin >> S;

	int len = S.size();

	for (int i = len - 2; i; i-= 2)
	{
		int r = S.compare(0, i / 2, S, i / 2, i / 2);
		if (r == 0)
		{
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
 
void solve()
{
    LL x;cin>>x;
    LL res=0;
    LL thousand = x/500;
    x = x%500;
    LL five = x/5;
    cout<<1000*thousand + 5*five << endl;

}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

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

int main () {
  int A, B;
  string S;
  cin >> A >> B >> S;
  string ans = "Yes";
  for (int i = 0; i < A; i++) {
    if (S.at(i) =='-') {
      ans = "No";
      break;
    }
  }
  if (S.at(A) != '-') ans = "No";
  for (int i = A+1; i < A+B+1; i++) {
    if (S.at(i) == '-') {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, *A = map(int, read().split())
if N == 1:
    print(A[0] - 1)
    exit()

answer = A[0] - 1
P = 2
for i in A[1:]:
    if i < P:
        continue
    elif i == P:
        P += 1
        continue
    answer += (i - 1) // P

print(answer)


Measured memory_bytes: 14116
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;

#define int ll

const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

struct UnionFind{
    vector<int> par;
    vector<int> siz;
    int c;//親の個数(グループ数)

    void init(int n){
        c=n;
        for(int i=0;i<n;i++){
            par.push_back(i);
            siz.push_back(1);
        }
    }
 
    UnionFind(int n){
        init(n);
    }
 
    int root(int x){
        //根を返す
        if(par[x]==x){
            return x;
        }
        else{
            return (par[x]=root(par[x]));
        }
    }
    bool sameParent(int x,int y){
        return(root(x)==root(y));
    }
    void unite(int x, int y){
        x=root(x);y=root(y);
        if(x==y)    return;
        //データ構造->小を大にくっつける
        if(siz[x]<siz[y]) swap(x,y);
        siz[x] += siz[y];
        par[y]=x;
        c--;
    }
 
    int size(int x){
        return siz[root(x)];
    }
};


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

    int n,m,q;
    cin>>n>>m>>q;

    UnionFind uf(n);
    vector<pair<int,int>> v;
    rep(abababababababa,q){
        int a,b,c;
        cin>>a>>b>>c;
        if(c==0) uf.unite(a,b);
        else v.push_back(make_pair(a,b));
    }

    if(m==n-1){
        if(v.size()){
             cout<<"No"<<endl;
             return 0;
        }
        cout<<"Yes"<<endl;
        return 0;
   }

    for(auto x:v){
        if(uf.sameParent(x.first,x.second)){
            cout<<"No"<<endl;
            return 0;
        }
    }
    int k=uf.c;
   if(m<=n-k+k*(k-1)/2){
       cout<<"Yes"<<endl;
       return 0;
   }
   cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 4076
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
using namespace std;
//cout << fixed << setprecision(0)
int main() { 
  int n;cin >> n;
  int a[100001],c[100001];
  rep(i,n){
    int b;cin >> b;b++;
    a[b]++;
  }
  c[1] = a[1];
  repd(i,2,100001){
    c[i] = c[i-1]+a[i];
  }
  int ans;
  repd(i,3,100001){
    ans = max(ans,c[i]-c[i-3]);
  }
  cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 2*1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 79
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
//vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

ll n, m, k;
ll a[11][11];

int main()
{
   cin >> n >> m;
   for(int i=0; i<=9; i++)
   {
       for(int j=0; j<=9; j++)
       {
           cin >> a[i][j];
       }
   }
   for(int k=0; k<=9; k++)
   {
       for(int i=0; i<=9; i++)
       {
           for(int j=0; j<=9; j++)
           {
               if(i == j) a[i][j] = 0;
               else a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
           }
       }
   }
   ll ans = 0;
   for(int i=1; i<=n; i++)
   {
       for(int j=1; j<=m; j++)
       {
           int x;
           cin >> x;
           if(x != -1 && x != 1)
           {
               ans += a[x][1];
           }
       }
   }
   cout << ans;
}
/*

*/


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

int main() {
	int N, K;
	cin >> N >> K;
	int ans=0;
	for (int i=0; i<N; i++) {
		int x;
		cin >> x;
		if (x < K-x) ans += x*2;
		else ans += (K-x)*2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
def factorize(n):
    fct = []
    b,e = 2,0
    while b*b <= n:
        while n % b == 0:
            n //= b
            e += 1
        if e > 0:
            fct.append((b,e))
        b,e = b+1,0
    if n > 1:
        fct.append((n,1))
    return fct
a,b = map(int,input().split())
ap = set()
for prime,count in factorize(a):
    ap.add(prime)
bp = set()
for prime,count in factorize(b):
    bp.add(prime)
print(len(ap&bp)+1)

Measured memory_bytes: 9140
#include<bits/stdc++.h>
using namespace std;
int i[11111111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0;
  string s;
  cin >>a>>b;
  if(a<9&&b<9) cout <<"Yay!\n";
  else cout <<":(\n";
  return (0);
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		String s = scanner.nextLine();
		
		scanner.close();
		
		String[] list = s.split("");
		
		if (list[2].equals(list[3]) && list[4].equals(list[5])) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23892
N, D = map(int, input().split())
ans = 0
count = 0

for i in range(N):
    num_1, num_2 = map(int, input().split())
    ans = (num_1**2 + num_2**2)**(1/2)
    if(ans <= D):
        count += 1
    else:
        pass
    
print(count)

Measured memory_bytes: 9592
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int MOD = pow(10, 9) + 7;

int kaijou(int n){
    if(n==0) return 1;
    else{
        return ((n%MOD)*(kaijou(n-1)%MOD))%MOD;
    }
}

bool ispow(int n){
    int rn=sqrt(n);
    if(rn*rn==n) return true;
    else return false;
}

signed main() {
    int n; cin>>n;
    string s; cin>>s;
    stack<char> kako;
    
    int left=0;
    int right=0;
    for(int i=n-1;i>=0;i--){
        if(s[i]==')'){
            left++;
        }else{
            if(left>0){
                left--;
            }else right++;
        }
    }

    string ans="";
    for(int i=0;i<left;i++){
        ans+='(';
    }
    ans+=s;
    for(int i=0;i<right;i++){
        ans+=')';
    }

    cout<<ans<<endl;
    
}


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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

map<string, int> freq;

void print(string s) {
    cout << s << " x " << freq[s] << "\n";
}

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


    int n;
    cin >> n;
    while (n--) {
        string s;
        cin >> s;
        ++freq[s];
    }

    print("AC");
    print("WA");
    print("TLE");
    print("RE");

    return 0;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B, C; cin >> A >> B >> C;
  cout << max((LL)0, C-(A-B)) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
bool vis[15];
int n,k;
bool check(int x)
{
	int a;
	while(x)
	{
		a=x%10;
		if(vis[a])
			return 0;
		x/=10;
	}
	return 1;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<=k;i++)
	{
		int a;
		scanf("%d",&a);
		vis[a]=1;
	}
	while(1)
	{
		if(check(n))
		{
			printf("%d\n",n);
			return 0;
		}
		n++;
	}
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;
ll level;
struct edge {
	ll to;
};

vector<edge>G[100010];
ll d[100010];

bool cmp(const pair<ll, ll> &a, const pair<ll, ll> &b) {
	if (a.second == b.second)return a.first < b.first;
	else return a.second > b.second;
}

void dfs(int root,vector<ll> &c) {
	d[root] = c[level];
	level--;
	for (auto itr = G[root].begin();itr != G[root].end();++itr) {
		//cout << itr->to << endl;
		if (d[itr->to] == 0)dfs(itr->to, c);
	}
	return;
}

int main(void) {
	ll n, a, b, ans = 0;
	cin >> n;
	vector<ll>c(n);
	for (int i = 0;i < n-1;i++) {
		cin >> a >> b;
		G[a].push_back({ b });
		G[b].push_back({ a });
	}
	for (ll i = 0;i < n;i++)cin >> c[i];
	sort(c.begin(), c.end());
	level = n - 1;
	for (ll i = 0;i < n - 1;i++)ans += c[i];
	dfs(1, c);
	cout << ans << endl;
	for (ll i = 1;i <= n;i++) {
		if (i == n)cout << d[n] << endl;
		else cout << d[i] << " ";
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
int cnt;
vector<int>q1,q2;
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%lld",&n);n++;
	int now=100;
	while(n!=1)
	{
		if(n&1)n--,q1.push_back(now--);
		else n>>=1,q2.push_back(now--);
		cnt++;
	}
	printf("%d\n",cnt*2);
	for(int i=0;i<q1.size();i++)printf("%d ",q1[i]);
	for(int i=q2.size()-1;i>=0;i--)printf("%d ",q2[i]);
	for(int i=now+1;i<=100;i++)printf("%d ",i);
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	// your code goes here
	int a,n;
	int approve=1;
	
	scanf("%d",&n);
	
	while(n--){
		scanf("%d",&a);
		if(a%2==0){
			if(a%3!=0&&a%5!=0)
				approve=0;
				
		}
	}
	
	if(approve==0)
		printf("DENIED");
	else
		printf("APPROVED");
	return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))

out = [[0 for _ in range(W)] for _ in range(H)]

index = [0, 0]
sign = 1
for color in range(N):
    for number in range(a[color]):
        out[index[0]][index[1]] = color + 1
        if index[0] == H - 1 and sign == 1:
            index[1] += 1
            sign = -1
        elif index[0] == 0 and sign == -1:
            sign = 1
            index[1] += 1
        else:
            index[0] += sign

for i in range(H):
    [print(x, end=' ') for x in out[i]]
    print()

Measured memory_bytes: 3828
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);
		Map<Integer, Integer> valToPlace=  new HashMap<Integer, Integer>();
		boolean[] bingo = new boolean[10];
		for (int i=0; i<3; i++) {
			for (int j=0; j<3; j++) {
				valToPlace.put(sc.nextInt(), i*3 + j + 1);
			}
		}
		int n = sc.nextInt();
		for (int i=0; i<n; i++) {
			int val = sc.nextInt();
			if (valToPlace.get(val) != null) {
				bingo[valToPlace.get(val)] = true;
			}
		}
		System.out.println(checkBingo(bingo));
		sc.close();
	}

	private static String checkBingo(boolean[] bingo) {
		boolean flag = false;
		if ((bingo[1] && bingo[5] && bingo[9]) 
				|| (bingo[1] && bingo[4] && bingo[7]) 
				|| (bingo[1] && bingo[2] && bingo[3]) 
				|| (bingo[2] && bingo[5] && bingo[8]) 
				|| (bingo[3] && bingo[5] && bingo[7]) 
				|| (bingo[3] && bingo[6] && bingo[9]) 
				|| (bingo[4] && bingo[5] && bingo[6]) 
				|| (bingo[7] && bingo[8] && bingo[9]) ) {
			flag = true;
		}
		return flag ? "Yes" : "No";
	}

}


Measured memory_bytes: 27072
#include <iostream>
using namespace std;
int a,b[200],m=100000000,c=0;
int main() {
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	for(int j=0;j<201;j++){
	for(int i=0;i<a;i++){
		c+=(j-100+b[i])*(j-100+b[i]);
	}
	m=min(m,c);	c=0;}
	cout<<m<<endl;
	return 0;
}

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

const int r = 1e5 + 1;
vector <int> adj[r];
int dp[r], n, m;

int dfs(int u) {
    if (dp[u] != -1)
        return dp[u];
    int pth = 0;
    for (auto v : adj[u])
        pth = max(pth, 1 + dfs(v));
    return dp[u] = pth;
}

void solve() {
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dfs(i));
    }
    cout << ans << '\n';
}

int main() {
    memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
    }
    solve();
    return 0;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  //input
  int N,D,X; cin>>N>>D>>X; 
  int sum=0; 
  //compute
  for(int i=0;i<N;i++){
    int A; cin>>A;
    if(D%A==0){
      sum+=D/A;
    }else{
      sum+=(D/A)+1;
    }
  }
  cout<<sum+X<<endl;
}
  



Measured memory_bytes: 256
// #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>

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()

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  
  rep(i,N) {
    A[i] -= i+1;
  }
  sort(all(A));
  ll med = A[N/2];
  ll ans = 0;
  rep(i,N) {
    ans += abs(A[i] - med);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long

/*************** using variables ***************/
/**********************************************/

int solve(int n, vector<int> w){
    bool dp[305][305];
    LL dp2[305];
    
    REP(i, 305){
        dp2[i] = 0;
        REP(j, 305){
            dp[i][j] = false;
        }
    }

    for(int i = 1; i < n; i++){
        if(abs(w[i-1]-w[i]) <= 1) dp[i-1][i] = true;
    }

    for(int len = 4; len <= n; len += 2){
        REP(l, n){
            int r = l + len - 1;
            if(r >= n) break;

            for(int c = l+2; c < r; c += 2){
                if(dp[l][c-1] && dp[c][r]) dp[l][r] = true;
            }
            
            if(abs(w[l]-w[r]) <= 1 && dp[l+1][r-1]){
                dp[l][r] = true;
            }
        }
    }

    FOR(r, 1, n){
        dp2[r] = dp2[r-1];
        REP(l, r){
            if(dp[l][r]){
                if(l == 0) dp2[r] = max(dp2[r], r - l + 1);
                else dp2[r] = max(dp2[r], dp2[l-1] + (r - l + 1));
            }
        }
    }
    return dp2[n-1];
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    while(cin >> n, n){
        vector<int> w(n, 0);   
        REP(i, n) cin >> w[i];
        cout << solve(n, w) << endl;
    }
   
}



Measured memory_bytes: 3236