akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
#include <queue>
using namespace std;

const int INF = 1000000000;
void chmin(int &a, int b) { if(a > b) a = b;}

int main(){
	int N; cin >> N;
	string S; cin >> S;

	vector<int> cusum(N, 0);
	int sum = 0;
	for(int i = 0; i < N; i++){
		if(S[i] == 'E'){
			sum++;
		}
		cusum[i] = sum;
	}

	int min = INF;
	for(int i = 0; i < N; i++){
		if(i == 0) chmin(min, sum - cusum[i]);
		else chmin(min, i - cusum[i - 1] + sum - cusum[i]);
	}

	cout << min << endl;
}


Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
int n,h[100005],arr[100005];
int solve(int idx){
    if(idx >= n)
        return 2e9;
    if(idx == n-1)
        return 0;
    if(arr[idx] != -1)
        return arr[idx];
    int ans = 2e9;
    ans = min(ans, abs(h[idx] - h[idx + 1]) + solve(idx + 1));
    ans = min(ans,abs(h[idx] - h[idx + 2]) + solve(idx + 2));
    arr[idx] = ans;
    return ans;
}
int main()
{
    cin >> n;
    memset(arr, -1, sizeof arr);
    for(int i =0; i < n; i++)
        cin >> h[i];
    cout << solve(0) << endl;

    return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<string> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    vector<ll> count(5);
    rep(i,5){
        count[i] = 0;
    }
    rep(i,N){
        if (vec[i][0] == 'A'){
            count[0] += 1;
        }
        else if (vec[i][0] == 'C'){
            count[1] += 1;
        }
        else if (vec[i][0] == 'H'){
            count[2] += 1;
        }
        else if (vec[i][0] == 'M'){
            count[3] += 1;
        }
        else if (vec[i][0] == 'R'){
            count[4] += 1;
        }
    }
    ll ans = 0;
    rep(i,5){
        for(int j = i + 1; j < 5; j++){
            for(int k = j + 1; k < 5; k++){
                ans += count[i] * count[j] * count[k];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

ll get(ll n){
    if(n < 6){return n;}
    ll j, k;
    for(ll i=1; i<20; i++){
        if(powl(6LL,i)>n){
            j = i-1; break;
        }
    }
    for(ll i=1; i<20; i++){
        if(powl(9LL,i)>n){
            k = i-1; break;
        }
    }
    ll p = powl(6LL,j), q = powl(9LL,k);
    return min(1+get(n - p), 1+get(n - q));
}

int main(){
    ll N; cin >> N;
    ll c = get(N);
    cout << c<<endl;;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int W, H, x, y, r;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
    cin >> r;

    if (x>=r&&x<=W-r&&y>=r&&y<=H-r)
    {
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }    
    

	return 0;
}



Measured memory_bytes: 3112
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int r;
  while (cin >> r) {
    cout << (3 * r * r) << endl;
  }
  return 0;
}


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

using namespace std;

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

  int d, t, s;
  cin >> d >> t >> s;

  string ans = "Yes";
  if (d > t * s) {
    ans = "No";
  }

  cout << ans << '\n';

  return 0;
}


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

int main() {
  ll n; cin>>n;
  int ans=100;
  for(ll i=1;i<=sqrt(n);i++) {
    if(n%i==0) {
      int len_a=to_string(i).size();
      int len_b=to_string(n/i).size();
      int f=max(len_a,len_b);
      ans=min(ans,f);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3676
//#include "pch.h" 
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>
#include <iomanip>
#include <thread>
#include <atomic>
#include <mutex>
#include <future>
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod (int)(1e9 + 7)
#define inf (int)1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
using namespace std;
signed main() {
	int a[5];
	int sum = 0;
	int k = 10;
	int w = 1;
	rep(i, 5) {
		cin >> a[i];
		if (a[i] % 10 == 0) sum += a[i];
		else sum += a[i] + (10 - (a[i] % 10));
		if (a[i] % 10 <= k&&a[i] % 10 != 0) {
			k = a[i] % 10;
			w = i;
		}
	}
	cout << sum -(10- k)<< endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
c=[0]*(n+2)
for i in range(m):
  l,r=map(int,input().split())
  c[l-1]+=1
  c[r]-=1
for i in range(1,n+2):
  c[i]=c[i]+c[i-1]
ans=0
for i in range(n+2):
  if c[i]==m:
    ans+=1
print(ans)

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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	#ifndef ONLINE_JUDGE
	//	freopen("input.txt","r",stdin);
	#endif
	int a,n;
	cin>>a>>n;
	int b=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		b+=x;
	}
	cout << (b>=a?"Yes" : "No") << '\n';
}

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

using namespace std;

int main()
{
    int a,b;
    cin>>a>>b;
    if(a<0&&b>0||a==0||b==0)
        cout<<"Zero"<<endl;
    else if(a>0&&b>0||a<0&&b<0&&(b-a+1)%2==0)
        cout<<"Positive"<<endl;
    else if(a<0&&b<0||(b-a+1)%2==1)
        cout<<"Negative"<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int a,b,c;
    //char ch[5];
    //scanf("%s",ch);
    scanf("%d %d",&a, &b);
    c = a % 500;
    if(b>=c) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

namespace ConsoleApp1
{
    static class BROTN
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var s = Console.ReadLine();
            var charA = 'A';
            var charZ = 'Z';

            var sChars = s.ToCharArray();

            string answer = "";

            foreach (var sChar in sChars)
            {
                int newChar = sChar + n <= charZ ? sChar + n : charA + (sChar + n - charZ - 1);
                answer += ((char)newChar).ToString();
            }

            Console.WriteLine(answer);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 34772
import itertools

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ref = list(itertools.combinations(L, 3))
cnt = 0
for i in ref:
  Li = i[0]
  Lj = i[1]
  Lk = i[2]
  if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
    if Li != Lj and  Lj!= Lk and Lk != Li:
      cnt += 1

print(cnt)

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

int main()
{
    int n;
    int i, ans = 0;
    
    cin >> n;
    
    int l[n], r[n];
    
    for(i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        
        ans = ans + (r[i] - l[i] + 1);
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

int N,m;
int c[1010];
int d[1010];
bool flg[1010];

int main(){
    int N;
    while(cin>>N){
        cin >> m;
        memset(flg,0,sizeof(flg));
        rep(i,m){
            int a,b; cin >> a >> b;
            loop(i,a,b) flg[i] = true;
        }
        int ans = N+1;
        rep(i,N+1) ans += 2*flg[i];
        cout << ans << endl;
    }
}

Measured memory_bytes: 1168
#include<cstdio>
#include<algorithm>
struct Energy
{
  long long a, b;
  bool operator<(const Energy& o) const {
    return a < o.a;
  }
};

Energy e[100000];

int main()
{
  long long n, m;
  scanf("%lld%lld", &n, &m);
  for (int i=0; i<n; i++) {
  	scanf("%lld%lld", &e[i].a, &e[i].b);
  }
  std::sort(e, e + n);
  long long ans = 0;
  for (int i=0; i<n; i++) {
    if (m > e[i].b) {
      m -= e[i].b;
      ans += e[i].a * e[i].b;
    } else {
      ans += e[i].a * m;
      break;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1664
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aa = readInts()
    val bb = (0..n).map {
        Math.abs(when(it) {
            0 -> aa[it]
            n -> aa[it - 1]
            else -> aa[it] - aa[it - 1]
        })
    }
    val bsum = bb.sum()
    repeat(n) {
        val t = Math.abs(when(it) {
            0 -> aa[it + 1]
            n - 1 -> aa[it - 1]
            else -> aa[it + 1] - aa[it - 1]
        })
        println(bsum - bb[it] - bb[it + 1] + t)
    }
}


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

using namespace std;
typedef long long ll;

const int N = int(1e8) + 7;

void init(){

}

void solve(){
    char c;
    scanf("%c", &c);
    if(c == 'A') printf("T\n");
    if(c == 'T') printf("A\n");
    if(c == 'G') printf("C\n");
    if(c == 'C') printf("G\n");
}

const bool mtc = false;

int main(){
    int t;
    if(mtc){
        scanf("%d", &t);
        while(t--) solve();
    }
    else solve();
}


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

#define fi first
#define se second

int main() {
	int N;

	while(cin >> N, N) {
		vector<pair<int,int> > t;
		for(int i = 0; i < N; i++) {
			int x, y;
			cin >> x >> y;
			t.push_back(pair<int,int>(x,y));
		}

		int M;
		cin >> M;
		pair<int,int> rob(10,10);

		for(int i = 0; i < M; i++) {
			char dir;
			int amo;

			cin >> dir >> amo;

			for(int j = 0; j < amo; j++) {
				switch(dir) {
					case 'E':
						rob.fi++;
						break;
					case 'W':
						rob.fi--;
						break;
					case 'N':
						rob.se++;
						break;
					case 'S':
						rob.se--;
						break;
				}

				for(int j = 0; j < t.size(); j++) {
					if(rob == t[j]) {
						t.erase(t.begin() + j);
					}
				}
			}
		}

		if(t.size())
			cout << "No" << endl;
		else
			cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include<stdio.h>

static const int MAX = 100;
static const int INFTY = 2000;

int main(){
  int n, i, j, e, sum, y=0;
  int M[MAX][MAX];
  int u, v;
  int minv;
  int d[MAX];
  int p[MAX];
  int vis[MAX];

  scanf("%d", &n);
  
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
          M[i][j] = 0;
    }
  }

  for ( i = 0; i< n; i++ ){
      y++;
    for ( j = 0; j < n; j++ ){
      scanf("%d", &e);
      if(e == -1){
          M[i][j] = INFTY;
      } else {
          M[i][j] = e;
      }
    }
  }

  for ( i = 0; i < n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    vis[i] = 0;
  }
  
  d[0] = 0;

  while(1){
    minv = INFTY;
    u = -1;
    for ( i = 0; i < n; i++ ){
      if ( minv > d[i] && !vis[i] ){
	u = i;
	minv = d[i];
      }
    }
    if ( u == -1 ) break;
    vis[u] = 1;
    for ( v = 0; v < n; v++ ){
      if ( !vis[v] && M[u][v] != INFTY ){
	if ( d[v] > M[u][v] ){
	  d[v] =  M[u][v];
	  p[v] = u;
	}
      }
    }
  }

  sum = 0;

  for ( i = 0; i < n; i++ ){
    if ( p[i] != -1 ) sum += M[i][p[i]];
  }

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

  return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()
#define all(x) x.bg,x.ed
#define rall(x) x.rbg,x.red
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

int main(){
    cout << fixed << setprecision(20);
    int n,k; cin >> n >> k;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    int ans = 1e9;
    rep(i,n-k+1){
        int l = a[i], r = a[i+k-1];
        chmin(ans, min(abs(l)+abs(r-l), abs(r)+abs(l-r)));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

int main(){
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++){
        cout<<s[s.size()-i];
    }
    cout<<s[0];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3140
package main

import (
	"fmt"
	"math"
	"strings"
)

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	var (
		N int
		S string
	)
	fmt.Scan(&N, &S)

	x, d := 0, 0
	for i := 0; i < N; i++ {
		if S[i] == '(' {
			d++
		} else {
			d--
		}
		x = intMin(x, d)
	}

	ans := strings.Repeat("(", -x) + S + strings.Repeat(")", d-x)
	fmt.Println(ans)
}


Measured memory_bytes: 1844
//
//  main.cpp
//  ThreeColor
//
//  Created by Mihozil on 4/26/19.
//  Copyright © 2019 Mihozil. All rights reserved.
//

#include <iostream>
using namespace std;
typedef long long ll;
#define maxD 998244353
ll n;
ll a[301];
ll c[301][90001],cc[301][90001];

void solve() {
    ll allCase = 1;
    for (int i=1;i<=n; i++) {
        allCase = (allCase*3)%maxD;
    }
    
    ll total = a[1];
    c[1][a[1]] = 1;
    c[1][0] = 2;

    for (ll i=2; i<=n; i++) {
        total += a[i];
        for (ll j = 0; j<=total; j++) {
            c[i][j] = (c[i-1][j]*2)%maxD;
            if (j>=a[i])
                c[i][j] = (c[i][j] + c[i-1][j-a[i]])%maxD;
        }
    }
    
    ll subtract = 0;
    ll begin = total/2+1;
    for (ll j=begin; j<=total; j++)
        subtract = (subtract + c[n][j])%maxD;
    
    ll result = (allCase-(subtract*3)%maxD)%maxD;
    
    if (total%2==0) {
            total = a[1];
            cc[1][a[1]] = 1;
            cc[1][0] = 1;
            for (ll i=2; i<=n; i++) {
                total+=a[i];
                for (ll j=0; j<=total; j++) {
                    cc[i][j] = cc[i-1][j];
                    if (j>=a[i]) {
                        cc[i][j] = (cc[i][j] + cc[i-1][j-a[i]])%maxD;
                    }

                }
            }
            ll more = (c[n][total/2]*3)%maxD - (cc[n][total/2]*3)%maxD;
            more = more%maxD;
            result = (result - more)%maxD;
        }

    
    if (result<0)
        result+=maxD;
    
    cout<<result;
    
}

void read() {
    cin>>n;
    for (ll i=1; i<=n; i++)
        cin>>a[i];
    solve();
}

int main(int argc, const char * argv[]) {
    // insert code here...
//#if DEBUG
//    freopen("/Users/mihozil/Desktop/CodeJam/input.in", "r", stdin);
//#endif
    read();
    return 0;
}


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

int main() {
string s;
cin >> s;
bool flag = true;
  int x,y;
rep(i,s.size()){
  if(s.at(i) == 'A' && flag){
    x = i;
    flag = false;
  }
  else if(s.at(i) == 'Z') {
    y = i;
  }
}
int ans = y-x+1;
cout << ans << endl;
}


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

int to_i(string s){
	int res=0;
	for(int i=0;i<s.size();i++){
		res*=10;
		res+=s[i]-'0';
	}
	return res;
}
string to_b(int n,int d){
	string s;
	for(int i=0;i<d;i++){
		s+=((n>>d-i-1)&1)+'0';
	}
	return s;
}

int main(){
	string s;
	while(cin>>s&&s[0]!='-'){
		bool ok=true;
		int p=s.find('.',0);
		if(p==string::npos){
			p=s.size()+1;
			s+=".0000";
		}
		else p++;
		if(p+4>s.size()){
			s.append(p+4-s.size(),'0');
		}
		int n=to_i(s.substr(0,p-1));
		if((n&((1<<8)-1)) !=n )ok=false;
		int b=0;
		if(ok){
			int m=to_i(s.substr(p,s.size() ));
			int a=5000;
			for(int i=0;i<4;i++){
				if(a<=m){
					m-=a;
					b|=1<<3-i;
				}
				a/=2;
			}
			if(m)ok=false;
		}
		if(ok)cout<<to_b(n,8)<<'.'<<to_b(b,4)<<endl;
		else cout<<"NA\n";
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		ll n, a, b;
		cin >> n;
		ll X[n], Y[n];
		for (int i = 0; i < n; i++) {
			cin >> a >> b;
			X[i] = a + b;
			Y[i] = a - b;
		}
		sort(X, X + n);
		sort(Y, Y + n);
		cout << max(X[n - 1] - X[0], Y[n - 1] - Y[0]) << "\n";
	}
	return 0;
}

Measured memory_bytes: 6820
n, m = map(int, input().split())
ks = []
for i in range(m):
    ks.append(list(map(int, input().split())))
p = list(map(int, input().split()))
ans = 0
for i in range(1<<n):   #全部分集合について
    all_flug = True
    for j in range(m):  #全電球(パターン)について
        cnt = 0
        for k in range(n):   #全スイッチについて
            # print(bin(i), k+1, ks[j][1:], (i & (1<<k)) and (k+1 in ks[j][1:]))
            if (i & (1<<k)) and (k+1 in ks[j][1:]):   #スイッチがオンかつ電球に繋がってる
                cnt += 1
        # print(bin(i), cnt, p[j])
        # print(bin(i), cnt, p[j], cnt % 2 == p[j])
        if cnt % 2 != p[j]:
            all_flug = False
            # break
    # print(bin(i), all_flug)
    if all_flug:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100100100100100100;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    ll N;
    string S;
    ll K;
    cin >> N >> S >> K;
    rep(i,N){
        if(S[i] != S[K-1]) S[i] = '*';
    }
    cout << S << endl;
}


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

const int D = 80 * 160 + 10;
const int D2 = D * 2;

typedef bitset<D2> bs;
bs dp[90][90];

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

  vector<vector<int>> diff(h, vector<int> (w));
  rep(i, h) rep(j, w) cin >> diff[i][j];
  rep(i, h) rep(j, w) {
    int x;
    cin >> x;
    diff[i][j] -= x;
    diff[i][j] = abs(diff[i][j]);
  }

  dp[0][0][D + diff[0][0]] = 1;
  dp[0][0][D - diff[0][0]] = 1;

  rep(i,h) rep(j,w) {
    if(i > 0) {
      dp[i][j] |= dp[i - 1][j] << diff[i][j];
      dp[i][j] |= dp[i - 1][j] >> diff[i][j];
    }
    if(j > 0) {
      dp[i][j] |= dp[i][j - 1] << diff[i][j];
      dp[i][j] |= dp[i][j - 1] >> diff[i][j];
    }
  }

  int ans = D2;
  for (int i = 0; i < D2; i++) {
    if(dp[h - 1][w - 1][i]) {
      ans = min(ans, abs(D - i));
    }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 24032
import itertools

n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

r = min(a, b, c, d, e)

if r >= n:
    print(5)
else:
    loss = n // r

    if n % r != 0:
        loss += 1
        
    print(loss + 4)

Measured memory_bytes: 3064
#include <stdio.h>
using namespace std;

int N;
int C[501],S[501],F[501];
int ans[501] = {0};

int solve(int i,int tm=0){
	if(i == N-1){
		return tm;
	}
	if(tm < S[i]){
		tm = S[i] + C[i];
	}
	else{
		if(tm % F[i] == 0){
			tm += C[i];
		}
		else{
			tm += (F[i] - (tm % F[i])) + C[i];
		}
	}
	return solve(i+1,tm);
}

int main(){
	scanf("%d",&N);
	for(int i = 0; i < N-1; i++){
		scanf("%d%d%d",&C[i],&S[i],&F[i]);
	}
	for(int i = 0; i < N-1; i++){
		ans[i] = solve(i);
	}
	for(int i = 0; i < N; i++){
		printf("%d\n",ans[i]);
	}

	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Move {
		int fx, fy, gx, gy;
		
		public Move(int fx, int fy, int gx, int gy) {
			this.fx = fx;
			this.fy = fy;
			this.gx = gx;
			this.gy = gy;
		}
		
		public String toString() {
			return this.fy + " " + this.fx + " " + this.gy + " " + this.gx;
		}
	}
	
	public static int[][] move_dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	public static boolean in_range(int x, int y, int W, int H) {
		return 0 <= x && x < W && 0 <= y && y < H;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int D = sc.nextInt() - 22;
			
			if(D == 0) {
				System.out.println("Christmas Eve Eve Eve");
			}else if(D == 1) {
				System.out.println("Christmas Eve Eve");
			}else if(D == 2) {
				System.out.println("Christmas Eve");
			}else {
				System.out.println("Christmas");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 20564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n,A[100000],Ans=0;
	cin>>n;
	for(ll i=0;i<2*n;i++) cin>>A[i];
	sort(A,A+2*n);
	for(ll i=0;i<2*n;i+=2)
	Ans+=A[i];
	cout<<Ans<<endl;

	return 0;
}

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

int main()
{
	string s, t;
	cin>>s>>t;
	string p;
	while(p.size()<s.size()+t.size())
		p+=t;
	int n=p.size();
	vector<int> mp(n+1, -1);
	int j=-1;
	for(int i=0;i<n;i++)
	{
		while(j>=0 && p[i] != p[j])
			j=mp[j];
		mp[i+1]=++j;
	}
	string u;
	while(u.size()<s.size()+t.size()*2)
		u+=s;
	int cur=0, mx=0;
	for(char c : u)
	{
		while(cur==n || (cur>=0 && p[cur] != c))
			cur=mp[cur];
		++cur;
		mx=max(mx, cur);
	}
	int ans;
	if(mx>=(int)(s.size()+t.size()))
		ans=-1;
	else
		ans=mx / t.size();
	cout<<ans<<endl;
}


Measured memory_bytes: 11592
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
int main(){
    int m,d,n,f;
    cin >>m >> d >> n >>f;
    if(m!=n){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt();
		
		long event[] = new long[N];
		
		for(int i = 0; i<N; i++) event[i] = readInt();
		
//		if(event[N-1] != 2) {println(-1); exit();}		
		
		long low = 2, high = 2;
		for(int i = N-1; i>=0; i--) {
			if(low/event[i] == high/event[i] && (low%event[i] != 0 && high%event[i] != 0)) {println(-1); exit();}
//			if(event[i] > high) {println(-1); exit();}
			
			low = (long) Math.ceil(low/(1.0*event[i]))*event[i];
//			high = 2*event[i]-1;
			high = (long) Math.floor(high/(1.0*event[i]))*event[i]+event[i]-1;	
//			System.out.println(high);
		}
		
		println(low + " " + high);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(Object o) {
		pr.print(o);
	}

	static void println(Object o) {
		pr.println(o);
	}

	static void flush() {
		pr.flush();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 39932
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a;
	cin >> n >> a;
	if (n % 500 <= a)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <algorithm>

#ifndef DUAL_SEGMENT_TREE_HPP
#define DUAL_SEGMENT_TREE_HPP

#include <vector>
#include <cstdint>

//===
template<class Monoid>
struct DualSegmentTree {
    using T = typename Monoid::value_type;
    std::vector<T> lazy;

    DualSegmentTree() = default;
    explicit DualSegmentTree(uint32_t n):
        lazy(n << 1, Monoid::identity()) {};

    inline int size() {
        return (int)(lazy.size() >> 1);
    };
    
    inline void propagate(uint32_t k) {
        if (k >= size()) return;
        lazy[(k << 1) | 0] = Monoid::operation(lazy[(k << 1) | 0], lazy[k]);
        lazy[(k << 1) | 1] = Monoid::operation(lazy[(k << 1) | 1], lazy[k]);
        lazy[k] = Monoid::identity();
    };
    inline void push_down(uint32_t k) {
        for (uint32_t i = 31; i > 0; i--) propagate(k >> i);
    };
 
    // [l, r)
    void update(uint32_t l, uint32_t r, T op) {
        l += size();
        r += size();
        push_down(l);
        push_down(r - 1);
         
        while (l < r) {
            if (l & 1) lazy[l] = Monoid::operation(lazy[l], op), l++;
            if (r & 1) --r, lazy[r] = Monoid::operation(lazy[r], op);
 
            l >>= 1;
            r >>= 1;
        }
    };
 
    T operator [] (uint32_t k) {
        k += size();
        push_down(k);
        return lazy[k];
    };
};
//===
#endif

using namespace std;
using llong = long long;

llong n, k;
llong a[200005];
llong imos[200005];

struct Operator {
    using value_type = llong;
    inline static llong identity() {
        return 0;
    };
    inline static llong operation(llong a, llong b) {
        return a + b;
    };
};

bool check() {
    for (int i = 0; i < n; i++) {
        if (a[i] < n) return false;
    }
    return true;
}

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

    for (int j = 0; j < k; j++) {
        if (check()) {
            break;
        }

        DualSegmentTree<Operator> seg(n);

        for (int i = 0; i < n; i++) {
            seg.update(max(0ll, i - a[i]), min(n, i + a[i] + 1), 1);
        }

        for (int i = 0; i < n; i++) {
            a[i] = seg[i];
        }
    }

    for (int i = 0; i < n; i++) {
        cout << a[i] << ' ';
    }
}

Measured memory_bytes: 8248
#include <bits/stdc++.h>
#define int long long
using namespace std;

inline int read(){
    int s=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    return s*w;
}

inline bool read(int& a){
    int s=0,w=1;
    char ch=getchar();
    if(ch==EOF){
		return false;
	}
    while(ch<'0'||ch>'9'){
        if(ch=='-')w=-1;ch=getchar();
    }
    while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
    a=s*w;
    return true;
}

inline void write(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}

inline void writeln(int x){
    if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
    puts("");
}

int a[100010],b[100010];
int fa[100010];
int vis[100010];

int fat(int x){
	if(x==fa[x])
		return x;
		
	return fa[x]=fat(fa[x]);
}

void merge(int x,int y){
	int p=fat(x),q=fat(y);
	if(p!=q)
		fa[p]=q;
}

signed main(){
	int n=read(),m=read();
	
	for(int i=1;i<=n;i++)
		fa[i]=i;
	
	for(int i=1;i<=m;i++){
		a[i]=read();
		b[i]=read();
		merge(a[i],b[i]);
		vis[a[i]]=vis[b[i]]=1;
	}
	
	int ans=0;
	
	for(int i=1;i<=n;i++){
		if(fa[i]==i)
			ans++;
	}
	
	writeln(ans-1);
	return 0;
}

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
//#define int long long  
int main(){
    int a,b,h;
    cin >> a >> b >> h;
    
    cout << (a+b)*h/2 << endl;
	return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
	let mut flag = false;
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	let h:u64 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	let n:u32 = match iter.next().unwrap().parse() {
		Ok(n) => n,
		Err(_) => panic!(""),
	};
	
	let mut sum:u64 = 0;
	
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let mut iter = buf.split_whitespace();
	
	for n in 0..n {
		let a: u64 = match iter.next().unwrap().parse() {
			Ok(n) => n,
			Err(_) => panic!(""),
		};
		sum = sum + a;
		if sum >= h {
			flag = true;
			break;
		}
	}
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

void solve() {
  string s[3];
  REP(i,3) cin >> s[i];
  int p = 0;
  for (;;) {
    if (s[p].empty()) {
      cout << char(p + 'A') << endl;
      return;
    }
    int q = s[p].front() - 'a';
    s[p] = s[p].substr(1);
    p = q;
  }
  return;
}


Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unused")
public class Main {

  private static void solve() {
    int n = ni();

    int mod = (int)1e9 + 7;

    long total = 1;
    for (int i = 0; i < n; i ++) {
      total *= 10;
      total %= mod;
    }
    long minus = 1;
    long minus2 = 1;
    for (int i = 0; i < n; i ++) {
      minus *= 9;
      minus2 *= 8;
      minus %= mod;
      minus2 %= mod;
    }
    total = (total - minus + mod) % mod;
    total = (total - minus + mod) % mod;
    total = (total + minus2) % mod;

    System.out.println(total);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36832
using System;

namespace ALDS1_1_D
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var r = new long[n];
            for (int i = 0; i < n; i++)
            {
                r[i] = long.Parse(Console.ReadLine());
            }

            long maxValue = long.MinValue;
            long minValue = r[0];

            for(int i = 1; i < n; i++)
            {
                maxValue = Math.Max(maxValue, r[i] - minValue);
                minValue = Math.Min(minValue, r[i]);
            }

            Console.WriteLine(maxValue);
        }
    }
}



Measured memory_bytes: 12920
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;


int main() {
    int  a,b;
    cin >>a;
    if (a / 10 == 9 || a % 10 == 9)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
  int K;
  string S;
  cin >> K;
  cin >> S;
  vector<string> T(K);
  if( int(S.size()) <= K){
    cout << S << endl;
  }
  else{
    rep(i,K){
      cout << S.at(i);
    }
    cout <<"..."<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner in=new Scanner(System.in);
        int a= in.nextInt();
        int b= in.nextInt();
        if (((a+b)%2)==0){
            System.out.println((a+b)/2);
        }
        else {
            System.out.println("IMPOSSIBLE");
        }
    }
}


Measured memory_bytes: 35900
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <limits.h>
typedef long long ll;
using namespace std;
int n;
int main(int argc,char const* argv[])
{
  cin >> n;
  int zerotimes=0,onetimes=0,moretimes=0;
  vector<ll> a(n,0);
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  for(int i=0;i<n;i++)
    {
      if(a[i] % 2 ==0 && a[i] % 4 !=0) onetimes++;
      else if(a[i] % 4 ==0) moretimes++;
      else zerotimes++;
    }
  if(onetimes==0)
    {
      if(zerotimes<=(moretimes+1))
	{
	  cout << "Yes" << endl;
	  return 0;
	}
      else 
	{
	  cout << "No" << endl;
	  return 0;
	}
    }
  else
    {
      if(zerotimes<=(moretimes))
	{
	  cout << "Yes" << endl;
	  return 0;
	}
      else 
	{
	  cout << "No" << endl;
	  return 0;
	}
    }

  return 0;
}


Measured memory_bytes: 1024
N = int(input())

already_list=[]
w=0
for i in range(N):
    W = input()
    if W not in already_list:
        if w==0 or w[-1]==W[0]:
            already_list.append(W)
            w=W

if len(already_list) == N:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
MOD = 1_000_000_007
N, M = gets.split.map(&:to_i)
dp = Array.new(N + 10, 0)
dp[0] = 1
M.times.map{gets.to_i}.each do |h|
  dp[h] = -1
end
(1 .. N).each do |h|
  dp[h] = dp[h] < 0 ? 0 : (dp[h-1] + dp[h-2]) % MOD
end
puts dp[N]


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

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

    int x[N], y[N], h[N];
    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i] >> h[i];
    }

    for (int cx = 0; cx <= 100; ++cx) {
        for (int cy = 0; cy <= 100; ++cy) {
            int ch = 0;
            for (int i = 0; i < N; ++i) {
                if (h[i] > 0) {
                    ch = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                    break;
                }
            }

            bool judge = true;
            for (int i = 0; i < N; ++i) {
                int preh = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
                if (h[i] == 0 && ch > preh) {
                    judge = false;
                } else if (h[i] > 0 && ch != preh) {
                    judge = false;
                }
            }

            if (judge) {
                cout << cx << " " << cy << " " << ch << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N;
	char s[100];
	scanf("%d",&N);
	scanf("%s",s);
	
	int redcount=0;
	int i=0;
	
	while(s[i]!='\0')
	{
		if(s[i]=='R')
		{
			redcount++;
		}
		i++;
	}
	
	if(redcount>i/2)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
	int left;
	int right;
};

Node T[500000];
int root = -1;

void printInOrder(int i) {
	if (i == -1) {
		return;
	}
	printInOrder(T[i].left);
	printf(" %d", i);
	printInOrder(T[i].right);
}

void printPreOrder(int i) {
	if (i == -1) {
		return;
	}
	printf(" %d", i);
	printPreOrder(T[i].left);
	printPreOrder(T[i].right);
}

void insert(int i) {
	T[i].left = T[i].right = -1;

	if (root == -1) {
		root = i;
		return;
	}

	int y;
	int x = root;
	while (x != -1) {
		y = x;
		if (i < x) {
			x = T[x].left;
		}
		else {
			x = T[x].right;
		}
	}
	if (i < y) {
		T[y].left = i;
	}
	else {
		T[y].right = i;
	}
}

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

	char s[19];
	for (int i = 0; i < m; i++) {
		scanf("%s", s);

		if (s[0] == 'i') {
			scanf("%s", s);
			insert(atoi(s));
		}
		else {
			printInOrder(root);
			printf("\n");
			printPreOrder(root);
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 4936
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]
    INF = 10 ** 9

    def dfs(cursor, a, b, c):
        if cursor == N:
            return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF

        no_compound_pattern = dfs(cursor+1, a, b, c)
        compound_a_pattern = dfs(cursor+1, a + l[cursor], b, c) + 10
        compound_b_pattern = dfs(cursor+1, a, b + l[cursor], c) + 10
        compound_c_pattern = dfs(cursor+1, a, b, c + l[cursor]) + 10

        return min(no_compound_pattern, compound_a_pattern, compound_b_pattern, compound_c_pattern)

    print(dfs(0, 0, 0, 0))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, h, m float64
	fmt.Scan(&a, &b, &h, &m)

	c := a*a + b*b - 2*a*b*math.Cos((math.Pi/6.0)*h-(math.Pi/30.0)*m+(math.Pi/360.0)*m)
	fmt.Println(math.Sqrt(c))
}


Measured memory_bytes: 1820
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

int main(){
    // READ
    string pat;
    getline(cin,pat);

    vector<string> y;
    string tttt;
    while(getline(cin,tttt)){
        y.pb(tttt);
    }
    int n = y.size();

    // SOLVE
    map<string,string> m;
    vector<string> property(n);
    vector<int> indent(n);
    rep(i,n){
        int ct = 0;
        while(y[i][ct]==' ') ++ct;
        indent[i] = ct;

        string t = y[i].substr(ct);
        int cl = 0;
        while(t[cl]!=':') ++cl;

        string p = t.substr(0,cl);
        string parent = "";
        if(ct>0){
            int par = i;
            while(par>=0 && indent[i]<=indent[par]) --par;
            assert(par>=0);
            parent = property[par];
        }
        property[i] = parent+"."+p;

        // object
        if(cl != t.size()-1){
            string name = t.substr(cl+2);
            m[property[i]] = ("string \"" + name + "\"");
        }
        else m[property[i]] = "object";
    }

    string ans = "no such property";
    if(m.count(pat)) ans = m[pat];
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3528