akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

 
 
const ll N = 1000005;
const ll mod = 1000000007;
const long long int inf = 1e10+5;
#define pp pair<ll,ll>
 
typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   




void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);



 ll a[N];
int main(){
    

   ll n;
    for(ll i = 2;i<N;i++){
        if(a[i]!=0) continue;
        for(ll j = i;j<N;j = j+i){
            if(a[j]==0)
            a[j] = i;
        }
        
    }

   
   cin>>n;
   ll b[n];
   rep(i,n) cin>>b[i];
   ll c[n];
   rep(i,n) c[i] = b[i];
   map<ll,ll> m;
   rep(i,n){
       map<ll,ll> m1;
       while(b[i]!=1){
           m1[a[b[i]]]++;
           if(m[a[b[i]]]<m1[a[b[i]]]) m[a[b[i]]]++;
           b[i] = b[i] / a[b[i]];
       }
   }
   ll lcm = 1;
   trace(i,m){
       lcm = modmulti(lcm,modpower(i->first,i->second));
   }
   
   ll ans = 0;
   rep(i,n){
       ans = modadd(ans,modmulti(lcm,modinv(c[i])));
   }
   cout<<ans<<endl;
   




   

}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}
 

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

int main(){
  int a,b;
  while(1){
    cin>>a>>b;
    if(a==0&&b==0)break;
    for(int i=0;i<a;i++){
      for(int j=0;j<b;j++){
        if(i==0||j==0||i==a-1||j==b-1){
          cout<<"#";
        }else{
          cout<<".";
        }
      }
      cout<<endl;
    }
    cout<<endl;
  }
}



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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    vector<bool> A(N,false),B(N,false);
    int a,b;
    for (int i = 0; i < M; i++)
    {
        cin >> a >> b;
        if(a == 1) A[b]=true;
        if(b == N) B[a]=true;
    }
    for (int i = 1; i < N; i++)
    {
        if(A[i] && B[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>
#include<stack>

using namespace std;

int main(){

  stack<int> s1;
  stack<pair<int, int> > s2;

  int i = 0, sum = 0;
  char c;

  while(scanf("%c", &c) != EOF){
    if(c == '\\'){
        s1.push(i);
    }
    else if(c == '/'){
      if(s1.empty() != 1){
        sum += i - s1.top();
        int x = 0;
        while(s2.empty() != 1 && s2.top().first >= s1.top()){
          x += s2.top().second;
          s2.pop();
        }
        s2.push(make_pair(s1.top(), x + i - s1.top()));
        s1.pop();
      }

    }
    i++;
  }
  cout << sum << endl;

  cout << s2.size();

  int size = s2.size();

  int a[size];

  if(s2.size() > 0){
    for(int i = size - 1; i >= 0; i--){
      a[i] = s2.top().second;
      s2.pop();
    }
  }

  for(int i = 0; i < size; i++){
    cout << " " << a[i];
  }

  cout << endl;




  return 0;

}


Measured memory_bytes: 3264
//****************************//
/**********  main *************/
//****************************//
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
 
using namespace std;
typedef long long ll;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(i=0;i<n;i++)
#define FOR(i,a,b) for(i=a;i<b;i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
 
int main(){
    
    string s,t;
    string res;
    cin >> s >> t;
    
    res = t + s;
    
    cout << res << endl;
    
} 
 
 
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n, l, r, tot;
int main(){
	scanf( "%s", s + 1 );
	n = strlen( s + 1 );
	l = 1; r = n;
	while( l <= r ){
		if( l == r ) break;
		if( s[l] == s[r] ){
			l++; r--;
			continue;
		}
		if( s[l] == 'x' ){
			tot++;
			l++;
			continue;
		}
		if( s[r] == 'x' ){
			tot++;
			r--;
			continue;
		}
		puts("-1");
		return 0;
	}
	printf( "%d\n", tot );
	return 0;
}

Measured memory_bytes: 384
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 100100;

    vi v;

    void solve() {
        ll n, cnt = 0;
        cin >> n;
        n = 2*n;
        ll a[n];
        rep(i, n) cin >> a[i];
        sort(a, a+n);
        for(ll i=0; i<n; i+=2) cnt+=min(a[i], a[i+1]);
        cout << cnt << endl;

    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
/*     
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
*/     
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long
#define ff first
#define ss second

template <class T>
void print(vector<T>& v){
    for(T x:v) cout<<x<<" ";
    cout<<"\n";
}
void inp(vector<int>& v, int n){
    for (int i=0; i<n; ++i) scanf("%d ", &v[i]);
}


void sol(){
    int n;
    cin>>n;
    vector<int> v(n);
    inp(v, n);
    int res=0;
    sort(v.begin(), v.end());
    for (int i=0; i<n; ++i){
        for (int j=i+1; j<n; ++j){
            if (v[i]==v[j]) continue;
            for (int k=j+1; k<n; ++k){
                if (v[j]==v[k]) continue;
                if (v[i]+v[j]>v[k]) res++;
            }
        }
    }
    printf("%d\n", res);
}


int main() {
    // int t;
    // cin>>t;
    // t++;
    // for (int i=1; i<t; ++i){ 
        sol();
    // }
    return 0;
}

Measured memory_bytes: 3792
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main{
	static final Scanner s=new Scanner(System.in);
	public static void main(String[]$){
		long k=s.nextLong();

		final int n=50;

		long[]r=IntStream.range(0,50).mapToLong(i->49-i).toArray();
		for(int i=0;i<n;i++)
			r[i]+=k/n;
		k%=n;
		for(int i=0;i<n&&k>0;i++) {
			++r[i];
			--k;
		}

		System.out.println(n);
		System.out.println(Arrays.stream(r).mapToObj(String::valueOf).collect(Collectors.joining(" ")));
	}
}


Measured memory_bytes: 28500
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	int mx = 0, ans = 0;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (mx <= x) ++ans;
		mx = max(mx, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3640
def main():
	N = int(input())
	info = []
	for i in range(N):
		x, y, h = [int(a) for a in input().split(" ")]
		info.append({"x": x, "y": y, "h": h})
	info.sort(key=lambda f: -f["h"])
	for cx in range(101):
		for cy in range(101):
			H = 0
			for i in range(len(info)):
				h = info[i]["h"] + abs(info[i]["x"] - cx) + abs(info[i]["y"] - cy)
				if i == 0:
					H = h
				else:
					if h != H:
						if (info[i]["h"] == 0 and h < H) or (info[i]["h"] > 0):
							break
			else:
				print(cx, cy, H)
				return 0
	if info[0]["x"] in [0, 100] and info[0]["y"] in [0, 100]:
		print(info[0]["x"], info[0]["y"], info[0]["h"])
		return 0

main()

Measured memory_bytes: 9232
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String retu = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51";
		String[] strings = retu.split(", ",0);

		System.out.println(strings[Integer.parseInt(sc.next()) - 1]);
		sc.close();
	}
}

Measured memory_bytes: 26988
#include <bits/stdc++.h>
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define rep(i,l,r) for(int i=l;i<r;i++)
#define bep(i,l,r) for(int i=l;i>=r;i--)
#define ld long double
#define ff first
#define ss second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define el '\n'
#define sz(s) s.size()
#define all(v) v.begin(),v.end()
#define mii map<int,int>
#define mr  make_pair
using namespace std;

int inf = 1e18;
const int N = 6e5+5;
int mod = 1e9+7;
/*
    int ncr(int n , int r ){
    	r = min(r,n-r);
    	int res = 1 ;
    	for(int i = 1 ; i <= r ; i++ ){
    		( res *= n-i+1 )%= mod;
    		res /= i ;
    	}
    	return res ;
    }
*/
//int powmod(int a,int b) {int res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
       int a,b;
       cin>>a>>b;
       cout<<6-(a+b);
    }

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  int l = 0;
  int r = 0;
  int ans = 0;

  while (l < n && r < n) {
    if (abs(a[l] - a[r]) <= 2) ans = max(ans, r - l + 1);

    if (abs(a[l] - a[r]) > 2)
      l++;
    else
      r++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 640
import sys

input=sys.stdin.readline

R,C,K=map(int,input().split())
item=[[0 for i in range(C)] for j in range(R)]
for i in range(K):
    r,c,v=map(int,input().split())
    item[r-1][c-1]=v

dp=[[0 for i in range(3)] for j in range(C)]
dp[C-1][0]=item[R-1][C-1]
dp[C-1][1]=item[R-1][C-1]
dp[C-1][2]=item[R-1][C-1]

for j in range(C-2,-1,-1):
    dp[j][0]=max(dp[j+1][1]+item[R-1][j],dp[j+1][0])
    dp[j][1]=max(dp[j+1][2]+item[R-1][j],dp[j+1][1])
    dp[j][2]=max(item[R-1][j],dp[j+1][2])


for i in range(R-2,-1,-1):
    ndp=[[0 for i in range(3)] for j in range(C)]
    ndp[C-1][0]=dp[C-1][0]+item[i][C-1]
    ndp[C-1][1]=dp[C-1][0]+item[i][C-1]
    ndp[C-1][2]=dp[C-1][0]+item[i][C-1]
    for j in range(C-2,-1,-1):
        ndp[j][0]=max(max(dp[j][0],ndp[j+1][1])+item[i][j],ndp[j+1][0])
        ndp[j][1]=max(max(dp[j][0],ndp[j+1][2])+item[i][j],ndp[j+1][1])
        ndp[j][2]=max(dp[j][0]+item[i][j],ndp[j+1][2])
    dp=ndp

print(dp[0][0])


Measured memory_bytes: 226848
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
#define int long long

void solve() {
    set<int> se;
    for(int i = 1; i * (i + 1) * (i + 2) / 6 <= 1000100; ++i) {
        se.insert(i * (i + 1) * (i + 2) / 6);
    }
    int dp[1000100], dp1[1000100];
    rep(i, 1000100) dp[i] = dp1[i] = INF;
    dp[0] = dp1[0] = 0;
    for(auto& x: se) {
        rep(i, 1000100) {
            if(i + x < 1000100) chmin(dp[i + x], dp[i] + 1);
            if(i + x < 1000100 && x % 2 == 1) chmin(dp1[i + x], dp1[i] + 1);
        }
    }
	int n;
    while(cin >> n) {
        if(n == 0) break;
        cout << dp[n] << " " << dp1[n] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}


Measured memory_bytes: 18760
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll,ll>pll;
const  ll MAX=100000000;
int main()
{

   ll ara[4];

   cin>>ara[0];

   cin>>ara[1];


   cin>>ara[2];



   sort(ara,ara+3);


   if(ara[0]==5 && ara[1]==5 && ara[2]==7)cout<<"YES"<<endl;
   else cout<<"NO"<<endl;


}



Measured memory_bytes: 3600
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long m = 0;
      long a = 0;
      long r = 0;
      long c = 0;
      long h = 0;
      for(int i = 0;i < n;i++){
      	String fi = sc.next().substring(0,1);
        if(fi.equals("M"))m++;
        else if(fi.equals("A"))a++;
        else if(fi.equals("R"))r++;
        else if(fi.equals("C"))c++;
        else if(fi.equals("H"))h++;
      }
      long sum = m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h;
      System.out.println(sum);
    }
}

Measured memory_bytes: 43780
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    d: i64,
    xy: [(i64, i64); n]
    }
    let mut ans = 0;
    for i in 0..n {
        if d * d >= xy[i].0.pow(2) + xy[i].1.pow(2) {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main(){
	ll n;
	cin >> n;
	cout << n*(n-1)/2 << endl;
    return 0;
}



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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    int x,y,z;
    cin >> x >> y >> z;

    if(x+y+z>=22)   puts("bust");
    else    puts("win");

    return 0;
}

Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<bitset>
using namespace std;
typedef long long LL;
const int MOD=998244353;
const int N=305;
int n,m;
bitset<N> s[N];
bitset<N> f[N];
int cnt=0;
void Ins ()
{
	for (int u=1;u<=n;u++)
	{
		bool tf=true;
		for (int i=1;i<=m;i++)
		if (s[u][i])
		{
			if (!f[i][i]) 	{f[i]=s[u];tf=false;break;}
			s[u]^=f[i];
		}
		cnt=cnt+tf;
	}
}
int Pow[N];
int main()
{
	scanf("%d%d",&n,&m);
	Pow[0]=1;for (int u=1;u<=n;u++) Pow[u]=Pow[u-1]*2%MOD;
	for (int u=1;u<=n;u++)
	{
		for (int i=1;i<=m;i++)
		{
			int x;
			scanf("%d",&x);
			s[u][i]=x;
		}
	}
	Ins();
	int ans=0;
	int t=1;	for (int u=1;u<m;u++) t=t*2%MOD;
	int lalal=(Pow[n]-Pow[cnt]+MOD)%MOD;
	//printf("%d %d\n",lalal,Pow[cnt]);
	ans=(LL)lalal*t%MOD;
	printf("%d\n",ans%MOD);
	return 0;
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}
#endif


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

    int N, X; cin >> N >> X;
    vi a(N);  REP(i,N) cin >> a[i];
    
    sort(a.begin(), a.end());

    int ans = 0;
    REP(i,N-1) {
        if (X>=a[i]){
            X -= a[i];
            ans++;
        }
    }
    if (X == a[N - 1]) ans++;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "math.h"


int i,j,k;
int in;
int cnt=0;
int data[3000][1000];
int ps[3000];
int sum[3000]={0};
double av[3000];
double ans[3000];

int main(){
  do{
    scanf("%d",&in);
    ps[cnt]=in;
    for(i=0;i<in;i++){
      scanf("%d",&data[cnt][i]);
      sum[cnt]+=data[cnt][i];
    }
    cnt++;
  }while(in!=0);
  cnt--;
  
  for(i=0;i<cnt;i++){
    av[i]=(double)sum[i]/(double)ps[i];
  }
  for(i=0;i<cnt;i++){
    double tmp=0;
    for(j=0;j<ps[i];j++){
      tmp+=(double)(data[i][j]-av[i])*(double)(data[i][j]-av[i]);
    }
    ans[i]=sqrt((double)tmp/(double)ps[i]);
  }
  
  for(i=0;i<cnt;i++){
    printf("%.8lf\n",ans[i]);
  }
  
  return 0;
}

Measured memory_bytes: 1112
#include<stdio.h>
#include<iostream>
#include<vector>
#include<list>
#include<math.h>
#include<algorithm>
#include<map>
using namespace std;
typedef unsigned long long ll;
ll ar[100003],at[100004];
map<ll,ll> mp;
int main()
{
    ll n,i;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>ar[i];
        at[i]=ar[i];
    }
    sort(at+1,at+1+n);
    for(i=1;i<=n;i++)
        mp[at[i]]=i;
    ll ans=0;
    for(i=1;i<=n;i++)
    {
        ll k=mp[ar[i]];
        if((k%2)!=(i%2))
            ans++;
    }
    cout<<ans/2;
    return 0;
}


Measured memory_bytes: 8064
#include<cstdio>
#include<algorithm>
using namespace std;
int n, m, Q, Mod, T, UF[6001000], Z[1000100];
struct point {
	int a, b, c;
}w[101000];
int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int Find(int a) {
	if (a == UF[a])return a;
	return UF[a] = Find(UF[a]);
}
void Merge(int a, int b) {
	a = Find(a), b = Find(b);
	if (a != b)UF[a] = b;
}
int main() {
	int i, a, b, c, j, k;
	scanf("%d%d%d%d", &n, &m, &Q, &Mod);
	T = Mod;
	for (i = 0; i < m; i++) {
		scanf("%d%d%d", &w[i].a, &w[i].b, &w[i].c);
		w[i].a--, w[i].b--;
		w[m + i] = w[i];
		swap(w[m + i].a, w[m + i].b);
		if(i)T = gcd(T, abs(w[i].c - w[i-1].c));
	}
	m *= 2;
	Mod = gcd(Mod, 3 * T);

	int A = Mod / T;
	int rr = w[0].c%T;
	for (i = 0; i < m; i++) {
		w[i].c -= rr;
	}
	for (i = 0; i < (A*2) * n; i++) UF[i] = i;
	for (i = 0; i < m; i++) {
		a = w[i].a, b = w[i].b, c = (w[i].c%Mod) / T;
		for (j = 0; j < A; j++) {
			Merge(a * (A*2) + j, b * (A*2) + A + (2 * j + c) % A);
			Merge(a * (A*2) + A + j, b * (A*2) + (2 * j + c) % A);
		}
	}
	int cnt = 0;
	for (i = 0; i < Mod; i++) {
		if (Z[i])continue;
		cnt++; int x = i;
		while (!Z[x]) {
			Z[x] = cnt;
			x = x * 4 % Mod;
		}
	}
	while (Q--) {
		scanf("%d%d%d", &a, &b, &c);
		a--, b--;
		for (j = 0; j < (A*2); j++) {
			if (Find(b * (A*2)) == Find(a * (A*2) + j)) {
				int t = (rr * (j/A+1) + (j%A)*T)%Mod;
				if (Z[t] == Z[(c + rr) % Mod]) {
					puts("YES");
					break;
				}
			}
		}
		if (j == (A*2))puts("NO");
	}
}

Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
#define Y cout<<"YES"<<endl;
#define N cout<<"NO"<<endl;
#define tc int t; cin>>t; while(t--)
#define eki int n; cin>>n;
#define loop for(int i=0; i<n; i++)
int main()
{  
    
  string s;
  cin>>s;
  if(isupper(s[0]))
  cout<<"A"<<endl;
  else cout<<"a"<<endl;
}




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

#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << endl;

using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
#define scl1(a)             scanf("%lld", &a)
#define scl2(a, b)          scanf("%lld %lld", &a, &b)

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
const int mod = 1e9+7;
const db pi = acos(-1);
const long long infl = LLONG_MAX;
const int inf = 0x3f3f3f3f;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase   

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);

ll t,i,x,j,y,z,k,n,r,c;

cin>>r>>c;
string s[r];
rep(i,0,r,1)cin>>s[i];
ll a[r][c];
Fill(a,0);

if(s[0][0]=='.')a[0][0]=1;
rep(i,1,c,1){
	if(s[0][i]=='#')break;
	a[0][i]++;
}
rep(i,1,r,1){
	if(s[i][0]=='#')break;
	a[i][0]++;
}

rep(i,1,r,1){
	rep(j,1,c,1){
		if(s[i][j]=='#')continue;
		a[i][j]=(a[i][j-1]+a[i-1][j]+mod)%mod;
	}
}

cout<<(a[r-1][c-1]+mod)%mod;
}


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

typedef int int_t;
#define int long long

const int maxn=2005;
const int mod=924844033;

int F[maxn][maxn][4];
int lis[maxn],ln;

void adm(int &x){x>=mod?x-=mod:0;}

void DP(){
    for(int i=1;i<=ln;i++)for(int j=0;j<=ln+1;j++){
        for(int k=0;k<4;k++)F[i][j][k]=0;
    }
    F[0][0][0]=1;
    for(int i=0;i<ln;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<4;k++){
                for(int t=0;t<3;t++)if(lis[i+1]>>t&1){
                    adm(F[i+1][j+(t!=0)][(k<<1|(t==1))&3]+=(!((k&2)&&(t==2)))*F[i][j][k]);
                }
            }
        }
    }
}

int N,K;

int G[maxn],T[maxn*2],fac[maxn];

int solve(){
    G[0]=1;
    for(int i=1;i<=K;i++){
        ln=0;
        for(int j=i;j<=N;j+=K){
            lis[++ln]=((j-K>=1)<<2)|((j+K<=N)<<1)|1;
        }
        DP();
        for(int i=0;i<=N;i++)for(int j=0;j<=ln;j++){
            (T[i+j]+=G[i]*(F[ln][j][0]+F[ln][j][1]+F[ln][j][2]))%=mod;
        }
        for(int i=0;i<=N;i++){G[i]=T[i];T[i]=0;}
    }
    fac[0]=1;
    for(int i=1;i<=N;i++)fac[i]=fac[i-1]*i%mod;
    int ans=0;
    for(int i=0;i<=N;i++){
        (ans+=(i&1?-1:+1)*G[i]*fac[N-i])%=mod;
    }
    return (ans+mod)%mod;
}

int_t main(){
    cin>>N>>K;
    cout<<solve()<<'\n';
    return 0;
}


Measured memory_bytes: 125696
#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;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 69
#endif
	

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename A,typename B> istream& operator>>(istream&,pair<A,B>&);
template<typename A> istream& operator>>(istream&,vector<A>&);
void add(int&,int);
int mul(int,int);
int powz(int,int);

const int N=500006;
string s;
int dp[N][2];
int n;
int rec(int pos,int flag)
{
	if(pos==n)return 1;
	if(dp[pos][flag]!=-1)return dp[pos][flag];
	int &ans=dp[pos][flag];
	ans=0;
	//~ if(pos==n)return 1;
	if(flag==0)
	{
		if(s[pos]=='0')add(ans,rec(pos+1,0));
		else {add(ans,mul(2,rec(pos+1,0)));add(ans,rec(pos+1,1));}
		}
	else
	{
		add(ans,mul(3,rec(pos+1,1)));
		
		}
	return ans;
	
	}

void solve()
{
    cin>>s;
    n=s.length();
    for(int i=0;i<N;i++)dp[i][0]=dp[i][1]=-1;
    cout<<rec(0,0);
    
}




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

}


int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}

void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	if(a<0)a+=mod;
}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
	}
	return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}



Measured memory_bytes: 7504
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		int sumResult = 0;
		for(int i=1; i<=n; ++i) {
			int sumPerKeta = 0;
			String formated = String.format("%04d", i);
			for(int j=0; j<= 3; ++j) {
				char numChar = formated.charAt(j);
				int num = Character.getNumericValue(numChar);
				sumPerKeta += num;
			}
			if(a <= sumPerKeta && sumPerKeta <= b) {
				sumResult += i;
			}
		}
		System.out.println(sumResult);
	}

}


Measured memory_bytes: 33724
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 200000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
typedef int64_t ll;
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; }

int N;

int main() {
	cin >> N;
	vector<int> a(N);
	rep(i, N) {
		cin >> a.at(i);
	}
	rep(i, N) {
		if (i == 0 || a.at(i) > a.at(i - 1))a.at(i)--;
	}
	rep(i, N - 1) {
		if (a.at(i) > a.at(i + 1)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using LL =unsigned long long;
using namespace std;

int main()
{
    int a,b;cin >> a >> b;
    if(a%2!=0&&b%2!=0){
        cout<<"Odd"<<endl;
    }else{
        cout<<"Even"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N=100;

int main(){

  int i,j,k,l,n,p[N+1],m[N+1][N+1];

  scanf("%d",&n);


  for(i=1;i<=n;i++){

    scanf("%d%d",&p[i-1],&p[i]);
    
  }

  for(i=1;i<=n;i++)m[i][i]=0;

  for(l=2;l<=n;l++){
    for(i=1;i<=(n-l)+1;i++){
      j=i+l-1;
    m[i][j]=(1<<21);
    for(k=i;k<=j-1;k++){
      if(m[i][j]>m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j])
      m[i][j]=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
    }
  }
  }


  printf("%d\n",m[1][n]);

  return 0;

}

  



Measured memory_bytes: 2112
n = int(input())
c = list(map(int, input().split()))
c.sort()

a, b = 0, 0
f = 'a'
while(len(c) != 0):
    if f == 'a':
        a += c.pop()
        f = 'b'
    elif f == 'b':
        b += c.pop()
        f = 'a'
print(a - b)

Measured memory_bytes: 3060
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;
 
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
const int INF = (1LL<<30);
const ll LLINF = (1LL<<60);
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;
#define int ll
 
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
 
signed main(void)
{
  int q, h, s, d;
  cin >> q >> h >> s >> d;
  int n;
  cin >> n;
  int nn = n;
 
  int flag;
  if(q*4 <= s && q*4 <= h*2) flag = 0;
  else if(h*2 <= s && h*2 <= q*4) flag = 1;
  else if(s <= h*2 && s <= q*4) flag = 2;
  else assert(false);
 
  // cout << flag << endl;
 
  ll ret = 0;
  ret += n/2*d;
  // cout << ret << endl;
  n %= 2;
  if(n) {
    if(flag == 0) ret += q*4;
    else if(flag == 1) ret += h*2;
    else if(flag == 2) ret += s;
  }
  n = nn;
  ll ans = ret;
  ret = 0;
  if(flag == 0) ret += q*4*n;
  else if(flag == 1) ret += h*2*n;
  else if(flag == 2) ret += s*n;
 
  // cout << ret << " " << ans << endl;
  cout << min(ret, ans) << endl;
 
  return 0;
}

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

int main() {
  int n, l;
  cin >> n >> l;
  string ans = "";
  vector<string> S(n);
  for (int i = 0; i < n; i++) cin >> S.at(i);
  
  sort(S.begin(), S.end());
  for (int i = 0; i < n; i++) ans += S.at(i);
  cout << ans << endl;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

class A {

    static final int[] money = new int[300];

    static {
        money[1] = 300000;
        money[2] = 200000;
        money[3] = 100000;
    }

    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final int X = sc.nextInt();
        final int Y = sc.nextInt();
        System.out.println(money[X] + money[Y] + (X == 1 && Y == 1 ? 400000 : 0));
    }
}
public class Main {
    public static void main(String... args) {
        A.main();
    }
}


Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
priority_queue <pi,vector<pi>,greater<pi>> q;
int n,m,l,r,ans;
struct note{
	int l,r,use;
}a[200005];
bool cmp(note x,note y) { return x.l<y.l; }
bool cmp1(note x,note y) { return x.r>y.r; }
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	std::sort(a+1,a+n+1,cmp);
	l=1,r=m;
	for (int i=1;i<=n;i++){
		if (a[i].l==0) continue;
		if (a[i].l>=l){
			l++,ans++,q.push(make_pair(a[i].r,i));
			a[i].use=1;
		}else{
			pi t=q.top();
			if (a[i].r>t.first){
				q.pop();
				a[i].use=1;
				a[t.second].use=0;
				q.push(make_pair(a[i].r,i));
			}
		}
	}
	std::sort(a+1,a+n+1,cmp1);
	for (int i=1;i<=n;i++){
		if (a[i].use || a[i].r>m) continue;
		if (r<l) break;
		if (a[i].r<=r) r--,ans++;
	}
	printf("%d\n",n-ans);
} 

Measured memory_bytes: 4724
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define pb push_back
using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;


int main(void){
  int n;
  cin>>n;
  vector<int >x,y;
  int t;
  for(int i=0;i<n;i++){
    cin>>t;
    x.pb(t);
    y.pb(t);
  }
  sort(x.begin(),x.end());

  for(int i=0;i<n;i++){
    if(y[i]<=x[(n/2)-1]) cout<<x[n/2]<<endl;
    else cout<<x[(n/2)-1]<<endl;
  }

  return 0;
}

Measured memory_bytes: 3948
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
       return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
int main()
{

   fastread();

   ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r;


     string str;

   bool flag=true;

     cin>>n;

      a=0;

      for(i=1; i<=1000000; i++)
      {

          a*=10;

          a+=7;
             a%=n;

          //   cout<<a<<endl;

             if(a==0)
             {
                 cout<<i<<endl;

                 return 0;
             }



      }
      cout<<-1<<endl;




}



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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define SORT(v) sort(ALL(v))
//#define scanf scanf_s
typedef pair<int, int> P;

int main()
{
	int x, y, s;
	while (cin >> x >> y >> s, x)
	{
		x += 100;
		y += 100;
		int ans = 0;
		FOR(i, 1, 1001)FOR(j, 1, 1001)
		{
			if (i*x / 100 + j*x / 100 == s) ans = max(ans, (i*y / 100 + j*y / 100));
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=1;
const int inf=2147483647;
int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int main()
{
	int a=read(),b=read(),c=read();
	if(a==b&&b==c)puts("Yes");else puts("No");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,d,l,i=1;
	scanf("%d %d %d %d %d",&l,&a,&b,&c,&d);
	while(a>c*i||b>d*i)i++;
	printf("%d\n",l-i);
	return 0;
}



Measured memory_bytes: 2044
#include <iostream>
#include <stdio.h>
using namespace std;

int a, b;

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

    cin >> a >> b;
    cout << a / b << ' ';
    cout << a % b << ' ';
    printf("%.5f\n", (double)a / b);
    return 0;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch 9x9 | diff 9x9.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 9x9.cpp && ./a.out

/*
 
 10/27/2019
 
 5:00-
 
 */

int A,B;

void solve() {
  int res;
  if(A>=10||B>=10) res=-1;
  else res=A*B;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
h,w = map(int, input().split())
S = [input() for _ in range(h)]
for r in range(h):
    for c in range(w):
        count = 0
        if S[r][c] == '#':
            print('#', end='')
        else:
            for x in S[max(0,r-1):min(r+2,h)]:
                count += x[max(0,c-1):min(c+2,w)].count('#')
            print(count, end='')
    print()

Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main() {
	int m, f, r;
	while (cin >> m >> f >> r && (m != -1 || f != -1 || r != -1)) {
		if (m == -1 || f == -1) cout << "F";
		else if (m + f >= 80) cout << "A";
		else if (m + f >= 65) cout << "B";
		else if (m + f >= 50 || r >= 50) cout << "C";
		else if (m + f >= 30) cout << "D";
		else cout << "F";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
} zahyo_t;

int koch(int n, zahyo_t p1, zahyo_t p2)
{
  //if(n == 0)
  // return 0;
  zahyo_t a, b, c;
  
  // printf("%f %f\n", p1.x, p1.y);
  if(p1.x < p2.x && p1.y == p2.y) {
    a.x = p1.x + (p2.x - p1.x)/3;
    a.y = p1.y;
    c.x = p1.x + 2 * (p2.x - p1.x)/3;
    c.y = p1.y;
    b.x = (a.x + c.x)/2;
    b.y = a.y + (c.x - a.x) * sqrt(3) / 2;
  } else if(p1.x < p2.x && p1.y < p2.y) {
    a.x = p1.x + (p2.x - p1.x)/3;
    a.y = p1.y + (p2.y - p1.y)/3;
    c.x = p1.x + 2 * (p2.x - p1.x)/3;
    c.y = p1.y + 2 * (p2.y - p1.y)/3;
    b.x = c.x - 2 * (c.x - a.x);
    b.y = c.y;
  } else if(p1.x < p2.x && p1.y > p2.y) {
    a.x = p1.x + (p2.x - p1.x)/3;
    a.y = p2.y +2 * (p1.y - p2.y)/3;
    c.x = p1.x + 2 * (p2.x - p1.x)/3;
    c.y = p2.y + (p1.y - p2.y)/3;
    b.x = a.x + 2 * (c.x - a.x);
    b.y = a.y;
  } else if(p1.x > p2.x && p1.y < p2.y) {
    a.x = p2.x + 2 * (p1.x - p2.x)/3;
    a.y = p1.y + (p2.y - p1.y)/3;
    c.x = p2.x + (p1.x - p2.x)/3;
    c.y = p1.y + 2 * (p2.y - p1.y)/3;
    b.x = a.x - 2 * (a.x - c.x);
    b.y = a.y;
  } else if(p1.x > p2.x && p1.y == p2.y) {
    a.x = p2.x + 2 * (p1.x - p2.x)/3;
    a.y = p1.y;
    c.x = p2.x + (p1.x - p2.x)/3;
    c.y = p1.y;
    b.x = (a.x + c.x)/2;
    b.y = a.y - (a.x - c.x) * sqrt(3) / 2;
  } else {
    a.x = p2.x + 2 * (p1.x - p2.x)/3;
    a.y = p2.y + 2 * (p1.y - p2.y)/3;
    c.x = p2.x + (p1.x - p2.x)/3;
    c.y = p2.y + (p1.y - p2.y)/3;
    b.x = c.x + 2 * (a.x - c.x);
    b.y = c.y;
  }
  if(n > 1) {
    n--;
    koch(n, p1, a);
    koch(n, a, b);
    koch(n, b, c);
    koch(n, c, p2);
  } else if(n == 1){
    //    printf("n = %d\n", n);
    // printf("p1.x = %f, p1.y = %f, p2.x = %f, p2.y = %f\n", p1.x, p1.y, p2.x, p2.y);
    printf("%.8f %.8f\n", p1.x, p1.y);
    printf("%.8f %.8f\n", a.x, a.y);
    printf("%.8f %.8f\n", b.x, b.y);
    printf("%.8f %.8f\n", c.x, c.y);
  } else {
    printf("%.8f %.8f\n", p1.x, p1.y);
  }
  
  //  printf("%f %f\n", p2.x, p2.y);
  return 0;
}

int main(void)
{
  int n;
  zahyo_t p1, p2;
  p1.x = 0;
  p1.y = 0;
  p2.x = 100;
  p2.y = 0;
  scanf("%d", &n);
  //  printf("%f %f\n", p1.x, p1.y);
  koch(n, p1, p2);
  printf("%.8f %.8f\n", p2.x, p2.y);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define pa pair<int,int>
const int Maxn=100010;
const int inf=2147483647;
LL read()
{
	LL x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x*f;
}
int n;
LL a[Maxn],b[Maxn],sa=0,sb=0,s=0,c[Maxn],lc=0;
bool cmp(int x,int y){return x>y;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)a[i]=read(),sa+=a[i];int ans=0;
	for(int i=1;i<=n;i++)
	{
		b[i]=read(),sb+=b[i];
		if(a[i]<b[i])s+=b[i]-a[i],ans++;
		else c[++lc]=a[i]-b[i];
	}
	if(sa<sb)return puts("-1"),0;
	sort(c+1,c+1+lc,cmp);
	for(int i=1;i<=lc;i++)
	{
		if(s<=0)break;
		s-=c[i];ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 2432
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;

ll popcount(ll num){
    num = num - ((num >> 1) & 0x55555555);
    num = (num & 0x33333333) + ((num >> 2) & 0x33333333);
    return ((num + (num >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
}

void virus(){
       ll n;
       cin>>n;
       unordered_map<ll,ll> mp;
       ll sum = 0;
       for(auto i=0;i<n;i++){
           ll t;
           cin>>t;
           sum += t;
           mp[t] += 1;
       }
       ll q;
       cin>>q;
        while(q--){
            ll ini,fnl;
            cin>>ini>>fnl;
            sum -= (mp[ini]*ini);
            sum += (mp[ini]*fnl);
            mp[fnl] += mp[ini];
            mp.erase(mp.find(ini));
            //cout<<mp[4]<<endl;
            cout<<sum<<endl;
        }

}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t=1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
         //cout << "Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 6652
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;
ll dp[100005];

ll stair(ll now){
    if(dp[now] != -1){
        return dp[now];
    }
    if(dp[now-1] == 0){
        dp[now] = stair(now-2)%MOD;
    }else if(dp[now-2] == 0){
        dp[now] = stair(now-1)%MOD;
    }else{
        dp[now] = (stair(now-2)%MOD+stair(now-1)%MOD)%MOD;
    }
    return 0;
}


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

    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    REP(i,n+1) dp[i] = -1;
    REP(i,m) cin >> a[i];
    ll then;
    dp[0] = 1;
    dp[1] = 1;
    if(a.size() > 0){
        VSORT(a);
        then = a[0];
        dp[a[0]] = 0;
    }
    for(int i = 1; i < a.size();i++){
        if(then == a[i]){
            cout << 0 << endl;
            return 0;
        }
        dp[a[i]] = 0;
        then = a[i];
    }
    for(ll i = 2; i < n+1;i++){
        if(dp[i] != 0){
            stair(i);
        }
    }

    cout << dp[n]%MOD << endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
int a[15][15];
int main()
{
//	freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	int n,d,i,j,k,sum,total=0;
	double t;
	cin>>n>>d;
	for(i=0;i<n;i++)
		for(j=0;j<d;j++)
			cin>>a[i][j];
	for(i=0;i<n;i++)
		for(j=i+1;j<n;j++)
		{
			sum=0;
			for(k=0;k<d;k++)
				sum+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
			t=sqrt(sum);
			if(t==(int)(t))
				total++;
		}
	cout<<total;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
# from collections import Counter
# from itertools import accumulate
# from fractions import gcd # >=Python3.5 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # <Python3.5
# from math import sqrt

# input = sys.stdin.readline
# def main():

#---------------------------------------------------------

n,q = map(int,input().split())

road = [[] for _ in range(n)]
cnt  = [0 for _ in range(n)]

for i in range(n-1):
    a,b = map(int,input().split())
    road[a-1].append(b-1)
    road[b-1].append(a-1)

for i in range(q):
    idx,v = map(int,input().split())
    cnt[idx-1] += v

dist = [-1]*n
que  = deque()
dist[0] = 0
que.append(0)

while(len(que)!=0):
    # BFS/DFS
    v = que.pop()
    for r in road[v]:
        if dist[r]!=-1:
            continue
        dist[r] = dist[v] + 1
        cnt[r] += cnt[v]
        que.append(r)

print(*cnt)

Measured memory_bytes: 62924