akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

main() {
    int N; cin >> N;
    if(N>=1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import heapq
from typing import List, Tuple, Dict
from dataclasses import dataclass, field

import scipy
import numpy as np
from numba import njit

D = int(input())  # 日数 D = 365
C = np.array(list(map(int, input().split())), dtype='int32')  # 満足度の下がりやすさ 26個
S = np.array([list(map(int, input().split())) for _ in range(D)], dtype='int32')  # d日目にコンテストiを行ったときの満足度

@dataclass()
class Node:
    value: int
    plan: List[int]
    last: List[int]

    def __lt__(self, other) -> bool:
        return self.value > other.value  # PriorityQueueで最大値が欲しいので逆に

CAPACITY = 20

queue: List[Node] = [Node(0, [], [0 for _ in range(26)])]
for d in range(D):
    next_queue: List[Node] = []

    heapq.heapify(queue)
    while queue:
        node = heapq.heappop(queue)

        for i in range(26):
            s = S[d][i] + C[i] * (d + 1 - node.last[i])

            next_queue.append(
                Node(
                    node.value + s,
                    node.plan + [i + 1],
                    node.last[:i] + [d + 1] + node.last[i + 1:]
                ),
            )

    queue = sorted(next_queue)[:CAPACITY]

res_node = heapq.heappop(queue)
print(res_node, file=sys.stderr)
print('\n'.join(map(str, res_node.plan)))


Measured memory_bytes: 95228
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

int main() {
    string s;
    cin >> s;
    int cntgroup = 1;
    for (int i = 1; i < (int)s.length(); ++i)
        if (s[i] != s[i - 1])
            ++cntgroup;
    cout << cntgroup - 1 << endl;
}

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

using namespace std;

#define LIMIT 100
typedef int64_t ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll x, y; cin >> x >> y;
  int o = 1;
  while(x*2 <= y){
    x *= 2;
    o++;
  }
  std::cout << o << std::endl;


  return 0;
}


Measured memory_bytes: 256
z='abcdefghijklmnopqrstuvwxyz'
e=lambda x,i,j:z[(z.index(x)*i+j)%26]
def f():
 for i in range(1,26,2):
  for j in range(26):
   if''.join(e(c,i,j)for c in'that')in s or''.join(e(c,i,j)for c in'this')in s:return(i,j)
for _ in[0]*int(input()):
 s=input()
 print(s.translate(str.maketrans(''.join(e(c,*f())for c in z),z)))


Measured memory_bytes: 5608
import numpy as np
x,y=list(map(int,input().split()))
A=[[1,1],[2,4]]
b=[x,y]
c,d=np.linalg.solve(A,b)

if c>=0 and d>=0 and c==int(c) and d==int(d):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27368
#include <bits/stdc++.h>
using namespace std;
#define x_ real()
#define y_ imag()
#define cross(a, b) (conj(a)*(b)).imag()
#define dot(a, b) (conj(a)*(b)).real()
#define PI acos(-1)
#define F first
#define S second
#define fastIO ios_base::sync_with_stdio(false), cin.tie(NULL)
#define fileIO freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef complex<ld> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
typedef pair<double, double> pd;
pair<int, int> dirs[] = { {1, 2}, {-1, 2}, {2, 1}, {2, -1}, {-2, 1}, {-2, -1}, {1, -2}, {-1, -2} };



int main() {
	fastIO;
	int n;
	cin >> n;
	vector<int> openMasks;
	for (int i = 0; i < n; i++) {
		int mask = 0;
		for (int j = 0; j < 10; j++) {
			int bit;
			cin >> bit;
			mask |= (bit << (10-j-1));
		}
		openMasks.push_back(mask);

	}

	int profits[n][11];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 11; j++) {
			cin >> profits[i][j];
		}
	}

	ll mx = -1e18;

	for (int i = 1; i < (1 << 10); i++) {
		ll p = 0;
		for (int j = 0; j < n; j++) {
			int mask = openMasks[j] & i;
			int idx = __builtin_popcount(mask);
			p += profits[j][idx];
		}
		mx = max(mx, p);
	}

	cout << mx;



}


Measured memory_bytes: 256
d = int(input()) #日にちは-1indexで
c = list(map(int, input().split()))
csum = 0
for i in range(26):
    csum += c[i]
s = [ [] for _ in range(d)]
for i in range(d):
    s[i] = list(map(int, input().split()))
t = [0 for _ in range(d)]
lastDI = [-1 for _ in range(26)]
for i in range(d):
    maxp = -1001002003
    for j in range(26):
        tmp = s[i][j]
        for k in range(26):
            if (j != k):
                tmp -= c[j]*(i-lastDI[k])
        if (tmp > maxp):
            maxp = tmp
            t[i] = j
    lastDI[t[i]] = i
    print(t[i]+1)

Measured memory_bytes: 9304
/*
Original problem: https://atcoder.jp/contests/dp/tasks/dp_c
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)


#define PII pair<int,int>
#define PLL pair<ll,ll>

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

namespace SOLVE {
    void main() {
        int n;
        cin >> n;

        vector < VLL > happiness(n, VLL(3));
        vector < VLL > dp(n, VLL(3)); // dp[i][j] is the best happiness after i days, last doing j
        REP(i, 0, n) {
            REP(j, 0, 3) {
                cin >> happiness[i][j];
            }
        }

        dp[0] = happiness[0]; // first day is the same! maximum
        REP(i, 1, n) {
            REP(j, 0, 3) {
                ll best = 0;
                REP(k, 0, 3) {
                    if (j != k) {
                        best = max(best, happiness[i][j] + dp[i - 1][k]);
                    }
                }
                dp[i][j] = best;
            }
        }

        ll ans = 0;
        REP(i, 0, 3) {
            ans = max(ans, dp[n - 1][i]);
        }
        cout << ans << endl;
    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		int a = sc.nextInt();
		long b = sc.nextLong();
		long n = sc.nextLong();
		if (n >= b) {
			System.out.println(a * (b - 1) / b - (a * ((b - 1) / b)));
		} else {
			System.out.println(a * (n) / b - (a * ((n) / b)));
		}

	}

	static class FastScanner {
		private BufferedReader reader;
		private StringTokenizer tokenizer;

		public FastScanner(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
			tokenizer = null;
		}

		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public String nextLine() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					return reader.readLine();
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}

			return tokenizer.nextToken("\n");
		}

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

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

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

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
	}
}

Measured memory_bytes: 32644
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>

#define PB push_back
#define MP make_pair
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
#define REP(i, n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;

bool graph[8][8];

int dfs(int v, int N, bool visited[8]) {
    bool all_visited = true;

    for (int i = 0; i < N; i++) {
        if (visited[i] == false) {
            all_visited = false;
        }
    }

    if (all_visited) {
        return 1;
    }

    int ret = 0;

    for (int i = 0; i < N; i++) {
        if (graph[v][i] == false)continue;
        if (visited[i])continue;

        visited[i] = true;
        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

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

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph[a - 1][b - 1] = graph[b - 1][a - 1] = true;
    }

    bool visited[8];
    for (int i = 0; i < n; i++) {
        visited[i] = false;
    }

    visited[0] = true;
    cout << dfs(0, n, visited) << endl;
    return 0;
}


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

#define MAX_LEN 2000000
#define MAX_VAL 10000

void countingSort(int n,int A[],int B[], int C[]){
	int i;
	for(i=0;i<MAX_VAL;i++){
		C[i]=0;
	}
	for(i=0;i<n;i++){
		C[A[i]]++;
	}
	
	int idx=0;
	for(i=0;i<MAX_VAL;i++){
		if(C[i]==0) continue;
		for(int j=0;j<C[i];j++){
			B[idx++]=i;
		}
	}
}

int main(){
	
	int n, A[MAX_LEN],B[MAX_LEN],C[MAX_VAL];
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}

	countingSort(n,A,B,C);
	
	cout << B[0];
	for(int i=1;i<n;i++){
		cout << " " << B[i];
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 18768
#include <iostream> // C++
using namespace std;

#define int long long

signed main(){

  int n;
  int r[200000];

  cin>>n;
  for(int i=0;i<n;i++) cin>>r[i];

  int min_r=11451419191,result=-11451419191;

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

    int sa=r[i]-min_r;

    result=max(result,sa);
    min_r=min(min_r,r[i]);

  }

  cout<<result<<endl;

  return 0;

}


Measured memory_bytes: 4640
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

const int MAX = 151;
const int INF = INT_MAX;

int main() {
	int H,W;
	while(cin >> H >> W && W) {
		int dia = H*H + W*W;	
		pair<int, int> ans = {MAX, MAX};
		bool check = false;
		
		int dia_tmp = 0;	
		REP(h, 1, MAX) {
			REP(w, h+1, MAX) {
				if(h > H && h != H)	{
					dia_tmp = h*h + w*w;
					if(dia == dia_tmp) {
						if(h < ans.first) {
							check = true;
							ans = {h, w};
						}
					}
				}
			}
		}

		int dia_now = 0;
		if(!check) {
			REP(h, 1, MAX) {
				REP(w, h+1, MAX) {
					dia_tmp = h*h + w*w;
					dia_now = ans.first*ans.first + ans.second*ans.second;
					if(dia < dia_tmp && dia_tmp < dia_now) {
						ans = {h, w};
					}
				}	
			}
		}
		cout << ans.first << " " << ans.second << endl;	
	}
	return 0;
}

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

int main() {
  
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  int res=0;
  
  if(A>=B && A>=C){ res= A*pow(2, K) +B +C; }
  else if(B>=C){ res= B*pow(2, K)+A+C; }
  else{ res = C*pow(2, K)+A+B; }

  
  cout << res << endl;

}

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

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
     	int x = sc.nextInt();
     	int count = 1;
     	int sum = 0;
     	while(true){
     		sum += count;
     		if(sum>=x){
     			break;
     		}
     		count++;
     	}   
     	System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>

#define ll long long

using namespace std;



int main()
{
    int n,i;
    cin>>n;
    int res = 0;
    for(i = 1 ; i <= n ; ++i)
    {
        int x = i;
        int cnt = 0;
        while(x)
            x/=10,++cnt;

        if(cnt&1)
            res++;
    }

    cout<<res;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
count1 = 0
count2 = 0
x.sort ()
ans1 = sum(x)//n
ans2 = ans1+1
for i in range(n):
    count1 += (x[i]-ans1)**2
    count2 += (x[i]-ans2)**2
print(min(count1,count2))

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  int n;
  long long int ans=0;
  cin>>n;
  vector<long long int> a(n,0),b(n,0);
  rep(i,n){
    cin>>a.at(i)>>b.at(i);
  }
  int k=0;
  for(int i=n-1;i>=0;i--){
    if(i!=n-1) a.at(i)+=ans;
    k=0;
    (a.at(i)%b.at(i)==0?k=0:k=b.at(i)-(a.at(i)%b.at(i)));
     ans+=k;
  }
  cout<<ans;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int A, P;

int main() {
	cin >> A >> P;
	cout << (A * 3 + P) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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; }

lli n, m;

int main(void){
    cin >> n >> m;
    vector<lli> v(n);
    rep(i, m){
        lli a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a]++;
        v[b]++;
    }
    bool ok = true;
    rep(i, n){
        if(v[i]%2 == 1) ok = false;
    }
    if(ok) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3900
#!usr/bin/env python3
import collections, heapq, itertools, bisect
import math, fractions
import sys, copy

from collections import defaultdict, deque, Counter, OrderedDict
from functools import reduce, lru_cache
from bisect import bisect_left, bisect_right

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def S(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]

alphabets = "abcdefghijklmnopqrstuvwxyz"

sys.setrecursionlimit(1000000)
dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
MOD = 1000000007

def main():
    s = S()
    t = S()

    chars = {ch: [] for ch in alphabets}

    for i, ch in enumerate(s):
        chars[ch].append(i)

    ans = 0
    last = -1
    for ch in t:
        if len(chars[ch]) == 0:
            print(-1)
            return

        idx = bisect_right(chars[ch], last)
        idx = idx if idx < len(chars[ch]) else 0
        if chars[ch][idx] > last:
            ans += chars[ch][idx] - last
        else:
            ans += len(s) - last + chars[ch][idx]
        last = chars[ch][idx]

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 93172
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll INF = pow(10,18);
#define rep(n) for(ll i=0; i<n; i++)

ll n,m;
vector<ll> a;
vector<ll> num;
vector<ll> dp;

void num_set()
{
  num.push_back(2);
  num.push_back(5);
  num.push_back(5);
  num.push_back(4);
  num.push_back(5);
  num.push_back(6);
  num.push_back(3);
  num.push_back(7);
  num.push_back(6);
}

ll dp_query(ll x)
{
  if(x<0) return -INF;
  return dp[x];
}

void dp_set(ll x)
{
  dp.push_back(0);
  // each iteration computes dp[i+1]
  for (ll i = 0; i < x; i++)
  {
    ll cur = -INF;
    for (ll j = 0; j < m; j++)
    {
      cur = max(cur,dp_query(i+1-num[a[j]-1]));
    }
    cur++;
    dp.push_back(cur);
  }
}

void ans(ll x)
{
  ll last = n;
  for (ll i = 0; i < x; i++)
  {
    for (int j = 0; j < m; j++)
    {
      if(dp_query(last-num[a[j]-1])==x-i-1) {
        last -= num[a[j]-1];
        cout << a[j];
        break;
      }
    }
  }
  cout << endl;
}

void print_vec(vector<ll> v)
{
  vector<ll>::iterator itr;
  for(itr = v.begin(); itr!=v.end(); itr++)
  {
    cout << *itr << endl;
  }
}

int main()
{
  num_set();
  cin >> n >> m;
  rep(m){
    ll tmp;
    cin >> tmp;
    a.push_back(tmp);
  }
  sort(a.begin(),a.end(),greater<ll>());
  dp_set(n);
  ans(dp[n]);
  return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 K; cin >> K;
    string S; cin >> S;
    if (S.length() <= K) {
        cout << S << endl;
        return 0;
    }

    string r = S.substr(0, K);
    cout << r << "..." << endl;

    return 0;
}

Measured memory_bytes: 3612
#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 x, y;
  cin >> x >> y;
  for (int c = 0; c <= x; c++) {
    int t = x-c;
    int asi = c*2+t*4;
    if (asi == y) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
"use strict";

const main = arg => {
  
    const input = arg.trim();

    const N = input;
    if (N[2] === N[3] && N[4] === N[5]) {
        console.log("Yes");
    } else {
        console.log("No");
    }
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
L = [int(x) for x in input()]
A, B, C, D = L[0], L[1], L[2], L[3]

if A+B+C+D == 7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A-B+C+D == 7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"+"+str(D)+"=7")
elif A+B-C+D == 7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A+B+C-D == 7:
    print(str(A)+"+"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A-B-C+D == 7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"+"+str(D)+"=7")
elif A-B+C-D == 7:
    print(str(A)+"-"+str(B)+"+"+str(C)+"-"+str(D)+"=7")
elif A+B-C-D == 7:
    print(str(A)+"+"+str(B)+"-"+str(C)+"-"+str(D)+"=7")
elif A-B-C-D == 7:
    print(str(A)+"-"+str(B)+"-"+str(C)+"-"+str(D)+"=7")


Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	// Code for A - AtCoder Beginner Contest 999
	var n string
	fmt.Scanf("%s", &n)

	for i := 0; i < 3; i++ {
		if n[i] == '1' {
			fmt.Printf("9")
		} else {
			fmt.Printf("1")
		}
	}
	fmt.Printf("\n")
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int a, b, t; cin >> a >> b >> t;
        int time = 0, cnt = 0;
        while (time + a <= t + 0.5) cnt += b, time += a;
        cout << cnt;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3636
/*
	Behind every successful man 
	there's a lot of unsuccessful years
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define E endl
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
const int N = 1e4+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
int cache[1010][10010];
int solve(int w, int wt[], int val[], int pos, int n) 
{   if(pos ==n){
 		if(w <=0)return 0;
  		else return 1e18;
	}
	if(w<=0)return 0;
	if(cache[pos][w]!=-1)return cache[pos][w];
	int x =1e18,y=1e18,z=1e18;
	y =val[pos]+solve(w-wt[pos],wt,val,pos+1,n);
	z= val[pos]+solve(w-wt[pos],wt,val,pos,n);
	x = solve(w,wt,val,pos+1,n);
	return cache[pos][w]=min({x,y,z});
} 
signed main(){
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int wt,n;
		cin >> wt >> n;
		for(int i =0 ;i <n;i++){
			cin >> ar[i] >> dp[i];			
		}
		for(int i =0 ;i <n;i++){
		    for(int j=0;j<=wt;j++){
		        cache[i][j]=-1;
		    }
		}
		int ans = solve(wt,ar,dp,0,n);
		cout<<ans<<endl;
	
	}
	
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}


Measured memory_bytes: 78976
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T>inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    string s;
    cin >> s;
    REP(i, s.size()) printf("%c", (s[i] == ',' ? ' ' : s[i]));
    puts("");
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
lli mod=1000000007;
typedef pair<lli,pair<lli,lli>> ppi;
lli zero_x[]={-1,0,1,0};
lli zero_y[]={0,-1,0,1};
lli one_x[]={-2,-2,-2,-2,-2,-1,-1,-1,-1,-1,0,0,0,0,1,1,1,1,1,2,2,2,2,2};
lli one_y[]={-2,-1,0,1,2,-2,-1,0,1,2,-2,-1,1,2,-2,-1,0,1,2,-2,-1,0,1,2};
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    lli h,w;
    cin>>h>>w;
    lli ch,cw,dh,dw;
    cin>>ch>>cw>>dh>>dw;
    string mat[h];
    for(lli i=0;i<h;++i)
        cin>>mat[i];
    priority_queue<ppi,vector<ppi>,greater<ppi>> q;
    q.push({0,{ch-1,cw-1}});
    lli vis[h][w]; 
    vis[ch-1][cw-1]=1;
    lli cost[h][w];
    cost[ch-1][cw-1]=0;
    for(lli i=0;i<h;++i)
        for(lli j=0;j<w;++j)
            cost[i][j]=LLONG_MAX;
    while(!q.empty()){
        lli curr=q.top().first;
        lli r=q.top().second.first;
        lli c=q.top().second.second;
        //cout<<r<<" "<<c<<" "<<curr<<endl;
        q.pop();
        for(lli i=0;i<4;++i){
            lli next_r=r+zero_x[i];
            lli next_c=c+zero_y[i];
            if(next_r>=0&&next_r<h&&next_c>=0&&next_c<w&&(cost[next_r][next_c]>curr)&&mat[next_r][next_c]=='.'){
                cost[next_r][next_c]=curr;
                q.push({curr,{next_r,next_c}});
            }
        }
        for(lli i=0;i<24;++i){
            lli next_r=r+one_x[i];
            lli next_c=c+one_y[i];
            if(next_r>=0&&next_r<h&&next_c>=0&&next_c<w&&(cost[next_r][next_c]>(curr+1))&&mat[next_r][next_c]=='.'){
                cost[next_r][next_c]=curr+1;
                q.push({curr+1,{next_r,next_c}});
            }
        }
    }
    if(cost[dh-1][dw-1]==LLONG_MAX)
        cout<<-1<<endl;
    else
        cout<<cost[dh-1][dw-1]<<endl;


}

Measured memory_bytes: 12640
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;
int main(){
  long long dp[55][3000][55];
  int n,a;
  cin>>n>>a;
  vector<int> x(n);
  for(int i=0;i<n;i++) cin>>x[i];
  
  memset(dp,0,sizeof(dp));
  dp[0][0][0]=1;
  for(int i=0;i<n;i++){
    for(int s=0;s<=n*a;s++){
       for(int k=0;k<=n;k++){
         if(dp[i][s][k]==0) continue;
         dp[i+1][s][k]+=dp[i][s][k];
         dp[i+1][s+x[i]][k+1]+=dp[i][s][k];
       }
    }
  }
  long long res=0;
  for(int k=1;k<=n;k++) res+=dp[n][a*k][k];
  cout<<res<<endl;
  return 0;
}


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

int main() {
    vector<string> vec(3);

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

    string result = "";
    for(int i=0; i<vec.size(); i++) {
        result += vec[i].at(0);
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,k,dp[100009],a[1009];
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    dp[0]=0;
    for(int i=1;i<=k;i++)
    {
        if(i<a[0])
        {
            dp[i]=0;
            continue;
        }
        for(int j=0;j<n&&i-a[j]>=0;j++)
        {
            dp[i]=max(dp[i],abs(dp[i-a[j]]-1));
        }
    }
    if(dp[k])cout<<"First";
    else cout<<"Second";
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,num;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
		cin>>num;
		n-=num;
	}
    if (n<0)cout<<-1<<endl;
	else cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;
#define MAX 1000000000

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

    int ans;
    if (N % 2 == 0)
    {
        ans = N;
    }
    else
    {
        ans = N * 2;
    }
    // for (int i = max(2, N); i < MAX * 2; i++)
    // {
    //     if (i % 2 == 0 && i % N == 0)
    //     {
    //         ans = i;
    //         break;
    //     }
    // }
    cout << ans << endl;
    return (0);
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n),b(n);
    unordered_map<int,int> mp;
    for (int i = 0;i < n;++i) {
        scanf("%d",&a[i]);
        if (mp.find(a[i]) != mp.end()) b[mp[a[i]]] = i;
        mp[a[i]] = i;
    }
    for (int i = 0;i < n;++i) {
        b[mp[a[i]]] = i;
        mp[a[i]] = i;
    }
    int cnt = 1,f = 0;
    do {
        if (b[f] <= f) cnt++;
        f = (b[f]+1)%n;
    } while (f);
    k %= cnt;
    while (1) {
        if (k == 0) break;
        if (b[f] <= f) {
            k--;
            if (k == 0) {
                k++;
                break;
            }
        }
        f = (b[f]+1)%n;
    }
    vector<int> ans;
    if (k) {
        do {
            if (b[f] > f) {
                f = (b[f]+1)%n;
            } else {
                ans.push_back(a[f]);
                f++;
                f %= n;
            }
        } while (f);
    }
    int m = ans.size();
    for (int i = 0;i < m;++i) printf("%d ",ans[i]);
    printf("\n");
    return 0;
}

Measured memory_bytes: 13128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int ps[100],ts[100];
int calc( int lev, int pos ){
	if( pos == 0 ) return 0;
	if( lev == 0 && pos == 1 ) return 1;
	if( pos <= ts[lev-1] + 1 ){
		return calc( lev-1, pos-1 );
	}
	if( pos == ts[lev-1] + 2 ){
		return ps[lev-1] + 1;
	}
	if( pos < ts[lev] ){
		return ps[lev-1] + 1 + calc( lev-1, pos - ts[lev-1] - 2 );
	}
	if( pos == ts[lev] ){
		return ps[lev];
	}
	return -1;
}
signed main(){
	int n,x;
	cin>>n>>x;
	ps[0] = 1; ts[0]=1;
	for(int i=1;i<=50;i++){
		ps[i] = ps[i-1] * 2 + 1;
		ts[i] = ts[i-1] * 2 + 3;
	}
	int ans = calc(n,x);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		//入力
		long n = sc.nextLong();
		TreeMap<Integer, Integer> map = primeFactorization(n);
		
		long result = 0;

		//出力
		int i = 0;
		for (Map.Entry<Integer, Integer> e: map.entrySet()) {
			
				long x = e.getValue();
				long y = 1;
				do {
					x -= y;
					result++;
					y++;
				}while(x - y >= 0);

			i++;
		}
		System.out.println(result);

	}

	private static TreeMap<Integer, Integer> primeFactorization (long n) {

		TreeMap<Integer, Integer> map = new TreeMap<>();
		int sq = (int)Math.sqrt(n);

		//nが素数ならn^1の形で返す
		if (isPrime(n) == true) {
			map.put((int) n, 1);
			return map;
		}

		for (int i=2; i<=sq; i++) {
			//n<iなら明らかにnをiで除算できないので終了（ループを余計に回さない）
			if (n < i) break;

			//iが素数なら、nをiで何回除算できるか、その回数をmapに記録する
			if (isPrime(i) == true) {
				int count = 0;
				while (n%i == 0) {
					n /= i;
					count++;
				}
				if (count > 0) {//1回以上割れた場合のみ、mapに記録する
					map.put(i, count);
				}
			}

		}

		//2～sqrt(n)で除算した結果、なお残った数をmapに追加する
		if (n != 1) map.put((int) n, 1);

		return map;

	}
	
	private static boolean isPrime (long n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		int d = (int)Math.sqrt(n);
		for (int i=3; i<=d; i+=2) {
			if(n%i==0){return false;}
		}
		return true;
	}
	
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long n, m;
    cin >> n >> m;
    long long ans = 1;
    for(long long i = m/n; i > 1; i--){
        if((m-i*n)%i == 0){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};
map<Int,Int> dp;
Int health(Int x){
    if(x==1) return 1;
    if(dp.count(x)) return dp[x];
    return dp[x]=1+health(x>>1LL)*2LL;
}

int main()
{
       cin>>N>>M;
       vector<Int> A(M+1),B(M+1);
       for(int i=1;i<M+1;++i){
           cin>>A[i];
           cin>>B[i];
       }
       
       vector<Int> dp(N+1,1e12);
       dp[0]=0;
       for(int i=1;i<=N;++i){
           for(int j=1;j<M+1;++j){
               dp[i]=min(dp[i],(i>=A[j] ? dp[i-A[j]]+B[j]:B[j]));
               
           }
       }
       cout<<dp[N]<<"\n";
       
}

Measured memory_bytes: 3672
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
const long MOD=1000000007;

long mpow(long a,long x, long M){
    if(a==0) return 0%M;
    if(x==1) return a%M;
    if(x==0) return 1%M;
    if(x%2==1) return (a*mpow(a,x-1,M))%M;
    else{
        long q=mpow(a,x/2,M);
        return (q*q)%M;
    }
}


int main() {
    string S;
    cin>>S;
    
    vector<vector<long>> dp(S.size()+1,vector<long>(13,0));
    if(S.at(S.size()-1)=='?'){
        for(int i=0;i<10;i++) dp.at(0).at(i)=1;
    }else{
        dp.at(0).at(stol(S.substr(S.size()-1,1)))=1;
    }
    
    
    
    for(int i=1;i<S.size();i++){
        if(S.at(S.size()-1-i)=='?'){
            for(int j=0;j<10;j++){
                long d=(mpow(10,i,13)*j)%13;
                for(int k=0;k<13;k++){
                    dp.at(i).at((k+d)%13)+=dp.at(i-1).at(k);
                    dp.at(i).at((k+d)%13)%=MOD;
                }
            }
        }
        else{
            long it=stol(S.substr(S.size()-1-i,1));
            long d=(mpow(10,i,13)*it)%13;
            for(int k=0;k<13;k++){
                dp.at(i).at((k+d)%13)+=dp.at(i-1).at(k);
                dp.at(i).at((k+d)%13)%=MOD;
            }
        }
    }
    /*for(int i=S.size()-1;i>=0;i--){
        for(int j=0;j<13;j++) cout<<dp.at(i).at(j);
        cout<<endl;
    }*/
    
    cout<<dp.at(S.size()-1).at(5)%MOD<<endl;
}

Measured memory_bytes: 13696
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <list>
using namespace std;

#define T_LEN_MAX 1000000
#define P_LEN_MAX 10000

char T[T_LEN_MAX + 1] = "\0";
char P[P_LEN_MAX + 1] = "\0";
int T_len;
int P_len;

list<int> T_index;
int P_index[UCHAR_MAX + 1];

int Compare(int idx)
{
	for (int i = 1; i < P_len; i++) {
		if (T[idx - i] != P[P_len - 1 - i]) return T[idx - i];
	}
	return -1;
}

void MakeTIndex(int idx1, int idx2) {
	for (int i = 0; i + idx2 < T_len; i++) {
		if (T[i + idx1] == P[idx1] && T[i + idx2] == P[idx2]) {
			T_index.push_back(i + P_len - 1);
		}
	}
}

void MakeTIndex() {
	for (int i = 0; T[i] != '\0'; i++) {
		if (T[i] == P[0]) {
			T_index.push_back(i);
		}
	}
}

void SearchAndOutput() {
	for (list<int>::iterator itr_t = T_index.begin(); *itr_t != -1;) {
		int ret = Compare(*itr_t);
		if (ret == -1) {
			cout << *itr_t - P_len + 1 << endl;
			itr_t++;
		}
		else {
			itr_t++;
			int idx = *itr_t + P_len - P_index[ret];
			while (*itr_t >= idx) {
				itr_t++;	
			}
		}
	}
}

void SearchPPAndOutput() {
	int okflag = 0;
	int okidx = -2;
	for (list<int>::iterator itr_t = T_index.begin(); *itr_t != -1;) {
		int ret;
		if (okflag == 1 && *itr_t == okidx + 1) {
			ret = -1;
		}
		else {
			ret = Compare(*itr_t);
		}
		if (ret == -1) {
			okflag = 1;
			okidx = *itr_t;
			cout << *itr_t - P_len + 1 << endl;
			itr_t++;
		}
		else {
			okflag = 0;
			itr_t++;
			int idx = *itr_t + P_len - P_index[ret];
			while (*itr_t >= idx) {
				itr_t++;	
			}
		}
	}
}

int main(void)
{
	//input
	cin >> T >> P;
	T_len = strlen(T);
	P_len = strlen(P);
	
	//make P_index
	for (int i = 0; P[i] != '\0'; i++) {
		P_index[P[i]] = i;
	}

	//make T_index
	int idx1, idx2;
	if (P_len == 1) {
		MakeTIndex();
	}
	else {
		idx1 = P_len - 1;
		idx2 = P_len - 2;
		while (idx2 > 0 && P[idx2] == P[idx1]) {
			idx2--;
		}
		MakeTIndex(idx2, idx1);
	}
	T_index.push_back(-1);
	
	//search and output
	if (P[idx1] == P[idx2]) {
		SearchPPAndOutput();
	}
	else {
		SearchAndOutput();
	}

	return 0;
}


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

using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    if(a>=13){
        cout << b;
    }
    else if(a>=6 && a<=12){
        cout << b/2;
    }
    else{
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
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 REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

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

	int n;
	string s;
	cin >> n >> s;

	int cnt = 0;
	int mi = 0;
	rep(i, n) {
		if (s[i] == '(') {
			cnt++;
		}
		else if (s[i] == ')') {
			cnt--;
			chmin(mi, cnt);
		}
	}
	rep(i, abs(mi)) cout << '(';
	cout << s;
	rep(i, cnt - mi) cout << ')';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int N,M; cin >> N >> M;
  bool g[N][N];
  int p[N];
  rep(i,N) p[i] = i;
  rep(i,N)rep(j,N) g[i][j] = false;
  for(int i = 0; i < M; i++){
    int a,b; cin >> a >> b;
    a--; b--;
    g[a][b] = g[b][a] = true;
  }
  int ans = 0;
  do{
    bool flg = true;
    if(p[0] != 0) break;
    for(int i = 0; i < N-1; i++){
      if(!g[p[i]][p[i+1]]) flg = false;
    }
    if(flg) ans++;
  }while(next_permutation(p, p+N));
  cout << ans << endl;
  return 0;
}


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

typedef const int& cint;
const int MAXN = 100010;

int N, K, ans;

struct Edge{
	int to, nxt;
	
	Edge(){}
	
	Edge(cint to_, cint nxt_){to = to_, nxt = nxt_;}
}ed[MAXN << 1];
int head[MAXN], tot;
int par[MAXN], dep[MAXN], mx[MAXN];

inline void add(cint u, cint v){
	ed[++tot] = Edge(v, head[u]), head[u] = tot;
	ed[++tot] = Edge(u, head[v]), head[v] = tot;
}

inline void chkmax(int& a, int b){if (b > a) a = b;}

void dfs(int u){
	mx[u] = dep[u];
	int tmp, v;
	for (tmp = head[u]; tmp; tmp = ed[tmp].nxt){
		v = ed[tmp].to;
		if (v != par[u])
			dep[v] = dep[u] + 1, dfs(v), chkmax(mx[u], mx[v]);
	}
	if (mx[u] - dep[u] == K - 1 && par[u] != 1)
		++ans, mx[u] = 0;
}

int main(){
	scanf("%d %d", &N, &K);
	for (int i = 1; i <= N; ++i)
		scanf("%d", &par[i]);
	if (par[1] != 1)
		++ans, par[1] = 1;
	for (int i = 2; i <= N; ++i)
		add(i, par[i]);
	dfs(1);
	printf("%d", ans);
	return 0;
} 


Measured memory_bytes: 6400
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
using namespace std;
ll gcd(ll a, ll b) { if (a == 0) return b; return gcd(b % a, a); } 
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];


void solve()
{
    int a;
    cin>>a;

    cout<<a+a*a+a*a*a<<endl;

}

int main()
{
    #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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 15528
#include <iostream>
#include <stdio.h>
#include <stdlib.h>


int floor(long long a,long long b,long long c) {
	long long max = 0;
	long long anser = 0;
	long long anser2 = 0;

	if (c >= b) {
		c = b - 1;
		anser = a * c / b;
		anser2 = c / b;
		max = anser - a * anser2;
	}
	else {
		anser = a * c / b;
		anser2 = c / b;
		max = anser - a * anser2;
		
		/*for (int i = 0; i <= c; i++) {
			anser = a * i / b;
			if (test != anser) {

				long long anser2 = i / b;
				long long anserA = anser - a * anser2;

				if (anserA > max) {
					max = anserA;
				}
				test = anser;
			}
		}*/
	}
	
	return max;
}

int main(int argc, char* argv[]) {
	long long a, b, c,d;

	

	std::cin >>a >> b >> c;

	
	d = floor(a, b, c);

	//printf("%d\n", d);
	std::cout <<d<< std::endl;
	return 0;
}



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

const int N = 6e5 + 9;

struct ST {
    int t[4 * N];
    ST() {
        memset(t, 0, sizeof t);
    }
    void build(int n, int b, int e) {
        if(b == e) {
            t[n] = 0;
            return;
        }
        int mid = (b + e) >> 1,  l = n << 1,  r = l | 1;
        build(l, b, mid);
        build(r, mid + 1, e);
        t[n] = max(t[l], t[r]);
    }
    void upd(int n, int b, int e, int i, int x) {
        if(b > i || e < i) return;
        if(b == e && b == i) {
            t[n] = max(t[n], x);
            return;
        }
        int mid = (b + e) >> 1,  l = n << 1,  r = l | 1;
        upd(l, b, mid, i, x);
        upd(r, mid + 1, e, i, x);
        t[n] = max(t[l], t[r]);
    }
    int query(int n, int b, int e, int i, int j) {
        if(b > j || e < i) return -1e9;
        if(b >= i && e <= j) return t[n];
        int mid = (b + e) >> 1,  l = n << 1,  r = l | 1;
        int L = query(l, b, mid, i, j);
        int R = query(r, mid + 1, e, i, j);
        return max(L, R);
    }
} t;

int dp[N];
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	t.build(1, 1, N - 1);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		dp[x] = t.query(1, 1, N - 1, max(0, x - k) + 1, x + k + 1) + 1;
		t.upd(1, 1, N - 1, x + 1, dp[x]);
		ans = max(ans, dp[x]);
	}
	cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 14232
n = int(input())
a = list(map(int,input().split()))

from collections import deque

b=deque([])

if n%2==0:
    for i in range(n):
        if i%2==0:
            b.append(a[i])
        else:
            b.appendleft(a[i])
else:
    for i in range(n):
        if i%2==0:
            b.appendleft(a[i])
        else:
            b.append(a[i])

print(*b)

Measured memory_bytes: 26180
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
#import numpy as np
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
#N = int(input())
#S = str(input())
A, B = map(int, input().split())

i = 1
while math.floor(i*0.08) <= A and math.floor(i*0.1) <= B :
  if math.floor(i*0.08) == A and math.floor(i*0.1) == B :
    print (i)
    exit()
  i += 1
print (-1)
  
  



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

public class Hello
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        SortedSet<int> hash = new SortedSet<int>();
        int num = 0;
        for(int i = 0;i < n;i++){
            num = int.Parse(Console.ReadLine());
            if(!hash.Contains(num))hash.Add(num);
        }
        Console.WriteLine(hash.Count());
    }
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(void)
{
    int n,t[100],m,p,x,i,j,s;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&t[i]);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%d%d",&p,&x);
        s=0;
        for(j=0;j<n;j++){
            if(j==p-1)s+=x;
            else s+=t[j];
        }
        printf("%d\n",s);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int d[11][11];
int w[102][102];

int main(){
  int a,b;
  cin>>a>>b;
  rep(i,a) rep(j,b) cin>>d[i][j];

  rep(i,101) rep(j,101){
    // i*x + j*y + w[i][j] >= d[k][l] for all k,l
    w[i][j] = 0;
    rep(k,a) rep(l,b) w[i][j] = max(w[i][j], d[k][l] - i*(k+1) - j*(l+1));
  }

  rep(k,a) rep(l,b){
    int tmp = INF;
    rep(i,101) rep(j,101){
      tmp = min(tmp, w[i][j] + i*(k+1) + j*(l+1));
    }
    if(tmp != d[k][l]){
      cout << "Impossible" << endl;
      return 0;
    }
  }

  cout << "Possible\n";
  cout << "202 10401\n";

  rep(i,1,101) cout << i << " " << i+1 << " X\n";
  rep(i,102,202) cout << i << " " << i+1 << " Y\n";
  rep(i,101) rep(j,101){
    cout << i+1 << " " << 202-j << " " << w[i][j] << "\n";
  }

  cout << "1 202\n";

  return 0;
}


Measured memory_bytes: 384