akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 998244353;
constexpr int inf = 3e18;

signed main() {
	cin.tie(0);ios::sync_with_stdio(false);
	int N;cin>>N;
	int all=0;
	vector<P>v1,v2;
	rep(i,N){
		string s;cin>>s;
		int cnt=0,mn=inf;
		for(char c:s){
			if(c=='(')cnt++;
			else cnt--;
			chmin(mn,cnt);
		}
		all+=cnt;
		int mx=cnt-mn;
		if(cnt>=0){
			v1.pb({-mn,mx});
		}else {
			v2.pb({-mn,mx});
		}
	}
	if(all!=0){
		cout<<"No"<<endl;
		return 0;
	}
	auto f=[](P a,P b){
		return a.first<b.first;
	};
	auto g=[](P a,P b){
		return a.second>b.second;
	};
	sort(all(v1),f);sort(all(v2),g);
	int now=0;
	for(auto i:v1){
		if(now<i.first){
			cout<<"No"<<endl;return 0;
		}
		now+=i.second-i.first;
	}
	for(auto i:v2){
		if(now<i.first){
			cout<<"No"<<endl;return 0;
		}
		now+=i.second-i.first;
	}
	cout<<"Yes"<<endl;
}


Measured memory_bytes: 19056
#include <cstdio>
const int maxn=1e5+10;
long long n,m,g;
char s[maxn],t[maxn];
long long gcd(long long n,long long m){return m?gcd(m,n%m):n;}
int main(){
	scanf("%lld%lld%s%s",&n,&m,s,t);
	g=gcd(n,m);
	for(int i=0;i<g;i++)
		if(s[i*n/g]!=t[i*m/g])
			return puts("-1"),0;
	printf("%lld\n",n*m/g);
}


Measured memory_bytes: 384
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = list(map(int,input().split()))

total = sum(A)
Ans = [0]*N

Ans[0] = total - sum(A[1::2])*2
for i in range(1,N):
    Ans[i] = (A[i-1] - Ans[i-1]//2)*2

print(" ".join(map(str,Ans)))

Measured memory_bytes: 19132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define fs first
#define sc second

// 1次元vectorの出力
template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cerr << v[i] << ' ';
  }
  cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cerr << v[i][j] << ' ';
    }
    cerr << endl;
  }
}

int main(void) {
	int n;
	string s;
	cin >> n >> s;
	int r=0; int g=0; int b=0;
    vector<int> rp, bp, gp;
	vector<bool> rv(n,false);
	vector<bool> gv(n,false);
	vector<bool> bv(n,false);
    rep(j, n){
		char i = s[j];
		if (i == 'R'){r++; rp.push_back(j); rv[j]=true;}
		else if (i == 'G'){g++; gp.push_back(j); gv[j]=true;}
		else{b++; bp.push_back(j); bv[j]=true;}
	}
	if(r==0 || b==0 || g==0){
		cout << 0 << endl;
		return 0;
	}
	ll ans  = (ll)r*g*b;
	for(int mid: rp){
		if(mid>0 && mid<n-1){
			//ans += gc[mid-1] * br[mid+1];
			for(int left: gp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
				if(bv[right]){
					ans--;
				}}
			}
			//ans += bc[mid-1] * gr[mid+1];
			for(int left: bp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
				if(gv[right]){
					ans--;
				}}
			}
		}
	}
	for(int mid: gp){
		if(mid>0 && mid<n-1){
			for(int left: rp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
				if(bv[right]){
					ans--;
				}}
			}
			//ans += bc[mid-1] * rr[mid+1];
			for(int left: bp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
					if(rv[right]){
						ans--;
					}
				}
			}
		}
	}
	for(int mid: bp){
		if(mid>0 && mid<n-1){
			//ans += gc[mid-1] * rr[mid+1];
			for(int left: gp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
				if(rv[right]){
					ans--;
				}}
			}
			//ans += rc[mid-1] * gr[mid+1];
			for(int left: rp){
				if(left >= mid) break;
				int right = mid + mid - left;
				if(right < n){
				if(gv[right]){
					ans--;
				}}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3632
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    As = map(int, input().split())

    dic = dict()
    ans = 'YES'

    for s in As:
        if s in dic:
            ans = 'NO'

        dic[s] = 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 44244
#include <iostream>
#include <stdio.h>
#include <stack>
using namespace std;

int main(){
	int amida[30][2];
	int n, m;// ??°??¨?????\????????°
	cin >> n >> m;
	for (int i = 0; i < m; i++)scanf("%d,%d",&amida[i][0],&amida[i][1]);

	for (int i = 0; i < n; i++) {
		int Now=i+1;
		for (int j = m - 1; j >= 0; j--) {
			if (amida[j][0] == Now) {
				Now = amida[j][1];
			}
			else if (amida[j][1] == Now) {
				Now = amida[j][0];
			}
		}
		printf("%d\n",Now);
	}
	return 0;
}

Measured memory_bytes: 1224
from collections import deque
import sys, copy,itertools
input = sys.stdin.readline

n = int(input())
L = list(map(int,input().split()))
A = sorted(L)

JR = list(itertools.combinations(A,3))

#print(A)
#print(JR)
cnt = 0

for i in range(len(JR)):
  if not(JR[i][0]==JR[i][1])and not(JR[i][1]==JR[i][2]) and (JR[i][0]+JR[i][1] > JR[i][2]):
    cnt += 1
    
print(cnt)

Measured memory_bytes: 20972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
typedef vector<ll> vl;
const int MN = 2012;
int ans[MN];
int main (void) {
  ios::sync_with_stdio(false);cin.tie(0);
  int n,x,y;
  cin >> n >> x >> y;
  --x; --y;
  for (int i = 0; i < n; i++) {
    for (int j = i+1; j < n; j++) {
      int dist;
      if (j <= x or y <= i) dist = j-i;
      else {
        if (x <= i and j <= y) {
          dist = min(j-i, (i-x) + (y-j) + 1);
        } else if (x <= i) {
          dist = min(j-i, (i-x) + (j-y) + 1);
        } else if (j <= y) {
          dist = min(j-i, (y-j) + (x-i) + 1);
        } else {
          dist = (x-i) + (j-y) + 1;
        }
      }
      ans[dist]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << '\n';
  return 0;
}



Measured memory_bytes: 256
#define REP(i, t, n)  for (int i = t; i < n; i++)
#define ALL(n)        (n).begin(),(n).end()
#include <limits.h>
#include <stdio.h>
#include <cmath>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cstring>
#include <unordered_map>
#include <numeric>

#define INF (10000000)
using namespace std;

typedef bool               BOOL;
typedef short              WORD;
typedef unsigned short     U_WORD;
typedef long               DWORD;
typedef unsigned long      U_DWORD;
typedef long long          QWORD;
typedef unsigned long long U_QWORD;

vector<DWORD> vecTime;
DWORD dwAns = INF;

void solve_main()
{
	REP(i, 0, 3) {
		DWORD tmp;
		cin >> tmp;
		vecTime.push_back(tmp);
	}

	REP(i, 0, 3) {
		REP(j, 0, 3) {
			DWORD dwSum = vecTime[i];
			if (i == j) {
				dwSum = INF;
			}
			dwSum += vecTime[j];
			dwAns = min(dwAns, dwSum);
		}
	}

	cout << dwAns << endl;
}

int main()		
{
#ifdef FOR_IDE
	ifstream in("input.txt");
	cin.rdbuf(in.rdbuf());
#endif

	solve_main();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> A(N);
  vector<int> B(0);

  for(int i =0;i<N;i++){
    cin >> A[i];
  }
  
  sort(A.begin(), A.end());
  
  int count =0;
  int maxcount =0;
  vector<string> C(0);
  for(int i =0;i<N-1;i++){
    if(A[i] == A[i+1]){
      count ++;
    }else{
      B.push_back(count);
      C.push_back(A[i]);
      if(count > maxcount) maxcount = count;
      count = 0;
    }
    if(i==N-2){
      B.push_back(count);
      C.push_back(A[i+1]);
      if(count > maxcount) maxcount = count;
    }
  }
  
  for(int i=0;i<C.size();i++){
    if(B[i] == maxcount)cout << C[i] << endl;
  }
}
      
      

Measured memory_bytes: 16872
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int ans = 1;
	for (int i = 1; i < N; i++) {
		if (S[i] != S[i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    vector<int> a(n);
    vector<int> b(n);

    for (int i = 0; i < n; ++i) {
        int t; cin >> t;

        a[i] = t;
        b[i] = t;
    }

    sort(b.rbegin(), b.rend());

    for (int i = 0; i < n; ++i) {
        if (a[i] == b[0]) {
            cout << b[1] << endl;
        } else {
            cout << b[0] << endl;
        }
    }
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	for (register int i=0; i<=2000; ++i)
	{
		if ((int)(i*0.08)==a && (int)(i*0.1)==b) {printf("%d\n",i); return 0;}
	}
	puts("-1");
return 0;
}

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

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

const int INF = 1e9;

void solve(int N) {
    vector<vector<int>> t(N, vector<int>(N + 1));
    rep(i, N) rep(j, N + 1) cin >> t[i][j];
    vector<int> dp(1 << N, INF);
    dp[0] = 0;
    rep(bit, 1 << N) {
        bitset<20> bs(bit);
        rep(i, N) {
            if(bs[i]) continue;
            int time = t[i][0];
            rep(j, N) if(bs[j]) chmin(time, t[i][j + 1]);
            chmin(dp[bit | (1 << i)], dp[bit] + time);
        }
    }
    cout << dp[(1 << N) - 1] << '\n';
}

int main() {
    int N;
    while(cin >> N) {
        if(!N) break;
        solve(N);
    }
    return 0;
}



Measured memory_bytes: 3416
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200){
        cout<<s<<endl;
    }else{
        cout<<"red"<<endl;
    }

    return 0;
}


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

t = set()
c = 0
for i in range(n):
    if a[i] <= 399:
        t.add(1)
    elif a[i] <= 799:
        t.add(2)
    elif a[i] <= 1199:
        t.add(3)
    elif a[i] <= 1599:
        t.add(4)
    elif a[i] <= 1999:
        t.add(5)
    elif a[i] <= 2399:
        t.add(6)
    elif a[i] <= 2799:
        t.add(7)
    elif a[i] <= 3199:
        t.add(8)
    else:
        c += 1
s = len(t)
if c == 0:
    print(s,s)
else:
    if s == 0:
        print(1,c)
        exit()
    print(s,s+c)

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

int main() {
    while (cin) {
        int n;
        cin >> n;
        if (n == 0) break;

        int m;
        string s;
        cin >> m >> s;

        int i = 0;
        int ans = 0;
        while (i < m) {
            if (s[i] == 'I') {
                int j = i;
                for (; j < m; j++) {
                    if ((j - i) & 1) {
                        if (s[j] == 'O')
                            continue;
                        else
                            break;
                    } else {
                        if (s[j] == 'I')
                            continue;
                        else
                            break;
                    }
                }
                int count = j - i;
                if(count & 1){
                    count /= 2;
                } else {
                    count--;
                    count /= 2;
                }
                ans += max(0, count - n + 1);
                // cout << j << " " << max(0, count - n + 1) << endl;
                i = j;
                i--;
            }
            i++;
        }
        cout << ans << endl;
    }
}

/*
1
50
IOOIOOOIIOIIIIIIIOOIOIOIOOOIIIOIIIOIIIOOOOOIIIOIIO

6
*/


Measured memory_bytes: 3908
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t index(int64_t a, int64_t b) {
    if (a < b) {
        swap(a, b);
    }
    return a * (a - 1) / 2 + b;
}

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

    vector<vector<int64_t>> links(n * (n - 1) / 2);
    vector<int64_t> nums(n * (n - 1) / 2);
    for (auto i : irange(0L, n)) {
        int64_t prev = -1;
        for (auto j : irange(0L, n - 1)) {
            int64_t a;
            cin >> a;
            --a;

            auto idx = index(i, a);
            if (prev >= 0) {
                links[prev].push_back(idx);
                ++nums[idx];
            }
            prev = idx;
        }
    }

    vector<int64_t> q;
    vector<int64_t> used(n * (n - 1) / 2);
    for (auto i : irange(0L, n * (n - 1) / 2)) {
        if (nums[i] == 0) {
            q.push_back(i);
        }
    }

    int64_t ans = 0;
    while (!q.empty()) {
        ++ans;
        vector<int64_t> next;
        for (auto qq : q) {
            used[qq] = true;
            for (auto v : links[qq]) {
                --nums[v];
                if (nums[v] == 0) {
                    next.push_back(v);
                }
            }
        }
        q = move(next);
    }

    if (any_of(used.begin(), used.end(), [](bool b) { return !b; })) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}

Measured memory_bytes: 35328
/* ******* MD Imran Hosen *******
     *******  BSMRSTU  *******
                :)
                (:
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main()
{
    float n1=0,n,i,j,k,m=0,b=0,a1=0,a2=0,a3=0,a4=0;
    int a5=0,a6=0,a7=0;
    cin>>n;
    a5=n/100;
    a6=(5*a5)+(100*a5);
    if(n<=a6)
    {
        cout<<"1"<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }




 	return 0;
}


Measured memory_bytes: 256
def main():
    N, A = map(int, input().split())
    x = [0]
    x.extend(list(map(int, input().split())))

    dp = [[[0 for _ in range(N * A + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                if k < x[i]:
                    dp[i][j][k] = dp[i - 1][j][k]
                else:
                    dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[N][j][A * j]

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    int n; cin >>n;
    int arr[n];


    for(int i=0; i < n;i++){
        cin>>arr[i];
    }
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    if(n == 2){
        cout << abs(arr[0]-arr[1]);
        return 0;
    }

    int sol[n];

    sol[0] = 0;
    sol[1] = abs(arr[0]-arr[1]);
    for(int i = 2; i < n;i++){
        int opc1 = abs(arr[i-1]-arr[i])+sol[i-1];
        int opc2 = abs(arr[i-2]-arr[i])+sol[i-2];
        if(opc1 < opc2){
            sol[i] = opc1;
        }else{
            sol[i] = opc2;
        }
    }

    cout << sol[n-1] << endl;
    return 0;
}


Measured memory_bytes: 4248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    string t;
    cin >> t;
    int l = t.size();
    rep(i, l) {
        if (t[i] == '?') t[i] = 'D'; 
    }
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 3728
import numpy as np 

n,m = map(int,input().split())
a,b=[],[]

for _ in range(n):
    a.append(list(input()))
for _ in range(m):
    b.append(list(input()))

anp=np.array(a)
bnp=np.array(b)

for ax in range(n-m+1):
    for ay in range(n-m+1):
        crnt=anp[ax:ax+m,ay:ay+m]
        if (crnt==bnp).all():
            print('Yes')
            exit()
print('No')
        


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

using namespace std;

int main() {

	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;

	transform(s1.begin(), s1.end(), s1.begin(), [](unsigned char S1) -> unsigned char { return toupper(S1); });
	transform(s2.begin(), s2.end(), s2.begin(), [](unsigned char S2) -> unsigned char { return toupper(S2); });
	transform(s3.begin(), s3.end(), s3.begin(), [](unsigned char S3) -> unsigned char { return toupper(S3); });

	cout << s1[0] << s2[0] << s3[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;

  vector<ll> x(n);
  vector<ll> y(n);
  vector<ll> h(n);
  rep(i, n) {
    cin >> x[i] >> y[i] >> h[i];
  }

  const ll inf = 1e10;
  rep(cx, 101) rep(cy, 101) {
    ll ch = -inf;

    rep(i, n) {
      cerr << ch << endl;
      ll dis = abs(cx-x[i]) + abs(cy-y[i]);

      if (ch == -inf) {
        if (h[i] == 0) {
          ch = -dis;
        } else {
          ch = dis + h[i];
        }
      } else if (ch < 0) {
        if (h[i] == 0 && dis <= -ch) {
          cmin(ch, -dis);
        } else if (h[i] != 0 && dis+h[i] <= -ch) {
          ch = dis + h[i];
        } else {
          ch = inf;
          break;
        }
      } else {
        if (h[i] == 0 && dis >= ch) {
        } else if (h[i] != 0 && dis+h[i] == ch) {
        } else {
          ch = inf;
          break;
        }
      }
    }

    if (ch != inf) {
      cout << cx << " " << cy << " " << ch << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 165, task B, 2020/05/02
//ms,
/*
*/

int main(void){
  int64_t X;
  int64_t money = 100;
  int64_t years = 0;
  cin >>X;

  while(money<X){
    years++;
    money += money/100;
  }

  cout <<years <<endl;

  return 0;
}
/*
*/


Measured memory_bytes: 3632
#include <iostream>
using namespace std;
int N, A, B, x;
int main() {
	cin >> N >> A >> B;
	int ret = 0;
	for(int i = 0; i < N; i++) {
		cin >> x;
		if(!(A <= x && x < B)) ret++;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
from fractions import gcd  # use math.gcd with python 3.5~


def main():
    N = int(input())
    A = list(map(int, input().split(' ')))
    L, R = [0 for _ in range(N)], [0 for _ in range(N)]
    L[0], R[N - 1] = A[0], A[N - 1]
    for i in range(1, N):
        L[i] = gcd(L[i - 1], A[i])
    for j in range(N - 2, -1, -1):
        R[j] = gcd(R[j + 1], A[j])
    max_gcd = 0
    for i in range(N):
        if i == 0:
            g = R[1]
        elif i == N - 1:
            g = L[N - 2]
        else:
            g = gcd(L[i - 1], R[i + 1])
        max_gcd = max([g, max_gcd])
    print(max_gcd)


if __name__ == '__main__':
    main()

Measured memory_bytes: 16100
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


A, B = readmap()

print(100, 100)

arr = [["."] * 50 + ["#"] * 50 for _ in range(100)]

for a in range(1, A):
    arr[2 * (a // 20) + 1][2 * (a % 20) + 51] = "."

for b in range(1, B):
    arr[2 * (b // 20) + 1][2 * (b % 20) + 1] = "#"

for i in range(100):
    print("".join(arr[i]))

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

int main(void){
    int n, res = 0;
    cin >> n;
    int v[n], c[n];
    for (int i = 0; i < n; i++){
        cin >> v[i];
    }
    for (int i = 0; i < n; i++){
        cin >> c[i];
    }
    for (int i = 0; i < n; i++){
        if (v[i] > c[i])
            res += v[i] - c[i];
    }

    cout << res << "\n";

}


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

#define x first
#define y second
#define y1 Y1
#define y2 Y2
#define mp make_pair
#define pb push_back
#define DEBUG(x) cout << #x << " = " << x << endl;

using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }
template <typename T> inline T read ()
{
	T sum = 0, fl = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fl = -1;
	for (; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
	return sum * fl;
}

inline void proc_status ()
{
	ifstream t ("/proc/self/status");
	cerr << string (istreambuf_iterator <char> (t), istreambuf_iterator <char> ()) << endl;
}

LL A, B, C;

inline void Solve ()
{
	if (C <= B) printf("%lld\n", B + C);
	else
	{
		LL ans = 2 * B;
		C -= B;
		if (C <= A + 1) printf("%lld\n", ans + C);
		else printf("%lld\n", ans + A + 1);
	}
}

inline void Input ()
{
	A = read<int>(), B = read<int>(), C = read<int>();
}

int main()
{

#ifdef hk_cnyali
	freopen("A.in", "r", stdin);
	freopen("A.out", "w", stdout);
#endif

	Input ();
	Solve ();

	return 0;
}


Measured memory_bytes: 256
# coding: utf-8

n = int(input())
xlist = list(map(int,input().split()))
xlist.sort()
ans = 10**9+7
st = xlist[0]
ed = xlist[-1]
for p in range(st, ed + 1):
  pp = 0
  for i in range(n):
    pp += (xlist[i] - p) ** 2
  ans = min(ans, pp)
print(ans)

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
using namespace std;
int n,ans;
int a[MAXN];
int main(){
	SF("%d",&n);
	for(int i=1;i<=n;i++)
		SF("%d",&a[i]);
	for(int i=2;i<=n;i++){
		if(a[i]==a[i-1]){
			a[i]=-1;
			ans++;
		}
	}
	PF("%d",ans);
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    ll n; cin >> n;
    vector <ll> bs;
    bs.push_back(1e9);
    REP(i, n-1){
        ll b; cin >> b;
        bs.push_back(b);
    }
    bs.push_back(1e9);
    ll ans = 0;
    REP(i, n){
        ans += min(bs[i], bs[i+1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,k = readInts()
A = readInts()
cnt = 1
now = k
while now < n:
    cnt += 1
    now += k - 1
print(cnt)


Measured memory_bytes: 14196
#include<stdio.h>
 
int main(){
	int n;
	scanf("%d", &n);
	if(n==1) {
		printf("0");
		return 0;
	}
	long long a = 1;
	long long b = 1;
	long long c = 1;
	long long mod = 1000000007;
	long long ans;
	for(int i=0; i<n; i++) {
		a *= 10;
		a%=mod;
		b *= 9;
		b%=mod;
		c *= 8;
		c%=mod;
	}
	ans = a - 2 * b + c;
	ans %= mod;
	ans = (ans + mod) % mod;
	printf("%lld", ans);
	return 0;
}


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

int main()
{
    int a,b,c;
    cin>>a>>b>>c;;
    if(a+b>=c){
        std::cout << "Yes" << std::endl;
    }
    else{
        std::cout << "No" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3676
import std.stdio, std.conv, std.array, std.string;
import std.algorithm;

void main() {
  ulong count = 0;
  int[string] dict;

  auto N = readln.chomp.to!int;
  foreach (i; 0..N) {
    char[] line = readln.chomp.dup;
    sort(line.representation);
    auto word = line.to!string;

    if (!(word in dict)) {
      dict[word] = 1;
      continue;
    }
    count += dict[word]++;
  }

  write(count);
}


Measured memory_bytes: 11388
<?php
$T = intval(fgets(STDIN));
for($i = 0; $i < $T; $i++){
  [$N, $A, $B, $C, $D] = array_map('intval',explode(' ',trim(fgets(STDIN))));
  $memo = [];
  echo cost($N),PHP_EOL;
}
function cost($i){
  global $N, $A, $B, $C, $D, $memo;
  if($i == 0)return 0;
  if($i == 1)return $D;
  if(isset($memo[$i]))return $memo[$i];
  $min = abs($i)*$D;
  foreach(["A" => 2, "B" => 3, "C" => 5] as $c => $mod){
    $up = intdiv($i+$mod-1,$mod)*$mod;
    chmin($min, abs($up-$i)*$D+$$c+cost($up/$mod));
    $down = intdiv($i,$mod)*$mod;
    chmin($min, abs($down-$i)*$D+$$c+cost($down/$mod));
  }
  $memo[$i] = $min;
  return $min;
}

function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}

Measured memory_bytes: 17416
def resolve():
    S=input()
    N=len(S)
    if S!=S[::-1]:
        print("No")
        return
    S1=S[:(N-1)//2 ]
    if S1!=S1[::-1]:
        print("No")
        return
    S2 = S[(N+3)//2-1:]

    if S2!=S2[::-1]:
        print("No")
        return
    print("Yes")
    




if __name__ == "__main__":
    resolve()

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;
string S,T;

signed main(){
    cin>>N;
    cin>>S>>T;

    deque<int>que;

    int ma=0;
    int cur=N-1;
    for(int i=N-1;i>=0;i--){
        if(que.size()&&que.back()-(int)que.size()+1>i)que.pop_back();
        if(cur<=i&&S[cur]==T[i])continue;
        chmin(cur,i);
        while(cur>=0&&S[cur]!=T[i])cur--;
        if(cur==-1){
            cout<<-1<<endl;
            return 0;
        }
        if(cur!=i){
            que.push_front(cur);
        }
        chmax(ma,(int)que.size());
    }
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 10376
N = int(input())
A_list = list(map(int, input().split(" ")))

L_list = []
R_list = []
#print(A_list)
gcd_list = []
ans = 0

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y, x%y)

for i in range(N):
    if i == 0:
        L_list.append(0)
        R_list.append(0)
    else:
        L_list.append(gcd(A_list[i-1], L_list[i-1]))
        R_list.append(gcd(A_list[-i], R_list[i-1]))

#print(L_list)
#print(R_list)

for j in range(N):
    gcd_list.append(gcd(L_list[j],R_list[-(j+1)]))

print(max(gcd_list))

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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,0,N) cin >> A[i];

    bool f = true;
    REP(i,0,N) {
        if (A[i] % 2 == 0) {
            if ((A[i] % 3 != 0) && (A[i] % 5 != 0)) {
                f = false;
            }
        }
    }

    if (f) _PR("APPROVED");
    else _PR("DENIED");

    return 0;
}

/*



*/

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		int n=Integer.parseInt(scan.next());
		int m=Integer.parseInt(scan.next());
		int[][] ab=new int [n][2];
		for (int i=0;i<n;++i) {
			ab[i][0]=Integer.parseInt(scan.next());
			ab[i][1]=Integer.parseInt(scan.next());
		}
		Arrays.sort(ab,(a,b)->Integer.compare(a[0], b[0]));
		
		long sum=0;
		for(int i=0;i<n;++i) {
			if (m<=0)break;
			sum+=Math.min(ab[i][1], m)*(long)ab[i][0];
			m-=Math.min(ab[i][1], m);
		}
		System.out.print(sum);
}
}
//end


Measured memory_bytes: 64704
#include<stdio.h>

int main(void)
{
    char s;
    int i, iCnt=0;

    for (i=0; i<3; i++) {
        scanf("%c",&s);
        if ('1' == s) {
            iCnt++;
        }
    }

    printf("%d\n", iCnt);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(int argc, char* argv[])
{
  int N;
  cin >> N;
  vector<double> p(N);
  for (int i=0; i<N; i++) cin >> p[i];
  
  // P(i, j) = probability of having j heads up to i-th coin
  vector< vector<double> > P(N);
  for (int i=0; i<N; i++) P[i].resize(N+1, 0);

  P[0][0] = 1-p[0];
  P[0][1] = p[0];
  for (int i=1; i<N; i++) {
    P[i][0] = P[i-1][0] * (1-p[i]);
  }

  
  for (int i=1; i<N; i++) {
    for (int j=1; j<N+1; j++) {
      P[i][j] = P[i-1][j] * (1-p[i]) + P[i-1][j-1] * p[i];
    }
  }

  double ans = 0;
  for (int j=(N/2 + 1); j < N+1; j++) ans += P[N-1][j];
  cout << setprecision(10) << ans << "\n";

  return 0;
}


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

int main() {

int X;
int A;

// your code goes here
scanf("%d",&X);
scanf("%d",&A);
int zero=0;
int ten=10;

if(X>=0 && X<=9 && A>=0 && A<=9){
	if(X<A){
			printf("%d",zero);
	}else{
		printf("%d",ten);
	}
}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<stack>
#include<algorithm>
#include<fstream>

#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define PI 3.14159265358979323846

// VECTOR DEFINITION 
#define vvi vector<vector<int>>
#define vvb vector<vector<bool>>
#define vi vector<int>
#define vl vector<long long>

//VECTOR PAIR
#define vpi vector<pair<int,int>>
#define mp make_pair
#define ff first
#define ss second
 
#define pb push_back

//MAXIMUM / MINIMUM ELEMENT IN VECTOR
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())

//SORTING OR REVERSING ANY VECTOR OR STRING
#define srt(a) sort(a.begin(),a.end());
#define rvr(a) reverse(a.begin(),a.end());
 
//LOOPS : s- start , e -end
#define loop(i,s,e) for(int i = s; i<e ; i++)
#define  rloop(i,s,e) for(int i = s; i>=e ;i--)
#define dloop(i,j,m,n) for(int i =0 ;i<m;i++){for(int j = 0;j<n;j++)} //double loop

typedef long long ll;
#define bits(n) __builtin_popcount(n);

#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;

using namespace std;

ll hcf(ll a,ll b){
    if(b==0) return a;
    return hcf(b,a%b);
}
 
ll lcm(ll a,ll b){
    return (a*b)/hcf(a,b);
}
void rdarr(vi& v, ll n){
    int x;
    loop(i,0,n){
        cin>>x;
        v.pb(x);
    }
}
void div(int n, vector<int>& di){
    for(int i =2;i<=sqrt(n);i++){
        if(n%i == 0){
            if(n/i !=i){
                di.pb(n/i);
            }
            di.pb(i);
        }
    }
    di.pb(1);
}
void solve(int t){
    int n;
    cin>>n;
    int r = n%10;
    if(r==2 || r==4 || r==5 || r==7 ||r==9) cout<<"hon"<<endl;
    else if(r==0 || r==1|| r==6 || r==8) cout<<"pon"<<endl;
    else cout<<"bon"<<endl;
   
}
signed main(){
   fast;
    // freopen("in.txt", "r", stdin);   
	// freopen("out.txt", "w", stdout);
    int t =1;
    // cin>>t;
    while(t--){
        solve(t);
    }
}

Measured memory_bytes: 3704
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const ll mod = 1e9 + 7;
const int maxn = 2007;
int arr[maxn], n;
ll k;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	cin >> n >> k;
	rep(i, 0, n) {
		cin >> arr[i];
	}
	ll res = 0;

	ll fact = ((k * k) - k) / 2;
	fact %= mod;
	rep(i, 0, n) {
		ll total = 0, part = 0;
		rep(j, i + 1, n) {
			if (arr[j] < arr[i]) part++;
		}
		rep(j, 0, n) {
			if (arr[j] < arr[i]) total++;
		}
		res += (total * fact);
		res %= mod;
		res += (part * k);
		res %= mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s;
    cin >> s;
    s.at(3) = '8';
    cout << s << endl;
}


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

class Main{
	public static void main(String[] args){
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int[] hairetu=new int[8];
		String max="",min="";

		try {
			int d_set;
			str=bfr.readLine();
			d_set=Integer.parseInt(str);

			for(int i=0; i<d_set; i++) {
				str="";
				min="";
				max="";
				str=bfr.readLine();
				for(int j=0; j<8; j++) {
					hairetu[j]=Integer.parseInt(str.charAt(j)+"");
				}
				hairetu=mSort(hairetu);

				for(int k=0; k<8; k++) {
					min=min+""+hairetu[k];
					max=max+""+hairetu[7-k];
				}
				System.out.println(Integer.parseInt(max)-Integer.parseInt(min));
			}
		}catch(IOException e) {

		}
	}

	public static int[] mSort(int array[])  {
		if(array.length > 1) {
			int elementsInA1 = array.length/2;
			int elementsInA2 = array.length - elementsInA1;
			int arr1[] = new int[elementsInA1];
			int arr2[] = new int[elementsInA2];

			for(int i = 0; i < elementsInA1; i++)
				arr1[i] = array[i];

			for(int i = elementsInA1; i < elementsInA1 + elementsInA2; i++)
				arr2[i - elementsInA1] = array[i];

			arr1 = mSort(arr1);
			arr2 = mSort(arr2);

			int i = 0, j = 0, k = 0;

			while(arr1.length != j && arr2.length != k) {
				if(arr1[j] <= arr2[k]) {
					array[i] = arr1[j];
					i++;
					j++;
				} else {
					array[i] = arr2[k];
					i++;
					k++;
				}
			}

			while(arr1.length != j) {
				array[i] = arr1[j];
				i++;
				j++;
			}
			while(arr2.length != k) {
				array[i] = arr2[k];
				i++;
				k++;
			}
		}
		return array;
	}
}


Measured memory_bytes: 24228
L, R = map(int, input().split())
if (R - L) >= 2018:
    print(0)
    exit()
else:#普通に二重for文で全探索(高々2017の範囲のfor文なので)
    ans = 2019
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            ans = min(ans, (i * j) % 2019)
    print(ans)


Measured memory_bytes: 65236
//People only find me interesting because they can't tell whether I'm serious or not
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
typedef __int128 s128;
typedef __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 3000
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;
double p[N];
double dp[N][N];
void solve(){
    ll n;
    cin>>n;
    f(i,1,n+1) cin>>p[i];
    cout<<setprecision(15);
    dp[0][0]=1.0000;
    f(i,1,n+1){
        f(j,0,i+1){
            double add=0.0000;
            if(j>0) add = double(p[i]*dp[i-1][j-1]);
            dp[i][j] = double((1.0000 - p[i])*(dp[i-1][j])) + add;
        }
    }
    double sum = 0.00;
    f(j,1 + (n/2), n+1) sum += dp[n][j];
    cout<<sum;

}
signed main() {
    teevra_gati
    
    solve();

    return 0;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)

/////////////////////////////////////////////////////////

void Main(){
  int N; cin >> N;
  vector<int> X(100001, 0);
  rep(i, 0, N){
    int a; cin >> a;
    if(a > 0) X[a - 1]++;
    X[a]++;
    X[a + 1]++;
  }
  int res = 0;
  rep(i, 0, 100001){
    if(X[i] > res) res = X[i];
  }
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 640
N, T = list(map(int, input().split()))
A = list(map(int, input().split()))

max_diff = 0
count = 0
minv = A[0]

for i in range(1, len(A)):
    if max_diff < (A[i]- minv):
        max_diff = A[i]- minv
        count = 1
    elif max_diff == (A[i]- minv):
        count += 1
        
    if minv > A[i]:
        minv = A[i]
        
print(count)   

Measured memory_bytes: 15020
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000;

int aa[N];

int main() {
	int n, a, b; cin >> n >> a >> b;
	int c = a - b;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	int lower = 0, upper = 1000000000;
	while (upper - lower > 1) {
		int k = (lower + upper) / 2;
		long long x = 0;
		for (int i = 0; i < n; i++) {
			long long d = aa[i] - (long long) b * k;
			if (d > 0)
				x += (d + c - 1) / c;
		}
		if (x <= k)
			upper = k;
		else
			lower = k;
	}
	cout << upper << '\n';
	return 0;
}


Measured memory_bytes: 3980
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int input = scan.nextInt();
        int A, B, C, D, a, b, c, d, e, f, g,h;

        D = input % 10;
        input /= 10;
        C = input % 10;
        input /= 10;
        B = input % 10;
        input /= 10;
        A = input % 10;
        input /= 10;

        a = A + B + C + D;
        b = A - B + C + D;
        c = A + B - C + D;
        d = A + B + C - D;
        e = A - B - C + D;
        f = A + B - C - D;
        g = A - B + C - D;
        h = A - B - C - D;

        if (a == 7) {
            System.out.println(A + "+" + B + "+" + C + "+" + D +"=7");
        } else if (b == 7) {
            System.out.println(A + "-" + B + "+" + C + "+" + D +"=7");
        } else if (c == 7) {
            System.out.println(A + "+" + B + "-" + C + "+" + D+"=7");
        } else if (d == 7) {
            System.out.println(A + "+" + B + "+" + C + "-" + D+"=7");
        } else if (e == 7) {
            System.out.println(A + "-" + B + "-" + C + "+" + D+"=7");
        } else if (f == 7) {
            System.out.println(A + "+" + B + "-" + C + "-" + D+"=7");
        } else if (g == 7) {
            System.out.println(A + "-" + B + "+" + C + "-" + D+"=7");
        }else if (h == 7) {
            System.out.println(A + "-" + B + "-" + C + "-" + D+"=7");
        }
    }
}

Measured memory_bytes: 22612
import std;
import core.bitop;

// dfmt off
ulong MAX = 100_100, MOD = 1_000_000_007, INF = 1_000_000_000_000;
alias sread = () => readln.chomp();
alias lread(T = long) = () => readln.chomp.to!(T);
alias aryread(T = long) = () => readln.split.to!(T[]);
void aryWrite(T = long)(T[] ary){ ary.map!(x => x.text()).join(' ').writeln(); }
alias Pair = Tuple!(long, "H", long, "W");
alias PQueue(T, alias less = "a>b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    auto n = lread();
    auto a = aryread();
    auto s = new long[](n + 1);
    iota(n).each!(i => s[i + 1] = s[i] + a[i]);
    long[long] counts;
    s.each!(x => counts[x] = (x in counts ? counts[x] + 1 : 1));
    counts.byValue.map!(x => x * (x - 1) / 2).sum.writeln();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}


Measured memory_bytes: 26912
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n , k;
    cin >> n >> k;
    int p[n] , c = 0;
    for( int i = 0 ; i < n ; i++ ) cin >> p[i];
    sort( p , p + n );
    for( int i = 0 ; i < k ; i++ ) c += p[i];
    cout << c;
} 


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
#define standardVar ll n,m,i,j,k,num,num1,num2,flag=0
#define nn <<"\n"
#define __ <<" "<<
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define ittr(x,v) for(auto x=v.begin();x!=v.end();x++)
#define itr(x,n) for(x=0;x<n;x++)
#define itrab(x,a,b) for(x=a;x<b;x++)
#define itpr(v) ittr(x,v)cout<<*x<<" "; cout nn
#define itppr(v) ittr(x,v)cout<<(*x).ff<<" "<<(*x).ss<<"  "; cout nn
#define size(x) (ll)x.size()
#define pi 3.14159265359
#define dTor(x) ((x)*pi)/180.0
#define INF 1000000100;

typedef long long int ll;       //TYPEDEFS
typedef long double ld;
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef set<ll> sl;
typedef string str;
typedef pair<ll, ll> pl;
typedef vector< pl > vpl;
typedef map<pl,ll> mpl;
typedef set< pl > spl;
typedef vector<str> vst;
typedef vector<vl> vvl;

const ll M=1000000007;          //COMMON MODULO PRIMES
const ll N=998244353;

ll power(ll x, ll y, ll p){     //MODULAR EXPONENTIATION
    ll res=1;
    x=x%p;
    if(x==0)
        return 0;
    while(y>0){
        if(y&1)
            res=(res*x)%p;
        y=y>>1;
        x=(x*x)%p;
    }
    return res;
}
ll inv(ll x, ll m){             //FERMAT INVERSE
    return power(x,m-2,m);
}
struct comp{                    //COMPARISON ON PAIRS
    template<typename T>        
    bool operator()(const T &a, const T &b){
        if (a.ff==b.ff)
            return (a.ss<b.ss);
        else
            return (a.ff<b.ff);
    }
};
bool mod(const pair<ll,ll> &a, const pair<ll,ll> &b){   //COMPARATOR FOR PAIRS (SORTING)
    if(a.ff!=b.ff)
        return (a.ff>b.ff);
    else
        return (a.ss>b.ss);
}
vector<bool> pr(1000000+1,1);
void sieve(ll mn, ll mx){       //SIEVE OF ERATOSTHENES
    for(ll i=mn;i*i<=mx;i++)
        if(pr[i-mn]==1)
            for(ll j=i*i;j<=mx;j+=i)
                pr[j-mn]=0;
}
bool isValid(ll i, ll j, ll n, ll m){   //CHECKS FOR OVERFLOW
    if(i>=0&&i<n&&j>=0&&j<m){
        return true;
    }
    return false;
}


//MAIN FUNCTION STARTS HERE

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    standardVar;
    vl v(5);
    itr(i,5){
        cin>>v[i];
        if(v[i]==0){
            cout<<i+1;
        }
    }
    return 0;
}

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

const int INF = 100000000;


int main()
{
     int N,M,X;
     int hekaku =INF;
     cin>>N>>M>>X;
      int c[N];
      int A[N][M];
     
  
      for(int i=0;i<N;i++)
      {
         cin>>c[i];
         for(int j=0;j<M;j++)
         {
             cin>>A[i][j];
         }
      }

    
  
     for(int bit =0;bit<(1<<N);bit++)
     {
        int sum =0;
        int cnt =0;
        vector<int>m(M,0);
          for(int i=0;i<N;i++)
          {
               if(bit&(1<<i))
               {
                   sum += c[i];
                 
                   for(int j=0;j<M;j++)
                   {
                       m[j] += A[i][j];
                   }
               } 
          }
       for(int j=0;j<M;j++)
       {
          if(m[j] >=X) 
          {
              cnt++;
          }
       }
         if(cnt==M)
          {
             hekaku = min(hekaku,sum);
          }
     }

  if(hekaku!=INF)
  {
        cout<<hekaku<<endl;
  }
  else
  {
      cout<<"-1"<<endl;    
  }
  
  
  return 0;

}


Measured memory_bytes: 3652
#include<iostream>
#include<vector>
int n,m,q;
std::vector<int> val(10);
std::vector<int> a(50),b(50),c(50),d(50);
int ans = 0;

void dfs(std::vector<int> &enu, int h){
    if(h == n-1){
        int cnt = 0;
        for(int k = 0;k < q;k++){
            if(enu.at(b.at(k)) - enu.at(a.at(k)) == c.at(k)){
                cnt += d.at(k);
            }
            ans = std::max(ans,cnt);
        }
        return;
    }
    for(int i = enu.at(h);i <= m;i++){
        val.at(h+1) = i;
        dfs(enu,h+1);
    }
    return;
}

int main(){
    std::cin >> n >> m >> q;
    for(int i = 0;i < q;i++){
        std::cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--;
        b.at(i)--;
    }
    for(int j = 1;j <= m;j++){
        val.at(0) = j;
        dfs(val,0);
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3652