akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k,a,b;
    vector<ll> x,y;
    vector<P> p;
    cin >> n >> k;
    rep(i,n){
        cin >> a >> b;
        x.push_back(a);
        y.push_back(b);
        p.push_back(P(a,b));
    }
    SORT(x);
    SORT(y);
    ll ans = INF*5;
    rep(i,n-1){
        rep(j,i+1,n){
            rep(s,n-1){
                rep(t,s+1,n){
                    ll c = 0;
                    rep(u,n){
                        tie(a,b) = p[u];
                        if (x[i] <= a && a <= x[j] && y[s] <= b && b <= y[t]) c++;
                    }
                    if (c >= k) chmin(ans,(x[j]-x[i])*(y[t]-y[s]));
                }
            }
        }
    }
    PRINT(ans);
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/03/03  Problem: code-festival-2016-qual-b_c / Link: https://code-festival-2016-qualb.contest.atcoder.jp/tasks/codefestival_2016_qualB_c?lang=en  ----- */
/* ------問題------

xy平面上の0≦x≦W,0≦y≦Hをみたす領域にあるx,yともに整数である点すべてに、ひとつずつ家があります。
x座標が等しくy座標の差が1であるか、y座標が等しくx座標の差が1であるような2点の組のうち、両方の点に家が存在するような全てのものに対し、その2点の間には舗装されていない道路があります。
座標(i,j)と(i+1,j)にある家の間の道路を舗装するのにはjの値にかかわらずコストがpi、 座標(i,j)と(i,j+1)にある家の間の道路を舗装するのにはiの値にかかわらずコストがqjかかります。
高橋君は、このうちいくつかの道路を舗装し、舗装された道路のみを通って任意の2つの家の間を行き来できるようにしたいです。 かかるコストの総和の最小値を求めてください。

-----問題ここまで----- */
/* -----解説等-----

辺の値はsortしても問題ない。
小さいものをたくさん使ってみても問題は無いので貪欲でやる。
縦に辺を置くときは置いた後に横の辺は一つだけ使わなくてもよい、
横に辺を置くときは置いた後にたっての辺は一つだけ使わなくても良い
ことがわかるのでこれをかく

----解説ここまで---- */

LL W, H;

LL ans = 0LL;

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

	cin >> W >> H;
	vector<PLL> a;
	FOR(i, 0, W) {
		int v; cin >> v;
		a.push_back(PLL(v, 0));
	}
	FOR(i, 0, H) {
		int v; cin >> v;
		a.push_back(PLL(v, 1));
	}

	SORT(a);
	H++, W++;

	FOR(i, 0, SZ(a)) {
		if (a[i].second == 0) {
			ans += H*a[i].first;
			W--;
		}
		else {
			ans += W*a[i].first;
			H--;
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 6512
import java.io.*
import java.util.*

fun main(args: Array<String>) {
    val inputStream = System.`in`
    val outputStream = System.out
    val inp = Main.InputReader(inputStream)
    val out = PrintWriter(outputStream)
    val solver = Main.TaskB()
    solver.solve(inp, out)
    out.close()
}

class Main {
    internal class TaskB {
        fun solve(inp: InputReader, out: PrintWriter) {
            val s = inp.next()
            val len = s.length
            for (i in 1..len)
                out.print("x")
        }
    }

    internal class InputReader(stream: InputStream) {
        private var reader: BufferedReader = BufferedReader(InputStreamReader(stream), 32768)
        private var tokenizer: StringTokenizer? = null

        init {
            tokenizer = null
        }

        operator fun next(): String {
            while (tokenizer == null || !tokenizer!!.hasMoreTokens()) {
                try {
                    tokenizer = StringTokenizer(reader.readLine())
                } catch (e: IOException) {
                    throw RuntimeException(e)
                }
            }
            return tokenizer!!.nextToken()
        }

        fun nextInt(): Int {
            return Integer.parseInt(next())
        }

        fun nextLong(): Long {
            return next().toLong()
        }
    }
}


Measured memory_bytes: 29608
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
s = gets.chomp
size = s.size
dp = Array.new(13, 0)
dp[0] = 1

s.size.times do |i|
  dp2= Array.new(13, 0)
  if s[i] != '?'
    si = s[i].to_i
    13.times do |j|
      dp2[(j*10 + si)%13] += dp[j] % MOD
    end
  else
    13.times do |j|
      dpj = dp[j]
      10.times do |k|
        dp2[(j*10 + k)%13] += dpj
      end
    end
    13.times do |j|
      dp2[j] %= MOD #=
    end
  end
  dp=dp2
#  p "----"; dp.each{|line| p line}
end

puts dp[5] % MOD

Measured memory_bytes: 3068
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int mVal = N;
		int sN = 0;
		while (mVal != 0) {
			sN += mVal % 10;
			mVal = mVal / 10;
		}
		if (N % sN == 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
N,Q=map(int,input().split())
C=[[] for _ in range(N+1)]
V=set([])
R=[0]*(N+1)
for i in range(N-1):
  a,b=map(int,input().split())
  C[a].append(b)
  C[b].append(a)
for i in range(Q):
  a,b=map(int,input().split())
  R[a]+=b

from collections import deque
q = deque([])
q.append(1)
while len(q) > 0:
  p = q.popleft()
  for i in C[p]:
    if not i in V:
      R[i]+=R[p]
      q.append(i)
  V.add(p)
print(*R[1:])

Measured memory_bytes: 64280
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>

int find_max(int a[], int size)
{
    int max = -999999;
    for (int i = 0; i < size; ++i) {
        if (max < a[i]) {
            max = a[i];
        }
    }

    return max;
}

int find_min(int a[], int size)
{
    int min = 999999;
    for (int i = 0; i < size; ++i) {
        if (a[i] < min) {
            min = a[i];
        }
    }

    return min;
}

int main()
{
    int N, M, X, Y;
    std::cin >> N >> M >> X >> Y;

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

    int y[M];
    for (int i = 0; i < M; ++i) {
        std::cin >> y[i];
    }

    int x_max = find_max(x, N);
    int y_min = find_min(y, M);
    for (int z = X + 1; z <= Y; ++z) {
        if (x_max < z && z <= y_min) {
            std::cout << "No War" << std::endl;
            return 0;
        }
    }

    std::cout << "War" << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define REP(i,j,n) for(int i=j ; i<n ; i++)
#define RREP(i,n,j) for(int i=n ; i>=j ; i--)
#define ppb pop_back()

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int ac=0,wa=0,tle=0,re=0;
	int q;cin>>q;
	while(q--)
	{
		string s;cin>>s;
		if(s=="AC") ac++;
		else if(s=="TLE") tle++;
		else if(s=="WA") wa++;
		else if(s=="RE") re++;
	}
	cout<<"AC x "<<ac<<endl;
	cout<<"WA x "<<wa<<endl;
	cout<<"TLE x "<<tle<<endl;
	cout<<"RE x "<<re;


	return 0;

}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length(),ans=1e9+7;
  for(ll i=0;i+2<l;++i) {
    ll val=stoll(s.substr(i,3));
    ans=min(ans,abs(val-753));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <ctime>

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

// defines
#define rep(i, N) for (i=0;i<(N);i++)
#define sqr(x) (x) * (x)
#define all(v) (v.begin(), v.end())
#define pb push_back
#define random (rand() << 16 ^ rand())

// Typedefs
typedef pair<int, int> ii;

// constants
const int64_t inf = 1e18+7;
const int64_t mod = 1e9+7;


int main() {
	int A, B;
	cin >> A >> B;

	if (A>8 || B > 8) {
		cout << ":(" << endl;
	} else {
		cout << "Yay!" << endl;

	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		int total = 1;
		sc.close();

		while (true) {
			if(total >= b){
				break;
			}
			total--;
			total += a;
			count++;
		}
System.out.println(count);
	}
}

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

int main(void) {
	int n = 0;
	cin >> n;
	vector<int> l(n);
	for (int i = 0; i < n; i++)cin >> l[i];
	int cnt = 0;
	for (int x = 0; x < n; x++) {
		for (int y = x; y < n; y++) {
			if (l[x] != l[y]) {
				for (int z = y; z < n; z++) {
					if ((l[x] != l[z]) && (l[y] != l[z])) {
						if ((l[x] < l[y] + l[z]) && (l[y] < l[x] + l[z]) && (l[z] < l[x] + l[y]))cnt++;
					}
				}
			}
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i ++)
using ll = long long;
const ll INF = 1ll<<55;
int N, K;
int H[100001];
ll dp[100001];

int main() {
    cin >> N >> K;
    rep(i, N) cin >> H[i];
    dp[0] = 0;
    for (int i = 1; i < N; i ++) {
        dp[i] = INF;
        for (int j = max(0, i - K); j < i; j ++) {
            dp[i] = min(dp[i], dp[j] + abs(H[i] - H[j]));
        }
    }
    cout << dp[N - 1] << endl;
    return 0;
}

Measured memory_bytes: 4776
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int main () {
int A , B , K ; cin >> A >> B >> K ;
for ( int i = min (A , B ); i >= 1; --i ) {
if ( A % i == 0 && B % i == 0) {
--K ;
if ( K == 0) {
cout << i << endl ;
return 0;
}
}
}
//assert ( false );
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
 
 
 
class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
 
    Scanner cin;
 
    List<Tuple<int, int>>[] es;
 
    void calc()
    {
        cin = new Scanner();
        int sx = cin.nextInt();
        int sy = cin.nextInt();
        int gx = cin.nextInt();
        int gy = cin.nextInt();
 
        int dx = gx - sx;
        int dy = gy - sy;
 
        string s = "";
        s += new string('R', dx);
        s += new string('U', dy);
        s += new string('L', dx);
        s += new string('D', dy);
 
        s += new string('D', 1);
        s += new string('R', dx + 1);
        s += new string('U', dy + 1);
        s += new string('L', 1);
 
        s += new string('U', 1);
        s += new string('L', dx + 1);
        s += new string('D', dy + 1);
        s += new string('R', 1);
 
        Console.WriteLine(s);
    }
}
 
 
class Scanner
{
    string[] s;
    int i;
 
    char[] cs = new char[] { ' '};
 
    public Scanner()
    {
        s = new string[0];
        i = 0;
    }
 
    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }
 
    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }
 
    public long nextLong()
    {
        return long.Parse(next());
    }
 
    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }
 
    public double nextDouble()
    {
        return double.Parse(next());
    }
 
 
    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
 
ll knapsack( vector <ll> wt, vector<ll> val, ll n, ll W){
 
    ll dp[W+1]; 
    for(ll i=0;i<W+1;i++)
        dp[i]=0;
    
    for(ll i=0; i < n; i++)  
        for(ll j=W; j>=wt[i]; j--) 
            dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); // max of when current not included or when 
    // current is included
    
    return dp[W]; 
}
 
int main()
{
    vector <ll> wts;
    vector<ll> prices;
    ll N,W;
    cin >> N >> W;
    for(ll i=0; i<N; i++)
    {
        ll a,b;
        cin >> a >>b;
        prices.push_back(b);
        wts.push_back(a);
    }
    ll ans = knapsack(wts, prices, N, W);
    cout << ans ;
    return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define ll long long
const ll MAX=100050;
const ll modn=1e9+7;
using namespace std;

void slove(){
    int n;
    string a;
    cin>>n>>a;
    int ans1=0;
    int ans2=0;
    int l=-1,r=-1;
    for(int i=0;i<a.length();i++){
        if(a[i]=='W') {
            l = i;
            break;
        }
    }
    for(int i=a.length()-1;i>=0;i--){
        if(a[i]=='R'){
            r=i;
            break;
        }
    }
    if(l==-1||r==-1){
        cout<<"0\n";
        return;
    }
    while(l<r){
        ans1++;
        ans2++;
        l++;
        r--;
        while(a[l]=='R')
            l++;
        while(a[r]=='W')
            r--;
    }
    cout<<ans1<<endl;
}

int main() {
    int _;
    //scanf("%d",&_);
    _=1;
    while(_--) {
        slove();
    }
    return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<string>
#include<bits/stdc++.h>
using namespace std;
int main() 
{ 
int x,t;
cin>>x>>t;
if(x<=t)
cout<<"0";
else if(x>t)
{

int c=x-t;
cout<<c;
}
return 0;  
}

Measured memory_bytes: 3512
// Practice AtCoder
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut vs = vec![];
    let mut ans = 0;
    for i in 0 .. n {
        vs.push(get!());
        if i >= 2 {
            if vs[i-2] < vs[i-1] && vs[i-1] < vs[i] {
                ans += 1;
            }
            if vs[i-2] > vs[i-1] && vs[i-1] > vs[i] {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#include <set>

int main() {
    double X;
    std::cin >> X;

    long long A = 100;

    int ret = 0;
    while (A < X) {
        A = static_cast<long long>(A*1.01);
        ++ret;
    }

    std::cout << ret << std::endl;            
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

vector<ll> solve(ll a){
    ll tmp = a;
    vector<ll> b(21,0);
    ll i = 0;
    while(tmp>0){
        if(tmp&1){
            b[i] = 1;
        }else{
            b[i] = 0;
        }
        tmp/=2;
        i ++;
    }

    return b;
}

int main(){

    ll n; cin >> n;
    vector<ll> a(n+5);
    rep(i,n) cin >> a[i];

    ll right = 0;
    ll ans = 0;
    vector<ll> s(21,0);
    vector<ll> b(21);

    for(ll left = 0; left < n; left++){
        // cout << "left " << left << endl;
        bool ok = true;
        while(right < n && ok){
            b  = solve(a[right]);
            // cout << "right " << right<< endl;
            for(ll i = 0; i < 21; i++){
                if(s[i]+b[i] == 2){
                    ok = false;
                }
            }

            if(ok){
                for(ll i = 0; i < 21; i++){
                    s[i] += b[i];
                }
                right ++;
            }
        }

        if(right==left){
            right++;
        }else{
            ans += right - left - 1;
            b = solve(a[left]);
            for(ll i = 0; i < 21; i++){
                s[i] -= b[i];
            }
            // rep(i,21)cout << s[20-i];
            // cout << endl;

        }
        // cout << ans << endl;
    }
    // cout << ans << endl;

    cout << ans + n << endl;



    return 0;
}

Measured memory_bytes: 1792
/**
DufauX-XuafuD
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define reset(x) memset(x,-1,sizeof(x))
#define CheckBit(a,b) (a&(1ll<<b))
#define SetBit(a,b) a=(a|(1ll<<b))
#define UnSetBit(a,b) a=(a&(~(1ll<<b)))
#define maxx 10000006
#define PI 2*acos(0.0)
const long long INF = 2000000000000000000LL;	// 2e18
const int inf = 0x3f3f3f3f;	// 1061109567
const long double EPS = 1e-9;
//bitset<maxx/2>vis;
//bitset<maxx>pr;
//int mobi[maxx+10];
//vector<ll>prime;
//void sieve(){
//    ll x=maxx/2, y=sqrt(maxx)/2;
//    for(ll i=1;i<=y;i++){
//        if(vis[i]==0){
//            for(ll j=(i*(i+1)*2);j<x;j+=(2*i)+1)
//                vis[j]=1;
//        }
//    }
//    prime.push_back(2);
//    for(ll i=3;i<maxx;i+=2)
//        if(vis[i/2]==0)
//        prime.push_back(i);
//}
//void generate_mobius()
//{
//    for(int i=0;i<maxx;i++)mobi[i]=1;
//    for(int i=2;i<maxx;i++){
//        if(!pr[i]){
//            mobi[i]*=-1;
//            for(int j=i+i;j<maxx;j+=i){
//                pr[j]=1;
//                mobi[j]*=(j%(i*i)?-1:0);
//            }
//        }
//    }
//}
//bool isprime(ll a)
//{
//    if(a==1)return false;
//    if(a==2)return true;
//    if(a%2==0)return false;
//    for(ll i=0;i<prime.size() && prime[i]*prime[i]<=a;i++)
//        if(a%prime[i]==0)return false;
//    return true;
//}
/*Used path compression technique*/
/*-------------------------------------*/
//ll finds(ll a)
//{
//    vector<ll>vec;
//    while(parent[a]>0){
//        vec.pb(a);
//        a=parent[a];
//    }
//    for(int i=0;i<vec.size();i++)parent[vec[i]]=a;
//    return a;
//}
//void unions(ll a,ll b)
//{
//    parent[a]+=parent[b];
//    parent[b]=a;
//}
/*------------------------------*/
/* Calculate ( a*b ) %c */
inline ll mulmod(ll a, ll b, ll c) {
    ll ret = 0 , cur = a % c ;
    while(b) { if(b%2) ret=(ret+cur)%c; cur=(cur<<1)%c; b=b>>1; }
    return ret%c;
}
//Calculate (b^p)%m || modular inverse: b^-1 = bigmod(b, m-2, m)
inline ll bigmod(ll b, ll p, ll m){
    ll ret = 1, cur = b % m;
    while(p) { if(p&1) ret=(ret*cur)%m; cur=(cur*cur)%m; p=p>>1; }
    return ret;
}
inline ll modulo(ll a,ll b,ll c) { //Same as big mod, use for numbers over 1e10
    ll ret = 1 , cur = a%c ;
    while(b) { if(b%2) ret=mulmod(ret,cur,c); cur=mulmod(cur,cur,c); b=b>>1; }
    return ret%c ;
}
inline ll power(ll b, ll p){
    ll ret = 1, cur = b;
    while(p) { if(p&1) ret=(ret*cur); cur=(cur*cur); p=p>>1; }
    return ret;
}
ll lcm(ll a,ll b)
{
    return (a/__gcd(a,b))*b;
}
ll gcd(ll a,ll b)
{
    return __gcd(a,b);
}
void Dufaux()
{
    ll m,n;
    cin>>m>>n;
    cout<<(m-1)*(n-1)<<endl;
}
int main()
{
    FastIO;
	///sieve();
	///generate_mobius();
	int test=1;
	while(test--){
        Dufaux();
	}
	return 0;
}





Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long a;
long long N;
cin>>N;
long long upper,lower,mid;
long long colors[N+100];
long long num_color=1;
cin>>a;
colors[0]=a;
for(long long j=1;j<N;++j){
  cin>>a;
  if(colors[num_color-1]>=a){
    colors[num_color]=a;
    num_color+=1;
    continue;
  }
  //upperはダメなとこギリギリ
  if(colors[0]<a){
    colors[0]=a;
    continue;
  }
  upper=0;
  //lowerは絶対いけるところ
  lower=(num_color-1);
  while(upper+1<lower){
    mid=(upper+lower)/2;
    //midが条件を満たさない場合
    if(colors[mid]>=a){
      upper=mid;
    }
    else{
      lower=mid;
    }
  }
  colors[lower]=a;
}
cout<<num_color<<"\n";
return 0;
}

Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n;
  ll cnt = 0;
  
  rep(i,n){
    ll x; cin >> x;
    if((i % 2) == 0 and (x % 2) == 1) cnt++;
  }
  
  cout << cnt << endl;
  
  
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n,x;
    ll ans = 0;
    cin >> n >> x;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    if(a[0] > x){
        ans += (a[0]-x);
        a[0] = x;
    }
    for (int i = 0; i < n-1; ++i) {
        if(a[i]+a[i+1] > x){
            ll herasu;
            herasu = a[i]+a[i+1]-x;
            ans += herasu;
            a[i+1] -= herasu;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

const int N = 1e5 + 5, mod = 1e9 + 7;

int a[N];
long long fac[N], inv[N];
long long powmod(long long b, long long p) {
  long long r = 1;
  for (; p; p >>= 1, b = b * b % mod)
    if (p & 1)
      r = r * b % mod;
  return r;
}

long long C(int n, int k) {
  if (k < 0 || n < k || n < 0)
    return 0;
  return (fac[n] * inv[k] % mod) * inv[n-k] % mod;
}
long long s[N];

int main() {
  fac[0] = 1;
  for (int i = 1; i < N; ++i)
    fac[i] = 1LL * fac[i-1] * i % mod;
  inv[N-1] = powmod(fac[N-1], mod-2);
  for (int i = N-2; i >= 0; --i)
    inv[i] = inv[i+1] * (i+1) % mod;
  int n;
  scanf("%d", &n);
  s[0] = 0;
  for (int i = 1; i < n; ++i) {
    long long now = (fac[i] * fac[n-i-1] % mod) * C(n, i+1) % mod;
    s[i] = (s[i-1] + now) % mod;
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    long long cnt = (fac[n] + s[i] + s[n-1-i]) % mod;
    scanf("%d", a+i);
    ans = (ans + cnt * a[i]) % mod;
  }
  ans %= mod;
  if (ans < 0) ans += mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 2944
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const int MAXN=1e3 + 5;
ll h,n,i,j,a[MAXN],b[MAXN];
void solve()
{
	cin>>h>>n;
	vll dp(h+1,1e9);
	dp[0]=0;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i];
		for(j=0;j<h;j++)
		{
			dp[min(j+a[i],h)]=min(dp[min(j+a[i],h)],dp[j]+b[i]);
		}
	}
	cout<<dp[h];
}
int main()
{
	fast();
	ll t;
	t=1;
	while(t--)
		solve();
}

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

#define FOR(i,l,r) for(int i = (int) (l);i < (int) (r);i++)
#define ALL(x) x.begin(),x.end()
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> edge [100001];
int dp [100001];

int dfs(int curr,int prev)
{
	int res = 0;
	vector<int> v;
	bool leaf = true;
	for(const auto& it : edge [curr]) if(it != prev){
		chmax(res,dfs(it,curr));
		v.push_back(dp [it]);
		leaf = false;
	}
	if(leaf) v.push_back(0);
	sort(v.rbegin(),v.rend());
	if(v.size() >= 2){
		chmax(res,v [0] + v [1] + (edge [curr].size() == 2));
		dp [curr] = v [0] + (edge [curr].size() == 2);
	}
	else if(v.size() == 1){
		chmax(res,v [0] + (edge [curr].size() == 2));
		dp [curr] = v [0] + (edge [curr].size() == 2);
	}
	return res;
}

int main()
{
	scanf("%d",&N);
	FOR(i,0,N - 1){
		int u,v;
		scanf("%d%d",&u,&v);
		edge [u].push_back(v);
		edge [v].push_back(u);
	}
	int ans = 0;
	FOR(i,1,N + 1){
		ans += edge [i].size() == 1;
	}
	ans += dfs(1,-1);

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

	return 0;
}


Measured memory_bytes: 6272
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int N, x, i, j, sum, ans;
	scanf("%lld%lld", &N, &x);
	int **a = (int **)malloc(sizeof(int *) * N);
	for(i = 0; i < N; i++){
		a[i] = (int *)malloc(sizeof(int) * N);
		scanf("%lld", &a[i][0]);
	}
	for(i = 0; i < N; i++){
		for(j = 1; j < N; j++){
			a[i][j] = min(a[i][j - 1], a[(i - j + N) % N][0]);
		}
	}
	for(j = 0, ans = inf; j < N; j++){
		for(i = 0, sum = x * j; i < N; i++){
			sum += a[i][j];
		}
		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31488
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define ii pair<int, int>
#define vi vector<int>
#define vii vector<pair<int, int>>
#define vvi vector<vector<int>>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define forr(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int main() {
  io();
  
  string al, bl, cl;
  queue<char> a, b, c;
  cin >> al >> bl >> cl;
  fori(i, al.size()) {
    a.push(al[i]);
  }
  fori(i, bl.size()) {
    b.push(bl[i]);
  }
  fori(i, cl.size()) {
    c.push(cl[i]);
  }
  
  char card = a.front();
  a.pop();
  
  while(true) {
    if(card == 'a') {
      if(a.empty()) {
        cout << "A";
        break;
      }
      card = a.front();
      a.pop();
    } elif(card == 'b') {
      if(b.empty()) {
        cout << "B";
        break;
      }
      card = b.front();
      b.pop();
    } else {
      if(c.empty()) {
        cout << "C";
        break;
      }
      card = c.front();
      c.pop();
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int num[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
bool uru(int checkyear){if(checkyear%4==0){if(checkyear%100!=0||checkyear%400==0)return true;}return false;}
int gcd( int x, int y ){return y ? gcd(y, x%y) : x;}
bool pairCompare(const pairint& firstElof, const pairint& secondElof)
{
  if(firstElof.second!= secondElof.second)    return firstElof.second> secondElof.second;
  else return firstElof.first< secondElof.first;
}
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
if(x%500>y)std::cout << "No" << '\n';
else std::cout << "Yes" << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s1 = scanner.next();
		String s2 = scanner.next();

		if (s1.charAt(0) == s2.charAt(2) && s1.charAt(1) == s2.charAt(1) && s1.charAt(2) == s2.charAt(0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23124
N, M = map(int, input().split())
reqs = []
ans = 0
B = 0
for _ in range(M):
    a, b = map(int, input().split())
    reqs.append((a, b))
reqs = sorted(reqs, key=lambda x: x[1])
for i in range(M):
    a, b = reqs[i]
    if a >= B:
        B = b
        ans += 1
print(ans)

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

using llint = long long int;

template<typename T>
void dump(const T& arr){
  std::cout << "[";
  for(const auto& elem: arr){
    std::cout << elem << ", ";
  }
  std::cout << "]" << std::endl;
}

llint sum(const std::vector<llint> &arr, int st, int ed){
  llint ret = 0;
  for(int i=st; i<ed; i++){
    ret += arr[i];
  }
  return ret;
}

void solve(void){
  llint N, X, M;
  std::cin >> N >> X >> M;
  
  std::map<llint, int> visited;
  std::vector<llint> history;
  llint result = 0;
  for(int i=0; i<N; i++){
    if(visited.find(X) != visited.end()){
      llint nokori = N - i;
      int len_loop = i - visited[X];
      llint n_loop = nokori / len_loop;
      llint loop_amari = nokori % len_loop;
      llint sum_loop = sum(history, visited[X], i);
      result += sum_loop * n_loop + sum(history, visited[X], visited[X]+loop_amari);
      break;
    }

    // else
    visited[X] = history.size();
    history.push_back(X);
    result += X;
    
    X = (X*X)%M;
  }
  
  std::cout << result << std::endl;
  return;

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





Measured memory_bytes: 6764
#include<stdio.h>
#include<string.h>
int main()
{
    char a[100],b[100];
    int i,n;
    scanf("%s",a);
    scanf("%s",b);
    if(strcmp(a,b)>0)
    {
        n=a[0]-'0';
        for(i=1; i<=n; i++)
        {
            printf("%s",b);
        }
    }
    else if(strcmp(a,b)<0)
    {
        n=b[0]-'0';
        for(i=1; i<=n; i++)
        {
            printf("%s",a);
        }
    }
    else
    {
        n=b[0]-'0';
        for(i=1; i<=n; i++)
        {
            printf("%s",a);
        }
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

int main()
{
    int n;
    cin >> n;
    ll a[200003], b[200003];
    P p[200003];
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        p[i] = P(b[i], a[i]);
    }
    sort(p, p + n);
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += p[i].second;
        if(sum > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 mod=1e9+7;
const int INF=1001001001;

int main() {
  int64_t N,M;
  cin>>N>>M;
  int MAX=0;
  for(int i=1;i*i<=M;i++){
    if(M%i==0){
      int r=M/i;
      if(i*N<=M){chmax(MAX,i);}
      if(r*N<=M){chmax(MAX,r);}
    }
  }
  cout<<MAX<<endl;
  return 0;  
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define forn(i,n) for(ll i=0;i<ll(n);++i)
#define all(x) (x).begin(),(x).end()

int main() {
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    set<string> S;
    ll n = s.size();
    forn(i, n) {
        for (ll j = i; j < n; ++j) {
            string t = s.substr(i, j-i+1);
            if ((ll)S.size() < k || t < *S.rbegin()) {
                S.insert(t);
            }
            else break;
            while ((ll)S.size() > k) {
                S.erase(prev(S.end()));
            }
        }
    }
    cout << *S.rbegin() << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
int memo[1000000];
using namespace std;

int next(int a,int keta){
  int tbl[6]={};
  int p = 0;
  while(a){
    tbl[p++] = a%10;
    a/=10;
  }
  int Max = 0, Min = 0;
  sort(tbl,tbl+keta);
  int pow10 = 1;
  for(int i=0;i<keta;++i){
    Max+=pow10*tbl[i];
    Min+=pow10*tbl[keta-1-i];
    pow10*=10;
  }
  return Max-Min;
}


int main(){
  int a,keta;
  while(cin>>a>>keta,a||keta){
    memset(memo,-1,sizeof(memo));
    int i = 0;
    while(true){
      if(memo[a]!=-1){
	break;
      }
      memo[a] = i;
      i++;
      a = next(a,keta);
    }
    cout << memo[a] << " " << a << " " << i-memo[a] << endl;
  }
  return 0;
}

Measured memory_bytes: 5088
#include <algorithm>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;

#define rep(i, n) repi(i, 0, n)
#define rep1(i, n) repi(i, 1, n + 1)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)

typedef long long ll;

int main()
{
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    string s;
    while(getline(cin, s)) {
        if(s==".") break;

        int flg = 1;
        stack<char> st;
        for(int i=0; i<s.size(); ++i) {
            if(s[i]=='(') st.push(s[i]);
            else if(s[i]=='[') st.push(s[i]);
            else if(s[i]==')') {
                if(!st.empty()&&st.top()=='(') st.pop();
                else {
                    flg = 0;
                    break;
                }
            }
            else if(s[i]==']') {
                if(!st.empty()&&st.top()=='[') st.pop();
                else {
                    flg = 0;
                    break;
                }
            }
        }
        if(!st.empty()) flg = 0;
        if(flg==1) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#include<stdio.h>
int main(){
    while(1){
    int H,W,i,j;
    scanf("%d%d",&H,&W);
        if(H==0&&W==0)
        break;
        for(i=0;i<H;i++)
        {
            for(j=0;j<W;j++)
            {
                printf("#");
             }
            printf("\n");
        }
        printf("\n");
         
         
    }
return 0;
}



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

int main()
{
	ll H, W;
	cin >> H >> W;
	vector<vector<char>> S(H,vector<char>(W));
	for(ll i = 0; i < H; i++)
		for(ll j = 0; j < W; j++)
			cin >> S[i][j];

	vector<vector<ll>> L(H,vector<ll>(W,0));
	for(ll i = 0; i < H; i++) if(S[i][0]=='.') L[i][0] = 1;
	for(ll i = 0; i < H; i++)
		for(ll j = 1; j < W; j++)
			if(S[i][j]=='.') L[i][j] = L[i][j-1]+1;
	vector<vector<ll>> R(H,vector<ll>(W,0));
	for(ll i = 0; i < H; i++) if(S[i][W-1]=='.') R[i][W-1] = 1;
	for(ll i = 0; i < H; i++)
		for(ll j = W-2; j >= 0; j--)
			if(S[i][j]=='.') R[i][j] = R[i][j+1]+1;
	vector<vector<ll>> D(H,vector<ll>(W,0));
	for(ll j = 0; j < W; j++) if(S[0][j]=='.') D[0][j] = 1;
	for(ll j = 0; j < W; j++)
		for(ll i = 1; i < H; i++)
			if(S[i][j]=='.') D[i][j] = D[i-1][j]+1;
	vector<vector<ll>> U(H,vector<ll>(W,0));
	for(ll j = 0; j < W; j++) if(S[H-1][j]=='.') U[H-1][j] = 1;
	for(ll j = 0; j < W; j++)
		for(ll i = H-2; i >= 0; i--)
			if(S[i][j]=='.') U[i][j] = U[i+1][j]+1;

	ll maxv = 0;
	for(ll i = 0; i < H; i++)
	{
		for(ll j = 0; j < W; j++)
		{
			ll tmp = L[i][j]+R[i][j]+D[i][j]+U[i][j]-3;
			maxv = max(maxv,tmp);
		}
	}

	cout << maxv << endl;
	return 0;
}


Measured memory_bytes: 129536
#include<bits/stdc++.h>
using namespace std;
const int MAX = 100005;
int h[MAX];
using ll = long long int;
ll dp[MAX];
int main() {
	int n,i;
	cin>>n;
	for(i=0;i<n;++i) {
		cin>>h[i];
	}
	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);
	for(i=2;i<n;++i) {
		dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <sstream>

int main() {
    std::stringstream ss;
    std::vector<int> a;
    int q;
    std::cin >> q;
    for (int i=0;i<q;++i) {
        int cmd, num;
        std::cin >> cmd;
        if (cmd == 0) {
            std::cin >> num;
            a.push_back(num);
        }
        if (cmd == 1) {
            std::cin >> num;
            ss << a[num] << std::endl;
        }
        if (cmd == 2) {
            a.pop_back();
        }
    }
    std::cout << ss.str();
    return 0;
}


Measured memory_bytes: 5412
/* ***********************************************
Author        :pkwv
Created Time  :2017年10月22日 星期日 20时17分56秒
File Name     :C.cc
************************************************ */

#include <algorithm>
#include <bitset>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	std::string s;
	while (std::cin >> s) {
		std::string s_x;
		for (const auto& c : s) {
			if (c != 'x') {
				s_x += c;
			}
		}
		bool ok{true};
		for (int i = 0; i < s_x.size(); ++ i) {
			if (s_x[i] != s_x[s_x.size() - 1 - i]) {
				ok = false;
			}
		}
		if (ok) {
			int res{0};
			for (int i = 0, j = s.size() - 1; i < j; ) {
				if (s[i] == s[j]) {
					++ i, -- j;
				} else if (s[i] == 'x') {
					++ i, ++ res;
				} else if (s[j] == 'x') {
					-- j, ++ res;
				}
			}
			std::cout << res << std::endl;
		} else {
			std::cout << -1 << std::endl;
		}
	}
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define adj_list vector<vi>
#define endl "\n"
#define INF_INT 2e9
#define INF_LL 2e18
#define matmax 25
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define pl pair<ll, ll>
#define pll pair<ll, pair<ll, ll> >
#define vi vector<int>
#define vl vector<ll>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
typedef long long int ll;

int lsone(int n)
{
	return (n&-n);
}

ll pow1(ll a, ll b)
{
	if (b == 0)
		return 1ll;
	else if (b == 1)
		return a;
	else
	{
		ll x = pow1(a, b/2);
		x *= x;
		x %= mod;
		if (b%2)
		{
			x *= a;
			x %= mod;
		}
		return x;
	}
}

int n, w, weights[110], val[110]; 
ll dp[110000];
int main()
{
	fastio;		
	cin>>n>>w;

	for (int i = 1; i <= n; i++)
	{
		cin>>weights[i]>>val[i];
	}
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;

	for (int i = 1; i <= n; i++)
	{
		for (int j = w-weights[i]; j >= 0; j--)
		{
			if (dp[j+weights[i]] == -1)
				dp[j+weights[i]] = dp[j]+val[i];
			else
				dp[j+weights[i]] = max(dp[j+weights[i]], dp[j]+val[i]);
		}
	}

	ll ans = 0;

	for (int i = 1; i <= w; i++)
		ans = max(ans, dp[i]);

	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long


int main(){

	int N;
	string w[101];

	cin >> N;

	for (int i = 0; i < N; i++){
		cin >> w[i];
		for (int j = 0; j < i; j++){
			if (w[i] == w[j]){
				cout << "No" << endl; return 0;
			}
		}
		if (i >= 1){
			if (w[i][0] != w[i - 1][w[i - 1].length()-1])
			{
				cout << "No" << endl; return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
import scala.math.sqrt

object Main extends App {

  val sc = new java.util.Scanner(System.in)
  val a = sc.next()
  val b = sc.next()
  val num = (a + b).toInt
  if(sqrt(num).toInt * sqrt(num).toInt == num) {
    println("Yes")
  } else {
    println("No" )
  }
}


Measured memory_bytes: 55244
# たくさんの数式 https://atcoder.jp/contests/arc061/tasks/arc061_a
S = input()
ans = 0
for i in range(1<<(len(S)-1)):
    chars = S[0]
    for j in range(len(S)-1):
        if ((i >> j) & 1) == 1:
            chars += '+' + S[j+1]
        else:
            chars += S[j+1]
    ans += eval(chars)
print(ans)

Measured memory_bytes: 3060