akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long


int main()
{
	int W, H, N, x[110], y[110], a[110];
	cin >> W >> H >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> a[i];
	}
	int an[110][110] = { 0 };
	for (int k = 0; k < N; k++) {
		if (a[k] == 1) {
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < x[k]; j++) {
					an[i][j] = 1;
				}
			}
		}
		else if (a[k] == 2) {
			for (int i = 0; i < H; i++) {
				for (int j = x[k]; j < W; j++) {
					an[i][j] = 1;
				}
			}
		}
		else if (a[k] == 3) {
			for (int i = 0; i < y[k]; i++) {
				for (int j = 0; j < W; j++) {
					an[i][j] = 1;
				}
			}
		}
		else {
			for (int i = y[k]; i < H; i++) {
				for (int j = 0; j < W; j++) {
					an[i][j] = 1;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (an[i][j] == 0) ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import collections
import sys

n = int(input())
a = list(map(int, input().split()))
c = collections.Counter(a)
value = list(c.values())
key = list(c.keys())

if 0 in key:
    if len(c) == 1 and key[0] == 0:
        print('Yes')
        sys.exit()
    elif len(c) == 2:
        for num, count in c.items():
            if num == 0:
                num0 = count
            else:
                numelse = count
        if num0 * 2 == numelse:
            print('Yes')
            sys.exit()
    else:
        print('No')
        sys.exit()

if len(c) != 3:
    print('No')
    sys.exit()

if value[0] != value[1] or value[1] != value[2] or value[2] != value[0]:
    print('No')
    sys.exit()

if key[0] ^ key[1] ^ key[2] != 0:
    print('No')
    sys.exit()

print('Yes')

Measured memory_bytes: 14468
a = list(map(int, input().split()))
n = []
for i in range(len(a)):
  if a[i] % 2 == 0: n.append(i+1)
if len(n) == 3:
  a.sort()
  ans = (a[2]-a[0]) // 2 + (a[2] - a[1]) // 2
elif len(n) == 2:
  N = 3 - sum(n) - 1 #奇数
  ans = 0
  if a[N] != max(a):
    while a[N] < max(a):
      a[N] += 2
      ans += 1
  a.sort()
  ans += (a[1] - a[0]) // 2 + a[2] - a[1]
elif len(n) == 1:
  for i in range(len(a)):
    if a[i] % 2 != 0:
      a[i] += 1
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2 + 1
else:
  a.sort()
  ans = (a[2] - a[0]) // 2 + (a[2] - a[1]) // 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 4e5 + 7;

int a[N], b[N], ok[N], okk[N], c[N], d[N], fail[N];
int n;

void goo() {
	for(int i=1,j=fail[0]=-1;i<n;i++) {
		while(j >= 0 && d[j+1] != d[i])
			j = fail[j];
		if(d[j+1] == d[i])
			j++;
		fail[i] = j;
	}
	for(int i=0,j=-1;i<2*n;i++) {
		while(j >= 0 && (j == n - 1 || d[j+1] != c[i]))
			j = fail[j];
		if(d[j+1] == c[i])
			j++;
		if(j == n - 1) okk[i-n+1] = 1;
	}
}

void go(int bit) {
	for(int i=0;i<2*n;i++)
		c[i] = a[i] >> bit & 1;
	for(int i=0;i<n;i++)
		d[i] = b[i] >> bit & 1;
	for(int i=0;i<n;i++) okk[i] = 0;
	goo();
	for(int i=0;i<n;i++)
		d[i] ^= 1;
	goo();
	for(int i=0;i<n;i++) ok[i] &= okk[i];
}

signed main()
{
	IO_OP;	

	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> a[i];
		a[i+n] = a[i];
		ok[i] = 1;
	}	
	for(int i=0;i<n;i++)
		cin >> b[i];
	for(int i=0;i<30;i++)
		go(i);
	for(int i=0;i<n;i++)
		if(ok[i]) cout << i << " " << (a[i] ^ b[0]) << endl;
}





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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;

LL n, a, b;
VL X;
// 걷거나, 텔레포트로 모든 마을을 방문할 때,
// 최소의 피로도를 반환한다.
ULL minFatigue()
{
	ULL ret = 0;
	for(int i = 0; i + 1 < n; ++i) {
		LL dist = X[i + 1] - X[i];
		if(dist * a < b)
			ret += 1ull * dist * a;
		else
			ret += b;
	}
	return ret;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n >> a >> b;

	X = VL(n);
	REP(i, 0, n) cin >> X[i];

	cout << minFatigue() << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
map<string,int> mp;
inline int read() {
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int n;
string s;
int main() {
	n=read();
	for (register int i=1;i<=n;++i) {
		cin>>s;
		if (!mp.count(s)) mp[s]=1;
		else ++mp[s];
	}
	printf("AC x %d\n",mp["AC"]);
	printf("WA x %d\n",mp["WA"]);
	printf("TLE x %d\n",mp["TLE"]);
	printf("RE x %d\n",mp["RE"]);
	return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  double W, H, x, y;
  cin >> W >> H >> x >> y;
  int p;
  if ((x == W / 2) && (y == H / 2))
    p = 1;
  else p = 0;
  cout << W * H / 2 << " " << p << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[0]*n
b=[0]*n
c=[0]*n
for i in range(n):
  a[i],b[i],c[i]=map(int,input().split())
ans=0
for i in range(2):
  for j in range(2):
    for k in range(2):
      lis=sorted([x*(-1)**i + y*(-1)**j + z*(-1)**k for x,y,z in zip(a,b,c)])
      lis=lis[n-m:]
      ans=max(sum(lis),ans)
print(ans)

Measured memory_bytes: 3188
n,m = map(int, input().split())
a = set([int(input()) for i in range(m)])
memo = [0]*(n+1)
 
memo[0] = 1
if 1 in a:
    memo[1] = 0
else:
    memo[1] = 1
for i in range(2,n+1):
    if i in a:
        continue
    memo[i] = (memo[i-1] + memo[i-2])%1000000007
    
print(memo[n])

Measured memory_bytes: 56664
#include <bits/stdc++.h>
#define all(a) (a).begin(),(a).end()
using namespace std;

int main(){
	ios_base::sync_with_stdio(false);

	int n , w;
	cin >> n >> w;

	vector<long long>dp(w+1,0);

	for(int i=0;i<n;i++){
		long long weight , value;
		cin >> weight >> value ;
		for(long long j=w;j>=weight;j--){
			dp[j] = max(dp[j],dp[j-weight] + value);
		}
	}

	cout << dp.back() << endl ;

	return 0;
}


Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int flag=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='C')
		{
			for(int j=i+1;j<s.size();j++)
			{
				if(s[j]=='F')
				{
					flag=1;
					cout<<"Yes";
					return 0;
				}
			}
		}
	}
	if(flag==0)
	{
		cout<<"No";
	}
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;
typedef pair<int,int> P;

class BECC{
private:
    int N;
    vector<vector<int>> G;
    vector<int> order,inS;
    stack<int> S,roots;
    vector<int> cmp;
public:
    vector<P> bridge;
    vector<vector<int>> bccs;
    vector<vector<int>> dcmp;//分解後のグラフ
    BECC(int n,vector<vector<int>> graph){
        N = n;
        G = graph;
        order = inS = cmp = vector<int>(N+1,0);
    }
    void dfs(int cur,int prev,int k){
        order[cur] = ++k; //訪問順に番号付け
        S.push(cur); inS[cur] = true;//訪問した頂点の集合に追加
        roots.push(cur);//各bccの根を管理
        for(auto to:G[cur]){
            if(order[to]==0) dfs(to,cur,k);
            else if(to!=prev && inS[to]){//後退辺なら
                while(order[roots.top()]>order[to]) roots.pop();//(to,cur]を捨てる
            }
        }
        if(cur==roots.top()){
            if(prev!=-1) bridge.emplace_back(prev,cur);//根でないなら橋になる
            vector<int> bcc;
            while(true){
                int node = S.top(); S.pop(); inS[node] = false;//nodeを捨てる
                bcc.emplace_back(node);//nodeをbccに追加
                cmp[node] = bccs.size();
                if(node==cur) break;
            }
            bccs.emplace_back(bcc);
            roots.pop();
        }
    }
    int find(int n){return cmp[n];}
    int cmp_size(int n){return bccs[cmp[n]].size();}
    int size(int n){return bccs[n].size();}
    void decomposition(){
        int k = 0;
        bccs.push_back(vector<int>{});
        for(int i=1;i<=N;i++) if(order[i]==0) dfs(i,-1,k);
        dcmp = vector<vector<int>>(bccs.size());
        for(auto x:bridge){
            dcmp[cmp[x.first]].push_back(cmp[x.second]);
            dcmp[cmp[x.second]].push_back(cmp[x.first]);
        }
    }
};

vector<int> dp(100010,0),dp2(100010,0);
vector<int> ok(100010,0);
vector<int> W(100010,0);
vector<int> S(100010,0);
void dfs(int n,int m,BECC& becc){
    int ma = 0;
    ok[n] = (becc.size(n)!=1);
    for(auto x:becc.dcmp[n]){
        if(x!=m){
            dfs(x,n,becc);
            if(ok[x]) dp[n] += dp[x];
            dp2[n] = max(dp2[n],dp2[x]);
            ok[n] = (ok[n] | ok[x]);
        }
    }
    if(!ok[n]) dp2[n] += S[n];
    else dp[n] += S[n];
}
int N,M;
int main(){
    cin >> N >> M;
    for(int i=1;i<=N;i++) cin >> W[i];
    vector<vector<int>> v(N+1);
    int a,b;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    BECC becc(N,v);
    becc.decomposition();
    for(int i=1;i<=N;i++){
        S[becc.find(i)] += W[i];
    }
    dfs(becc.find(1),-1,becc);
    cout << dp[becc.find(1)]+dp2[becc.find(1)] << endl;
}


Measured memory_bytes: 36864
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
string s[100100];
ll ans = 0ll;
map<string,ll> m;
int main(){
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> s[i];
		sort(all(s[i]));
		ans += m[s[i]];
		m[s[i]]++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 18176
#include<bits/stdc++.h>
using namespace std;
const int N=300005;
int read(){
	int x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1; ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct Edg{
	int nxt,poi;
}e[N<<1];
int rt=0,l=0,first[N],a[N],f[N],c[N],g[N],ans=0,n,d[N],size[N],x[N],y[N],m,zs=0,tot=0;
bool le[N],pd[N];
char ch[N];
void addedge(int u,int v){
	l++;
	e[l].nxt=first[u];
	e[l].poi=v;
	first[u]=l;
}
void dfs(int u,int fa){
	if (c[u]==1) pd[u]=1;
	for (int p=first[u];p;p=e[p].nxt){
		int v=e[p].poi;
		if (v==fa) continue;
		dfs(v,u);
		if (!pd[v]) d[v]++,d[u]++;
		pd[u]&=pd[v];
	}
}
void dp(int u,int fa){
	bool flag=0;
	int mx1=0,mx2=0; ans+=d[u];
	if ((c[u]+d[u])%2==0) a[u]=2,ans++;
	for (int p=first[u];p;p=e[p].nxt){
		int v=e[p].poi;
		if (v==fa||pd[v]) continue;
		flag=1; dp(v,u);
		tot=max(tot,max(f[v]+mx2,g[v]+mx1)+a[u]);
		mx1=max(mx1,f[v]); mx2=max(mx2,g[v]);
	}
	f[u]=mx1+a[u]; if (flag==1) g[u]=mx2+a[u]; else g[u]=-1e9; 
}
int main(){
	n=read();
	for (int i=1;i<n;i++){
		int u=read(),v=read();
		addedge(u,v); addedge(v,u); 
	}
	scanf("%s",ch+1);
	rt=0;
	for (int i=1;i<=n;i++){
		if (ch[i]=='W'){c[i]=0; rt=i;}
		else{c[i]=1;  }
	}
	dfs(rt,rt); 
	tot=0;
	dp(rt,rt);
	ans-=tot;
	if (rt==0) ans=0;
	printf("%d\n",ans);
	return 0; 
}

Measured memory_bytes: 18432
#include <bits/stdc++.h> 
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
#define MAX 100005
#define DEBUG 0 
#define LIMIT (LONG_MAX / 10)
#define POSITIVE_LAST_D (LONG_MAX % 10)
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;

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

    if(h%a==0){
        cout<<h/a<<endl;
    }else{
        cout<<h/a+1<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for (int i = (a); i < (b); i++)
//#include "library/debug.cpp"

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

    ll i, o, t, j, l, s, z;
    cin >> i >> o >> t >> j >> l >> s >> z;
    ll ans = 0;
    t = s = z = 0;
    ans = i / 2 * 2 + j / 2 * 2 + l / 2 * 2;
    if (i > 0 && j > 0 && l > 0) {
        ll x = 3;
        i--, j--, l--;
        x += i / 2 * 2 + j / 2 * 2 + l / 2 * 2;
        ans = max(ans, x);
    }
    ans += o;
    cout << ans << endl;

    return 0;
}

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

map<char, int> mp;

int main() {
	string s;
  	cin >> s;
  	for (int i = 0; i < s.size(); i++)
    	mp[s[i]] = true;
	cout << (!(mp['S'] ^ mp['N']) && !(mp['E'] ^ mp['W'])? "Yes": "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long LL;

int n, a[200010], len, ans = 1, vt[200010], p;
LL k;

int main() {
    scanf("%d%lld", &n, &k);
    for (int i = 1 ; i <= n ; i++) scanf("%d", &a[i]);
    for (int i = 1, j = 0 ; ; i = a[i]) {
        if (vt[i]) {
            len = j - vt[i] + 1;
            p = i;
            break;
        }
        vt[i] = ++j;
    }
    int cur = 1;
    while (k > 0) {
        if (p == cur) {
            k %= len;
            if (!k) {
                printf("%d", p);
                return 0;
            }
        }
        cur= a[cur];
        k--;
    }
    printf("%d", cur);
}


Measured memory_bytes: 3244
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, M;
	cin >> N >> M;

	vector<Int> A(N);
	for (Int i = 0; i < N; i++) {
		cin >> A[i];
	}
	
	sort(A.begin(), A.end());

	vector<pair<Int, Int>> cb;

	Int b, c;
	for (Int i = 0; i < M; i++) {
		cin >> b >> c;
		cb.push_back(make_pair(c, b));
	}

	sort(cb.begin(), cb.end());

	Int cnt = 0;
	Int flag = 0;
	for (Int i = M-1; i >= 0; i--) {
		while (cb[i].second) {
			if (cnt < N && cb[i].first >= A[cnt]) {
				A[cnt] = cb[i].first;
				cb[i].second--;
			}
			cnt++;
			if (cnt == N) {
				flag = 1;
				break;
			}
		}
		if (flag)break;
	}

	Int ans = 0;
	for (Int i = 0; i < N; i++) {
		ans += A[i];
	}

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

Measured memory_bytes: 3188
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=500050;
int n,m;
int c[26][maxn];
char s[maxn];
int lowbit(int x){return x&-x;}
void add(int t,int x,int p)
{
	while(x<=n)
	{
		c[t][x]+=p;
		x+=lowbit(x);
	}
}
int query(int t,int x)
{
	int res=0;
	while(x)
	{
		res+=c[t][x];
		x-=lowbit(x);
	}
	return res;
}
int main()
{
	cin>>n;
	cin>>(s+1);
	cin>>m;
	for(int i=1;i<=n;i++) add(s[i]-'a',i,1);
	while(m--)
	{
		int opt;read(opt);
		if(opt==1)
		{
			int x;char y;
			cin>>x>>y;
			add(s[x]-'a',x,-1);
			add(y-'a',x,1);
			s[x]=y;
		}
		else
		{
			int ans=0;
			int x,y;read(x),read(y);
			for(int i=0;i<26;i++)
			{
				if(query(i,y)-query(i,x-1)) ans++;
			}
			cout<<ans<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 51584
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ADiscountFare {
public:
	void solve(istream& in, ostream& out) {
        int x, y;
        in >> x >> y;
        out << x + y / 2 << endl;
	}
};

int main() {
	ADiscountFare solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string S;
	cin >> S;
	int ans = 0;
	for (int i = 0;i<4;i++){
		if (S[i] == '+'){
			ans++;
		}
		else{
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register
inline int read(){
	re int t=0;
	re char v=getchar();
	while(v<'0'||v>'9')v=getchar();
	while(v>='0'&&v<='9'){
		t=(t<<3)+(t<<1)+(v^48);
		v=getchar();
	}
	return t;
}
char s[1002],t[1002];
int main(){
scanf("%s%s",s+1,t+1);
printf("%s%s",t+1,s+1);
}

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

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> heights(N+1, 0);

    for(int i=1; i<N+1; i++){
        cin >> heights.at(i);
    }

    vector<bool> isGood(N+1, true);

    vector<set<int>> groups(N+1);
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        groups.at(a).insert(b);
        groups.at(b).insert(a);
    }

    for(int i=1; i<N+1; i++){
        if(!isGood.at(i))continue;
        int height = heights.at(i);
        for(int index : groups.at(i)){
            if(height > heights.at(index)){
                isGood.at(index) = false;
            }else{
                isGood.at(i) = false;
            }
        }
    }

    int res = 0;
    for(int i=1; i<N+1; i++){
        if(isGood.at(i))res++;
    }
    cout << res;
}

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

int main(){
    int X, Y;
    scanf("%d%d", &X, &Y);

    for(int i = 0; i <= X; i ++){
        if(i*2+(X-i)*4 == Y){
            printf("Yes");
            return 0;
        }
    }

    printf("No");
    return 0;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

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

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const long long MOD = 1000000007;
ll k,n;

long long mod_pow(long long a, long long b)
{
  if (b == 0) return 1;
  long long ret = mod_pow(a, b/2);
  ret = ret * ret % MOD;
  if (b % 2 == 1) ret = a * ret % MOD;
  return ret;
}

long long comb(long long a, long long b)
{
  if (b > a - b) return comb(a, a - b);

  long long num = 1;
  long long denom = 1;

  for (int i = 1; i <= b; i++) {
    num = num * (a - i + 1) % MOD;
    denom = denom * i % MOD;
  }

  return num * mod_pow(denom, MOD-2) % MOD;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> k;

  forn1(i,k) {
    if (n-k+1 < i) {
      cout << 0 << "\n";
    } else {
      ll res = comb(k-1,i-1) * comb(n-k+1,i) % MOD;
      cout << res << "\n";
    }
  }


  return 0;
}


Measured memory_bytes: 256
class UnionFind:
    def __init__(self, sz: int):
        self._par: list[int] = [-1] * sz

    def root(self, a: int):
        if self._par[a] < 0:
            return a
        self._par[a] = self.root(self._par[a])
        return self._par[a]
    
    def size(self, a: int):
        return -self._par[self.root(a)]
    
    def unite(self, a, b):
        a = self.root(a)
        b = self.root(b)
        if a != b:
            if self.size(a) < self.size(b):
                a, b = b, a
            self._par[a] += self._par[b]
            self._par[b] = a
    
if __name__ == '__main__':
    N, M = map(int, input().split())
    uf = UnionFind(N + 1)
    for i in range(M):
        a, b = map(int, input().split())
        uf.unite(a, b)
    ans = 1
    for i in range(1, N + 1):
        ans = max(ans, uf.size(i))
    print(ans)

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

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB emplace_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

int main(){
    ll n, l;
    cin >> n >> l;
    ll ans = 0, min_ = 1000000;
    REP(i, n){
        ll tmp = l + i;
        if(abs(min_) > abs(tmp)) min_ = tmp;
        ans += tmp;
    }
    cout << ans - min_;
    return 0;
}

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

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main() {
  int N;
  ll result = 0;
  cin >> N;
  FOR(i, 1, N+1) {
    if (i % 3 != 0 && i % 5 != 0) {
      result += i;
    }
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3624
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.par = [i for i in range(n+1)]  # �?要�?の親要�?の番号を�?�納するリス�?
        self.rank = [0] * (n+1)
        self.size = [1] * (n+1)  # 根?��ルート）�?�場合、そのグループ�?�要�?数を�?�納するリス�?

    # 要�? x が属するグループ�?�根を返す
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 要�? x が属するグループと要�? y が属するグループとを併合す�?
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 要�? x, y が同じグループに属するかど�?かを返す
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
    # 要�? x が属するグループに属する要�?をリストで返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(1,self.n+1) if self.find(i) == root]

    # 要�? x が属するグループ�?�サイズ?��要�?数?��を返す
    def get_size(self, x):
        return self.size[self.find(x)]

    # すべての根の要�?をリストで返す
    def roots(self):
        return [i for i, x in enumerate(self.par) if x == i and i != 0]
    
    # グループ�?�数を返す
    def group_count(self):
        return len(self.roots())
    
    # {ルート要�?: [そ�?�グループに含まれる要�?のリス�?], ...} の辞書を返す
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    a,b = map(int,input().split())
    uf.union(a,b)
print(len(uf.roots())-1)

Measured memory_bytes: 76852
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = String.valueOf(n);
		int sTotal = 0;
		for (int i = 0; i < s.length(); i++) {
			sTotal += Integer.parseInt(s.substring(i, i + 1));
		}
		if (n % sTotal == 0) {
			System.out.print("Yes");
		} else{
			System.out.print("No");
		}
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

int main() {
  i64 limit = 300000;
  vector<i64> prime(limit, 0);
  i64 num[] = {1, 6};
  vector<i64> ps;
  for(i64 i = 0, j = 1; i * 7 + num[j] < limit; i += j, j ^= 1) {
    i64 n = i * 7 + num[j];
    if(prime[n] == 0) {
      prime[n] = 1;
      ps.push_back(n);
      for(i64 p = 0, q = 1; n * (p * 7 + num[q]) < limit; p += q, q ^= 1) {
        prime[n * (p * 7 + num[q])] = -1;
      }
    }
  }
  i64 n;
  while(cin >> n, n != 1) {
    cout << n << ":";
    for(auto x: ps) {
      if(n % x == 0) {
        cout << " " << x;
      }
    }
    cout << endl;
  }
}



Measured memory_bytes: 5548
#include<iostream>
#include<cstdio>
#include<iomanip>
using namespace std;
long long l, r;
int main()
{
	ios::sync_with_stdio(false);
	cin>>l>>r;
	int min1=(1<<30);
	int l1=l%2019, r1=r%2019;
	if(l/2019!=r/2019)
	{
		cout<<"0";
		return 0;
	}
	else
	{
		for(long long i=l; i<=r; i++)
			for(long long j=i+1; j<=r; j++)
			{
				if(min1>i*j%2019)
					min1=i*j%2019;
			}
			cout<<min1<<endl;
	}
	return 0;
}

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



int ddp(vector<int>&nums) {
	if(nums.size()==0 || nums.size()==1) return 0 ;
	int dp[nums.size()] ;
	dp[0] =0 ;
	dp[1] = abs(nums[1]-nums[0]) ;
	for(int i =2;i<nums.size();i++){
		dp[i] = min(dp[i-1]+abs(nums[i]-nums[i-1]) , dp[i-2]+abs(nums[i]-nums[i-2])) ;
	}
	return dp[nums.size()-1] ;
} 

int main() {
	int N; cin >> N ;
	vector<int>arr(N) ;
	for(int i =0 ;i<N;i++) {
		cin >> arr[i] ;
	}
    int ans = ddp(arr) ;
	cout << ans ;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
int main(){
    string botun[] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
 
        string ans=""; 
        int btn=0,count=0;
        for(int j=0;j<s.size();j++){
            if(btn ==0 &&(int)s[j]>0){
                btn=s[j]-'0';
                count=0;
            }else if(btn==(int)s[j]-'0'){
                count++;
            }else if((int)s[j]-'0'==0&&btn>0){
                ans += botun[btn][count % botun[btn].size()];
                btn=0;
                count=0;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
n = int(input())
ans = []
while n != 0:
  S = input()
  players = [0 for _ in range(0, n)]
  buf = 0
  for idx, c in enumerate(S, 0):
    target_player = idx % n
    if c == 'S':
      # 坊主
      players[target_player] += 1
      buf += players[target_player]
      players[target_player] = 0
    elif c == 'M':
      # 男
      players[target_player] += 1
    elif c == 'L':
      # 女
      players[target_player] += 1
      players[target_player] += buf
      buf = 0

  players = sorted(players)
  players.append(buf)
  ans.append(players)
  n = int(input())

for players in ans:
  print(' '.join(map(lambda s: str(s), players)))


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

using namespace std;

#pragma GCC optimize ("-O3")

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define vll vector<ll> 
#define vs vector<string>
#define vc vector<char>
#define vpll vector<pair<ll,ll>>
#define tc ll t=0;cin>>t;while(t--)
#define pb push_back
#define pop pop_back
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define maxe *max_element
#define mine *min_element
#define f first
#define s second
#define vli vll::iterator 
#define mp make_pair
#define unmap unordered_map
#define unmapll unordered_map<ll,llt>
#define max_val 99999999
#define min_val -99999999
#define mod 1000000007
const ld PI = 3.141592653589793;

bool isPowerOfTwo (int x) 
{ 
  return x && (!(x&(x-1))); 
} 


int main()
{
    IOS
    #ifdef LOCAL
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\input.txt","r",stdin);
            freopen("C:\\Users\\Just Coding Things\\Codeforces\\output.txt","w",stdout);
        #endif
    
    string s;
    cin>>s;
    if(s=="ARC")cout<<"ABC";
    else cout<<"ARC";
return 0;
}

Measured memory_bytes: 3580
import numpy as np

H,W=map(int,input().split())
max_value = H+W
matrix =[]

for _ in range(H):
    matrix.append([0 if i == '#' else max_value for i in list(input())])
matrix = np.array(matrix)

for c in range(W-1):
    matrix[:,c+1] = np.minimum(matrix[:,c]+1,matrix[:,c+1])
for c in range(W-1,0,-1):
    matrix[:,c-1] = np.minimum(matrix[:,c-1],matrix[:,c]+1)
for r in range(H-1):
    matrix[r+1,:] = np.minimum(matrix[r,:]+1,matrix[r+1,:])
for r in range(H-1,0,-1):
    matrix[r-1,:] = np.minimum(matrix[r,:]+1,matrix[r-1,:])
print(np.max(matrix))


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

int main(){
    string n; cin>>n;
    bool val = false;
    for(auto x:n)if(x=='7')val=true;
    cout<<(val?"Yes":"No");
    return 0;
}



Measured memory_bytes: 3572
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] a = new String[h];
		int[] if_tate = new int[w];
		int[] if_yoko = new int[h];

		for (int i = 0; i < h; i++) {
			a[i] = sc.next();
		}

		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				if (a[j].substring(i, i + 1).equals("#")) {
					if_tate[i] = 1;
					break;
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i].substring(j, j + 1).equals("#")) {
					if_yoko[i] = 1;
					break;
				}
			}
		}

		for (int i = 0; i < h; i++) {
			if (if_yoko[i] == 0) {
				continue;
			}

			for (int j = 0; j < w; j++) {
				if (if_tate[j] == 0) {
					continue;
				}
				System.out.print(a[i].substring(j, j + 1));
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 26336
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int dp[1010][1010];
bool fld[1010][1010];
int main(){
	int h,w,n;
	while(1){
		cin>>h>>w>>n;
		if(h==0&&w==0&&n==0)break;
		REP(i,h)REP(j,w)cin>>fld[j][i];
		memset(dp,0,sizeof(dp));
		dp[0][0]=n-1;
		REP(i,h){
			REP(j,w){
				if(j!=0){
					dp[j][i]+=dp[j-1][i]/2;
					if(dp[j-1][i]&1&&fld[j-1][i])dp[j][i]++;
				}
				if(i!=0){
					dp[j][i]+=dp[j][i-1]/2;
					if(dp[j][i-1]&1&&!fld[j][i-1])dp[j][i]++;
				}
			}
		}
		REP(i,h)REP(j,w)fld[j][i]=(fld[j][i]+dp[j][i])%2;
		int nx=0,ny=0;
		while(nx<w&&ny<h){
			if(fld[nx][ny])nx++;
			else ny++;
		}
		cout<<ny+1<<" "<<nx+1<<endl;
	}
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 300000;

int m, n;
struct Flow{
    struct edge{
        int to, cap, rev;
    };
    vector<edge> G[MAX_V];//??£??\?????????
    bool used[MAX_V];

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

    //?¢???????????????¢???
    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;
        while(1){
            memset(used, 0, sizeof(used));
            int f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }
};

int b[510], r[510];
int main(void){
    while(1){
        cin >> m >> n;
        if(m == 0 && n == 0) return 0;
        rep(i, m) cin >> b[i];
        rep(i, n) cin >> r[i];
        int s = m + n, t = m + n + 1;
        Flow mf;
        //s -> b
        rep(i, m){
            mf.add_edge(s, i, 1);
        }
        //r -> t
        rep(i, n){
            mf.add_edge(m + i, t, 1);
        }
        //b -> r
        rep(i, m)rep(j, n){
            if(__gcd(b[i], r[j]) > 1){//1??\???????´???°?????????
                mf.add_edge(i, m + j, 1);
            }
        }
        printf("%d\n", mf.max_flow(s, t));
    }
    return 0;
}


Measured memory_bytes: 14808
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int n, h[114514];

int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> h[i];
  int ans = 0, cnt = 0;
  for(int i=1;i<n;i++){
    if (h[i-1] >= h[i]){
      cnt++;
    }else{
      ans = max(cnt, ans);
      cnt = 0;
    }
  }
  ans = max(cnt, ans);
  cout << ans << endl;  
  return 0;
}
  

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define each(i, mp) for(auto& i:mp)

const int INF = 1001001001;

int main() {
  ll a;
  long double b;
  cin >> a >> b;

  ll ans = floor((long double)a*b);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
const int NMAX = 100005;
vector<int> par(NMAX);
vector<int> siz(NMAX);
int n;
void init(){
    for(int i=0;i<n;i++){
        par.at(i) = i;
        siz.at(i) = 1;
    }
}

int root(int x){
    if(par.at(x) == x){
        return x;
    }else{
        return par.at(x) = root(par.at(x));
    }
}

bool same(int x,int y){
    return root(x) == root(y);
}

bool unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x==y){
        return false;
    }
    if(siz[x]<siz[y]) swap(x, y);
    siz[x] += siz[y];
    par.at(y) = x;
    return true;
}

int size(int x){
    return siz.at(root(x));
}

int deg[100005];
vector<int> to[100005];

int main(){
  	int m,k;
  	cin >> n >> m >> k;
  	init();
  	for(int i=0;i<m;i++){
      int a,b;
      cin >> a >> b;
      --a;--b;
      unite(a,b);
      deg[a]++;
      deg[b]++;
    }
  
  	for(int i=0;i<k;i++){
      int c,d;
      cin >> c >> d;
      --c;--d;
      to[c].push_back(d);
      to[d].push_back(c);
    }
  
  	for(int i=0;i<n;i++){
      int ans = size(i) - deg[i] - 1;
      for(auto x : to[i]){
        if(same(i,x)){
          ans--;
        }
      }
      cout << ans << " ";
    }
  	
  	cout << endl;
  
    return(0);
}


Measured memory_bytes: 9516
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }

  ll ans = 0;
  while (true)
  {
    bool ok = true;
    for (ll i = 0; i < N; i++)
    {
      if (A.at(i) > N - 1)
      {
        ok = false;
        break;
      }
    }
    if (ok)
      break;

    for (ll i = 0; i < N; i++)
    {
      ll K = A.at(i) / N;
      for (ll j = 0; j < N; j++)
      {
        A.at(j) += ((j == i) ? -N * K : K);
      }
      ans += K;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
typedef pair<ll,ll> l_l;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back


ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}


string bina(ll i,ll x){
    string ans="";
    while(i>0){
        if(i%2==1){
            ans='1'+ans;
            i=i/2;
        }else{
            ans='0'+ans;
            i=i/2;
        }
    }
    while(ans.size()<x){
        ans='0'+ans;
    }
    return ans;
}


int main(){
    ll n;cin>>n;
    ll a[n+1];
    ll x[20][20];
    ll y[20][20];
    rep(i,1,n){
        cin>>a[i];
        rep(j,1,a[i]){
            cin>>x[i][j]>>y[i][j];
        }
    }
    string s;
    bool b;
    ll ans=0;
    int c;
    string ss;
    ll ii;
    ll p=1;
    rep(i,1,n){
        p=p*2;
    }
    rep(i,0,p-1){
        s=bina(i,n);
        b=true;
        rep(j,1,n){
            rep(k,1,a[j]){
                ss=s[x[j][k]-1];
                ii=stoll(ss);
                if(ii==y[j][k]){
                    if(s[j-1]=='1'){
                        
                    }else{
                        
                    }
                }else{
                    if(s[j-1]=='1'){
                        b=false;
                    }else{
                        
                    }
                }
            }
        }
        if(b){
            c=0;
            //cout<<s<<endl;
            rep(j,0,n-1){
                if(s[j]=='1'){
                    c++;
                }
            }
            ans=max(ans,c);
        }
        
        
    }
    cout<<ans<<endl;
    
    return 0;
}



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


// [pos][from] -> cost
unordered_map<ll, vector<tuple<ll, ll>>> field;

unordered_map<ll, ll> memo;
ll solve(ll p) {
	if (p <= 0) return 0;
	auto it = memo.find(p);
	if (it != memo.end()) {
		return it->second;
	}
	ll res = p;
	for (auto nx : field[p]) {
		if (p == get<0>(nx)) continue;
		res = min(res, solve(get<0>(nx)) + get<1>(nx));
	}
	return memo[p] = res;
}

int main() {
	ll L;
	int n;
	while (cin >> L >> n) {
		memo.clear(); field.clear();
		vector<ll> points;
		points.push_back(0);
		for (int i = 0; i < n; i++) {
			ll p, d, t;
			cin >> p >> d >> t;
			field[p + d].push_back(make_tuple(p, t));
			points.push_back(p);
			points.push_back(p + d);
		}
		points.push_back(L);
		sort(points.begin(), points.end());
		points.erase(unique(points.begin(), points.end()), points.end());
		for (int i = 1; i < points.size(); ++i) {
			const int pos = points[i];
			const int pre = points[i - 1];
			field[pos].push_back(make_tuple(pre, pos - pre));
		}
		// for (auto f : field) {
		// 	cout << f.first << ": ";
		// 	for (auto p : f.second) cout << '(' << get<0>(p)<<','<<get<1>(p) << ") ";
		// 	cout << endl;
		// }
		cout << solve(L) << endl;
	}
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl;
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl;
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  ll n;
  cin >> n;
  vll t(n), a(n);
  rep(i,n) {
    cin >> t[i] >> a[i];
  }

  ll nx = 1, ny = 1;
  rep(i,n) {
    ll m = max(dup(nx,t[i]), dup(ny,a[i]));
    nx = m*t[i], ny = m*a[i];
  }

  cout << nx + ny << endl;
  return 0;
}

Measured memory_bytes: 256
func main() {
    let nd = readLine()!.split(separator: " ").map{Int($0)!}
    var xyList = [[Int]]()
    for _ in 0...nd[0]-1 {
        xyList.append(readLine()!.split(separator: " ").map{Int($0)!})
    }
    print(xyList.filter{$0[0]*$0[0]+$0[1]*$0[1] <= nd[1]*nd[1]}.count)
}

main()




Measured memory_bytes: 24580
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

template<typename T> bool chmin(T& a, T b) {return a > b ? a = b, true : false;}

template<typename T> bool chmax(T& a, T b) {return a < b ? a = b, true : false;}

template<typename T> void sort(vector<T>& v) {sort(v.begin(), v.end());}

int main() {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int fib(int a);

int n;
int x[44];


int main(void)
{
	x[0] = 1;
	x[1] = 1;
	
//	printf("%d", fib(2));
	
	scanf("%d", &n);
	
	printf("%d\n", fib(n));
	
	return (0);
}

int fib(int a) {
	if (a == 0 || a == 1) {
		return (1);
	}
		
	fib(a - 1);
	
	x[a] = x[a - 1] + x[a - 2];
	
	
	return (x[a]);
}

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

int main(){
  int N,K;
  cin >> N >> K;
  
  vector <int> a(N);
  
  for (int i=0;i<N;i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  
  int sum = 0;
  for (int i=0;i<K;i++){
    sum+=a.at(i);
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
<?php
$tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}

$nums = explode(' ', $tmp[0]);

$n = (int)$nums[0];
$m = (int)$nums[1];

function nCr(int $n, int $r)
{
    if ($n <= 1 || $r <= 1)
        return 0;

    return factorial($n) / (factorial($r) * factorial($n - $r));
}

function factorial(int $val)
{
    if ($val > 0)
        return $val * factorial($val - 1);

    return 1;
}

echo nCr($n, 2) + nCr($m, 2);

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

void solve(long long N, vector<long long> T, long long M, vector<long long> P, vector<long long> X){
  long long sum = 0;
  for ( long long t : T ) {
    sum += t;
  }
  for ( int i = 0; i < M; i++ ) {
    printf("%d\n", sum - T[P[i]-1] + X[i]);
  }
}

int main(){
	long long N;
	long long M;
	scanf("%lld",&N);
	vector<long long> T(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&T[i]);
	}
	scanf("%lld",&M);
	vector<long long> P(M-1+1);
	vector<long long> X(M-1+1);
	for(int i = 0 ; i <= M-1 ; i++){
		scanf("%lld",&P[i]);
		scanf("%lld",&X[i]);
	}
	solve(N, T, M, P, X);
	return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

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

    int S1 = A * B;
    int S2 = C * D;
    int output = (S1 > S2) ? S1 : S2;

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]
m = 0
score = sum(S)
if score%10 != 0:
    print(score)
    exit()

for s in S:
    if (score - s) % 10 != 0:
        m = max(m, score - s)
print(m)

Measured memory_bytes: 8944
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int ans = 0;
    for (int i = 1; i < n; i++)
        ans += i;
    for (int i = 1; i < m; i++)
        ans += i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256