akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;//例: VVI dp(10, vector<int>(10, INF);
typedef priority_queue<int, vector<int>, less<int> > QUE_int;
const int INF = 2 * pow(10, 9) + 1;//+1しないとREになるかも(out of rangeになるんかな?? )

vector<int> dx = { -1, 0, 1, 0, -1, -1, 1, 1 };
vector<int> dy = { 0, -1, 0, 1, -1, 1, -1, 1 };

ll max(ll a, ll b) { return (a > b) ? a : b; }
ll min(ll a, ll b) { return (a < b) ? a : b; }

////////////////////////////////////////////////////////////////

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = pow(10, 9) + 7;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

////////////////////////////////////////////////////////////////




	

int main(void) {
	int N, K, C;
	cin >> N >> K >> C;
	string S;
	cin >> S;

	vector<int> work_day_L(N, -1);
	int cnt = 0; //count
	for(int i=0; i<N; ){
		if(cnt >= K) break;
		if(S[i] == 'x'){
			i++;
			continue;
		}
		work_day_L[i] = cnt;
		cnt++;
		i += C+1;
	}

	vector<int> work_day_R(N, -1);
	cnt = K-1; //count
	for(int i=N-1; i>=0; ){
		if(cnt < 0) break;
		if(S[i] == 'x'){
			i--;
			continue;
		}
		work_day_R[i] = cnt;
		cnt--;
		i -= C+1;
	}
	
	//print_vec(work_day_L);
	//print_vec(work_day_R);

	for(int i=0; i<N; i++){
		//if(S[i] == 'x') continue;
		if(work_day_L[i] == -1) continue;
		if(work_day_L[i] == work_day_R[i]) cout << i+1 << endl;
	}
}




Measured memory_bytes: 3332
h, n = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)

a = a.sort.reverse!

a.each do |a|
  h -= a
  if (h <= 0) then
    break
  end
end

if (h > 0) then
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 10232
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	string S;
	cin >> S;
	string T = "AC";
	bool ok = false;
	rep(i, S.size()-1){
		string s = S.substr(i, 2);
		if(s == T) ok = true; 
	}

	Cout(Yes(ok));
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import os

x, y = map(int, input().split())

group_a = [1, 3, 5, 7, 8, 10, 12]
group_b = [4, 6, 9, 11]
group_c = [2]

if x in group_a and y in group_a:
    print('Yes')
elif x in group_b and y in group_b:
    print('Yes')
elif x in group_c and y in group_c:
    print('Yes')
else:
    print('No')

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

ll a, b, v, w, t;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> v >> b >> w >> t;
    ll dist = abs(b - a);
    cout << (dist - (v - w) * t <= 0 ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define replrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) replrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mt make_tuple
#define INF 2000000000
#define INFL 1000000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<double, double> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<P> vP;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<P> > vvP;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<P, vector<P>, greater<P> > pqlP;
typedef pair<int, pair<int, int> > Edge;
typedef vector<Edge> vE;
typedef priority_queue<Edge, vector<Edge>, greater<Edge> > pqlE;

string debug_show(P a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}



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

	int H, W;
	cin >> H >> W;
	vi num(26,0);
	rep(i, H) {
		string s;
		cin >> s;
		rep(j, W) {
			num[s[j] - 'a']++;
		}
	}
	int num1 = 0, num2 = 0, num4 = 0;
	rep(i, 26) {
		if (num[i] % 4 == 0)num4++;
		else if (num[i] % 2 == 0)num2++;
		else num1++;
	}
	if (H % 2 == 0 && W % 2 == 0) {
		if (num1 == 0 && num2 == 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (H % 2 == 0) {
		if(num1==0&&num2<=H/2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else if (W % 2 == 0) {
		if (num1 == 0 && num2 <= W / 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		if(num1<=1&&num2<=(H-1)/2+(W-1)/2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}

	return 0;
}

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

ll divisor=1e9+7;
int main(){
	int n,k;
	cin>>n>>k;
	int a[n]={};
	rep(i,k){
		int d;
		cin>>d;
		rep(i,d){
			int an;
			cin>>an;
			a[an-1]++;
		}
	}
	int count=0;
	rep(i,n){
		if(a[i]==0)count++;
	}
	puts(count);
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX_V 100000
#define INF (1<<29)
typedef long long ll;
 
void bfs(int s,int *d,ll *cnt,vector<int> G[MAX_V]){
    queue<int> Q; Q.push(s);
    memset(cnt,0,sizeof(cnt));
    fill(d,d+MAX_V,INF);
    d[s] = 0;
    cnt[d[s]]++;
    while(!Q.empty()){
	int v = Q.front(); Q.pop();
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    int to = G[v][i];
	    if(d[v] + 1 < d[to]){
		d[to] = d[v] + 1;
		cnt[d[to]]++;
		Q.push(to);
	    }
	}
    }
}
 
int main(){
    int V,E,S,T,x,y;
    int ds[MAX_V],dt[MAX_V];
    ll cs[MAX_V],ct[MAX_V];
    vector<int> G[MAX_V];
    cin >> V >> E >> S >> T;
    S--; T--;
    for(int i = 0 ; i < E ; i++){
	cin >> x >> y; x--; y--;
	G[x].push_back(y);
	G[y].push_back(x);
    }
   
    bfs(S,ds,cs,G); 
    bfs(T,dt,ct,G);
   
    ll ans = 0LL;
    int min_dist = ds[T];
    for(int i = 0 ; i < V ; i++){
	int j = min_dist-2-i;
	ans += (j >= 0 ? cs[i]*ct[j] : 0);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10132
/*
  AUTHOR:SOURABH
  CREATED:03:04:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,x,y,z;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>x>>y>>z;
        cout<<z<<" "<<x<<" "<<y<<endl;
    }
    return 0;
}














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

using namespace std;

const int maxN = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
main() {
    int n = readInt(), k = readInt();
    int ans = 100000000000ll;
    for(int i = 0; i <= n; i++) {
        ans = min(ans, (1 << i) + (n - i) * k);
    }
    cout << ans;
}


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


int main(){
	int a,b;
	cin>>a>>b;
	cout<<(a+b)/2<<endl;
	
	/*random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> rnd3(1, 3);
	
	string p1, p2, p3, p4;
	cin >> p1 >> p2 >> p3 >> p4;
	
	int t = rnd()%3;
	
	if(t == 0){
		cout << "1:" << p1 << ',' << p2 << endl;
		cout << "2:" << p3 << ',' << p4 << endl;
	}
	if(t == 1){
		cout << "1:" << p1 << ',' << p3 << endl;
		cout << "2:" << p2 << ',' << p4 << endl;
	}
	if(t == 2){
		cout << "1:" << p1 << ',' << p4 << endl;
		cout << "2:" << p2 << ',' << p3 << endl;
	}*/
	
	/*
	switch(type){
		case 0:
			cout << "1:" << p1 << ',' << p2 << endl;
			cout << "2:" << p3 << ',' << p4 << endl;
			break;
		case 1:
			cout << "1:" << p1 << ',' << p3 << endl;
			cout << "2:" << p2 << ',' << p4 << endl;
			break;
		case 2:
			cout << "1:" << p1 << ',' << p4 << endl;
			cout << "2:" << p2 << ',' << p3 << endl;
			break;
	}
	*/
	
	
	return 0;
}



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

long long countMultiples(long long minLim, long long maxLim, long long divisor)
{
    return ((maxLim / divisor) - ((minLim - 1) / divisor));
}

int main()
{
    long long a, b;
    int c, d;
    cin >> a >> b >> c >> d;

    int x = c, y = d, remainder = x % y;
    while (remainder != 0)
    {
        x = y;
        y = remainder;
        remainder = x % y;
    }
    int gcdOfCAndD = y;

    // cout << gcdOfCAndD << endl;

    long long lcmOfCAndD = (long long)c / gcdOfCAndD * d;

    // cout << lcmOfCAndD << endl;

    long long cMultiplesCount = countMultiples(a, b, c);
    long long dMultiplesCount = countMultiples(a, b, d);
    long long lcmMultiplesCount = countMultiples(a, b, lcmOfCAndD);

    cout << ((b - a + 1) - (cMultiplesCount + dMultiplesCount - lcmMultiplesCount)) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include<random>
#include<math.h>
#include<limits.h>
#include<iterator>
#define rep(i,a) for(int i=0;i<a;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i>=0;i--)
#define ll long long
#define vl vector<ll> 
#define vvl vector<vector<ll> > 
#define vb vector<bool> 
#define vvb vector<vector<bool> > 
#define INF 1123456789012345
using namespace std;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i, n) cin >> a[i];
	ll sum = 0; rep(i, n) sum += a[i];
	if (sum % 10){
		cout << sum << endl;
		exit(0);
	}
	sort(a.begin(), a.end());
	rep(i, n){
		if (a[i] % 10){
			sum -= a[i];
			cout << sum << endl;
			exit(0);
		}
	}cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<time.h>
#include<ctype.h>
int main(){
    int a, b;
    while(~scanf("%d%d", &a, &b)){
        if(a==1&&b==2)
            printf("3\n");
        else if(a==1&&b==3)
            printf("2\n");
        else if(a==2&&b==1)
            printf("3\n");
        else if(a==3&&b==1)
            printf("2\n");
        else if(a==2&&b==3)
            printf("1\n");
        else if(a==3&&b==2)
            printf("1\n");

    }

return 0;
}


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

int main() {
	int N; cin >> N; N += 2;
	int A[100002];
	int B[100002];
	A[0] = 0;
	for (int i = 1; i < N - 1; i++)
		cin >> A[i];
	A[N - 1] = 0;
	B[0] = 0;
	for (int i = 1; i < N; i++)
		B[i] = B[i - 1] + abs(A[i] - A[i - 1]);

	for (int i = 1; i < N - 1; i++) {
		int ex = B[i + 1] - B[i - 1];
		int shortcut = abs(A[i + 1] - A[i - 1]);
		int res = B[N - 1] - ex + shortcut;
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
    int x = 0, f = 1, c = getchar();
    for (; !isdigit(c); c = getchar())
        if (c == '-')
            f = -1;
    for (;  isdigit(c); c = getchar())
        x = x * 10 + c - '0';
    return x * f;
}

const int MAXN = 305;
const int mod = 1e9 + 7;

int n, a[MAXN], fac[MAXN], inv[MAXN], f[MAXN][MAXN][2];

int main()
{
#ifdef wxh010910
    freopen("data.in", "r", stdin);
#endif
    n = Read(), fac[0] = fac[1] = inv[0] = inv[1] = 1;
    for (int i = 2; i <= n; i ++)
        fac[i] = 1LL * fac[i - 1] * i % mod, inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
    bool sam = true;
    for (int i = 1; i <= n; i ++)
        inv[i] = 1LL * inv[i - 1] * inv[i] % mod, a[i] = Read(), sam &= a[i] == 2;
    if (sam)
        return printf("%d\n", 1LL * fac[n - 1] * inv[2] % mod), 0;
    f[0][0][0] = 1;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j <= i; j ++)
            for (int k = 0; k < 2; k ++)
                if (f[i][j][k])
                {
                    f[i + 1][j][k] = (f[i + 1][j][k] + f[i][j][k]) % mod;
                    if (a[i + 1] >= 2)
                        f[i + 1][j + 1][k] = (1LL * f[i][j][k] * (a[i + 1] - 1) + f[i + 1][j + 1][k]) % mod;
                    if (a[i + 1] >= 3 && !k)
                        f[i + 1][j + 1][1] = (1LL * f[i][j][k] * (a[i + 1] - 1) * (a[i + 1] - 2) + f[i + 1][j + 1][1]) % mod;
                }
    int ans = 0, cur = 1;
    for (int i = 1; i <= n; i ++)
        cur = 1LL * cur * inv[a[i] - 1] % mod;
    for (int i = 3; i < n; i ++)
        if (f[n][i][1])
            ans = (1LL * fac[i - 1] % mod * f[n][i][1] % mod * fac[n - i - 1] % mod * inv[2] + ans) % mod;
    return printf("%d\n", 1LL * ans * cur % mod), 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>

typedef long long int llint;

int main(void){

  std::string s, t;

  std::cin >> s >> t;
  for(int i=0; i<s.size(); i++){
    if(s[i]!=t[i]){
      std::cout << "No" << std::endl;
      return 0;
    }
  }

  std::cout << "Yes" << std::endl;
 
  return 0;
}


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

int main(){
    long long N;
    cin >> N;
    long long yaku[N+1];
    long long i,j;
    for(i=1; i<=N; i++){
        yaku[i]=0;
    }
    for(i=1; i<=N; i++){
        for(j=1; i*j<=N; j++){
            yaku[i*j]++;
        }
    }
    long long ans=0;
    for(i=1; i<=N; i++){
        ans += i*yaku[i];
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

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

int main() {
int n,p,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
	    cin>>p;
	    if(p==i){
	        c++;
	        i++;
	        cin>>p;
	    }
	}
	cout<<c<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>

#define N 100000
#define S 2000000000

typedef struct Card {
  int value;
  char suit;
} card;

card L[N/2 + 2];
card R[N/2 + 2];

int partition(card A[],int n,int p,int r);
void merge(card A[],int n,int l,int mid,int r);
void mergeSort(card A[],int n,int l,int r);
void quickSort(card A[],int n,int p,int r);



int main(void){
  int i,n;
  int x;
  card A[N],B[N];
  char s[100];
  int st = 1;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s %d",s,&x);
    
    B[i].suit = s[0];
    A[i].suit = B[i].suit;
    
    B[i].value = x;
    A[i].value = B[i].value;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n-1);

  for(i = 0;i < n;i++){
    if(A[i].suit != B[i].suit){
      st = 0;
    }
  }

  if(st == 1){
    puts("Stable");
  } else {
    puts("Not stable");
  }

  for(i = 0;i < n;i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }

  return 0;
}
    
    






void merge(card A[],int n,int l,int mid,int r){
  int i,j,k;
  int n1,n2;

  n1 = mid - l;
  n2 = r - mid;
  
  for(i = 0;i < n1;i++){
    L[i] = A[l+i];
  }
  
  for(i = 0;i < n2;i++){
    R[i] = A[mid+i];
  }

  R[n2].value = S;
  L[n1].value = R[n2].value;
  
  i = 0;
  j = 0;

  for(k = l;k < r;k++){
    if(L[i].value <= R[j].value){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
  
}


void mergeSort(card A[],int n,int l,int r){
  int mid;

  if(l+1 < r){
    mid = (l+r)/2;
    mergeSort(A,n,l,mid);
    mergeSort(A,n,mid,r);
    merge(A,n,l,mid,r);
  }
}

int partition(card A[],int n,int p,int r){
  int i,j;
  card x;
  card temp;

  x = A[r];
  i = p-1;

  for(j = p;j < r;j++){
    if(x.value >= A[j].value){
      i++;
      
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }

  temp = A[i+1];
  A[i+1] = A[r];
  A[r] = temp;

  return (i+1);
}

void quickSort(card A[],int n,int p,int r){
  int q;
  
  if(p < r){
    q = partition(A,n,p,r);
    
    quickSort(A,n,p,q-1);
    quickSort(A,n,q+1,r);
  }
}





Measured memory_bytes: 4072
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean b = true;
		for(int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if(a % 2 == 0) {
				if((a % 3 != 0) && (a % 5 != 0)) {
					b = false;
				}
			}
		}

		if(b) {
			System.out.println("APPROVED");
		}else {
			System.out.println("DENIED");
		}
		sc.close();
	}
}


Measured memory_bytes: 21844
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef long long lint;
typedef double ld;

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 0;
    while(a > 0 && c > 0){
        if(i % 2)a -= d;
        else  c -= b;
        i++;
    }
    if(a <= 0)puts("No");
    else puts("Yes");
    return 0;
}
// Write Here


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

using namespace std;

const int INF = 1e9;

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for (int bit = 1; bit < 1 << n; bit++) {
    int sum = 0;
    vector<int> b(n, 0);
    for (int i = 0; i < n; i++) {
      if (bit >> i & 1) {
        sum += c[i];
        for (int j = 0; j < m; j++) {
          b[j] += a[i][j];
        }
      }
    }
    bool ok = true;
    for (int i = 0; i < m; i++) {
      if (b[i] < x) ok = false;
    }
    if (ok) ans = min(ans, sum);
  }
  if (ans == INF)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3644
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

h1, m1, h2, m2, k = LI()
print(max(0, (60*h2+m2) - (60*h1+m1) - k))


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


int main(){


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


  int mn = a[0], mx = a[0];
  long long sum = 0;
  for(int i=0;i<n;i++){
    mn = min(mn, a[i]);
    mx = max(mx, a[i]);
    sum += a[i];
  }


   cout<<mn<<" "<<mx<<" "<<sum<<endl;


   return 0;
}


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

struct LCA {
  int N, logN; // logN-1 == floor(lg(N-1))
  vector<vector<int>> G;
  vector<int> depth;
  // vから根の方向に2^k回登ったときのノード parent[k][v]
  vector<vector<int>> parent;

  LCA(int size) : N(size), G(size), depth(size) {
    logN = 1;
    for(int x = 1; x < N; x *= 2) logN++;
    parent.assign(logN, vector<int>(N));
  }

  // どちらが根であってもOK
  void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
  }

  void dfs(int v, int par, int dep) {
    depth[v] = dep;
    parent[0][v] = par;
    for(int next : G[v]) {
      if(next != par) dfs(next, v, dep + 1);
    }
  }

  void init(int root) {
    dfs(root, -1, 0);
    for(int k = 1; k < logN; k++) {
      for(int v = 0; v < N; v++) {
        if(parent[k - 1][v] == -1) parent[k][v] = -1;
        else parent[k][v] = parent[k - 1][parent[k - 1][v]];
      }
    }
  }

  int lca(int u, int v) {
    if(depth[u] > depth[v]) swap(u, v); // vのほうが深くなる
    // uとvの深さが同じになるまでvを根の方向に移動する
    for(int k = 0; k < logN; k++) {
      if(((depth[v] - depth[u]) >> k) & 1) {
        v = parent[k][v];
      }
    }
    if(u == v) return u;
    for(int k = logN - 1; k >= 0; k--) {
      if(parent[k][u] != parent[k][v]) {
        u = parent[k][u];
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
};

int main() {
  ios::sync_with_stdio(false);
  int N; cin >> N;
  LCA lca(N);
  for(int u = 0; u < N; u++) {
    int k; cin >> k;
    while(k--) {
      int v; cin >> v;
      lca.add_edge(u, v);
    }
  }
  lca.init(0);
  int Q; cin >> Q;
  while(Q--) {
    int u, v; cin >> u >> v;
    cout << lca.lca(u, v) << endl;
  }
}

Measured memory_bytes: 16492
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans,a[220000], b[220000];
bool dp[200000];
string str, ss;
bool f[200000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st[200000];

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	rep(i, n)
		cin >> a[i];
	rep(i, m + 1) {
		rep(j, n) {
			if (i - a[j] >= 0)dp[i] |= !dp[i - a[j]];
		}
	}
	cout << (dp[m]==0?"Second":"First") << endl;
	return 0;
}


Measured memory_bytes: 14592
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

def f(n):
    if n%2 == 0:
        return n/2
    else:
        return 3*n+1

s = ri()

t = [0 for _ in range(1000000)]

ans = 0
a = s
for i in range(1,1000000):
    if t[int(a)] == 1:
        ans = i
        break
    else:
        t[int(a)] = 1
    a = f(a)

print(ans)

Measured memory_bytes: 11160
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int main() {
	ll n, a[100001], cnt = 0, b[100001];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n - 1; i++) {
		if (a[i] == a[i + 1]) {
			b[cnt] = a[i];
			cnt++;
			a[i] = 0;
			a[i + 1] = 0;
		}
	}
	if (cnt < 2)cout << 0 << endl;
	else cout << b[cnt - 1] * b[cnt - 2] << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 1408
input1 :: IO [[Int]]
input1 = loop []
  where
    loop list = do
      temp <- getLine
      let [h,w] = map read . words $ temp :: [Int]
      if h == 0 && w == 0
        then return list
        else do
        loop (list ++ [[h,w]])


solve2 [h,w] = loop h
  where
    loop x = do
      if x == 0
        then putStrLn ""
        else do
        if x == h || x == 1
          then do
          putStrLn $ concat $ replicate w "#"
          loop (x-1)
          else do
          putStrLn $ "#" ++ (concat $ replicate (w-2) ".") ++ "#"
          loop (x-1)


main = do
  hws <- input1
  mapM_ solve2 hws



Measured memory_bytes: 4808
#include<stdio.h>

int KETA(int n){
    int i=0;
    while(n!=0){
        n = n/10;
        i++;
    }
    return i;
}

int main(void){
    int N;
    scanf("%d",&N);
    int count = 0;
    //printf("%d",KETA(N));
    for(int i=1;i<=N;i++){
        if(KETA(i)%2==1) count++;
    }
    printf("%d",count);
    return 0;
}

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

int main(){
    int X,N;
    cin >> X >> N;
    if(N==0){
        cout << X << endl;
    }
    else if(N==100){
        if(X>=51){
            cout << 101 << endl;
        }
        else{
            cout << 0 << endl;
        }
    }
    else{
        int p[N];
        for(int i=0; i<N; i++){
            cin >> p[i];
        }
        int p2[102];
        for(int i=0; i<=101; i++){
            p2[i]=i;
            for(int j=0; j<N; j++){
                if(i==p[j]){
                    p2[i]=1000;
                    break;
                }
            }
        }
        int abs;
        int num;
        for(int i=0; i<=101; i++){
            if(i==0){
                abs=pow((X-p2[i]),2);
                num=p2[i];
            }
            else{
                if(abs>pow((X-p2[i]),2)){
                    abs=pow((X-p2[i]),2);
                    num=p2[i];
                }
                else if(abs==pow((X-p2[i]),2)){
                    if(num>p2[i]){
                        num=p2[i];
                    }
                }
            }
        }
        cout << num << endl;
    }    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
        ios::sync_with_stdio(0);
        cin.tie(0);
        int n, ans = 1, ls;
        cin >> n;
        vector<pair<int, int> > v(n);
        for(int i = 0, x, l; i < n; ++i) {
                cin >> x >> l;
                v[i] = {x - l, x + l};
        }
        sort(v.begin(), v.end(), [] (pair<int, int> a, pair<int, int> b) {
                if(a.second != b.second) return a.second < b.second;
                return a.first < b.first;
        });
        ls = v[0].second;
        for(int i = 1; i < n; ++i)
                if(ls <= v[i].first) ++ans, ls = v[i].second;
        cout << ans;
        return 0;
}


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

int kakuwa(int);

int main(){

	int N, A, B;
	cin >> N >> A >> B;
	int result = 0;
	

	for (int i = 1; i <= N; i++) {
		if (kakuwa(i) >= A && kakuwa(i) <= B){
			result += i;
		}
	}

	cout << result;

	return 0;
}

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


Measured memory_bytes: 256
/* ***********************************************
Author        :axp
Created Time  :2017/2/4 21:26:02
TASK		  :C.cpp
LANG          :C++
************************************************ */

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;

typedef long long ll;
const int inf = 1<<30;
const int md = 1e9+7;
const int N = 1e5+10;
int ar[N];
int n,m;
int T;
vector<int> ve[N];

bool dfs(int x,int p)
{
	if(ve[x].size()==1)return 1;
	ll sum=0;
	int mx=0;
	for(int i=0;i<ve[x].size();i++)
	{
		int &y=ve[x][i];
		if(y==p)continue;
		if(!dfs(y,x))
		{
			//cout<<"!"<<y<<endl;
			return 0;
		}
		sum+=ar[y];
		mx=max(mx,ar[y]);
	}
	
	if(sum<ar[x])return 0;

	int a=sum-ar[x];
	int b=ar[x]-a;
	if(a<0||b<0)return 0;

	ar[x]-=a;
	if(ar[x]<0)return 0;

	if((mx-b)>a)return 0;

	if(p==0)return ar[x]==0;
	return 1;
}

bool solve()
{
	if(n==2)return ar[1]==ar[2];
	for(int i=1;i<=n;i++)
	{
		if(ve[i].size()!=1)
			return dfs(i,0);
	}
	exit(1);
}

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d",&n);
	int x,y;
	for(int i=1;i<=n;i++)scanf("%d",&ar[i]);
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&x,&y);
		ve[x].push_back(y);
		ve[y].push_back(x);
	}
	bool ans=solve();
	puts(ans?"YES":"NO");
    return 0;
}


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

#define int long long

signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
//	int t;
//	cin >> t;
//	while(t--){
		int l,r,k;
		cin >> l >> r >> k;
		if(l%k==0){
			cout << r/k-l/k+1 << endl;
		}
		else{
			cout << r/k-l/k << endl;
		}
//	}
}


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

int main() {
	int N;
	string S, T;
	cin >> S;
	cin >> T;
	int ans=0, count;
	bool flag=false;
	
	for ( int i=0; i < S.size (); i++ ){
	    if ( S == T ) {
		flag = true ;
		break ;
	    }
	    S = S.back () + S.substr (0 , S . size () -1);
	}

	cout << (flag ? "Yes": "No") << endl;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
V = list(map(int, input().split()))

R = min(N, K)
ans = -10**7+1
for i in range(R+1):
    for j in range(i+1):
        A, B = j, i-j
        jeweler = []
        if A != 0:
            jeweler += V[:A]
        if B != 0:
            jeweler += V[-B:]
        
        jeweler.sort()
        rem_k = K-(A+B)
        can = sum(jeweler)
        for k in range(min(rem_k, len(jeweler))):
            if jeweler[k] < 0:
                can += -jeweler[k]
        if ans < can:
            ans = can
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair <int, int> P;
vector <P> target;

void rotate(vector <P> &line)
{
	for (int i = 0; i < line.size(); i++){
		int x = line[i].first, y = line[i].second;
		line[i].first = y * -1;
		line[i].second = x;
	}
	return;
}

bool issame(vector <P> line)
{
	return line == target;
}

int main(void)
{
	int n;
	while (cin >> n, n){
		int m;
		vector < vector < P > > data;

		for (int i = 0; i <= n; i++){
			cin >> m;
			vector <P> line;
			int x, y, px, py;
			cin >> px >> py;
			for (int j = 1; j < m; j++){
				cin >> x >> y;
				line.push_back(make_pair(x - px, y - py));
				px = x;
				py = y;
			}
			data.push_back(line);
		}
		target = data[0];

		for (int i = 1; i <= n; i++){
			bool pf = false;
			for (int cnt = 0; cnt < 4; cnt++){
				rotate(data[i]);
				if (issame(data[i])){
					cout << i << endl;
					pf = true;
					break;
				}
			}
			reverse(data[i].begin(), data[i].end());
			rotate(data[i]); rotate(data[i]);
			for (int cnt = 0; cnt < 4; cnt++){
				rotate(data[i]);
				if (issame(data[i])){
					cout << i << endl;
					pf = true;
					break;
				}
			}
			if (!pf && issame(data[i])){
				cout << i << endl;
			}
		}
		cout << "+++++" << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
N = int(input())
P = list(map(int, input().split()))
count = 0
for i in range(N-1):
    if i + 1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        count += 1

if N == P[N-1]:
    count += 1
print(count)

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long int lli;
typedef long long ll;

int main() {
    string s;
    cin >> s;

    int cnt0 = 0;
    int cnt1 = 0;
    rep(i,s.size()){
        if(s[i] == '0') cnt0++;
        if(s[i] == '1') cnt1++;
    }

    cout << min(cnt0,cnt1)*2 << endl;
}


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

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> h(n,0);
	for(int &i:h){
		scanf("%d",&i);
	}
	for(int i=0;i<n-1;i++){
		if(i!=0 && h[i]==h[i-1]){
			if(h[i]>h[i+1]){
				//printf("H%d\n",i);
				printf("No\n");
				return 0;
			}
		}
		else{
			if(h[i]<=h[i+1]){
				h[i]--;
			}
			else if(h[i]-1==h[i+1]){
				h[i]--;
			}
			else{
				//printf("L%d\n",i);
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MAX 10005
using namespace std;
double a[MAX];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF&&n)
    {
        double sum=0;
        int res=0;
        for(int i=0;i<n;i++)
        {
            scanf("%lf",&a[i]);
            sum+=a[i];
        }
        sum/=(double)n;
        for(int i=0;i<n;i++)
            if(a[i]<=sum)res++;
        printf("%d\n",res);
    }
}



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

int main(){
    int n, l, i = 0, x[101], min = 0, MIN;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }





   for(int r = 1; r <= 100; r++){
        for(int i = 0; i < n; i++){
            min = min + (x[i]-r)*(x[i]-r);
        }
        if(r == 1){
            MIN = min;
        }
        if(MIN > min){
            MIN = min;
        }
        min = 0;
    }

    cout << MIN << "\n";
    return 0;
    
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    int i, j, n, q, t;
    int c = 0;
    scanf("%d",&n);
    int s[n];
    for(i=0;i<n;i++){
        scanf("%d",s+i);
    }
    scanf("%d",&q);
    for(i=0;i<q;i++){
        scanf("%d",&t);
        for(j=0;j<n;j++){
            if(t==s[j]){
                c++;
                break;
            }
        }
    }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 2676
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>

#define reps(i, j, k) for (int i = (j); i < (k); i++)
#define rep(i, j) reps(i, 0, j)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	string str;
	cin >> str;

	int sum = 0;
	rep(i, str.length()) {
		if (str[i] == '1') sum++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define all(X) X.begin(),X.end()

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   str.substr (x) : returns a substring str[x],... end of string
   str.find(qtr) : returns the first occurenece of qtr in str */

const int M = (1<<20)+5;
const int md = 1e9+7;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll a,b;
	cin >> a >> b;
	if(max(a,b)<=9 && min(a,b)>=1)
		cout << a*b << "\n";
	else
		cout << -1 << "\n";

	return 0;
}

Measured memory_bytes: 256
#import<cstdio>
int main(){int a,c=3,r=1;for(char d[]="123546",s[9];a=scanf("%s",s),*s>60;r+=*d&7)*s%6-4?a+=*s%5+*s%2*2+c&3,d[a]=*d,*d=d[a=++a%4+1],d[a]=d[5],d[5]=~*d:c+=*s+3;~-r&&printf("%d\n",r);~a&&main();}

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

#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define sz(v) (int) v.size()

const long long Q =  1000000000000000000;

int main(){

    int n;
    cin >> n;

    long long g = 1 ;
    vector<long long> v(n);
    
    for( int i = 0 ; i < n ; ++i ){
        cin >> v[i];
        if( v[i] == 0 ) g = 0;        
    }

    if( g == 0 ) {
        cout << g << endl;
    }

    else{

        for( int i = 0 ; i < n ; ++i ){
            long long top = Q / g ;
            if( v[i] > top ) {
                g = -1;
                break;
            } else g *= v[i];
        }

        cout << g << endl;
    }

    return 0;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n+1);
    for(int i=0;i<n;i++) cin>>a[i+1];
    vector<int> b(n+1);
    for(int i=n;i>=1;i--){
        int sum=0;
        for(int j=i+i;j<=n;j+=i){
            sum^=b[j];
        }
        b[i]=sum^a[i];
    }
    vector<int> ans;
    for(int i=1;i<=n;i++){
        if(b[i]) ans.push_back(i);
    }
    cout<<ans.size()<<endl;
    for(int i=0;i<ans.size();i++) cout<<ans[i]<<endl;
}

Measured memory_bytes: 3064
#abc141b

s=raw_input()
so=''
se=''
for i in xrange(1,len(s),2):
 so+=s[i]
for i in xrange(0,len(s),2):
 se+=s[i]
if so.count('L')+so.count('U')+so.count('D')==len(so) and se.count('R')+se.count('U')+se.count('D')==len(se):
 print 'Yes'
else:
 print 'No'


Measured memory_bytes: 2568
a,b=map(int,input().split())
s=str(input())
e=["0",'1','2','3','4','5','6','7','8','9']
for i in range(len(s)):
  if a==i:
    if s[i]!='-':
      print("No")
      exit()
  else:
    if s[i] not in e:
      print("No")
      exit()

print("Yes")

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

using namespace std;

int main(){
    int n,q;
    cin >> n;
    int S[n];
    rep(i, n) cin >> S[i];
    cin >> q;
    int T[q];
    rep(i, q) cin >> T[i];
    
    int cnt = 0;
    int left,right,mid;
    for(int i=0; i<q; i++) {
        int t = T[i];
        left = 0;
        right = n;

        while(left < right) {
            mid = (left + right) / 2;
            if(S[mid] == t) {
                cnt++;
                break;
            } else if(S[mid] < t) {
                left = mid + 1;
            } else if(S[mid] > t) {
                right = mid;
            }

        }
        
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 3624
n, m = map(int,input().split())
List = [list(map(int,input().split())) for i in range(n)]

food = [0]*(m+1)

for i in range(n):
    for j in range(1, List[i][0]+1):
        food[List[i][j]] += 1

cnt = 0
for i in range(1, m+1):
    if food[i] == n: cnt += 1

print(cnt)


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

using namespace std;
#define int long long
int32_t main() {
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int mx=max(a*c,a*d);
    mx=max(mx,b*c);
    mx=max(mx,b*d);
    cout<<mx<<endl;
    // cout<<(int)max(a*c,max(a*d,max(b*c,max(b,d))))<<endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cassert>
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <iterator>
#include <queue>
#include <utility>

using namespace std;

int N, Q;
struct P {
    int begin, end; // [begin, end]
    P(int begin = 0, int end = 0) : begin(begin), end(end) {}
    bool contains(int year) {
        return begin <= year && year <= end;
    }
    int transform(int year) {
        return year - begin + 1;
    }
};
map<string, P> Map;
vector<int> Queries;
bool input() {
    cin >> N >> Q;
    if (N == 0 && Q == 0) return false;
    Map.clear();
    Queries.clear();
    for (int i = 0; i < N; i++) {
        string Name; int Year, GYear;
        cin >> Name >> Year >> GYear;
        Map[Name].begin = GYear - Year + 1;
        Map[Name].end   = max(Map[Name].end, GYear);
    }
    for (int i = 0; i < Q; i++) {
        int Y;
        cin >> Y;
        Queries.push_back(Y); 
    }
    return true;
}

void solve() {
    for (int i = 0; i < Q; i++) {
        for (map<string, P>::iterator it = Map.begin(); it != Map.end(); it++) {
            if (it->second.contains(Queries[i])) {
                cout << it->first << " " << it->second.transform(Queries[i]) << endl;
                goto next;
            }
        }
        cout << "Unknown" << endl;
next:;
    }
}

int main() {
    while (input()) {
        solve();
    }
    return 0;
}

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

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, l;
  cin >> n >> l;
  int ans = 0, Min = 1000;
  rep(i, n) {
    int v = l + i;
    if (abs(v) < abs(Min)) Min = v;
    ans += v;
  }
  cerr << Min << endl;
  ans -= Min;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3644
n, k = map(int,input().split())
v = list(map(int,input().split()))

ans = 0

for l in range(n):
    for r in range(n+1)[::-1]:
        if l <= r and 0 <= (l+n-r) <= k: # l+n-r個拾う
            q = v[:l] + v[r:n]
            q.sort(reverse = True)
            
            for i in range(k-(l+n-r)):
                if q == []:
                    break
                if q[-1] < 0:
                    q.pop()
                else:
                    break

            ans = max(ans, sum(q))
        else:
            continue

print(ans)

Measured memory_bytes: 9156
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
const long long inf = 1ll<<61;
typedef pair<int, int> P;
typedef pair<int ,P> PP;
struct edge { int to; int to2; int cost; };
int x[55], y[55];

signed main() {
	int n; cin >> n;
	rep(i, n)cin >> x[i] >> y[i];
	vector<P>V;
	rep(i, n)V.push_back(P(x[i], y[i]));
	sort(V.begin(), V.end());

	vector<P>tansa;
	
	rep(i, n) {
		rep(j, n)tansa.push_back(P(V[i].first - V[j].first, V[i].second - V[j].second));
	}

	int ans = inf;
	if (n == 1)ans = 1;

	rep(i, n*n) {
		int used[55];
		rep(j, n)used[j] = 0;
		int cnt = 0;
		rep(j, n) {
			int lsx = V[j].first, lsy = V[j].second;
			if (used[j])continue;
			used[j] = 1;
			cnt++;

			rep(k, n) {
				int X = V[k].first - lsx;
				int Y = V[k].second - lsy;
			
				if (used[k]==0&&X == tansa[i].first&&Y == tansa[i].second) {
					used[k]++;
					lsx = V[k].first;
					lsy = V[k].second;
				}
			}
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;
}

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

int main() {
  int n,k;
  int res = 0;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0;i<n;i++) cin >> a.at(i);
  sort(a.begin(),a.end());
  for(int i = 0;i<k;i++) res += a.at(i);
  cout << res << endl;
}

Measured memory_bytes: 3596
#include<iostream>

using namespace std;

int partition(int* A,int p, int r) {
  int x = A[r];
  int i = p - 1;
  for (int j = p; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }
  swap(A[i+1], A[r]);
  return i + 1;
}

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

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

  int q = partition(A, 0, N - 1);
  for(int i=0; i < N; i++){
    if (i) {
      cout << " ";
    }
    if (i == q) {
      cout<<"[";
    }
    cout << A[i];
    if (i == q) {
      cout<<"]";
    }
  }
  cout << endl;

  return 0;
}


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

int main() {
	int X, N;
	cin >> X >> N;
	if(N == 0){
		cout << X << endl;
		return 0;
	}
	vector<int> p(N);
	for(int i=0;i<N;i++){
		cin >> p.at(i);
	}
	sort(p.begin(), p.end());
	int search = X, cnt = 0;

	while(true){
		if(cnt == 0 && std::find(p.begin(), p.end(), search) == p.end()){
			cout << search << endl;
			return 0;
		}else if(std::find(p.begin(), p.end(), search - cnt) == p.end()){
			cout << search - cnt << endl;
			return 0;
		}else if(std::find(p.begin(), p.end(), search + cnt) == p.end()){
			cout << search + cnt << endl;
			return 0;
		}else{
			cnt ++;
		}
	}
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int i;
    int flag;
    if(s.length()==6)
    {
        for(i=0;i<6;i++)
        {
            if(s[i]>='a'&&s[i]<='z')
                flag=1;
            else
            {
                flag=0;
                break;
            }
        }
        if(flag==1)
        {
            if(s[2]==s[3]&&s[4]==s[5])
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256