akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
int main(){
	int h,m,s,ansh[3],ansm[3],anss[3],h1,m1,s1,S,S1,memo;
	for(int i=0;i<3;i++){
		cin>>h>>m>>s>>h1>>m1>>s1;
		S=h*3600+m*60+s;
		S1=h1*3600+m1*60+s1;
		memo=S1-S;
		ansh[i]=memo/3600;
		ansm[i]=memo/60-ansh[i]*60;
		anss[i]=memo%60;
	}
	for(int i=0;i<3;i++){
		cout<<ansh[i]<<" "<<ansm[i]<<" "<<anss[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
    // cout<<"succ"<<endl;
    int n;


    cin>>n;
    int v[n];
    int c[n];
    for(int i=0; i<n; i++)
        cin>>v[i];
    for(int i=0; i<n; i++)
        cin>>c[i];
    int sum=0;
    for(int i=0; i<n; i++)
    {
        if((v[i]-c[i])>0)
            sum+=v[i]-c[i];

    }


    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 384
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
void solve(ll x, vector<ll>&c, vector<ll>&d){
    ll ans = 1LL<<60;
    rep(i,2){
        rep(j,2){
            ans = min({ans,abs(c[i]-x)+abs(c[i]-d[j]), abs(d[j]-x)+abs(d[j]-c[i])});
        }
    }
    cout << ans << "\n";
}
int main(){
    int a,b;
    cin >> a >> b;
    int q;
    cin >> q;
    vector<ll>s(a);
    vector<ll>t(b);
    rep(i,a)cin >> s[i];
    rep(i,b)cin >> t[i];
    while(q--){
        ll x;
        cin >> x;
        int id = (int) (lower_bound(s.begin(),s.end(),x)-s.begin());
        int id2 = (int) (lower_bound(t.begin(),t.end(),x)-t.begin());
        vector<ll>c,d;
        if(id==a){
            c.push_back(s.back());
            c.push_back(1LL<<59);
        }else if(id == 0){
            c.push_back(s[0]);
            c.push_back(-(1LL<<59));
        }else{
            c.push_back(s[id]);
            c.push_back(s[id-1]);
        }
        if(id2==b){
            d.push_back(t.back());
            d.push_back(1LL<<59);
        }else if(id2 == 0){
            d.push_back(t[0]);
            d.push_back(-(1LL<<59));
        }else{
            d.push_back(t[id2]);
            d.push_back(t[id2-1]);
        }
        solve(x,c,d);
    }
}

Measured memory_bytes: 2944
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 14 21:08:40 2020

@author: NEC-PCuser
"""

X, N = map(int, input().split())
p = list(map(int, input().split()))

i = 0
ans = 0
while True:
    if (X - i) not in p:
       ans = X - i
       break
    if (X + i) not in p:
       ans = X + i
       break
    i += 1

print(ans)

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <stack>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  string line;
  while(getline(cin,line)) {
    char str[81];
    strcpy(str, line.c_str());
    char *p;
    p = strtok(str, " ");
    stack<double> sk;
    while(p) {
      if (strlen(p) == 1 && !isdigit(*p)) {
        double tmp2 = sk.top();
        sk.pop();
        double tmp1 = sk.top();
        sk.pop();
        if (*p=='+')
          sk.push(tmp1+tmp2);
        else if (*p=='-')
          sk.push(tmp1-tmp2);
        else if (*p=='*')
          sk.push(tmp1*tmp2);
        else if (*p=='/')
          sk.push(tmp1/tmp2);
      } else
        sk.push(atof(p));
      p = strtok(NULL, " ");
    }
    printf("%.6lf\n", sk.top());
  }
}

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

using namespace std;
int main(){
	int arr[5];
	for(int i=0;i<5;i++){
		cin>>arr[i];
	}
	for(int i=0;i<5;i++){
		if(arr[i]==0){
			cout<<i+1<<endl;
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,num;
    cin>>n>>m;
    set<int>s1;
    set<int>::iterator it;
    int i;
    for(i=1;i<=n;i++)
    {
        cin>>num;
        s1.insert(num);
    }
    int sum=0;
    for(it=s1.begin();it!=s1.end();it++)
    {
        sum=sum+*it;
    }
    //cout<<sum<<endl;
    float t=float(float(sum)/float(4*m));
    int k=0;
    for(it=s1.begin();it!=s1.end();it++)
    {
        if(*it>=t)
            k++;
    }
    if(k<m)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;



}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long ans;
long long sum1[200005];
long long a[200005];
long long mod=1e9+7;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		sum1[i]=(sum1[i-1]+a[i])%mod;
	}
	for(int i=1;i<n;i++)
	{
		ans=(ans+a[i]*((sum1[n]-sum1[i])%mod))%mod;
	}
	cout<<(ans+mod)%mod;
}

Measured memory_bytes: 6756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Collections;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC128_b solver = new ABC128_b();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC128_b {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            List shops = new ArrayList<Shop>();

            for (int i = 0; i < N; i++) {
                shops.add(new Shop(i + 1, in.next(), in.nextInt()));
            }
            Collections.sort(shops);
            for (Object shop : shops) {
                out.println(shop);
            }


        }

        class Shop implements Comparable<Shop> {
            private int no;
            private String name;
            private int score;

            public Shop(int no, String name, int score) {
                this.no = no;
                this.name = name;
                this.score = score;
            }

            public int getScore() {
                return score;
            }

            public String getName() {
                return name;
            }

            public String toString() {
                return String.valueOf(no);
            }

            public int compareTo(Shop o) {
                if (this.getName().equals(o.getName())) {
                    return (o.getScore() - this.getScore());
                } else {
                    return (this.getName().compareTo(o.getName()));
                }
            }

        }

    }
}



Measured memory_bytes: 25172
import Data.List (sort)

main = do
  _ <- read <$> getLine :: IO Int
  ss <- sort.map read.lines <$> getContents :: IO [Int]
  let sss = filter (\s->s`mod`10/=0) ss
      total = sum ss
  if total `mod` 10 /= 0
    then print total
    else if null sss
      then print 0
      else print $ total - head sss


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    sort(s.begin(), s.end());
    do{
        if(s == "abc"){
            cout<<"Yes"<<endl;
            return 0;
        }
    }while(next_permutation(s.begin(), s.end()));
    cout<<"No"<<endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	map<string, int> s;
	rep(i, n){
		string t; cin >> t;
		s[t]++;
	}

	printf("AC x %d\n", s["AC"]);
	printf("WA x %d\n", s["WA"]);
	printf("TLE x %d\n", s["TLE"]);
	printf("RE x %d\n", s["RE"]);
	return 0;
}

Measured memory_bytes: 3756
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
        string s;
        cin>>s;
        for(int i=0;i<s.size();i++)
        {
        	if(s[i]=='?')
        		s[i]='D';
        }
        cout<<s;
     
    }
    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		string s = to_string(i);
		if (s.size() %2 == 1) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stack>
using namespace std;

int mapp[10000];
int main()
{
    int a, b, c;
    cin>>a>>b>>c;
    mapp[a]++;
    mapp[b]++;
    mapp[c]++;
    if(mapp[5]==2&&mapp[7]==1)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {        
    int h, w;
    cin >> h >> w;
    cout << string(w + 2, '#') << endl;
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        cout << string(1, '#') << s << string(1, '#') << endl;

    }
    cout << string(w + 2, '#') << endl;

}


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


using namespace std;

int main()
{
    int n;
    char s[12345];
    string str;
    scanf("%d %s", &n, s);
    //gets(s);

    int len = strlen(s);
    //printf("%d", len);
    int val = 0, formula = 0;
    for(int i = 0; i < len; i++)
    {
        val = int(s[i]);
        formula = 65 + ((val - 65 + n) % 26);
        str += char(formula);
    }
    cout << str <<'\n';
    return 0;
}


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

int main() {
  /*
  ∧＿∧
  ( ´･ω･) みなさん、お茶が入りましたよ・・・・。
  ( つ旦O
  と＿)＿) 旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦旦
  */
  int m;
  cin >> m;
  cout << 48 - m << endl;
}

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

int main()
{
    // 入力の受け取り
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> vecWin(q);
    for(int i=0; i<q; i++){
        cin >> vecWin.at(i);
    }

    // 各選手のポイント
    vector<int> vecPoint(n, k-q);
    for(int i=0; i<q; i++){
        vecPoint[vecWin[i]-1] += 1;
    }

    // 結果保存
    vector<string> vecRes(n);
    for(int i=0; i<n; i++){
        if(vecPoint[i] > 0)
            vecRes[i] = "Yes";
        else
            vecRes[i] = "No";
    }

    // 結果
    for(int i=0; i<n; i++)
        cout << vecRes[i] << endl;

    return 0;
}

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

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

  int cnt=0,sum;
  for(int i=0;i<n;i++){
    sum=c;
   for(int j=0;j<m;j++){
    sum+=a[i][j]*b[j];
   }
    if(sum>0)cnt++;

  }
  cout << cnt << endl;
}

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

// TYPEDEF
// ----------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> Pair;
typedef vector<ll> vll;
typedef vector<vector<ll>> Graph;
typedef vector<string> vs;
typedef vector<pair<ll, ll>> Pll;
typedef queue<ll> qll;

// REPEAT
// ----------------------------------------
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REPA(i,a) for(ll i=0;i<(ll)(a.size());i++);
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define COUT(a) cout << (a) << endl;
#define ENDL(a) cout << endl;
#define COUTA(i,a) for(ll i=0;i<(ll)(a.size());i++) {cout << (a)[i] << " ";} cout << endl;

// UTIL
// ----------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())

// DEBUG
// ----------------------------------------
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

// BIT FLAG
// ----------------------------------------
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000
const unsigned int BIT_FLAG_8 = (1 << 8); // 0000 0001 0000 0000
const unsigned int BIT_FLAG_9 = (1 << 9); // 0000 0010 0000 0000
const unsigned int BIT_FLAG_10 = (1 << 10); // 0000 0100 0000 0000
const unsigned int BIT_FLAG_11 = (1 << 11); // 0000 1000 0000 0000

// CONST
// ----------------------------------------
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI=3.14159265358979323846; // or M_PI
constexpr int MOD = 1000000007;


void Main() {
    ll n, l;
    cin >> n >> l;
    ll total = 0;
    ll min_apple = INF;
    ll min_apple_index = 0;
    REP(i, n) {
      if (min_apple > abs(i + l)) {
        min_apple = abs(i + l);
        min_apple_index = i;
      }
      total += i + l;
    }

    COUT(total - min_apple_index - l);
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

/*

5
1 3 5 4 2
*/


Measured memory_bytes: 3608
#include <iostream>
#include <queue>

using namespace std;

int main(){
    int N,M;
    cin >>N >>M;
    int temA,A[100000];
    for(int i=0;i<N;i++){
        cin >>temA;
        A[i]=temA;
    }
    int B[100000],C[100000];
    for(int i=0;i<M;i++){
        cin >> B[i]>>C[i];
    }
    priority_queue<pair<int,int>> q;
    for(int i=0;i<N;i++){
        q.push(make_pair(A[i],1));
    }
    for(int i=0;i<M;i++){
        q.push(make_pair(C[i],B[i]));
    }
    long long ans=0;
    for(int i=0;i<N;i++){
        auto p=q.top();
        q.pop();
        ans+=p.first;
        if(p.second>1){
            p.second--;
            q.push(p);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3572
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	vector<int> h_id(h, 0);
	int id = 0;
	rep(i,h){
		bool cut = false;
		rep(j,w){
			if(s[i][j] == '#') cut = true;
		}
		if(cut) h_id[i] = ++id;
		else h_id[i] = max(id, 1);
	}
	vector<vector<int>> ans(h, vector<int>(w, 0));
	int num = 1;
	rep(i,h){
		int las = i;
		while(las + 1 < h && h_id[las+1] == h_id[i]){
			++las;
		}
		bool firstCut = true;
		rep(j,w){
			bool cut = false;
			for(int l = i; l <= las; ++l){
				if(s[l][j] == '#') cut = true;
			}
			if(cut){
				if(firstCut) firstCut = false;
				else ++num;
			}
			for(int l = i; l <= las; ++l){
				ans[l][j] = num;
			}
		}
		i = las;
		++num;
	}
	rep(i,h){
		rep(j,w) cout << ans[i][j] << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
  int N, A,B;
  cin >> N >> A >> B;
  if(abs(A-B)%2==1) cout << "Borys" <<endl;
  else cout << "Alice" <<endl;

  return 0;
}

Measured memory_bytes: 256
rows,cols=map(int,input().split(" "))
a=[[0 for i in range(cols)] for j in range(rows)]
b=[0 for col in range(cols)]
c=[0 for row in range(rows)]

for row in range(rows):
    a_val=list(map(int,input().split(" ")))
    for col in range(cols):
        a[row][col]=a_val[col]

for col in range(cols):
    b_val=int(input())
    b[col]=b_val

for row in range(rows):
    for col in range(cols):
        c[row]+=a[row][col]*b[col]

for row in range(rows):
    print(c[row])



Measured memory_bytes: 6008
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10 ** 7)


def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):
    res = [0 for i in range(N)]
    G = [[] for i in range(N)]
    for i, j, k in zip(u, v, w):
        # print(i, j, k)
        i -= 1
        j -= 1
        # print(i, j, k)
        G[i].append((j, k))
        G[j].append((i, k))
    # print(G)

    # v を c に塗る。 p は v の親。
    def dfs(v, p, c):
        res[v] = c
        for e in G[v]:
            if e[0] == p:
                continue
            if e[1] & 1:
                dfs(e[0], v, 1 - c)
            else:
                dfs(e[0], v, c)

    dfs(0, -1, 1)

    for x in res:
        print(x)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools
# (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)


if __name__ == '__main__':
    main()


Measured memory_bytes: 169308
#include<iostream>
using namespace std;
int main(){
  string s[55];
  // char count[55][55];
  // 周囲1マスへの変位.右上から時計回りに
  int dx[8]={1,1,1,0,-1,-1,-1,0}; 
  int dy[8]={-1,0,1,1,1,0,-1,-1};
  int h,w; cin >> h >> w;
  for(int i=0;i<h;i++) cin >> s[i];
  
  for(int y=0;y<h;y++){
    for(int x=0;x<w;x++){
      if(s[y][x]=='.'){
        int num=0;
        for(int i=0;i<8;i++){
          if(y+dy[i]>=h || x+dx[i]>=w || y+dy[i]<0 || x+dx[i]<0) continue;
          if(s[y+dy[i]][x+dx[i]]=='#') num++;
        }
        s[y][x]= (char)(num+'0');
      }
    }
  }
  
  for(int i=0;i<h;i++) cout << s[i] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    vector<pair<ll, ll>> c;
    ll n;
    cin >> n;
    F0R(i, n)
    {
        ll x, y;
        cin >> x >> y;
        c.pb({x, y});
    }
    sort(c.begin(), c.end());
    map<pair<ll, ll>, int> v;
    F0R(i, n - 1)
    {
        FOR(j, i + 1, n)
        {
            if(v.find({c[i].f - c[j].f, c[i].s - c[j].s}) == v.end())
                v.insert({{c[i].f - c[j].f, c[i].s - c[j].s}, 1});
            else
            {
                (*v.find({c[i].f - c[j].f, c[i].s - c[j].s})).s++;
            }
        }
    }
    int res = 0;
    for(auto itx : v)
    {
        res = max(res, itx.s);
    }
    cout << n - res;
    return 0;
}

Measured memory_bytes: 384
fun main(args:Array<String>){
  val (y,m,d) = readLine()!!.split("/").map(String::toInt)
  val H = "Heisei"
  val T = "TBD"
  if(y<2019){
    println(H)
  }else{
    if(m>4){
      println(T)
    }else {
      println(H)
    }
  }
}

Measured memory_bytes: 36008
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

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

	int d = (m + n - 1) / n;
	int ans;
	for (int i = d; i > 0; i--) {
		if (m % i == 0 && m / i >= n) {
			ans = i;
			break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define pi pair<ll,ll>
#define pii pair<ll,pi>
#define pb push_back
#define mk make_pair
const ll INF = 1e18l;
int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<int>weight(n), value(n);
	ll sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> weight[i] >> value[i];
		sum += value[i];
	}
	vector<ll>dp(sum + 1); // min weight to get value of i;
	for (int i = 0; i <= sum; i++)dp[i] = INF;
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		ll v = value[i];;
		for (int k = sum - v; k >= 0; k--) {
			dp[k + v] = min(dp[k + v], dp[k] + weight[i]);
		}
	}
	ll ans = -INF;
	for (ll i = 0; i <= sum; i++) {
		if (dp[i] <= w) {
			ans = max(ans, i);
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100001;
int a[maxn],dp[maxn];

int main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	dp[n]=0;
	dp[n-1]=abs(a[n]-a[n-1]);
	for(int i=n-2;i>=1;i--){
		dp[i]=min(abs(a[i+1]-a[i])+dp[i+1],dp[i+2]+abs(a[i+2]-a[i]));
	}
	cout<<dp[1];
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int,input().split()))
A_guu = [i for i in A if i % 2 == 0]
A_ans = [i for i in A_guu if i % 3 == 0 or i % 5 == 0]
# print(A_guu)
# print(A_ans)
if A_ans == A_guu:
    print("APPROVED")
else:
    print("DENIED")


Measured memory_bytes: 2940
#include <iostream>
#include <string>

int main()
{
  std::string n;

  std::cin >> n;



  if ((n[0] == n[1] && n[1] == n[2]) ||
      (n[1] == n[2] && n[2] == n[3])) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;
const ll mod = 1000000007;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  double a, b, c;
  cin >> a >> b >> c;
  c = (c/180.0)*M_PI;
  double S = 0.5*a*b*sin(c);
  double L = a+b+pow(a*a+b*b-2*a*b*cos(c), 0.5);
  double h = 2.0*S/a;
  cout << fixed << setprecision(10);
  cout << S << endl;
  cout << L << endl;
  cout << h << endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(1e9 + 7)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 5005;

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
	
	int n;
	cin >> n;

	vector<int> b(n-1);
	// b[i] >= b[i+1]
	// a[i] = b[i+1]
	// a[i] = b[i]

	rep(i,n-1) cin >> b[i];
	int sum = b[n-2];

	repD(i,n-3,0) {
		if(b[i] >= b[i+1])
			sum += b[i+1];
		else
			sum += b[i];
		// db(sum);
	}

	cout << sum+b[0] << '\n';
}	

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

int main(){
	char c;
	cin >> c;
  	if(c=='A')
		cout << 'T' << endl;
	else if(c=='G')
		cout << 'C' << endl;
	else if(c=='C')
		cout << 'G' << endl;
	else
      	cout << 'A' << endl;
}




Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h){
        cin >> a[i];
    }
    char ans[h+2][w+2];
    REP(i, h+2){
        REP(j, w+2){
            if(i == 0 || j == 0 || i == h+1 || j == w+1){
                ans[i][j] = '#';
            }
            else {
                ans[i][j] = a[i-1][j-1];
            }
        }
    }
    REP(i, h+2){
        REP(j, w+2){
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

struct Combination{
  const int MOD = 1e9+7;

  vector<int> fact; //　fact[i] = iの階乗
  void init(int n){
    fact.resize(n+1);
    fact[0] = fact[1] = 1;
    for(int i = 2; i <= n; i++){
      fact[i] = i * fact[i-1] % MOD;
    }
  }

  int nCr(int n, int r){ // nCr = n!/r!(n-r)!
    if(n < r) return 0;
    return fact[n] * mod_pow(fact[r]*fact[n-r]%MOD, MOD-2) % MOD;
  }

  int mod_pow(int n, int p){ // a/n ≡ a*n^(p-2) nとpは互いに素
    int r = 1;
    for(; p > 0; p >>= 1){
      if(p & 1LL) r = (r * n) % MOD;
      n = (n * n) % MOD;
    }
    return r; // r = n^p % MOD
  }

}comb;

const int MOD = 1e9 + 7;

signed main(){

  int x, y, p, q; cin >> x >> y >> p >> q;

  comb.init(2e6+2);
  int ans = comb.nCr(p+1 + q+1, p+1) - 1 - comb.nCr(x + q+1, x) + 1 - comb.nCr(p + y+1, y) + 1 + comb.nCr(x + y, x) - 1;
  cout << (ans + MOD * 9) % MOD << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

const int dx[]={0,-1,1,0},dy[]={-1,0,0,1};

int main(){

  ll n;cin>>n;
  ll sum=pow(3,n);
  ll evn=0;
  rep(i,0,n){
    ll a;cin>>a;

    if(a%2==0)evn++;
  }

  out(sum-pow(2,evn));

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

long long int solve(long long int h){
    long long int tw = 1;
    long long int n = 0;
    if(h == 1) return 1;
    if(h%2 == 1) return 1 + 2 * solve(h/2);
    if(h % 2 == 0) return 1 + 2 * solve(h/2);
}

int main(){
    long long int h; cin >> h;
    cout << solve(h) << endl;
    return 0;
}

Measured memory_bytes: 888
def count(ps, N, X):
    if X ==0:
        return 0
    total = ps[N][0]
    #print("count N=%d, x=%-20d, total(N)=%d"%( N, X, total))
    half = (total +1)//2
    if X >= total:
        return ps[N][1]
    elif X < half:
        return count(ps, N-1,X-1)
    elif X == half:
        return ps[N-1][1] + 1
    elif X > half:
        return (ps[N-1][1] + 1) + count(ps, N-1, X - half)


def main(N,X):
    ps = [(1, 1)] # total, p
    for i in range(1, N+1):
        ps.append((ps[i-1][0] * 2 + 3, ps[i-1][1] * 2 + 1))

    c = count(ps, N, X)
    print(c)
    return c

#assert(main(2, 7)== 4)
#assert(main(1,1)==0)
#assert(main(50,4321098765432109)==2160549382716056)
N, X = (int(x) for x in input().split())
main(N, X)






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

int main(){
	int N,M;
	cin >> N >> M;
	vector< pair<int,int> > a(M);
	for(int i = 0 ; i < M ; i++) cin >> a[i].first >> a[i].second;

	int c = 0 , ans = 0 , idx = 0;

	for(int i = 0 ; i < N ; i++){
		int best = c;
		for(int i = 0 ; i < M ; i++){
			if( a[i].first <= c + 1 ){
				best = max( best , a[i].second);
			}
		}
		if( best == c ) break;
		c = best;
		ans++;
	}

	if( c < N ){
		cout << "Impossible" << endl;
	}else{
		cout << ans << endl;
	}
}

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

int main(){ 
  int n;
  cin >> n;
  map<int,int> mp;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    mp[a]++;
  }
  bool ok = true;
  for (auto e : mp ) {
    if (e.second > 1) ok = false;
  }
  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
} 

Measured memory_bytes: 9600
def gcd(a, b) : 
    if b == 0 : 
    	return a 
    else : 
    	return gcd(b, a%b) 

def lcm(a, b) :
	return a * b // gcd(a,b)
  
a, b = map(int, input().split())
print(lcm(a,b))

Measured memory_bytes: 2940
S = list(input())
 
res_10 = 0
res_01 = 0
 
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            res_10 += 1
        else:
            res_01 += 1
    else:
        if S[i] == "1":
            res_10 += 1
        else:
            res_01 += 1
print(min(res_10, res_01))

Measured memory_bytes: 3956
#include <stdio.h>
#include <stdbool.h>

void printLeapYear(int, int);
bool judgeLeapYear(int);

int main(void)
{
    int start_year, end_year;
    bool first_data = true;
    
    while (true) {
        scanf("%d%d", &start_year, &end_year);
        
        if (start_year == 0 && end_year == 0) {
            break;
        }
        
        if (first_data) { //各データセットの間に空行入れる用
            first_data = false;
        } else {
            printf("\n");
        }
        
        printLeapYear(start_year, end_year);

    }
    
    return 0;
}

void printLeapYear(int start_year, int end_year)
{
    bool exist_leap_year = false;
    
    for (int year = start_year; year <= end_year; year++) {
        if (judgeLeapYear(year)) {
            exist_leap_year = true;
            printf("%d\n", year);
        }
    }

    if(!exist_leap_year) {
        printf("NA\n");
    }
}

bool judgeLeapYear(int year)
{
    if (year % 400 == 0) {
        return true;
    } else if (year % 100 == 0) {
        return false;
    } else if (year % 4 == 0) {
        return true;
    } else {
        return false;
    }
}

Measured memory_bytes: 1044
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	fmt.Fprintln(wr, abs(n-2)*abs(m-2))
}


Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;
const int INF= 1e9+5;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>v(n);
  int count=1;
  for(int i=0;i<n;i++)cin>>v[i];
  for(int i=1;i<n;i++){
    bool b=true;
    for(int j=0;j<i;j++){
       
      if(v[j]>v[i])b=false;
     
    }
     if(b)count++;
  }
  cout<<count<<endl;
}
  

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

# 最小の答えは1、ここに足していく
ans = 1

# 増加と減少切り替わったタイミングで組の数を増やす
flags = [False, False]

for i in range(N - 1):
    da = a[i + 1] - a[i]
    if da > 0:
        flags[0] = True
    elif da < 0:
        flags[1] = True

    if flags[0] == True and flags[1] == True:
        ans += 1
        # 初期化
        flags = [False, False]

print(ans)


Measured memory_bytes: 20068
#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;

bool isPrime(int v) {

	if (v == 2 || v == 3)
		return true;

	if (v % 2 == 0)
		return false;

	int p = ceil(sqrt(v));

	for (int i = 3; i <= p; i = i + 2) {
		if (v % i == 0)
			return false;
	}

	return true;
}

int main() {

	int n;
	scanf("%d", &n);

	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int v;
		scanf("%d", &v);

		if (isPrime(v))
			++cnt;
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3164
H,W,K=map(int,input().split())
import numpy as np
import copy
c=[]
for i in range(H):
  c.append(list(input().replace('.','0').replace('#','1')))

def count(xdel,ydel,l):
  cnt=0
  for i in range(H):
      for j in range(W):
        if 2**i&ydel!=0 or 2**j&xdel!=0:
          l[i][j]=2
        if l[i][j]=='1':
          cnt+=1
          l[i][j]=1
        
  return cnt

result=0
for i in range(2**H):
  for j in range(2**W):
    l=copy.deepcopy(c)
    if count(j,i,l)==K:
      result+=1
print(result)

Measured memory_bytes: 27160
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>n>>a>>b>>c>>d;
    rep(i,ohara){
        tmp=i;
        tmpp=n-i-1;
        if(tmp>n-1||tmpp>n-1)continue;
        ll mi,ma;
        mi=c*tmp-d*tmpp;
        ma=d*tmp-c*tmpp;
        if(mi<=b-a&&b-a<=ma){
            Cout("YES");
            return 0;
        }
    }
    Cout("NO");
    return 0;
}


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

int W;
int H;
int K;
char grid[6][6];

int main()
{
    cin >> H;
    cin >> W;
    cin >> K;
    for (int y = 0; y < H; y++)
    {
        for (int x = 0; x < W; x++)
        {
            cin >> grid[x][y];
        }
    }
    //1x1 case
    int res=0;
    for (int xmask = 0; xmask < (1 << W); xmask++)
    {
        for (int ymask = 0; ymask < (1 << H); ymask++)
        {
            int count=0;
            for (int y = 0; y < H; y++)
            {
                for (int x = 0; x < W; x++)
                {
                    bool val=grid[x][y]=='#';
                    val&=((xmask&(1<<x))==0)&&((ymask&(1<<y))==0);
                    if(val){
                        count++;
                    }
                }
            }
            if(count==K){
                res++;
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3588
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = arg[0];
    const D = arg[1].split(" ")[0];
    const X = arg[1].split(" ")[1];
    const A = arg.slice(2).map(n=>parseInt(n));
    
    let original = 0;
    
    for(let i=0; i<A.length; i++) {
        for(let j=0; (j * A[i]) + 1 <= D; j++) {
            original++;
        }
    }
    
    console.log(parseInt(original) + parseInt(X));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
def getGrade(m, f, r):
  grade = ""
  if m == -1 or f == -1:
    grade = "F"
  elif m + f >= 80:
    grade = "A"
  elif m + f >= 65:
    grade = "B"
  elif m + f >= 50:
    grade = "C"
  elif m + f >= 30:
    if r >= 50:
      grade = "C"
    else:
      grade = "D"
  else:
    grade = "F"
  return grade

while True:
  line = raw_input().split(" ")
  m = int(line[0])
  f = int(line[1])
  r = int(line[2])
  if m == -1 and f == -1 and r == -1:
    break
  else:
    print getGrade(m, f, r)

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

int main(){
  int N;
  cin >> N;
  if (N == 1) {cout << "Yes" << endl;}
  else {
  vector<int> vec1(N);
  rep(i, N) cin >> vec1[i];
  
  vector<int> vec2(N-1);
  rep(i, N-1) vec2[i] = vec1[i+1] - vec1[i];
  
  int check = 0;
  rep(i, N-1) {
    if ( i == N-2 && vec2[i] >= 0) {
      cout << "Yes" << endl;
      break;
    }
    else if ( i == N-2 && vec2[i] == -1 && check == 0) {
      cout << "Yes" << endl;
      break;
    }
    else if (vec2[i] > 0) check = 0;
    else if (vec2[i] == -1 && check == 0) check = -1;
    else if (vec2[i] == -1 && check == -1) {
      cout << "No" << endl;
      break;
    }
    else if (vec2[i] < -1) {
      cout << "No" << endl;
      break;
    }
  }
  }

}

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

//28
typedef long long ll;

ll power(ll a , ll b) {
    ll ans = 1;
	while (b) {
		if (b & 1) {
			ans = ans  * a;
		}
		a = a * a;
		b  /= 2;
	}
	return ans;
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	int minn = 1e9 + 7;
	sort(v.begin(),v.end());
	for (int i = k - 1; i < n; ++i) {
		minn = min(v[i] - v[i - k + 1],minn);
	}
	cout <<minn;
} 	



Measured memory_bytes: 3740
import java.util.*;

public class Main {
	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		long A =sc.nextInt();
		long B = sc.nextLong();
		long C =6;
	    long ans = 6 -A -B;
	     System.out.println(ans);
	}
	
}


Measured memory_bytes: 21588
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] r = new int[n+1];
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            r[a]++;
            r[b]++;
        }

        for (int i = 1; i <= n; i++) {
            System.out.println(r[i]);
        }
    }
}

Measured memory_bytes: 35856
#include<iostream>
#include<string>
using namespace std ;
int main()
{
    string s ;
    cin >> s ;
    int len = s.size(),n,ans=0;
    n=len/2;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s[len-i-1]){ans++;}
    }
    cout << ans << endl;
    return 0 ;
}


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

int main() {
  int H,W;
  cin >> H >> W;
  
  //二次元配列を宣言
  vector<vector<char>> table(H,vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> table.at(i).at(j);
    }
  }
  
  //p 残したい行の番号を記録
  vector<int> p;
  //q 残したい列の番号を記録
  vector<int> q;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (table.at(i).at(j) == '#') {
        p.push_back(i);
        break;
      }
    }
  }
  
   for (int i = 0; i < W; i++) {
    for (int j = 0; j < H; j++) {
      if (table.at(j).at(i) == '#') {
        q.push_back(i);
        break;
      }
    }
  }
  
  for (int i = 0; i < p.size(); i++) {
    for (int j = 0; j < q.size(); j++) {
      cout << table.at(p.at(i)).at(q.at(j));
      if ( j + 1 == q.size()) {
        cout << endl;
      }
    }
  }
}

Measured memory_bytes: 256