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

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define eof !cin.eof()
#define pb push_back
#define pf push_front
#define pof pop_front
#define pob pop_back
#define ull unsigned long long
#define ll long long
#define ld long double
#define sz(a) a.size()
#define all(s) s.begin(), s.end()
#define rall(s, n) s, s + n
#define x first
#define y second
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define ii pair <int, int>
#define iii pair <int, ii>
#define vi vector <int>
#define vit vector <int> :: iterator
#define vlt vector <ll> :: iterator
#define vl vector <ll> 
#define vii vector <ii>
#define viii vector <iii>
#define vd vector <double>
#define vull vector <ull>
#define vc vector <char>
#define vs vector <string>
#define vvi vector <vector <int>>
#define vvl vector <vector <ll>>
#define EPS 1e-10
#define INF 1000000000
#define mod 1000000007
#define reset(a, nilai) memset(a, nilai, sizeof(a))
#define minof min_element
#define maxof max_element
using namespace std;

int n;
int main () {
	IOS;
	
	scanf("%d", &n);
	vi h(n), dp(n, INF);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + 2; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
			}
		}
	}
	printf("%d\n", dp[n - 1]);
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(bu.readLine()),f=0,l=0,i;
        char s[]=bu.readLine().toCharArray();
        for(i=0;i<n;i++)
        if(s[i]!='R') break;
        else f++;
        for(i=n-1;i>=0;i--)
        if(s[i]!='W') break;
        else l++;
        if(f+l==n) {System.out.print(0); return;}

        l=n-1-l;
        int r=0,w=0;
        for(i=f;i<=l;i++)
        if(s[i]=='R') r++;
        for(i=f;i<f+r;i++)
        if(s[i]=='W') w++;
        System.out.print(w);
    }
}

Measured memory_bytes: 36444
/*
 * author: Tran Minh Khoa
 * Ho Chi Minh University of Science
 */

#include <bits/stdc++.h>

using namespace std;

const int inf = (int) 1e9 + 7;
const long long INF = (long long) 1e18 + 7;

const int N = 123456;
const int M = 1010;

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define sz(a) (int) a.size()
#define all(a) a.begin(), a.end()
#define sqrt(x) (x) * (x)

#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define DEBUG(x) cerr << #x << " = " << x << '\n';
#define PR(x, a, b) { cerr << #x << " = "; REP(i, a, b) cerr << x[i] << ' '; cerr << '\n'; }
                 
int main() {
  #ifdef KM777
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
  #endif
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr); cout.tie(nullptr);
  
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> a(m + 1), b(m + 1);
  for (int i = 1; i <= m; i++) {
    cin >> b[i];
  }
  int result = 0;
  while (n--) {
    int sum = c;
    for (int i = 1; i <= m; i++) {
      cin >> a[i];
      sum += a[i] * b[i];
    }
    if (sum > 0) {
      result++;
    }     
  }
  cout << result << '\n';
  return 0;
}

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


using namespace std;


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

	int count = 0;
	int input;
	int ex;
	for(int i=0; i<m; i++) {
		cin >> input;
		if(i == 0 && input-1 > count) count = input-1;
		if(i == m-1 && n-input > count) count = n-input;
		if(i != 0 && (input-ex)/2 > count) count = (input-ex)/2;
		ex=input;
	}

	cout << count << endl;

	return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);

int n,ans,a,hoge,memo[100000];
vector<int> v;

main() {
    cin >> n;
    rep(i,n) cin >> a,v.pb(a);
    sort(all(v));
    rep(i,v.size()-1) {
        if (v[i]==v[i+1]) hoge++;
        else {
            memo[v[i]]=++hoge;
            hoge=0;
        }
    }
    memo[v[v.size()-1]]=++hoge;
    rep(i,99998) {
        ans = max(ans,memo[i]+memo[i+1]+memo[i+2]);
    }
    ct(ans)
}

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

int main() {
	int N;
	cin >>N;
	int ans = 0;
	vector<int>D(N);
	for (int n = 0;n<N;++n) {
		cin >> D[n];
		ans += D[n];
	}
	ans *= ans;
	for (int n = 0; n < N; ++n) {
		ans -= D[n]*D[n];
	}
	ans /= 2;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
vector<int> edg[100005], ch[100005];
bool used[100005];
ll dp[100005][2];

void mkch(int pos) {
	used[pos] = true;
	for (int i : edg[pos]) {
		if (used[i]) continue;
		ch[pos].push_back(i);
		mkch(i);
	}
}

ll func(int pos, bool black) {
	if (dp[pos][black] != -1) return dp[pos][black];
	if (ch[pos].size() == 0) return dp[pos][black] = 1 + black;
	ll bl = black, wh = 1;
	if (black) {
		for (int i : ch[pos]) {
			bl *= func(i, false);
			bl %= mod;
		}
	}
	for (int i : ch[pos]) {
		wh *= func(i, true);
		wh %= mod;
	}
	return dp[pos][black] = (bl + wh)%mod;
}

int main() {
	int N; cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	mkch(0);
	for (int i = 0; i <= N; i++) dp[i][0] = dp[i][1] = -1;
	cout << func(0, true) << endl;
	return 0;
}

Measured memory_bytes: 18432
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;





signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int s = abs(a[0]); s += abs(a[n - 1]);
	rep(i, n - 1) {
		s += abs(a[i] - a[i + 1]);
	}
	rep(i, n) {
		if (i == 0) {
			cout << s + abs(a[i + 1]) - (abs(a[i]) + abs(a[i] - a[i + 1])) << endl;
		}
		else if (i == n - 1) {
			cout << s + abs(a[i - 1]) - (abs(a[i - 1] - a[i]) + abs(a[i])) << endl;
		}
		else {
			cout << s + abs(a[i - 1] - a[i + 1]) - (abs(a[i - 1] - a[i]) + abs(a[i] - a[i + 1])) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 2048
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	
	int n = sc.nextInt();
	Integer []a = new Integer [3*n];
	
	for(int i = 0; i < 3*n; i++)
		a[i] = sc.nextInt();
	
	Arrays.sort(a,Collections.reverseOrder());
	
	long sum = 0;
	
	for(int i = 1; i <= n; i++) {
		sum += a[(2 * i) - 1];
	}
	System.out.println(sum);
	
	}

}


Measured memory_bytes: 101208
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<long long> a(n), b(n), c;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < n; i++){
        cin >> b[i];
    }
    long long sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i] >= b[i]){
            c.push_back(a[i] - b[i]);
        }else{
            sum += a[i] - b[i];
            ans++;
        }
    }
    sort(rbegin(c), rend(c));
    int t = 0;
    while(sum < 0 && t < c.size()){
        sum += c[t];
        t++;
        ans++;
    }
    cout <<(sum >= 0? ans:-1)<< endl;
    return 0;
}


Measured memory_bytes: 2936
#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 h,w,k;
  cin >> h >> w >> k;
  vector<string> s(h);
  int ans = 0;
  rep(i, h) cin >> s[i];
  rep(is, 1 << h) rep(js, 1 << w) {
    int cnt = 0;
    rep(i, h) rep(j, w) {
      if(is >> i&1) continue;
      if(js >> j&1) continue;
      if(s[i][j] == '#') cnt++;
    }
    if(cnt == k) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream f ("test.in"); ofstream g ("test.out");
ll dp[100005],v[100005],w[100005];
int main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=0;i<=(1e5);i++)
        dp[i]=(1<<30);
    int pretmax=0;
    dp[0]=0;
    for(int i=1;i<=n;i++) pretmax+=v[i];
    for(int i=1;i<=n;i++)
        for(int j=pretmax-v[i];j>=0;j--)
            dp[j+v[i]]=min( dp[j+v[i]],dp[j]+w[i]);

    for(int i=(1e5);i;i--)
        if(dp[i]<=W)
        {   cout<<i;
            return 0;
        }
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll a;
    long double b;
    cin >> a >> b;
    cout << setprecision(20) << floorl(a*b);
    return 0;
}

Measured memory_bytes: 3792
from bisect import bisect


n = int(input())
A = sorted(map(int, input().split()))


x = A[-1]

A = [-float("inf")] + A[:n - 1] + [float("inf")]
i = bisect(A, x / 2)
if abs(A[i - 1] - x / 2) < abs(A[i] - x / 2):
    y = A[i - 1]
else:
    y = A[i]


print(x, y)


Measured memory_bytes: 14428
#include <cstdio>

int main (int argc, char const* argv[])
{
	int a=0,b=0;
	
	for (unsigned int i = 0; i < 4; i += 1)
	{
		int c;
		scanf("%d",&c);
		a+=c;
	}
	
	
	for (unsigned int i = 0; i < 4; i += 1)
	{
		int c;
		scanf("%d",&c);
		b+=c;
	}
	
	printf("%d\n",(a>b)?a:b);
	
	return 0;
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin >> N;
    if(N%2==0) cout << N << endl;
    else cout << N*2 << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int n = 0; n < N; ++n) {
        cin >> A[n];
    }
    
    ll Pos = A[0] + A[1];
    ll Neg = -Pos;
    for (int n = 1; n < N-1; ++n) {
        ll PosNew = Pos + A[n+1];
        ll Tmp = Neg + A[n+1];
        if (Tmp > PosNew) PosNew = Tmp;
        
        ll NegNew = Pos - 2*A[n] - A[n+1];
        Tmp = Neg + 2*A[n] - A[n+1];
        if (Tmp > NegNew) NegNew = Tmp;
        
        Pos = PosNew;
        Neg = NegNew;
    }
    
    cout << (Pos > Neg ? Pos : Neg) << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

template<typename T>
struct Point {
	T x, y;
	Point(T x=0, T y=0):x(x), y(y) {}
	Point(pair<T, T> p): x(p.first), y(p.second) {}
	Point operator+ (const Point &o) const { return Point(x+o.x, y+o.y); }
	Point& operator+= (const Point &o){ x += o.x; y += o.y; return *this; }
	Point operator- (const Point &o) const { return Point(x-o.x, y-o.y); }
	Point& operator-= (const Point &o){ x -= o.x; y -= o.y; return *this; }
	T dot(const Point &o) const { return x*o.x + y*o.y; }
	T det(const Point &o){ return x*o.y-y*o.x; }
	bool operator< (const Point &o) { return x<o.x || (x==o.x && y<o.y); };
};

typedef Point<long long> PLL;
vector<PLL> convex_hull(vector<PLL> &points){
	int n = points.size();
	sort(points.begin(), points.end());
	for(int i=0; i<n; i++) debug(any{"s", points[i].x, points[i].y});
	vector<PLL> lower(n), upper(n);
	int l = 0, r = 0;
	for(auto p: points){
		while(l>1 && (lower[l-1]-lower[l-2]).det(p-lower[l-1]) <= 0) l--;
		lower[l++] = p;
	}
	for(int i=0; i<l; i++) debug(any{"l", lower[i].x, lower[i].y});

	for(int j=points.size()-1; j>=0; j--){
		auto p = points[j];
		while(r>1 && (upper[r-1]-upper[r-2]).det(p-upper[r-1]) <= 0) r--;
		upper[r++] = p;
	}
	for(int i=0; i<r; i++) debug(any{"r", upper[i].x, upper[i].y});

	for(int j=1; j<r-1; j++) lower[l++] = upper[j];
	lower.resize(l);

	return lower;
}

int main(){
	int N;
	cin >> N;
	vector<ll> X(N), Y(N);
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i];
	vector<PLL> Ps(N);
	for(int i=0; i<N; i++) Ps[i] = PLL(X[i], Y[i]);

	vector<PLL> hull(1);
	for(int i=0; i<N; i++){
		int n_hull = hull.size();
		for(int j=0; j<n_hull; j++) hull.push_back(hull[j]+Ps[i]);
		for(auto p: hull) debug(any{i, p.x, p.y});
		debug(any{"="});
		hull = convex_hull(hull);
		for(auto p: hull) debug(any{i, p.x, p.y});
	}

	ll ans = 0;
	for(auto p: hull) ans = max(ans, p.dot(p));

	cout << setprecision(20) << sqrt(ans) << endl;

	return 0;
}


Measured memory_bytes: 256
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

a,b=MI()
grid=[[0]*100 for i in range(100)]
for i in range(50):
    for j in range(100):
        grid[i+50][j]=1
#print(grid)
hor=[2*i for i in range(50)]
#print(hor)
ver=[2*i for i in range(25)]
#print(ver)
count=0
print(100,end=" ")
print(100)
if b>1:
    for x in hor:
        for y in ver:
            grid[y][x]=1
            count+=1
            if count==b-1:
                break
        else:
            continue
        break
#print(count)
count=0
if a>1:
    for x in hor:
        for y in ver:
            grid[99-y][x]=0
            count+=1
            if count==a-1:
                break
        else:
            continue
        break
for i in range(100):
    for j in range(100):
        if grid[i][j]==1:
            print("#",end="")
        else:
            print(".",end="")
    print()

    
    


    

    
            
        
        
    
    
    
    

    
    


    
    

        
        
    


    

Measured memory_bytes: 69328
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<climits>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N;
    int V[20],C[20];
    cin>>N;
    int ans=0;
    for(int i=0;i<N;i++){
        cin>>V[i];
    }
    for(int i=0;i<N;i++){
        cin>>C[i];
    }
    for(int i=0;i<N;i++){
        if(V[i]-C[i]>=0) ans+=V[i]-C[i];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3188
// *_*
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readarr(a, n) int a[(n) + 1] = {}; fori(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori(i, 1, n) {fori(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for(int i = a; i <= b; i++)
#define ford(i, a, b) for(int i = a; i >= b; i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'

using namespace std;
using namespace __gnu_pbds; 

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;

const long long inf2 = (long long)1e18;
const long long mod = (long long)(1e9+7);
const long long inf1 =(long long)(1e6+1);

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

    read(n);
    string s;
    cin >> s;

    fori(i, 0, s.length()-1)
    {
        int p = s[i];
        p += n;
        if(p > 90) p = 64 + p-90;
        char c = p;
        cout << c;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    vector<int> psort(p.size());
    copy(p.begin(),p.end(),psort.begin());
    sort(psort.begin(),psort.end());
    int cnt=0;
    for(int i=0;i<p.size();i++){
        if(p[i]!=psort[i]){
            cnt++;
        }
    }
    if(2==cnt||0==cnt){
        cout<<"YES";
    }else{
        cout<<"NO";
    }
    return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("Ofast")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// template <typename T>
// using o_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define sfind(i) find_by_order(i)
// #define ord(i) order_of_key(i)
typedef long long ll;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
using cd = complex<double>;
const double pi = acos(-1);
// #define mod 1000000007
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define repc(i, a, b, c) for (ll i = a; (c > 0 ? i < b : i > b) and c != 0; i += c)
#define vi vector<int>
#define vl vector<ll>
#define _max(vec) (*max_element(all(vec)))
#define _min(vec) (*min_element(all(vec)))
#define fi first
#define si second
#define pb push_back
#define all(name) name.begin(), name.end()
#define ral(name) name.rbegin(), name.rend()
#define fact(n) rep(i, 1, n+1)ft.pb((ft[i-1]*i)%mod)
#define mod_in(a) power(a, mod - 2)
#define ncr(n, r) (n>=r?((ft[n]*mod_in((ft[r]*ft[(n)-(r)])%mod))%mod):0LL)
#define deb(x) cerr << "[" << #x << " " << x << "]" << endl;
#define endl '\n'  //....????
#define int ll
vector<ll> ft(1, 1LL);


/*======================================================================*/
void solve(){
    int n, cunt[2] = {0};
    string s;
    cin >> n >> s;
    vi v(n+1, 0);
    rep(i, 1, n+1){ 
        int c = 0, j = i;
        while(j != 0){
            j = j%__builtin_popcount(j);
            c++;
        }
        v[i] = c;
    }
    for(auto i : s)cunt[0] += i == '1';
    int mo[2] = {0, 0};
    int p[2] = {1, 1};
    cunt[1] = cunt[0]+1, cunt[0]--;
    reverse(all(s));
    rep(i, 0, 2){
        if(cunt[i] <= 0)continue;
        rep(j, 0, n){
            mo[i] = (mo[i] + (s[j] - '0')*p[i])%cunt[i];
            p[i] = (p[i]*2)%cunt[i];
        }
    }
    vi ans;
    p[0] = p[1] = 1;
    rep(j, 0, n){
        if(s[j] == '1'){
            if(cunt[0] == 0)ans.pb(-1);
            else ans.pb(v[(mo[0] - p[0] + cunt[0])%cunt[0]]);
        }
        else {
            ans.pb(v[(mo[1] + p[1])%cunt[1]]);
        }
        rep(i, 0, 2)if(cunt[i] != 0)p[i] = (p[i]*2)%cunt[i];
    }
    reverse(all(ans));
    for(auto i : ans)cout << i+1 << endl;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
}

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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int n,sum=0;
  cin >> n;
  vector<int> s(n);
  for(int i=0;i<n;i++){
    cin >> s[i];
  }
  sort(s.begin(),s.end());
  for(int i=0;i<n;i++){
    sum +=s[i];
  }
  if(sum%10==0){
    for(int i=0;i<n;i++){
      sum -=s[i];
      if(sum%10!=0)
        break;
      else
        sum +=s[i];
      if(i==n-1)
        sum=0;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,c5=0,c7=0;
    for(int i=0;i<3;i++){
        cin >> a;
        if(a==5)    c5++;
        else if(a==7)   c7++;
    }
    if(c5==2&&c7==1)    cout << "YES" << endl;
    else    cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		//方針：BFS
		//利用；キュー、隣接リスト
		
		List<ArrayList<int[]>> l = new ArrayList<ArrayList<int[]>>();
		for(int i=0;i<N;i++) l.add(new ArrayList<int[]>());
		
		for(int i=0;i<N-1;i++) {
			int from = sc.nextInt();
			int to = sc.nextInt();
			int dist = sc.nextInt();
			from--;
			to--;
			int tmp1[] = {to,dist};
			l.get(from).add(tmp1);
			int tmp2[] = {from,dist};
			l.get(to).add(tmp2);
		}
		
		int ans[] = new int[N];
		Arrays.fill(ans,-1);
		ans[0]=0;
		
		Queue<Integer> q = new ArrayDeque<Integer>();
		q.add(0);
		while(!q.isEmpty()) {
			int from = q.poll();
			List<int[]> tos = l.get(from);
			for(int tmp[] :tos) {
				int to = tmp[0];
				int dist = tmp[1];
				if(ans[to]!=-1)continue;
				ans[to]=(ans[from]+dist)%2;
				q.offer(to);
			}
		}
		
		StringBuilder sb = new StringBuilder();
		Arrays.stream(ans).forEach(i->sb.append(i + "\n"));
		System.out.println(sb.toString());
		
	}
}


Measured memory_bytes: 107652
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include <random>
#include <list>
#include <numeric>
#include <chrono>
#include <set>


#define rep(i,p,q) for(ll i = p;i < q;i++)
#define ll long long

using namespace std;


const long long MAX_N = 1 << 17;

long long dat[2 * MAX_N - 1];

ll ecd(ll a, ll b) {
	if (a < b) swap(a, b);
	if (b == 0) return a;
	else {
		return ecd(b, a % b);
	}
}

ll pow(ll a, ll b) {
	vector<ll> d = vector<ll>((ll)(log(b)) + 2);
	d[0] = a;
	rep(i, 1, d.size()) d[i] = d[i - 1] * d[i - 1];
	ll ret = 1;
	rep(i, 0, log(b) + 1) {
		if (b & 1 << i) ret *= d[i];
	}
	return ret;
}

//H
int main(void) {
	ll H, W;
	cin >> H >> W;
	vector<vector<ll>> dp = vector<vector<ll>>(H, vector<ll>(W, 0));
	vector<string> grid = vector<string>(H);
	rep(i, 0, H) {
		cin >> grid[i];
	}

	dp[0][0] = 1;

	const ll MOD = 1e9 + 7;

	rep(i, 0, H) {
		rep(j, 0, W) {
			if (j + 1 < W && grid[i][j + 1] == '.') {
				dp[i][j + 1] += dp[i][j];
				dp[i][j + 1] %= MOD;
			}
			if (i + 1 < H && grid[i + 1][j] == '.') {
				dp[i + 1][j] += dp[i][j];
				dp[i + 1][j] %= MOD;
			}
			
		}
	}
	cout << dp[H - 1][W - 1] << endl;
}


Measured memory_bytes: 11008
from sys import stdin


def main():
    n = next_int()
    k = next_int()
    ans = 1

    for i in range(n):
        ans *= k - (i != 0)

    print(ans)


def next_int():
    return int(next_str())


def next_str():
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()


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

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll H,W;
	cin>>H>>W;
    ll ans;
    if(H==1||W==1){
        ans = 1;
    }else{
        ans = (H*W+1)/2;
    }
    cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    counter = {}
    ans = 0

    for i in a:
        if str(i) in counter.keys():
            counter[str(i)] += 1
        else:
            counter[str(i)] = 1
    for i, j in counter.items():
        if int(i) > j:
            ans += j
        else:
            ans += j - int(i)

    print(ans)



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

void output(const deque<int>& dq) {
  for (int i = 0; i < dq.size(); ++i) {
    cout << ".#"[dq[i] / 2];
  }
  cout << endl;
  for (int i = 0; i < dq.size(); ++i) {
    cout << ".#"[dq[i] % 2];
  }
  cout << endl;
}

bool read() {
  string s; cin >> s;
  if (s == "end") exit(0);
  return s == "T";
}

int main() {
  int N; cin >> N;
  deque<int> dq;
  bool test = false;
  do {
    test = false;
    for (int i = 0; i < 4; ++i) {
      dq.push_back(i);
      output(dq);
      if (read()) {
        test = true;
        break;
      }
      else dq.pop_back();
    }
  } while (test);
  do {
    test = false;
    for (int i = 0; i < 4; ++i) {
      dq.push_front(i);
      output(dq);
      if (read()) {
        test = true;
        break;
      }
      else dq.pop_front();
    }
  } while (test);
}


Measured memory_bytes: 724
def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    color = set()
    etc = 0
    for a in A:
        idx = a // 400
        if idx >= 8:
            etc += 1
        else:
            color.add(idx)

    min_ = len(color)
    if min_ == 0:
        min_ = 1
    max_ = len(color) + etc

    print(min_, max_)

main()


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
long long int p=1e9 +7;
int n;
int moves[100];
int ans[100007]={0};
int solve(int k){
    if(ans[k]){
        return ans[k]-1;
    }
    bool ansk=1;
    for(int i=0;i<n;i++){
        if(k>=moves[i]){
        ansk&=solve(k-moves[i]);
        }
        if(!ansk){
            break;
        }
    }
    ansk=!ansk;
    if(ansk){
        ans[k]=2;
    }
    else{
        ans[k]=1;
    }
    return ans[k]-1;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	   int k;
	   cin>>n>>k;
	   for(int i=0;i<n;i++){
	       cin>>moves[i];
	   }
	   ans[0]=0;
	   if(solve(k)){
	    cout<<"First";   
	   }
	   else{
	       cout<<"Second";
	   }
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;
int s[11][11];
int main() {
    int N, M;
    int k[11];
    int p[11];

    cin >> N >> M;
    for (int i=0; i<M; i++) {
        cin >> k[i];
        for (int j=0; j<k[i]; j++) {
            int num;
            cin >> num;
            s[i][num-1] = 1;
        }
    }
    for (int i=0; i<M; i++) cin >> p[i];

    int ans = 0;
    for (int sw=0; sw< (1<<N); sw++) {
        int fail = 0;
        for (int i = 0; i<M; i++) {
            int lamp_n = 0;
            int sw_ite = sw;
            for (int j=0; j<N; j++) {
                int sw_ = sw_ite & 1;
                if (sw_ == 1 && s[i][j] == 1) lamp_n++;
                sw_ite >>= 1;
            }
            if (lamp_n % 2 != p[i]) {fail = 1; break;}
        }
        if (fail == 0) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    ll n;
    string s;
    cin>>n>>s;
    ll now=0,mn=0;
    rep(i,n){
        if(s[i]=='(') now++;
        if(s[i]==')') now--;
    }
    if(now>=0){
        rep(i,now) s.push_back(')');
    }else{
        rep(i,-now) s.insert(0,"(");
    }
    now=0;
    rep(i,s.size()){
        if(s[i]=='(') now++;
        if(s[i]==')') now--;
        mn=min(mn,now);
    }
    rep(i,-mn){
        s.push_back(')');
        s.insert(0,"(");
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#define ll long long
#define inf 1<<30
#define il inline 
#define in1(a) read(a)
#define in2(a,b) in1(a),in1(b)
#define in3(a,b,c) in2(a,b),in1(c)
#define in4(a,b,c,d) in2(a,b),in2(c,d)
il void readl(ll &x){
    x=0;ll f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
il void read(int &x){
    x=0;int f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    x*=f;
}
using namespace std;
/*===================Header Template=====================*/
#define N 100010
#define mod 1000000007
ll dp[100010][4];
int main(){
	string s;
	cin>>s;
	int n=s.size();
	for(int i=n;i>=0;i--){
		for(int j=3;j>=0;j--){
			if(i==n){
				dp[i][j]=(j==3?1:0);
			}else {
				dp[i][j]=dp[i+1][j]*(s[i]=='?'?3:1);
				if(j<3&&(s[i]=='?'||"ABC"[j]==s[i])){
					dp[i][j]+=dp[i+1][j+1];
				}
				dp[i][j]%=mod;
			}
		}
	}
	printf("%lld\n",dp[0][0]);
	return 0;
}

Measured memory_bytes: 3584
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long n, a, b, c, d, e;
    scan(n);scan(a);scan(b);scan(c);scan(d);scan(e);
    auto x = min(a, b, c, d, e);
    auto ans = (n - 1) / x + 5;
    writeln(ans);
}

























int[][] readGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new int[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v;
        scan(u, v);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= v;
        if (isUndirected) {
            adj[v] ~= u;
        }
    }

    return adj;
}

alias Edge = Tuple!(int, "to", int, "cost");

Edge[][] readWeightedGraph(int n, int m, bool isUndirected = true, bool is1indexed = true) {
    auto adj = new Edge[][](n, 0);

    foreach (i; 0 .. m) {
        int u, v, c;
        scan(u, v, c);
        if (is1indexed) {
            u--, v--;
        }
        adj[u] ~= Edge(v, c);
        if (isUndirected) {
            adj[v] ~= Edge(u, c);
        }
    }

    return adj;
}

void yes(bool b) {
    writeln(b ? "Yes" : "No");
}

void YES(bool b) {
    writeln(b ? "YES" : "NO");
}

T[] readArr(T)() {
    return readln.split.to!(T[]);
}

T[] readArrByLines(T)(int n) {
    return iota(n).map!(i => readln.chomp.to!T).array;
}

void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> w(n);
	REP(i, n) cin >> w[i];
	int ans = 10000;
	for (int i = 0; i < n-1;++i) {
		int sum = 0; int sum1 = 0;
		for (int j = 0; j <= i; ++j) {
			sum += w[j];
		}
		for (int j = i+1; j < n; ++j) {
			sum1 += w[j];
		}
		ans = min(ans,abs(sum-sum1));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#define lf double
#define ll long long
#define N 200005

int n;

int cnt[50][50],cnt2[N],cnt5[N];

ll ans;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		lf A;
		scanf("%lf",&A);
		ll a=(llround)(A*1e9);
		while(a%2==0){
			cnt2[i]++;
			a/=2;
		}
		while(a%5==0){
			cnt5[i]++;
			a/=5;
		}
		cnt[cnt2[i]][cnt5[i]]++;
		if(cnt2[i]>=9&&cnt5[i]>=9)
			ans--;
		cnt2[i]=std::max(18-cnt2[i],0);
		cnt5[i]=std::max(18-cnt5[i],0);
	}
	for(int i=48;i>=0;i--)
		for(int j=48;j>=0;j--)
			cnt[i][j]+=cnt[i+1][j]+cnt[i][j+1]-cnt[i+1][j+1];
	for(int i=1;i<=n;i++)
		ans+=cnt[cnt2[i]][cnt5[i]];
	printf("%lld\n",ans/2);
} 

Measured memory_bytes: 3688
import java.util.Scanner;

class Dice {
	int up;
	int front;
	int right;
	int left;
	int back;
	int down;
	
	Dice(int up,int front,int right,int left,int back,int down){
		this.up=up;	this.front=front; this.right=right;
		this.left=left; this.back=back; this.down=down;
	}
	
	void printRight(){	System.out.println(right); }
	
	void rotate(char c){
		int temp;
		if(c=='E'){
			temp=up; up=left; left=down; down=right; right=temp;
		}
		
		if(c=='N'){
			temp=up; up=front; front=down; down=back; back=temp;
		}
		
		if(c=='S'){
			temp=up; up=back; back=down; down=front; front=temp;
		}
		
		if(c=='W'){
			temp=up; up=right; right=down; down=left; left=temp;
		}
	}
	
	void all_rotate(int u,int f,int r,int l,int b,int d){
		for(int i=0;i<4;i++){
			rotate('E');
			for(int j=0;j<4;j++){
				rotate('N');
				for(int k=0;k<4;k++){
					rotate('E');
					if(up==u && front==f && right==r && left==l && back==b && down==d){
						System.out.println("Yes");
						return;
					}
				}
			}
		}
		System.out.println("No");
	}
			
}


class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		
		Dice a=new Dice(scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt());
		Dice b=new Dice(scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt(),scan.nextInt());
		
		b.all_rotate(a.up,a.front,a.right,a.left,a.back,a.down);
		
	}
}


Measured memory_bytes: 26120
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    int a,b,c; cin >> a >> b >> c;
    cout << min(c, b/a) << endl;
    return 0;
}


Measured memory_bytes: 256
import bisect
# from collections import Counter, defaultdict, deque, namedtuple
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    k = int(input())

    count1 = 0
    for i in range(len(s)):
        num = int(s[i])
        if num == 1:
            count1 += 1
            if count1 == k:
                print(1)
                sys.exit()
        if num != 1:
            print(num)
            sys.exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
//long long a[200005];
int main ()
{
    ///without test case
    long long int a,b,c,d,t,n,i,j;
    cin >> a>>b;
    if(a>=1 && a<=9   && b>=1 && b<=9 )
    {
        cout << a*b<<"\n";
    }
    else
    {
        cout<< -1<<"\n";
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N= 1e3+5;
int n,t,m;
int a,b,k,x;
string s1,s2;
int mat[N][N];
vector<int>c(N);
vector<int>algo(N);
int cost= 1e18;


int32_t main()
{
	IOS;
	cin>>n>>m>>x;
	
	c.resize(n);
	algo.resize(m);
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++){
			cin>>mat[i][j];
		}
	}
	
	for(int i=1;i<pow(2,n);i++){
		
		fill(&algo[0], &algo[0]+m,0);
		int flag=0, temp_cost=0;
		for(int j=0;j<n;j++){
			if(i&(1<<j)){
				for(int t=0;t<m;t++){
					algo[t]+= mat[j][t];
				}
				temp_cost+= c[j];
			}
		}
		
		for(int k=0;k<m;k++){
			if(algo[k]<x){
				flag=1;
				break;
			}
		}
		if(flag==0){
			
			cost=min(cost, temp_cost);
			
		}
	}
	if(cost!=1e18)
		cout<<cost<<endl;
	else
		cout<<-1<<endl;
	
}
	 

Measured memory_bytes: 4192
import std.stdio, std.string, std.conv, std.array, std.range, std.algorithm, std.typecons;

void main() {
    long n, k;
    readf("%d %d\n", &n, &k);

    long[] vs = readln.strip.split(" ").map!(to!long).array;
    alias T = Tuple!(long, long, long);
    long[T] dp;

    long solve(long c, long l, long r) {
        auto key = T(c, l, r);
        if (key in dp) {
            return dp[key];
        }
        long[] xs = [0];
        if (c > 0 && l <= r) {
            xs ~= solve(c - 1, l + 1, r) + vs[l];
            xs ~= solve(c - 1, l, r - 1) + vs[r];
        }
        if (c > 1 && l <= r) {
            xs ~= solve(c - 2, l + 1, r);
            xs ~= solve(c - 2, l, r - 1);
        }

        long x = xs[0];
        foreach (i; 1..xs.length) {
            x = max(x, xs[i]);
        }
        dp[key] = x;
        return x;
    }
    writeln(solve(k, 0, n-1));
}



Measured memory_bytes: 10236
N = int(input())
monster = list(map(int, input().split()))
hero = list(map(int, input().split()))
ans = 0

for i in range(N):
    i1_enemy = monster[i]
    i2_enemy = monster[i+1]
    atk = hero[i]
    if atk <= i1_enemy:
        ans += atk
    elif i1_enemy <= atk <= i1_enemy + i2_enemy:
        ans += atk
        monster[i+1] = i1_enemy + i2_enemy - atk
    else:
        ans += i1_enemy + i2_enemy
        monster[i+1] = 0

print(ans)




Measured memory_bytes: 24144
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	string s;
	cin>>s;
	if((s[0]=='R')&&(s[1]=='R')&&(s[2]=='R')){
		cout<<"3"<<endl;
	}
	else if(((s[0]=='R')&&(s[1]=='R')&&(s[2]=='S'))||((s[0]=='S')&&(s[1]=='R')&&(s[2]=='R'))){
		cout<<"2"<<endl;
	}
	else if(((s[0]=='R')&&(s[1]=='S')&&(s[2]=='R'))||((s[0]=='R')&&(s[1]=='S')&&(s[2]=='S'))||((s[0]=='S')&&(s[1]=='S')&&(s[2]=='R'))||((s[0]=='S')&&(s[1]=='R')&&(s[2]=='S'))){
		cout<<"1"<<endl;
	}
	else if((s[0]=='S')&&(s[1]=='S')&&(s[2]=='S'))
	{
		cout<<"0"<<endl;
	}
	return 0;
}

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(ll i=a;i<b;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	ll n,k; cin>>n>>k;
	ll s; cin>>s;
	
	if(s!=1000000000){		
		forn(i,0,k) cout<<s<<" ";
		forn(i,0,n-k) cout<<1000000000<<" ";
		return 0;
	}
	
	if(k==0){
		forn(i,0,n) cout<<1<<" ";
		return 0;
	}
	
	forn(i,0,n){
		if(i%(n-k+1)==0) cout<<s/(n-k+1)+(s%(n-k+1))<<' ';
		else cout<<s/(n-k+1)<<' ';
	}
	
	return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  map<string, int> m;
  vector<pair<int, string>> v;
  for(int i=0; i<n; i++){
    string s; cin >> s;
    m[s]++;
  }
  for(auto a : m){
    v.push_back(make_pair(-a.second, a.first));
  }
  sort(v.begin(), v.end(), greater<>());
  for(int i=v.size()-1; i>=0; i--){
    static int c=v[i].first;
    if(c!=v[i].first) return 0;
    cout << v[i].second << endl;
  }
  return 0;
}

Measured memory_bytes: 29168
N=int(input())
S=[]
total=0

for s in range(N):
    tmp=input()
    S.append("".join(sorted(tmp)))

S=sorted(S)
S_key=list(set(S))
count=[0]*len(S_key)
S_dict=dict(zip(S_key,count))


for s in S:
    total+=S_dict[s]
    S_dict[s]+=1

print(total)

Measured memory_bytes: 23992
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
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;}


template<typename F>
struct FixPoint : F{
  FixPoint(F&& f):F(forward<F>(f)){}
  template<typename... Args>
  decltype(auto) operator()(Args&&... args) const{
    return F::operator()(*this,forward<Args>(args)...);
  }
};
template<typename F>
inline decltype(auto) MFP(F&& f){
  return FixPoint<F>{forward<F>(f)};
}

//INSERT ABOVE HERE
signed main(){
  Int h;
  cin>>h;
  auto dfs=
    MFP([&](auto dfs,Int v)->Int{
          if(v==1) return 1;
          return dfs(v/2)*2+1;
        });
  cout<<dfs(h)<<endl;
  return 0;
}


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

using namespace std;

#define INF 1000000000
#define pb(a) push_back(a)
#define vi vector<int>
#define vvi vector<vi>
#define P pair<int,int>
#define all(vec) (vec.begin()),(vec.end())
#define ll long long
#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x;
#define bit(n) (1<<(n))

#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define REP3(i, m, n) for(int i = m, i##_len=(n);i < i##_len;i++)
#define FORVEC(i, v) for(int i = 0;i < sz(v);i++)


int main(){
	string s;
	cin>>s;
	s[3]='8';
	cout<<s<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5+5; 
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

ll raise(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}


ll d, t, s;

void solve()
{
    cin >> d >> t >> s;
    if (d<=t*s) nout("Yes");
    else nout("No");
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

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

int main(){
    int X, Y, Z, K;
    std::cin >> X >> Y >> Z >> K;
    std::vector< long long > A(X);
    std::vector< long long > B(Y);
    std::vector< long long > C(Z);
    for(int i=0; i<X; i++){
        std::cin >> A[i];
    }
    for(int i=0; i<Y; i++){
        std::cin >> B[i];
    }
    for(int i=0; i<Z; i++){
        std::cin >> C[i];
    }
    
    std::priority_queue< long long > AB_pq;
    for(int i=0; i<X; i++){
        for(int j=0; j<Y; j++){
            AB_pq.push(A[i] + B[j]);
        }
    }
    
    int K_ab = std::min(K, X * Y);
    std::vector< long long > AB(K_ab);
    for(int i=0; i<K_ab; i++){
        AB[i] = AB_pq.top();
        AB_pq.pop();
    }
    
    
    std::priority_queue< long long > ABC_pq;
    for(int i=0; i<K_ab; i++){
        for(int j=0; j<Z; j++){
            ABC_pq.push(AB[i] + C[j]);
        }
    }
    
    for(int i=0; i<K; i++){
        std::cout << ABC_pq.top() << std::endl;
        ABC_pq.pop();
    }
    
    
    return 0;
}



Measured memory_bytes: 44120