akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using ll = long long;
using namespace std;

void solve() {
   int n, p;
   cin >> n >> p;

   vector <int> v(n);
   int even = 0;
   int odd = 0;
   for(int i = 0; i < n; i++) {
      cin >> v[i];
      v[i] %= 2;
      even += v[i] == 0;
      odd += v[i] == 1;
   }

   if(odd == 0) {
      if(p == 1) {
         cout << 0 << endl;
      } else {
         cout << (1LL << n) << endl;
      }
   } else {
      cout << (1LL << (n - 1)) << endl;
   }
}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   }
 
   return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <string>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <numeric>
using namespace std;

int abs(int num){
   if (num > 0)
      return num;
   else
      return -num;
}

int main(){
  int A,B;
  cin >> A >> B;
  if(A + B >= 10){
    cout << "error" << endl;
  }
  else{
    cout << A + B << endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
  int n; cin >> n;
  vector<ll> A(n);
  ll sum = 0;
  rep(i, n){
    cin >> A[i];
    sum += A[i];  
  }
  double avg = sum / (double)n;
  double sa = LINF, res = -1;
  rep(i, n){
    if(sa > abs(avg - A[i])){
      sa = abs(avg - A[i]);
      res = i;
    }
  }
  cout << res << ln;
}


Measured memory_bytes: 3696
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cmath>
using namespace std;

int main(){
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(a - x) > abs(b - x))
		cout << "B" << endl;
	else
		cout << "A" << endl;

	return 0;
}

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

#define int long long

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

    int a[100010];

    int ans = 0;
    int ma = LLONG_MIN;
    int cnt = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(a[i] <= 0){
            ans += -a[i];
            ma = max(ma, a[i]);
            cnt++;
        }else{
            ans += a[i];
            ma = max(ma, -a[i]);
        }
    }

    if(cnt % 2 == 0){
        cout << ans << endl;
    }else{
        cout << ans + ma*2 << endl;
    }

    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}

signed main()
{
    int N;
    cin >> N;
    int tb[10][10];
    REP(i, 10)
    {
        REP(j, 10)
        {
            tb[i][j] = 0;
        }
    }
    REP(i, N)
    {
        int a = i + 1;
        int b = a % 10;
        while (a >= 10)
            a /= 10;
        tb[a][b]++;
    }
    int ans = 0;
    REP(i, 10)
    {
        REP(j, 10)
        {
            ans += (tb[i][j] * tb[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int n;
    cin >> n;
    vi L(n);
    for (auto &&e: L) cin >> e;

    sort(all(L));

    int mx = L[n - 1];
    int sum = accumulate(all(L), 0);
    return sum - mx > mx;
}


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

    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 256
my ($p, $q, $r) = split(/ /, <>);
my $a = $p + $q;
my $b = $q + $r;
my $c = $r + $p;
my $min = $a;
if ($b < $min){
        $min = $b;
}
if ($c < $min){
        $min = $c;
}
print $min;

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a, b, c;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> a >> b >> c;
	cout << (c-b == b-a ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
long long int x, y;
int main(){
    scanf("%lld%lld", &x, &y);
    long long int diff = y / x;
    int cnt = 0;
    while(diff){
        cnt ++;
        diff /= 2;
    }
    printf("%d", cnt);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>//万能头万岁！
using namespace std;
long long n,x,y,z,d,ma;
int main(){
    scanf("%d%d%d%d%d",&x,&y,&z,&d,&n);ma=min(min(4*x,2*y),z);
    cout<<min(ma*n,(n/2*d+n%2*ma))<<endl;
    return 0;
}
//THIS PROGRAM IS WRITTEN BY NO_MANEY

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#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 int N = 2005;
const ll MOD = 1e9 + 7;

int n, m;
ll dp[N][N];

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    vector<int> a(n), b(m);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    
    rep(i, 0, N) {
        dp[0][i] = 1;
        dp[i][0] = 1;
    }

    rep(i, 1, n + 1) {
        rep(j, 1, m + 1) {
            if (a[i - 1] == b[j - 1]) {
                dp[i][j] = (2 * dp[i - 1][j - 1]) % MOD + (dp[i - 1][j] + dp[i][j - 1] - 2 * dp[i - 1][j - 1]);
                dp[i][j] %= MOD;
            } else {
                dp[i][j] = ((dp[i - 1][j] + dp[i][j - 1]) % MOD - dp[i - 1][j - 1] + MOD) % MOD;
                dp[i][j] %= MOD;
            }
        }
    }
    
    if (dp[n][m] < 0) cout << dp[n][m] + MOD;
    else cout << dp[n][m];
}


Measured memory_bytes: 34988
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define SORT(obj) sort(ALL(obj))
#define GSORT(obj) sort(ALL(obj) , greater<int>())
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
int main(void) {

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

	P s, t;  cin >> s.first >> s.second >> t.first >> t.second;
	int dx = t.first - s.first, dy = t.second - s.second;

	REP(i, dx)  cout << 'R';  REP(i, dy)  cout << 'U';
	REP(i, dx)  cout << 'L';  REP(i, dy)  cout << 'D';

	cout << 'D';  REP(i, dx+1)  cout << 'R';  REP(i, dy+1)  cout << 'U';  cout << 'L';
	cout << 'U';  REP(i, dx+1)  cout << 'L';  REP(i, dy+1)  cout << 'D';  cout << 'R';

	return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
import numpy as np
H = np.array(input().split(), dtype = int)

INF = 10 ** 9 + 1
dp = np.full(N,INF,dtype = int)
dp[0] = 0

for i in range(1, N):
  dp[i] = min(dp[max(i - K,0):i] + abs(H[max(i - K,0):i] - H[i]))

print(dp[-1])

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

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

int main(){
    char b[8][9];
    while(1){
        loop(i,8)if(!(cin>>b[i])) return 0;
        int maxx=-1,maxy=-1,minx=8,miny=8;
        loop(y,8)loop(x,8){
            if(b[y][x]=='1'){
                minx=min(x,minx),miny=min(y,miny);
                maxx=max(x,maxx),maxy=max(y,maxy);
            }
        }
        int dx=maxx-minx,dy=maxy-miny;
        char ans;
        if(dx==1&&dy==1) ans='A';
        else if(dx==0) ans='B';
        else if(dy==0) ans='C';
        else if(b[miny][minx]=='0'){
            if(dx==1) ans='D';
            else ans='G';
        } else {
            if(dx==1) ans='F';
            else ans='E';
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1132
n=int(input())
l=[]
for _ in range(n):
    a,b=map(int,input().split())
    l.append((b,a))
l.sort()
#print(l)
t=0
for i in l:
    b=i[0]
    a=i[1]
    if t>b-a:
        print('No')
        exit()
    else:
        t+=a
print('Yes')


Measured memory_bytes: 29444
from math import factorial
n, k = [int(i) for i in input().split()]
mod = 10 ** 9 + 7

def s(n, m=0): # m~nの総和
    global mod
    return (n * (n+1) // 2 - (n-m) * (n-m+1) // 2) % mod

sm = 0
for i in range(k, n+1):
    sm = (sm + s(n, i) - s(i-1, i-1) + 1) % mod

print((sm+1) % mod)

Measured memory_bytes: 9116
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int dp[2][2001][2001]={};
int dp2[2][2001][2001]={};
int dp3[2][2001][2001]={};
int main() {
	int n,k;
	cin>>n>>k;
	ll x1,y1;
	char c1;
	for(int i=0;i<n;++i){
		cin>>x1>>y1>>c1;
		x1%=2*k;
		y1%=2*k;
		if(c1=='B')dp[0][x1+1][y1+1]++;
		if(c1=='W')dp[1][x1+1][y1+1]++;
	}
	for(int h=0;h<2;++h){
		for(int i=1;i<2*k+1;++i){
			for(int j=1;j<2*k+1;++j){
				dp2[h][i][j]=dp2[h][i][j-1]+dp[h][i][j];
				dp3[h][i][j]=dp3[h][i-1][j]+dp2[h][i][j];
			}
		}
	}
	int r=0;
	for(int i=0;i<k+1;i++){
		for(int j=0;j<k+1;j++){
			int t=0;
			t+=dp3[0][2*k][j]-dp3[0][i+k][j]+dp3[0][i][j];
			t+=dp3[0][i+k][k+j]-dp3[0][i+k][j]-dp3[0][i][k+j]+dp3[0][i][j];
			t+=dp3[0][2*k][2*k]-dp3[0][2*k][j+k]-dp3[0][i+k][2*k]+dp3[0][i+k][j+k];
			t+=dp3[0][i][2*k]-dp3[0][i][j+k];
			t+=dp3[1][i+k][j]-dp3[1][i][j];
			t+=dp3[1][2*k][j+k]-dp3[1][i+k][j+k]-dp3[1][2*k][j]+dp3[1][i+k][j];
			t+=dp3[1][i][j+k]-dp3[1][i][j];
			t+=dp3[1][i+k][2*k]-dp3[1][i+k][j+k]-dp3[1][i][2*k]+dp3[1][i][j+k];
			r=max(r,t);
			t=0;
			t+=dp3[1][2*k][j]-dp3[1][i+k][j]+dp3[1][i][j];
			t+=dp3[1][i+k][k+j]-dp3[1][i+k][j]-dp3[1][i][k+j]+dp3[1][i][j];
			t+=dp3[1][2*k][2*k]-dp3[1][2*k][j+k]-dp3[1][i+k][2*k]+dp3[1][i+k][j+k];
			t+=dp3[1][i][2*k]-dp3[1][i][j+k];
			t+=dp3[0][i+k][j]-dp3[0][i][j];
			t+=dp3[0][2*k][j+k]-dp3[0][i+k][j+k]-dp3[0][2*k][j]+dp3[0][i+k][j];
			t+=dp3[0][i][j+k]-dp3[0][i][j];
			t+=dp3[0][i+k][2*k]-dp3[0][i+k][j+k]-dp3[0][i][2*k]+dp3[0][i][j+k];

			r=max(r,t);
		}
	}

	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 94080
#include <stdio.h>
#define MAX 100
int main(void){
    int n,i,a[MAX];
    scanf("%d",&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++){
        printf("%d",a[n-i-1]);
        if(i!=n-1)
            putchar(' ');
    }
    puts("");
    return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
const int INF = 1000000000;

int main(){
	int a,b;
	ci2(a,b);
	if((a+b)%2==0){
		co(((a+b)/2));
	}
	else{
		co("IMPOSSIBLE");
	}
}


Measured memory_bytes: 256
x,y=map(int,input().split())
ans=0
if x>=0 and y>=0 and y>=x:
    print(y-x)
elif x>=0 and y>0 and y<x:
    x*=-1
    ans=+1#xを負にする
    ans+=abs(x)-y
    ans+=1#xを正に戻す
    print(ans)
elif x>0 and y==0:
    print(x+1)
elif x>y and x>0 and y<0:
    if abs(x)>=abs(y):
        x*=-1
        ans=+1#xを負にする
        ans+=abs(x)-abs(y)
        print(ans)
    elif abs(x)<abs(y):
        ans+=abs(y)-abs(x)
        ans+=1#xを負にする
        print(ans)
elif x==0 and y<0:
    print(-y+1)
elif x<0 and y>0:
    if abs(x)>=abs(y):
        ans+=abs(x)-abs(y)
        ans+=1#xを正にする
        print(ans)
    elif abs(x)<abs(y):
        x*=-1
        ans+=1#xを正にする
        ans+=(y-x)
        print(ans)
elif x<0 and y==0:
    print(y-x)
elif x<0 and y<0:
    if x<=y:
        print(y-x)
    elif x>y:
        x*=-1#xを正にする
        ans+=1
        ans+=abs(y)-abs(x)
        ans+=1#xを負に戻す
        print(ans)

Measured memory_bytes: 9284
def main():
    n = int(input())
    w = list(map(int, input().split()))

    avr = sum(w) // 2
    res = 0
    ans1 = 0
    ans2 = 0    
    for i in range(n):
        res += w[i]
        if res > avr:
            ans1 = abs(sum(w[(i+1):]) - sum(w[:(i+1)]))
            ans2 = abs(sum(w[i:]) - sum(w[:i]))
            print(min(ans1,ans2))
            return


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
N,Q = gets.split.map(&:to_i)
str = gets.chomp
ans_ary = [0]
(N-1).times{|i|
  ans_ary[i+1] = if str[i..(i+1)] == 'AC'
    ans_ary[i] + 1
  else
    ans_ary[i]
  end
}
Q.times{
  l,r = gets.split.map(&:to_i)
  puts ans_ary[r-1] - ans_ary[l-1]
}

Measured memory_bytes: 3452
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
#define ll long long int

bool ATGC( char x ) {
  if (x == 'A' || x == 'T' || x == 'G' || x == 'C' ){
    return true;  
  } else {
    return false;  
  }
}
int main () {
  int ans = 0,temp = 0;
  string s;
  cin >> s;
  for ( int i = 0; i < s.size(); ++i ) {
    if ( ATGC(s[i]) ) {
      ++temp;
      ans = max( ans, temp );  
    }else {
      temp = 0;  
    }
  }
  cout << ans << endl;
  return 0;
}


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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

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

    int r, d, x;
    cin >> r >> d >> x;
    for (int i = 0; i < 10; i++) {
        x = r * x - d;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    long long n;
    scanf("%lld", &n);
    long long a[n+1];
    long long hasil = 1;
    int flag = 1;
    int print;
    
    for(int i = 0; i<n; i++){
    	scanf("%lld", &a[i]);
    	if(a[i] == 0){
    		printf("0");
    		flag = 0;
    		break;
    	}
    }
    
    if(flag){
	    for(int i = 0; i<n; i++){
	    	if(a[i] > 1000000000000000000/hasil){
	    		flag = 0;
	        	break;
	    	}
	        hasil *= a[i]; 
	        if(i >= n-1){
	        	     print = 1;
	    }
    }
    
    if(print){
    	flag ? printf("%lld\n", hasil) : printf("-1\n");
    }
    
    return 0;
	}
}

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

// 約数の個数 (１の倍数＋２の倍数＋３の倍数＋...)
template <int N> struct calc_approx {
    int cnt[N + 1] = {0};

    constexpr calc_approx() : cnt() {
        for (int_fast64_t i = 1; i <= N; ++i) {
            for (int_fast64_t j = i; j <= N; j += i)
                cnt[j]++;
        }
    }
};
calc_approx<200000> approx;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 105; i <= N; i += 2) {
        ans += (approx.cnt[i] == 8);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4420
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import Data.List (sortBy)
import Data.Maybe (fromJust)

main :: IO ()
main = do
  [n, m] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- sortBy (flip compare) . map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    table = V.constructN (succ n) rec :: V.Vector ((Int, [Int]))
      where
        rec :: V.Vector ((Int, [Int])) -> ((Int, [Int]))
        rec v | l == 0    = (0, [])
              | otherwise = maximum . map f $ as
          where
            l = V.length v :: Int
            f :: Int -> (Int, [Int])
            f d | l < k     = (-n, [])
                | otherwise = ((,) <$> succ . fst <*> (d :) . snd) $ v V.! (l - k)
              where
                k = matchNums VU.! d :: Int
  mapM_ (putStr . show) . snd $ table V.! n
  putStrLn ""

matchNums = VU.fromList [6, 2, 5, 5, 4, 5, 6, 3, 7, 6] :: VU.Vector Int
{-# INLINE matchNums #-}

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  double ans=0;
  for(int i=1;i<=n;i++){
    double t=1.0/n;
    int x=i;
    while(x<k){
      x*=2;
      t/=2;
    }
    ans+=t;
  }
  cout << fixed << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0)return a;
    return gcd(b,a%b);
}
signed main(){
    ll ans=0;
    ll k;cin>>k;
    REP(i,1,k+1){
        REP(j,1,k+1){
            REP(l,1,k+1){
                ans+=gcd(i,gcd(j,l));
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  string s; cin>>s;  
  string ans = "-1";
  if(s.size()<26){
    map<char,int> mp;
    REP(i,s.size()){ ++mp[s[i]]; }
    for(char c='a'; c<='z'; ++c){
      if(mp[c]==0){ ans = s + (char)c; break;}
    }
  }else{
    int i = 25;
    int j = 25;
    while(s[i-1]>s[i]){--i;}
    while(s[i-1]>s[j]){--j;}
    if(i>0){
      ans = s.substr(0,i-1) + s[j];
    }
  }
  cout << ans<< "\n";  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/***** MAIN *****/
signed main() {
  int n;
  scanf("%d",&n);
  string s, sub_s = "ABC";
  cin >> s;
  int ans = 0;
  int position = s.find(sub_s);
  
  while(position != string::npos) {
    ++ans;
    position = s.find(sub_s, position + sub_s.length());
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
 
bool mas[4][4][4];
string s = "LURD";
const int dy[] = { 0, -1, 0, 1}, dx[] = { -1, 0, 1, 0};
 
void dfs( int y, int x, int pos){
  cout << s[pos];
  if(!y && !x){
    cout << endl;
    return;
  }
  for(int i = 0 ; i < 4 ; i++ ){
    int dd = ( pos + 3 + i ) % 4;
    int ny = y + dy[ dd], nx = x + dx[ dd];
    if(mas[y][x][dd]){
      dfs( y + dy[ dd], x + dx[ dd], dd);
      return;
    }
  }
}
int main(){
  char c;
  for(int i = 0 ; i < 9 ; i++ ){
    if(i & 1) for(int j = 0 ; j < 5 ; j++ ){
      cin >> c;
      if(c == '1') mas[i / 2][j][3] = mas[i / 2 + 1][j][1] = true;
    } else for(int j = 0 ; j < 4 ; j++ ){
      cin >> c;
      if(c == '1') mas[i / 2][j][2] = mas[i / 2][j + 1][0] = true;
    }
  }
  dfs( 0, 1, 2);
}


Measured memory_bytes: 1180
fun main(args: Array<String>) {
    val abcd = readLine()!!

    for (bit in 0..7) {
        var exp = abcd[0].toString()
        var eval = abcd[0] - '0'
        for (i in 0..2) {
            if (1 and (bit shr i) == 1) {
                exp += "+" + abcd[i+1]
                eval += abcd[i+1] - '0'
            } else {
                exp += "-" + abcd[i+1]
                eval -= abcd[i+1] - '0'
            }
        }
        if (eval == 7) {
            println("$exp=7")
            return
        }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N){
    cin >> A.at(i);
  }
  
  int count = 0;
  int count_2 = 0;
  rep(i, N){
    if (A.at(i) % 2 == 0){
      count += 1;
      if (A.at(i) % 3 == 0 | A.at(i) % 5 == 0){
        count_2 += 1;
      }
    }
  }
  
  if (count == count_2){
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
  
      
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1


N, Q = map(int, input().split())
AB = [[int(x) for x in input().split()] for _ in range(N - 1)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
    graph[a].append(b)
    graph[b].append(a)

value = [0] * (N + 1)
for p, x in PX:
    value[p] += x

q = [(1, 0)]
while q:
    x, parent = q.pop()
    value[x] += value[parent]
    for y in graph[x]:
        if y == parent:
            continue
        q.append((y, x))

ans = ' '.join(map(str, value[1:]))
print(ans)


Measured memory_bytes: 124756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, A, B;
	cin >> N >> A >> B;

	co(min(N * A, B));

	Would you please return 0;
}

Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');
// 自分の得意な言語で
// Let's チャレンジ！！

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
 

var a = parseInt(lines[0].split(' ')[0],10);
var b = parseInt(lines[1].split(' ')[0],10);

if(a===b){
    console.log(0);
}else{
    console.log(1);
}

});

Measured memory_bytes: 11596
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  
         long long int n,k,i,j;
                cin>>n>>k;
        long long int a[n];
                for(i=0;i<k;i++)
                {
                    cin>>a[i];    
                }
                for(;i<n;i++)
                {
                        cin>>j;
                        a[i]=j;
                        if(j>a[i-k])
                                cout<<"Yes"<<endl;
                        else
                                cout<<"No"<<endl;
                }
   return 0;    
}

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

//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cerr << #a << " = " << a << endl;

template<typename T> void setmax(T& x, T y) {x = max(x, y);}
template<typename T> void setmin(T& x, T y) {x = min(x, y);}

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1 << 18;
int n, m, l[N], r[N], c[N];
vector<pair<int, int>> g[N];
LL d[N];

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

	cin >> n >> m;
	FOR(i, 0, m){
		cin >> l[i] >> r[i] >> c[i];
		g[l[i]].PB({r[i], c[i]});
	}

	FOR(i, 1, n) g[i + 1].PB({i, 0});
	
	FOR(i, 2, n + 1) d[i] = LINF;
	set<pair<LL, int>> S;
	S.insert({0, 1});
	while(SZ(S)){
		int v = S.begin()->Y;
		S.erase(S.begin());
		for(auto to: g[v]){
			if (d[to.X] > d[v] + to.Y){
				S.erase({d[to.X], to.X});
				d[to.X] = d[v] + to.Y;
				S.insert({d[to.X], to.X});
			}
		}
	}
	
	if (d[n] == LINF) d[n] = -1;
	cout << d[n] << endl;

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}


Measured memory_bytes: 17212
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>


int main(){
	int n;
	std::cin>>n;

	std::vector<long long> aList(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	long long cur=0;
	for(int i=0; i<n; i++)
		cur= aList[i]-cur;

	cur= cur/2;

	for(int i=0; i<n; i++){
		std::cout<<cur*2;
			cur= aList[i]-cur;	
		if(i<n-1)
			std::cout<<" ";
	}

	std::cout<<std::endl;

	return 0;
	
}

Measured memory_bytes: 2048
import numpy as np

N,K=map(int, input().split())

A=[]
l=[]
for _ in range(K):
    d = map(int, input())
    l=list(map(int,input().split()))
    A.append(l)
#print(A)
a=np.zeros((N, K))
for i in range (len(A)):
    for j in range(len(A[i])):
        a[A[i][j]-1][i]=1
#print(a)
print(np.count_nonzero(np.all(a==0, axis=1)))


Measured memory_bytes: 27452
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <set>

using ll = long long;

using namespace std;

int main() {
    long n, k;
    cin >> n >> k;
    int a[n], last[200001], next[n];
    fill(last, last+200001, -1);
    fill(next, next+n, 2000000);
    for (auto &ai:a) cin >> ai;
    for (int i=0; i<2*n; i++) {
        int ai = a[i % n];
        if (0 <= last[ai] && last[ai] < n && next[last[ai]] > i) next[last[ai]] = i + 1;
        last[ai] = i;
    }
    int cur = 0;
    long cnt = 0;
    set<long> starts;
    while (true) {
        starts.insert(cnt);
        cnt += next[cur] - cur;
        cur = next[cur] % n;
        if (cur == 0) break;
    }
    auto st = prev(starts.upper_bound((n * k) % cnt));
    for (int i=(*st % n); i<n; ) {
        if (next[i] <= n) {
            i = next[i];
            continue;
        }
        cout << a[i] << ' ';
        i++;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 13184
import java.util.Scanner;

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

        for (int i = 0; i < h; i++) {
            String s = sc.next();
            System.out.println(s);
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 24788
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,M=MI()
    if N==M:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  for (int i = A; i <= B; i++) {
    if (i%K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }
  cout << "NG" << endl;
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n;
    string s, ans = "";
    cin >> n;
    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        int add = s[i] + n;
        if (add > 90) {
            add = 65 + s[i] + n - 91;
        }
        ans += add;
    }
    cout << ans << '\n';
    return 0;
}

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

int main(void){
  int a, b, c;
  int total=0;

  scanf("%d %d %d", &a, &b, &c);
  while((a+b+1) < c){
    c -= 1;
  }
  total = b + c;
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> v[i];
	}

	sort(v.begin(), v.end(), greater<ll>());

	auto sum = 0ll;
	auto cur = 0ll;
	auto num = 0;
	auto numA = 0;
	for (auto i = 0; i < N; ++i)
	{
		if (i < A)
		{
			sum += v[i];
			if (cur != v[i])
			{
				cur = v[i];
				num = 0;
				numA = 0;
			}
			++num;
			++numA;
		}
		else if (cur == v[i])
		{
			++num;
		}
	}

	auto ave = (double)sum / A;
	auto maxNum = 0;
	if (v[A - 1] == v[0])
	{
		maxNum = min(B - A + numA, num);
	}
	else
	{
		maxNum = numA;
	}
	auto result = 0ll;
	auto comb = 1ll;
	for (auto i = 1; i <= maxNum; ++i)
	{
		comb *= num - i + 1;
		comb /= i;
		if (i >= numA)
		{
			result += comb;
		}
	}

	cout << fixed << setprecision(10) << ave << endl;
	cout << result << endl;

	return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


// 2数の最大公約数をユークリッドの互助法により求める
template <typename T>
T gcd( T a, T b )
{
    if( b == 0 ) return a;
    else return gcd( b, a % b );
}

// 最小公倍数
template <typename T>
T lcd( T a, T b ) { return a * b / gcd( a, b ); }

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

    long long num_C_multiple = B/C-(A-1)/C;
    long long num_D_multiple = B/D-(A-1)/D;
    long long CD_lcd = lcd<long long>(C, D);
    long long num_CD_multiple = B/CD_lcd-(A-1)/CD_lcd;

    cout << (B-A+1) - (num_C_multiple+num_D_multiple-num_CD_multiple) << endl;
    
    return 0;
}

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

int main(){
    int q;
    scanf("%d\n",&q);
    
    int a[q];
    int i=0;
    
    int com,x;
    while(q--){
        scanf("%d \n",&com);
        switch(com){
            case 0:
                scanf("%d\n",&x);
                a[i++]=x;
                break;
            case 1:
                scanf("%d\n",&x);
                printf("%d\n",a[x]);
                break;
            case 2:
                a[i--]=-1;
                break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 2464
k=int(input())

q=["1","2","3","4","5","6","7","8","9"]
x=9
for i in q:
    if x>100000:
        break
    x+=1
    a=i[-1]
    for j in ([-1,0,1]):
        bb=int(a)+j
        if bb<10 and bb>=0:
            q.append(i+str(bb))


print(q[k-1])

Measured memory_bytes: 23796
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double n,m;
    cin >> n >> m;
    cout << n/m << endl;
    return 0;
}

Measured memory_bytes: 256
arr = []
ARGF.each_line do |line|
    arr.push line.to_i
end
n = arr.shift
j = 1
min_val = arr[0]
result = arr[1]-arr[0]
while j < n
    val = arr[j] - min_val
    if result < val
        result = val
    end
    if arr[j] < min_val
        min_val = arr[j]
    end
    j += 1
end

puts result


Measured memory_bytes: 9236
K = int(input())
nums = []

def ans(num):
    if num > 3234566667:
        return
    nums.append(num)
    if int(str(num)[-1]) + 1 <= 9:
        tmp = int(str(num) + str(int(str(num)[-1]) + 1))
        ans(tmp)
    if int(str(num)[-1]) - 1 >= 0:
        hoge = int(str(num) + str(int(str(num)[-1]) - 1))
        ans(hoge)
    hage = int(str(num) + str(int(str(num)[-1])))
    ans(hage)

for i in range(1,10):
    ans(i)

nums.sort()
print(nums[K-1])

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

int main(){
    int n;
    cin >> n;
    int num[4], i=0;
    while(n>0){
        num[i] = n % 10;
        n /= 10;
        i++;
    }
    if(num[0]==num[1] && num[1]==num[2]){
        cout << "Yes" << endl;
    }
    else if(num[1]==num[2] && num[2]==num[3]){
        cout << "Yes" << endl; 
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

typedef long long ll;

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

    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = n / (a+b);
    ans *= a;
    if(n%(a+b)>=a) ans += a;
    else ans += n%(a+b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
ans = 'NA'
if 1 <= int(s[:2]) <= 12:
    ans = 'MMYY'
    if 1 <= int(s[2:]) <= 12:
        ans = 'AMBIGUOUS'
elif 1 <= int(s[2:]) <= 12:
    ans = 'YYMM'
print(ans)

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= (int) b; i--)
#define R0F(i, a) ROF(i, a, 0)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, 30, +31, +30, +31, +31, +30, +31, +30, +31};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, mx = 0;
  cin >> n;
  map<string, int> cnt;
  F0R (i, n) {
    string foo;
    cin >> foo;
    ++cnt[foo];
    mx = max (mx, cnt[foo]);
  }
  GO (to, cnt) if (to.s == mx) cout << to.f << '\n';
  return 0;
}



Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
int a[4];
char ans[5];
bool dfs(int i,int sum);
int main(){
  string temp;
  cin >> temp;
  for(int i=0;i<4;i++){
    a[i] = temp[i]-'0';
  }
  dfs(1,a[0]);
  cout << a[0] << ans[1] << a[1] << ans[2] << a[2] << ans[3] << a[3] << "=7";
}
bool dfs(int i,int sum){
  if(i==4){
    return sum==7;
  }else if(dfs(i+1,sum+a[i])){
    ans[i] = '+';
    return true;
  }else if(dfs(i+1,sum-a[i])){
    ans[i] = '-';
    return true;
  }else{
    return false;
  }
}


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

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()
#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}

typedef uint64_t ulint;
typedef int64_t lint;
using namespace std;

lint a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
bool flagdebug = false;

int main(){
//////////////////////////////////////////////////////
    // flagdebug = true;

    cin >> h >> w >> n;

    if(h > w)
    {
        cout << (n + h - 1) / h << endl;
    }
    else
    {
        cout << (n + w - 1) / w << endl;
    }


//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ic;
        if(n>2 && n<101){
            ic = 180*(n-2);
            System.out.println(ic);
        }
        
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(void)
{
    int N, M, K, A;
    cin >> N >> M;
    vector<int> count(M + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> K;
        for (int j = 0; j < K; j++)
        {
            cin >> A;
            count[A]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= M; i++) if (count[i] == N) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}

void solve(){
    ll f =0;
    ll a[3][3];
    rep(i, 3) rep(j, 3) cin >> a[i][j];
    rep(i, 3) rep(j, 3) f += a[i][j];
    if(f%3) ANS("No");
    ll f1 = 0;
    rep(i, 3) f1 += a[i][i];
    if(f1*3 != f) ANS("No");
    cout << "Yes";
}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
using namespace std;
struct node{
  int key;
  node *parent,*left,*right;
};
node *NIL,*root;
void insert(int x){
  node *n,*r=root,*m=NIL;
  n=(node *)malloc(sizeof(node));
  n->key=x; n->left=NIL; n->right=NIL;
  while(r!=NIL){
    m=r;
    if(n->key<r->key) r=r->left;
    else r=r->right;
  }
  n->parent=m;
  if(m==NIL) root=n;
  else{
    if(n->key<m->key) m->left=n;
    else m->right=n;
  }
}
void inorder(node *p){
  if(p!=NIL){
    inorder(p->left);
    cout<<" "<<p->key;
    inorder(p->right);
  }
}
void preorder(node *p){
  if(p!=NIL){
    cout<<" "<<p->key;
    preorder(p->left);
    preorder(p->right);
  }
}
int find(int x){
  node *r=root;
  while(r!=NIL){
    if(r->key==x) return 1;
    if(r->key<x) r=r->right;
    else r=r->left;
  }
  return 0;
}
int main(){
  int n,x;
  char s[7]; cin>>n;
  for(int i=0;i<n;++i){
    cin>>s;
    if(s[0]=='i'){
      cin>>x;
      insert(x);
    }else if(s[0]=='p'){
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }else{
      cin>>x;
      if(find(x)) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 21852
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
const ll MOD = 998244353;
const ll INF = 10000000000000000;

#define fr first
#define sc second
#define mp1(a,b,c) P1(a,P(b,c))

int main(){
	ll n,k;
	cin >> n >> k;
	
	if(2*k > n+1){
		puts("-1");
		return 0;
	}
	vector<P1> vec;
	if(n%2 == 1){
		for(int i = 0 ; i <= (n-1)/2 ; i ++){
			vec.push_back(mp1(k+2*i,k+2*n-(n-1)/2-i-1,k+2*n+i));
		}
		for(int i = 1 ; i <= (n-1)/2 ; i ++){
			vec.push_back(mp1(k+2*i-1,k+2*n-i,k+2*n+(n-1)/2+i));
		}
	}
	else {
		n --;
		for(int i = 0 ; i <= (n-1)/2 ; i ++){
			vec.push_back(mp1(k+2*i,k+2*n-(n-1)/2-i-1+2,k+2*n+i+2));
		}
		for(int i = 1 ; i <= (n-1)/2 ; i ++){
			vec.push_back(mp1(k+2*i-1,k+2*n-i+2,k+2*n+(n-1)/2+i+2));
		}
		vec.push_back(mp1(k+n,k+n+1,k+3*n+2));
	}
	
	for(int i = 0 ; i < vec.size() ; i ++){
		printf("%lld %lld %lld\n",vec[i].fr,vec[i].sc.fr,vec[i].sc.sc);
	}
}


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

constexpr int maxn = 1e5 + 100;

int n, m;
vector<int> vec[maxn]= {}, path;
bitset<maxn> viz = 0;

bool extend_path(){
    const int cur = path.back();
    while(!vec[cur].empty() && viz[vec[cur].back()]) vec[cur].pop_back();
    if(vec[cur].empty()) return false;
    viz[vec[cur].back()] = 1;
    path.push_back(vec[cur].back());
    return true; }

int main(){
    cin >> n >> m;
    for(int i = 0, a, b; i < m; ++i){
        cin >> a >> b;
        vec[a].push_back(b);
        vec[b].push_back(a); }
    path.push_back(1);
    path.push_back(vec[1][0]);
    viz[1] = viz[vec[1][0]] = 1;
    while(extend_path());
    reverse(begin(path), end(path));
    while(extend_path());
    cout << path.size() << endl;
    for(const auto x : path) cout << x << ' ';
    cout << endl;
    return 0; }


Measured memory_bytes: 6776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include<complex>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> pr;
typedef complex<double> com;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b)*c / 2 << endl;
	return 0;
}
//Ctrl+Aを使わない

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n ,r, a;
    scanf("%d %d", &n, &r);
    
    a = ( r + 100*(10-n));
    
    if(n >= 10)
    {
        printf("%d\n", r);
    }
    else
    {
        printf("%d\n", a);
    }

    return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i ++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i ++)
#define MP make_pair

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
const int MOD = 998244353;

int n;
char cs[1000005];
int occ[3], dat[3], hv[3];
bool del[1000005];

int main()
{
	scanf("%s", cs);
	n = unique(cs, cs + strlen(cs)) - cs;
	
	rep(i, n) occ[cs[i] - 'A'] ++;
	
	char ch = 'A';
	rep(i, 3) if(occ[i] > occ[ch - 'A']) ch = i + 'A';
	
	rep(i, n) if(cs[i] == ch) {
		if(i == 0 || i == n - 1 || cs[i - 1] != cs[i + 1]) dat[ch - 'A'] ++;
		else dat[cs[i - 1] - 'A'] ++;
	}
	
	int ret = n;
	rep(i, 3) ret = min(ret, occ[i]);
	
	while(ret > 0) {
		int tot = 0;
		rep(i, 3) tot += min(occ[i] - ret, dat[i]);
		if(occ[ch - 'A'] - tot <= ret) break;
		ret --;
	}
	
	rep(i, 3) dat[i] = min(dat[i], occ[i] - ret);
	
	for(int t = occ[ch - 'A'] - ret; t > 0; t --) {
		int moc = -1;
		rep(i, 3) if(i != ch - 'A' && dat[i] > hv[i]) moc = max(moc, occ[i]);
		if(moc == -1) {
			hv[ch - 'A'] ++;
			occ[ch - 'A'] --;
			if(occ[ch - 'A'] == ret) break;
			continue;
		}
		rep(i, 3) if(i != ch - 'A' && dat[i] > hv[i] && occ[i] == moc) {
			hv[i] ++;
			occ[i] --;
			occ[ch - 'A'] --;
			break;
		}
	}
	
	rep(i, n) if(cs[i] == ch) {
		if(i == 0 || i == n - 1 || cs[i - 1] != cs[i + 1]) {
			if(hv[ch - 'A']) {
				del[i] = true;
				hv[ch - 'A'] --;
			}
		} else {
			if(hv[cs[i - 1] - 'A']) {
				del[i] = true;
				del[i + 1] = true;
				hv[cs[i - 1] - 'A'] --;
			}
		}
	}
	
	int nn = 0;
	rep(i, n) if(!del[i]) cs[nn ++] = cs[i];
	rep(i, nn) del[i] = false;
	
	rep(i, 3) if(occ[i] != ret) {
		rep(j, n) if(cs[j] - 'A' == i && (j == 0 || j == nn - 1 || cs[j - 1] != cs[j + 1])) {
			del[j] = true;
			break;
		}
		break;
	}
	
	rep(i, nn) if(!del[i]) printf("%c", cs[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 3200