akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  char c[4];
  while(cin>>c[0]>>c[1]>>c[2]>>c[3]){
    if(c[0]=='0'&&c[1]=='0'&&c[2]=='0'&&c[3]=='0') break;
    int su[4];
    int mems[4];
    int count = 0;
    int d = 1000;
    int h=1;
    for(int i=0;i<4;i++) su[i] = c[i] - '0';
    while(su[0]!=6||su[1]!=1||su[2]!=7||su[3]!=4){
      if(su[0]==0&&su[1]==0&&su[2]==0&&su[3]==0){
	cout << "NA" << endl;
	h = 0;
	break;
      }
      sort(su,su+4);
      for(int i=0;i<4;i++) mems[i] = su[i];
      sort(su,su+4,greater<int>());
      for(int i=0;i<4;i++) su[i] -= mems[i];
	for(int i=4;i>=1;i--){
	  if(su[i]<0){
	    su[i-1] -= 1;
	    su[i] += 10;
	  }
	}
	count++;
      }
    if(h==1) cout << count << endl;
  }
  return 0;
}

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

int main() {
int n,a[100000],c;
long long b[100000];
cin>>n;
for(int i=0;i<n;i++){
    cin>>a[i];
}
sort(a,a+n);
b[0]=a[0];
for(int i=1;i<n;i++){
    b[i]=b[i-1]+a[i];
}
c=n;
for(int i=n-2;i>=0;i--){
    if(b[i]*2<a[i+1]){
        c=n-i-1;
        i=-1;
    }
}
cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());

        String ab = String.valueOf(a) + String.valueOf(b);
        int abInt = Integer.parseInt(ab);

        int[] intArray = {11, 22, 33, 44, 55, 66, 77, 88, 99, 1010, 1111, 1212};

        int count =0;

        for(int i: intArray){
            if(i <= abInt){
                count++;
            }
        }

        System.out.println(count);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

int main() {
  int n;
  float inf = std::numeric_limits<float>::infinity();
  long long min = inf;
  cin >> n;
  vector<long long>sum(n);
  for(int i = 0;i < n;i++){
    long long a;
    cin >> a;
    if(i == 0){
      sum[i] = a;
    }
    else{
      sum[i] = sum[i-1]+a;
    }
  }
  for(int i = 0;i < n-1;i++){
    long long x = sum[i],y = sum[n-1]-sum[i];
    long long sa = abs(x-y);
    if(min >= sa) min = sa;
  }
  cout << min << endl;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, A, B;
        cin >> N >> A >> B;
        Int k = N / (A + B);
        Int ans = k * A + min(N % (A + B), A);
        cout << ans << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> V(N);
    for(int i = 0; i < N; i++){std::cin >> V[i];}
    int ans = 0;
    for(int l = 0;l <= N;l++){
        for(int r = N; r >= l and (N-r+l)<=K; r--){
            std::priority_queue<int, std::vector<int>,std::greater<int>> Q;
            int sum=0;
            for(int i = 0; i < l; i++){Q.push(V[i]),sum+=V[i];}
            for(int i = N-1; i >= r; i--){Q.push(V[i]),sum+=V[i];}
            const int E = K-l-(N-r);
            for(int i = 0; i < E and not Q.empty(); i++){
                const int T = Q.top();
                Q.pop();
                if(T>0){break;}
                sum -= T;
            }
            ans = std::max(ans, sum);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  i64 sum = 0;
  reps(i, n) {
    if (i % 3 != 0 && i % 5 != 0) sum += i;
  }
  cout << sum << endl;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if ( a >= 13 ) {
        cout << b << endl;
    } else if ( a >= 6 && a <= 12 ) {
        cout << b/2 << endl;
    } else if ( a >= 0 && a <= 5 ){
        cout << 0 << endl;
    }
    return 0;
}


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

#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rep1(i,n) for(ll i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;

ll f(ll x) {
    int dig = 0;
    while(x > 0) {
        x /= 10;
        ++dig;
    }
    return dig;
}

int main() {
    ll n;
    cin >> n;
    int min = 1000;
    for(ll i = 1; i*i <= n;++i){
        if(n % i == 0) {
            ll a = f(i);
            ll b = f(n / i);
            if(min > max(a,b) ) min = max(a,b);
        }
    }
    cout << min  <<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ff first
#define ss second
#define END "\n"
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef vector<ii> vii;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////



int main()
{
    fast
    #ifdef ANUBHAB
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    string str;
    char c;
    deque<char> Q;
    int flag = 1;
    cin >> str;
    int n, f, t;
    cin >> n;
    for (int i = 0; i < str.size(); i++)
      Q.push_back(str[i]);
    while(n--)
    {
      cin >> t;
      if (t == 1)
        {
          flag *= -1;
          continue;
        }
      cin >> f >> c;
      if (f == 1)
      {
        if (flag == 1)
          Q.push_front(c);
        else Q.push_back(c);
      }
      else
      {
        if (flag == 1)
          Q.push_back(c);
        else Q.push_front(c);
      }
    }
    if (flag == 1)
    {
      for (int i = 0; i < Q.size(); i++)
        cout << Q[i];
    }
    else
    {
      for (int i = Q.size() - 1; i >= 0; i--)
        cout << Q[i];
    }
}

Measured memory_bytes: 976
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    # xの属する木の根を求める
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    # xとyの属する集合のマージ
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
 
        if x == y:
            return
 
        if self.parents[x] > self.parents[y]:
            x, y = y, x
 
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    # xの属する集合の大きさを返す
    def size(self, x):
        return -self.parents[self.find(x)]
    
    # xとyが同じ集合に属するかを判定
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    # xと同じグループを返す
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    # 根ノードを返す
    # 複数存在する時はその分だけ返す
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    
    # グループ数を返す
    def group_count(self):
        return len(self.roots())
    
    # groupとそれに属するメンバーの辞書を返す
    # exp. {0: [0, 1, 4], 2: [2, 3]}
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    # 上記メソッド参照
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())

union = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split())
    union.union(a-1, b-1)

ans = 0
for i in range(N):
    ans = max(ans, union.size(i))

print(ans)

Measured memory_bytes: 14588
#create date: 2020-08-06 09:16

import sys
stdin = sys.stdin
from bisect import bisect_left, bisect_right

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    a = na()
    b = na()
    c = na()
    a.sort()
    b.sort()
    c.sort()
    cnt = 0
    #print(a, b, c)
    for bi in b:
        i = bisect_left(a, bi)
        j = bisect_right(c, bi)
        cnt += i * (n-j)
        #print(bi, i, n-j)
    print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 28344
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll x;
    cin >> x;
    ll a = 100;
    ll answer = 0;
    while(a < x){
        answer++;
        double tmp = a * 1.01;
        a = (ll)floor(tmp);
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include<ctime>
#define ll long long
using namespace std;
const int maxn=3e5+5;
ll a[maxn],xsum[maxn],sum[maxn];
int main(){
	srand((unsigned)time(0));
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		xsum[i]=xsum[i-1]^a[i];
		sum[i]=sum[i-1]+a[i];
	}
	
	
	ll l=1,r=1,sum=a[1],ans=0;
	while (r<=n){
		while (r<n&&(sum^a[r+1])==(sum+a[r+1]) ) r++,sum+=a[r];
		ll len=r-l+1;
		ans+=len*(len+1)/2;
		r++;
		if (r>n) break;
		while (l<=r && (sum^a[r])!=(sum+a[r])) sum-=a[l],l++;
		sum+=a[r];
		if (l<r){
			len=r-l;
			ans-=len*(len+1)/2;
		}
	}
	
	cout<<ans<<endl;
	
}

Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

const ll MAX_SIZE = 200005;
array<ll, MAX_SIZE> fac, inv, finv;
void fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % MOD;
    finv[0] = modpow(fac[MAX_SIZE - 1], MOD - 2, MOD);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % MOD;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, MOD - 2, MOD);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % MOD; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % MOD * finv[a - b] % MOD; }
//--------------------------------------------------------------------------------//

ll N;
vvc<ll> G(MAX_SIZE);
ll dp[MAX_SIZE], ans[MAX_SIZE], T[MAX_SIZE];

void dfs1(ll now, ll parent){
    ll nowsize = 1, tmpv = 1;
    for(auto& to: G[now]){
        if (parent == to) continue;
        
        dfs1(to, now);
        
        nowsize += T[to];

        (tmpv *= finv[T[to]] * dp[to] % MOD) %= MOD;
    }

    dp[now] = (fac[nowsize - 1] * tmpv) % MOD;
    T[now] = nowsize;
    return;
}

void dfs2(ll now, ll parent, ll pdiv){
    ll nowsize = T[now], tmpv = pdiv;

    if (parent != -1) (tmpv *= inv[N-T[now]] * finv[T[now]-1] % MOD) %= MOD;

    ans[now] = tmpv;

    for(auto& to: G[now]){
        if(to!=parent){
            dfs2(to, now, ans[now] * fac[T[to]] % MOD);
        }
    }

    return;
}

int main() {
    init(), fac_init();

    cin >> N;
    rep(i,N-1){
        ll a, b;
        cin >> a >> b;
        a--, b--;
        G[a].eb(b), G[b].eb(a);
    }

    dfs1(0, -1);
    dfs2(0, -1, dp[0]);

    rep(i,N) cout << ans[i] << "\n";

}

Measured memory_bytes: 24048
n,k,q = map(int, input().split( ))
a = []
for _ in range(q):
    inp = int(input())
    a.append(inp)

Q = [0]*(n+1)

for i in a:
    Q[i] += 1

for i in range(1,n+1):
    if k-q+Q[i]>0:
        print("Yes")
    else:
        print("No")


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

int main() {
	int N, Odd[8] = { 6, 2, 10, 3, 9, 4, 8, 12 }, Even[8] = { 2, 10, 3, 9, 4, 8, 6, 12 };
	cin >> N;
	if (N == 3) {
		cout << "2 5 63\n";
		return 0;
	}
	if (N % 2 == 0) {
		for (int i = 0; i < N; i++) {
			if (i != 0) cout << " ";
			cout << Even[i % 8];
			Even[i % 8] += 12;
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			if (i != 0) cout << " ";
			cout << Odd[i % 8];
			Odd[i % 8] += 12;
		}
	}
	cout << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>   
#include <unordered_map>    

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

ll h,w,d;
vector<ll> dis;
vector<pair<ll,ll>> a;
ll q;


int main(){
   
    cin >> h >> w >> d;
    
    a.resize(w*h+10);
    dis.resize(w*h+10);
    
    rep(i,0,h)rep(j,0,w){
        ll b;
        cin >> b;
        a[b] = make_pair(i,j);
    }

    rep(i,d,w*h+1){
        dis[i] = dis[i-d] + abs(a[i].ft - a[i-d].ft) + abs(a[i].sd - a[i-d].sd);
       // cout << i << " " << dis[i] << endl;;
    }
    cin >> q;
   
    rep(i,0,q){
        ll l,r;
        cin >> l >> r;

        P(dis[r] -dis[l]);
    }

	return  0;
}

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

#define rep(i,j,n) for(i=j;i<n;i++)
#define repi(i,j,n) for(i=j;i>n;i--)
#define inf 1e18
#define M 1000000007
#define pie 3.141592653589793238
#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define UQ(x) (x).resize(distance((x).begin(),unique(x.begin(),x.end())))

using namespace std;

mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rnd64(chrono::high_resolution_clock::now().time_since_epoch().count());

ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2) ans*=a, ans%=(mod);
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}


void init(ll* a,ll n,ll val){
	for(ll i=0;i<n;i++)
		a[i]=val;
}

void solve(){
	ll i,j,_;
	ll x;
	cin >> x;
	cout << (!x) << endl;
}

int main()
{
	ios::sync_with_stdio(0);
 	cin.tie(0);
	ll T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}




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


int32_t main(){
      
    int n;  cin >> n;
    if(n % 2) return cout << 0 , 0;

    int ans = 0;

    for(int i = 10; i <= n; i *= 5){
          ans += n / i;
    }
    
    cout << ans << endl;

     return 0;
}

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

using namespace std;
//#define getchar getchar_unlocked

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0'|| ch>'9')ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<pr> vec;
#define x first
#define y second
const int N=131100;

int n,fa[N];
vec g[N],f[N];
ll mid,mv[N];

inline bool cmpx(pr a,pr b){return a.x<b.x;}
inline bool cmpy(pr a,pr b){return a.y<b.y;}

inline void work(vec &ls,vec &rs,vec &f)
{
	if(ls.size()>rs.size())swap(ls,rs);
	int el=ls.size(),er=rs.size();
	
	sort(ls.begin(),ls.end(),cmpy);
	sort(rs.begin(),rs.end(),cmpx);

	mv[0]=rs[0].y;
	for(int i=1;i<er;i++)
		mv[i]=min(mv[i-1],rs[i].y);

	for(int i=0,j=er-1;i<el;i++)
	{
		while(j>=0 && ls[i].y+rs[j].x>mid)j--;
		if(j>=0)f.push_back(pr(ls[i].x,mv[j]));
	}

	sort(ls.begin(),ls.end(),cmpx);
	sort(rs.begin(),rs.end(),cmpy);
	mv[0]=rs[0].x;
	for(int i=1;i<er;i++)
		mv[i]=min(mv[i-1],rs[i].x);

	for(int i=0,j=er-1;i<el;i++)
	{
		while(j>=0 && ls[i].x+rs[j].y>mid)j--;
		if(j>=0)f.push_back(pr(mv[j],ls[i].y));
	}
}

inline void dfs(int u)
{
	if(!f[u].empty())f[u].clear();
	if(g[u].empty())
	{
		f[u].push_back(pr(0,0));
		return;
	}

	for(int i=0,e=g[u].size();i<e;i++)
		dfs(g[u][i].x);

	vec &ls=f[g[u][0].x];
	for(int i=0,e=ls.size(),c=g[u][0].y;i<e;i++)
		ls[i].x+=c,ls[i].y+=c;
	vec &rs=f[g[u][1].x];
	for(int i=0,e=rs.size(),c=g[u][1].y;i<e;i++)
		rs[i].x+=c,rs[i].y+=c;
	
	work(ls,rs,f[u]);
	ls.clear();
	rs.clear();
}

int main()
{
	if(fopen("vj.in","r"))
	{
		freopen("vj.in","r",stdin);
		freopen("vj.out","w",stdout);
	}

	n=read();
	for(int i=2,a;i<=n;i++)
	{
		fa[i]=read();
		g[fa[i]].push_back(pr(i,read()));
	}
		
	ll l=0,r=1e10,ans=1e10;
	while(l<=r)
	{
		mid=l+r>>1;
		dfs(1);
		if(f[1].empty())
			l=mid+1;
		else
			r=mid-1,ans=mid;
	}
	
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 30328
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <complex>
#include <math.h>
#include <assert.h>

using namespace std;
typedef complex<double> Complex;

static const double E = 0.000001;

inline bool collide_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2) {
  assert(r1 >= 0.0 && r2 >= 0.0);
  Complex dif = p1 - p2;
  return dif.real() * dif.real() + dif.imag() * dif.imag() <= (r1 + r2) * (r1 + r2) + E;
}

// include circle inside
inline bool collide_circle_point(const Complex p1, const double r1, const Complex p2) {
  return collide_circle_circle(p1, r1, p2, 0.0);
}

inline void intersection_circle_circle(const Complex p1, const double r1, const Complex p2, const double r2, int *size, Complex *ret1, Complex *ret2) {
  assert(p1 != p2);
  assert(ret1 != NULL && ret2 != NULL);
  if (!collide_circle_circle(p1, r1, p2, r2)) {
    if (size != NULL) { *size = 0; }
    *ret1 = *ret2 = Complex(NAN, NAN);
    return;
  }
  Complex center = (p1 * r2 + p2 * r1) / (r1 + r2);
  Complex vect = (center - p1) * Complex(0.0, 1.0);
  if (abs(vect) < E) {
    *ret1 = *ret2 = center;
    if (size != NULL) { *size = 1; }
    return;
  }
  vect *= sqrt(r1 * r1 - norm(vect)) / abs(vect);
  *ret1 = center + vect;
  *ret2 = center + vect * Complex(-1.0, 0.0);
  if (size != NULL) { *size = 2; }
}

Complex point[301];

int main() {
  int n;
  while (scanf("%d", &n), n != 0) {
    for (int i = 0; i < n; i++) {
      double a, b;
      scanf("%lf %lf", &a, &b);
      point[i] = Complex(a, b);
    }
    int max_ans = 1;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < i; j++) {
        if (!collide_circle_circle(point[i], 1.0, point[j], 1.0)) { continue; }
        int size;
        Complex m[2];
        intersection_circle_circle(point[i], 1.0, point[j], 1.0, &size, &m[0], &m[1]);
        for (int s = 0; s < size; s++) {
          int ans = 0;
          for (int k = 0; k < n; k++) {
            if (collide_circle_point(m[s], 1.0, point[k])) {
              ans++; }
          }
          max_ans = max(max_ans, ans);
        }
      }
    }
    printf("%d\n", max_ans);
  }
}

Measured memory_bytes: 932
object Main {
  def main(args: Array[String]): Unit = {
      val sc = new java.util.Scanner(System.in)
      val x = sc.nextInt
      val y = sc.nextInt

    if (x >= 13) { println(y) }
    else if (x >= 6 && x <= 12) { println(y / 2) }
    else println(0)
  }
}

Measured memory_bytes: 25516
# frozen_string_literal: true

N = gets.to_i
lists = gets.chomp.split(' ').map(&:to_i)

sum = 0
N.times do |i|
  min = if i.zero?
    lists[i]
  elsif i == (N - 1)
    lists[i - 1]
  else
    [lists[i], lists[i-1]].min
  end

  sum += min
end

puts sum


Measured memory_bytes: 1788
# ABC131
def main():
    n, l = list(map(int, input().rstrip().split()))
    lst = []
    for i in range(1, n + 1):
        lst += [i + l - 1]
    if 0 in lst:
        print(sum(lst))
    else:
        if l > 0:
            print(sum(lst[1:]))
        else:
            print(sum(lst[:-1]))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
#define MAX_N 100002
#define INF 10000000001
ll dp[101][MAX_N];

void init(){
	rep(i,101){
		rep(j,100002){
			dp[i][j] = INF;
		}
	}
}

int main()
{
	int N,W;
	cin>>N>>W;
	init();
	int *v = new int[N];
	int *w = new int[N];
	rep(i,N){
		cin>>w[i]>>v[i];
	}
	dp[0][0] = 0;
	for(int i = 0;i < N; i++){
		for(int j = 0; j <= 100001; j++){
			if(j - v[i] >= 0){
				dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]] + w[i]);
			}else{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	ll ans = 0;
	for(int i = 0; i <= 100001; i++){
		if(dp[N][i] <= W) ans = i;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int X,Y;
  cin>>X>>Y;
  int ans=1;
  while(1){
    X*=2;
    if(X>Y)
      break;
    ans++;
    }
  cout<<ans;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    char tmp;
    string S;
    cin >> A >> B;
    
    
    ans = (A-1)*(B-1);
    
    cout <<ans<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    // if(A+B==C || B+C==A || C+A==B)
    // 	puts("Yes");
    // else
    // 	puts("No");
}


Measured memory_bytes: 256
n = gets.chomp.to_i
line = gets.chomp.split('')
# print(line)

# Eの累積和
e_s = []
num = 0
n.times do |i|
    num += 1 if line[i] == "E"
    e_s << num
end
# print("\n")
# print(e_s)
counts = []

n.times do |i|
    self_dis = line[i] == "E" ? 1 : 0
    counts << (i - e_s[i] + self_dis) + (e_s[-1] - e_s[i])
end

print(counts.min)

Measured memory_bytes: 32316
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, A, B; cin >> N >> A >> B;
  cout << min(A * N, B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
#define rep(i,n) for(ll i=0;i<(n);i++)
bool is_prime(ll n) {
	ll x = sqrt(n);
	if (n == 1)return 0;
	if (n % 2 == 0) {
		if (n == 2)return 1;
		else return 0;
	}
	for (ll i = 3; i <= x; i += 2) {
		if (n%i == 0)return 0;
	}
	return 1;
}
int main() {
	vector<ll> pri, cnt;
	for (ll i = 1; i <= 1000; i++)if (is_prime(i))pri.push_back(i);
	cnt = pri;
	for (int i = 0; i < cnt.size(); i++)cnt[i] = 0;
	ll n, yan = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		ll num = i;
		for (int j = 0; j < pri.size(); j++) {
			while (num%pri[j] == 0) {
				cnt[j]++;
				num /= pri[j];
			}
		}
	}
	ll mod = 1e9 + 7, ans = 1;
	for (int i = 0; i < cnt.size(); i++) {
		ans *= cnt[i] + 1;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))
B = [0]
C = [0]
for i in range(n):
    B.append(B[i] + A[i])
    C.append(C[i] + A[n-i-1])
ans = 10 ** 11
for i in range(1, n):
    if abs(B[i] - C[n-i]) < ans:
        ans = abs(B[i] - C[n-i])
print(ans)

Measured memory_bytes: 30136
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define xy          exit(0);
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,b,d,x,a,h,l,r,n,p,q,c,ans;
    	string s;
    	cin>>n;
    	b=0;
    	rep(i,1,n+1)
    	{
    		if(i%5!=0 && i%3!=0)
    		b+=i;
		}
    	cout<<b;
    	
    	
    	
    	
    	
    	
    	
    	
    	
    }
	return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    vector<i64> l(N),r(N);
    rep(i,0,N) cin >> l[i] >> r[i];

    i64 bottom=0,left_uniform=2*l[0],right_uniform=0;
    multiset<i64> left_diverse={l[0]},right_diverse={l[0]};
    rep(i,1,N){
        left_uniform-=r[i]-l[i];
        right_uniform+=r[i-1]-l[i-1];

        if(left_uniform-*left_diverse.begin()<=l[i] and l[i]<=right_uniform+*right_diverse.begin()){
            left_diverse.insert(-l[i]+left_uniform);
            right_diverse.insert(l[i]-right_uniform);
        }else if(l[i]<left_uniform-*left_diverse.begin()){
            bottom+=(left_uniform-*left_diverse.begin())-l[i];

            left_diverse.insert(-l[i]+left_uniform);
            left_diverse.insert(-l[i]+left_uniform);
            right_diverse.insert(left_uniform-*left_diverse.begin()-right_uniform);
            left_diverse.erase(left_diverse.begin());
        }else{
            bottom+=l[i]-(right_uniform+*right_diverse.begin());

            right_diverse.insert(l[i]-right_uniform);
            right_diverse.insert(l[i]-right_uniform);
            left_diverse.insert(-(right_uniform+*right_diverse.begin())+left_uniform);
            right_diverse.erase(right_diverse.begin());
        }
    }

    cout << bottom << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
using namespace std;
ll keta(ll a,ll b){
  ll A=0,B=0;
  while(a){
    a/=10;
    A++;
  }
  while(b){
    b/=10;
    B++;
  }
  return max(A,B);
}

int main(){
  ll N,ans=INF,a,b;
  cin>>N;
  for(ll i=1;i*i<=N;i++){
    if(N%i==0){
      a=i;
      b=N/i;
    }
    ans=min(ans,keta(a,b));
  }
  cout<<ans<<endl;
}

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

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

int main(){
	long n,x;
	cin>>n>>x;
	long a[n];
	for(long i=0;i<n;i++){
		cin>>a[i];
		a[i] = abs(a[i]-x);
	}
	long g = a[0];
	for(long i=1;i<n;i++){
		if(g>a[i])
			g = gcd(a[i], g);
		else if(g<a[i])
			g = gcd(g,a[i]);
	}
	cout<<g;
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define int         ll int
#define float       double
#define	endl		'\n'
#define maxpq       priority_queue<ll>
#define minpq       priority_queue<ll, vector<ll>, greater<ll> >
#define mii         map<int,int>
#define msi         map<string,int>
#define mis         map< int, string>
#define mpi         map<pair< int, int>, int>
#define pii         pair< int, int>
#define vi          vector< int>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define EPS         1e-9
#define INF         1e18
#define PI          3.14159265358979323846
#define MAXI        1000000
#define what_is(x)  cerr << #x << " is " << x << endl;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
#define N 100005
signed main()
{
	fast;
    int t=1;
    //cin>>t;
    while(t--)
    {
    	int n;
		cin>>n;
		vector <string> v;
		map <string,int> m;
		int i,j,k;
		for(i=0;i<=n-1;i++)
		{
			string s;
			cin>>s;
			m[s]++;
		}
		cout<<"AC x "<<m["AC"]<<endl;
		cout<<"WA x "<<m["WA"]<<endl;
		cout<<"TLE x "<<m["TLE"]<<endl;
		cout<<"RE x "<<m["RE"]<<endl;
    	
	}
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,N,f,ans=1,m=0,p[1000];
  bool b[1000]={};
  for(int i=2;i*i<1000;i++) if(!b[i]) for(int j=2*i;j<1000;j+=i) b[j]=1;
  for(int i=2;i<1000;i++) if(!b[i]) p[m++]=i;
  cin>>N;
  fr(i,m){
    n=N;f=1;
    while(n){
      n/=p[i];
      f+=n;
    }
    ans*=f;
    ans%=1000000007;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
N=int(input())
l=list(map(int,input().split()))
ans=0
if N<3:
   print(0)
   exit()
for i in range(N):
   for j in range(i+1,N):
      for k in range(j+1,N):
         if l[i] != l[j] and l[j] != l[k] and l[i] != l[k]  and (l[i]+l[j]+l[k])-max(l[i],l[j],l[k])>max(l[i],l[j],l[k]):
            ans+=1
print(ans)

Measured memory_bytes: 9216
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String store = scan.next();
		String x;
		int cnt = 0, sa = 0, store2 = 0; 

		for(int i = 0; i < N; i++){
			x = scan.next();
			a:	for(int j = 0; j < x.length(); j++){
				if(x.charAt(j) == store.charAt(0)){   //看板名と店名の１文字目の一致
					for(int k = j+1; k < x.length(); k++){   
						if(x.charAt(k) == store.charAt(1)){   //看板名と店名の２文字目の一致
							sa = k-j;   //文字の差
							store2 = 2;
							for(int l = k+sa; l < x.length(); l = l+sa){   //差の分増やしながら
								if(x.charAt(l) == store.charAt(store2)){   //看板名と店名の３文字目以降の一致
									if(store2 == store.length()-1){   //strを最後まで確認でできたか
										cnt++;
										break a; 
									}
									store2++;
								}
								else break;
							}
						}
					}
				}
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 20520
//       BAAP IZ HERE           //
#include<bits/stdc++.h>
using namespace std;
#define gcd __gcd
#define lli long long int
#define jmd ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int main()
{
    string s = "No";
    jmd; double x,y;cin>>x>>y;
    double b = (y-2*x)/2;
    double a = (4*x-y)/2;
    if(a>=0 && ceil(a)==floor(a) && b>=0 && ceil(b)==floor(b))
        s = "Yes";
    cout<<s;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
    ll a, b;
    cin >> a >> b;

    a--;
    b--;
    println(a * b);
}



Measured memory_bytes: 3624
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    //int[][] arr = new int[n][2];
    int ans=0;
    for(int i=0;i<n;i++){
      int a =sc.nextInt();
      if(a%2!=0 && (i+1)%2!=0){
        ans++;
      }
    }
    System.out.println(ans);
  }
}


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

int main() {
    int N; cin >> N;
    vector<int> a(N); for (int i = 0; i < N; i++) cin >> a[i];
    stack<int> s;
    for (int i = 0; i < N; i++) {
        bool f = true;
        for (int j = N - 1 - i; 0 <= j; j--) {
            if (a[j] == j+1) {
                s.push(j+1);
                a.erase(a.begin()+j, a.begin()+j+1);
                f = false;
                break;
            }
        }
        if (f) {
            cout << -1 << endl;
            return 0;
        }
    }
    while (!s.empty()) {
        int x = s.top();
        s.pop();
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>


using namespace std;



int main() {

	int N, P, count=0;

	cin >> N;

	int min = N;

	for (int i = 0; i < N; i++) {
		cin >> P;
		if (min >= P) {
			min = P;
			count++;
		}
	}

	cout << count;

	return 0;

}

Measured memory_bytes: 256
/*****include*****/
#include <iostream>
#include <fstream>
#include <string>

/*****デバッグ定義*****/
//#define DEBUG
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int month_table[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int month;
	int date;
	int date_num;
	/*****処理部*****/
	while(1){
		cin >> month >> date;
		if(month == 0)	break;
		month--;	//配列の番号に合わせる
		date_num = 0;
		for(int i=0;i<month;i++)
			date_num += month_table[i];
		date_num += date;
		date_num = date_num % 7;
		switch(date_num){
		case 0:
			cout << "Wednesday" << endl;
			break;
		case 1:
			cout << "Thursday" << endl;
			break;
		case 2:
			cout << "Friday" << endl;
			break;
		case 3:
			cout << "Saturday" << endl;
			break;
		case 4:
			cout << "Sunday" << endl;
			break;
		case 5:
			cout << "Monday" << endl;
			break;
		case 6:
			cout << "Tuesday" << endl;
			break;
		}
	}
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

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

using namespace std;


int main()
{
	int n, w;
	cin >> n >> w;

	//dp[n][w]
	vector<vector<int>> dp(101, vector<int>(100001, 1000000007));

	for (int i = 0; i <= n; i++) dp[i][0] = 0;

	for (int i = 1; i <= n; i++) {
		int wi, vi;
		cin >> wi >> vi;

		for (int j = 1; j <= 100000; j++) {

			if (j < vi) {
				dp[i][j] = min(dp[i - 1][0] + wi, dp[i - 1][j]);
			}
			else {
				dp[i][j] = min(dp[i - 1][j - vi] + wi, dp[i - 1][j]);
			}
			//if (dp[i][j] < 1000000000) cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}

	/*for (int i = 100000; i > 0; i--) {
		cout << dp[n][i] << endl;
	}*/


	for (int i = 100000; i > 0; i--) {
		if (dp[n][i] <= w) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 40320
def main():
    a = []
    flag = False
    for i in range(5):
        a.append(int(input()))
    k = int(input())
    for i in a:
        for j in a:
            if i - j > k:
                print(':(')
                flag = True
                break
        if flag:
            break
    else:
        print('Yay!')


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner stdin = new Scanner(System.in);
		String s = stdin.next();
		int a=0;
		char[] c;
		c = s.toCharArray();
		for(int i=0;i<4;i++) {
			if(c[i]=='+') {
				a++;
			}else {
				a--;
			}
			
		}
		System.out.println(a);
	}

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}



int main()
{
ll x,k,d;
cin>>x>>k>>d;
x=llabs(x);
ll a=x/d;

if(k<a){
    x-=k*d;
    cout<<x<<endl;
    return 0;
}

if(a<=k){
    x-=a*d;
    k-=a;
    if(k%2==0)cout<<x<<endl;
    else cout<<llabs(x-d)<<endl;
    return 0;
}

}



Measured memory_bytes: 3604
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;



int main()
{

	int n;
	cin >> n;
	int x = n % 1000;
	if (x != 0)
		cout << 1000 - x;
	else
		cout << 0;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <functional>

using namespace std;

const int INF = 1 << 29;	// 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策

int main(void)
{
	int N;
	int A[100001];
	int min = INF;
	int minus_num = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {
		long long tmp;
		cin >> tmp;

		if (tmp >= 0) {
			A[i] = tmp;
		}
		else {
			A[i] = -tmp;
			minus_num++;
		}
		if (A[i] < min) {
			min = A[i];
		}
	}

	long long sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}
	
	if (minus_num % 2 == 1) {
		sum -= min * 2;
	}
	
	cout << sum << endl;

	return 0;
}

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

ll n;

ll F(ll i){
    ll a = i;
    ll b = n/i;
    int ketaA = 0;
    int ketaB = 0;
    
    while(a!=0){
        a/=10;
        ketaA++;
    }
    while(b!=0){
        b/=10;
        ketaB++;
    }
    return max(ketaA,ketaB);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    
    cin >> n;
    
    vector<ll> arr;
    
    ll m = sqrt(n);
    for(ll i = 1; i <= m; i++){
        if(n % i == 0) arr.push_back(i);
    }
    ll minv = 1e9;
    for(int i = 0; i < arr.size(); i++){
        minv = min(minv,F(arr[i]));
    }
    cout << minv << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  long long N,M;
  long long X[100001],Y[100001];
  cin>>N>>M;
  FOR(i,1,N+1){
    cin>>X[i];
  }
  FOR(i,1,M+1){
    cin>>Y[i];
  }
  sort(X+1,X+N+1);
  sort(Y+1,Y+M+1);
  long long sumx=0,sumy=0;
  FOR(i,1,N+1){
    (sumx+=(i-1)*X[i]-(N-i)*X[i])%=MOD;
  }
  FOR(i,1,M+1){
    (sumy+=(i-1)*Y[i]-(M-i)*Y[i])%=MOD;
  }
  cout<<sumx*sumy%MOD<<endl;
  return 0;
}


Measured memory_bytes: 1792