akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(read())


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

# i番目の要素とi+K番目の要素を比較すればok
N, K = ints()
A = ints()
ans = []
for i in range(N):
    if i + K == N:
        break
    if A[i] < A[i + K]:
        ans.append('Yes')
    else:
        ans.append('No')
print(*ans, sep='\n')


Measured memory_bytes: 109388
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

const int max_k = 160*80;
bool dp[81][81][max_k+1];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w;
  cin >> h >> w;
  vector< vector<int>> a(h, vector<int>(w));
  REP(i,h) REP(j,w) cin >> a[i][j];
  REP(i,h) REP(j,w){
    int b;
    cin >> b;
    a[i][j] = abs(a[i][j]-b);
  }
  REP(i,h) REP(j,w) REP(k,max_k+1) dp[i][j][k] = false;
  dp[0][1][0] = true;
	dp[1][0][0] = true;
 
	REP(i, h) REP(j, w) REP(k, max_k+1){
		int d = a[i][j];
 
		if(k + d <= max_k) dp[i+1][j+1][k + d] |= dp[i+1][j][k];
		if(abs(k - d) <= max_k) dp[i+1][j+1][abs(k - d)] |= dp[i+1][j][k];
		if(k + d <= max_k) dp[i+1][j+1][k + d] |= dp[i][j+1][k];
		if(abs(k - d) <= max_k) dp[i+1][j+1][abs(k - d)] |= dp[i][j+1][k];
 
	}
 
  REP(k, max_k+1){
    if(dp[h][w][k]){
      cout << k << '\n';
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 82304
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

struct Node{
  int key;
  struct Node *parent, *left, *right;
};

void insert(int);
struct Node * find(struct Node *,int);
void inorder(struct Node *);
void preorder(struct Node *);

struct Node *root,*NIL;

int main(){
  int m,i,x;
  char com[10];
  
  scanf("%d",&m);

  for(i=0;i<m;i++){
    scanf("%s",com);
    if(strcmp(com,"insert")==0){
      scanf("%d",&x);
      insert(x);
    }else if(strcmp(com,"find")==0){
      scanf("%d",&x);
      struct Node *t=find(root,x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }else if(strcmp(com,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}

void insert(int k){
  struct Node *y=NIL;
  struct Node *x=root;
  struct Node *z;

  z=(struct Node *)malloc(10*sizeof(struct Node *));
  z->key=k;
  z->left=NIL;
  z->right=NIL;

  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x=x->left;
    }else{
      x=x->right;
    }
  }
  
  z->parent=y;
  if(y==NIL){
    root=z;
  }else{
    if(z->key < y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}

struct Node * find(struct Node *u,int k){
  while(u!=NIL && k!=u->key){
    if(k< u->key) u=u->left;
    else u=u->right;
  }
  return u; 
}

void inorder(struct Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(struct Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


Measured memory_bytes: 39200
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    vector<LP> ba(n);
    rep(i, n) cin>>ba[i].se>>ba[i].fi;
    
    sort(rng(ba));
    ll t = 0;
    rep(i, n) {
        ll a = ba[i].se;
        ll b = ba[i].fi;
        t += a;
        if (t > b) {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3456
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		ArrayList<Integer> list = new ArrayList<Integer>();
		int number;

		while (true) {

			number = input();

			if (number != 0) {

				list.add(number);

			} else if (number == 0) {

				break;

			}
		}

		for (int i = 0; i < list.size(); i++) {

			System.out.println("Case " + (i + 1) + ": " + list.get(i));

		}

		close();

	}

	public static int input() {

		return Integer.parseInt(scanner.next());

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

Measured memory_bytes: 43304
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,L;
    cin >> N >> L;
    string S[110];
    rep(i,0,N) cin >> S[i];
    sort(S, S+N);
    rep(i,0,N){
        cout << S[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

std::vector<size_t> make_vector(size_t n, size_t x) {
  return std::vector<size_t>(n, x);
}

template <class Tp>
std::vector<Tp> make_vector(size_t n, const Tp& x) {
  return std::vector<Tp>(n, x);
}

template <class... Ts>
auto make_vector(size_t n, size_t m, const Ts&... x) {
  return std::vector<decltype(make_vector(m, x...))>(n, make_vector(m, x...));
}

int main() {
  size_t N;
  scanf("%zu", &N);

  char buf[4096];
  scanf("%s", buf);
  std::string s = buf;

  constexpr intmax_t mod = 1e9+7;

  auto dp = make_vector(N+1, N+1, intmax_t(0));
  for (size_t j = 0; j < N; ++j)
    dp[1][j] = 1;

  for (size_t i = 1; i < N; ++i) {
    if (s[i-1] == '<') {
      for (size_t j = 0; i+j <= N; ++j) {
        (dp[i+1][0] += dp[i][j]) %= mod;
        (dp[i+1][j] += mod - dp[i][j]) %= mod;
      }
    } else if (s[i-1] == '>') {
      for (size_t j = 0; i+j <= N; ++j) {
        (dp[i+1][j] += dp[i][j]) %= mod;
        (dp[i+1][N-i+1] += mod - dp[i][j]) %= mod;
      }
    }

    for (size_t j = 1; j < N; ++j)
      (dp[i+1][j] += dp[i+1][j-1]) %= mod;
  }

  printf("%jd\n", dp[N][0]);
}


Measured memory_bytes: 70656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	priority_queue<pair<int, int>,vector<pair<int,int>>,greater<pair<int,int>>> que;
	priority_queue<int> que1;
	int a, b;
	int ans = 0;
	int k = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		que.emplace(a, b);
	}
	for (int j = 1; j <= m; j++) {
		for (;;) {
			if (que.empty()) {
				break;
			}
			if (que.top().first > j) {
				break;
			}
			else {
				que1.push(que.top().second);
				que.pop();
			}
		}
		if (que1.empty()) {
			continue;
		}
		ans += que1.top();
		que1.pop();
	}
	cout << ans << endl;
	return 0;
}






Measured memory_bytes: 1908
n,k=map(int,input().split())
s=input()
A=[]
cur=s[0]
for i in range(1,n):
  if s[i]!=cur:
    A.append(i)
    cur=s[i]
A.append(n)
start,end=s[0],s[-1]
nn=len(A)
ans=0
if start=="0" and nn<=2*k:
  ans=n
elif start=="1" and nn<=2*k+1:
  ans=n
elif start=="0":
  ans=A[2*k-1]
  for i in range(1,nn//2-k+1):
    ans=max(ans,A[2*k-1+2*i]-A[2*i-2])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
else:
  ans=A[2*k]
  for i in range(1,(nn-1)//2-k+1):
    ans=max(ans,A[2*k+2*i]-A[2*i-1])
  if end=="0":
    ans=max(ans,A[-1]-A[-2*(k+1)+1])
print(ans)

Measured memory_bytes: 7168
#include<iostream>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll x, y;
    cin >> x >> y;
    if(abs(x-y) % 2 == 1){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << (abs(x-y) / 2) + min(x,y) << endl;
    return 0;
}


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

void bubbleSort (vector<int> A, int N){
    bool flag = true;
    int count = 0;
    while (flag == true){
        flag = false;
        for (int j = N-1; j > 0; j--){
            if (A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = true;
                count++; 
            }
        }
    }
    for (int i = 0; i < N; i++){
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    
}

int main(void){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];

    bubbleSort(A, N);

    
}


Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <bitset>
#include <iomanip>
#include <deque>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
    int a;

    cin >> a;

    if (a < 1200) {
        cout << "ABC" << endl;
    }
    else if (a < 2800) {
        cout << "ARC" << endl;
    }
    else {
        cout << "AGC" << endl;
    }
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] args)throws Exception {

		   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	        while(true){
	        	String line = br.readLine();
	        	//文字列に先頭又は最後に空白文字がくっ付いている場合、それらを全て取り除く。
	        	line = line.trim();
	        	//半角スペースを区切り文字として扱う
	        	String[] readLineArray = line.split("[\\s+]");
	        	//変数に配列を代入
	        	int a = Integer.parseInt(readLineArray[0]);
	        	int b = Integer.parseInt(readLineArray[1]);
	        	if(a == 0 && b == 0){
	        		break;
	        	}
	        	for(int i = 0;i < a;i++){
	        		for(int j = 0;j < b; j++){
	        			System.out.printf("#");
	        		}
	        		System.out.printf("\n");
	        	}
	        	System.out.printf("\n");
	        	
	        }

	}

}

Measured memory_bytes: 46288
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cstdio>
using namespace std;
typedef long long ll;
 
int main() {
	ios_base::sync_with_stdio(false);
	int h,w;
	cin>>h>>w;
	int a[10][10];
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++)
			cin>>a[i][j];
	}
	int b[10];
	b[0]=a[0][1];
	b[1]=0;
	for(int i=2;i<10;i++){
		b[i]=a[i][1];	
	}
	for(int k=0;k<100;k++){
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				if(b[i]+a[j][i]<b[j]){
					b[j]=b[i]+a[j][i];
				}
			}
		}
	}
	
	ll sum=0;
	int c[300][300];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
			if(c[i][j]==-1){}
			else
				sum+=b[c[i][j]];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    for(int i=0;i<n;i++){
        cout << s[i];
        cout << t[i];
    }
}   

Measured memory_bytes: 256
a=int(input())
b=int(input())
c=int(input())
x=int(input())
count=0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(500*i+100*j+50*k==x):
                count+=1
print(count)

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


int main()
{
	int a, b,c,d;
	cin >> a >> b >> c >> d;
	cout << (abs(a-c) <= d ? "Yes" : (abs(a-b) <= d && abs(b-c) <= d ? "Yes" : "No"))<< endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, W = map(int, input().split())
vmax = 1000*100+1
wmax = 100*10**9
dp = [wmax] * vmax
dp[0] = 0
 
for i in range(N):
    wi, vi = map(int, input().split())
    ndp = dp[:]
    for j in range(vi, vmax):
        ndp[j] = min(dp[j], dp[j-vi] + wi)
    dp = ndp

v = 0
for i, w in enumerate(dp):    
    if w == wmax:
        continue
    if w <= W:
        v = i
print(v)

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

using namespace std;


int main() {
	int n, k;
	cin >> n >> k;
	vector<vector<int>> dp(n, vector<int>(k, 0));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < k; j++) {
			if (i == 0) dp[i][j] = 1;
			else {
				for (int l = 0; l < k; l++) {
					if (j != l) dp[i][l] += dp[i - 1][j];
				}
			}
		}
	}
	int res = 0;
	for (int i = 0; i < k; i++) {
		res += dp[n - 1][i];
	}

	cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 vector <int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 int n;
  cin >> n;
  cout << v.at(n-1);
}


Measured memory_bytes: 256
N = int(input())
T = []
L = []
for i in range(0,N):
    S = str(input())
    L.append(S)

L = sorted(L)
k = 0
T.append([L[0],1])  
for i in range(1,N):
    for j in range(k,len(T)):
        if L[i] == T[j][0]:
            T[j][1] += 1
        else:
            k = j + 1
            T.append([L[i],1])
            break

Max = 0
for i in range(0,len(T)):
    if T[i][1] > Max:
        Max = T[i][1]

ans = []
for i in range(0,len(T)):
    if T[i][1] == Max:
        ans.append(T[i][0])

ans = sorted(ans)

for i in range(0,len(ans)):
    print(ans[i])

Measured memory_bytes: 43012
#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;

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;

#define DE 1
#define FI first
#define SE second
#define PB push_back
#define MP make_pair
#define ALL(s) (s).begin(),(s).end()
#define REP(i,n) for (int i = 0; i < (int)(n); ++i)
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

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) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}


const int MAX = 100100;
int N, W;
int con[MAX];

int main() {
    //freopen( "/Users/macuser/Documents/Programming/Contest/input.in", "r", stdin );
    
    while (cin >> N >> W) {
        memset(con, 0, sizeof(con));
        int geta = (W-1)/2;
        for (int d = (W+1)/2; d <= W-1; ++d) {
            con[1]++; con[d+1]--;
            for (int i = 2; i*d <= N; ++i) {
                int left = (i+1)*d-W+1, right = i*d;
                con[left]++; con[right+1]--;
            }
        }
         
        for (int i = 1; i <= N-W+1; ++i) {
            con[i+1] += con[i];
            int res = geta + con[i] + min(i, W);
            //cout << i << " : " << geta << ", " << con[i] << ", " << res << endl;
            cout << res;
            if (i != N-W+1) cout << " ";
        }
        cout << endl;
    }
    
    return 0;
}


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define fst first
#define snd second

typedef long long ll;

const int N = 3e5;

#define oper max
#define NEUT 0
struct STree { // segment tree for min over integers
	vector<ll> st;int n;
	STree(int n): st(4*n+5,NEUT), n(n) {}
	void init(int k, int s, int e, int *a){
		if(s+1==e){st[k]=a[s];return;}
		int m=(s+e)/2;
		init(2*k,s,m,a);init(2*k+1,m,e,a);
		st[k]=oper(st[2*k],st[2*k+1]);
	}
	void upd(int k, int s, int e, int p, ll v){
		if(s+1==e){st[k]=v;return;}
		int m=(s+e)/2;
		if(p<m)upd(2*k,s,m,p,v);
		else upd(2*k+1,m,e,p,v);
		st[k]=oper(st[2*k],st[2*k+1]);
	}
	ll query(int k, int s, int e, int a, int b){
		if(s>=b||e<=a)return NEUT;
		if(s>=a&&e<=b)return st[k];
		int m=(s+e)/2;
		return oper(query(2*k,s,m,a,b),query(2*k+1,m,e,a,b));
	}
	void init(int *a){init(1,0,n,a);}
	void upd(int p, ll v){upd(1,0,n,p,v);}
	ll query(int a, int b){return query(1,0,n,a,b);}
}; // usage: STree rmq(n);rmq.init(x);rmq.upd(i,v);rmq.query(s,e);

int main() {
    int n;
    cin >> n;
    ll h[n], a[n];
    fore(i, 0, n) cin >> h[i];
    fore(i, 0, n) cin >> a[i];
    STree rmq(n + 1);
    fore(i, 0, n) {
        ll q = rmq.query(1, h[i]);
        rmq.upd(h[i], q + a[i]);
    }
    cout << rmq.query(0, n + 1) << endl;
}

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

#define int long long

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

	int x, n;
	cin >> x >> n;

	int p[n];
	for (int i = 0; i < n; ++i) cin >> p[i];

	sort(p, p + n);

	auto it = lower_bound(p, p + n, x);
	int min_diff1 = 0;
	for (auto it1 = lower_bound(p, p + n, x); it1 != p + n; ++it1) {
		if (*it1 - x != min_diff1) break;
		++min_diff1;
	}
	int min_diff2 = 0;
	for (auto it2 = *it == x ? it : prev(it); it2 != p - 1; --it2) {
		if (x - *it2 != min_diff2) break;
		++min_diff2;
	}
	if (min_diff1 < min_diff2)
		cout << x + min_diff1;
	else
		cout << x - min_diff2;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

typedef long long i64;

int main() {
  i64 result = 0, N, M;
  scanf("%lld%lld", &N, &M);
  if (N > M) swap(N, M);
  if (N == 1) {
    if (M == 1) puts("1");
    else printf("%d\n", M - 2);
  } else {
    result = (N - 2) * (M - 2);
    printf("%lld\n", result);
  }
  
  return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 0 && x % 5 && x % 3) {
            cout << "DENIED";
            return;
        }
    }
    cout << "APPROVED";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans += a[i] - 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>

using namespace std;

int main(){
	vector< pair<char,int> >v;
	char str[1000002];
	scanf("%s",str);
	int a;
	for(int i=0;str[i]!='\0';i++){
		char n = str[i];
		a = 1;
		while(str[i+1] == n){
			i++;
			a++;
		}
		v.push_back( make_pair(n,a) );
	}
	int ans = 0;
	int j,o,i;
	for(int k=1;k<v.size()-1;k++){
	    if(v[k].first == 'O' && v[k-1].first == 'J' && v[k+1].first == 'I'){
	    	j = v[k-1].second;
	    	o = v[k].second;
	    	i = v[k+1].second;
	    	if(j >= o && i >= o){
	    		a = min(j,min(o,i));
	    		if(a > ans){
	    			ans = a;
	    		}
	    	}
	    }
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>

using namespace std;
 
int main() {
  int N;
  cin >> N;

  vector<int> a(N);
  int sum=0;
  int now=1;
  int bef;

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

  while(a[now-1] != 0 && a[now-1] != 2){
    bef = now;
    now = a[now-1];
    a[bef-1] = 0; 
    sum++;
  }

  if (a[now-1] == 0) sum = -1;
  else sum++;
  cout << sum << endl;

}

Measured memory_bytes: 640
package main

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

func main() {
	scanInit()

	n := nextInt()

	maxs := 0
	for i := 1; i*i <= n; i++ {
		maxs = i * i
	}

	fmt.Println(maxs)

}

// ---- readfunc
var sc = bufio.NewScanner(os.Stdin)

func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int D,T,S;cin>>D>>T>>S;
    if(D<=T*S){
        cout<<"Yes"<<endl;
    }
    else{
        cout<< "No"     <<endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: [chars],
    }
    let mut hm = HashMap::new();
    for s in s {
        *hm.entry(s).or_insert(0) += 1;
    }
    let mut k: Vec<_> = hm.into_iter().map(|(s, v)| (-v, s)).collect();
    k.sort();
    let ma = k[0].0;
    for (a, b) in k {
        if a == ma {
            puts!("{}\n", b.into_iter().collect::<String>());
        }
    }
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 40716
w = list(input())

alpha = list("abcdefghijklmnopqrstuvwxyz")
count = [0] * len(alpha)

for i in w:
  for index,j in enumerate(alpha):
    if i ==j:
      count[index] += 1

odd = "Yes"
for i in count:
  if i % 2 == 1:
    odd = "No"
    break
print(odd)

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

int main()
{
  int x=0,a[150],k,N;
  char S[150];
  cin>>N;
  cin>>S;
  a[0]=0;
  for(int i=0; i<N; i++)
  {
    if(S[i]=='I')
     x++;
    else if(S[i]=='D')
     x--;
    a[i+1]=x;
  }
  k=a[0];
  for (int i=1; i<N+1;i++)
  {
    if(k<a[i])
     k=a[i];
  }
  cout<<k;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll cnt = 0;
  string s;
  cin >> s;
  for (ll i = 0; i < s.length(); ++i)
  {
    if (s[i] != s[s.length() - i - 1])
    {
      s[s.length() - i - 1] = s[i];
      ++cnt;
    }
  }
  cout << cnt;
}


Measured memory_bytes: 3624
from sys import stdin
from collections import deque

def dfs(ny,nx):
    d=deque([[ny,nx]])
    count=0
    while len(d)>0:
        now=d.pop()
        count+=1
        for dy,dx in (-1,0),(1,0),(0,-1),(0,1):
            y=now[0]+dy
            x=now[1]+dx
            if 0<=y<H and 0<=x<W:
                if flags[y][x]==False and grid[y][x]=="#":
                    d.append([y,x])
                flags[y][x]=True
    return count

#入力
readline=stdin.readline
H,W=map(int,readline().split())
grid=[]
for i in range(H):
    s=readline().strip()
    grid.append(s)

flags=[[False]*W for _ in range(H)]
answer=True
for y in range(H):
    for x in range(W):
        if flags[y][x]==True:
            continue
        elif grid[y][x]==".":
            flags[y][x]=True
        elif grid[y][x]=="#":
            flags[y][x]=True
            res=dfs(y,x)
            if res==1:
                answer=False
                break
    if answer==False:
        break

if answer: print("Yes")
else: print("No")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

int main() {
  double a, b, h;
  cin >> a >> b >> h;
  cout << ((a+b)*h / 2) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, m;

    cin >> n >> m;

    vector<ll> sum(n + 1, 0);

    ll ans = 0;

    int l, r;

    for (int i = 0; i < m; i++)
    {
        cin >> l >> r;
        l--;
        sum[l] += 1;
        sum[r] += -1;
    }

    for (int i = 0; i < n; i++)
    {
        sum[i + 1] += sum[i];

        if (sum[i] == m)
        {
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
  int change, rest, price, i, value[] = {500, 100, 50, 10, 5, 1};
 
  while(1){
    scanf("%d", &price);
    if(price == 0) break;

    change = 1000 - price;
    i = rest = 0;
    while(change != 0){
      if(change - value[i] >= 0){
	change -= value[i];
	rest++;
      }else
	i++;
    }
    printf("%d\n", rest);
  }
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int w,a,b; cin >> w >> a >> b;
    int l = min(a,b);
    int r = max(a,b);
    cout << max(r-(l+w),0) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int input = scan.nextInt();
		int n = 0;
		if(input >= 1 && input <= 20)n = input;
		int a = Integer.MAX_VALUE;
		int v = Integer.MIN_VALUE;

		for(int i = 0 ; i < n ; i++) {
			int num = scan.nextInt();
			int fishNum = scan.nextInt();
			if(fishNum > v) {
				v = fishNum;
				a = num;
			}else if(fishNum == v) {
				a = Integer.min(a, num);
			}
		}
		System.out.println(a + " " + v);
		scan.close();
	}

}



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

ll n,m;
vector<ll>gr[100005];
bool vis[200005]; 
ll dp[200005];
ll mod=1000000007;
 ll dfs(ll node){
 	ll ans=0;
 	vis[node]=1;
 	for(ll i=0;i<gr[node].size();i++){
 		if(!vis[gr[node][i]]){
 		//	cout<<node<<' '<<gr[node][i]<<'\n';
 			ans=max(ans,1+dfs(gr[node][i]));
 		}
 		else{
 			ans=max(ans,1+dp[gr[node][i]]);
 		}
 		
 			
 		//};
 	}
 	dp[node]=ans;
 	return ans;
 }
 
int main(){
	//ll n,m;
	ll h,w;
	cin>>h>>w;
	char terr[h+1][w+1];
	ll dp[h+1][w+1];
	
	for(ll i=1;i<=h;i++){
		for(ll j=1;j<=w;j++){
			cin>>terr[i][j];
			dp[i][j]=0;
		}
	}
	for(ll i=0;i<=h;i++){
		dp[i][0]=0;
	}
	for(ll i=0;i<=w;i++){
		dp[0][i]=0;
	}
	dp[1][1]=1;
	for(ll i=1;i<=h;i++){
		for(ll j=1;j<=w;j++){
			if(i-1>0){
				if(terr[i][j]=='.'){
					dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
				}
				
			}
			if(j-1>0){
				if(terr[i][j]=='.'){
					dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
				}
				
			}
			dp[i][j]%=mod;
			
			//cout<<dp[i][j]<<' ';
		}
	//	cout<<'\n';
	}
	cout<<dp[h][w];
	
}

Measured memory_bytes: 11392
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN=300005,MAXL=28;
 
int n;
int A[MAXN],B[MAXN];
int a[MAXN],b[MAXN];
 
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",A+i);
	for(int i=1;i<=n;i++)
		scanf("%d",B+i);
	
	int ans=0;
	for(int k=0;k<=MAXL;k++)
	{
		memcpy(a,A,sizeof(int)*(n+1));
		memcpy(b,B,sizeof(int)*(n+1));
		int T=1<<k;
		for(int i=1;i<=n;i++)
		{
			a[i]%=2*T;
			b[i]%=2*T;
		}
		sort(b+1,b+n+1);
		int res=0;
		for(int i=1;i<=n;i++)
		{
			int *l=lower_bound(b+1,b+n+1,T-a[i]);
			int *r=lower_bound(b+1,b+n+1,T*2-a[i]);
			res^=((r-l)&1);
		}
		for(int i=1;i<=n;i++)
		{
			int *l=lower_bound(b+1,b+n+1,T*3-a[i]);
			int *r=lower_bound(b+1,b+n+1,T*4-a[i]);
			res^=((r-l)&1);
		}
		if(res)
			ans^=T;
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 3968
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
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; }
const long long mod = 1e9 + 7;
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
vector<vector<ll>> s(23, vector<ll>(23, mod));
vector<vector<ll>> d(23, vector<ll>(23, mod));
ll cnt = 0, dx[] = { 1, 0 , -1,  0 }, dy[] = { 0, 1, 0, -1 }, h, w;
void bfs(ll a, ll b);

int main() {
	cin >> h >> w;

	char tmp;

	repl(i, 1, h + 1){
		repl(j, 1, w + 1) {
			cin >> tmp;
			if (tmp == '.') s[i][j] = 0;
		}
	}

	repl(i, 1, h + 1) {
		repl(j, 1, w + 1) {
			bfs(i, j);
		}
	}

	cout << cnt;

	return 0;
}

void bfs(ll a, ll b) {
	queue<P> que;
	
	if (s[a][b] != 0) return;

	rep(i, 23) {
		rep(j, 23) {
			d[i][j] = mod;
		}
	}

	que.push(P(a, b));
	d[a][b] = 0;

	while (que.size()) {
		P p = que.front();
		que.pop();

		rep(i, 4) {
			rep(i, 4) {
				ll nx = p.first + dx[i];
				ll ny = p.second + dy[i];
				if (s[nx][ny] == 0 && d[nx][ny] == mod) {
					que.push(P(nx, ny));
					d[nx][ny] = d[p.first][p.second] + 1;
					cnt = max(cnt, d[nx][ny]);
				}
			}
		}
	}
}


ll gcd(ll a, ll b) {
	if (a % b == 0)return(b);
	else return(gcd(b, a % b));
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

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

int main(){
	int n, q;
	cin >> n;
	int S[n];
	for(int i = 0; i < n; i++){
		cin >> S[i];
	}
	cin >> q;
	int T[q];
	for(int i = 0; i < q; i++){
		cin >> T[i];
	}
	int count = 0;
	for(int i = 0; i < q; i++){
		for(int j = 0; j < n; j++){
			if(S[j] == T[i]){
				count++;
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3580
s = input()		# 文字列の入力  abcdefg...

ans="hon"
if s[-1]=="3": ans = "bon"

if s[-1]=="0": ans = "pon"
if s[-1]=="1": ans = "pon"
if s[-1]=="6": ans = "pon"
if s[-1]=="8": ans = "pon"

print(ans)


Measured memory_bytes: 8980
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	int L[3000];

	cin >> N;
	rep(i, 0, N)
	{
		cin >> L[i];
	}
	sort(L, L + N);

	int ans = 0;
	rep(i, 0, N)
	{
		rep(j, i + 1, N)
		{
			ans += lower_bound(L + j + 1, L + N, L[i] + L[j]) - (L + j + 1);
		}
	}

	cout << ans << endl;

	return 0;
}

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

#include <map>
using std::map;

#include <string>
using std::string;

int main()
{
    ll n;
    cin >> n;
    map<ll, ll> score;
    vector<ll> data(n);
    for (int i = 0; i < n; i++)
    {
        ll a;
        cin >> a;
        score[a] += 1;
        data[i] = a;
    }

    ll count = 0;
    for (auto x : score)
    {
        ll v = x.second;
        ll u = x.first;

        count += v * (v - 1) / 2;
    }
    for (ll s : data)
    {
        ll count1 = count;
        ll u = score[s];
        count1 -= u * (u - 1) / 2;
        count1 += (u - 1) * (u - 2) / 2;
        cout << count1 << endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

int main(){
	int N;
	cin >> N;
	vector<int> a(N);
	for(int i=0; i<N; i++){
		scanf("%d", &a[i]);
	}
	a.push_back(0);
	a.push_back(1e9);
	sort(a.begin(), a.end());

	vector<long long> sum(N+2,0);
	for(int i=1; i<N+2; i++){
		sum[i] = sum[i-1] + a[i];
	}

	int M;
	cin >> M;
	vector<int> b(M);
	for(int i=0; i<M; i++){
		scanf("%d", &b[i]);
	}
	
	vector<long long> c(M);
	for(int i=0; i<M; i++){
		scanf("%lld", &c[i]);
	}

	for(int i=0; i<M; i++){
		int pos = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
		pos--;
		//cerr << i << " : " << sum[pos] << endl;
		if(c[i] <= sum[pos]){
			puts("Yes");
		}else{
			puts("No");
		}
	}

	return 0;
}

Measured memory_bytes: 7864
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int VMAX =1e5+10;
vector<vector<int> >G(VMAX);

int dfs(int v, int p){
  int ret = 0;
  for(const int& u:G[v]){
    if(u==p)continue;
    ret ^= dfs(u,v)+1;
  }
  return ret;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int V;cin >> V;
  rep(i,V-1){
    int x,y;cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  if(dfs(1,-1))cout << "Alice" << endl;
  else cout << "Bob" << endl;
  return 0;
}


Measured memory_bytes: 10368
$>.sync=gets;S='? '+?0*N=200;*A=?!;N.times{|i|S[i+2]=?1;i.times{|j|S[j+2]=?1;puts S;S[j+2]=?0;gets=="1
"&&A<<"(#{i},#{j})"};S[i+2]=?0};puts A*?\s

Measured memory_bytes: 3152
#include <stdio.h>
#include <time.h>

int main(){
	int a,b,c,d;
	int x[256],y[256];
	int p=1;
	int cc;
	
	scanf("%d %d %d",&a,&b,&d);
	
	c=a;
	if(a>b){
	c=b;
	}
	
	x[0]=1;
	for(int i=2;i<=c;i++){
		if(a%i==0&&b%i==0){
			x[p]=i;
			p++;
		}
	}
	cc=p;
	p--;
	
	for(int i=0;i<cc;i++){
		y[i]=x[p];
		p--;
	}
	
	printf("%d",y[d-1]);
	
	return 0;
}

Measured memory_bytes: 128
s = [input() for i in range(2)]
N = int(s[0])
A = [int(i) for i in s[1].split()]

for i in range(N):
    N = 0
    while A[i] % 2 == 0:
         A[i] = A[i] / 2
         N += 1
    A[i] = N

print(min(A))

Measured memory_bytes: 3060
a, b, c, x, y=map(int, input().split())
f=False
if 2*c < a+b:
    f = True
if f:
    if x>y:
        print(2*y*c+(x-y)*min(a,2*c))
    else:
        print(2*x*c+(y-x)*min(b,2*c))
else:
    print(a*x+b*y)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int a, b, c, x, y, z;
int ans;

int main() {
	int n, r;
	cin >> n >> r;
	if (10 <= n) {
		ans = r;
	}
	else {
		ans = r+(100 * (10 - n));
	}
	cout << ans << endl;
	return 0;
}


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

int main(void) {
      int n;
      cin >> n;
      int ans[n];
      for (int i = 0; i < n; i++) {
            int ai;
            cin >> ai;
            ans[ai - 1] = i + 1;
      }
      for (int i = 0; i < n; i++) {
            cout << ans[i] <<' ';
      }
      cout << endl;
      return 0;
}


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

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_V(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_M(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}

int h, w;

int main() {
    cin >> h >> w;
    V<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    V<V<ll>> tate(h, V<ll>(w, 0)), yoko(h, V<ll>(w, 0));
    for (int i = 0; i < h; ++i) {
        int sum = 0;
        int st = 0;
        for (int j = 0; j < w; ++j) {
            if (grid[i][j] == '#' or j==w-1) {
                if(j==w-1)if(grid[i][j]=='.')sum++;

                if(!(j==w-1 && grid[i][j]=='.')){
                    tate[i][j] -= sum;
                }

                tate[i][st] += sum;
                st = j + 1;
                if(st==w)break;
                sum = 0;
            } else {
                sum++;
            }
        }
    }

    for (int i = 0; i < w; ++i) {
        int sum = 0;
        int st = 0;
        for (int j = 0; j < h; ++j) {
            if (grid[j][i] == '#' or j==h-1) {
                if(j==h-1){
                    if(grid[j][i]=='.')sum++;
                }

                if(!(j==h-1 && grid[j][i]=='.')){
                    yoko[j][i] -= sum;
                }

                yoko[st][i] += sum;
                st = j + 1;
                if(st==h)break;
                sum = 0;
            } else {
                sum++;
            }
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 1; j < w; ++j) {
            tate[i][j] += tate[i][j - 1];
        }
    }
    for (int i = 0; i < w; ++i) {
        for (int j = 1; j < h; ++j) {
            yoko[j][i] += yoko[j - 1][i];
        }
    }

    ll ans = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            ans = max(ans, (ll)tate[i][j] + yoko[i][j]-1);
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 67072
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
{
        printf("a < b");
}
    if(a>b)
{
        printf("a > b");
}
    if(a==b) 
{
    printf("a == b");
}
    printf("\n");
    return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;

#define rep(i,N) for (int i = 0; i < N; i++)
#define llong long long
#define ldouble long double

int N;
vector<vector<pair<int,int>>> table;

int getNinnzuu(int bit) {
    int count = 0;
    while(bit) {
        if (bit & 1) count++;
        bit /= 2;
    }
    return count;
}

int main() {
    cin >> N; table.resize(N);
    rep(i,N) {
        int a; cin >> a;
        table[i].resize(a);
        rep(j,a) {
            int x, y;
            cin >> x >> y;
            x--;
            table[i][j] = make_pair(x, y);
        }
    }
    int res = 0;
    for (int bit = 0; bit < (1 << N); bit++) {
        bitset<20> bits(bit);
        int flag = 1;
        rep(i,N) {
            if (!bits.test(i)) continue;
            rep(j,table[i].size()) {
                if (bits.test(table[i][j].first) != table[i][j].second) {
                    flag = 0;
                }
            }
        }
        if (flag) res = max(res, getNinnzuu(bit));
    }
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;



int main(){FIN

    ll n; string s;
    cin>>n>>s;
    ll ans=mod;
    vll ws(1,0); vll es(1,0);
    ll cnt=0;
    FOR(i,1,n-1){
        
        if(s[i-1]=='W') cnt++;
        ws.push_back(cnt);
    }
    cnt=0;
    FORR(i,n-2,0){
        
        if(s[i+1]=='E') cnt++;
        es.push_back(cnt);
    }
    reverse(ALL(es));
    // REP(i,n){
    //     cout<<ws[i]<<endl;
    // }
    REP(i,n){
        ans = min(ans, es[i]+ws[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12676
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define F first
#define S second
#define N 500000
#define INF 2e9
typedef pair<int, int> P;
int V, E, r;
vector<P> path[500000];
int flag[100000];
int dijkstra(int s){
    for(int i = 0; i < V; i++){
        flag[i] = -INF;
    }
    priority_queue<P> pq;
    pq.push(MP(0, s));
    while(!pq.empty()){
        P p = pq.top();
        pq.pop();
        if(flag[p.S] > p.F){
            continue;
        }
        flag[p.S] = p.F;
        for(auto i = path[p.S].begin(); i != path[p.S].end(); i++){

            if(flag[(*i).F] == -INF){
                pq.push(MP(p.F + (*i).S, (*i).F));
            }
        }
    }
}
int main(){
    cin >> V >> E >> r;
    for(int i = 0; i < E; i++){
        int temp, temp2, temp3;
        cin >> temp >> temp2 >> temp3;
        path[temp].push_back(MP(temp2, -temp3));
    }
    dijkstra(r);
    for(int i = 0; i < V; i++){
        if(flag[i] == -INF){
            cout << "INF" << endl;
        }
        else{
            cout << -flag[i] << endl;
        }
    }
}


Measured memory_bytes: 23436
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
int x;
int _5(int now)
{
	return now*now*now*now*now;
}
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>x;
	for(int i=-200;i<=200;++i)
	{
		for(int j=-200;j<=200;++j)
		{
			if(_5(i)-_5(j)==x)
			{
				cout<<i<<' '<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3612
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
s = input()

print(s[0], end="")
print(len(s)-2, end="")
print(s[-1])

Measured memory_bytes: 5192