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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int K;
	string S;
	cin >> K >> S;

	if (SZ(S) <= K)
	{
		cout << S << endl;
	}
	else
	{
		cout << S.substr(0, K) << "..." << endl;
	}

	return 0;
}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int d=c-(a-b);
  if(d>=0){
    cout <<d<<endl;
  }
  else{
    cout <<0<<endl;
  }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int S = 1; //表示されている数字
  
  for (int i = 0; i < N; i++){
    if (S >= K){
      S += K; //Bの操作
    }
    else {
      S *= 2; //Aの操作
    }
  }
  
  cout << S << endl;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n; cin >> n;
	int m = 0, cnt = 0;
	REP(i, n) {
		int h; cin >> h;
		if (m <= h)cnt++;
		chmax(m, h);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
import math
a,b,h,m = map(int, input().split())
h2 = h*30 + m*6/360*30
m2 = m*6
if h2 <= m2 :
    c = m2 - h2
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(c))
    print(math.sqrt(ans))
else:
    c = h2 - m2
    ans = a**2 + b**2 -2*a*b*math.cos(math.radians(c))
    print(math.sqrt(ans))

Measured memory_bytes: 9524
// AOJ ALDS1_5_B Merge Sort
// 2018.4.30 bal4u

#include <stdio.h>
#include <string.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in()
{
	int n = 0, c = gc();
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20];
void mypr(int n)
{
	int w;
	if (!n) { pc('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	while (w--) pc(buf[w]);
}

#define MAX_N 500002
#define INF   0x7f7f7f7f

int a[MAX_N];
int w[MAX_N/2+2];
int cnt;

void merge_sort(int low, int high) 
{ 
	int i, j, k, p, mid; 

	if (low < high) {
		mid = (low + high) >> 1;
		merge_sort(low,   mid);
		merge_sort(mid+1, high);

cnt += high-low+1;

		p = mid-low+1;
		memcpy(w, a+low, p << 2);
		i = mid+1, j = 0; k = low;

		w[p] = INF;
		while (i <= high) {
			if (w[j] <= a[i]) a[k++] = w[j++];
			else              a[k++] = a[i++];
		}
		memcpy(a+k, w+j, (p-j) << 2);
	}
}

int main()
{
	int n, i;
	
	n = in(); for (i = 0; i < n; i++) a[i] = in();

	cnt = 0;
	merge_sort(0, n-1);

	mypr(a[0]); for (i = 1; i < n; i++) pc(' '), mypr(a[i]); pc('\n');
	mypr(cnt); pc('\n');
	return 0;
}


Measured memory_bytes: 4492
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	string S;
	cin >> S;
	int rec = 0;
	int ans = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == 'A' || S[i] == 'T' || S[i] == 'C' || S[i] == 'G') {
			rec++;
		}
		else {
			ans = max(ans, rec);
			rec = 0;
		}
	}
	ans = max(ans, rec);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REPR(i, n) for(int i = (n); i >= 0; i--)
#define FOR(i, m, n) for(int i = (m); i < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  int n, cnt = 0;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    if(to_string(i).length() % 2 == 1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int H, W;
	char x;

	cin >> H >> W;

	vector<vector<int>> M(H + 2, vector<int>(W + 2, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> x;

			if (x == '#')
			{
				M[i + 1][j + 1] = 1;
			}
		}
	}

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (!M[i + 1][j + 1])
			{
				int num = 0;
				for (int k = 0; k < 3; k++)
				{
					for (int l = 0; l < 3; l++)
					{
						num += M[i + k][j + l];
					}
				}

				cout << num;
			}
			else
				cout << '#';
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		StringBuilder output = new StringBuilder();
		Scanner scan = new Scanner(System.in);
		while(true) {
			int a = scan.nextInt();
			int b = scan.nextInt();
			if (a == 0 && b == 0)
				break;
			if (a <= b) {
				output.append(a).append(" ").append(b).append('\n');
			} else {
				output.append(b).append(" ").append(a).append('\n');
			}
		}
		System.out.print(output);
	}
}

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

int main(){
  int n,red=0; cin>>n;
  for(int i=0;i<n;i++){
    char a; cin>>a;
    if(a=='R')red++;
  }
  
  cout<<(red > n-red ? "Yes" : "No")<<endl;
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize(2)


#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/hash_policy.hpp>
#include<ext/pb_ds/trie_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#include<ext/rope>*/
//using namespace __gnu_cxx;
//using namespace __gnu_pbds;
//void err(istream_iterator<string> it){cerr<<endl;}
//template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args){cerr << *it << " = " << a << " , ";err(++it, args...);}
//#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mem(a,b) memset((a),b,sizeof((a)))
#define fpre(x) cout<<fixed<<setprecision(x)
#define clr(v) (v).clear()
#define pii pair<int,int>
#define pdd pair<double,double>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define mp make_pair
#define eb emplace_back
#define pb emplace_back
#define ll long long
#define ld long double
#define ull unsigned long long
#define uint unsigned int
#define ushort unsigned short
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define lowbit(i) (i&(-i))
#define lson rt<<1
#define rson lson|1
#define fi first
#define se second
const double eps=1e-7;
const double pi=acos(-1);
inline int dcmp(double x)
{
    if(x<-eps)
        return -1;
    if(x>eps)
        return 1;
    return 0;
}
//-----------------------------------------------head


int main()
{
    int a;
    while(cin>>a)
        if(a%2)
        cout<<2*a<<endl;
    else cout<<a<<endl;
}
















/*
























*/









Measured memory_bytes: 256
def main():
    mod = 10**9 + 7
    N, K = map(int, input().split())
    ans = 0
    for i in range(K, N+2):
        max = (N * i - 2 * (((i-1)*i)//2))%mod
#         min = (((i-1)*i)//2)%mod
        ans += max + 1
    print(ans%mod)
    
        
    
    
    
if __name__ == '__main__':
    main()

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

int main(){

    string s ;
    cin >> s ;
    int counter = 0;
    int flag = 0;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'R') cout << 3 << endl;
    if(s[0] == 'S' && s[1] == 'R' && s[2] == 'R') cout << 2 << endl;
    if(s[0] == 'R' && s[1] == 'S' && s[2] == 'R') cout << 1 << endl;
    if(s[0] == 'R' && s[1] == 'R' && s[2] == 'S') cout << 2 << endl;
    if(s[0] == 'S' && s[1] == 'S' && s[2] == 'R') cout << 1 << endl;
    if(s[0] == 'S' && s[1] == 'R' && s[2] == 'S') cout << 1 << endl;
    if(s[0] == 'R' && s[1] == 'S' && s[2] == 'S') cout << 1 << endl;
    if(s[0] == 'S' && s[1] == 'S' && s[2] == 'S') cout << 0 << endl;
    




}

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

struct _Node{
  int key;
  struct _Node *next;
  struct _Node *prev;
};
typedef struct _Node Node;

Node *nil;

void insert(int key) {
  Node *n;
  n = (Node *)malloc(sizeof(Node));
  n->key = key;
  n->next = nil->next;
  nil->next = nil->next->prev = n;
  n->prev = nil;
}

void deleteNode(Node *n) {
  n->prev->next = n->next;
  n->next->prev = n->prev;
}

void delete(int key) {
  Node *n;
  for (n = nil->next; n != nil; n = n->next) {
    if (n->key == key) {
      deleteNode(n);
      return;
    }
  }
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

int main() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
  int i, key, N;
  char *command;
  command = (char *)malloc(sizeof(char) * 12);

  scanf("%d", &N);
  for (i = 0; i < N; i++) {
    *(command + 6) = ' ';
    scanf(" %s", command);
    switch(*command) {
    case 'i':
      scanf(" %d", &key);
      insert(key);
      break;
    default :
      switch(*(command + 6)) {
      case 'F':
        deleteFirst();
        break;
      case 'L':
        deleteLast();
        break;
      default:
        scanf(" %d", &key);
        delete(key);
        break;
      }
    }
  }

  Node *node;
  for (node = nil->next;; node = node->next) {
    if (node->next == nil) {
      printf("%d\n", node->key);
      break;
    }
    printf("%d ", node->key);
  }
  return 0;
}



Measured memory_bytes: 36096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[2001][2001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	#ifndef ONLINE_JUDGE
	    // for getting input from input.txt
	    freopen("input.txt", "r", stdin);
	    // for writing output to output.txt
	    freopen("output.txt", "w", stdout);
	#endif
	   ll s,w;
	   cin>>s>>w;
	   if(w>=s)
	   	cout<<"unsafe";
	   else
	   	cout<<"safe";
}

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

int main() {
    int n, m;
    cin >> n >> m;
    if ((n * m) % 2) {
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                Map hs = new HashMap();
                PrintWriter ou = new PrintWriter(System.out);
                int n = Integer.parseInt(sc.next());
                boolean ebishu = true;
                for(int i = 0 ; i < n && ebishu ; i++){
                        if(Integer.parseInt(sc.next()) % 2 != 0) ebishu = false;
                }
                sc.close();
                if(ebishu) ou.print("second\n");
                else ou.print("first\n");
                ou.flush();
        }
}

Measured memory_bytes: 58020
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '9'){
			cout << "Yes"<<endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import combinations

S = input()
cands = [S[i:j] for i, j in combinations(range(len(S)+1), 2)]
ans = 0
for s in cands:
    flag = True
    for c in s:
        if c not in ['A', 'T', 'G', 'C']:
            flag = False
            break
    if flag and ans < len(s):
        ans = len(s)
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
  int k,x,i;
  cin>>k>>x;
  for(i=x-k+1;i<=x+k-1;i++){
    cout<<i;
    if(i==x+k-1) cout<<endl;
    else cout<<' ';
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long a, b, c, d, tmp1, tmp2, tmp3, tmp4, good1, good2;
    cin >> a >> b >> c >> d;

    tmp1 = a*c;
    tmp2 = a*d;
    tmp3 = b*c;
    tmp4 = b*d;

    if(tmp1 < tmp2) {
        good1 = tmp2;
    } else {
        good1 = tmp1;
    }
    if(tmp3 < tmp4) {
        good2 = tmp4;
    } else {
        good2 = tmp3;
    }

    if(good1 > good2) {
        cout << good1 << endl;
    } else {
        cout << good2 << endl;
    }

    return 0;
}

Measured memory_bytes: 3644
#include <stdio.h>




int main(void)
{
    char S[3];
    int count = 0;
    scanf("%s", S);
    for (int i = 0; i < 3; i++) {
        if (i == 0 && S[i] == 'R') {
            count += 1;
        }
        else {
            if (S[i] == 'R' && S[i-1] == 'R') {
                count += 1;
            } else if (S[i] == 'R' && count == 0) {
                count += 1;
            } else {
                continue;
            }
        }
    }
    printf("%i", count);
    return 0;
}

Measured memory_bytes: 1732
import collections
import copy

S = list(input())
len_s = len(S)
S_count = collections.Counter(S)

ans = {}

for key in S_count:
    if len(set(S)) == 1:
        ans[key] = 0
    else:
        new_S = copy.copy(S)
        count = 0
        while len(set(new_S)) != 1:
            count += 1
            old_S = copy.copy(new_S)
            new_S = []
            for i in range(len(old_S)-1):
                if old_S[i] == key or old_S[i+1] == key:
                    new_S.append(key)
                else:
                    new_S.append(old_S[i])

        ans[key] = count
print(min(ans.values()))

Measured memory_bytes: 40304
def main():
    n = int(input())
    A = []
    for _ in range(n):
        A.append(input())
    m = int(input())
    B = []
    for _ in range(m):
        B.append(input())
    
    ans = 0
    A_set = list(set(A))
    for i in range(len(A_set)):
        tmp = 0
        for j in range(len(A)):
            if(A_set[i] == A[j]):
                tmp += 1
        for j in range(len(B)): 
            if(A_set[i] == B[j]):
                tmp -= 1
        ans = max(ans, tmp)
    print(ans)

    
if __name__ == "__main__":
    main()

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);

//from ok 2018-12-02 must retry
//condate=18-12-4

struct Node{
	int key;
	Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while(x != NIL){
		y = x;
		if(z->key < x->key){
			x = x->left;
		} else {
			x = x->right;
		}
	}
	z->parent = y;
	if( y == NIL){
		root = z;
	} else {
		if(z->key < y->key){
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

bool find(int k, Node *u){
	if(u == NIL) return false;
	if(u->key == k) return true;
	return (u->key > k)?find(k,u->left):find(k,u->right);
}

Node * treeMinimum(Node *x){
	while(x->left != NIL) x = x->left;
	return x;
}

Node * _find(Node *u, int k){
	while(u != NIL && k != u->key){
		if(k < u->key) u = u ->left;
		else u = u->right;
	}
	return u;
}

Node * treeSuccessor(Node * x){
	if(x->right != NIL) return treeMinimum(x->right);
	Node  *y = x->parent;
	while(y != NIL && x == y->right){
		x = y;
		y = y->parent;
	}
	return y;
}
void treeDelete(Node *z){
	Node *y;
	Node *x;
	
	if(z->left == NIL  || z->right == NIL) y = z;
	else y = treeSuccessor(z);
	
	if(y->left != NIL){
		x = y->left;
	} else {
		x = y->right;
	}
	
	if(x != NIL){
		x->parent = y->parent;
	}
	
	if(y->parent == NIL){
		root = x;
	} else {
		if(y == y->parent->left){
			y->parent->left = x;
		} else {
			y->parent->right = x;
		}
	}
	
	if(y != z){
		z->key = y->key;
	}
	
	free(y);
}

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

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

signed main(){
	int n;
	string s;
	
	cin>>n;
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++){
		// scanf("%s", s);
		cin>>s;
		if(s == "print"){
			inorder(root);
			printf("\n");
			preoder(root);
			printf("\n");
		} else if(s == "insert"){
			int x;
			scanf("%d", &x);
			insert(x);
		} else if(s == "find"){
			int k;
			scanf("%d", &k);
			printf(("%s",find(k,root)?"yes":"no"));
			printf("\n");
		} else if(s == "delete"){
			int k;
			scanf("%d", &k);
			treeDelete(_find(root,k));
		}
	}
	
	return 0;
}



Measured memory_bytes: 22032
#include <bits/stdc++.h>
#include<unordered_map>
using namespace std;
unordered_map<string, bool> vis;
int main() {
	int n;
	cin >> n;
	int ans = 0;
	while (n--) {
		
		string s;
		cin >> s;
		if (!vis[s]) {
			ans++;
			vis[s] = 1;
		}
	}
	cout << ans;
}

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

long long combinationOfChosingTwo(int num)
{
    return (long long)num * (num - 1) / 2;
}

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

    vector<int> ballVec, numCountVec(n + 1, 0);

    for (int i = 0; i < n; ++i)
    {
        int input;
        cin >> input;

        ballVec.push_back(input);
        ++numCountVec.at(input);
    }

    vector<long long> combinationNumVec(n + 1, 0), combinationOfMissingOneVec(n + 1, 0);

    long long combinationSum = 0;

    for (int i = 1; i <= n; ++i)
    {
        long long combination = combinationOfChosingTwo(numCountVec.at(i));

        combinationNumVec.at(i) = combination;
        combinationOfMissingOneVec.at(i) = combinationOfChosingTwo(numCountVec.at(i) - 1);

        combinationSum += combination;
    }

    for (const int &numOnMissingBall : ballVec)
    {
        long long sumOfCombi = combinationSum - combinationNumVec.at(numOnMissingBall) + combinationOfMissingOneVec.at(numOnMissingBall);

        cout << sumOfCombi << endl;
    }
}

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

int findSumOfDigits (int n){
  int sum = 0;
  while (n > 0){
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main(){
  int n;
  cin >> n;
  if(n % findSumOfDigits(n) == 0)
    cout << "Yes" << endl;
  else 
    cout << "No" << endl;
}

Measured memory_bytes: 256
/*

Sviatoslav Bidzilia 2019
CF: anakib1

*/

#include <iostream>
#include <cmath>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
#include <bitset>
#include <map>
#include <chrono>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <list>
#include <deque>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdarg.h>
#include <utility>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unisgned long long
#define ld long double
#define all(a) a.begin(), a.end()
#define SORT(a) sort(all(a))
#define pii pair<int, int>
#define tii triple<int, int, int>
#define e 1e-7
#define PI acos(-1)
#define inf 1e17
#define vi vector<int>
#define F first
#define S second
#define rng(x) for(int _ = 0; _ < (x); _++)
#define rngi(i, x) for(int i = 0; i < (x); i++)
#define rngsi(s, i, x) for(int i = (s); i <(x); i++)
#define int long long

template<typename A, typename B, typename C>
struct triple
{
	A X;
	B Y;
	C Z;
	triple(A a = 0, B b = 0, C c = 0) :X(a), Y(b), Z(c) {}
};
template<typename A, typename B, typename C>
triple<A, B, C> make_triple(A a = 0, B b = 0, C c = 0)
{
	return triple<A, B, C>(a, b, c);
}
template<typename A, typename B, typename C>
bool operator<(const triple<A, B, C>& a, const triple<A, B, C>& b)
{
	if (a.X != b.X)
		return a.X < b.X;
	if (a.Y != b.Y)
		return a.Y < b.Y;
	return a.Z < b.Z;
}
template<typename T, typename SS>
ostream& operator<<(ostream& ofs, const pair<T, SS>& p)
{
	ofs << "( " << p.F << " , " << p.S << " )";
	return ofs;
}
template<typename T>
void print(T a)
{
	for (auto i : a)
		cout << i << ' ';
	cout << '\n';
}
template<typename T>
T max(T a, T b, T c)
{
	return max(a, max(b, c));
}
template<typename T>
T min(T a, T b, T c)
{
	return min(a, min(b, c));
}
struct custom_hash
{
	static uint64_t splitmix64(uint64_t x)
	{
		x += 0x9e3779b97f4a7c15;
		x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
		x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
		return x ^ (x >> 31);
	}

	size_t operator()(uint64_t x) const
	{
		static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
		return splitmix64(x + FIXED_RANDOM);
	}
};
signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	srand(time(NULL));
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a > 9 || b > 9)
		return cout << "-1\n", 0;
	cout << a * b << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    string s; cin >> s;
    rep(i, s.length()) s[i] = 'x';
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 888
import bisect
N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N-1,1,-1):
  for j in range(i-1,0,-1):
    t = bisect.bisect(L, L[i]-L[j])
    if j-t>0: ans+=j-t
print (ans)

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


void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

int main()
{
    fastIO();

    long long n, t=0, ans = 0, ansp = 0;
    cin >> n;
    vector<long long> arr(n);
    for(int i=0;i<n;i++){
        cin >> arr[i];
        t+=arr[i];
    }
    t=(t/n);
    for(int i=0;i<n;i++){
        ans+=((arr[i]-t)*(arr[i]-t));
    }
    for(int i=0;i<n;i++){
        ansp+=((arr[i]-(t+1))*(arr[i]-(t+1)));
    }
    cout << min(ansp, ans) << '\n';

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :???8:45 9:41
// 2nd 10:43 11:55
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>

using namespace std;
const long long INF=2000000000000001;

int main() {
	int N,M,K;
	cin>>N>>M>>K;
	long long A;

	long long R=0;
	long long dp[1001]={};
	long long dMax[1001]={};
	long long dMin[1001]={}
	;
	for(long long j=M;j>0;--j){
		dMin[j]=INF;
		dp[j]=INF;
	}
	for(int i=0;i<N;++i){
		cin>>A;
		R=R+K;
		for(long long j=M;j>1;--j){
			dMax[j]=max(dMax[j-1],A);
			dMin[j]=min(dMin[j-1],A);
			dp[j]=dp[j-1]-(j-1)*(dMax[j-1]-dMin[j-1])+j*(dMax[j]-dMin[j]);
			R=min(R,dp[j]);
		}
		dp[1]=dp[0]+K;
		dMax[1]=A;dMin[1]=A;
		dp[0]=R;
	}

	cout<<R<<endl;


}

Measured memory_bytes: 3112
/**
 *    author:  math2do
 *    created: 31.05.2020 17:31:32
**/

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> v(m);
	rep(i,n){
		int k;
		cin >> k;
		rep(j,k){
			int a;
			cin >> a;
			v[--a]++;
		}
	}
	int count = 0;
	rep(i,m){
		if(v[i] == n) count++;
	}
	cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

using ll = long long;
const ll INF = 1e18L + 5;
const int mod = 1e9 + 7;

int n;
string k;

void add(int& a, int b){
    a += b;
    if(a >= mod){
        a -= mod;
    }
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    cin >> k;
    int D;
    cin >> D;
    vector<vector<int>> dp(D, vector<int>(2));
    //dp[sum][smaller_already] number of ways to chose digits so far such that the sum of digits modulo D is sum and smaller already says whether we already chosen some digit smaller than in K
    int len = k.size();
    dp[0][0] = 1;
    for(int where = 0; where < len; where++){
        vector<vector<int>> newDp(D, vector<int>(2));
        for(int sum = 0; sum < D; sum++){
            for(bool sm_already : {false, true}){
                for(int digit = 0; digit < 10; digit++){
                    if(digit > k[where] - '0' && !sm_already){
                        break;
                    }
                    add(newDp[(sum + digit) % D][sm_already || (digit < k[where] - '0')], dp[sum][sm_already]);
                }
            }
        }
        dp = newDp;
    }
    int answer = dp[0][false] + dp[0][true];
    answer %= mod;
    answer--;
    if(answer == -1){
        answer = mod - 1;
    }
    cout << answer;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    string s;
    cin>>s;
    int l=4;
    bool ans=false;
    if(s[0]==s[1]){
        if(s[2]==s[3] &&s[0]!=s[2])ans=true;
    }else if(s[0]==s[2]){
        if(s[1]==s[3] &&s[0]!=s[1])ans=true;
    }else if(s[0]==s[3]){
        if(s[1]==s[2] &&s[0]!=s[1])ans=true;
    }

    string answer=(ans)?"Yes":"No";

    cout<<answer<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
using namespace std;
typedef long long LL;
#define ms(a,b) memset(a,b,sizeof(a))
#define eps 1e-8
const int MAXN=1e5+100;

int a,b,c,d;
int ok=0;
void dfs(int i,int j,int k)
{
    if(ok==1) return ;
    int sum=a;
    if(i==0) sum+=b;
    else sum-=b;
    if(j==0) sum+=c;
    else sum-=c;
    if(k==0) sum+=d;
    else sum-=d;
    if(sum==7){
        cout<<a;
        if(i==0) cout<<"+";
        else cout<<"-";
        cout<<b;
        if(j==0) cout<<"+";
        else cout<<"-";
        cout<<c;
        if(k==0) cout<<"+";
        else cout<<"-";
        cout<<d<<"=7"<<endl;
        ok=1;
    }
}
int main ()
{
    int N;
    cin>>N;
    d=N%10;
    c=N/10%10;
    b=N/100%10;
    a=N/1000%10;
    dfs(0,0,0);
    dfs(0,0,1);
    dfs(0,1,0);
    dfs(1,0,0);
    dfs(1,1,0);
    dfs(1,0,1);
    dfs(0,1,1);
    dfs(1,1,1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main(){
    int n; cin >> n;
    int mx=0, ans=1;
    for(int i=n; i > 0; i--){
        int cnt =0, cur=i;
        while(true) {
            if (cur % 2 != 0) {
                break;
            }else{
                cnt++;
                cur /= 2;
            }
        }
        if(cnt > mx){
            mx = cnt;
            ans=i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;
using vi=vector<int>;
using vc=vector<char>;
using vs=vector<string>;
using vvi =vector<vector<int>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
int main(){
    int n,a=0,b=0,c=1;
    cin>>n;
    vector<int>p(n);
    vi q(n),t(n);
    rep(i,n){
        cin>>p[i];
        t[i]=p[i];
    }
    sort(t.begin(),t.end());
    rep(i,n)cin>>q[i];
    do{
        bool ok=true,ok1=true;;
        rep(i,n){
            if(p[i]!=t[i])ok=false;
            if(q[i]!=t[i])ok1=false;
        }
        if(ok1)b=c;
        if(ok)a=c;
        c++;

    }while(next_permutation(t.begin(),t.end()));
    cout<<abs(a-b)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long int;

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

  vector<double> v;

  for (size_t i = 0; i < n; i++) {
    double p;
    cin >> p;
    v.push_back(p);
  }

  double sum = 0;
  for (size_t i = 0; i < k; i++) {
    sum += (v[i] + 1.0) / 2.0;
  }

  double ans = sum;
  for (size_t i = k; i < n; i++) {
    double next = (v[i] + 1.0) / 2.0;
    double prev = (v[i-k] + 1.0) / 2.0;

    sum = sum + next - prev;
    ans = max(ans, sum);
  }

  cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 2420
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int a,t,r;cin>>a>>t>>r;



	cout << fixed << setprecision(10) << (double)r/a*t << endl;


}



Measured memory_bytes: 3312
import java.util.Scanner;

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

        int a=sc.nextInt();
        int b=sc.nextInt();
        
        System.out.print(a/b+" "+a%b+" ");
        System.out.printf("%f\n",(double) a/(double) b);
        }

    
}


Measured memory_bytes: 26428
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define REEP(i, N) for(ll i = N - 1; i >= 0; --i)
#define FOR(i,m,n) for(ll i = m; i < n; ++i)
#define RFOR(i,m,n) for(ll i = n - 1; i >= m; --i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define PB push_back
#define KIRIAGE(a, b) a += (b - a % b) % b // a を b の倍数値まで増やす
#define CEIL(c, a, b) if(a % b == 0) { c = a / b;} else { c = a / b + 1;} // a / b 以上の最小整数
#define sp(n) setprecision(n)
#define INF 1000000000
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
int dx8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	int a, b;
	cin>>a>>b;
	int ans = -1;
	if(a < 0) {
		if(b < 0) {
			if((b - a) % 2) ans = 1;
			else ans = 2;
		} else ans = 0;
	} else if(a == 0) ans = 0;
	else ans = 1;
	switch(ans) {
		case 0: cout<<"Zero"<<endl; break;
		case 1: cout<<"Positive"<<endl; break;
		case 2: cout<<"Negative"<<endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,w;

int bfs(int s_h, int s_w, vector<vector<int>> &maze){
    queue<int> q;
    vector<vector<int>> dist(h,vector<int>(w,-1));
    int p;
    p = s_h*w+s_w;
    q.push(p);
    dist.at(s_h).at(s_w) = 0;
    while(!q.empty()){
        int front;
        front = q.front();
        int f_h = front/w;
        int f_w = front%w;
        for(int i=-1;i<=1;i++){
            for(int j=-1; j<=1; j++){
                if(0<=f_h+i && f_h+i<h){
                    if(0<=f_w+j && f_w+j<w){
                        if(i+j==1 || i+j==-1){
                            if(maze.at(f_h+i).at(f_w+j)==1){
                                if(dist.at(f_h+i).at(f_w+j)==-1){
                                    dist.at(f_h+i).at(f_w+j)
                                      = dist.at(f_h).at(f_w) + 1;
                                    q.push((f_h+i)*w + f_w+j);
                                }
                            }
                        }
                    }
                }
            }
        }
        q.pop();
    }
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            ans = max(ans, dist.at(i).at(j));
        }
    }
    return ans;
}

int main(){
    cin >> h >> w;
    vector<vector<int>> maze(h, vector<int>(w));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            char c;
            cin >> c;
            if(c=='.') maze.at(i).at(j) = 1;
            else maze.at(i).at(j) = 0;
        }
    }
    int ans=0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maze.at(i).at(j) == 1){
                int dist;
                dist = bfs(i, j, maze);
                ans = max(ans, dist);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;

void solve() {
	int X; cin >> X;
	int c = X / 500;
	ll ans = 0;
	ans += c * 1000;
	X -= c * 500;
	ans += X / 5 * 5;
	print(ans);
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

const double EPS=1e-9;

signed main(){
    double d;scanf("%lf",&d);

    double ans=d*sqrt(2);

    rep(i,10+1){
        if(i>d+EPS)break;
        double x=sqrt(d*d-i*i);
        if(x+EPS>1)chmax(ans,x+i);
        else chmax(ans,i+1);
    }
    printf("%.20f\n",ans);
    return 0;
}

Measured memory_bytes: 3196
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    ll Q,H,S,D; cin >> Q >> H >> S >> D;
    ll N; cin >> N;

    ll m = min(8*Q,min(4*H,min(2*S,D)));
    ll m2 = min(4*Q,min(2*H,S));
    ll ans = 0;

    if(m == 8*Q) ans = 4*Q*N;
    if(m == 4*H) ans = 2*H*N;
    if(m == 2*S) ans = S*N;
    if(m == D){
        if(N % 2 == 0) ans = D*N/2;
        else{
            ans = D*(N/2) + m2;
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<sstream>
#include<map>
using namespace std;
#define int long long
int N[4];
int sum;
int M;
map<string, int> mp;
vector<vector<string> > A;
vector<vector<string> > B;
vector<vector<int> > C;
bool ok = true;
const int MOD = 1000000007;
void rec(int i) {
	for (int j = 0; j < A[i].size(); j++) {
		if (!ok)break;
		if (A[i][j][0] <= 'Z') {
			B[i].push_back(A[i][j]);
		}
		else {
			int k = mp[A[i][j]];
			if ((int)B[k].size() == 0) {
				rec(k);
			}
			if (!ok)break;
			for (int l = 0; l < B[k].size(); l++) {
				B[i].push_back(B[k][l]);
			}
		}
		if (!ok)break;
	}
	if ((int)B[i].size() > 200) {
		ok = false;
	}
}
int dp[51][51][51][51];
int solve(const int n[4]) {
	if (dp[n[0]][n[1]][n[2]][n[3]] >= 0) {
		return dp[n[0]][n[1]][n[2]][n[3]];
	}
	int T[4];
	int s = sum;
	int res = 0;
	for (int i = 0; i < 4; i++) {
		T[i] = n[i];
		s -= n[i];
	}


	for (int i = 0; i < 4; i++) {
		if (T[i] > 0 && C[s][i] == 1) {
			T[i]--;
			res = (res + solve(T)) % MOD;
			T[i]++;
		}
	}
	//res = 0;
	//cerr << n[0] << " " << n[1] << " " << N[2] << " " << N[3] << " " << res << endl;
	return dp[n[0]][n[1]][n[2]][n[3]] = res;
}
signed main() {


	cin >> N[0] >> N[1] >> N[2] >> N[3];
	sum = N[0] + N[1] + N[2] + N[3];
	cin >> M;
	cin.ignore();
	vector<string> S(M);
	A.resize(M);
	B.resize(M);
	string X;
	for (int i = 0; i < M; i++) {
		getline(cin, S[i]);
		stringstream ss(S[i]);
		ss >> X;
		X.pop_back();
		mp[X] = i;
		while (ss >> X) {
			//cerr << X << endl;
			if (X[0] == '[') {
				//cerr << X << endl;
				X.erase(X.begin());
				X.pop_back();
				sort(X.begin(), X.end());
				X.erase(unique(X.begin(), X.end()), X.end());
			}
			//cerr << i << " " << X << endl;
			A[i].push_back(X);
		}
	}
	
	rec(0);
	if (ok) {
		ok = (B[0].size() == sum);
	}
	if (!ok) {
		cout << 0 << endl;
		return 0;
	}
	/*for (int i = 0; i < B[0].size(); i++) {
		cerr << B[0][i] << " ";
	}
	cerr << endl;*/
	//cerr << (ok ? "ok" : "ng") << endl;
	for (int i0 = 0; i0 <= N[0]; i0++) {
		for (int i1 = 0; i1 <= N[1]; i1++) {
			for (int i2 = 0; i2 <= N[2]; i2++) {
				for (int i3 = 0; i3 <= N[3]; i3++) {
					dp[i0][i1][i2][i3] = -1;
				}
			}
		}
	}
	dp[0][0][0][0] = 1;
	C.resize(sum, vector<int>(4, 0));
	for (int i = 0; i < sum; i++) {
		for (int j = 0; j < B[0][i].size(); j++) {
			if (B[0][i][j] == 'A')C[i][0] = 1;
			else if (B[0][i][j] == 'T')C[i][1] = 1;
			else if (B[0][i][j] == 'G')C[i][2] = 1;
			else if (B[0][i][j] == 'C')C[i][3] = 1;
		}
	}
	
	/*for (int i = 0; i < sum; i++) {
		for (int j = 0; j < 4; j++) {
			cerr << C[i][j] << " ";
		}
		cerr << endl;
	}*/
	cout << solve(N) << endl;
}


Measured memory_bytes: 55096
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a%3==0||b%3==0||(a+b)%3==0)
			System.out.println("Possible");
		else
			System.out.println("Impossible");
	}
}


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

using namespace std;

struct edge {
	int u, v, w;
};

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

	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> edges(m);
	vector<vector<int>> g(n);
	for (int i = 0; i < m; ++i) {
		int u, v, w;
		cin >> u >> v >> w;
		g[u - 1].push_back(v - 1);
		edges[i].u = --u;
		edges[i].v = --v;
		edges[i].w = p - w;
	}
	const int inf = 1e9;
	vector<int> d(n, inf);
	d[0] = 0;
	vector<int> kek;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (d[edges[j].u] < inf and d[edges[j].v] > d[edges[j].u] + edges[j].w) {
				d[edges[j].v] = d[edges[j].u] + edges[j].w;
				if (i == n - 1) {
					kek.push_back(edges[j].v);
				}
			}
		}
	}
	vector<bool> used(n);
	function<void(int)> dfs = [&](int v) {
		used[v] = true;
		for (int to : g[v]) {
			if (used[to]) {
				continue;
			}
			dfs(to);
		}
	};
	for (int v : kek) {
		if (!used[v]) {
			dfs(v);
			if (used[n - 1]) {
				cout << -1;
				return 0;
			}
		}
	}
	cout << max(0, -d[n - 1]);

	return 0;
}


Measured memory_bytes: 512
require("fs").readFileSync("/dev/stdin","utf8").trim().split('\n').forEach(function(z){i=z.split(' ');console.log(x=((i[2]*i[4]-i[1]*i[5])/(i[0]*i[4]-i[1]*i[3])).toFixed(3),((i[2]-i[0]*x)/i[1]).toFixed(3))})

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define repb(i, l, n) for (int64_t i = l; i < n; ++i)
#define repb2(i, l, n) for (int64_t i = l; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;  } return 0;  }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;  } return 0;  }
template<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

int main() {
    string s;
    cin >> s;
    int64_t ans = 0;
    rep(i, s.length()) {
        int64_t num = s[i]-'0';
        ans += num;
    }
    cout << ( (ans%9 == 0) ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 3752
n,k = map(int,input().split())
ans = 0
for i in range(1,n+1):
    c = 0
    a =i
    # print('i',i)
    while(a<k):
        a+=a
        c+=1
        # print('a,',a)
    ans += (1/2)**c * (1/n)
print(ans)

Measured memory_bytes: 3060
# import sys
# input = sys.stdin.readline
import collections

def main():
    n, m = input_list()
    Friend = [[] for i in range(n+1)]
    for _ in range(m):
        a, b = input_list()
        Friend[a].append(b)
        Friend[b].append(a)
    Flag = [False for i in range(n+1)]
    ans = 1
    for i in range(1, n+1):
        if Flag[i]:
            continue
        q = collections.deque()
        q.append(i)
        cnt = 1
        while q:
            st = q.popleft()
            Flag[st] = True
            for j in Friend[st]:
                if Flag[j]:
                    continue
                cnt += 1
                Flag[j] = True
                q.append(j)
            ans = max(ans, cnt)
    print(ans)


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		ans += min(x, K - x) * 2;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int main() {
	string S, T;
	cin >> S >> T;
	for (int i = S.size() - T.size(); i >= 0; --i) {
		bool b = true;
		for (int j = 0; j < T.size(); ++j) {
			if (S[i + j] != '?') {
				if (S[i + j] != T[j]) {
					b = false;
				}
			}
		}
		if (b) {
			for (int j = 0; j < S.size(); ++j) {
				if ((j < i) || ((i + T.size()) <= j)) {
					if (S[j] == '?') {
						S[j] = 'a';
					}
				}
				else {
					S[j] = T[j - i];
				}
			}
			cout << S << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
int dp[105][4][2];
int main(){
  string s;cin>>s;
  int n=s.size(),k;cin>>k;
  dp[0][0][0]=1;
  rep(i,n)rep(j,4)rep(l,2){
    int nd=s[i]-'0';
    rep(x,10){
      int ni=i+1,nj=j,nl=l;
      if(x!=0)nj++;
      if(nj>k)continue;
      if(nl==0){
        if(x>nd)continue;
        if(x<nd)nl=1;
      }
      dp[ni][nj][nl]+=dp[i][j][l];
    }
  }
  cout<<dp[n][k][0]+dp[n][k][1];
}

Measured memory_bytes: 256