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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = 998244353;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;

const int N_MAX = 300;
vector<vector<ll>> dp(N_MAX+1, vector<ll>(N_MAX*N_MAX+1, -1));
vector<vector<ll>> dpe(N_MAX+1, vector<ll>(N_MAX*N_MAX+1, -1));
int N, a[N_MAX], a_sum = 0;

ll dfs(int n, int k) {
  if (dp[n][k]!=-1) return dp[n][k];
  if (n==0) return dp[n][k] = (k==0) ? 1 : 0;
  ll result = 0;
  if (k==a_sum) {
    for (int i=0; i<=min(a_sum, a[n-1]); i++) {
      result += (i==0) ? dfs(n-1, k-i)*3 : dfs(n-1, k-i);
      result %= MOD;
    }
  }
  else if (k-a[n-1]<0) result += dfs(n-1, k)*2;
  else result += dfs(n-1, k)*2 + dfs(n-1, k-a[n-1]);
  result %= MOD;
  return dp[n][k] = result;
}

ll dfse(int n, int k) {
  if (dpe[n][k]!=-1) return dpe[n][k];
  if (n==0) return dpe[n][k] = (k==0) ? 1 : 0;
  ll result = 0;
  if (k-a[n-1]<0) result += dfse(n-1, k);
  else result += dfse(n-1, k) + dfse(n-1, k-a[n-1]);
  result %= MOD;
  return dpe[n][k] = result;
}

int main() {
  cin >> N;
  rep(i,N) { cin >> a[i]; a_sum += a[i]; }
  bool even = (a_sum%2==0);
  a_sum = (a_sum+1)/2;

  ll csum = 1; rep(i,N) { csum *= 3; csum %= MOD; }
  ll sum = dfs(N, a_sum)*3;
  if (even) sum -= dfse(N, a_sum)*3;
  ll result = (csum-sum%MOD+MOD)%MOD;
  cout << result << endl;
  // rep(i, N+1) {
  //   rep(j, a_sum+1) cout << dpe[i][j] << " ";
  //   cout << endl;
  // }
  return 0;
}

Measured memory_bytes: 424640
n=int(input())
s=[input() for i in range(n)]
l=[0]*26
moji=[]
for i in range(26):
  mini=len(s[0])
  for j in range(n):
    if s[j].count(chr(97+i))<mini:
      mini=s[j].count(chr(97+i))
  l[i]+=mini
for i in range(26):
  for j in range(l[i]):
    moji.append(chr(97+i))
print("".join(moji))

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

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

LL l[100];
int main(){
    int N;
    cin>>N;
    l[0]=2;
    l[1]=1;
    FOR(i,2,N+1)l[i]=l[i-1]+l[i-2];
    cout<<l[N]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll X, t;
    scanf("%lld %lld", &X, &t);
    printf("%lld\n", (X-t>0)?X-t:0);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int x,y,a,b;
	while(cin>>a>>b>>x>>y)
	{
		int m,n;
		m=x-a;
		n=y-b;
		while(n--)
			cout<<'U';
		while(m--)
			cout<<'R';
		m=x-a;
		n=y-b;
		while(n--)
			cout<<'D';
		while(m--)
			cout<<'L';
		m=x-a+1;
		n=y-b+1;
		cout<<'L';
		while(n--)
			cout<<'U';
		while(m--)
			cout<<'R';
		cout<<'D';
		m=x-a+1;
		n=y-b+1;
		cout<<'R';
		while(n--)
			cout<<'D';
		while(m--)
			cout<<'L';
		cout<<'U'<<endl;
	}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <float.h>
using namespace std;
int main(){
  int a,b,c,d,e,f,g;
  cin >> a;
  b=a/500;
  c=b*1000;
  d=a-b*500;
  e=d/5;
  f=e*5;
  int ans = f+c;
  cout << ans;



    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];
int64_t len = accumulate(ALL(A), 0LL);
int64_t r = 0, l =0;
int64_t mid;
// if (len % 2) --len;
{int i = 0;
while (r < len/2) {
    r += A[i];
    ++i;
}
r -= A[i-1];
mid = A[i-1];
while (i < N){
    l += A[i];
    ++i;
}
}

cout << min(r+mid - l, l+mid -r) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



Measured memory_bytes: 1792
from itertools import permutations

n,m=map(int,input().split())
es=set()
for _ in range(m):
    u,v=map(int,input().split())
    u,v=u-1,v-1
    es|={(u,v),(v,u)}

res=0
for p in permutations(range(n)):
    if p[0]!=0: continue
    if all((p[i],p[i+1]) in es for i in range(n-1)):
        res+=1
print(res)


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(4100000)
import math
import collections
INF = 10**9


def main():
    n = int(input())
    S = []
    for i in range(n):
        S.append(input())

    count = 0
    c = collections.Counter(S)
    for _, val in c.items():
        count = max(count, val)
    array = []
    for key, val in c.items():
        if val == count:
            array.append(key)
    array.sort()
    for val in array:
        print(val)


if __name__ == '__main__':
    main()


Measured memory_bytes: 103376
/* ALDS1_4_B: Binary Search */

#include <cstdio>

bool bin_search(int array[], int target, int from, int to) {
    if (to <= from) return false;

    int mid = (from + to) / 2;
    if (target == array[mid])
        return true;
    else if (target < array[mid])
        return bin_search(array, target, from, mid);
    else
        return bin_search(array, target, mid + 1, to);
}

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

    int S[n_s];
    for (int i = 0; i < n_s; i++)
        scanf("%d", &S[i]);

    int n_t;
    scanf("%d", &n_t);

    int T[n_t];
    for (int i = 0; i < n_t; i++)
        scanf("%d", &T[i]);

    int n_commons = 0;
    for (int i_t = 0; i_t < n_t; i_t++) {
        n_commons += bin_search(S, T[i_t], 0, n_s) ? 1 : 0;
    }
    printf("%d\n", n_commons);

    return 0;
}

Measured memory_bytes: 1612
import java.util.Scanner;

public class Main {
   public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  while(sc.hasNext()){
		  String line = sc.nextLine();
		  String[] datas = line.split(",");
		  double weight = Double.parseDouble(datas[1]);
		  double height = Double.parseDouble(datas[2]);
		  double bmi = weight/(height*height);
		  if(bmi >= 25.0){
			  System.out.println(datas[0]);
		  }
	   }
     }
}

Measured memory_bytes: 17168
size = input()#Y???X????????????????????¨?????¨???
while size != '0 0':
	tile = []
	for i in range(0, int(size.split(' ')[0])):#?????????????????????
		tilestr = []
		inp = input()
		for j in range(0,int(size.split(' ')[1])):
				 tilestr.append(inp[j:j+1])
		tile.append(tilestr)
		isVisited = []
		for i in range(0 , len(tile)):
			isIdxVisited = []
			for j in range(0,len(tile[i])):
				isIdxVisited.append(False)
			isVisited.append(isIdxVisited)
	currentIdx = [0,0] #?????£??????XY??§?¨?
	while True:
		if isVisited[currentIdx[1]][currentIdx[0]] == True:#???????????¨[Y][X]???????????????
			print('LOOP')
			break
		isVisited[currentIdx[1]][currentIdx[0]] = True
		if tile[currentIdx[1]][currentIdx[0]] == '^':
			currentIdx[1] -= 1
			continue
		elif tile[currentIdx[1]][currentIdx[0]] == 'v':
			currentIdx[1] += 1
			continue
		elif tile[currentIdx[1]][currentIdx[0]] == '<':
			currentIdx[0] -= 1
			continue
		elif tile[currentIdx[1]][currentIdx[0]] == '>':
			currentIdx[0] += 1
			continue
		elif tile[currentIdx[1]][currentIdx[0]] == '.':
			print(str(currentIdx[0])+' '+str(currentIdx[1]))
			break
	size = input()

Measured memory_bytes: 7820
using System;
using System.Linq;
using System.Collections.Generic;
using System.Collections;

class Program
{
    static void Main(string[] args)
    {
        var sol = new Solve();
        sol.Exec();
    }
}

class Solve
{
    public void Exec()
    {
        var l = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h = l[0], a = l[1];
        Console.WriteLine(h % a == 0 ? h / a : h / a + 1);
    }
}


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

int main() {
	int a, b, s;
	cin >> a >> b;
	if (1 <= b && b <= 9)
		s = 10 * a + b;
	else if (10 <= b && b <= 99)
		s = 100 * a + b;
	else
		s = 1000 * a + b;
	cout << (floor(sqrt(s)) == sqrt(s) ? "Yes" : "No") << endl;
	return 0;
}


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

typedef long long ll;
int mod = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	int ans = 1;
	for (int i = 1; i <= n; ++i) {
		ans = ((ans % mod)  * 1LL *  (i % mod)) % mod; 
	}
    cout << ans;
}



















Measured memory_bytes: 256
N,M=map(int, input().split())
E=[[] for _ in range(N)]
for i in range(M):
    a,b,c=map(int, input().split())
    E[a-1].append((b-1,c,i))
    E[b-1].append((a-1,c,i))

ans=[1]*M

import heapq
def dijkstra(s):
    distance=[-1]*N
    parent_n=[-1]*N
    parent_e=[-1]*N
    distance[s]=0
    parent_n[s]=s
    q=[(0,s)]
    while q:
        nc,n=heapq.heappop(q)
        for to,c,eid in E[n]:
            if distance[to]<0 or nc+c<distance[to]:
                distance[to]=nc+c
                parent_n[to]=n
                parent_e[to]=eid
                heapq.heappush(q,(nc+c,to))
    checked=[False]*N
    checked[s]=True
    for i in range(N):
        if checked[i]: continue
        n=i
        while n!=s:
            checked[n]=True
            ans[parent_e[n]]=0
            n=parent_n[n]

for i in range(N): dijkstra(i)
print(sum(ans))

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



int main() {

    ll n,m; cin >> n >> m;
    
    if(n == 1 && m == 1) cout << 1;
    else if(n == 1) cout << m-2;
    else if(m == 1) cout << n-2;
    else cout << (m-2)*(n-2);

    return 0;
}











Measured memory_bytes: 3532
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            String str = String.valueOf(n);
            int sumDigit = 0;
            for (int i = 0; i < str.length(); i++) {
                sumDigit += Integer.valueOf(String.valueOf(str.charAt(i)));
            }

            if (n % sumDigit == 0) {
                out.print("Yes");
            } else {
                out.print("No");
            }
        }

    }
}



Measured memory_bytes: 23636
#import"bits/stdc++.h"
#define r(n) for(i=0;i<n;i++)
using namespace std;main(int N){cin>>N;int A[2*N],c[N+1]={},n,t,i;r(2*N)cin>>A[i];r(2*N)c[A[i]]++;if(*max_element(c,c+N+1)>N)cout<<"No";else{cout<<"Yes ";queue<int> s;r(N)if(A[i]==A[N+i])s.push(i);while(!s.empty()){n=s.front(),t=N+rand()%N;s.pop();if(A[n]!=A[t]&A[t-N]!=A[n+N])swap(A[n+N],A[t]);else s.push(n);}r(N)cout<<A[i+N]<<" ";}}

Measured memory_bytes: 6724
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

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

    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }

    rep(x, h) {
        rep(y, w) {
            if(board[x][y] == '.') {
                ll cnt = 0;
                rep(dir, 8) {
                    ll nx = x + dx[dir];
                    ll ny = y + dy[dir];
                    if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                        continue;
                    }
                    if(board[nx][ny] == '#') {
                        cnt++;
                    }
                }
                board[x][y] = cnt + '0';
            }
        }
    }
    
    rep(i, h) {
        rep(j, w) {
            cout << board[i][j];
        }
        cout << "\n";
    }

    re0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define UNIQUE(c) sort(ALL(c)), c.erase(unique(ALL(c)), c.end())

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

template <typename T>
T powmod(T n, T k, T mod) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    return powmod(n * n % mod, k / 2, mod);
  } else {
    return n * powmod(n, k-1, mod) % mod;
  }
}

template <typename T>
T inv(T x, T mod = 1e9 + 7) {
  return powmod(x, mod-2, mod);
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  const ll mod = 1e9 + 7;

  int N; cin >> N;
  vector<ll> fact(N), inv_fact(N);
  fact[0] = fact[1] = 1;
  inv_fact[0] = inv_fact[1] = inv(1);
  FOR(i, 2, N) {
    fact[i] = (fact[i - 1] * (ll)i) % mod;
    inv_fact[i] = inv(fact[i]);
  }

  ll ans = 0, prev = 0;

  REP(k, N) {
    if (k - 1 >= 0 and N - k - 1 >= 0 and k - 1 >= N - k - 1) {
      ll now = fact[k - 1] * inv_fact[2 * k - N] % mod * fact[k] % mod;
      ans += (now - prev + mod) % mod * k % mod;
      ans %= mod;
      prev = now;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15872
#include <stdio.h>
int c[26];

int main(void) {
    int n;
    char ch;
    while( scanf( "%c", &ch ) != EOF ) {
        if( 'a' <= ch && ch <= 'z' ){
            n = ch - 'a';
            c[n]++;
        } else if( 'A' <= ch && ch <= 'Z' ) {
            n = ch - 'A';
            c[n]++;
        }
    }
    for( int i = 0; i < 26; i++ ){
        printf( "%c : %d\n", 'a' + i, c[i] );
    }
    return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
string str;
signed main()
{
	cin>>str;
	if(str=="MON")
		printf("6");
	else if(str=="TUE")
		printf("5");
	else if(str=="WED")
		printf("4");
	else if(str=="THU")
		printf("3");
	else if(str=="FRI")
		printf("2");
	else if(str=="SAT")
		printf("1");
	else if(str=="SUN")
		printf("7");
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
int main(void)
{
	ios::sync_with_stdio(false);
	int tate, yoko;
	cin >> tate >> yoko;
	vector<vector<char>> nyuryoku(tate + 2, vector<char>(yoko + 2, 'a'));
	vector<vector<int>> syuturyoku(tate + 2, vector<int>(yoko + 2, 0));
	for (int i = 1; i <= tate; i++)
	{
		for (int j = 1; j <= yoko; j++)
		{
			cin >> nyuryoku[i][j];
		}
	}
	for (int i = 1; i <= tate; i++)
	{
		for (int j = 1; j <= yoko; j++)
		{
			int aaa = 0;
			if (nyuryoku[i][j] == '#')
			{
				syuturyoku[i][j] = -1;
			}
			else
			{
				if (nyuryoku[i - 1][j - 1] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i][j - 1] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i + 1][j - 1] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i - 1][j] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i + 1][j] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i - 1][j + 1] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i][j + 1] == '#')
				{
					aaa++;
				}
				if (nyuryoku[i + 1][j + 1] == '#')
				{
					aaa++;
				}
				//cout << aaa << endl;
				syuturyoku[i][j] = aaa;
			}
		}
	}

	for (int i = 1; i <= tate; i++)
	{
		for (int j = 1; j <= yoko; j++) 
		{
			if (syuturyoku[i][j] == -1)
			{
				cout << "#";
			}
			else 
			{
				cout << syuturyoku[i][j];
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 256
# input
A, B, K = (int(i) for i in input().split())

# main
ans_list = []
for i in range(1, min(A, B) + 1):
    if A % i == 0 and B % i == 0:
        ans_list.append(i)

# output 
ans = ans_list[-K]
print(ans)

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

public class Main {
    static final int INF = (int)Math.pow(10, 9) + 7;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] C = new int[N];
        int[][] A = new int[N][M];
        for (int i = 0; i < A.length; i++) {
            C[i] = sc.nextInt();
            for (int j = 0; j < A[i].length; j++) {
                A[i][j] = sc.nextInt();
            }
        }
        boolean ok = false;
        int min = INF;
        for (int bit = 0; bit < (1 << N); bit++) {
            int money = 0;
            int[] understand = new int[M];
            for (int i = 0; i < N; i++) {
                if ((bit & (1 << i)) != 0) {
                    money += C[i];
                    for (int j = 0; j < M; j++) {
                        understand[j] += A[i][j];
                    }
                }
            }
            Arrays.sort(understand);
            if (understand[0] >= X) {
                ok = true;
                min = Math.min(min, money);
            }
        }
        if (ok) {
            System.out.println(min);
        } else {
            System.out.println(-1);
        }
        sc.close();
    }
}

Measured memory_bytes: 37588
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:table/trie.cpp>
namespace table {
    template <class ValueType> class Trie {
    public:
        typedef std::string::const_iterator StringIterator;
        static const int SIZE = 256;
        ValueType value;
        Trie *next[SIZE];
        Trie() { std::fill( next, next+SIZE, (Trie*)NULL ); }
        Trie& find( const std::string& s ) {
            Trie* res = this;
            for ( StringIterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
                const int& c = *it_i;
                if ( ! res->next[c] ) res->next[c] = new Trie;
                res = res->next[c];
            }
            return *res;
        }
        int count( const std::string& s ) {
            Trie* res = this;
            for ( StringIterator it_i = s.begin(); it_i != s.end(); ++ it_i ) {
                const int& c = *it_i;
                if ( ! res->next[c] ) return 0;
                res = res->next[c];
            }
            return 1;
        }
        ValueType& operator []( const std::string& s ) { return find(s).value; }
    };
}

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
    class ISolution {
    public:
        virtual void init() {};
        virtual bool input() { return false; };
        virtual void output() {};
        virtual int run() = 0;
    };
}

// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
    using namespace std;
    class Solution: public ISolution {
    public:
        table::Trie<int> T;
        int n;
        void init() {
            T = table::Trie<int>();
        }
        bool input() {
            if ( ! ( cin >> n && n ) )
                return false;
            for ( int i = 0; i < n; ++ i ) {
                string item;
                int value;
                cin >> item >> value;
                T[item] = value;
            }
            return true;
        }
        void solve() {
            int m;
            cin >> m;
            for ( int i = 0; i < m; ++ i ) {
                string item;
                cin >> item;

                int k;
                cin >> k;

                int sum = 0;
                for ( int j = 0; j < k; ++ j ) {
                    string item;
                    cin >> item;
                    sum += T[item];
                }
                T[item] = min( T[item], sum );
            }
            string q;
            cin >> q;
            cout << T[q] << endl;
        }
        int run() {
            while ( init(), input() ) {
                solve();
                output();
            }
            return 0;
        }
    };
}


// @snippet<sh19910711/contest:main.cpp>

int main() {
    return solution::Solution().run();
}

Measured memory_bytes: 6260
# A - Kyu in AtCoder
def main():
    X = int(input())
    if X < 600:
        res = 8
    elif X < 800:
        res = 7
    elif X < 1000:
        res = 6
    elif X < 1200:
        res = 5
    elif X < 1400:
        res = 4
    elif X < 1600:
        res = 3
    elif X < 1800:
        res = 2
    else:
        res = 1
    print(res)


if __name__ == "__main__":
    main()


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

int N, A, B;
int a[17], b[17];
int used[17];
pair<int, int> P[8];
void match(int n) {
	rep(j, N) if (used[j] == 0) {
		if (n != (N + 1) / 2 - 1) {
			for (int i = j + 1; i < N; i++) {
				if (used[i] == 0) {
					if ((a[j] + b[j] + a[i] + b[i]) % 2 == 0) {
						used[j] = 1;
						used[i] = 1;
						P[n] = mp(j, i);
						match(n + 1);
						break;
					}
				}
			}
		}
		else {
			for (int i = j + 1; i < N; i++) {
				if (used[i] == 0) {
					P[n] = mp(j, i);
					break;
				}
			}
		}
	}
}



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


	cin >> N >> A >> B;

	if (N == 1) {
		co("YES");
		cosp(A);
		co(B);
	}
	else {
		int na = 0;
		int nb = 0;
		rep(i, N) if (A >> i & 1) {
			a[i] = 1;
			na ^= 1;
		}
		rep(i, N) if (B >> i & 1) {
			b[i] = 1;
			nb ^= 1;
		}

		if (na == nb) {
			co("NO");
		}
		else {
			co("YES");
			match(0);

			rep(i, 3) {
				cesp(P[i].first);
				ce(P[i].second);
			}
			
			int kotae = A;
			int dotti[8] = {};
			rep(i, N / 2) {
				if (a[P[i].first] == b[P[i].first]) dotti[i] = 1;
			}

			int hajimete[8] = {};
			int dotti2[8] = {};
			rep(k, N % 2 + 1) {
				rep1(i, (1 << N / 2 * 2) - 1) {
					cosp(kotae);
					int keta = 0;
					int kari = i;
					while (kari % 4 == 0) {
						kari /= 4;
						keta++;
					}
					if (keta == (N + 1) / 2 - 1) {
						if (kari % 2 == 0) {
							if (dotti[keta]) kotae ^= 1 << P[keta].second;
							else kotae ^= 1 << P[keta].first;
						}
						else {
							if (dotti[keta]) kotae ^= 1 << P[keta].first;
							else kotae ^= 1 << P[keta].second;
						}
					}
					else {
						if (dotti2[keta] == 0) {
							if (kari % 4 == 1) {
								kotae ^= 1 << P[keta].first;
							}
							else if (kari % 4 == 2) {
								kotae ^= 1 << P[keta].second;
							}
							else {
								kotae ^= 1 << P[keta].first;
								dotti2[keta] = 1;
							}
						}
						else {
							if (kari % 4 == 1) {
								if (dotti[keta] == 0 && hajimete[keta] == 0) kotae ^= 1 << P[keta].second;
								else kotae ^= 1 << P[keta].first;
							}
							else if (kari % 4 == 2) {
								if (dotti[keta] == 0 && hajimete[keta] == 0) kotae ^= 1 << P[keta].first;
								else kotae ^= 1 << P[keta].second;
							}
							else {
								if (dotti[keta] == 0 && hajimete[keta] == 0) kotae ^= 1 << P[keta].second;
								else kotae ^= 1 << P[keta].first;
								dotti2[keta] = 0;
								hajimete[keta] = 1;
							}
						}
					}
				}
				if (k == 1 || N % 2 == 0) {
					co(kotae);
				}
				else {
					cosp(kotae);
					rep(i, N) if (used[i] == 0) kotae ^= 1 << i;
				}
			}
		}
	}

	Would you please return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, c;
    cin >> n >> c;
    
    int cnt = 0;
    rep(i, c){
        int p;
        cin >> p;
        cnt += p;
    }

    int ans = cnt / (n + 1) + (cnt % (n + 1) > 0);
    cout << ans << endl;

    return 0;
}


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

signed main() {
  int N;
  cin >> N;
  
  vector<int> C(N-1);
  vector<int> S(N-1);
  vector<int> F(N-1);
  for( int i = 0; i < N-1; i++ ){
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  
  for( int i = 0; i < N; i++ ){
    int t = 0;
    for( int j = i; j < N-1; j++ ){
      if( t < S.at(j) ) t = S.at(j);
      else if( t % F.at(j) != 0 ) t = t + F.at(j) - ( t%F.at(j) );
      t += C.at(j);
    }
    cout << t << endl;
  }
    
  
    

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int n, m;
  scanf("%d %d", &n, &m);
  int a[m];
  int sum = 0;
  for (int i = 0; i < m; i++)
  {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  int ans;
  if (n >= sum)
  {
    ans = n - sum;
  }
  else if (n < sum)
  {
    ans = -1;
  }
  printf("%d", ans);
  return 0;
  
}


Measured memory_bytes: 1744
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

const int MOD=1000000007;

int main(){
  int r1,c1,r2,c2;
  cin >> r1 >> c1 >> r2 >> c2;

  int N=r2+c2+3;
  vector<ll> fac(N);
  vector<ll> inv(N);
  vector<ll> facinv(N);

  fac[0]=fac[1]=1;
  facinv[0]=facinv[1]=1;
  inv[1]=1;

  for(int i=2;i<N;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    facinv[i]=facinv[i-1]*inv[i]%MOD;
  }

  ll res=0;
  --r1;--c1;
  res =fac[r2+c2+2]*facinv[r2+1]%MOD*facinv[c2+1]%MOD;
  //cout << fac[r2+c2+2]*facinv[r2+1]%MOD*facinv[c2+1]%MOD << endl;
  res+=fac[r1+c1+2]*facinv[r1+1]%MOD*facinv[c1+1]%MOD;
  //cout << fac[r1+c1+2]*facinv[r1+1]%MOD*facinv[c1+1]%MOD << endl;
  res-=fac[r1+c2+2]*facinv[r1+1]%MOD*facinv[c2+1]%MOD;
  res-=fac[r2+c1+2]*facinv[r2+1]%MOD*facinv[c1+1]%MOD;
  res+=MOD;res%=MOD;

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 47104
import itertools
D, G = map(int, input().split())
p = [0] * D
c = [0] * D
pc = [0] * D
for i in range(D):
    p[i], c[i] = map(int, input().split())

l = list(itertools.product(range(2), repeat=D))

comp = []
for i in range(len(l)-1):
    score = 0
    count = 0
    m = -100
    for j in range(D):
        if l[i][j] == 1:
            score += (j+1) * 100 * p[j] + c[j]
            count += p[j]
        elif l[i][j] == 0:
            m = max(m, j)
    tmp = [score, count]
    comp.append(tmp)
    for j in range(p[m]-1):
        score += (m+1) * 100 * 1
        count += 1
        tmp = [score, count]
        comp.append(tmp)

score = 0
count = 0
for i in range(D):
    score += (i+1) * 100 * p[i] + c[i]
    count += p[i]
tmp = [score, count]
comp.append(tmp)    

#print(comp)

ans = []
for i in range(len(comp)):
    if comp[i][0] >= G:
        ans.append(comp[i][1])

ans = min(ans)
print(ans)


Measured memory_bytes: 20888
#include<stdio.h>
#define N 100
int main(){
  int i,j,k,l,n,p[N+1],m[N+1][N+1];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }
  for(i=1;i<=n;i++){
    m[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=0;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=(1<<21);
      for(k=i;k<=j-1;k++){
        if(m[i][j]<(m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]))
      	  m[i][j]=m[i][j];
      	else m[i][j]=m[i][k]+m[k+1][j]+(p[i-1]*p[k]*p[j]);
      }
    }
  }
  printf("%d\n",m[1][n]);
  return 0;
}



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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll n, m;
  cin >> n >> m;
  cout << (1900 * m + 100 * (n-m)) * pow((ll)2, m) << endl;
}


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

using ll = long long;

#define for_(i,a,b) for(int i = (a);i < (b);i++)
#define rfor_(i,a,b) for(int i = (b)-1;i >= (a);i--)
#define rep(i,n) for_(i,0,(n))
#define rrep(i,n) rfor_(i,0,(n))

using vi = vector<int>;

vi a;

int q;

int main(){
	cin.tie(0);
	
	cin>>q;
	rep(i, q) {
		int c, x;
		cin>>c;
		if(c==0) {
			cin>>x;
			a.push_back(x);
		}else if(c==1) {
			cin>>x;
			cout<<a[x]<<endl;
		}else {
			a.pop_back();
		}
	}

	return 0;
}



Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair

int main(){
	ll n,count=0;
	cin >> n;
	ll a[n+1];
	for(ll i=1;i<=n;i++) cin >> a[i];
	vector<ll>res;
	vector<ll>b(n+1,0);
	for(ll i=n;i>=1;i--){
		ll j=2;
		ll c=0;
		while(i*j<=n){
			c+=b[i*j];
			j++;
		}
		if(c%2!=a[i]){
			b[i]=1;
			count++;
			res.push_back(i);
		}
	}
	if(count==0){
		cout << count << endl;
	}
	else{
		cout << count << endl;
		for(auto p:res){
			cout << p << " ";
		}
		cout << endl;
	}
}


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

using namespace std;

int main(){
    int m,n;
    int sum=0;

   int x[100000];
   int y[100000];

   cin>>n>>m;

   
   for(int i=0;i<m;i++){
       
       cin>>x[i];
       
      
   }

   sort(x,x+m);

  

   for(int i=0;i<m-1;i++){
       y[i]=x[i+1]-x[i];
   }

    sort(y,y+m-1);

   

   if(n>=m){
       sum=0;
   }
   else {
       for(int i=0;i<m-n;i++){
           sum+=y[i];
       }
   }
   cout<<sum<<endl;
   return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include <algorithm>
using namespace std;
int const mod = 1e9+7;
int main(){
	long long S;
	scanf("%lld",&S);
	if(S<3){
		printf("%d\n",0);
		return 0;
	}
	vector<int> dp(S+1,1);
	for(int i=4;i<=S;i++){
		for(int term=3;term<=i;term++){
			if(i-term>=3)
				dp[i]=(dp[i]+dp[i-term])%mod;
		}
	}
	printf("%d\n",dp[S]);
	return 0;
} 


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

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum_xor = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    sum_xor ^= a[i];
  }

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

  return 0;
}

Measured memory_bytes: 4736
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    a, b = input().split()
    if a == b:
        print("H")
    else:
        print("D")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4200
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }

    map<pii,int> dp;
    dp[{0,0}] = 1;
    for(int i = 0; i < n; i++){
        map<pii,int> dp2;
        dp2[{0,0}] = 1;
        vector<pii> check_list;
        for(auto itr = dp.begin(); itr != dp.end(); ++itr) {
            check_list.push_back({itr->first.first,itr->first.second});
        }
        for(int j = 0; j < check_list.size(); j++){
            if(dp[{check_list[j].first+a[i],check_list[j].second+b[i]}] == 0){
                dp2[{check_list[j].first+a[i],check_list[j].second+b[i]}] =dp[{check_list[j].first,check_list[j].second}]+c[i];
            }else{
                dp2[{check_list[j].first+a[i],check_list[j].second+b[i]}] = min(dp[{check_list[j].first+a[i],check_list[j].second+b[i]}],dp[{check_list[j].first,check_list[j].second}]+c[i]);
                
            }
        }
        for(auto itr = dp2.begin(); itr != dp2.end(); ++itr) {
            dp[{itr->first.first,itr->first.second}] = dp2[{itr->first.first,itr->first.second}];
        }

    }
    int ans = 999999;
    int cnt = 1;


    while(cnt*ma <= 405 && cnt*mb <= 405){
        if(dp[{cnt*ma,cnt*mb}] != 0){
            ans = min(ans,dp[{cnt*ma,cnt*mb}]);
        }
        cnt++;
    }
    if(ans == 999999){
        cout << -1 << endl;
    }else{
        cout << ans-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3236
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll n, m, q;
vector<ll> a(100), b(100), c(100), d(100);
ll ans = 0;

void bfs(vector<ll> x)
{
    if (x.size() == n)
    {
        ll res = 0;

        for (ll k = 0; k < q; k++)
        {
            if (c[k] == x[b[k]] - x[a[k]])
            {
                res += d[k];
            }
        }

        ans = max(res, ans);

        return;
    }

    for (ll i = *x.rbegin(); i <= m; i++)
    {
        vector<ll> A = x;
        A.push_back(i);

        bfs(A);
    }
}

int main(void)
{
    cin >> n >> m >> q;

    for (int i = 0; i < q; i++)
    {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    for (int i = 1; i <= m; i++)
    {
        vector<ll> A = {i};
        bfs(A);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)
dp = Array.new(n,Float::INFINITY)
dp[0] = 0
(1..n-1).each do |i|
    if i >= 2
        dp[i] = [(h[i]-h[i-1]).abs + dp[i-1],(h[i]-h[i-2]).abs + dp[i-2]].min
    end
    if i == 1
        dp[i] = (h[i]-h[i-1]).abs
    end
end
puts dp.pop

Measured memory_bytes: 21488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define rrep(i,a,b) for(int i = b; i --> (a);)
#define all(v) v.begin(),v.end()
#define trav(x,v) for(auto &x : v)
#define sz(v) (int)(v).size()
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	string s;
	cin >> n >> s;
	
	map<pair<string,string>, int> mp;

	rep(msk, 0, 1<<n){
		string a, b;
		rep(i,0,n){
			if(msk & (1<<i)) a.push_back(s[i]);
			else b.push_back(s[i]);
		}
		reverse(all(b));
		++mp[make_pair(a,b)];
	}

	ll ans = 0;

	rep(msk, 0, 1<<n){
		string a, b;
		rep(i,0,n){
			if(msk & (1<<i)) a.push_back(s[i+n]);
			else b.push_back(s[i+n]);
		}
		reverse(all(a));
		ans += mp[make_pair(a,b)];
	}

	cout << ans << endl;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a <= 8 && b <= 8 ? "Yay!" : ":(") << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

signed main(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if(a > b && a > c){
        cout << b + c + a * pow(2, k) << endl;
        return 0;
    }

    if(b > a && b > c){
        cout << a + c + b * pow(2, k) << endl;
        return 0;
    }
    cout << a + b + c * pow(2, k) << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x;
    cin>>x;
    string s;
    cin>>s;
    if(s.size()>x)
    {
        s.erase(x);
        cout<<s+"..."<<endl;
    }
    else
        cout<<s<<endl;
    return 0;
}


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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int pattern = 0;
	for(int i=0; i<=a; ++i){
		int money = 500*i;
		if(money > x) break;
		for(int j=0; j<=b; ++j){
			if(money > x) break;
			if(x-money <= 50*c) pattern++;
			money += 100;
		}
	}
	cout << pattern << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().solver();
	}

	void solver() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] cs = sc.next().toCharArray();
		int ans = 0;
		int[][] dp = new int[N][N];
		for (int s = N - 1; s >= 0; --s) {
			for (int t = N - 1; t > s; --t) {
				if (cs[s] != cs[t])
					continue;
				dp[s][t] = 1 + (s + 1 < N && t + 1 < N ? dp[s + 1][t + 1] : 0);
				dp[s][t] = Math.min(dp[s][t], t - s);
			}
		}
		for (int i = 0; i < N; ++i)
			for (int j = 0; j < N; ++j)
				ans = Math.max(ans, dp[i][j]);
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


Measured memory_bytes: 167352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    REP(i,s.size()) {
        if (s[i] == '1') s[i] = '9';
        else if (s[i] == '9') s[i] = '1';
    }

    OUT(s)

    return 0;
}

Measured memory_bytes: 256
// Problem : P - Independent Set
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_p
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

int n;
int dp[N][2];
vi g[N];

void dfs(int u, int par){
    int white = 1;
    int black = 1;
    for(int i : g[u]){
        if(i != par){
            dfs(i,u);
            (black *= dp[i][0]) %= mod;
            (white *= dp[i][0]+dp[i][1]) %= mod;
        }
    }
    dp[u][0] = white;
    dp[u][1] = black;
}

void solve(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int u,v;
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,0);
    cout<<(dp[1][0]+dp[1][1])%mod;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 18896
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define pqb priority_queue<int>
#define pqs priority_queue<int, vi, greater<int>>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x, y) fixed << setprecision(y) << x
#define mk(arr, n, type) type *arr = new type[n];
#define w(x) \
  ll x;      \
  cin >> x;  \
  while (x--) 

void cpc()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main()
{
  cpc();
  int n,m,i,j,a,b,flag,ans=0;
  cin>>n>>m;
  vector<int> vec(n+1,0);
  vector<vector<int>> arr(n+1);
  for(i=1;i<=n;i++){
    cin>>vec[i];
  }
    for(i=1;i<=m;i++){
      cin>>a>>b;
        arr[a].pb(b);
        arr[b].pb(a);
    }
    for(i=1;i<=n;i++){
      flag=1;
      for(j=0;j<arr[i].size();j++){
        if(vec[arr[i][j]]>=vec[i]){
            flag=0;
            break;
        }
      }
      if(flag){
        ans++;
      }
  }
    
  
 
  cout<<ans<<"\n";
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  int cnt = 0, N, Nr, digit = 10000;
  for (int i = A; i<=B; i++){
    N = i;
    Nr = i;
    digit = 10000;
    while (N>0){
      Nr -= (N%10)*digit;
      N /= 10;
      digit /=10;
    }
    if (Nr == 0) cnt++;
  }

  cout << cnt << endl;
}

  
  

Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

a,b = map(int, input().split())

if (a*b % 2 == 0):
    print("Even")
else:
    print("Odd")


Measured memory_bytes: 9012
#include<cstdio>
using namespace std;
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(b-a==c-b)
	{
		printf("YES\n");
		return 0;
	}
	printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;
using ll=long long;

int main() {
  int N, M, S=0;
  cin >> N >> M;
  vector<int> X(M), V(M-1);
  for (int i=0; i<M; i++) {
    cin >> X[i];
  }
  sort(X.begin(), X.end());
  for (int i=1; i<M; i++) {
    V[i-1]=X[i]-X[i-1];
    S+=V[i-1];
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  
  if (M-N<=0) {cout << 0 << endl;}
  else {
    for (int i=0; i<N-1; i++) {
      S-=V[i];
    }
    cout << S << endl;
  }
}

Measured memory_bytes: 4048