akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

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

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> L) {
  LL maxim = 0;
  LL sum = 0;
  for (int i = 0; i < L.size(); i++) {
    auto& l = L[i];
    chmax(maxim, l);
    sum += l;
  }
  cout << ((maxim * 2 < sum) ? YES : NO) << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &L[i]);
  }
  solve(N, std::move(L));
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define acc(v) accumulate(v.begin(), v.end(), 0)

using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
	ll a, b, k;
	cin >> a >> b >> k;
	a -= k;
	if(a < 0){
		b += a;
		a = 0;
	}
	if( b < 0){
		b = 0;
	}
	cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-12;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

struct info {
	char c;
	pii u, d;
	info(char c, pii u, pii d) : c(c), u(u), d(d) {};
	bool operator<(const info &o)const {
		return o.c<c;
	}
};

int main() {
	int n;
	cin >> n;
	REP(_, n) {
		int H, W;
		cin >> H >> W;
		vs field(H);
		vi flag(26);
		REP(i, H) {
			cin >> field[i];
			REP(j, W) {
				if(field[i][j] != '.') {
					flag[field[i][j]-'A'] = 1;
				}
			}
		}
		vector<info> data;
		REP(i, 26) {
			if(flag[i]) {
				data.push_back(info('A'+i, pii(INF, INF), pii(0, 0)));
			}
		}

		int size = data.size();
		REP(i, size) {
			REP(j, H) {
				REP(k, W) {
					if(field[j][k] == data[i].c) {
						data[i].u.first = min(data[i].u.first, j);
						data[i].u.second = min(data[i].u.second, k);
						data[i].d.first = max(data[i].d.first, j);
						data[i].d.second = max(data[i].d.second, k);
					}
				}
			}
		}

		sort(ALL(data));
		bool safe = false;
		do {
			REP(i, size-1) {
				FOR(j, i+1, size-1) {
					FOR(y, data[j].u.first, data[j].d.first) {
						FOR(x, data[j].u.second, data[j].d.second) {
							if(field[y][x] == data[i].c) {
								goto next;
							}
							if(field[y][x] == '.') {
								goto show;
							}
						}
					}
				}
			}
			safe = true;
			break;
			next:;
		} while(next_permutation(ALL(data)));
		
		show:;
		cout << (safe ? "SAFE" : "SUSPICIOUS") << endl;
	}

	return 0;
}

Measured memory_bytes: 1220
from collections import defaultdict

v_num, e_num, flow = (int(n) for n in input().split(" "))
edges = defaultdict(list)
for _ in range(e_num):
    s1, t1, cap, cost = (int(n) for n in input().split(" "))
    edges[s1].append([t1, cap, cost, len(edges[t1])])
    edges[t1].append([s1, 0, -cost, len(edges[s1]) - 1])
answer = 0
before_vertice = [float("inf") for n in range(v_num)]
before_edge = [float("inf") for n in range(v_num)]
sink = v_num - 1
while True:
    distance = [float("inf") for n in range(v_num)]
    distance[0] = 0
    updated = 1
    while updated:
        updated = 0
        for v in range(v_num):
            if distance[v] == float("inf"):
                continue
            for i, (target, cap, cost, trace_i) in enumerate(edges[v]):
                if cap > 0 and distance[target] > distance[v] + cost:
                    distance[target] = distance[v] + cost
                    before_vertice[target] = v
                    before_edge[target] = i
                    updated = 1
    if distance[sink] == float("inf"):
        print(-1)
        break
    decreased = flow
    trace_i = sink
    while trace_i != 0:
        decreased = min(decreased, edges[before_vertice[trace_i]][before_edge[trace_i]][1])
        trace_i = before_vertice[trace_i]
    flow -= decreased
    trace_i = sink
    while trace_i != 0:
        this_edge = edges[before_vertice[trace_i]][before_edge[trace_i]]
        this_edge[1] -= decreased
        answer += this_edge[2] * decreased
        edges[trace_i][this_edge[3]][1] += decreased
        trace_i = before_vertice[trace_i]
    if flow <= 0:
        print(answer)
        break

Measured memory_bytes: 8416
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    string s;cin>>s;
    ll cnt=0;
    ll ans=1;
    ll a=0,b=0;
    rep(i,n*2){
        if(s[i]=='B'){
            if(cnt%2==0){
                cnt++;
                a++;
            }
            else{
                ans*=cnt;
                ans%=inf;
                cnt--;
                b++;
            }
        }else{
            if(cnt%2==0){
                ans*=cnt;
                ans%=inf;
                cnt--;
                b++;
            }else{
                cnt++;
                a++;
            }
        }
    }
    rep(i,n){
        ans*=i+1;
        ans%=inf;
    }
    if(a!=b)ans=0;
    cout<<ans<<endl;
}

Measured memory_bytes: 644
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
     Scanner scan = new Scanner(System.in);
     int[] x = new int[3];
     x[0] = scan.nextInt();
     x[1] = scan.nextInt();
     x[2] = scan.nextInt();
     java.util.Arrays.sort(x);
     System.out.println(x[0]+" "+x[1]+" "+x[2]);
    }
}


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


int main() {
  int N;
  cin >>N;
  
  int M =2*N;
  
  vector<int> vec(M);
  
  for (int i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  
  int K=0;
  
  for (int i = 0; i < M-5; i++) {
    if(i%2==0){
      if(vec.at(i)==vec.at(i+1)){
        if(vec.at(i+2)==vec.at(i+3)){
          if(vec.at(i+4)==vec.at(i+5)){
            K --;
          }
          else{
            K ++;
          }
        }
        else{
          K ++;
        }
      }
      else{
        K ++;
      }
    }
    else{
      K ++;
    }
  }
  if(K==M-5){
    cout << "No" <<endl;
  }
  else{
    cout << "Yes" <<endl;
  }
}


Measured memory_bytes: 3632
from functools import reduce


def gcd(a, b):
    if a < b:
        return gcd(b, a)
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


N, K = map(int, input().split())
A = list(map(int, input().split()))
g = reduce(gcd, A)
print("POSSIBLE" if K % g == 0 and K <= max(A) else "IMPOSSIBLE")


Measured memory_bytes: 14596
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int a, b;
	cin >> a >> b;

	cout << a - b + 1 << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void){
    char s[101];
    scanf("%s", s);

int n = strlen(s);
int m = n / 2;

int count = 0;

    for(int i = 0; i < m; i++){
        if(s[i] != s[n - 1 - i]){
            count++;
        }
    }

    printf("%d", count);
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c){
		printf("%d %d %d\n",a,b,c);
	}
	else if(a<=c&&c<=b){
		printf("%d %d %d\n",a,c,b);
	}
	else if(b<=a&&a<=c){
		printf("%d %d %d\n",b,a,c);
	}
	else if(b<=c&&c<=a){
		printf("%d %d %d\n",b,c,a);
	}
	else if(c<=a&&a<=b){
		printf("%d %d %d\n",c,a,b);
	}
	else if(c<=b&&b<=a){
		printf("%d %d %d\n",c,b,a);
	}
	
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;
vector<int>node[100009];
int ans[100009],mx[100009],p[100009],t[100009];

int main(){
  int n,m;
  cin>>n>>m;
  for(int i=0;i<n+m-1;i++){
    int a,b;
    cin>>a>>b;
    node[a].push_back(b);
    p[b]++;
  }
  int s;
  for(int i=1;i<=n;i++){
    if(p[i]==0){
      s=i;
    }
  }

  queue<P>que;
  que.push(P(s,0));
  while(!que.empty()){
    P now_p=que.front();que.pop();
    int now=now_p.first;
    int cnt=now_p.second;
    for(int i=0;i<node[now].size();i++){
      int next=node[now][i];
      if(cnt+1>mx[next]){
	mx[next]=cnt+1;
	ans[next]=now;
      }
      t[next]++;
      if(t[next]==p[next]){
	que.push(P(next,cnt+1));
      }
    }
  }
  
  for(int i=1;i<=n;i++){
    cout<<ans[i]<<endl;
  }
  return(0);
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
 #define rep(i,a,b) for (int i=a;i<b;i++)
 #define rep2(i,a,b) for (int i=a;i>=b;i--)
 #define mod 1000000007
 #define INF  1e9+5
 #define f first
 #define se second
 #define endl '\n'
 #define ll long long
 #define ii pair <int,int>
 #define pll pair <ll,ll>
 #define vi vector <int>
 #define vl vector <ll>
 #define vvi vector < vi >
 #define vii vector < ii >
 #define vvii vector < vii >
 #define vll vector < ll >
 #define mi map<int,int>
 #define mll map<ll,ll>
 #define mci map<char,int>
 #define msi map<string,int>
 #define vb  vector <bool>
 #define pb push_back
 #define mk make_pair
 #define sz(a) a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define int long long int
 #define Anurag_Gupta ios_base::sync_with_stdio(false);
#define IIIT_ALLD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
vi fact(1000007);
inline int mdpower(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
inline int power(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res*a);
        b/=2;
        a = a*a;
    }
    return res;
}

inline void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}

inline int inverse(int a)
{
    return mdpower(a,mod-2);
}
 signed main()
 {
     Anurag_Gupta
     IIIT_ALLD
     
   /*  #ifndef ONLINE_JUDGE
         freopen("input.txt","r",stdin);
         freopen("output.txt","w",stdout);
     #endif*/
         int H,W,h,w;
         cin>>H>>W>>h>>w;
         int ans = h*W+w*H-h*w;
            cout<<H*W-ans<<"\n";
 }


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

void solve() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);

    int t = 1;
//    cin>>t;
    for(; t; t--) {
    	solve();
	}
	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define N 1003
#define llong long long
#define veto vector<int>
#define _pair pair<llong, llong>
#define MP make_pair
#define fi first
#define se second
using namespace std;
int n,m;
string a[N];
int d[N][N];
queue<_pair> q;
int X[]={-1,0,0,1};
int Y[]={0,-1,1,0};
bool inT(int u, int v){return (u >= 1)&&(u <= n)&&(v >= 1)&&(v <= m)&&(d[u][v] == -1);}
int main()
{
    ios::sync_with_stdio(0);
    cin>>n>>m;
    for (int i=1; i <= n; i++){
        cin>>a[i];
        a[i].insert(0," ");
    }
    memset(d,-1,sizeof d);
    for (int i=1; i <= n; i++)
        for (int j=1; j <= m; j++)
            if (a[i][j] == '#'){
                d[i][j]=0;
                q.push(MP(i,j));
            }
    int res=0;
    while (!q.empty()){
        _pair p=q.front(); q.pop();
        int u=p.fi, v=p.se;
        res=max(res,d[u][v]);
        for (int i=0; i < 4; i++){
            int nu=u+X[i];
            int nv=v+Y[i];
            if (inT(nu,nv)&&(a[nu][nv] == '.')){
                d[nu][nv]=d[u][v]+1;
                q.push(MP(nu,nv));
            }
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 22580
#総数少ないのでしらみつぶしできる
n = int(input())
#再帰なし版
su753 = set([0])
#リスト内包表記にif
#集合和演算
for _ in range(10):
    tmp = set()
    for x in su753:
        tmp |= set(x*10+y for y in [3,5,7])
    su753 |= tmp 

st = set(str(x) for x in su753 if x<=n)
st = set(x for x in st if set(x)==set('357'))
print(len(st))


Measured memory_bytes: 22040
#include<bits/stdc++.h>
#define re register
using namespace std;
typedef long long ll;
typedef double db;
const ll inf=2e9,N=2001001,MAX=2001;
inline void read(register ll &ret)
{
    ret=0;register ll pd=0;register char c=getchar();
    while(!isdigit(c)){pd|=c=='-';c=getchar();}
    while(isdigit(c)){ret=(ret<<1)+(ret<<3)+(c^48);c=getchar();}
    ret=pd?-ret:ret;
}
ll n,d[N],sum[2001][1001],ans,w[2001][1001];
int main()
{
	read(n);
	for(re int i=1;i<=n;i++)
		read(d[i]);
	sort(d+1,d+n+1);
	for(re int i=1;i<=n;i++)
	{
		for(re int j=i;j<=n;j++)
			w[i][d[j]]++;
		for(re int j=1;j<=1000;j++)
			sum[i][j]=sum[i][j-1]+w[i][j];
	}
	for(re int i=1;i<=n-2;i++)
	{
		for(re int j=i+1;j<=n-1;j++)
		{
			re ll l=d[j]-d[i]+1,r=min(d[i]+d[j]-1,1000ll);
			ans+=sum[j+1][r]-sum[j+1][l-1];
		}
	}
	printf("%lld\n",ans);
	exit(0);
}



Measured memory_bytes: 33024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

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

  if(s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <list>

using namespace std;

struct Pair {
	unsigned int x;
	unsigned int y;
	bool operator<(const Pair& r)
		{ return (y < r.y)||((y == r.y)&&(x < r.x)); }
};

int main()
{
	unsigned int n, m, ans = 0;
	cin >> n >> m;

	list<Pair> rl;

	for(unsigned int i = 0; i < m; ++i) {
		Pair p;
		cin >> p.x >> p.y;
		rl.push_back(p);
	}

	rl.sort();
	do {
		list<Pair>::iterator i = rl.begin();
		unsigned int x = i->y - 1;
		rl.erase(i++);
		++ans;
		list<Pair>::iterator ie = rl.end();
		while(i != ie) {
			if (i->x <= x && i->y > x)
				rl.erase(i++);
			else ++i;
		}
	} while ( ! rl.empty());

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


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  double p[N];
  for(int i=0;i<N;i++) cin >> p[i];

  double dp[N][N+1]; //dp[i][j]:i番目まで投げた時表がj枚の確立
  dp[0][0]=1-p[0];
  dp[0][1]=p[0];
  for(int j=2;j<=N;j++) dp[0][j]=0;

  for(int i=1;i<N;i++){
    dp[i][0]=dp[i-1][0]*(1-p[i]);
  }

  for(int i=1;i<N;i++){
    for(int j=1;j<=N;j++){
      dp[i][j]=dp[i-1][j-1]*p[i]+dp[i-1][j]*(1-p[i]);
    }
  }

  /*for(int j=0;j<=N;j++){
    for(int i=0;i<N;i++){
      printf("%lf ",dp[i][j]);
    }
    printf("\n");
  }*/

  double sum=0;
  for(int j=(N+1)/2;j<=N;j++){
    sum+=dp[N-1][j];
  }

  printf("%.10f\n",sum);
  return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define MAX 100005

int n,q;
int arr[MAX];


void updateTree(int index, int *st){
    if(index==0){
        if(index+2<n){
            st[index] = min(st[index+1],st[index+2]);
        }
        return;
    }
    if(index%2==0){
        st[(index-1)/2] = min(st[index-1],st[index]);
        updateTree((index-1)/2, st);
    }
    else{
        st[(index-1)/2] = min(st[index+1],st[index]);
        updateTree((index-1)/2, st);
    }
}

int updatePos(int pos, int value, int ss, int se, int index, int *st){
    if(ss==se){
        if(se==pos){
            st[index] = value;
            //printf("change %d to %d\n",index,value);
            return index;
        }
    }
    if(pos>=ss && pos<=se){
        if(st[index] > value){
            st[index]=value;
            //printf("change %d to %d\n",index,value);
        }
        int mid = (ss+se)/2;
        if(pos<=mid){
            return updatePos(pos, value, ss, mid, index*2+1,st);
        }
        else{
            return updatePos(pos, value, mid+1, se, index*2+2,st);
        }
    }
}

int getSmallest(int ss, int se, int qs, int qe, int *st, int index){
    if(qs<=ss && qe>=se){
        return st[index];
    }
    if(se<qs || qe<ss){
        return INT_MAX;
    }
    int mid = (ss+se)/2;
    return min(getSmallest(ss,mid,qs,qe,st,2*index+1),
               getSmallest(mid+1,se,qs,qe,st,2*index+2));
}

int constructSTUtil(int ss, int se, int *st, int index){
    if(ss==se){
        st[index] = arr[ss];
        return st[index];
    }
    int mid = (ss+se)/2;
    st[index] = min(constructSTUtil(ss, mid, st, 2*index+1),
                    constructSTUtil(mid+1, se, st, 2*index+2));
    return st[index];
}

int* constuctSegTree(){
    int x = (int)(ceil(log2(n)));
    // Maximum size of segment tree
    int max_size = 2*(int)pow(2, x) - 1;
    int *st = new int[max_size];
    constructSTUtil(0, n-1, st, 0);
    return st;
}

int main(){
    int comd, x, y, res, index;
    //FILE *fp=fopen("In3.txt","r");
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;++i) arr[i] = INT_MAX;
    int *st = constuctSegTree();
    for(int i=0;i<q;++i){
        scanf("%d %d %d",&comd,&x,&y);
        if(comd==0){
            index = updatePos(x, y, 0, n-1, 0,st);
            updateTree(index,st);
        }
        if(comd==1){
            res = getSmallest(0,n-1,x,y,st,0);
            printf("%d\n",res);
        }
    }
    return 0;
}



Measured memory_bytes: 4864
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public long factorial(long n) {
		if (n == 1) return 1;
		else return n*factorial(n-1);
	}

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

		Main m = new Main();

		while (sc.hasNext()) {
			System.out.println(m.factorial(sc.nextLong()));
		}

	}
}

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

public class Main {
    //-------------------------------------------------------------//
    public static final void main(String[] args) {
        new Main().solve();
    }
    //-------------------------------------------------------------//
    private final Scanner sc = new Scanner(System.in);

    int N, M, Q;
    boolean[][] memo;
    int[] color;
    ArrayList<ArrayList<Integer>> g = new ArrayList<ArrayList<Integer>>();
    void dfs(int v, int d, int c) {
        if (d < 0 || memo[d][v]) return;
        if (color[v] == 0) color[v] = c;
        memo[d][v] = true;
        dfs(v, d - 1, c);
        for (int n : g.get(v)) {
            dfs(n, d - 1, c);
        }
    }

    void solve() {
        N = sc.nextInt();
        M = sc.nextInt();
        for (int i = 0; i < N; i++) g.add(new ArrayList<Integer>());
        for (int i = 0; i < M; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            g.get(a).add(b);
            g.get(b).add(a);
        }
        Q = sc.nextInt();
        int[] v = new int[Q];
        int[] d = new int[Q];
        int[] c = new int[Q];
        for (int i = 0; i < Q; i++) {
            v[i] = sc.nextInt() - 1;
            d[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        memo = new boolean[11][N];
        color = new int[N];
        Arrays.fill(color, 0);
        for (int i = Q - 1; i >= 0; i--) {
            dfs(v[i], d[i], c[i]);
        }
        PrintWriter w = new PrintWriter(System.out);
        for (int i = 0; i < N; i++) {
            w.println(color[i]);
        }
        w.flush();
    }
}

Measured memory_bytes: 169012
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	
	static boolean isPerfectSquare(long x)  
    { 
          
        // Find floating point value of 
        // square root of x. 
        double sr = Math.sqrt(x); 
      
        // If square root is an integer 
        return ((sr - Math.floor(sr)) == 0); 
    } 
	
	
	 static boolean checkPrime(long n) 
	    { 
	        // Converting long to BigInteger 
	        BigInteger b = new BigInteger(String.valueOf(n)); 
	  
	        return b.isProbablePrime(1); 
	    } 
	
	static void canMultiply(long a) {
		
	
	List<Long> list=new ArrayList<Long>();
 for (long i=1; i<=Math.sqrt(a); i++) 
    { 
        if (a%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (a/i == i) 
            list.add(i);    //printf("%d ", i); 
  
            else {// Otherwise print both 
               // printf("%d %d ", i, a/i); 
            list.add(i);
            list.add(a/i);
        } }
    } 
 
 Collections.sort(list);
 
 for(int i=1;i<list.size();i++) {
	 
	if(list.get(i)*list.get(i-1)==a) {
		System.out.println(list.get(i)+list.get(i-1)-2);
	}
 }
} 
		
	
	
	
	
	static void check(long a) {
		List<Long> list =new ArrayList<Long>();
		
		for(long i=1;i<=a;i++) {
			for(long j=1;j<=a;j++) {
				
				if(i*j==a) {
					list.add(i+j-2);
					
				}
				
			}
			
		}
		System.out.println(Collections.min(list));

	}
		public static void main(String[] args) {
			
			Scanner sc =new Scanner(System.in);
			
			
			long a,b;
			a=sc.nextLong();
			
			
			
			if(a<100) {
				check(a);
				
			}
			else {
			
			if(checkPrime(a)) {
				System.out.println(a-1);
			}
			else if(isPerfectSquare(a)) {
				System.out.println(2*(int)Math.sqrt(a)-2);

			}
			else {
			canMultiply(a);
			}
			
			
		
		}
		}
}


Measured memory_bytes: 23636
#ABC-125-B
import numpy as np
N = int(input())
V = list(map(int, input().split()))
C = list(map(int, input().split()))

VminusC = np.array(V) - np.array(C)

ans = 0
for item in VminusC:
    if item > 0:
        ans += item
        
print(ans)

Measured memory_bytes: 12508
//intのオーバーフローに気をつけろ,AGCはだいたいlongにしておけ
//毎回余りを求めることでオーバーフローしなくなる
//nextLineよりnextだ
//charは''で囲うんだぞ
//読み込みは先に全部やっておけ
//for文を回す回数に気をつけろ
	//for文は10^3の三重はTLE,10^5の二重はTLE
//貪欲は使えるか？？試した？？

import java.util.Scanner;

public class Main {

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

		    long a = sc.nextLong();
		    long b = sc.nextLong();
		    long x = sc.nextLong();
		    long ans = 0;
		    
		    if( a == 0 ) {
		    	ans += b / x + 1;
		    }else {
		    	ans += b / x;
		    	if( a % x == 0) {
		    		ans -= a / x - 1;
		    	}else {
		    		ans -= a / x;
		    	}
		    }
		    
		    System.out.println(ans);
		    
		    sc.close(); }

	public static void saiki(int a, String b) {
		//再帰コーディングのお手本

		if(a == 0) {
			System.out.println(b);
		}else {
			for(char ch = 'a'; ch <= 'c'; ch++) {
				saiki(a-1,b + ch);
			}
		}
	}

	public static  int gcd(int a, int b) {
	    if (a < b) {
	        int tmp = a;
	        a = b;
	        b = tmp;
	    }

	    int r = -1;
	    while (r != 0) {
	        r = a % b;
	        a = b;
	        b = r;
	    }

	    return a;
	}
}


Measured memory_bytes: 23124
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/21/20 20:55:02
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k; cin>>n>>k;
  vector<int> P(n); for (auto& p:P) cin>>p;
  sort(P.begin(), P.end());
  int ans = 0;
  for (int i = 0; i < k; i++)
    ans += P[i];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val N  = nextInt()
    val A = listOfInt()
    if (N % 3 != 0) {
        println(if (A.all { it == 0 }) "Yes" else "No")
        return
    }
    var M = A.groupBy { it }.map { Pair(it.key, it.value.size) }.sortedBy { it.second }
    if (M.size == 1) {
        println(if (M[0].first == 0) "Yes" else "No")
        return
    }
    if (M.size == 2) {
        println(if (M[0].first == 0 && M[0].second * 2 == M[1].second) "Yes" else "No")
        return
    }
    if (M.size == 3) {
        println(if (M.groupBy { it.second }.size == 1 && M[0].first xor M[1].first == M[2].first) "Yes" else "No")
        return
    }
    println("No")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 63780
#include <stdio.h>
#include <string.h>

int main(void) {
    char str[20];
    int i, len;
    
    scanf("%s", str);
    
    len = (int)strlen(str);
    
    for(i = len - 1; i >= 0; i--) {
        printf("%c", str[i]);
    }
    
    putchar('\n');
    
    return(0);
}

Measured memory_bytes: 524
MOD = 998244353
MAX = int(2e5)


def div(a, b):
    return a * pow(b, MOD-2, MOD) % MOD


FACT = [1] * (MAX+1)
for i in range(1, MAX+1):
    FACT[i] = (i * FACT[i-1]) % MOD
INV = [1] * (MAX+1)
INV[MAX] = div(1, FACT[MAX])
for i in range(MAX, 0, -1):
    INV[i-1] = (INV[i] * i) % MOD


def main():
    N, M, K = map(int, input().split())
    ans = 0
    for i in range(K+1):
        tmp = M * pow(M-1, (N-1-i), MOD) % MOD
        # (N-1)Ci
        tmp = tmp * FACT[N-1] * INV[N-1-i] * INV[i] % MOD
        ans = (ans + tmp) % MOD
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 71228
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d;
	if(a<b)e=a;
	else e=b;
	if(c<d)f=c;
	else f=d;
	cout<<e+f<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	LL N;
	cin>>N;
	for(LL a=1;a<=3500;++a){
		for(LL b=1;b<=3500;++b){
			LL bo = a*b*4-N*a-N*b;
			if(bo<=0){
				continue;
			}
			LL si = N*a*b;
			if(si%bo != 0 ){
				continue;
			}
			LL c = si/bo;
			cout<<a<<" "<<b<<" "<<c<<endl;
			return;
		}
	}
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1e9+7
#define PI acos(-1.0)
#define ll long long
#define INF 1000000001

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b,c;cin>>a>>b>>c;
  P(min(a+b, min(b+c, c+a)));
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n , a[maxn] , k , mx = 0;
int main()
{
	scanf("%d %d" , &n , &k);
	for(int i = 1; i <= n; i ++) scanf("%d" , a + i) , mx = max(mx , a[i]);
	if(mx < k) return puts("IMPOSSIBLE") , 0;
	int d = a[1]; for(int i = 2; i <= n; i ++) d = __gcd(d , a[i]);
	if(k % d) puts("IMPOSSIBLE");
	else puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 640
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on July 27, 2018, 12:10 PM
 */

#include <stdio.h>
#include <stdlib.h>
#define MAX 100

/*
 * 
 */
int M[MAX][MAX];
int n, u, k, v;

void makeGraph(int size);

int main(int argc, char** argv) {
    scanf("%d", &n);
    
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j) M[i][j] = 0;
    
    makeGraph(n);
    
    for (int j = 0; j < n; ++j)
    {
        for (int jx = 0; jx < n; ++jx)
        {
            if (jx) printf(" ");
            printf("%d", M[j][jx]);
        }
        printf("\n");
    }
    return (EXIT_SUCCESS);
}

void makeGraph(int size)
{
    for (int i = 0; i < size; ++i)
    {
        scanf("%d %d", &u, &k);
        u--;
        for (int ix = 0; ix < k; ++ix)
        {
            scanf("%d", &v);
            v--;
            M[u][v] = 1;
        }
    }
}




Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

string f[50];
int maxX[26], maxY[26], minX[26], minY[26];
bool on[26][26];
bool used[26];

bool dfs(int n, int prev) {
	if(used[n]) {
		return false;
	}
	used[n] = true;
	for(int i = 0; i < 26; i++) {
		if(on[n][i] && i != prev && i != n) {
			if(!dfs(i, n)) return false;
		}
	}
	used[n] = false;
	return true;
}

void check() {
	memset(on, 0, sizeof on);
	memset(used, 0, sizeof used);
	for(int i = 0; i < 26; i++) {
		if(maxX[i] == -1) continue;
		for(int y = minY[i]; y <= maxY[i]; y++) {
			for(int x = minX[i]; x <= maxX[i]; x++) {
				if(f[y][x] == '.') {
					cout << "SUSPICIOUS" << endl;
					return;
				}
				if(f[y][x] != 'A' + i) {
					on[i][f[y][x] - 'A'] = true;
				}
			}
		}
	}

	for(int k = 0; k < 26; k++) {
		for(int i = 0; i < 26; i++) {
			for(int j = 0; j < 26; j++) {
				on[i][j] |= on[i][k] & on[k][j];
			}
		}
	}

	for(int i = 0; i < 26; i++) {
		for(int j = 0; j < 26; j++) {
			if(on[i][j] && on[j][i]) {
				cout << "SUSPICIOUS" << endl;
				return;
			}
		}
	}
	cout << "SAFE" << endl;
}

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

	int T, H, W;
	cin >> T;
	while(T--) {
		cin >> H >> W;
		for(int i = 0; i < H; i++) {
			cin >> f[i];
		}

		for(int i = 0; i < 26; i++) {
			maxX[i] = maxY[i] = -1;
			minX[i] = minY[i] = 100000;
		}

		for(int y = 0; y < H; y++) {
			for(int x = 0; x < W; x++) {
				if(f[y][x] == '.') continue;
				int c = f[y][x] - 'A';
				maxX[c] = max(maxX[c], x);
				maxY[c] = max(maxY[c], y);
				minX[c] = min(minX[c], x);
				minY[c] = min(minY[c], y);
			}
		}

		check();
	}
}

Measured memory_bytes: 3184
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <string.h>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

#ifndef INT_MAX
#  define INT_MAX std::numeric_limits<int>().max()
#endif
#ifndef INT_MIN
#  define INT_MIN std::numeric_limits<int>().min()
#endif
#define LL_MAX std::numeric_limits<ll>().max()
#define LL_MIN std::numeric_limits<ll>().min()
#define INF LL_MAX

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
// 配列の初期化
#define ZERO(p) memset(p, 0, sizeof(p))
// 配列の初期化(-1)
#define MINUS(p) memset(p, 1, sizeof(p))

#define MAX_S 105

int main()
{
    const string alph = "abcdefghijklmnopqrstuvwxyz";
    const size_t alph_size = 26;
    int res = 1000000;
    string s;
    cin >> s;

    REP(i, alph_size) {
        char comp = alph[i];
        string s_tmp = s;
        string s_next = "";
        int res_tmp = 0;
        bool isSame = false;
        //printf("use %c string %s\n", comp, s_tmp.c_str());
        while(!isSame) {
            //printf("  %s\n", s_tmp.c_str());
            isSame = true;
            REP(j, s_tmp.size()) {
                if(s_tmp[j] != comp){ isSame = false; }
            }
            if(isSame) {
                //printf("%d\n", res_tmp);
                res = min(res, res_tmp);
                break;
            }
            s_next = "";
            REP(j, s_tmp.size()-1) {
                if(s_tmp[j] == comp) {
                    s_next += comp;
                    continue;
                } else {
                    if(s_tmp[j+1] == comp) {
                        s_next += s_tmp[j+1];
                    } else {
                        s_next += s_tmp[j];
                    }
                }
            }
            s_tmp = s_next;
            res_tmp++;
        }
    }

    printf("%d\n", res);

    return 0;
}


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

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

int main()
{
  string o, e, n;
  cin >> o >> e;
  forll(i, 0, o.size()){
    if (i < e.size())
      n += {o[i], e[i]};
    else
      n += {o[i]};
  }
  cout << n << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
li=[list(map(int,input().split())) for _ in range(n)]
li.sort()
an=0

for i in range(n):
    if m > li[i][1]:
        an+=li[i][0]*li[i][1]
        m-=li[i][1]
    else:
        an+=m*li[i][0]
        print(an)
        exit()

Measured memory_bytes: 27760
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLL = vector<PLL>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    LL a, b, c, k;
    cin >> a >> b >> c >> k;

    if (k%2==0) cout << a - b << endl;
    else cout << b - a << endl;

    return 0;
}


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

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

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

ll dp[55][55][2550];

int main(){
	int N,A; cin >> N >> A;
	vector<int> x(N);
	rep(i,N) cin >> x[i];
	dp[0][0][0] = 1;
	rep(i,N)rep(j,N+1)rep(k,2550){
		if(j >= 1 && k-x[i] >= 0) dp[i+1][j][k] += dp[i][j-1][k-x[i]];
		dp[i+1][j][k] += dp[i][j][k];
	}
	ll ans = 0;
	repr(j,1,N+1)rep(k,2550){
		if(k % j == 0 && k / j == A) ans += dp[N][j][k];
	}
	cout << ans << endl;
}



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

int main()
{
    ll a, b, k; cin >> a >> b >> k;
    
    ll a_ans, b_ans;
    
    if (k <= a) {
        a_ans = a - k;
        b_ans = b;
    }
    else {
        a_ans = 0;
        b_ans = max(0LL, b - k + a);
    }

    cout << a_ans << " " << b_ans << endl;
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0);
	
	int n, k; cin >> n >> k;
	vector<int> v(n);
	for (int &x : v) cin >> x;
	sort(v.begin(), v.end());
	
	cout << accumulate(v.begin(), v.begin() + k, 0LL) << "\n";
	
}


Measured memory_bytes: 3652
s = gets.chomp
t = gets.chomp

ns = s.size
nt = t.size

ss = []
(ns - nt + 1).times do |i|
    nt.times do |j|
        break if s[i + j] != "?" && s[i + j] != t[j]
    end or next
    (x = s.clone)[i, nt] = t
    ss << x.gsub("?", "a")
end

puts ss.empty? ? "UNRESTORABLE" : ss.min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	set<string> ss;
	REP(i, N) {
		string s;
		cin >> s;
		ss.insert(s);
	}
	cout << ss.size() << endl;
	return 0;
}


Measured memory_bytes: 19120
using System;

namespace Csharp_ITP1 {
    class ITP1_3_B {
        static void Main() {
            var i = 1;
            var n = 1;
            while (n != 0) {
                n = int.Parse(Console.ReadLine().Trim());
                if (n != 0) Console.WriteLine("Case {0}: {1}", i, n);
                i++;
            }
        }
    }
}


Measured memory_bytes: 20052
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;
using ll=long long;
using pint=pair<int,int>;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define el '\n'
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl
#define $in(v,n) ;rep(II,0,n)cin>>v[II]
inline void IN(void){return;}
template<typename F,typename... R>inline void IN(F& f, R&... r){cin>>f;IN(r...);}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

 
int main(){
	int a,b; IN(a,b);
	if(a>=10 || b>=10){
		cout << -1 << el;
		return 0;
	}
	cout << a*b << el;
    return 0;
}


Measured memory_bytes: 3196
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if (A * B % 2 == 0) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23252
def main():
    import sys
    input = sys.stdin.readline
    import heapq
    from collections import defaultdict

    N=int(input())
    A=[0]+list(map(int,input().split()))

    def Nextstring(nowlength,nextlength):
        if nextlength>nowlength:
            while -USELIST[0]>nowlength:
                dis=-heapq.heappop(USELIST)
                del NOWSTR[dis]
            nowlength=nextlength

        else:
            while -USELIST[0]>nextlength:
                dis=-heapq.heappop(USELIST)
                del NOWSTR[dis]

            if NOWSTR[nextlength]<mid-1:
                
                if NOWSTR[nextlength]==0:
                    NOWSTR[nextlength]+=1
                    heapq.heappush(USELIST,-nextlength)
                    nowlength=nextlength
                else:
                    NOWSTR[nextlength]+=1
                    nowlength=nextlength

            else:
                klength=nextlength
                while NOWSTR[klength]==mid-1:
                    if klength in NOWSTR:
                        del NOWSTR[klength]
                    klength-=1
                    if mid!=1:
                        dis=-heapq.heappop(USELIST)
                        if dis in NOWSTR:
                            del NOWSTR[dis]

                    if klength==0:
                        return -1

                if NOWSTR[klength]==0:
                    NOWSTR[klength]+=1
                    heapq.heappush(USELIST,-klength)
                    nowlength=nextlength

                else:
                    NOWSTR[klength]+=1
                    nowlength=nextlength

        return 0

    for i in range(N):
        if A[i]>=A[i+1]:
            MIN=2
            break
    else:
        print(1)
        sys.exit()

    from collections import Counter
    MAX=max(Counter(A).values())+1

    while MIN!=MAX:
        mid=(MIN+MAX)//2
        nowlength=0
        NOWSTR=defaultdict(int)
        USELIST=[10**6]

        for i in range(N):

            if Nextstring(A[i],A[i+1])==-1:
                MIN=mid+1
                break
            #print(mid,NOWSTR,USELIST)
        else:
            MAX=mid

    print(MIN)
main()


Measured memory_bytes: 33384
#include <bits/stdc++.h>
 
using namespace std;
 
int x;
 
bool f(long long & i) {
	return i * (i + 1) >= 2 * x;
}
 
int main() {
	long long first = 0, last = INT_MAX;
	cin >> x;
 
	long long mid;
	while (last - first > 1) {
		mid = (first + last) / 2;
		if (f(mid))
			last = mid;
		else
			first = mid;
		//cout << first << " " << last << " " << mid << "\n";
	}
 
	cout << last << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main()
{
    using namespace std;
    
    long int a, b, x;
    cin >> a >> b >> x;
 
    long int cnt = b/x;
    if(a==0)
        cnt += 1;
    else
        cnt -= (a-1)/x;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
    fastio;
    int n, x, y, d=0;
    cin >> n;
    while (n--)
    {
        cin >> x >> y;
        if (x == y) d++;
        else d = 0;
        if (d == 3) {cout << "Yes"; return 0;}
    }
    cout << "No";
}


Measured memory_bytes: 3588
from collections import deque

s = input()
t = input()
ls = len(s)
lt = len(t)
DP_len = [[0] * (lt + 1) for i in range(ls + 1)]
Prev =[[0] * (lt + 1) for i in range(ls + 1)]
for i in range(1, ls + 1):
    for j in range(1, lt + 1):
        if s[i - 1] == t[j - 1]:
            if max(DP_len[i - 1][j - 1] + 1, DP_len[i][j - 1], DP_len[i - 1][j]) == DP_len[i-1][j-1] + 1:
                DP_len[i][j] = DP_len[i-1][j-1] + 1
                Prev[i][j] = (i-1, j-1)
            else:
                if DP_len[i][j - 1] >= DP_len[i - 1][j]:
                    DP_len[i][j] = DP_len[i][j - 1]
                    Prev[i][j] = (i, j - 1)
                else:
                    DP_len[i][j] = DP_len[i - 1][j]
                    Prev[i][j] = (i - 1, j)

        else:
            if DP_len[i][j - 1] >= DP_len[i - 1][j]:
                DP_len[i][j] = DP_len[i][j - 1]
                Prev[i][j] = (i, j-1)
            else:
                DP_len[i][j] = DP_len[i - 1][j]
                Prev[i][j] = (i - 1, j)

x = ls
y = lt
ans = ''
while True:
    if x == 0 or y == 0:
        break
    nx, ny = Prev[x][y]
    if (nx != x) and (ny != y):
        ans = s[x-1] + ans
    x = nx
    y = ny
print(ans)


Measured memory_bytes: 405896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

ll fac[212346];
void combInit(int mx)
{
    fac[0] = 0;
    fac[1] = 1;
    for (int i = 2; i <= mx; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
    }
}

ll modDiv(ll a, ll b)
{
    return a * fastPow(b, MOD - 2) % MOD;
}

ll comb(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (a < b)
        return 0;
    if (a <= 0 || b < 0)
        return 0;
    if (a == b)
        return 1;

    ll p, c;

    c = modDiv(fac[a], fac[a - b]);
    p = fac[b];

    ll res = modDiv(c, p);

    return res;
}

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

    combInit(212345);

    int b, w;

    cin >> b >> w;

    ll bp = 0, wp = 0;

    REP(i, b + w)
    {
        if (i != 0)
        {
            (bp += fastPow(modDiv(1, 2), i) * comb(i - 1, b - 1) % MOD) %= MOD;
            (wp += fastPow(modDiv(1, 2), i) * comb(i - 1, w - 1) % MOD) %= MOD;
        }

        cout << (modDiv((1 + wp - bp + MOD) % MOD, 2) + MOD) % MOD << endl;
    }

    return 0;
}

Measured memory_bytes: 3840