akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

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

	int h, w;
	cin >> h >> w;

	vector<string> field(1, string(w + 1, '.'));
	field.reserve(h + 2);

	for(int i = 0; i < h; ++i) {
		string line;
		cin >> line;
		field.emplace_back(line + '.');
	}

	field.emplace_back(string(w + 1, '.'));

	typedef pair<double, bool> event; // arg, inc
	vector<event> events;

	const int oy = h;

	for(int i = 1; i < h + 2; ++i) {
		for(int j = 0; j < w; ++j) {
			if(field[i][j] == field[i - 1][j + 1]) {
				if(field[i][j] == field[i][j + 1] && field[i][j] != field[i - 1][j]) { // inc
					events.emplace_back(atan2(oy - (i - 1), j + 1), true);
				}
				else if(field[i][j] != field[i][j + 1] && field[i][j] == field[i - 1][j]) { // dec
					events.emplace_back(atan2(oy - (i - 1), j + 1), false);
				}
			}
		}
	}

	sort(events.begin(), events.end());

	int ans = 1;
	int cnt = 1;

	for(const auto &e : events) {
		if(e.second) {
			chmax(ans, ++cnt);
		}
		else {
			--cnt;
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 3948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll N; cin >> N;
    vector<int> v(N); for (int i = 0; i < N; ++i) cin >> v[i];
    sort(v.begin(), v.end());
    ll sum = 0;
    for (int i = 0; i < N - 1; ++i) sum += v[i];
    if (sum > v[N - 1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <limits.h>

int count;
const int infty = INT_MAX;

void merge(int* a, int left, int mid, int right)
{
    int n1,n2,i,j,k;
    
    n1 = mid - left;
    n2 = right - mid;
    
    int l[n1 + 1],r[n2 + 1];
    
    for(i = 0;i < n1;i++) {
        l[i] = a[left + i];
    }
    for(i = 0;i < n2;i++) {
        r[i] = a[mid + i];
    }
    l[n1] = infty;
    r[n2] = infty;
    i = 0;
    j = 0;
    for(k = left;k < right;k++) {
        if(l[i] <= r[j]) {
            a[k] = l[i];
            i++;
        }
        else {
            a[k] = r[j];
            j++;
        }
        count++;
    }
}

void mergeSort(int* a, int left, int right)
{
    int mid;

    if(left + 1 < right) { //比較対象が２以外の場合に下記を実行
        mid = (left + right) / 2;
        mergeSort(a, left, mid);
        mergeSort(a, mid, right);
        merge(a, left, mid, right);
    }
/*
    for(i = 0;i < right;i++) {
        printf("%ld",a[i]);
        if(i != right - 1) {
            printf(" ");
        }
    }
*/
}

int main(void)
{
    int i,right;
    int a[500000];
    
    scanf("%d",&right);
    for(i = 0 ; i < right ; i++) {
        scanf("%d",&a[i]);
    }
  /*  
    if(right % 2 == 0) {
        left = right / 2;
    }
    else {
        left = (right - 1) / 2;
    }
    */
    mergeSort(a, 0, right);
    
    for(i = 0;i < right;i++) {
        printf("%d",a[i]);
        if(i != right - 1) {
            printf(" ");
        }
        else {
            printf("\n");
        }
    }
    printf("%d\n",count);
    
    return(0);
    
}


Measured memory_bytes: 6452
h, w, k = map(int, input().split())
c = list(input() for _ in range(h))
# print(c)

cnt = 0

for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '#'
        if black == k:
            cnt += 1

print(cnt)

Measured memory_bytes: 9140
h, n = map(int, input().split())
a = []
b = []
for i in range(n):
    ia, ib = map(int, input().split())
    a.append(ia)
    b.append(ib)

dp = [[0 for i in range(h)] for j in range(n)]

for i in range(n):
    for j in range(h):
        if i == 0:
            tmp = (j + 1) // a[i]
            if tmp != (j + 1) / a[i]:
                tmp += 1
            dp[i][j] = tmp * b[i]
        else:
            if j != 0:
                if j - a[i] < 0:
                    tmp = b[i]
                else:
                    tmp = dp[i][j - a[i]] + b[i]
                dp[i][j] = min(dp[i - 1][j], tmp)
            else:
                tmp = (j + 1) // a[i]
                if tmp != (j + 1) / a[i]:
                    tmp += 1
                dp[i][j] = min(dp[i - 1][j], tmp * b[i])

print(dp[-1][-1])

Measured memory_bytes: 125788
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e6+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

int main() {//ikarus_101

    ll n,m,i,j,k,x;

    cin>>k;
    queue<ll>a;
    rep1(i,9) a.push(i);

    vll v;
    while(v.size() <= k)
    {
        x = a.front();
        a.pop();
        v.eb(x);
        i = x%10;
        if(i>0) a.push(x * 10 + i-1);
        a.push(x * 10 + i);
        if(i<9) a.push(x*10 + i + 1);
    }

    sajo(v);
    cout << v[k-1] << endl;


    return 0;
}


Measured memory_bytes: 5696
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli K[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    lli n;
    cin >> n;
    cout << K[n - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
int main(){
    int h,a;
    cin>>h>>a;
    int ans;
    if (h%a!=0) ans = h/a +1 ;
    else ans = h/a;
    cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
int lcm(int x, int y) { return x*y / gcd(x, y); }

int p, q, a, n;
using T = tuple<int, int, int, int, int>;
int f(int x, int y, int z, int c, int a_) {
	if (c == n - 1 && x != 1)return 0;
	if (c == n)return 0;
	if (x*z > (n - c)*y)return 0;
	int ret = 0;
	rep(i, z, a + 1) {
		if (i*a_ > a)
			break;
		if (x*i > y) {
			int nx = x*i - y, ny = y*i;
			int g = gcd(nx, ny);
			nx /= g;
			ny /= g;
			ret += f(nx, ny, i, c + 1, i*a_);
		}
		else if (x*i == y) {
			ret += 1;
		}
	}
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	for (; cin >> p >> q >> a >> n&&p;) {
		cout << f(p, q, 1, 0, 1) << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split();
            var n = int.Parse(input[0]);
            var limit = int.Parse(input[1]);
            var total = 0;
            var queue = new Queue<Process>(100000);

            for(var i = 0; i < n; i++){
                input = Console.ReadLine().Split();
                var p = new Process(input[0], int.Parse(input[1]));
                queue.enqueue(p);
            }

            while(!queue.isEmpty())
            {
                var p = queue.dequeue();
                if(p.time - limit > 0){
                    p.time -= limit;
                    queue.enqueue(p);
                    total += limit;
                }else{
                    total += p.time;
                    Console.WriteLine($"{p.name} {total}");
                }
            }
        }
    }

    struct Process
    {
        public string name;
        public int time;
        public Process(string name, int time)
        {
            this.name = name;
            this.time = time;
        }
    }

    class Queue<T>
    {
        private T[] _buf;
        private int _head;
        private int _tail;

        public Queue(int num)
        {
            _buf = new T[num + 1];
            _head = 0;
            _tail = 0;
        }

        public void enqueue(T data)
        {
            if(isFull()){
                throw new IndexOutOfRangeException();
            }
            _buf[_head++] = data;
            if(_head >= _buf.Length){
                _head = 0;
            }
        }

        public T dequeue()
        {
            if(isEmpty()){
                throw new IndexOutOfRangeException();
            }
            var result = _buf[_tail++];
            if(_tail >= _buf.Length){
                _tail = 0;
            }

            return result;
        }

        public bool isEmpty()
        {
            return _head == _tail;
        }

        public bool isFull()
        {
            var head = _head + 1;
            if(head >= _buf.Length){
                head = 0;
            }

            return head == _tail;
        }
    }
}



Measured memory_bytes: 22888
n = int(input())

max_range = 10 ** 5
dp = [int(i) for i in range(max_range + 1)]

for i in [6,9]:
    check = i
    while check < max_range:
        for j in range(max_range + 1):
            if j - check >= 0:
                dp[j] = min(dp[j],dp[j-check] + 1)

        check =  check * i
        
print(dp[n])

Measured memory_bytes: 7064
import java.util.*;

class Main{
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    while(true) {
      int n = scan.nextInt();
      if(n==0) return;
      List<List<Path>> list = new ArrayList<>(10);
      for(int i = 0; i < 10; i++) {
        list.add(new ArrayList<Path>());
      }
      int maxTown = 0;
      for(int i = 0; i < n; i++) {
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        list.get(a).add(new Path(b,c));
        list.get(b).add(new Path(a,c));
        maxTown = Math.max(maxTown,Math.max(a,b));
      }
      int result = 99999999;
      int resultCount = 1;
      int result_index = 0;
      for(int start = 0; start < maxTown; start++) {
        int[] costs = new int[maxTown+1];
        for(int i = 0; i < maxTown+1; i++) {
          costs[i] = 99999999;
        }
        costs[start] = 0;
        boolean[] flags = new boolean[maxTown+1];
        flags[start] = true;
        calc(costs,flags,list,start,0);
        int _res = 0;
        for(int i = 0; i < maxTown+1; i++) {
          _res += costs[i];
        }
        if(_res==result) {
          resultCount++;
        }else if(_res < result) {
          result = _res;
          result_index = start;
          resultCount=1;
        }
        //System.out.println(Arrays.toString(costs));
        //System.out.println(resultCount+","+result+","+_res+","+result_index);
      }
      System.out.println(result_index+" "+result);
    }
  }
  static void calc(int[] costs, boolean[] flags, List<List<Path>> list, int start, int cost) {
    int minIndex = -1;
    int minCost = 1<<30;
    for(Path _p : list.get(start)) {
      costs[_p.to] = Math.min(costs[_p.to],cost+_p.cost);
    }
    for(int i = 0; i < costs.length; i++) {
      if(!flags[i] && costs[i]<minCost) {
        minIndex = i;
        minCost = costs[i];
      }
    }
    if(minIndex==-1) return;
    flags[minIndex] = true;
    calc(costs,flags,list,minIndex,minCost);
  }
}

class Town{
  int cost;
  int index;
  Town(int _cost, int _index) {
    cost = _cost;
    index = _index;
  }
}

class Path{
  int to;
  int cost;
  Path(int _to, int _cost) {
    to = _to;
    cost = _cost;
  }
}

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

/*
int64_t Lucas(int i){
  if (i == 0) return 2;
  if (i == 1) return 1;
  
  int64_t L;
  L = Lucas(i-1)+Lucas(i-2);
  
  return L;
}
*/

int main() {
  int N;
  cin >> N;
  int64_t L=0,L0=2,L1=1; 
  if(N>1){
    for(int i = 2; i<=N; i++){
      L = L0+L1;
      L0 = L1;
      L1 = L;
    }
  }else{
    L = L1;
  }
  //ans = Lucas(N);

  cout << L << endl;
}



Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int n=sc.nextInt();
		int ans=1;
		while(2*ans<n)ans++;
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 21204
"""
int(input())
map(int, input().split())
list(map(int, input().split()))
input()
input().split()
"""

s = input()
s2 = []
s2.append(s[0])
ans = 0
for i in range(1,len(s)):
    if len(s2) != 0:
        if (s[i] != s2[-1]):
            s2.pop()
            ans += 2
        else:
            s2.append(s[i])
    else:
        s2.append(s[i])
print(ans)

    

Measured memory_bytes: 9824
import sys
sys.setrecursionlimit(1000000)

def input(f):
    global v, e
    global s, t
    
    v, e = map(int, f.readline().split())
    s = [-1 for _ in range(e)]
    t = [-1 for _ in range(e)]
    for i in range(e):
        s[i], t[i] = map(int, f.readline().split())

def solve():
    g = [[] for _ in range(v)]
    for i in range(e):
        g[s[i]].append(t[i])
        g[t[i]].append(s[i])
    
    used = [False for _ in range(v)]
    ord = [-1 for _ in range(v)]
    low = [10**6 for _ in range(v)]
    res = []
    
    def rec(cur, prev, d):
        if used[cur]:
            return
        used[cur] = True
        ord[cur] = d
        low[cur] = ord[cur]
        
        cnt = 0
        for nxt in g[cur]:
            if not used[nxt]:
                cnt += 1
                rec(nxt, cur, d+1)
                low[cur] = min(low[cur], low[nxt])
                if prev >= 0 and ord[cur] < low[nxt]:
                    res.append((min(cur, nxt), max(cur, nxt)))
            elif nxt != prev:
                low[cur] = min(low[cur], ord[nxt])
        
        if prev == -1 and (cnt >= 2 or len(g[cur]) == 1):
            for nxt in g[cur]:
                res.append((min(cur, nxt), max(cur, nxt)))
    
    rec(0, -1, 0)
    
    for src, dst in sorted(res):
        print('{} {}'.format(src, dst))

with open('/dev/stdin') as f:
    input(f)
    solve()


Measured memory_bytes: 20312
/*In the name of ALLAH, Most Gracious, Most Merciful*/

#include<bits/stdc++.h>

#define ll                      long long int
#define ull                     unsigned long long int
#define PI                      2*acos(0.0)
#define sqr(x)                  (x)*(x)
#define EPS                     10E-10
#define MOD                     1000000007
#define longlimit               92233720368547758
#define infinity                (1<<28)
#define setbits                 __builtin_popcount
#define zerobits                __builtin_ctzll
#define pb(a)                   emplace_back(a)
#define mp                      make_pair
#define ff                      first
#define ss                      second
#define gcd(a, b)               __gcd(a,b)
#define lcm(a, b)               ((a)*(b))/gcd(a,b)
#define watch(x)                cout << (#x) << " is " << (x) << endl
#define FOR(x,n)                for (ll i=x,j=x,k=x;i<n,j<n,k<n;i++,j++,k++)
#define FORR(n,x)               for (ll i=n-1,j=n-1,k=n-1;i>=x,j>=x,k>=x;i--,j--,k--)
#define TEST_CASES()            ll t;cin>>t;while (t--)
#define PRECISION(a,x)          fixed<<setprecision(x)<<a<<endl;
#define all(a)                  (a.begin()),(a.end())
#define UNIQUE(X)               (X).erase(unique(all(X)),(X).end())
#define DELETE(X)               (X).erase (remove (all(X)),(X).end())
#define SORT_UNIQUE(c)          (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define FAST_IO()               ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define FILE_IO()               freopen("output.txt", "w", stdout);freopen("input.txt", "r", stdin)
using namespace std;
ll tc=1;


void solve()
{
    string a,b;
    cin>>a>>b;
    ll cnt=0;
    for (int i=0;a[i];i++)
    {
        if (a[i]!=b[i])cnt++;
    }
    cout<<cnt<<endl;
}

int32_t main()
{
    FAST_IO();
    //TEST_CASES()
        solve();
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N;
	vector<lpair> A;

	cin >> N;
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		A[i].second = i;
		cin >> A[i].first;
	}
	sort(ALL(A));

	for (int i = 0; i < N; ++i)
		cout << A[i].second + 1 << " ";
	cout << endl;

	return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
typedef long long LL;

LL s(int x, int b)
{
	int t = x / b;
	LL s = (LL)(t - 1) * (LL)t / 2 * (LL)b;
	s += (LL)(x % b + 1) * (LL)t;
	return s;
}

int main() 
{
	int i, n, k, b, y, x;
	LL ss = 0;
	
	scanf("%d%d", &n, &k);
	if(!k){
		printf("%lld\n", (LL)n * (LL)n);
		return 0;
	}
	for(i = k + 1, y = n - k, x = n - i; i <= n; i++, x--){
		ss += s(y, i) - s(x, i) + y - x;
	}
	printf("%lld\n", ss);
			
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;
typedef struct box{
	int val;
	vector<int> ul;
}box;
box boxes[1010];
const int MAXM=1e3+10;
const int INF=1e18;
int memo[MAXM][5000];
int n,m;
int dfs(int cur,int sta){
	if(sta==((1<<n)-1))return 0;
	if(cur==m)return INF;
	if(memo[cur][sta]!=-1)return memo[cur][sta];
	int nxsta=sta;
	for(int i=0;i<(int)boxes[cur].ul.size();i++){
		nxsta=nxsta|(1<<(boxes[cur].ul[i]-1));
	}
	memo[cur][sta]=min(dfs(cur+1,sta),boxes[cur].val+dfs(cur+1,nxsta));
	return memo[cur][sta];
}
int32_t main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;
		boxes[i].val=a;
		for(int j=0;j<b;j++){
			int v;cin>>v;
			boxes[i].ul.push_back(v);
		}
	}
	memset(memo,-1,sizeof(memo));
	int ans=dfs(0,0);
	if(ans==INF){
		cout<<-1<<endl;
	}else cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 39936
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T>inline int bs(int g,int k,T c){while(abs(k-g)>1){int m=(g+k)/2;(c(m)?k:g)=m;}return k;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}


int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;

    int ans = 0;
    string hand = "";
    for(int i = 0; i < n; ++i){
        if(i >= k and t[i] == hand[i-k]) {
            hand += "#";
            continue;
        }
        if(t[i] == 'r') {
            ans += p; 
            hand += "r";
        }
        if(t[i] == 's') {
            ans += r; 
            hand += "s";
        }
        if(t[i] == 'p') {
            ans += s; 
            hand += "p";
        }
    }

    cout << ans << '\n';
    return 0;
}


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



//文字列を入れ替える変数
string f_max(string);

string f_min(string);

//減算関数
string sum(string , string);



int main(void)
{
	//入力変数
	string str_input;

	while (true)
	{
		cin >> str_input;

		if (str_input == "0000")
		{
			break;
		}
		int count = 0;
		for (int i = 1; i < 4; i++)
		{
			if (str_input[0] == str_input[i])
			{
				count++;
			}
		}
		if (count == 3)
		{
			cout << "NA" << endl;
		}
		else
		{
			//出力変数
			int output = 0;
			while (str_input != "6174")
			{
				str_input = f_max(str_input);
				//min変数
				string min = f_min(str_input);

				str_input = sum(str_input , min);

				output++;
			}

			cout << output << endl;
		}
	}

	return 0;
}



//文字列を入れ替える変数
string f_max(string max)
{
	//配列に格納
	int h_hozon[4] = {0};
	for (int i = 0; i < 4; i++)
	{
		h_hozon[i] = max[i];
	}

	//ソート
	for (int i = 0; i < 3; i++)
	{
		for (int j = i + 1; j < 4; j++)
		{
			if (h_hozon[i] < h_hozon[j])
			{
				int tmp = h_hozon[i];
				h_hozon[i] = h_hozon[j];
				h_hozon[j] = tmp;
			}
		}
	}

	for (int i = 0; i < 4; i++)
	{
		max[i] = h_hozon[i];
	}

	return max;
}

string f_min(string min)
{
	string h_tmp = "0000";

	for (int i = 0; i < 4; i++)
	{
		h_tmp[3 - i] = min[i];
	}

	return h_tmp;
}



//減算関数
string sum(string max , string min)
{
	int int_max = 0;
	int int_min = 0;

	//掛け算変数
	int kakeru = 1000;

	for (int i = 0; i < 4; i++)
	{
		int_max += ((max[i] - '0') * kakeru);
		int_min += ((min[i] - '0') * kakeru);

		kakeru /= 10;
	}

	int_max -= int_min;

	int waru = 1000;

	for (int i = 0; i < 4; i++)
	{
		max[i] = (int_max / waru) + '0';
		int_max %= waru;

		waru /= 10;
	}

	return max;
	
}

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

int main(void){
    int n,a,b,c;
    scanf("%d",&n);
    a = n%10;
    b = n/10 - (n/100)*10;
    c = n/100;
    if(a == 7 || b == 7 || c == 7){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int64)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template<typename T,T MOD,T B>
struct RollingHash{
  using ll = long long;
  vector<T> hash,po;
  RollingHash(){}
  RollingHash(vector<T> vs){init(vs);}
  RollingHash(string &s){
    vector<T> vs;
    for(char c:s) vs.emplace_back(c);
    init(vs);
  }
  void init(vector<T> vs){
    int n=vs.size();
    hash.assign(n+1,0);
    po.assign(n+1,1);
    for(int i=0;i<n;i++){
      hash[i+1]=((ll)hash[i]*B+vs[i])%MOD;
      po[i+1]=(ll)po[i]*B%MOD;
    }
  }
  //S[l, r)
  T find(int l,int r){
    T res=(ll)hash[r]+MOD-(ll)hash[l]*po[r-l]%MOD;
    return res>=MOD?res-MOD:res;
  }
};

int main(void) {
  int64 N;
  string s, t;
  cin >> N >> s >> t;
  REP(i, N) {
    cout << s[i] << t[i];
  }
  cout << endl;
}


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

int main() {
	string s, t;
	cin >> s;
	cin >> t;

	int count = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3912
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    int k, n;
    cin >> k >> n;
    vector<int> as(n);
    for (int i = 0; i < n; ++i) {
        cin >> as[i];
    }
    int max_diff = 0;
    for (int i = 1; i < n; ++i) {
        max_diff = max(max_diff, as[i] - as[i - 1]);
    }
    max_diff = max(max_diff, k - as[n - 1] + as[0]);
    cout << k - max_diff << endl;
    return 0;
}


Measured memory_bytes: 1024
#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(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

template <class T>
void chmax(T &x, const T &y) {
    x = max(x, y);
}

bool dp[5010][10010]; // i桁の数がj本で作れる
int cost[] = {0,2,5,5,4,5,6,3,7,6};

int n, m;

string make(int dig, const vector<int> &a) {
    string ans;
    int rem = n;
    for (int d = dig; d >= 1; --d) {
        for (int x : a) {
            if (rem - cost[x] >= 0 && dp[d-1][rem - cost[x]]) {
                ans += x + '0';
                rem -= cost[x];
                break;
            }
        }
    }
    return ans;
}

int main() {
    while (cin >> n >> m) {
        vector<int> a(m);
        rep(i, m) cin >> a[i];
        sort(all(a));
        reverse(all(a));

        memset(dp, 0, sizeof dp);
        dp[0][0] = true;
        rep(i, 5001) {
            rep(j, n) {
                for (int x : a) {
                    dp[i+1][j+cost[x]] |= dp[i][j];
                }
            }
        }

        for (int i = 5000; i >= 0; --i) {
            if (dp[i][n]) {
                // dump(i);
                cout << make(i, a) << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
#define mod                   1000000007
#define ll                    long long
#define Author                std::ios_base::sync_with_stdio(0);
#define u_map                 unordered_map<ll,ll>
#define n_map                 map<ll,ll>
#define n_pair                pair<ll,ll>
#define all(v)                v.begin(),v.end()
#define frr(i,j,k)           for(int i=j; i<k; i++)
#define frp(i,j,k)           for(int i=j; i>=k; i--)
#define pb(a)                 push_back(a)
#define lb(v,t)               lower_bound(all(v),t)-v.begin()
#define ub(v,t)               upper_bound(all(v),t)-v.begin()
#define in(t)                 scanf("%lld",&t);
#define out(t)                printf("%lld\n",t);
#define inputarr(a,n)        for(int i=0;i<n;++i) cin>>a[i]
#define printarr(a,n)        for(int i=0;i<n;++i) cout<<a[i]<<" "
#define mem(a)              memset(a,0,sizeof(a))
#define int_max     INT_MAX64
ll abst(ll a){if(a<0)return -a; return a;}
ll power(ll a, ll b){ll res=1;while(b){if(b&1)res=res*a;a=a*a;b/=2;}return res;}
ll invmod(ll a){return power(a,mod-2);}
ll lcm(ll a, ll b){return a*b/__gcd(a,b);}
ll ncr(ll n, ll r){ll p=1;ll i;for(i=1; i<=r; i++){p*=(n-i+1);p*=i;}return p;}
ll ans=0;
int main(){
    ll n,k;
    cin>>n>>k;
    if(n==1){
        cout<<0;
        return 0;
    }
    ll h[n+1];
    frr(i,0,n)cin>>h[i];
    ll dp[n+1];
    mem(dp);
    dp[0]=0;
    for(int i=1;i<n;++i){
        dp[i]=INT_MAX;
        frr(j,1,k+1){
            if(j<=i)
            dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
        }
        //cout<<dp[i]<<" ";
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>
#include <cassert>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount

char ALPH[] = {'A','B','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

int main() {
    string s; cin>>s;
    if(s[0]!='A'){
        puts("WA");
        return 0;
    }
    for (int i = 1; i < sz(s); i++) {
        for (int j = 0; j < 25; j++) {
            if(s[i]==ALPH[j]){
                puts("WA");
                return 0;
            }
        }
    }

    int cnt=0;
    for (int i = 2; i < sz(s)-1; i++) {
        if(s[i]=='C')cnt++;
    }

    if(cnt==1)puts("AC");
    else puts("WA");
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int n;
 cin>>n;
 string s;
 while(n){
 s.push_back(n%10);
 n/=10;
}
int f=0;
for(int i=0;i<3;i++)
 if(s[0]==s[i]) f++;
if(f==3) cout<<"Yes"<<endl;
else {
    f=0;
    for(int i=1;i<4;i++)
     if(s[1]==s[i]) f++;
   if(f==3) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}
 
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int X, N, x, Y, M, y, i;
int main(){
  scanf("%d%d%d%d", &N, &M, &X, &Y);
  for(i=0; i<N; i++){
    scanf("%d",  &x);
    if(x>X){X=x;}
  }
  for(i=0; i<M; i++){
    scanf("%d",  &y);
    if(y<Y){Y=y;}
  }
  if(X<Y){
    printf("No War\n");
  }else{
    printf("War\n");
  }
}


Measured memory_bytes: 128
import math

x = int(input())

divisors = []

for i in range(1, int(x**0.5)+1):
    if x % i == 0:
        divisors.append(i)

        if i != x//i:
            divisors.append(x//i)


for i in divisors:
    for a in range(i//2,x,1):
        b = a - i
        if a**5 - b**5 == x:
            print(a, b)
            break
        elif a**5 - b**5 > x:
            break


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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

		// ????????????????????\???
		String first_lines = input.readLine();

		// ??\??????????????°??????1??¢??????6??¢?????§??????????????????????????§?????????????????????
		Dice_third insdice = new Dice_third(first_lines.split(" "));

		// 2???????????????????????\???
		String second_lines = input.readLine();

		String[] another_dice_array = second_lines.split(" ");

		int[] another_dice_num = new int[6];

		for (int array_spot = 0; array_spot < another_dice_array.length; array_spot++) {

			another_dice_num[array_spot] = Integer.parseInt(another_dice_array[array_spot]);

		}

		// ??\????????????????????????????????¢????????¢??????????????¢????????????????????????????????????dice_roll??????????????????
		insdice.dice_roll(another_dice_num[0], another_dice_num[1], another_dice_num[2], another_dice_num[3],

				another_dice_num[4], another_dice_num[5]);

		System.out.println(insdice.get_answer());

	}

}

class Dice_third {

	int[] array_dice = new int[6];

	int top = 0;

	int bottom = 0;

	int front = 0;

	int back = 0;

	int right = 0;

	int left = 0;

	String answer = "No";

	// top?????°????????\??????????????????????????°
	int num;

	// front?????°????????\??????????????????????????°
	int num_front;

	// ????????????????????????????????£????????????????????\????????????????????§???????????§?????????
	Dice_third(String[] strings) {

		this.top = Integer.parseInt(strings[0]);

		this.front = Integer.parseInt(strings[1]);

		this.right = Integer.parseInt(strings[2]);

		this.left = Integer.parseInt(strings[3]);

		this.back = Integer.parseInt(strings[4]);

		this.bottom = Integer.parseInt(strings[5]);

	}

	// 1?????????????????°??¨????????????????????????????????¶???????????????
	void dice_roll(int top_side, int front_side, int right_side, int left_side, int back_side, int bottom_side) {

		// ????????????????????£???????????¨???????????????????????????top,front?????\?????????????????°??¨?????´????????¨???????????¢??????????????????
		for (int East_roll = 0; East_roll < 2; East_roll++) {

			// ???????????????4???????????¢???????????¨??????1?????¢
			for (int South_roll = 0; South_roll < 4; South_roll++) {

				for (int horizontal_roll = 0; horizontal_roll < 4; horizontal_roll++) {

					num = front;

					front = right;

					right = back;

					back = left;

					left = num;

					// ??\????????????top??¨
					if (top == top_side && front == front_side && right == right_side && left == left_side

							&& back == back_side && bottom == bottom_side) {

						answer="Yes";

					}

				}

				num = top;

				top = back;

				back = bottom;

				bottom = front;

				front = num;
			}

			num = top;

			top = left;

			left = bottom;

			bottom = right;

			right = num;

		}
	}

	String get_answer() {

		return answer;

	}
}

Measured memory_bytes: 24416
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ff first
#define ss second
#define sf ss.ff
#define tt ss.ss
#define input(a) scanf("%lld",&a)
#define M 1000000007
#define inf 1<<30
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);

using namespace std;

typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

/*
 *Use abbreviation:
 *dsu ->Disjoint Set Union
 *bit ->Binary Indexed Tree
 *math ->Mathematical Functions(gcd,fact,bigMod,ncr)
 *test ->For test cases
 */

ll n,ara[300010],res;

int main()
{
    cin>>n;
    for(int i=0;i<3*n;i++)
        scanf("%lld",&ara[i]);
    sort(ara,ara+3*n);
    res=0;
    for(int i=3*n-1,j=0;j<2*n;i--,j++){
        //cout<<ara[i]<<endl;
        if(j&1)
            res+=ara[i];
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int solve(int x){
    int res=1;
    while(res<=x){
        res*=2;
    }
    return res-x;
}
signed main() {
    int N;cin>>N;
    vector<int>A(N);
    map<int,int>M;
    rep(i,N){
        cin>>A[i];
        M[A[i]]++;
    }
    sort(all(A),greater<int>());
    int ans=0;
    for(auto x:A){
        if(M[x]==0)continue;
        M[x]--;
        int next=solve(x);
        if(M[next]>0){
            M[next]--;
            ans++;
        }
    }
    cout<<ans<<endl;
    
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    Int res = 0;
    if (a + b >= c * 2) {
        res += min(x, y) * c * 2;
        Int sub = min(x, y);
        x -= sub;
        y -= sub;
        if (x > 0) {
            res += x * min(a, c * 2);
        }
        else {
            res += y * min(b, c * 2);
        }
    }
    else {
        if (c * 2 < a) {
            res += x * (c * 2);
            y = max((Int)0, y - x);
            res += y * b;
        }  
        else if (c * 2 < b) {
            res += y * (c * 2);
            x = max((Int)0, x - y);
            res += x * a;
        }
        else {
            res += a * x + b * y;
        }
    }
    dump(res);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int rating = s.nextInt();
        if(rating < 1200)
            System.out.println("ABC");
        else if(rating < 2800)
            System.out.println("ARC");
        else
            System.out.println("AGC");
        s.close();
    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

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

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

int main() {
    
    int N;
    cin >> N;
    vector<int> D(N);
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> D[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = i+1; j < N; j++) {
            ans += D[i]*D[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}


int a[10];
int64_t ans=-999999999999999;
int N;
int F[200][10];
int P[200][11];

void func(void){
  int64_t score=0;
  for(int i=0;i<N;i++){
   int cnt=0;
   for(int j=0;j<10;j++){
    if(a[j]==1&&F[i][j]==1){
      cnt++;
    }
   }
   score+=P[i][cnt];
  }
  ans=max(ans,score);
}

void dfs(int pos){
  if(pos==10){
    bool ok=false;
    for(int i=0;i<10;i++){
      if(a[i]==1){ok=true;}
    }
    if(ok){func() ;}
    return ;
  }
  a[pos]=0;dfs(pos+1);
  a[pos]=1;dfs(pos+1);
}

int main() {
  cin>>N;
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin>>F[i][j];
    }
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin>>P[i][j];
    }
  }
  dfs(0);

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

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b){return *(int*)a - *(int*)b;} /* 1,2,3,4.. */
int des(const void *a, const void *b){return *(int*)b - *(int*)a;} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b){return *(char*)a - *(char*)b;} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b){return strcmp(*(const char **)a, *(const char **)b);} /* aaa,aab.. */
#define min(a,b) (a < b ? a: b)
#define max(a,b) (a > b ? a: b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007

typedef long long int lli;

int Gcd(int x, int y) {
  if (y == 0) return x;
  return Gcd(y, x % y);
}

int main(void) {
  int N, X;
  int x[MAX];
  scanf("%d %d", &N, &X);
  rep(i, 0, N) {
    scanf("%d", &x[i]);
  }

  int dist[MAX]; // 出発地点からの距離
  rep(i, 0, N) {
    dist[i] = abs(x[i] - X);
  } 

  // 最大公約数を計算
  int ans = 0;
  rep(i, 0, N) {
    ans = Gcd(ans, dist[i]);
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 896
// なんかうまく書けない
#include<iostream>
using namespace std;

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

    int cnt[3] = {}, a;
    for(int i = 0; i < n; i++){
        cin >> a;
        cnt[a%3]++;
    }

    if(cnt[1] > cnt[2]) swap(cnt[1], cnt[2]);

    if(cnt[2] == 0){
        cout << 1 << endl;
        return 0;
    }

    int ans = 1 + cnt[0];
    cnt[2]--;
    for(int i = 0;;i++){
        if(cnt[2-i%2] == 0) break;
        ans++;
        cnt[2-i%2]--;
    }

    cout << min(n, ans+1) << endl;

    return 0;
}


Measured memory_bytes: 3084
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    rFor(i,n) for(int i=n-1;i>=0;i--)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    //test
    {
        int n;
        string s;
        cin>>n>>s;
        fors(i,s)
        {
            int p=s[i]-'0'+48+n;
            //cout<<p<<" ";
            if(p<90)cout<<char(p);
            else if(p==90)cout<<'Z';
            else 
            cout<<char(p%90+64);
        }
    }
    
End;
}


Measured memory_bytes: 3652