akhauriyash/Code-Regression huggingface dataset:
T,F = True,False
while 1:
    s = raw_input()
    if s == "#": break
    for i in xrange(100): s = s.replace("--","")
    for b,a in zip(["=","->","-","*","+"],[") == ("," != 1 or "," not "," and "," or "]):
        s = s.replace(b,a)
    s = "("+s+")"
    for v in xrange(2**11):
        a,b,c,d,e,f,g,h,i,j,k = map(int,list(format(v,"b").zfill(11)))
        if not eval(s):
            print "NO"
            break
    else:
        print "YES"

Measured memory_bytes: 4288
a, b, c, d, e, f = map(int, input().split())

ans = [100 * a, 0]
for sg in range(f + 1):
    exist = False
    for kc in range(sg // c + 1):
        if (sg - kc * c) % d == 0 and 0 <= (sg - kc * c) // d:
            exist = True
    if not exist:
        continue
    for sw in range(sg, f + 1, 100):
        exist = False
        for ka in range((sw - sg) // 100 * a + 1):
            kb = (sw - sg - 100 * ka * a) // (100 * b)
            if (sw - sg - 100 * ka * a) % (100 * b) == 0 and 0 <= (sw - sg - 100 * ka * a) // (100 * b):
                exist = True
        if not exist:
            continue
        if (100 + e) * sg <= sw * e and ans[1] * sw < ans[0] * sg:
            ans = [sw, sg]

print(' '.join(map(str, ans)))

Measured memory_bytes: 43868
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200005;
const int K = 50;
set < int > g[N];
int f[N], d[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
   // freopen("input.txt", "r", stdin);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++){
        int u, v;
        cin >> u >> v;
        g[u].insert(v);
        g[v].insert(u);
        d[u]++;
        d[v]++;
    }
    for (int i = 1; i <= n; i++){
        if (d[i] % 2){
            cout << "No";
            return 0;
        }
    }
    for (int i = 1; i <= n; i++){
        if (d[i] >= 6){
            cout << "Yes";
            return 0;
        }
    }
    set < int > s;
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        if (d[i] == 2){
            s.insert(i);
        }
        if (d[i] == 4){
            cnt++;
            f[i] = 1;
        }
    }
    if (cnt <= 1){
        cout << "No";
        return 0;
    }
    if (cnt >= 3){
        cout << "Yes";
        return 0;
    }
    while(!s.empty()){
        auto v = *s.begin();
        s.erase(s.begin());
        auto it = g[v].begin();
        if (g[v].size() == 1 && f[v] == 0){
            cout << "Yes";
            return 0;
        }
        auto v1 = *it;
        it++;
        auto v2 = *it;
        g[v1].erase(v);
        g[v1].insert(v2);
        g[v2].erase(v);
        g[v2].insert(v1);
        while (!g[v].empty()) g[v].erase(g[v].begin());
        if (g[v2].size() == 2 && f[v2] == 0) s.insert(v2);
        if (g[v1].size() == 2 && f[v1] == 0) s.insert(v1);
    }
   // cout << g[3].size() << " " << g[6].size() << endl;
    for (int i = 1; i <= n; i++){
        if (g[i].size() != 4 && g[i].size() != 0 && g[i].size() != 1){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


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

int main()
{
string s;
cin >>s;
ll index=0;
string a="";
string pre="";
while(index!=s.size()){
  ans++;
  a+=s[index];
  index++;
  if(index==s.size()){if(pre.size()==1&&pre[0]==a[0]){ans--;break;}}
  if(a==pre){a+=s[index];index++;}
  pre=a;
  a="";
}

cout << ans << endl;
return 0;
}


Measured memory_bytes: 640
//This template belongs to Juan Carlo Vieri
#include <bits/stdc++.h>
using namespace std;

typedef int_fast64_t ll;
typedef long double ld;
typedef int_fast32_t intt;
typedef int_fast32_t tmp_m;
#define deb(x) cout << #x << ' ' << x << endl
#define rep(i, cmp1, cmp2) for (tmp_m i = cmp1; i < cmp2; ++i)
#define repp(i, cmp1, cmp2) for (tmp_m i = cmp1; i >= cmp2; --i)
#define pb push_back
#define st stack
#define pa pair
#define vc vector
#define qu queue
#define pq priority_queue
#define fr first
#define sc second
#define mp map
const ld pi = acos(-1.0);
const intt mod = 1e9 + 7;

struct pr {
  intt x;
  intt y;
  intt dst;
  pr() {}
  pr(intt x, intt y, intt dst) : x(x), y(y), dst(dst) {}
  inline bool operator<(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst < cmp2.dst;
    if (x != cmp2.x) return x < cmp2.x;
    return y < cmp2.y;
  }
  inline bool operator==(const pr& cmp2) const {
    return (cmp2.dst == dst) && (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const pr& cmp2) const {
    if (dst != cmp2.dst) return dst > cmp2.dst;
    if (x != cmp2.x) return x > cmp2.x;
    return y > cmp2.y;
  }
};

struct point {
  intt x;
  intt y;
  point() {}
  point(intt x, intt y) : x(x), y(y) {}
  inline bool operator<(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x < x;
    return cmp2.y < y;
  }
  inline bool operator==(const point& cmp2) const {
    return (cmp2.x == x) && (cmp2.y == y);
  }
  inline bool operator>(const point& cmp2) const {
    if (cmp2.x != x) return cmp2.x > x;
    return cmp2.y > y;
  }
};

class prHash {
 public:
  size_t operator()(const pr& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y)) ^
           (hash<intt>()(cmp1.dst));
  }
};

class pointHash {
 public:
  size_t operator()(const point& cmp1) const {
    return (hash<intt>()(cmp1.x)) ^ (hash<intt>()(cmp1.y));
  }
};

inline bool spoint(const point& cmp1, const point& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

inline bool spr(const pr& cmp1, const pr& cmp2) {
  // swap(cmp1, cmp2);
  if (cmp1.dst != cmp2.dst) return cmp1.dst < cmp2.dst;
  if (cmp1.x != cmp2.x) return cmp1.x < cmp2.x;
  return cmp1.y < cmp2.y;
}

void solve() {
  string s, t;
  cin >> s >> t;
  rep(i, 0, (intt)s.length()){
    if(s[i] != t[i]){
      puts("No");
      return;
    }
  }
  puts("Yes");
}


void init() {
  // remove if interactive
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  srand(time(0));
  // memset(dp, -1, sizeof dp);
}

int main() {
  init();
  solve();
  return 0;
}


Measured memory_bytes: 3644
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

#include<unistd.h>
struct Buffer{
    enum { chunk = 1 << 16 };
    int idx;
    char buf[chunk];
    Buffer(){ init(); }
    void init(){ idx = 0; read(0, buf, chunk); }
    void check(){ if(idx == chunk){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};
struct FastInput {
    Buffer buf;
    template <class T>
    FastInput& operator >> (T& num) { num = buf.next(); return *this; }
    void tie(int){ }
    template <class S, class T>
    friend FastInput& operator >> (FastInput& in, pair<S, T>& p){ return in >> p.first >> p.second; }
    template <class T>
    friend FastInput& operator >> (FastInput& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
};
FastInput fin;
#define cin fin

int accs[500][500];
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    // vector<vector<int>> accs(n, vector<int>(n));
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        l--; r--;
        for(int i = 0; i <= l; i++){
            accs[i][r]++;
        }
    }
    for(int i = 0; i < n; i++){
        for(int j = 1; j < n; j++){
            accs[i][j] += accs[i][j - 1];
        }
    }
    for(int i = 0; i < q; i++){
        int p, q;
        cin >> p >> q;
        p--; q--;
        cout << accs[p][q] << '\n';
    }
}


Measured memory_bytes: 1920
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

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

    cout << min({A + B, B + C, C + A}) << endl;
    return 0;
}


Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return table

def solve(Q: int, l: "List[int]", r: "List[int]"):
    primes = sieve(10**5)
    hash_table = {}

    for prime in primes:
        hash_table[prime] = True
    
    like_number_list = []
    for prime in primes:
        if hash_table.get((prime+1)/2) == True:
            like_number_list.append(prime)
    
    ## i以下の最大の2017likenumberの個数
    ruiseki_like_number = [0]*(10**5+1)
    for like in like_number_list:
        ruiseki_like_number[like] += 1

    from itertools import accumulate
    ruiseki_like_number = list(accumulate(ruiseki_like_number))

    for i in range(Q):
        left = ruiseki_like_number[l[i]-1]
        right = ruiseki_like_number[r[i]]
        print(right-left)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    Q = int(next(tokens))  # type: int
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(Q, l, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 16312
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;

bool answer[100001];
int wrongs[100001];

int main() {

	int N, M;
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int target;
		string result;
		cin >> target;
		cin >> result;
		if (result == "AC") {
			answer[target] = true;
		}
		else if(answer[target]==false) {
			wrongs[target] += 1;
		}

	}

	int total_ans = 0;
	int total_wrongs = 0;
	for (int i = 0; i < 100001; i++) {
		if (answer[i] == true) total_ans += 1;
		if (answer[i] == true) total_wrongs += wrongs[i];
	}

	cout << total_ans << " " << total_wrongs << endl;

	return 0;
}



Measured memory_bytes: 768
#include<stdio.h>
#include<math.h>

int main(void)
{
  int N ,M ,C,i,k;
  int b[20],a[20][20],c[20];
  scanf("%d %d %d",&N,&M,&C);
  
  
  for(i=0;i<M;i++)
  {
    scanf("%d",&b[i]);
  }
  
  for(i=0;i<N;i++)
  {
    c[i]=0;
    for(k=0;k<M;k++)
    {
      scanf("%d",&a[i][k]);
      c[i]=c[i]+(b[k]*(a[i][k]));
    }
  }
  k=0;
    for(i=0;i<N;i++)
    {
      if(c[i]+C>0)
      {
        k++;
      }
    }
    
    printf("%d",k);
    
    return 0;
  }

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	nextReader = NewScanner()
	a := nextInt()
	b := nextInt()
	c := nextInt()
	x := nextInt()

	var count int
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				if i*500+j*100+k*50 == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)

}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

var nextReader func() string

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


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

using namespace std;

int main(void){
	int h,w,cnt[26],q=0,p=0,i,j;
	char a;
	cin >> h >> w;
	fill(cnt,cnt+26,0);
	for(i=0; i<h; i++){
		for(j=0; j<w; j++){
			cin >> a;
			cnt[a-'a']++;
		}
	}
	for(i=0; i<26; i++){
		q += cnt[i]/4;
		p += cnt[i]/2;
	}
	i = (h/2)*(w/2);
	j = (h/2)+(w/2);
	if(h%2==0 && w%2==0){
		 if(q<i){
		 	cout << "No" << endl;
		 }else{
		 	cout << "Yes" << endl;
		 }
	}else if(h%2==1 && w%2==1){
		if(q>=i && (p-i*2)>=j){
		 	cout << "Yes" << endl;
		}else{
		 	cout << "No" << endl;
		}
	}else{
		if(h%2==0){
			swap(h,w);
		}
		if(q>=i && (p-i*2)>=(w/2)){
		 	cout << "Yes" << endl;
		}else{
		 	cout << "No" << endl;
		}
	}
	return 0;
}

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

long long getvalue (long long x){
	if(x<=L) return x + 1;
	else return L - x%(L+1);
}

int main(void){
	int n;
	int tcase = 0;
	while(cin>>n){
		tcase ++;
		long long cnt=0;
		
		
		for ( int i = 0; i <= 2*L; i++ ){
      int t = n - i;
			if( 0 <= t && t <= 2*L){

				cnt += getvalue(i) * getvalue(t);
			}
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        static void Main(string[] args)
        {
            SolveA(args);
            //SolveB(args);
            //SolveC(args);
            //SolveD(args);


        }
        private struct GoHomeRoute
        {
            public int c;
            public int t;
        }
        private const long MOD = 1000000007;
        static void SolveA(string[] args)
        {
            var NT = ReadAndParseIntArr();
            int n = NT[0];
            int t = NT[1];

            var routeList = new List<GoHomeRoute>();
            for(int i=0;i<n;++i)
            {
                var ct = ReadAndParseIntArr();
                var route = new GoHomeRoute()
                {
                    c = ct[0],
                    t = ct[1]
                };
                routeList.Add(route);
            }
            routeList.Sort((a, b) => a.c.CompareTo(b.c));
            int minCost = int.MaxValue;
            foreach(GoHomeRoute route in routeList)
            {
                if( route.t <= t)
                {
                    minCost = route.c;
                    break;
                }
            }
            if( minCost != int.MaxValue)
            {
                Console.WriteLine(minCost);
            }
            else
            {
                Console.WriteLine("TLE");
            }
        }
       
    }
}

Measured memory_bytes: 13512
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n;
    cin >> n;
    ll k = 2;
    map<ll, ll> primeCounts;
    while (true)
    {
        if (n == 1)
        {
            break;
        }
        if (k >= 1000000)
        {
            k = n;
        }
        if (n % k == 0)
        {
            ++primeCounts[k];
            n /= k;
        }
        else
        {
            ++k;
        }
    }
    ll result = 0;
    for (const auto &[prime, count] : primeCounts)
    {
        ll y = 0;
        ll count2 = count;
        for (ll x = 1; count2 >= x; ++x)
        {
            count2 -= x;
            ++y;
        }
        result += y;
    }
    cout << result << endl;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

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

struct xor_basis {
public:
    ll basis[64] = {};
    inline void add (ll x) {
        for (int bit = 63; bit >= 0; bit--) {
            if ((x & (1ll << bit)) == 0) continue;
            if (!basis[bit]) {
                basis[bit] = x;
                return;
            }
            x ^= basis[bit];
        }
    }
    inline bool check (ll x) {
        for (int bit = 63; bit >= 0; bit--) {
            if ((x & (1ll << bit)) == 0) continue;
            if (!basis[bit]) return false;
            x ^= basis[bit];
        }
        return true;
    }
};

inline void solve () {
    int n;
    cin >> n;
    vector <ll> a(n);
    string s;
    for (auto &i : a) cin >> i;
    cin >> s;
    xor_basis b;
    for (int i = n - 1; i >= 0; i--) {
        if (s[i] == '0') {
            b.add(a[i]);
        }
        else {
            if (!b.check(a[i])) {
                cout << "1\n";
                return;
            }
        }
    }
    cout << "0\n";
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve ();
    }
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;

  int s;
  s=N%1000;

  if (s==0)cout<< 0 << endl;
  else {
    int k;
    k=1000-s;
    cout << k << endl;
  }
  return 0;
}


Measured memory_bytes: 3592
// bismillah
// author : anaksoleh
// 14 Dec 2019
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    long long S;
    cin >> N >> S;
    vector<long long> x(N);
    vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        cin >> x[i] >> p[i];
    }
    vector<long long> route;
    int i = 0 , j = N - 1;
    while(true)
    {
        if(x[i] > S){
            route.push_back(x[j]);
            break;
        }
        if(x[j] < S){
            route.push_back(x[i]);
            break;
        }
        if(p[i] >= p[j]){
           p[i] += p[j];
           route.push_back(x[j]);
           j--;
        }else{
            p[j] += p[i];
            route.push_back(x[i]);
            i++;
        }
    }
    long long ans = 0;
    for(int i = route.size()-1 ; i >= 0 ; i--){
        ans += abs(S - route[i]);
        S = route[i];
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 2936
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}

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

int a[2010];
bitset<4000010> dp[2];
signed main(void)
{
  int n;
  cin >> n;
  int su = 0;
  REP(i, n) cin >> a[i], su += a[i];

  int cur = 0, nxt = 1;
  dp[0].set(0);
  REP(i, n) {
    // dp[i] → dp[i+1] への遷移
    // a[i]回右シフトをする
    dp[nxt] = dp[cur] | (dp[cur] << a[i]);
    dp[cur] = dp[nxt];
  }
  // dp[n] でビットが立っている sum/2 以上の最小
  FOR(i, su/2 + !!(su%2), su+1) {
    if(dp[nxt][i]) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

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

  string ans;

  if (b < 0) {
    if ((a - b - 1) % 2 == 0) ans = "Positive";
    else ans = "Negative";
  } else if (a <= 0 && 0 <= b) ans = "Zero";
  else ans = "Positive";

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto N = readln.split[0].to!int;
	bool[string] S;
	foreach (i; 0 .. N) {
	    S[readln.split[0]] = true;
	}
	writeln(S.keys.length);
}



Measured memory_bytes: 35844
#include<stdio.h>
int main()
{
  int D;
  scanf("%d",&D);
  if(D>=22 && D<=25)
  {
    if(D==25)
      printf("Christmas");
    else if(D==24)
      printf("Christmas Eve");
    else if(D==23)
      printf("Christmas Eve Eve");
    else
      printf("Christmas Eve Eve Eve");
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using ll=long long;
using namespace std;
int main(){
  ll n;
cin>>n;
  string res;
  while(1){
  res+=(char)('a'+((n-1)%26));//aから、(n-1)%26個分シフト
  n=(n-1)/26;//n-1を26で割った商を代入する
  if(n==0) break;//割った商が0ならbreak
  }
  reverse(res.begin(),res.end());//最初と最後を逆転させる
  cout<<res<<endl;
}


Measured memory_bytes: 3596
S=input()

if S == "SUN":
  print(7)
elif S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
elif S == "FRI":
  print(2)
else:
  print(1)

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

int main()
{
  long long int n, k;
  cin >> n >> k;
  vector<long long int> dp(n), input(n);
  for (int i = 0; i < n; i++)
  {
    cin >> input[i];
    dp[i] = 1e18;
  }

  dp[0] = 0;
  long long int j;
  for (long long int i = 1; i < n; i++)
  {
    j = 1;
    while(i - j >= 0)
    {
      dp[i] = min(dp[i], dp[i - j] + abs(input[i] - input[i - j]));
      j++;
      if (j > k)
        break;
    }
  }
  cout << dp[n - 1];
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


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

  int a, b, c;

  cin >> a >> b >> c;

  if (a == b && b == c) {
      cout << "Yes" << endl;
  } else {
      cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll x,k,d;
    cin >> x >> k >> d;
    x = abs(x);
    ll n = min(k,x/d);
    k -= n;
    x -= n*d;
    if(k%2) cout << min(abs(x+d),abs(x-d)) << endl;
    else cout << x << endl;
    return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root,NIL;
int max;

void insert(int k){
  int H;
  Node y=NIL;
  Node x=root;
  Node z;

  z =malloc(sizeof(struct node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x=x->right;
    }
  }

  z->parent = y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }else{
      y->right=z;
    }
  }
  
}

void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n,i,t;
  char com[20];
  scanf("%d",&n);
  max=0;
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&t);
      insert(t);
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




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

using namespace std;



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    if(floor(ceil(n/1.08)*1.08)==n) cout<<ceil(n/1.08);
    else cout<<":(";

}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
 int a,b,c=0,i,j;
 scanf("%d %d",&a,&b);
 for(i=1;i<=a;i++){
  for(j=1;j<=31;j++){
   if(j==i){
    c++;
   }
   if(i==a&&j==b){
     printf("%d\n",c);
     return 0;
   }
  }
 }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int MOD = 1000000007;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

const int MAX = 1000005;

int x, y;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main() {

    cin >> x >> y;

    if(x*2 < y || y*2 < x || (x+y)%3 != 0) {
        cout << 0 << endl;
        return 0;
    }

    COMinit();

    cout << COM((x+y)/3,(x+y)/3*2-x) << endl;
    
    
    return 0;
}



Measured memory_bytes: 23680
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int []h = new int [n];
		
		for(int i = 0; i < n ; i++) {
			h[i] = sc.nextInt();
		}
		int count = 1;
		int max = h[0];
		
		for(int j = 1; j < n ; j++) {
			if(h[j] >= max) {
				max = h[j];
				count++;
			}
			
		}
		System.out.println(count);
			
		

	}

}


Measured memory_bytes: 25044
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  priority_queue< u64, vector< u64 >, greater< u64 > > a;
  for (int i = 0; i < n; ++i) {
    u64 ai;
    cin >> ai;
    a.push(ai);
  }
  u64 weakest = a.top();
  a.pop();
  int cnt = 1;
  while (!a.empty()) {
    u64 next = a.top();
    a.pop();
    if (weakest * 2 < next) {
      cnt = 1;
    } else {
      cnt++;
    }
    weakest += next;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1400
def q4():
    N, K = [int(i) for i in input().split(" ")]
    A = [-1] + [int(i) for i in input().split(" ")]

    arrived = []
    arrived_set = set()
    current = 1
    loop_start_station = -1
    while True:
        arrived.append(current)
        arrived_set.add(current)
        current = A[current]
        if current in arrived_set:
            loop_start_station = arrived.index(current)
            break

    if K <= loop_start_station:
        print(arrived[K])
        return
    K = K - loop_start_station
    arrived = arrived[loop_start_station:]
    K = K % len(arrived)
    print(arrived[K])
        

q4()


Measured memory_bytes: 32428
#include<bits/stdc++.h>
using namespace std;
#define forN(n, N) for(int n=0; n<N; n++)
#define res_out(ans) cout << ans << "\n";
#define ll long long

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    double K, mul_2, ans = 0, div = 0, div_p = 0, p_n = 0;
    cin >> N >> K;
    for(int n=1; n<N+1; n++){
        div = K / n;
        if(div <= 1)p_n = 1;
        else if(div != div_p){
            mul_2 = log2(div);
            if(int(mul_2) == mul_2)p_n = pow(0.5, int(mul_2));
            else p_n = pow(0.5, int(mul_2) + 1);
        }
        ans += p_n;
        div_p = div;
        //if(n <10)cout << n << " " << div << " " << p_n << "\n";
    }
    //ans /= N;
    cout << setprecision(11) << ans / N << "\n";
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

main :: IO ()
main = do
    n <- read <$> getLine
    s <- replicateM n getLine
    m <- read <$> getLine
    t <- replicateM m getLine
    putStrLn $ show $ solve s t


solve :: [String] -> [String] -> Int
solve s t = max 0 $ maximum [match w s - match w t | w <- s]
    where match ws li = length $ elemIndices ws li

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

int main() {
  int n;
  string s1;
  string s2;
  cin >> n >> s1 >> s2;
  vector<int> data;
  REP(i, n) {
    if (s1[i] == s2[i]) {
      data.push_back(0);
    } else {
      data.push_back(1);
      i++;
    }
  }
  ll ans = 1;
  REP(i, data.size()) {
    if (i == 0) {
      if (data[i] == 0) {
        ans *= 3;
      } else {
        ans *= 6;
      }
    } else {
      if (data[i - 1] == 0) {
        ans *= 2;
        ans %= MOD;
      } else {
        if (data[i] == 0) {
          ans *= 1;
          ans %= MOD;
        } else {
          ans *= 3;
          ans %= MOD;
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3556
#include <iostream>

using namespace std;

bool palindromic(int a) {
    int tmp = a, rev = 0, rt;

    while (tmp != 0) {
        rt = tmp % 10;
        rev *= 10;
        rev += rt;
        tmp /= 10;
    }

    return a == rev;
}

int main(void) {
    int A, B, sum = 0;

    cin >> A >> B;

    for (int i = A; i <= B; i++) {
        if (palindromic(i)) {
            sum++;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		while (true) {
		    int n = sc.nextInt();
		    if (n == 0) {
		        break;
		    }
		    int[] arr = new int[n];
		    for (int i = 0; i < n; i++) {
		        arr[i] = sc.nextInt();
		    }
		    Arrays.sort(arr);
		    int min = Integer.MAX_VALUE;
		    for (int i = 1; i < n; i++) {
		        min = Math.min(min, arr[i] - arr[i - 1]);
		    }
	        sb.append(min).append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 46388
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1'000'000'007;
long long A,B,x,y,z,w;
long long sumx,sumy;
int main(){
    cin>>A>>B;
    cin>>z;
    for(int i=1;i<A;i++){
        cin>>x;
        sumx += (x - z) * (A - i) % MOD * i;
        sumx %= MOD;
        z = x;
    }
    cin>>w;
    for(int j=1;j<B;j++){
        cin>>y;
        sumy += (y - w) * (B- j) % MOD * j;
        sumy %= MOD;
        w = y;
    }
    cout<<sumx * sumy % MOD<<endl;

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back

int f(int n) {
    if(n == 0) return 1;
    else
        return f(n-1) + n;
}

int main() {
    int n;
    while(cin >> n) {
        cout << f(n) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double[] a = new double[n];
		int[] b = new int[n];
		double[] c = new double[n];
		
		Arrays.setAll(a, i -> sc.nextInt());
		Arrays.setAll(b, i -> sc.nextInt());
		Arrays.setAll(c, i -> sc.nextInt());
		
		Arrays.sort(a);
		Arrays.sort(b);
		Arrays.sort(c);
		
		long ans = 0;
		for (int i = 0; i < n; i++) {
			int idxA = ~Arrays.binarySearch(a, b[i] - 0.1);
			if (idxA < 0) continue;
			long numA = idxA;
			
			int idxC = ~Arrays.binarySearch(c, b[i] + 0.1);
			if (idxC < 0) continue;
			long numC = n - idxC;
			
			ans += numA * numC;
		}
		
		System.out.println(ans);
		
		sc.close();
	}
}


Measured memory_bytes: 98884
#include<stdio.h>

int main(){
    int i =1;
    int x;    

    for(;;i++)
    {
        scanf("%d",&x);
        
        if(x == 0){
            break;
        }
        printf("Case %d: %d\n",i,x);
    }
    
    
    return 0;
}


Measured memory_bytes: 1924
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
 
map<int,int> a;
int f[100005];
 
int main(){
	int n,i,s=0,t;
	
	cin>>n;
	
	for(i=1;i<=n;i++){
		cin>>f[i];
		a[f[i]]=a[f[i]]+1;
	}
	
	for(i=1;i<=n;i++){
		if(a[f[i]]<f[i])s+=a[f[i]];
		if(a[f[i]]>f[i])s+=a[f[i]]-f[i];
		a[f[i]]=0;
	}
	
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

bool pairCompare(pair<int,int> firstelem, pair<int,int> secondelem) {
	return firstelem.first < secondelem.first;
}

int main() {
	long long int N,K;
	cin >> N >> K;
	
	int a,b;
	pair<int,int> arr[N];
	for (int i = 0; i < N; ++i) {
		cin >> a >> b;
		arr[i] = make_pair(a,b);
	}
	
	sort(arr, arr+N,pairCompare);
	for (int i = 0; i < N; ++i) {
		if (K > arr[i].second) {
			K -= arr[i].second;
		} else {
			cout << arr[i].first;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1024
<?php
fscanf(STDIN, "%d", $a);
fscanf(STDIN, "%d", $b);
fscanf(STDIN, "%d", $c);
fscanf(STDIN, "%d", $x);

$ans = 0;
$ma = min($a, floor($x / 500));
for ($i = 0; $i <= $ma; $i++) {
	$ra = $x - $i * 500;
	$mb = min($b, floor($ra / 100));
	for ($j = 0; $j <= $mb; $j++) {
		$rb = $ra - $j * 100;
		if ($rb / 50 <= $c) $ans++;
	}
}
echo $ans;

Measured memory_bytes: 4728
import java.util.*;
public class Main {
    public static void main(String[] args){
        Main start=new Main();
        start.start();

    }
    public Main(){
    }
    public void start(){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int R = sc.nextInt();
        int G = sc.nextInt();
        int B = sc.nextInt();
        int N = sc.nextInt();
        int result=0;
        for(int i=0;i<=N/R;i++){
            for(int j=0;j<=(N-i*R)/G;j++){
                if((N-i*R-j*G)%B==0){
                    result++;
                }
            }
        }
        System.out.println(result);

    }
    int gcd (int a, int b) {
        int temp;
        while((temp = a%b)!=0) {
            a = b;
            b = temp;
        }
        return b;
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N, M;
  cin >> N >> M;
  vector<int> ans(N);
  bool memo = true;
  if (N == 1 && M == 0) {
    cout << 0 << endl;
    memo = false;
  }
  if (N == 1 && M == 1) {
    int a, b;
    cin >> a >> b;
    if (a == 1 && b == 0) {
      cout << 0 << endl;
      memo = false;
    }
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (b == 0) {
      ans.at(a - 1) = 100;
    }
    else if (ans.at(a - 1) == 0) {
      ans.at(a - 1) = b;
    }
    else if (b != ans.at(a - 1)) {
      cout << "-1" << endl;
      memo = false;
      break;
    }
  }
  if (ans.at(0) == 0) {
    ans.at(0) = 1;
  }
  for (int i = 0; i < N; i++) {  
    if (ans.at(i) == 100) {
      ans.at(i) = 0;
    }
  }
  if (memo == true && ans.at(0) == 0) {
    cout << "-1" << endl;
    memo == false;
  }
  else if (memo == true) {
    for (int i = 0; i < N; i++) {
    cout << ans.at(i); 
    }
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;

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

int main()
{
    int d;
    cin >> d;
    for (int data = 0; data < d; data++) {
        int a, b;
        cin >> a >> b;
        if (a < b) {
            for (int i = a; i < b; i++) {
                cout << i << " ";
            }
            cout << b << endl;
        } else if (a >= 6) {
            for (int i = a; i < 10; i++) {
                cout << i << " ";
            }
            if (b <= 5) {
                for (int i = 5; i > b; i--) {
                    cout << i << " ";
                }
                cout << b << endl;
            } else {
                for (int i = 5; i >= 0; i--) {
                    cout << i << " ";
                }
                for (int i = 1; i < b; i++) {
                    cout << i << " ";
                }
                cout << b << endl;
            }
        } else {
            for (int i = a; i > b; i--) {
                cout << i << " ";
            }
            cout << b << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<LINE<<")"<<endl;
#define vdeb(x) {cout<<#x<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<" (L"<<LINE<<")"<<endl;}
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vivi = vector<vi>;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    ll pos;
    ll res;
    if (K <= A) {
        pos = 0;
    }
    else if (A < K and K <= A+B) {
        pos = 1;
    }
    else if (A+B <= K) {
        pos = 2;
    }
    if (pos == 0) {
        res = 1*K;
    }
    if (pos == 1) {
        res = A;
    }
    if (pos == 2) {
        res = A - (K-A-B);
    }
    cout << res << endl;
}

Measured memory_bytes: 3608
#include<iostream>

using namespace std;

int main(){

  int W,H,x,y,r;

  cin>>W>>H>>x>>y>>r;

  if(x+r>W||y+r>H||x-r<0||y-r<0){

    cout<<"No"<<endl;
  }


 
  else{

    cout<<"Yes"<<endl;
  }


  return 0;
}

Measured memory_bytes: 3072
N=int(input())
INF=10**9
dp=[INF]*(N+1)#dp[i] 足場i+1にいるときの最小コスト
dp[0]=0
list=[1]
i=1
while(6**i<=N):
    list.append(6**i)
    i+=1
i=1
while(9**i<=N):
    list.append(9**i)
    i+=1
for i in range(N+1):
    for k in list:
        if i+k<=N:
            dp[i+k]=min(dp[i+k],1+dp[i])
print(dp[N])


Measured memory_bytes: 42204
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define maxn 100005
#define maxm 100005
#define eps 1e-6
typedef long long ll;
using namespace std; 
const ll mod = 1e9 + 7;
inline int read(){
	int x = 0, f = 1;char ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
	return x * f;
}

int n ;
ll x, sum ,ans;
int main(){
	int i, j;
	n = read();
	for(i = 1;i <=n;i++){
		x = read();
		ans = (ans +sum *x%mod)%mod;
		sum=(sum + x)%mod;
	}
	cout<<ans;
}
//

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

using ll = long long;

#define int ll

void max_self(ll& a,ll b)
{
	a = max(a,b);
}

int32_t main()
{
	int n,W;
	scanf("%lld%lld",&n,&W);
	vector<ll> dp(W+1);
	for(int item=0;item<n;item++)
	{
		int weight,value;
		scanf("%lld%lld",&weight,&value);
		for(int weight_already = W-weight;weight_already>=0;weight_already--)
		{
			max_self(dp[weight_already + weight],dp[weight_already] + value);
		}
	}
	ll answer = 0;
	for(int i=0;i<=W;i++)
	{
		max_self(answer,dp[i]);
	}
	printf("%lld\n",answer);
	return 0;
}


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

int func(int x){
    if(x % 2==0) return x/2;
    else return 3*x + 1;
}

int main(void){
    // Your code here!
    vector<int> V(1000000);
    long n = 1;
    cin >> V[0];
    while(1){
        
        V[n] = func(V[n-1]);
        
        for(long i=n-1;i>=0;i--){
            //cout<<V[i]<<":"<<V[n]<<endl;
            if(V[i] == V[n]){
                cout<<n+1;
                return 0;
            }
        }
        n++ ;
    }
    
    return 0;
}


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

using namespace std;

int main() {
    double n, k;
    cin >> n >> k;
    double prob = 0;
    for (int i = 1; i <= n; i++) {
        int score = i;
        int p = 0;
        while (score < k) {
            p++;
            score *= 2;
        }
        prob += (1.0 / n) * pow(0.5, p);
    }
    printf("%.12f", prob);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 10000000000000000


int main() {
	
	int K;
	cin>>K;
	
	long long ans = 0;
	
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int k=1;k<=K;k++){
				
				for(int x=min({i,j,k});true;x--){
					if(i%x==0&&j%x==0&&k%x==0){
						ans+=x;
						break;
					}
				}
				
			}
		}
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void) {
	int i,am,pm,money,h;
	char cname[20];
	for (i = 1;i <= 9; i++){
		scanf("%s%d%d",cname,&am,&pm);
		money = am * 200 + pm * 300;
		h = am + pm;
		printf("%s %d %d\n",cname,h,money);
	}
	return 0;
}
//aoj 0173

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 0;
int h, w;
char arr[55][55];

int row[]={0, 1, 0, -1};
int col[]={1, 0, -1, 0};

int main(){
	IOS
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> arr[i][j];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(arr[i][j]=='#'){
				bool bener=0;
				int baris, kolom;
				for(int k=0;k<4;k++){
					baris=i+row[k];
					kolom=j+col[k];
					if(arr[baris][kolom]=='#'){
						bener=1;
						break;	
					}
				}
				if(!bener){
					cout << "No" << '\n';
					return 0;
				}
			}
		}
	}
	cout << "Yes" << '\n';
}


Measured memory_bytes: 3612