akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int n,i;
	cin>>n>>i;
	cout<<n-i+1;
	re 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] spreadsheet = new int[r][c];
		int[][] sumSpreadsheet = new int[r + 1][c + 1];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				spreadsheet[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sumSpreadsheet[i][j] = spreadsheet[i][j];
			}
		}
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sumSpreadsheet[i][c] += sumSpreadsheet[i][j];
			}
		}
		for (int j = 0; j < c; j++) {
			for (int i = 0; i < r; i++) {
				sumSpreadsheet[r][j] += sumSpreadsheet[i][j];
			}
		}
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				sumSpreadsheet[r][c] += sumSpreadsheet[i][j];
			}
		}
		for (int i = 0; i < r + 1; i++) {
			for (int j = 0; j < c + 1; j++) {
				if (j == c) {
					System.out.print(sumSpreadsheet[i][j]);
				} else {
					System.out.print(sumSpreadsheet[i][j] + " ");
				}
			}
			System.out.println();
		}
		sc.close();
	}
}


Measured memory_bytes: 42100
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <string>
#include <numeric>
#include <algorithm>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <complex>
#include <ctime>
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
using namespace std;

double dis(double x,double y)
{
    return sqrt(x*x+y*y);
}

int main(){
	int n,d;
	scanf("%d%d",&n,&d);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
	    double x,y;
	    scanf("%lf%lf",&x,&y);
	    if(dis(x,y)<=d)
            ans++;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 3860
#include <iostream>

using namespace std;

int main()
{
  int a,b;
  int p,m,e,max = -999;

  cin >> a >> b;

  p = a + b;
  m = a - b;
  e = a * b;

  if(max < p)
    max = p;
  
  if(max < m)
    max = m;

  if(max < e)
    max = e;

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    string x,y;
    
    cin>>x>>y;
    
   if(x<y) cout<<"<"<<endl;    
   if(x==y) cout<<"="<<endl;
   if(x>y)cout<<">"<<endl; 
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l, r) uniform_int_distribution<int>(l, r)(rng)
 
#define LL long long int
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N = 3e5 + 5;
const int oo = 1e9 + 5;
const LL ooll = (LL)1e18 + 5;
const int MOD = 1e9 + 7;
const int M = 1e6 + 5;
 
clock_t start = clock();

void solve() {
	int k;
	cin >> k;
	if (k < 600) {
		cout << "8\n";
	} else if (k < 800) {
		cout << "7\n";
	}else if (k < 1000) {
		cout << "6\n";
	}else if (k < 1200) {
		cout << "5\n";
	}else if (k < 1400) {
		cout << "4\n";
	}else if (k < 1600) {
		cout << "3\n";
	}else if (k < 1800) {
		cout << "2\n";
	} else {
		cout << "1\n";
	}
}
 
int main() {
	FASTIO;
	int T = 1;
	// pre();
	// cin >> T;
	while(T--) {
		solve();
	}
	// cout << fixed << setprecision(10);
	// cout << (clock() - start) / ((double)(CLOCKS_PER_SEC)) << " s\n";
	return 0;
} 

Measured memory_bytes: 3648
n = int(input())
p = list(map(int, input().split()))

def swap():
    cnt = 0
    for i in range(n):
        if i+1 == p[i]:
            if i+1 < n:
                p[i], p[i+1] = p[i+1], p[i]
            else:
                p[i-1], p[i] = p[i], p[i-1]
            cnt += 1
    return cnt

ok = True
ans = 0
while True:
    ans += swap()
    for i in range(n):
        if p[i] == i+1:
            ok = False
    if ok:
        print(ans)
        exit()

Measured memory_bytes: 14008
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  string S;
  cin >> S;
  int N = S.size();
  bool ok = true;
  bool cflag = false;
  rep(i, N) {
    if (i == 0) {
      if (S[i] != 'A') ok = false;
    } else if (!cflag && 2 <= i && i <= N - 2 && S[i] == 'C') {
      cflag = true;
    } else {
      if ('A' <= S[i] && S[i] <= 'Z') ok = false;
    }
  }
  if (!cflag) ok = false;
  cout << (ok ? "AC" : "WA") << endl;
  return 0;
}

Measured memory_bytes: 256
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

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

    int64 a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    int64 X = abs(a - b);
    int64 V = v - w;
    if (v <= w) {
        print("NO");
        return 0;
    }

    if ((X + V - 1) / V <= t) {
        print("YES");
    } else {
        print("NO");
    }

    return 0;
}



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

int main(){
  char c;

  while(true){
    scanf("%c", &c);
    if(c=='\n') break;
    if(c>='a'&&c<='z') c-=32;
    else if(c>='A'&&c<='Z') c+=32;
    cout << c;
  }
  cout << endl;
}



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

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

vector <int> ki[200010];
vector <ll> ans(200100,0);

void dfs(ll i, ll p){
  for (ll j:ki[i]){
    if (j == p) continue;
    ans[j] += ans[i];
    dfs(j, i);
  }
}

int main(){
  ll n, q;
  cin >> n >> q;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    ki[a].push_back(b);
    ki[b].push_back(a);
  }
  rep (i, q){
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0, -1);
  rep(i, n){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 24320
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int a[410000];
long long sum[410000];

int main() {
  while (cin >> N ) {
	for (int i = 0; i < N; ++i) cin >> a[i];
	sum[0] = 0;
	for (int i = 0; i < N; ++i) sum[i+1] = sum[i] + a[i];

	long long res = 1LL<<60;
	for (int i = 1; i < N; ++i) {
	  long long a = sum[i] - sum[0];
	  long long b = sum[N] - sum[i];
	  chmin(res, abs(a-b));
	}
	cout << res << endl;
  }
}












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

using namespace std;

using ll = long long;
using db = double;
using vi = vector<int>;
#define pb push_back

const int maxn = 100006; 

ll A, B, n; 
ll h[maxn]; 
ll f[maxn]; 

bool check(ll x) {
	for (int i = 1; i <= n; ++i) f[i] = h[i]; 
	for (int i = 1; i <= n; ++i) f[i] -= x * B; 
	ll s = 0; 
	for (int i = 1; i <= n; ++i) 
		if (f[i] > 0) s += ((f[i]-1)/(A-B)+1); 
	if (s > x) return false; 
	return true; 
}

int main() {
	cin>>n>>A>>B; 
	for (int i = 1; i <= n; ++i) scanf( "%lld", &h[i] ); 
	ll l = -1, r = ll(1e9+7); 
	while (l+1<r) {
		ll m = (l+r)/2; 
		if (check(m)) r = m; 
		else l = m; 
	}
	cout<<r<<endl; 
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

const int N=3000;
int ans[N],dist[N];
vector<int>edges[N];
void bfs(int s)
{   
    set<pair<int,int>>q;
    q.insert({0,s});
    dist[s]=0;

    while(!q.empty()){
        auto it=*q.begin();
        q.erase(q.begin());
        int level=it.first,node=it.second;
        ans[level]++;    
        for(auto x:edges[node]){
            if(dist[x]>dist[node]+1){
                if(q.find({dist[x],x})!=q.end())
                    q.erase({dist[x],x});
                dist[x]=dist[node]+1;
                q.insert({dist[x],x});
            }
        }
    }

}

signed main(){
    int n,x,y;
    cin>>n>>x>>y;
    edges[x].push_back(y);
    edges[y].push_back(x);
    for(int i=1;i<=n-1;i++){
        edges[i].push_back(i+1);
        edges[i+1].push_back(i);
    }
    for(int i=1;i<=n;i++){
        for(int i=0;i<=n;i++){
            dist[i]=1e4;
        }
        bfs(i);
    }
    for(int i=1;i<n;i++){
        cout<<ans[i]/2<<"\n";
    }
    return 0;
}

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

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

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

int ans=0;

for(int i=1; i<n-1; i++) {
if((p.at(i-1)<p.at(i))&&(p.at(i)<p.at(i+1))){ 
  ans++;}
else if((p.at(i-1)>p.at(i))&&(p.at(i)>p.at(i+1))){ 
  ans++;}
}
cout <<ans<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FT first
#define SC second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;
const int INF = 1e9;
const double EPS = 1e-9;



int main()
{
  int h, w ;
  cin >> h >> w ;
  vector<vector<int>> vec(h+2,vector<int>(w+2,0))  ;

  REP(i,h){
    string s ;
    cin >> s ;
    REP(j,w){
      if(s.at(j)=='.'){
        vec.at(i+1).at(j+1) = 0 ;
      }
      else{
        vec.at(i+1).at(j+1) = 10 ;
      }
    }
  }
  FOR(i,1,h+1){
    FOR(j,1,w+1){
      if(vec.at(i).at(j)>=10){
        FOR(k,i-1,i+2){
          FOR(l,j-1,j+2){
            vec.at(k).at(l)++ ;
          }
        }
      }
    }
  }
  
  FOR(i,1,h+1){
    FOR(j,1,w+1){
      if(vec.at(i).at(j)>=10){
        cout << "#" ;
      }
      else{
        cout << vec.at(i).at(j) ;
      }
    }
    cout <<endl ;
  }
      
  return 0 ;
}




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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
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;
}

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) (x).erase(unique(all(x)), (x).end())
#define int long long

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

/* const */
const int inf = 1e9 + 7;

/* main */
signed main(void)
{
    string s;
    cin >> s;
    int fsize = s.size();
    set<char> st;
    rep(i, s.size())
    {
        st.insert(s[i]);
    }
    int esize = st.size();
    cout << (fsize == esize ? "yes" : "no") << endl;
    return 0;
}

Measured memory_bytes: 256
from math import floor

def c(n,x):
    ret = [-1] * n
    for i in range(n):
        if i%2 == 0: idx = floor(i/2) 
        else: idx = n - 1 - floor(i/2)
        ret[idx] = x[n-i-1] 
    return " ".join([str(i) for i in ret])

def main():
    n = int(input())
    x = list(map(int, input().split()))
    print(c(n,x))

def test():
    print( c(4,[1,2,3,4]))
    print( c(6,[0,6,7,6,7,0]))
main()


Measured memory_bytes: 28864
#include<cstdio>
#include<algorithm>
#include<vector>
#include<functional>
long long buf[100001]={};
int main(){
    int n;
    scanf("%d",&n);
    std::vector<std::pair<long long,int>> vp;
    vp.push_back({0,0});
    for(int i=1;i<=n;i++){
        long long a;
        scanf("%lld",&a);
        vp.push_back({a,i});
    }
    std::sort(vp.begin(),vp.end(),std::greater<std::pair<long long,int>>());
    int mink=1000000;
    for(int i=0;i<n;i++){
        if(mink>vp[i].second)mink=vp[i].second;
        buf[mink]+=(vp[i].first-vp[i+1].first)*((long long)(i+1));
    }
    for(int i=1;i<=n;i++){
        printf("%lld\n",buf[i]);
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*y/gcd(x,y);
}

int main(){
	ll N; cin>>N;
    vector<ll> A(N+1);
    vector<ll> L(N+1,0);
    vector<ll> R(N+2,0);
    rep1(i,N) cin>>A[i];
    rep1(i,N){
        L[i]=max(L[i-1],A[i]);
    }
    for(int i=N;i>=1;i--){
        R[i]=max(R[i+1],A[i]);
    }
    rep1(i,N){
        ll  ans=0;
        printf("%lld\n",max(L[i-1],R[i+1]));
    }
}

Measured memory_bytes: 6272
#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() {
    string s;
    cin >> s;
    int n = s.size();
    if(s[n-1] == '1'){
        cout << -1 << endl;
        return 0;
    }
    rep(i, n/2){
        if(s[i] != s[n-2-i]){
            cout << -1 << endl;
            return 0;
        }
    }
    if(s[0] == '0'){
        cout << -1 << endl;
        return 0;
    }

    int v = 1;
    rep(i, n-1){
        cout << v << ' ' << i + 2 << endl;
        if(s[i] == '1')v = i + 2;
    }
    
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define maxs 2020202
#define mme(i,j) memset(i,j,sizeof(i))
using namespace std;
vector<int>ed[maxs];
int n,m;

bool dfs(int u,int p,int k)
{
    if(k==0&&u==n)
        return 1;
    int sz =ed[u].size();
    for(int i=0;i<sz;i++)
    {
        int j = ed[u][i];
        if(j == p ) continue;
        if(dfs(j,u,k-1)) return 1;
    }
    return 0;
}

int main()
{
    while(~scanf("%d%d",&n,&m))
    {
        for(int i=0;i<=n;i++) ed[i].clear();

        int u,v;
        for(int i=0;i<m;i++)
        {
            scanf("%d%d",&u,&v);
            ed[u].push_back(v);
        }
        if(dfs(1,0,2))
            puts("POSSIBLE");
        else puts("IMPOSSIBLE");
    }
    return 0;
}

Measured memory_bytes: 51200
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,d[100005];
    cin>>n;
    for(int i=0;i<n;i++){
      cin>>d[i];
    }
    sort(d,d+n);
    if(d[n/2+n%2]-d[n/2+n%2-1]==0){
      cout<<"0"<<endl;
    }
    else
     cout<<d[n/2+n%2]-d[n/2+n%2-1]<<endl;
    return(0);
}

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

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

using namespace std;

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

    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N) cin >> a[i];
    vector<vector<int>> g(N);
    REP(i, N - 1) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    vector<int> dp(N, INT_MAX);
    vector<int> result(N);

    function<void(int, int)> dfs = [&](int u, int parent) {
        int k = distance(dp.begin(), lower_bound(all(dp), a[u]));
        int tmp = dp[k];
        dp[k] = a[u];

        result[u] = distance(dp.begin(), lower_bound(all(dp), INT_MAX));

        for (int v: g[u]) {
            if (v == parent) {
                continue;
            }
            dfs(v, u);
        }
      
        dp[k] = tmp;
    };

    constexpr int root = 0;

    dfs(root, -1);

    REP(i, N) {
        cout << result[i] << '\n';
    }
    cout << flush;

    return 0;
}


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

using namespace std;
#define DIM 100007
#define INF 2E60
#define MAXN 1023
#define LG 18
typedef int ll;
typedef long double ld;
typedef ll arr[DIM];
typedef vector<ll> vec;
typedef vector<ll> graph[DIM];
typedef pair<ll, ll> pll;
typedef pll parr[DIM];
struct pp {
	ll a, b;
	bool operator <(const pp& V)const {
		if (a == V.a)return b < V.b;
		return a < V.a;
	}
	bool operator ==(const pp& V)const {
		if (a == V.a && b == V.b)return 1;
		return 0;
	}
};


ll n,k;
arr A, B, C, DA, DB, DC;
int main()
{
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> A[i] >> B[i] >> C[i];
	for (int i = 1; i <= n; i++) {
		DA[i] = max(DB[i - 1], DC[i - 1]) + A[i];
		DB[i] = max(DC[i - 1], DA[i - 1]) + B[i];
		DC[i] = max(DA[i - 1], DB[i - 1]) + C[i];
	}
	cout << max(max(DA[n], DB[n]), DC[n]) << endl;

}
// 11
// 

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

#define int long long
#define mod 1000000007ll

int arr[200005],n;
int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
		cin>>n;
    int ways=1,c[n],t;
    for(int x=0;x<n;x++){
      cin>>c[x];
      if(x>0 && c[x]==c[x-1])continue;
      t=arr[c[x]];
      arr[c[x]]+=ways;
      arr[c[x]]%=mod;
      if(x==0 || c[x]!=c[x-1]){
        ways+=t;
        ways%=mod;
      }
    }
    cout<<ways;
    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int A, B;

void solve() {
	cin >> A >> B;
	if(A < 6) cout << 0 << "\n";
	else if(6 <= A && A <= 12) cout << B / 2 << "\n";
	else cout << B << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	int c,d;
	int x[a+1];
	for(int i=0;i<=a;i++) x[i] = 0;
	int maxv = 0;
	int maxp = 1;
	for(int i=0;i<b;i++){
		cin >> c >> d;
		x[c] += d;
		if(c==maxp){
			maxv = x[c];
			if(d<0){
				for(int j=1;j<=a;j++){
					if(j==maxp) continue;
					if(maxv==x[j] and j<maxp) maxp = j;
					else if(maxv<x[j]){
						maxv = x[j];
						maxp = j;
					}
				}
			}
		}
		else{
			if(maxv==x[c] and c<maxp) maxp = c;
			else if(maxv<x[c]){
				maxv = x[c];
				maxp = c;
			}
		}
		cout << maxp << " " << maxv << endl;
	}
}

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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../IO/io.h" 1
inline int readInt() {
    int v;
    int r = scanf("%d", &v);
    return v;
}

inline long long readLong() {
    long long v;
    int r = scanf("%lld", &v);
    return v;
}

inline vector<int> readVecInt(int n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = readInt();
    }
    return a;
}


inline void printLine(int v) {
    printf("%d\n", v);
}

inline void printLine(long long v) {
    printf("%lld\n", v);
}

inline void printLine(const vector<int> &a) {
    for (int v: a) {
        printf("%d ", v);
    }
    printf("\n");
}

inline void printLine(const string &s) {
    printf("%s\n", s.c_str());
}
# 5 "<stdin>" 2

int main() {
    int l = readInt();
    int r = readInt();
    int d = readInt();
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i%d == 0) {
            ans++;
        }
    }
    printLine(ans);
}


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

using namespace std;

int ans, N, W, w[100], v[100];
long long dp[110][100010];

int main(){
	cin >> N >> W;
	for(int i = 0; i < N; ++i) cin >> w[i] >> v[i];

	int maxv = N * 1000;
	for(int i = 0; i <= N; ++i) for(int j = 0; j <= maxv; ++j) dp[i][j] = 1e16;
	dp[0][0] = 0;

	for(int i = 0; i < N; ++i){
		for(int j = 0; j <= maxv; ++j){
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
			dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j]+w[i]);
		}
	}

	for(int j = 0; j <= maxv; ++j) if(dp[N][j] <= W) ans = j;

	cout << ans << endl;
}

Measured memory_bytes: 80128
#include<bits/stdc++.h>
using namespace std;
#define reg register
typedef long long ll;
#define MOD 998244353

const int MAXN=300+5;

inline int add(reg int a,reg int b){
	reg int sum=a+b;
	return sum>=MOD?sum-MOD:sum;
}

char S[MAXN];
int a[MAXN],K;
int dp[2][MAXN][MAXN];

int main(void){
	scanf("%s%d",S,&K);
	reg int n=strlen(S);
	int sum=0;
	reg int tot=0,cnt=0;
	for(reg int i=0;i<=n;++i)
		if(S[i]=='1')
			++cnt,++sum;
		else{
			a[++tot]=cnt;
			cnt=0;
		}
	reg int t=0;
	dp[0][0][0]=1;
	for(reg int i=tot;i>=1;--i){
		for(reg int j=0;j<=t;++j)
			for(reg int k=0;k<=t;++k){
				dp[1][j][k]=dp[0][j][k];
				dp[0][j][k]=0;
			}
		for(reg int j=0;j<=t;++j){
			dp[0][j][t]=dp[1][j][t];
			for(reg int k=t-1;k>=0;--k)
				dp[0][j][k]=add(dp[0][j][k+1],dp[1][j][k]);
		}
		for(reg int j=0;j<=t;++j)
			for(reg int k=0;k<=t;++k)
				for(reg int l=1;l<=a[i];++l)
					dp[0][j+l][k+l]=add(dp[0][j+l][k+l],dp[1][j][k]);
		t+=a[i];
	}
	reg int ans=0,Max=min(K,sum);
	for(reg int i=0;i<=Max;++i)
		ans=add(ans,dp[0][i][0]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4484
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
int t[59];
string s[59];
string z;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;

    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>s[i]>>t[i];
    }
    cin>>z;
    int sum=0;
    for(int i=n; i>=1; i--)
    {
        if(s[i]==z)
        {
            cout<<sum<<endl;
            return 0;
        }
        sum+=t[i];
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    int h,w;
    cin >> h >> w;
    map<pair<int,int>,int>mp;
    vector<int>a(h+1,0);
    vector<int>b(w+1,0);
    int m;cin >> m;
    int maxx = 0;int maxy = 0;
    for(int i = 0;i<m;i++){
        int x,y;cin >> x >> y;
        a[x]++; maxx = max(maxx,a[x]);
        b[y]++; maxy = max(maxy,b[y]);
        mp[{x,y}] = 1;
    }
    vector<int>idx;
    vector<int>idy;
    for(int i = 1;i<=h;i++) {
        if(a[i]==maxx) idx.push_back(i);
    }
    for(int i = 1;i<=w;i++){
        if(b[i]==maxy) idy.push_back(i);
    }
    for(int i = 0;i<idx.size();i++){
        for(int j = 0;j<idy.size();j++){
            int x = idx[i];int y = idy[j];
            if(mp[{x,y}]!=1) {
                cout << maxx+maxy;
                return;
            }
        }
    }
    cout << maxx+maxy-1;
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;
const ll mo=998244353;
const int NUM_=4400001;
static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];


ll comb(ll N_, ll C_) {
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:comb(P_+Q_-1,Q_);}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	
	ll ret=0;
	for(i=0;i<=min(N,M);i++) {
		int lef=3*M-i;
		if(lef%2) continue;
		lef=lef/2;
		ret+=comb(N,i)*hcomb(N,lef)%mo;
	}
	
	for(i=2*M+1;i<=3*M;i++) ret-=N*hcomb(N-1,3*M-i)%mo;
	
	
	cout<<(ret%mo+mo)%mo<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 103424
X=int(input())
N=0
if X<100:
    print("0")
elif X>=2000:
    print("1")
else:
    while N<21:
        res=X-100*N
        if res>5*N:
            count=0
            N+=1
            continue
        elif 0<=res and res<5*N+1:
            print('1')
            count=1
            break
        N+=1
    if count==0:
        print("0")

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


vector<int> e[200000];
ll num[200000];

void dfs(int i, int p){
  for(int j : e[i]) {
    if(j != p){
      num[j] += num[i];
      dfs(j,i);
    }
  }
}

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

  rep(i,n-1) {
    int a,b;
    cin >> a >> b;
    e[a-1].push_back(b-1);
    e[b-1].push_back(a-1);
  }
  rep(i,q){
    int p,x;
    cin >> p >> x;
    num[p-1] += x;
  }
  dfs(0,-1);
  rep(i,n) cout << num[i] << " ";
  
}


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

int gcd(int a, int b){
    if (a == b){
        return a;
    }
    else if (a > b){
        return gcd(a-b, b);
    }
    else{
        return gcd(a, b-a);
    }
}

int main(void) {
    long int K,i,j,k,m,sum = 0;
    scanf("%ld",&K);
     for (i=1;i<=K;++i){
       for (j=1;j<=K;++j){
       for (k=1;k<=K;++k){
    
    m = gcd(gcd(i,j),k);
    sum = sum + m;

    }
    }
    }
    printf("%ld\n",sum);
 
  
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;
ll cnt =0;

const int MAX = 510000;
unsigned ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
   for (int i = 2; i < MAX; i++){
     fac[i] = fac[i - 1] * i % MOD;
     inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
     finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算関数
long long comb(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
   string s;    cin >> s;
   for(int i=0;i<3;i++){
       if(s.at(i) == s.at(i+1)){
           cout << "Bad" << endl;
           return 0;
       }
   }
   cout << "Good" << endl;
   return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int y = sc.nextInt();

		for  (int i = n; i >= 0; i--) {
			for (int j = n - i; j >= 0; j--) {
				int k = n - i - j;
				int yen = 10000 * i + 5000 * j + 1000 * k;
				if (yen == y) {
					System.out.println(i + " "
							+ j + " "
							+ k);
					sc.close();
					return;
				}
			}
		}

		System.out.println("-1 -1 -1");

		sc.close();
	}
}


Measured memory_bytes: 24020
function Main(input){
  	var input = input.split(" ");
	var a = input[0];
	var b = input[1];

    if(a*b % 2 == 0){
      console.log("Even");
    }else {
      console.log("Odd");
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

using int64 = long long;
//const int mod = 1e9 + 7;
const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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...));
}

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

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

/**
 * @brief Union-Find
 * @docs docs/union-find.md
 */
struct UnionFind {
  vector< int > data;

  UnionFind() = default;

  explicit UnionFind(size_t sz) : data(sz, -1) {}

  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return false;
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return true;
  }

  int find(int k) {
    if(data[k] < 0) return (k);
    return data[k] = find(data[k]);
  }

  int size(int k) {
    return -data[find(k)];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind uf(N);
  while(M--) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    uf.unite(x, y);
  }
  int rot = 0;
  for(int i = 0; i < N; i++) rot += uf.find(i) == i;
  cout << rot - 1 << "\n";
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define rrep(i,a) for(int i=int(a)-1; i>=0;--i)
using ll = long long;
using namespace std;
int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll total = 0;
    rep(i,n) total+=a[i];
    ll cnt=2020202020;
    ll left = 0;
    rep(i,n){
        left+=a[i];
        ll right = total-left;
        cnt=min(cnt,abs(right-left));
    }
    cout<<cnt<<endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 1000000007 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
vll a;

// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> n >> m;
	cout<<abs((n-2)*(m-2));
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int n;
	cin >> n;
	map<ll,ll> mp;
	ll temp;
	rep(i,n) {
		cin >> temp;
		mp[temp]++;
	}
	for(auto itr=mp.begin(); itr != mp.end(); ++itr) {
		//cout << itr->first << " " << itr->second << endl;
		if (itr->second >= 2){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;


  return 0;
}


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

#define ll long long int
ll mod=1e9+7;

// vector<ll> g[200005];
// ll vis[200005];
// queue<ll> q;
// ll level[200005];

// void dfs(ll i)
// {
//     vis[i] = 1;
//     for(ll j=0;j<g[i].size();j++)
//     {
//         ll child = g[i][j];
//         if(vis[child] == 0)
//         {
//             dfs(child);
//         }
//     }
// }

// void bfs(ll i)
// {
//     vis[i] = 1;
//     while(!q.empty())
//     {
//         ll top = q.front();
//         ll len_adj = g[top].size();
//         ll j;
//         for(j=0;j<len_adj;j++)
//         {
//             ll v = g[top][j];
//             if(vis[v]==0)
//             {
//                 vis[v]=1;
//                 q.push(v);
//                 level[v] = level[top] + 1;
//             }
//         }   
//         q.pop();
//     }
// }

vector<ll> DecToBinary(ll num,ll trailing_zero, ll nbits)
{
    vector<ll> bits;
    while(num > 0)
    {
        bits.push_back(num%2);
        num /= 2;
    }

    if(trailing_zero == 1)
    {
        while(bits.size() < nbits)
        {
            bits.push_back(0);
        }
    }

    return bits;
}

long long int BinaryToDec(vector<ll> bits)
{
    ll number = 0;
    ll i;
    for(i=bits.size()-1;i>=0;i--)
    {
        number += (bits[i] * (long long)pow((ll)2 , i));
    }
    return number;
}

ll modular_exponentiation(ll base, ll power)
{
    ll ans = 1;
    base = base % mod;
    while (power > 0)
    {
        if (power & 1)
        {
            ans = (ans * base) % mod;
        }

        power /= 2;
        base = (base * base) % mod;
    }
    return ans;
}

int main()
{
    /* Faster input ouput */
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    /* To read input from a file and output to a file */
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    
    ll t = 1;
    // cin >> t;
    while(t--)
    {        
        ll n,i,j,k;
        cin >> n >> k;
        ll arr[n];

        for(i=0;i<n;i++)
        {
            cin >> arr[i];
        }

        sort(arr,arr+n);

        int ans = 0;
        for(i=0;i<k;i++)
        {
            ans += arr[i];
        }

        cout << ans << '\n';
    }
    
    return 0;
}

Measured memory_bytes: 3720
#include <stdio.h>

int main(){

  int n,a[100],i,minj,j,sub,cnt=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
      }
    }
    if(a[i]>a[minj]){
      sub=a[i];
      a[i]=a[minj];
      a[minj]=sub;
      cnt++;
    }
  }
  
  
  


  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%d\n",a[i]);
    }
    else {
      printf("%d ",a[i]);
    }
  }
  if(n==1){
    printf("0\n");
  }
  else {
    printf("%d\n",cnt);
  }
  return 0;
}

Measured memory_bytes: 608
N = int(input())
S = input()

def run(N, S):
    num_black= S.count('#')

    arr = []
    nSharp = 0
    nDot = 0
    flagDot = False
    if S[0] == '.':
        flagDot = True
    for i in S:
        if i == '#':
            if flagDot:
                arr.append((nSharp, nDot))
                flagDot = False
                nSharp = 0
                nDot = 0
            nSharp += 1
        else:
            flagDot = True
            nDot += 1
    arr.append((nSharp, nDot))    

    result = N - num_black
    min_result = result
    for i,val in enumerate(arr):
        result += val[0] - val[1]
        min_result = min(result, min_result)
        
    return min_result
        
print(run(N, S))

Measured memory_bytes: 10600
Y, M, D = map(str, input().split("/"))
if int(Y) > 2019:
    print("TBD")
elif int(Y) == 2019 and int(M) > 4:
    print("TBD")
elif int(Y) == 2019 and int(M) == 4 and int(D) == 31:
    print("TBD")
else:
    print("Heisei")

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

#define N 	2000000

using namespace std;

template<typename T_n>
int linearSearch(vector<T_n> &v, T_n key){
	int n = v.size();
	if(n == 0) return -1;
	int i = 0;
	while(v[i] != key){
		i++;
		if(i == n)
			return -1;
	}
	return i;
}

int binarySearch(vector<int> &v, int key){
	int left = 0;
	int right = v.size();
	while(left < right){
		int mid = (left + right) / 2;
		if(v[mid] == key)
			return mid;
		else {
			if(key < v[mid])
				right = mid;
			else left = mid + 1;
		}
	}
	return -1;
}

class hashTable
{
public:
	int hashSize1;
	int hashSize2;
	int interval;
	vector<int> table;

	hashTable(){
		hashSize1 = 2000000;
		hashSize2 = 1000;
		interval = hashSize1 / hashSize2;
		for(int i = 0; i < N; i++)
			table.push_back(0);
	};

	~hashTable(){
		table.clear();
	};

	void insert(string str);
	bool find(string str);
	int convertStr(string str);
};

void hashTable::insert(string str){
	int hash = convertStr(str);
	int num = (hash % hashSize2) * interval;
	while(table[num] != 0)
		num++;
	table[num] = hash;
}

bool hashTable::find(string str){
	int hash_key = convertStr(str);
	int num = (hash_key % hashSize2) * interval;
	while(num < hashSize1){
		if(table[num] == hash_key) return true;
		if(table[num] == 0) return false;
		num++;
	}
	return false;
}


int hashTable::convertStr(string str){
	int n = str.size();
	int hash = 0, d = 1;
	for(int i = 0; i < n; i++){	
		switch(str[i]){
			case 'A':
				hash += d;
				break;
			case 'C':
				hash += d * 2;
				break;
			case 'G':
				hash += d * 3;
				break;
			case 'T':
				hash += d * 4;
				break;
			default :
				break;
		}
		d *= 5;
	}
	return hash;
}

int main(){
	int n;
	string str,cmd;
	hashTable dict;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> cmd;
		cin >> str;
			if(cmd == "insert"){
				dict.insert(str);
			}
			if(cmd == "find"){
				// sort(hash_dict.begin(),hash_dict.end());
				cout << (dict.find(str)? "yes" : "no") << endl;
			}
	}
	return 0;
}

Measured memory_bytes: 11176
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long[] a = new long[s.length() + 1];
        Arrays.fill(a, -1);
        if (s.charAt(0) == '<') {
            a[0] = 0;
        }
        if (s.charAt(s.length() - 1) == '>') {
            a[s.length()] = 0;
        }
        for (int i = 1; i < s.length(); i++) {
            if (s.charAt(i) == '<' && s.charAt(i - 1) == '>') {
                a[i] = 0;
            }
        }
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '<') {
                a[i + 1] = a[i] + 1;
            }
        }
        for (int i = s.length() - 1; i >= 0; i--) {
            if (s.charAt(i) == '>') {
                if (a[i + 1] >= a[i]) {
                    a[i] = a[i + 1] + 1;
                }
            }
        }
        System.out.println(Arrays.stream(a).sum());
    }
}

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

using i64 = int64_t;

constexpr i64 MOD = 1e9 + 7;

i64 dp[2003][2003]={0};

int main(){
    int n, m;
    cin >> n >> m;
    vector<i64> s, t;
    for(int i=0;i<n;++i){
        i64 tmp;
        cin >> tmp;
        s.push_back(tmp);
    }
    for(int i=0;i<m;++i){
        i64 tmp;
        cin >> tmp;
        t.push_back(tmp);
    }

    for(int i=0;i<=n;++i)dp[i][0] = 1;
    for(int i=0;i<=m;++i)dp[0][i] = 1;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=m;++j){
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            dp[i][j] %= MOD;
            if(s[i-1] != t[j-1])dp[i][j] = (dp[i][j] - dp[i-1][j-1] + MOD) % MOD;
        }
    }

    cout << dp[n][m] << endl;

    return 0;
}


Measured memory_bytes: 31616