akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var W = ReadSplitInt();
            var ans = int.MaxValue;
            for (int i = 0; i < N; i++)
            {
                var a = 0;
                var b = 0;
                for (int j = 0; j <= i; j++)
                {
                    a += W[j];
                }

                for (int k = i + 1; k < N; k++)
                {
                    b += W[k];
                }
                ans = Min(ans, Abs(a - b));
            }
            Println(ans);
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static int Gcd(int a, int b) => b == 0 ? a : Gcd(b, a % b);

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}

Measured memory_bytes: 13268
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(1 <= a && a <= 100){
      if(1 <= b && b <= 100){
        System.out.println(a * b);
      }
    }
  }
}

Measured memory_bytes: 35732
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdlib>
using namespace std;

struct NODE{
	string to;
	int cost;
	NODE(string to,int cost) : to(to) , cost(cost) {}
};

int main(){
	int n;
	while(cin >> n && n){
		map<string,vector<NODE> > g;
		
		for(int i = 0 ; i < n ; i++){
			string a,b,c,d,e;
			cin >> a >> b >> c >> d >> e;
			g[b].push_back(NODE(e,atoi(d.substr(d.find("^")+1).c_str())));
			g[e].push_back(NODE(b,-atoi(d.substr(d.find("^")+1).c_str())));
			
		}
		int ok = 1;
		for( map<string,vector<NODE> > ::iterator it = g.begin() ; it != g.end() ; ++it ){
			map<string,int> done;
			queue<NODE> Q;
			Q.push(NODE(it->first,0));
			while(Q.size()){
				NODE q = Q.front(); Q.pop();
				if( done.count(q.to) ){
					if( done[q.to] != q.cost ) ok = 0;
					continue;
				}
				done[q.to] = q.cost;
				for(int i = 0 ; i < g[q.to].size() ; i++)
					Q.push(NODE(g[q.to][i].to,q.cost+g[q.to][i].cost));
			}
		}
		cout << (ok?"Yes":"No") << endl;
	
	}
}

Measured memory_bytes: 1296
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  m=2*m;
  n=n-m;
  if(n<0){
	cout<<"0";
  }
  else 
    cout<<n;
  
  
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, q, pos[N], kier[N], res, i, j, po, akt, a, b, ind[30], l, r, indd;
VI v[30];
char t[N];

int simulate(int po) {
	int a, j, akt, b;
	for (j=0;j<26;j++) ind[j] = 0;
	akt = 0;
	while(true) {
		a = pos[po];
		while(ind[a] < v[a].size() && v[a][ind[a]] < akt) ind[a]++;
		if (ind[a] >= v[a].size()) break;		
		b = v[a][ind[a]];
		if (kier[b]) po++; else po--;
		if (po == -1 || po == n) break;
		akt = b + 1;
	}
	return po;
}

int main() {
scanf("%d %d", &n, &q);
scanf("%s", t);
for (i=0;i<n;i++) pos[i] = int(t[i] - 'A');
for (i=0;i<q;i++) {
	scanf("%s", t);
	v[int(t[0] - 'A')].pb(i);
	scanf("%s", t);
	kier[i] = (t[0] == 'R');
}
res = n;
if (simulate(0) == -1) {
	l = 0;
	r = n - 1;
	while (l < r) {
		indd = (l + r) / 2 + 1;
		if (simulate(indd) == -1) l = indd; else r = indd - 1;
	}
	res -= (l + 1);
}
if (simulate(n - 1) == n) {
	l = 0;
	r = n - 1;
	while (l < r) {
		indd = (l + r) / 2;
		if (simulate(indd) == n) r = indd; else l = indd + 1;
	}
	res -= (n - r);
}
printf("%d\n", res);
return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << 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; }

const ll MOD = 1e9 + 7;

int main()
{   
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    for(ll i = k; i <= n + 1; i++) {
        ll a = i * (i-1) / 2;
        ll b = i * (2*n-i+1) / 2;
        ll add = b - a + 1;
        ans = (ans + add) % MOD;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3600
S = list(input())
ans = [0] * len(S)
l = 0
N = len(S)
for i in range(1,N,1):
    if i != N-1:
        if S[i] == 'L' and S[i-1] == 'R':
            ans[i-1] += (i-l)-(i-l)//2
            ans[i] += (i-l)//2
            l = i
        elif S[i] == 'R' and S[i-1] == 'L':
            ans[l] += (i-l)-(i-l)//2
            ans[l-1] += (i-l)//2
            l = i
    else:
        if S[N-2] == 'L':
            ans[l-1] += (i-l+1)//2
            ans[l] += (i-l+1)-(i-l+1)//2
        elif S[N-2] == 'R':
            ans[N-1] += (N-l)-(N-l)//2
            ans[N-2] += (N-l)//2
print(*ans)

Measured memory_bytes: 51320
def main():
    a, b, c, x, y = map(int, input().split())
    
    t1 = a * x + b * y
    t2 = c * max(x, y) * 2
    if x >= y:
        t3 = c * y * 2 + a * (x - y)
    else:
        t3 = c * x * 2 + b * (y - x)
        
    print(min(t1, t2, t3))
    
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line

inline void solve(void){
  int N;
  in(N);
  switch(N%10){
    case 3:
    out("bon");
    break;
    case 0:
    case 1:
    case 6:
    case 8:
    out("pon");
    break;
    default:
    out("hon");
    break;
  }
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3648
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N;
    cin >> N;

    vector<int> a(N);
    vector<int> b(N);
    int suma = 0;
    REP(i, N) {
        cin >> a[i];
        suma += a[i];
    }
    int sumb = 0;
    REP(i, N) {
        cin >> b[i];
        sumb += b[i];
    }

    if (suma > sumb) {
        cout << "No" << endl;
        return 0;
    }

    int num = sumb - suma;
    int one = 0;
    int two = 0;
    REP(i, N) {
        if (a[i] > b[i]) {
            one += a[i] - b[i];
        } else if (a[i] < b[i]) {
            two += (b[i] - a[i] + 1) / 2;
        }
    }
    cout << (one <= num && two <= num ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A,B;
    cin>>A>>B;
    int sum=-1;
    for(int i=1;i<=10000;i++){
        int Asum=i*0.08;
        int Bsum=i*0.1;
        if(ceil(Asum)==A&&ceil(Bsum)==B){
            sum=i;
            break;
        }
        
}
    cout<<sum<<endl;
}

Measured memory_bytes: 256
import heapq

INF = 10**9+1

def solve():
  n_V,n_E,r = map(int, input().split())
  graph = {v:[] for v in range(n_V)}
  for _ in range(n_E):
    u,v,w = map(int, input().split())
    graph[u].append((v,w))

  min_distances = [INF]*n_V; min_distances[r] = 0

  prev = [None for _ in range(n_V)]
  # (d(u),u)
  queue = [(min_distances[v], v) for v in range(n_V)]
  heapq.heapify(queue)

  while queue:
    _, dom = heapq.heappop(queue)
    for cod, edge_weight in graph[dom]:
      if min_distances[cod] > min_distances[dom] + edge_weight:
        min_distances[cod] = min_distances[dom] + edge_weight
        prev[cod] = dom
        heapq.heappush(queue, (min_distances[cod], cod))

  for d in min_distances:
    print(d if d < INF else 'INF')


solve()


Measured memory_bytes: 107328
/*
  DATE:   2020-03-10 11:33:22
  NAME:   
  PROBLEM:  ABC158E
*/
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 2e5;
const int MAXP = 1e4;
 
int a[MAXN + 7];
 
int cnt[MAXP + 7];
 
int main() {
  int n, p;
  cin >> n >> p;
 
  string st;
  cin >> st;
 
  for (int i = 1; i <= n; i++) {
    a[i] = (st[i - 1] - '0') % p;
  }

  if (p != 2 and p != 5) {
    long long ans = 0;
    int e = 1;
   
    cnt[0] = 1;
   
    for (int i = n; i >= 1; i--) {
      a[i] = (a[i + 1] + (e * a[i]) % p) % p;
      ans += cnt[a[i]];
      cnt[a[i]]++;
      e = (e * 10) % p;
    }
   
    cout << ans << "\n";
  }
  else {
    long long ans = 0;
    for (int i = n; i >= 1; i--) {
      if (a[i] % p == 0) {
        ans += i;
      }
    }
    cout << ans << "\n";
  }
 
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

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

  int dp[N];
  dp[0] = 0, dp[1] = abs(H[0] - H[1]);
  for (int i = 2; i < N; i++) {
    int x = dp[i - 2] + abs(H[i] - H[i - 2]);
    int y = dp[i - 1] + abs(H[i] - H[i - 1]);
    dp[i] = min(x, y);
  }

  cout << dp[N - 1] << "\n";
}

Measured memory_bytes: 1024
import java.util.Scanner;

// *** at 2018/**/**

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solveA();
	}

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (n < k) {
			System.out.println(n * x);
		} else {
			System.out.println((k * x) + ((n - k) * y));
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveE() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

	private void solveF() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(N);
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <stack>

using namespace std;

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define pb push_back
#define sz(s) (int)s.size()
#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)

const int N=(int)1e5+7;

int n,op,cl;
string s;

int main() {
    cin >> n >> s;
    string t = "";

    stack<char> st;

    forn(i, n) {
        if (s[i] == '(') {
            st.push('(');
        } else {
            if(!st.empty() and st.top()=='(') st.pop();
            else st.push(')');
        }
        t += s[i];
    }

    while(!st.empty()){
        char tt = st.top();
        if(tt=='(') t = t + ')';
        else t = '(' + t;
        st.pop();
    }

    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define int long long

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

const int kMaxN = 100000;

int N;
int ans = kMaxN;

int DigitsSum(int n) {
  int r = 0;
  while (n) {
    r += n%10;
    n /= 10;
  }
  return r;
}

signed main() {
  cin >> N;

  FOR(i, 1, N) { ans = MIN(ans, DigitsSum(i)+DigitsSum(N-i)); }

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
 
namespace IO{
    const int insiz = 1 << 12, outsiz = 1 << 18;
    char in[insiz], *A(in), *B(in); char out[outsiz], *ptr(out);
    inline char getc(){
    	#ifndef LOCAL
        return (A == B) && (B = (A = in) + fread(in, 1, insiz, stdin), A == B) ? EOF : *A++;
        #endif
        return getchar();
    }
    template <typename T> inline T read(){
        T ret(0), p(1); char ch(getc());
        while(ch < '0' || ch > '9'){
            if(ch == '-') p = -1; ch = getc();
        }
        while(ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getc();
        return ret*p;
    }
    inline void flush(){ fwrite(out, 1, ptr - out, stdout); ptr = out; }
    template <typename T> inline void write(T x, char cmd = '\n'){
        if(x < 0) *ptr++ = '-', x = -x;
        if(x == 0) *ptr++ = '0';
        static char s[123]; int cnt = 0;
        for(; x; x /= 10) s[++cnt] = x % 10 + '0';
        for(; cnt; --cnt) *ptr++ = s[cnt];
        *ptr++ = cmd;
        if((outsiz >> 1) > ptr - out) flush();
    }
} using IO::getc; using IO::read; using IO::write; using IO::flush;

const int maxn = 212345;
struct edge{
	int v, nxt;
}e[maxn << 1];
int fir[maxn], num(1);
inline void add(int u, int v){
	e[++num].v = v; e[num].nxt = fir[u]; fir[u] = num;
}
bool asked[maxn]; 
int main(){
	int n = read<int>();
	for(int i(1), u, v; i < n; ++i){
		u = read<int>(); v = read<int>();
		add(u, v); add(v, u);
	}
	std::queue<int> q;
	q.push(1); asked[1] = true; int las = 1;
	while(!q.empty()){
		las = q.front(); q.pop();
		for(int itr(fir[las]), v; itr; itr = e[itr].nxt){
			if(asked[v = e[itr].v]) continue;
			q.push(v); asked[v] = true;
		}
	}
	memset(asked, 0, sizeof(asked));
	int len = 0; asked[las] = true; q.push(las);
	while(!q.empty()){
		int l = q.size(); ++len;
		while(l--){
			int now = q.front(); q.pop();
			for(int itr(fir[now]), v; itr; itr = e[itr].nxt){
				if(asked[v = e[itr].v]) continue;
				q.push(v); asked[v] = true;
			}
		}
	}
	printf("%s\n", len%3 == 2 ? "Second" : "First");
	flush(); return 0;
}


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



int main() {
  int n;
  cin >>n;
  int a[n][26]={};
  rep(i,n){
    string s;
    cin >>s;
    int g=s.size();
    rep(r,g){
      a[i][(int)s[r]-97]++;
    }
  }
  rep(i,26){
    int ans=100000;
    rep(r,n){
      ans=min(ans,a[r][i]);
    }
    rep(r,ans){
      cout << (char)(i+97);
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;

int N, M, K;
long long A[200200], B[200200];

int main()
{
	scanf ("%d %d %d", &N, &M, &K);
	for (int i = 1; i <= N; i++) scanf ("%lld", &A[i]), A[i] += A[i - 1];
	for (int i = 1; i <= M; i++) scanf ("%lld", &B[i]), B[i] += B[i - 1];

	int c = 0;
	for (int i = 0; i <= N; i++){
		long long R = K - A[i];
		if (R < 0) break;

		int j = upper_bound(B, B + M + 1, R) - B - 1;
		if (c < i + j)
			c = i + j;
	}

	printf ("%d\n", c);
	return 0;

}

Measured memory_bytes: 6324
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << x * y / 2 << endl;
}

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

Measured memory_bytes: 768
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        Set<Long> set = new HashSet<Long>();
        long N=sc.nextLong();
        for(long i=0;i<N;i++){
            long temp=sc.nextLong();
            set.add(temp);
        }
        if(set.size()==N){
            System.out.println("YES");
        }else{
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 103040
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
string s;

int main() {
  cin >> s;
  cout << "2018/01/" << s[8] << s[9] << endl;
}


Measured memory_bytes: 256
N,K = map(int, input().split())
mod = 10 ** 9 + 7

def make_fact(n):#0~nの階乗を求める
    fact = [1]*(n+1)
    for i in range(1, n+1):
        fact[i] = fact[i-1]*i%mod
    return fact
fact = make_fact(N) #＠
def make_fact_inv(n):#0~nの階乗のmodに関する逆元を求める
    fact_inv = [1]*(n+1)
    fact_inv[n] = pow(fact[n], mod-2, mod)#フェルマーの小定理
    for i in range(n, 0, -1):
        fact_inv[i-1] = fact_inv[i]*i%mod
    return fact_inv
fact_inv = make_fact_inv(N)#＠
def comb(n, k):#nCk
    return fact[n]*fact_inv[k]*fact_inv[n-k]%mod

for i in range(K):
    if N - K < i:
        print(0)
    else:
        print(comb(K - 1, i) * comb(N - K + 1, i + 1) % mod)

Measured memory_bytes: 42352
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back

using namespace std;
typedef pair<ll,ll> pll;

string s;
ll n;
int main()
{
        cin >> n;
        ll cnt1 = 0;
        ll cnt2 = 0;
        ll cnt3 = 0;
        ll ans = 0;
        for(ll i=1;i<=n;i++) {
                cin >> s;
                bool st = false;
                bool e = false;
                if(s[0] == 'B') st = true;
                if(s[s.length()-1] == 'A') e = true;
                if(st && e){
                        cnt2++;
                }else if(st) cnt1++;
                else if(e) cnt3++;
                for(ll j=0;j<s.length()-1;j++){
                        if(s[j] == 'A' && s[j+1] == 'B') ans++;
                }
        }
        //cout << ans << endl;
        if(cnt2) ans += cnt2-1;
        else {
                ans += min(cnt1, cnt3);
                cout << ans << endl; return 0;
        }
        //cout << ans << endl;
        ll yo = min(cnt1,cnt3);
        //cout << cnt1 << " " << cnt3 << endl;
        if(yo == 0){
                if(cnt1 || cnt3) ans++;
        }else {
                cnt1--;
                cnt3--;
                ans += 2;
                ans += min(cnt1,cnt3);
        }
        cout << ans << endl;
        return 0;
}


Measured memory_bytes: 256
var
  n,k,i,ans:longint;
begin
  readln(n);
  readln(k);
  ans:=1;
  for i:=1 to n do
  begin
    if ans*2<ans+k then ans:=ans*2
                   else ans:=ans+k;
  end;
  writeln(ans);
end.

Measured memory_bytes: 128
#include <stdio.h>

int main(){
    
    int i, n, num[100];
    
    scanf("%d", &n);
    
    for( i = 0;i < n; i++){
        scanf("%d", &num[i]);
    }
    
    for( i = n-1; i >= 0; i--){
        printf("%d", num[i]);
        if( i != 0){
            printf(" ");
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
	if(a==0){
		return b;
	}
	return gcd(b%a,a);
}
int gcdt(int a,int b,int c){
	int x=gcd(a,b);
	x=gcd(x,c);
	return x;
}
int main(){
	int n,sum=0,i,j,k;
	cin>>n;
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			for(k=0;k<n;k++){
				sum+=gcdt(i+1,j+1,k+1);
			}
		}
	}
	cout<<sum<<"\n";
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define bgn begin()
#define sz size()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define all(a)  (a).begin(),(a).end()
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second

signed main(){
  string s;
  cin >> s;
  if(s == "keyence"){
    cout << "YES" << endl;
    return 0;
  }

  int n = s.size();
  fo(i,n){
    for(int j = i; j < n; j++){
      string t = "";
      fo(k,n){
        if(i <= k && k <= j)
          continue;
        t.pb(s[k]);
      }
      if(t == "keyence"){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
 
int main(){
  int n;
  cin >> n;
  VI a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  map<int ,int > cnt;
  for(int x: a){
    if(cnt.count(x)){
      cnt.at(x)++;
    }
    else{
      cnt[x]=1;
    }
  }
  ll xmax=0;
  rep(i,100000){
    ll sum=cnt[i]+cnt[i+1]+cnt[i+2];
    xmax=max(xmax,sum);
  }
  cout << xmax << endl;
}

Measured memory_bytes: 5376
////////////////////////////////////////////
///                                      ///
///        Template ver. 1.2. rapel      ///
/// Fear is Temporary, Regret is Forever ///
///          Must Try and Get AC         ///
///                                      ///
////////////////////////////////////////////
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <iomanip>

#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>

#include <math.h>
#include <complex>

#include <assert.h>
#include <time.h>
//#include <chrono>
//#include <random>

#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <list>
#include <bitset>

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define endl '\n'
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

void desperate_optimization(int precision){
  	ios_base::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
  	cout.setf(ios::fixed);
  	cout.setf(ios::showpoint);
  	cout.precision(precision);
}

void hora(int tc) {
	int n, r;
	cin>>n>>r;
	if(n >= 10) cout<<r<<endl;
	else cout<<r + 100 * (10 - n)<<endl;
}

int main(){
	desperate_optimization(10);
	int ntc = 1;
	//cin>>ntc;
	for(int tc = 1;tc <= ntc;tc++) hora(tc);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100
#define MOD 1000000007
#define pb push_back

/* add vars here */

ll n;

/* add your algorithm here */

int main() {
  cin >> n;
  vector<ll> a;
  rep(i,n) {
    ll t; cin >> t;
    a.pb(t);
  }

  ll si = a.size();
  vector<ll> ans(si, 0);
  
  ll cnt1, cnt2;
  if (si % 2 == 1) {
    ans[si/2] = a[0];
    cnt1 = si/2-1, cnt2 = si/2 + 1;
    for (ll i = 1; i < si; ++i) {
      if (i % 2 == 0) {
        ans[cnt1--] = a[i];
      } else {
        ans[cnt2++] = a[i];
      }
    }
  } else {
    cnt1 = si/2 - 1, cnt2 = si/2;
    for (ll i = 0; i < si; ++i) {
      if (i % 2 == 1) {
        ans[cnt1--] = a[i];
      } else {
        ans[cnt2++] = a[i];
      }
    }
  }

  for (auto itr : ans) {
    cout << itr << " ";
  }

  cout << endl;
}


Measured memory_bytes: 5488
[N,M] = [int(x) for x in input().split()]

m = [[] for i in range(N)]

def toid(p,n):
    return "%06d%06d" % (p,n)

ids=["" for i in range(M)]
for i in range(M):
    [p,y] = [int(x) for x in input().split()]
    m[p-1].append((i,y))
    # print(i,y)

for p in range(N):
    if len(m[p]) == 0:
        continue
    nn = sorted(m[p],key=lambda x:x[1])

    for n,(i,y) in enumerate(nn): 
        ids[i] = toid(p+1,n+1)

print("\n".join(ids))


Measured memory_bytes: 38320
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	int n; cin >> n;
	map<ll, int> mp;
	for (int i = 1; i*i <= n; ++i)
	{
		for (int j = 1; j*j <= n; ++j)
		{
			for (int k = 1; k*k <= n; ++k)
			{
				ll tmp = i * i + j * j + k * k + i * j + j * k + k * i;
				++mp[tmp];
			}
		}
	}
	for (ll i = 1; i <= n; ++i)cout << mp[i] << endl;
}

Measured memory_bytes: 6064
#include<stdio.h>
int main(void){
	int a,b;
	char op;
	while(1){
		scanf("%d %c %d",&a,&op,&b);
		if(op=='+'){
			printf("%d\n",a+b);
		}
		if(op=='-'){
			printf("%d\n",a-b);
		}
		if(op=='*'){
			printf("%d\n",a*b);
		}
		if(op=='/'){
			printf("%d\n",(int)a/b);
		}
		if(op=='?'){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int n; cin >> n;
	vector<string> s(n);
	map<string, int> mp1 ,mp2;
	rep(i,n) cin >> s[i], mp1[s[i]]++;
	int m; cin >> m;
	vector<string> t(m);
	rep(i,m) cin >> t[i], mp2[t[i]]++;
	vector<int> v;
	v.push_back(0);
	for(auto &i: mp1){
		if (i.second > mp2[i.first]){
			v.push_back(i.second - mp2[i.first]);
		}
	}
	cout << *max_element(all(v)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        if (m == 0) {
            if (n == 1) {
                System.out.println(0);
            } else if (n == 2) {
                System.out.println(10);
            } else {
                System.out.println(100);
            }           
        } else {
            int[] s = new int[m];
            int[] c = new int[m];
            for (int i = 0; i < m; i++) {
                s[i] = sc.nextInt();
                c[i] = sc.nextInt();
            }
            boolean judge = true;
            loop: for (int i = 0; i < m; i++) {
                for (int j = i + 1; j < m; j++) {
                    if (s[i] == s[j] && c[i] != c[j]) {
                        judge = false;
                        break loop;    
                    }
                }
            }
            if (judge) {
                String str = "";
                for (int i = 1; i <= n; i++) {
                    boolean find = false;
                    for (int j = 0; j < m; j++) {
                        if (s[j] == i) {
                            find = true;
                            str += c[j];
                            break;
                        }
                    }
                    if (!find) {
                        if (i == 1) {
                            str += 1;
                        } else {
                            str += 0;
                        }
                    }
                }
                if (n == 1) {
                    System.out.println(Integer.parseInt(str));
                } else {
                    if (str.charAt(0) == '0') {
                        System.out.println(-1);
                    } else {
                        System.out.println(Integer.parseInt(str));
                    }
                }
            } else {
                System.out.println(-1);
            }
        }
        sc.close();
    }
}

Measured memory_bytes: 23764
H,W = map(int,input().split())
C = [list(map(int,input().split())) for _ in range(10)]
A = [list(map(int,input().split())) for _ in range(H)]

cost = [float("INF")]*(10)
cost[1] = 0
cnt = 0
while cnt < 10:
    cnt += 1
    for i in range(10):
        for j in range(10):
            cost[j] = min(cost[j],cost[i]+C[j][i])

ans = 0
for i in range(H):
    for j in range(W):
        if A[i][j] != -1:
            ans += cost[A[i][j]]
print(ans)

Measured memory_bytes: 73936
#include <bits/stdc++.h>
static const int MAX=100000;

using namespace std;

int lis(int n,const int A[],int L[]){
    L[0]=A[0];
    int length=1;

    for(int i=1;i<n;i++){
        if(L[length-1]<A[i])
            L[length++]=A[i];
        else
            *lower_bound(L,L+length,A[i])=A[i];
    }
    return length;
    
}
int main(){
    int n,A[MAX+1],L[MAX+1];
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    cout<<lis(n,A,L)<<"\n";
    return 0;
}


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

int main() {
  int H, W, M;
  cin >> H >> W >> M;
  map<P, bool> mp;
  vector<int> r(H, 0);
  vector<int> c(W, 0);
  rep(i, M) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    mp[{x, y}] = true;
    r.at(x)++;
    c.at(y)++;
  }

  int maxR = 0;
  rep(i, H) {
    if (r.at(i) > maxR) maxR = r.at(i);
  }
  vector<int> list1;
  rep(i, H) {
    if (r.at(i) == maxR) list1.push_back(i);
  }

  int maxC = 0;
  rep(i, W) {
    if (c.at(i) > maxC) maxC = c.at(i);
  }
  vector<int> list2;
  rep(i, W) {
    if (c.at(i) == maxC) list2.push_back(i);
  }

  int ans = maxR + maxC;
  for (auto x : list1) {
    for (auto y : list2) {
      if (!mp.count({x, y})) {
        cout << ans << endl;
        return 0;
      }
    }
  }

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

Measured memory_bytes: 28528
// unordered return continue break vector visited check flag bool while iterator temp true false ll_MAX ll_MIN insert pop push compare ll64_MAX ll64_MIN   replace stringstream string::npos  substr front 
#include<bits/stdc++.h>
using namespace std;
#ifdef AAYUSH
#include "/home/aayj/debug.cpp"
#else
#define debug(...) ;
#endif
#define ll  long long
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll&a , ll b){a=(a+b);
	if(a>=mod)a-=mod;
}
#define all(x) x.begin(),x.end()
#define pb push_back
#define ff first
#define ss second
#define bg begin
#define ed end
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define er erase
#define rev reverse
#define lg length
#define pii pair<ll,ll>
#define heap priority_queue
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
#define sz(a) (ll)((a).size())
#define forn(i, n) for (ll i = 0; i < ll(n); ++i)
#define fore(i, l, r) for (ll i = ll(l); i < ll(r); ++i)
#define YYY cout << "YES" << endl;
#define NNN cout << "NO" << endl;
const ll nax = 2e5+5   ;

signed main() {
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
ll n; cin >> n;
ll can[n+1][n+1] = {0};
for(ll i = 0; i < n; i++){
	for(ll j = 0; j < n; j++){
		cin >> can[i+1][j+1];
	}
}
ll x = (1<<(n));

vector<vector<ll>> dp(n+1, vector<ll>(x));
// dp[0].fill(1);
fill(all(dp[0]),1);

for(ll mask = 0; mask < x-1; mask ++){
	ll a = __builtin_popcount(mask) + 1;
	for(ll b = 1; b<=n; b++){
		ll m2 = 1<<(b-1);
		if((!(mask&m2)) && can[a][b]){
			// assert(mask|m2 < x);
			// assert(a<=n);
			add_self(dp[a][mask|m2], dp[a-1][mask]);
		}
	}
}
cout << dp[n][x-1];
	
}


Measured memory_bytes: 380200
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false); 
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    
    public static int[] generatePrimes(int n) {
		boolean[] prime = new boolean[n + 1];
		Arrays.fill(prime, 2, n + 1, true);
		for (int i = 2; i * i <= n; i++)
			if (prime[i])
				for (int j = i * i; j <= n; j += i)
					prime[j] = false;
		int[] primes = new int[n + 1];
		int cnt = 0;
		for (int i = 0; i < prime.length; i++)
			if (prime[i])
				primes[cnt++] = i;
		return Arrays.copyOf(primes, cnt);
	}
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}	
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}		    
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}	    	  	
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}		
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}	
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}	    	
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}	    	
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}				
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int m = in.nextInt();
        if(n<10 && m<10) out.println(n*m);
        else out.println(-1);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

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

typedef struct { char suit, value; } Card;

istream & operator>>(istream & is, Card & c) {
    is >> c.suit >> c.value;
    return is;
}

ostream & operator<<(ostream & os, const Card & c) {
    os << c.suit << c.value;
    return os;
}

bool operator<(const Card & a, const Card & b) {
    return a.value < b.value;
}

bool operator!=(const Card & a, const Card & b) {
	return a.suit!=b.suit || a.value!=b.value;
}

void show(Card *A, int n)
{
    int i;
    for (i=0; i<n-1; i++)
        cout << A[i] << " ";
    cout << A[i] << endl;
}

int bubbleSort(Card A[], int N) {
    int sw = 0; // ??¨?????°????????¢?¬???°
    bool flag = 1;
    for (int i=0; flag; i++) {
        flag = 0;
        for (int j=N-1; j>=i+1; j--) {
            if (A[j] < A[j-1]) {
                swap(A[j],A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int selectionSort(Card *A, int N){
    int i,j,minj,sw=0;
    for (i=0; i<N-1; i++) {
        minj=i;
        for (j=i+1; j<N; j++) {
            if (A[j]<A[minj]) minj = j;
        }
        if (minj!=i) {
            swap(A[i],A[minj]);
            sw++;
        }
    }
    return sw;
}

int main() {

    Card A[40],B[40];
    int N;
    cin >> N;
    for (int i= 0; i<N; i++) {
        cin >> A[i];
        cin.get();
    }

    for (int j=0; j<N; j++) B[j] = A[j];

    bubbleSort(A,N);
    show(A,N);
    cout << "Stable" << endl;

    selectionSort(B,N);
    show(B,N);
    int k;
    for (k=0; k<N; k++) if (A[k]!=B[k]) break;
    if (k==N) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

    return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  string s; cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PB push_back

int main()
{
    ll N; cin >> N;
    map<ll, ll> value_count;
    vector<ll> A(N);
    rep(i, N){
        cin >> A.at(i);
        value_count[A.at(i)]++;
    }
    ll all_conbination=0;
    for(auto i=value_count.begin(); i!=value_count.end(); i++){
        all_conbination+=i->S*(i->S-1)/2;
    }
    rep(i,N){
        cout << all_conbination-value_count[A.at(i)]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
package main

import (
  "fmt"
)

func main() {
  var s, t string
  fmt.Scan(&s, &t)
  cnt := 0
  for i:=0;i<len(s);i++{
    if s[i] != t[i] {
      cnt+=1
    }
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 3388
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	double p[n];
	for(int i=0;i<n;i++)
	cin>>p[i];
    
    double pb[n+1][n+1];
    for(int j=1;j<=n;j++)
    pb[0][j]=0.00;

    pb[0][0]=1.00;

    for(int i=1;i<=n;i++)
    {
    for(int j=0;j<=n;j++)
    {
    if(j>0)
    pb[i][j]=pb[i-1][j]*(1.0-p[i-1])+pb[i-1][j-1]*p[i-1];
    else
    pb[i][j]=pb[i-1][j]*(1.0-p[i-1]);    
    }
    }
    double ans=0.00;
    int j=(n+1)/2;
    while(j<=n)
    {
    ans+=pb[n][j];
    j++;
    }
    cout<<fixed<<setprecision(12)<<ans;
    return 0;
}

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

int dp[101]={};
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int count=0;
  for(int i=0;i<=100;i++) {
    if(i==a) {
      dp[i]++;
    }
    if(i==c) {
      dp[i]++;
    }
    if(i==b) {
      dp[i]--;
    }
    if(i==d) {
      dp[i]--;
    }
    dp[i+1] = dp[i];
    if(dp[i+1]==2)
      count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

typedef long long LL;

int main()
{
	LL a,b;
	scanf("%lld %lld",&a,&b);
        LL n=2;
        LL ans=0;
        while(a<=b){
    	a=a*n;
    	ans++;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256
import math
n = int(input())
s = int(input())

def c(b):
    cur = n
    acc = 0
    while cur != 0:
        div, mod = divmod(cur, b)
        acc += mod
        cur = div
    return acc

def g(b):
    if b > n: return n
    return sum(divmod(n,b))

def f():
    if n == s:
        return (n + 1)
    if n < s:
        return -1
    rt = math.ceil(math.sqrt(n))
    for b in range(2, rt + 1):
        if c(b) == s: return b
    for p in range(rt - 1, 0, -1):
        q = s - p
        x = n - q
        b = x // p
        if g(b) == s:
            return b
    return -1
    
print(f())

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;
const int mod = 1e9+7;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int b_count = 0 ;
	ll ans = 0 ;
	rep(i,s.size()){
		if(s[i] =='B'){
			b_count ++ ;
		} else {
			ans += b_count;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;cin>>W>>H;
  for(int i=0; i<H+2; i++)cout<<"#";
  cout<<endl;
  for(int i=0; i<W; i++){
    cout<<"#";
    string s;cin>>s;
    cout<<s;
    cout<<"#"<<endl;
  }
  for(int i=0; i<H+2; i++)cout<<"#";
  cout<<endl;
}

Measured memory_bytes: 256