akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int int64_t
#define rp(i, N) for(int i=0; i<N; i++);
using namespace std;
using pair = pair<int, int>;
using tup  = tuple<int, int, int>;
using vec  = vector<int>;
using vvec = vector<vec>;
const int INF = 100000000;
// " ", ' '

// プロトタイプ宣言
// int myfunc(int, vvec);

// グローバル変数
// int N, M;
// vvec data(N, vec(M));

// 関数：

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N; cin >> N;
	int ans;
	if(N==1) ans = 0;
	else ans = N*(N-1)/2;
	cout << ans << endl;
}


Measured memory_bytes: 256
///In the name of GOD
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll MXN = 2e5 + 10;
int n, m, Root;
int dis[MXN];
vector<pair<int, int>> adj[MXN];
queue<int> q;
map<pair<int, int>, bool> mp;
void dfs(ll u, ll c){
    if(u == n){cout << dis[n]; exit(0);}
    for(auto Pr : adj[u]){
        int v = Pr.first, cp = Pr.second;
        if(cp != c || dis[v] < dis[Root] || mp[{v, c}]) continue;
        mp[{v, c}] = 1;
        if(dis[v] > dis[Root] + 1) q.push(v);
        dis[v] = min(dis[v], dis[Root] + 1);
        dfs(v, c);
    }
}
void BFS(){
    dis[1] = 0, q.push(1);
    while(!q.empty()){
        int u = q.front(); Root = u;
        q.pop();
        for(auto Pr : adj[u]){
            ll v = Pr.first, c = Pr.second;
            if(dis[v] < dis[u] || mp[{v, c}]) continue;
            mp[{v, c}] = mp[{u, c}] = 1;
            if(dis[v] > dis[u] + 1) q.push(v);
            dis[v] = min(dis[v], dis[u] + 1), dfs(v, c);
        }
    }
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
    cin >> n >> m, memset(dis, 31, sizeof dis);
    for(int i = 1; i <= m; i ++){
        int u, v, c; cin >> u >> v >> c;
        adj[u].push_back({v, c}), adj[v].push_back({u, c});
    }
    BFS();
    cout << (dis[n] > 1e8 ? -1 : dis[n]);
    return 0;
}
/*!
    I CHOOSE TO HAVE FAITH,
    BECAUSE WITHOUT THAT,
    I HAVE NOTHING....
    ITS THE ONLY THING THAT'S KEEPING ME GOING.
*/
//! N.N


Measured memory_bytes: 34816
n,m=map(int,input().split())
l=list(map(int,input().split()))
d={}
for i in range(n):
	d[i+1]=[]
while m:
	m-=1
	a,b=map(int,input().split())
	d[a].append(b)
	d[b].append(a)
c=0
for i in d:
	f=0
	for j in d[i]:
		if l[j-1]>=l[i-1]:
			f=1
			break
	if f==0:
		c+=1
		#print(i)
	
print(c)

Measured memory_bytes: 94744
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_067_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(7).
    01 A      PIC 9(3).
    01 B      PIC 9(3).

    01 MODA   PIC 9(1).
    01 MODB   PIC 9(1).
    01 MODAB  PIC 9(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    UNSTRING INP
    DELIMITED BY SPACE
    INTO A B.

    COMPUTE MODA = FUNCTION MOD(A, 3).
    COMPUTE MODB = FUNCTION MOD(B, 3).
    ADD A TO B.
    COMPUTE MODAB = FUNCTION MOD(B, 3).

    IF MODA = 0 OR MODB = 0 OR MODAB = 0 THEN
        DISPLAY "Possible"
    ELSE
        DISPLAY "Impossible"
    END-IF.

    STOP RUN.


Measured memory_bytes: 384
def mi():
    return map(int, input().split())

def main():
    S = input()
    N = len(S)+1
    l = [0]*N
    r = [0]*N
    ans = 0

    for i in range(N-1):
        if S[i] == '<':
            l[i+1] = l[i]+1
    for i in range(N-2, -1, -1):
        if S[i] == '>':
            r[i] = r[i+1]+1

    for i in range(N):
        ans += max(l[i], r[i])

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 50288
w, h, n = map(int,input().split())
x0, y0, x1, y1 = 0, 0, w, h

for i in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        x0 = max(x0, x) 
    elif a == 2:
        x1 = min(x1, x)
    elif a == 3:
        y0 = max(y0, y)
    elif a == 4:
        y1 = min(y1, y)

print((x1 - x0) * (y1 - y0) if x1-x0 > 0 and y1 - y0 > 0 else 0)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            cout << i << "x" << j << "=" << i*j <<"\n";
        }
    }
}


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

int main() {
  ll n;
  cin >> n;
  ll r = 0;
  if (n % 2 == 0) {
    while (n) {
      r += n / 10;
      n /= 5;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
#define dbg(x) cout << #x << " = " << (x) << endl;
const ll MOD = 1000000007;
const ll INF = 1e18;

const int maxn = 1000;
int n, c;
int w[maxn];
int v[maxn];
vector<vector<ll> > dp(105, vector<ll>(100005, INF));

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("F:\\Scripts\\input","r",stdin);
    // freopen("F:\\Scripts\\output","w",stdout);
    // #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> c;
    int maxv = 1;
    for(int i = 0;i < n;i++) cin >> w[i] >> v[i], maxv += v[i];
    dp[0][0] = 0;
    ll ans = 0;
    for(int i = 0;i < n;i++)
        for(int j = 0;j < maxv;j++){
            dp[i][0] = 0;
            if (v[i] <= j) dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
            else dp[i+1][j] = dp[i][j];
            if (dp[i+1][j] <= c) ans = max(ans, 1LL*j);
        }
            
    return cout << ans, 0;
    
}

Measured memory_bytes: 83328
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        std::cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
    }
} fast;

/* define */
#define FOR(I, X, Y) for (long long(I) = (X); (I) < (Y); (I)++)
#define REP(I, X, Y) for (long long(I) = (Y)-1; (I) >= (X); (I)--)
#define ALL(X) (X).begin(), (X).end()
#define pb push_back
#define COUNT(V, X)                           \
    (upper_bound((V).begin(), (V).end(), X) - \
     lower_bound((V).begin(), (V).end(), X))
#define debug(x) cerr << #x << ':' << x << endl;
#define DEBUG(v)                             \
    {                                        \
        cerr << #v << ':';                   \
        for (auto xv : v) cerr << xv << ' '; \
        cerr << endl;                        \
    }
#define Yes(X) cout << (X ? "Yes" : "No") << endl;
#define YES(X) cout << (X ? "YES" : "NO") << endl;
#define ctoi(C) (C - '0')
#define pow2(x) ((long long)((long long)1 << x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1, 0, -1, 0};
const long long dy[] = {0, 1, 0, -1};
const long long dx8[] = {1, 1, 0, -1, -1, -1, 0, 1};
const long long dy8[] = {0, 1, 1, 1, 0, -1, -1, -1};
const long long dx9[] = {1, 1, 0, -1, -1, -1, 0, 1, 0};
const long long dy9[] = {0, 1, 1, 1, 0, -1, -1, -1, 0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) a = b;
    return a > b;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) a = b;
    return a < b;
}
long long max(long long x, int y) {
    return max(x, (long long)y);
}
long long max(int x, long long y) {
    return max((long long)x, y);
}
long long min(long long x, int y) {
    return min(x, (long long)y);
}
long long min(int x, long long y) {
    return min((long long)x, y);
}

/* library */

/* main */

string S;
ll N;

ll data[500010];
ll dfs(ll n) {
    if (data[n] != -1) {
        return data[n];
    }
    if (n == 0 && S[0] == '<') {
        return data[n] = 0;
    }
    if (n == N - 1 && S[N - 2] == '>') {
        return data[n] = 0;
    }
    if (S[n - 1] == '>' && S[n] == '<') {
        return data[n] = 0;
    }
    ll res = 0;
    if (S[n - 1] == '<') {
        res = max(res, 1 + dfs(n - 1));
    }
    if (S[n] == '>') {
        res = max(res, 1 + dfs(n + 1));
    }
    return data[n] = res;
}

signed main() {
    cin >> S;
    N = S.size() + 1;
    FOR(i, 0, 500010) {
        data[i] = -1;
    }
    ll ans = 0;
    for (size_t i = 0; i < N; i++) {
        ans += dfs(i);
    }
    cout << ans << endl;
}

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

int main(){
	int n;	cin>>n;
	vector<pair<int, pair<double,double>>>data(n);
	for(int i=0;i<n;i++){
		double x,y;	cin>>x>>y;
		data[i]={i,{x,y}};
	}

	double ans=0;
	do{
		double px=data[0].second.first,py=data[0].second.second;
		double len=0;
		for(int i=0;i<n;i++){
			double x=data[i].second.first, y=data[i].second.second;
			len+=sqrt((x-px)*(x-px) + (y-py)*(y-py));
			px=x; py=y;
		}
		//cout<<len<<endl;
		ans+=len;

	}while(next_permutation(data.begin(), data.end()));

	double tmp=1;
	for(int i=1; i<=n; i++)tmp*=i;
	ans/=tmp;
	printf("%.6lf\n",ans);

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x;
long long a[200005],ans=1e18;
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&x),a[i]=a[i-1]+x;
	for (int i=1;i<n;i++)
		ans=min(ans,abs(a[n]-2*a[i]));
	printf("%lld",ans);
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

#define MAX 10000

int D;
long long G;
int p[10+2] = {0};
int c[10+2] = {0};
long long C[10+2] = {0};

int main(int argc, char* argv[]){
	cin >> D >> G;

	for(int i = 0; i < D; i++){
		cin >> p[i] >> c[i];
		C[i] = (100 * (i+1) * p[i]) + c[i];
	}

	//コンプリートの有無によるビット全探索
	int ans = 100*10;
	for(int b = 0; b < (1<<D); b++){
		long long point = 0;
		int problems = 0;
		for(int i=0; i<D; i++){
			if( b & (1<<i) ){ //コンプリートする100(i+1)点問題
				point += C[i];
				problems += p[i];
			}
		}
		if(point < G){ //このパターンのコンプリートだけでは不足
			for(int i=D-1; i>=0; i--){ //コンプリートしていない高得点のものから解く
				if( !( b & (1<<i) ) ){ 
					for(int j=1; j<=p[i]-1; j++){ //コンプリートではないので、j=p[i]は除外。
						point += 100 * (i+1);
						problems++;
						if(point >= G){
							break;
						}
					}
				}
				if(point >= G){
					break;
				}
			}
		}
		if(point >= G && ans > problems){
			ans = problems;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    string S;
    ll K;
    cin >> S >> K;

    ll num = 0;
    int len = S.size();
    REP(i, S.size()) {
        if (S[i] != '1') {
            num = S[i] - '0';
            len = i;
            break;
        }
    }

    if (K <= len) {
        cout << 1 << endl;
    } else {
        cout << num << endl;
    }

    return 0;
}


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



int main ()
{
    vector<int>v(10000);
    int cnt=0;
    for(int i=0;i<10000;i++){
        cin>>v.at(i);
        if(v.at(i)==0) break;
        cnt++;
        
    }

    for(int i=0;i<cnt;i++){
        cout << "Case" << " " << i+1 << ":" << " " <<v.at(i) << endl;
    }

}



Measured memory_bytes: 3140
#include<cstdio>  
#include<iostream>  
#include<algorithm>  
#include<cstdlib>  
#include<cstring>
#include<string>
#include<climits>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<ctime>
#define LL long long
#define inf 0x3f3f3f3f

using namespace std;
  
inline char nc(){
    /* 
  static char buf[100000],*p1=buf,*p2=buf;
  if (p1==p2) { p2=(p1=buf)+fread(buf,1,100000,stdin); if (p1==p2) return EOF; }
  return *p1++;
    */return getchar();
}
  
inline void read(int &x){
  char c=nc();int b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
  
inline void read(LL &x){
  char c=nc();LL b=1;
  for (;!(c>='0' && c<='9');c=nc()) if (c=='-') b=-1;
  for (x=0;c>='0' && c<='9';x=x*10+c-'0',c=nc()); x*=b;
}
 
inline int read(char *s)
{
    char c=nc();int len=1;
    for(;!(c=='.'||c=='#');c=nc()) if (c==EOF) return 0;
    for(;(c=='.'||c=='#');s[len++]=c,c=nc());
    s[len++]='\0';
    return len-2;
}
 
inline void read(char &x){
  for (x=nc();!(x>='0' && x<='1');x=nc());
}
 
int wt,ss[19];
inline void print(int x){
    if (x<0) x=-x,putchar('-'); 
    if (!x) putchar(48); else {
    for (wt=0;x;ss[++wt]=x%10,x/=10);
    for (;wt;putchar(ss[wt]+48),wt--);}
}
inline void print(LL x){
    if (x<0) x=-x,putchar('-');
    if (!x) putchar(48); else {for (wt=0;x;ss[++wt]=x%10,x/=10);for (;wt;putchar(ss[wt]+48),wt--);}
}

int n,m,a[20][20];
char b[20];

bool check()
{
    int l=1;
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<l;j++)
            if (a[i][j]==1) return false;
        if (a[i][l]==0) return false;
        int j;
        for (j=l+1;a[i][j]==1;j++);
        l=j-1;
        //cout<<l<<endl;
        for (;j<=m;j++)
            if (a[i][j]==1) return false;
    }
    return true;
}

int main()
{
    read(n);read(m);
    for (int i=1;i<=n;i++)
    {
        m=read(b);
        for (int j=1;j<=m;j++)
            if (b[j]=='#') a[i][j]=1;else a[i][j]=0;
    }
    if (check()) puts("Possible");else puts("Impossible");
    return 0;
}

Measured memory_bytes: 256
n,a,b = map(int,input().split())
while True:
    if a+1 != b:
        a += 1
    elif a != 1:
        a -= 1
    else:
        print("Borys")
        break

    if b-1 != a:
        b -= 1
    elif b != n:
        b += 1
    else:
        print("Alice")
        break


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K;
    cin >> N >> K;
    VEC(int) A(N);
    READVEC(A);

    int S = 0;
    FOR(i, 0, N)
        S += A[i];

    auto need = [&A](int g) {

        lint ret = 0;
        int halves = 0;
        VEC(int) rems;
        for (int a : A) {
                rems.push_back(a % g);
        }

        sort(ALL(rems));
        VEC(lint) Suffix(1 + rems.size(), 0);
        for (int i = rems.size() - 1;i >= 0; i--) {
            Suffix[i] = Suffix[i + 1] + (g - rems[i]);
        }

        lint add = 0, mn = 1LL << 60;
        for (int i = 0;i + 1 <= rems.size(); i++) {
            add += rems[i];
            mn = min(mn, max(add, Suffix[i + 1]));
        }

        return ret + mn;
    };

    int ret = 0;
    for (int g = 1;g <= S / g; g++)
        if (S % g == 0) {

            if (need(g) <= K)
                ret = max(ret, g);
            if (need(S / g) <= K)
                ret = max(ret, S / g);
        }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)

const int MOD = 1e9+7;
string L;
int N;

ll memo[100005][2];
ll dfs(int n, int lower) {
  if (memo[n][lower] != -1)
    return memo[n][lower];

  if (n == N)
    return 1;

  if (lower == 1)
    return memo[n][lower] = (3 * dfs(n+1, 1)) % MOD;

  if (L[n] == '0')
    return memo[n][lower] = dfs(n+1, 0);
  return memo[n][lower] = (dfs(n+1, 1) + 2 * dfs(n+1, 0)) % MOD;
}

int main() {
  cin >> L;
  N = L.size();
  rep(i, N+1)
    memo[i][0] = memo[i][1] = -1;

  cout << dfs(0, 0) << endl;

  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int A, B, C, D, E, F;

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

   vec<int> sugar, water;
   for (int i = 0; i <= F; i++) {
      for (int j = 0; j <= F; j++) {
         // 砂糖
         int s = C*i + D*j;
         if (s <= F) sugar.push_back(s);
         // 水
         int w = 100*A*i + 100*B*j;
         if (w <= F) water.push_back(w);
      }
   }

   const double kijun = (double)E/(100+E);
   double noudo = -1;
   int a = 0, b = 0;
   rep (i, sugar.size()) {
      rep (j, water.size()) {
         int sum = sugar[i] + water[j];
         double x = (double)sugar[i]/sum;
         if (sum <= F && x <= kijun && x > noudo) {
            noudo = x;
            a = sum, b = sugar[i];
         }
      }
   }
   printf("%d %d\n", a, b);

   return 0;
}


Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.AtCoder_Begginer_Contest_158
{
    class C
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int A = int.Parse(input[0]);
            int B = int.Parse(input[1]);



            int withoutTax1 = (int)(A * 12.5);
            int withoutTax2 = B * 10;

            int withoutTax = withoutTax1 < withoutTax2 ? withoutTax2 : withoutTax1;
            int answer = -1;
            const double taxRate1 = 0.08;
            const double taxRate2 = 0.1;
            while (true) {
                if (((int)(withoutTax * taxRate1) == A) && ((int)(withoutTax * taxRate2) == B))
                {
                    answer = withoutTax;
                    break;
                } else
                {
                    if((A < (int)(withoutTax * taxRate1)) || (B < (int)(withoutTax * taxRate2)))
                    {
                        break;
                    }
                    withoutTax++;
                }
            }

            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13140
H,W,D = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]

plc = {}
for h in range(H):    
    for w in range(W):
        mm = A[h][w]
        plc[mm] = (h,w)

cst = {}
for i in range(1,D+1):
    cst[i] = 0
for i in range(D+1,H*W+1):
    cst[i] = cst[i-D]+abs(plc[i][0]-plc[i-D][0])+abs(plc[i][1]-plc[i-D][1])


Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    print(cst[R]-cst[L])






Measured memory_bytes: 36816
from collections import deque
N, X, Y = map(int, input().split())
graphs = [[i - 1, i + 1] for i in range(1, N - 1)]
graphs.insert(0, [1])
graphs.append([N - 2])

# scores = [0 for _ in range(N)]

graphs[X - 1].append(Y - 1)
# print(graphs)


# 数をカウントする
counts = [0 for _ in range(N)]


for index, start_point in enumerate(graphs):
    scores = [10**9 + 7 for _ in range(N)]
    queue = deque([index])
    scores[index] = 0
    while queue:
        now_index = queue.pop()
        for next_index in graphs[now_index]:
            if scores[next_index] > scores[now_index] + 1:
                queue.append(next_index)
                scores[next_index] = scores[now_index] + 1
    for score in scores[index:]:
        counts[score] += 1

for count in counts[1:]:
    print(count)


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

using namespace std;

int main(void)
{
    string a, b;

    cin >> a >> b;

    if((a[0]=='H' && b[0] == 'H') || (a[0]=='D' && b[0]=='D')){
        cout << 'H' << endl;
    }
    else{
        cout << 'D' << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 100010

ll a[3][SIZE], s[SIZE];

int main() {
   int n;
   scanf("%d", &n);
   for (int i = 0 ; i < 3 ; ++i) {
      for (int j = 0 ; j < n ; ++j) scanf("%lld", &a[i][j]);
      sort (a[i], a[i] + n);
   }

   int k = n;
   a[2][n] = 1e9 + 7;
   for (int i = n - 1 ; i >= 0 ; --i) {
      while (a[2][k] > a[1][i]) --k;
      s[i] = n - k - 1;
   }

   ll ans = 0;
   k = n;
   a[1][k] = 1e9 + 7;
   ll sum = 0;
   for (int i = n - 1 ; i >= 0 ; --i) {
      while (a[1][k] > a[0][i]) {
         sum += s[k];
         --k;
      }
      ans += sum;
   }

   printf("%lld\n", ans);
   return 0;
}


Measured memory_bytes: 3328
n = int(input())
a = list(map(int, input().split()))
D = {i: [0] for i in range(1, n+1)}
for i in range(n+1):
  D[a[i]][0] += 1
  D[a[i]].append(i)
pl, pr = 0, 0
for i in D:
  if D[i][0] == 2:
    pl = D[i][1]
    pr = D[i][2]
    break
L = pl
M = pr - pl - 1
N = n - pr
mod = int(1e9) + 7 # <-- input modulo
maxf = n+11          # <-- input factional limitation

def make_fact(n, k):
    tmp = n
    perm = [i for i in range(k)]
    L = [0 for _ in range(k)]
    for i in range(k):
        L[i] = tmp % (i + 1)
        tmp //= i + 1
    LL = [0 for _ in range(k)]
    for i in range(k):
        LL[i] = perm[L[-i-1]]
        for j in range(L[-i-1]+1, k):
            perm[j-1] = perm[j]
    return LL

def doubling(n, m, modulo=mod):
    y = 1
    base = n
    tmp = m
    while tmp != 0:
        if tmp % 2 == 1:
            y *= base
            if modulo > 0:
                y %= modulo
        base *= base
        if modulo > 0:
            base %= modulo
        tmp //= 2
    return y

def inved(a, modulo=mod):
    x, y, u, v, k, l = 1, 0, 0, 1, a, modulo
    while l != 0:
        x, y, u, v = u, v, x - u * (k // l), y - v * (k // l)
        k, l = l, k % l
    return x % modulo

fact = [1 for _ in range(maxf+1)]
invf = [1 for _ in range(maxf+1)]

for i in range(maxf):
    fact[i+1] = (fact[i] * (i+1)) % mod
invf[-1] = inved(fact[-1])
for i in range(maxf, 0, -1):
    invf[i-1] = (invf[i] * i) % mod

for i in range(1, n+2):
  S = fact[n+1]*invf[i]*invf[n-i+1]%mod
  if i <= n-M:
    S -= fact[n-1-M]*invf[i-1]*invf[n-M-i]%mod
    S %= mod
  print(S)


Measured memory_bytes: 43988
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, gcd, lcm 
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <vector> // vectors
#include <string> // string
#include <queue> // queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <unordered_map> // hashed by keys
#define _for(i,n) for(int i = 0; i < n; i++)

typedef long long ll; // at least int64 > 9*10^18
typedef unsigned long long ull; // at least uint64

int went[100007]={};

void dp(int i,int color,int n,std::vector<std::vector<std::pair<int,int> > >&connected) {
  went[i] = color+1;
  _for(j,connected[i].size()) {
    if(went[connected[i][j].first]==0) dp(connected[i][j].first,(connected[i][j].second)?(color+1)%2:color,n,connected);
  }
}

int main() {
  int n;
  std::cin >> n;
  int u[n-1][2];
  ll w[n-1];
  _for(i,n-1) std::cin >> u[i][0] >> u[i][1] >> w[i];
  _for(i,n-1) {
    _for(j,2) u[i][j]--;
  }
  std::vector<std::vector<std::pair<int,int> > > connected(n,std::vector<std::pair<int,int> >());
  _for(i,n-1) {
    connected[u[i][0]].emplace_back(u[i][1],w[i]%2);
    connected[u[i][1]].emplace_back(u[i][0],w[i]%2);
  }
  dp(0,0,n,connected);
  _for(i,n) {
    std::cout<<went[i]-1<<std::endl;
  }
  return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("O3")
#define lll __int128_t
#define ll long long int
#define FOR(i,a,b) for(ll (i)=(a);i<(ll)(b);i++)
#define FORr(i,a,b) for(ll(i)=(a);i>(ll)(b);i--)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,n)
#define outi(a) printf("%lld\n",(a))
#define case(i) cout << "Case " << i << ": ";
#define pb push_back
#define in(n) ll n = read();
#define show(arr) for(auto a : arr) cout << a << " "; cout << endl;
#define inp(arr, n) ll arr[n] ; rep(i,n) arr[i] = read();
#define mp make_pair
#define f first 
#define s second 
#define mod 1000000007
#define modu(a) if(a>=mod) a-=mod;
#define test int tt = read(); rep(i,tt) solve(i+1);
using namespace std;
inline ll read()
{
    ll x=0; static ll p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
    return x;
}
int solve(int tt);
int main()
{
    //system("clear");
   // freopen("input.txt", "r", stdin);
    in(a) in(b) in(c)
    ll remain = a- b;
    cout << max(c-remain, 0LL) << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

ans = 1
for i in range(n):
    if a[i] == 0:
        ans = 0

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        break

if ans <= 10**18:
    print(ans)
else:
    print(-1)

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

ll solve(vector<int>a , ll n , ll k){

    int dp[k+1];
    memset(dp,0,sizeof(dp));

    for(int i=0;i<=k;i++) {
        for(int j : a) {
            if(j<=i && !dp[i-j])
                dp[i] = 1;
        }
    }

    return dp[k];


}

int main(){

    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    ll n,k;
    cin>>n>>k;

    ll a;

    vector<int>vec;
    for(int i=0;i<n;i++) cin>>a,vec.push_back(a);

    if(solve(vec,n,k)) cout<<"First\n";
    else cout<<"Second\n";

}


Measured memory_bytes: 640
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
ans = []
val = 0
for arr in a:
    for s in range(m):
        val += arr[s]*b[s]
        if s == m-1:
            ans.append(val)
            val = 0
ans = list(map(lambda x: x + c, ans))
print(sum(l > 0 for l in ans))

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

#ifdef LOCAL 
string to_string(char a) { return string(1,a); }
string to_string(bool a) { return a ? "1" : "0"; }
string to_string(const char* a) { return (string)a; }
string to_string(string a) { return a; }
string to_string(vector<bool> v) {
	string s = "["; for(unsigned i=0;i<v.size();i++){ s += ((i>0)?" ":"");
    s += char('0'+v[i]); } 	s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p);
template<class T> string to_string(T v) {
	bool b = 1; string s = "["; for (const auto& x: v) {
		if (!b) {s += ", ";} b = 0; s += to_string(x); } s += "]"; return s; }
template<class A, class B> string to_string(pair<A,B> p) {
	return "("+to_string(p.first)+", "+to_string(p.second)+")"; }
void dbgf() { cerr << endl; }
template<class H, class... T> void dbgf(H h, T... t) {
	cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
	dbgf(t...); }
#define dbg(...) cerr << #__VA_ARGS__ << " = ", dbgf(__VA_ARGS__)
#else
#define dbg(...) 0
#endif
#define boolout(x) cout<<(x?"YES":"NO")<<endl;
typedef long long ll;


int mod = 1e9+7;

void add_self(int &a, int b){
    a += b;
    if (a>=mod) {
        a-=mod;
    }
}

void solve()
{
    int n;
    cin >> n;
    vector<vector<int>> can(n, vector<int>(n));
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> can[i][j];
        }
    }

    vector<int> dp(1<<n);
    dp[0]=1;
    for (int mask = 0; mask < (1<<n)-1; ++mask) {
        int a = __builtin_popcount(mask);
        for (int b = 0; b < n; ++b) {
            if (can[a][b] && !(mask & (1<<b))) {
                int m = mask | (1<<b);
                //dp[m] += dp[mask];
                add_self(dp[m], dp[mask]);
            }
        }
    }
    dbg(dp);

    cout << dp[(1<<n)-1] << endl;

}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t; // read t. cin knows that t is an int, so it reads it as such.
    for (int i = 1; i <= t; ++i) {
        solve();
    }
    return 0;
}



Measured memory_bytes: 8448
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    ll a[n];
    for(int i=0; i<n; i++) cin >> a[i];


    // odd : plus
    // even : minus
    ll cntf=0, cnts=0, sum=0;
    for(int i=0; i<n; i++) {
        sum += a[i];
        if(i%2==0 && sum>=0) {
            cntf += sum+1;
            sum = -1;
        } else if(i%2==1 && sum<=0) {
            cntf += abs(sum)+1;
            sum = 1;
        }
    }

    // odd : minus
    // even : plus
    sum=0;
    for(int i=0; i<n; i++) {
        sum += a[i];
        if(i%2==0 && sum<=0) {
            cnts += abs(sum)+1;
            sum = 1;
        } else if(i%2==1 && sum>=0) {
            cnts += sum+1;
            sum = -1;
        }
    }


    ll ans = (cntf>cnts?cnts:cntf);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int c=0;
    FOR(i,1,n){
        if(s[i]==s[i-1]){
            c++;
        }
    }
    cout<<min(c+2*k,n-1)<<endl;

	
}


Measured memory_bytes: 512
#include <map>
#include <set>
#include <list>
#include <cstdio>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define fr first
#define sc second
#define mp make_pair

typedef long long int64;
typedef pair< int, int > iP;
typedef pair< iP, int > iiP;

const int INF = 2 << 28;
const double EPS = 1e-10;

int dp1[1000001 * 2], dp2[1000001 * 2];
int main() {

    fill_n(dp1, 1000001 * 2, INF);
    fill_n(dp2, 1000001 * 2, INF);
    vector< int > p;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000000; i++) {
        int v = i * (i + 1) * (i + 2) / 6;
        p.push_back(v); dp1[v] = 1;
        if(v % 2) dp2[v] = 1;
    }
    for(int i = 1; i < 1000001; i++) {
        if(dp1[i] != INF) {
            for(int j = 0; j < p.size(); j++) {
                dp1[i + p[j]] = min(dp1[i + p[j]], dp1[i] + 1);
                if(p[j] % 2) dp2[i + p[j]] = min(dp2[i + p[j]], dp2[i] + 1);
            }
        }
    }

    int N;
    while(cin >> N, N) {
        cout << dp1[N] << " " << dp2[N] << endl;
    }
}

Measured memory_bytes: 16844
#include<cstdio>
#include <set>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;

typedef long long LL;

/*

题意：
略；
思路：
这本来就是个多重背包。
但是不知道这个路径应该怎么记录，原因就是不会利用好自己手中的条件。

*/
const int N=1e5+10;
LL a[N];
LL a1[N];

int main()
{
    int n;
    scanf("%d",&n);
    LL ans1=0;
    LL ans=0;

    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
    for(int i=1;i<=n;i++)
    {
        ans+=a[i]/2;
        if(a[i]%2)
        {
            if(a[i+1]&&i+1<=n)
            {
                ans+=1;
                a[i+1]-=1;
            }
        }
    }
    printf("%lld\n",ans);
    return 0;
}





Measured memory_bytes: 1024
import Data.List
import Data.Ord
solve a = (minimumBy (comparing (abs.(\x -> 2 * x - m))) $ init a, m)
  where m = last a
main = do
  getLine
  a <- getLine >>= return. map read. words :: IO [Integer]
  let (x, y) = solve.sort $ a
  putStrLn $ show y ++ " " ++ show x


Measured memory_bytes: 39932
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int a,b,c,A,B,C;
cin>>a>>b>>c;
A=max(a,max(b,c));
B=min(a,min(b,c));
C=a+b+c-A-B;
A=A-C;
C=C-B;
C+=A;
cout<<C;
return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = br.readLine();
        double n = Double.parseDouble(line);
        int i=(int) n;
        while(!isNumber(String.valueOf(Math.sqrt(i)))){
            i--;
        }
        System.out.println(i);
    }
    
    private static boolean isNumber(String str) {
        return str.substring(str.length()-1).equals("0");
    }
}


Measured memory_bytes: 27024
from collections import deque
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
M = 80*(H+W)
dp = [[0 for i in range(W)] for j in range(H)]
c = C[0][0]
dp[0][0]+=(1<<(c+M))|(1<<(M-c))
for s in range(1, H+W):
    for b in range(max(s-H+1, 0), min(s+1, W)):
        a = s-b
        c = C[a][b]
        if a>=1:
            d = dp[a-1][b]
            dp[a][b]|=(d<<c)|(d>>c)
        if b>=1:
            d = dp[a][b-1]
            dp[a][b]|=(d<<c)|(d>>c)
ans = 10**10
d = dp[-1][-1]
for i in range(0, M*2+1):
    if 1<<i&d:
        ans = min(ans, abs(i-M))
print(ans)

        









Measured memory_bytes: 58588
n,m,xPos,yPos = gets.chomp.split(" ").map(&:to_i)
xPoses = gets.chomp.split(" ").map(&:to_i)
xPosMax = xPoses.max
yPoses = gets.chomp.split(" ").map(&:to_i)
yPosMin = yPoses.min
putsString = "War"
((xPos+1)..yPos).each do |value|
	if xPosMax < value && yPosMin >= value
      putsString = "No War"
      break
    end
end
puts putsString

Measured memory_bytes: 1788
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, K;
  cin >> N >> K;
  vector<long> a(N);
  rep (i, N) cin >> a[i];
  vector<long> acc(N+1, 0);
  rep (i, N) acc[i+1] = acc[i] + a[i];
  vector<long> beauty;
  for (long i = 0; i < acc.size(); i++)
    for (long j = i+1; j < acc.size(); j++)
      beauty.push_back(acc[j] - acc[i]);
  /*
  for (auto it: beauty) cout << it << " ";
  cout << endl;
  cout << "--------------=" << endl;
  */
  for (long i = 1l << 40; i > 0; i >>= 1) {
    vector<long> foo;
    for (auto it: beauty) if (it & i) foo.push_back(it);
    /*
    for (auto it: foo) cout << it << " ";
    cout << endl;
    */
    if (foo.size() >= K) beauty = foo;
  }
  long ans = beauty[0];
  for (auto it: beauty) ans &= it;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll H, N; cin >> H >> N;
  vector<ll> A(N), B(N);
  for (ll i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  vector<vector<ll>> dp(N+1, vector<ll>(H+1, 1e10));
  dp.at(0).at(0) = 0;
  for (ll i = 0; i < N; i++) {
    ll a = A.at(i);
    dp.at(i+1).at(0) = 0;
    for (ll j = 1; j <= H; j++) {
      ll base = j-a >= 0 ? dp.at(i+1).at(j-a) : 0;
      dp.at(i+1).at(j) = min(dp.at(i).at(j), base + B.at(i));
    }
  }
  cout << dp.at(N).at(H) << endl;

  return 0;
}



Measured memory_bytes: 78592
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] abt = sc.nextLine().split(" ");
        int R = Integer.parseInt(abt[0]);
        int G = Integer.parseInt(abt[1]);
        int B = Integer.parseInt(abt[2]);
        int N = Integer.parseInt(abt[3]);

        int pattern = 0;
        for (int i = 0; i * R <= N; i++) {
            long x = i * R;
            for (int j = 0; x + j * G <= N; j++) {
                long y = j * G;
                if ((N - x - y) % B == 0) {
                    pattern++;
                }

            }
        }
        System.out.println(pattern);
    }
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if ((b - a) / 2 < k) {
    for (int i = a; i <= b; i++) {
      cout << i << endl;
    }
  } else {
    for (int i = 0; i < k; i++) {
      cout << a + i << endl;
    }
    for (int i = k - 1; i >= 0; i--) {
      cout << b - i << endl;
    }
  }
}


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

int main() {
    int N;
    cin >> N;
    // vector<int> dp(N);
    vector<vector<int>> happy(N, vector<int>(3));
    vector<vector<int>> dp(N, vector<int>(3));
    // make data from input
    for (int i=0;i<N;i++){
        cin >> happy.at(i).at(0) >> happy.at(i).at(1) >> happy.at(i).at(2);
    }
    // initial value
    for(int i=0;i<3;i++){
        dp.at(0).at(i) = happy.at(0).at(i);
    }
    // dp
    for (int i=1;i<N;i++){
        dp.at(i).at(0) = max(dp.at(i-1).at(1), dp.at(i-1).at(2)) + happy.at(i).at(0);
        dp.at(i).at(1) = max(dp.at(i-1).at(0), dp.at(i-1).at(2)) + happy.at(i).at(1);
        dp.at(i).at(2) = max(dp.at(i-1).at(0), dp.at(i-1).at(1)) + happy.at(i).at(2);
    }
    cout << max(max(dp.at(N-1).at(0), dp.at(N-1).at(1)), dp.at(N-1).at(2));
    return 0;
}



Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define MAIN 210
using namespace std;
struct node
{
    int x,y;
} a[MAIN],b[MAIN];
int n,nx,ny;
bool edge[MAIN][MAIN]= {};
int cx[MAIN],cy[MAIN];
bool used[MAIN]= {};
int path(int u)
{
    for(int v=1; v<=ny; v++)
    {
        if(edge[u][v]&&!used[v])
        {
            used[v]=true;
            if(cy[v]==-1||path(cy[v]))
            {
                cx[u]=v;
                cy[v]=u;
                return 1;
            }
        }
    }
    return 0;
}
int MaxMatch()
{
    int res=0;
    memset(cx,-1,sizeof(cx));
    memset(cy,-1,sizeof(cy));
    for(int i=1; i<=nx; i++)
    {
        if(cx[i]==-1)
        {
            memset(used,false,sizeof(used));
            res+=path(i);
        }
    }
    return res;
}
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++) cin>>a[i].x>>a[i].y;
    for(int i=1; i<=n; i++) cin>>b[i].x>>b[i].y;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=n; j++)
            if(b[i].x>a[j].x&&b[i].y>a[j].y)
                edge[i][j]=true;
    ///**
    nx=ny=n;
    cout<<MaxMatch()<<endl;
    /**
    for(int i=1; i<=n*2; i++)
    {
        for(int j=1; j<=n*2; j++)
            cout<<edge[i][j]<<" ";
        cout<<endl;
    }
    //*/
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int A = sc.nextInt();
    	int B = sc.nextInt();

    	if(B%A==0){
    		System.out.println(A+B);
    		}else{
    			System.out.println(B-A);
    		}
}
}


Measured memory_bytes: 21588
program sample
    implicit none
    character(100)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) s
    n=len_trim(s)
    m=10000
    do i=1,n-2
        read(s(i:i+2),*)a
        b=abs(a-753)
        if(b<m)then
            m=b
        end if
    end do
    write(*,*)m
   
    stop
end program sample
  



Measured memory_bytes: 2788
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long int LL;
typedef long long int ll;
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
#include<stack>

int a[60];

int main()
{
#ifdef LOCAL
    freopen("data.h", "r", stdin);
    //freopen("1.h","w",stdout);
#endif
    int n,m;
    scanf("%d%d",&n,&m);
    memset(a,0,sizeof(a));
    for(int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        a[x]++;
        a[y]++;
    }
    for(int i=1;i<=n;i++){
        if(i==1) printf("%d",a[i]);
        else printf(" %d",a[i]);
    }
    puts("");
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef vector<int> vi;

vi generate(int n,int s,int w){
  vi ret(n);
  int g=s;
  for(int i=0;i<n;i++){
    ret[i]=(g/7)%10;
    if (g%2 == 0){g=(g/2);}
    else         {g=(g/2)^w;}
  }
  return ret;
}

int bf(vi &in,int q){
  int n=in.size();
  vi tmp(n);
  int ret=0;
  for(int i=0;i<n;i++){
    tmp[i]=0;
    for(int j=0;j<=i;j++){
      tmp[j]=(tmp[j]*10+in[i])%q;
      if (in[j]!=0&&tmp[j] == 0)ret++;
    }
    
  }
  return ret;
}

int solve2(vi &in,int q){
  int ret=0;
  int cnt=0;
  rep(i,in.size()){
    if (in[i] != 0)cnt++;
    if (q==2){if(in[i]%2 == 0)ret+=cnt;}
    else if (q == 5){if (in[i]%5 == 0)ret+=cnt;}
  }
  return ret;
}

int solve(vi &in,int q){
  map<int,int>M;
  int ret=0,cur=0,base=1;
  for(int i=(int)in.size()-1;i>=0;i--){
    cur=(cur+in[i]*base)%q;
    base=(base*10)%q;
    if (in[i] != 0){
      if (cur == 0)ret++;
      ret+=M[cur];
    }
    M[cur]++;
  }
  return ret;
}

main(){
  int n,s,w,q;
  while(cin>>n>>s>>w>>q && n){
    vi a=generate(n,s,w);
    //rep(i,(int)a.size())cout << a[i]<<" ";cout<<endl;
    //cout << bf(a,q) << endl;
    cout << ((q==2||q==5)?solve2(a,q):solve(a,q)) <<endl;
  }
  return false;
}

Measured memory_bytes: 4116
N = int(input())
H = list(map(int,input().split()))
tmp_top = H[-1]
thg = True
for i in range(1,N+1):
  if H[-i] - tmp_top >= 2:
    thg = False
    
  if tmp_top > H[-i]:
    tmp_top = H[-i]

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

Measured memory_bytes: 63856
N = int(input())
S = input()

d = [0 for _ in range(N)]
d[0] = 1 if S[0] == '(' else -1
for i in range(1, N):
    if S[i] == '(':
        d[i] = d[i - 1] + 1
    else:
        d[i] = d[i - 1] - 1

if d[-1] < 0:
    d = [i for i in range(1, abs(d[-1]) + 1)] + [x - d[-1] for x in d]
m = min(d)
if m < 0:
    d = [i for i in range(1, abs(m) + 1)] + [x - m for x in d]
if d[-1] > 0:
    d = d + [i for i in reversed(range(d[-1]))]

ans = ''
for i, num in enumerate(d):
    if i == 0:
        ans += '('
    elif d[i] > d[i - 1]:
        ans += '('
    else:
        ans += ')'
print(ans)

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

int main( void )
{
    ll x,t;
    cin >> x >> t;
    
    if ( x - t > 0 )
        cout << x - t << endl;
    else
        cout << 0 << endl;
}


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

int main() {
    long long N,C,K;
    cin >>N>>C>>K;
    vector<long long> T(N);
    for(int i = 0; i<N; i++) cin >> T[i];

    sort(T.begin(), T.end());
    int res = 0;
    int pas = 0;
    int tli = 0;
    for(int i = 0; i<N; i++) {
        if(tli != 0 && tli < T[i]) {
            res++;
            pas = 0;
            tli = 0;
        }
        pas++;
        if(tli == 0) tli = T[i] + K;
        if(pas == C) {
            res++;
            pas = 0;
            tli = 0;
        }
    }
    if(pas > 0) res++;
    cout << res << endl;
}

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

using namespace std;
int main() {
    int N, Y;

    cin >> N >> Y;

    for (int x = 0; x <= N; x++) {
        for (int y = 0; y <= N-x; y++) {
            int z = N-x-y;
            if (10000*x + 5000*y + 1000*z == Y) {
                cout << x << " " << y << " " << z << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


Measured memory_bytes: 256