akhauriyash/Code-Regression huggingface dataset:
#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 NMAX = 1e5+10;
vector<vector<int> > G(NMAX);
vector<vector<int> > Tree(NMAX);
vector<PII> edge(NMAX);
vector<int> num(NMAX,0);
vector<int> parent(NMAX,0);

int searchRoute(int v){
  if(G[v].size()==0)return v;
  return searchRoute(G[v][0]);
}

void bfs(int v){
  queue<int> que;
  que.push(v);
  while(!que.empty()){
    v = que.front();que.pop();
    for(const int& u:Tree[v]){
      if(num[u] == 1){
        parent[u] = v;
        que.push(u);
      }else --num[u];
    }
  }
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  rep(i,N-1+M){
    int f,t;cin >> f >> t;
    Tree[f].push_back(t);
    G[t].push_back(f);
    ++num[t];
  }
  int route = searchRoute(1);
  Tree[0].push_back(route);
  ++num[route];
  bfs(0);
  repp(v,1,N+1) cout << parent[v] << endl;
  return 0;
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if ((a%2 == 0) || (b%2 == 0)) {
    cout << "Even" << endl;
  }
  else{
    cout << "Odd" <<endl;
  }
  
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(int (i)=(a-1);(i)>=(b);(i)--)
#define ALL(x) (x).begin(), (x).end()
const int INF = 1e18;
const int MOD = 1e9+7;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<string> vstr;
void print() {cout<<endl;}template<class Head,class...Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template<class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template<class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}
template<class T=int>T in(){T x;cin>>x;return(x);}
template<class T=int>vector<T> input_to_vector(int n){vector<T>x;REP(i,n){T a;cin>>a;x.push_back(a);}return(x);}

signed main(){
    int n = in();
    vint L = input_to_vector(n);
    sort(ALL(L));
    int ans = 0;
    REP(i, n-2){
        FOR(j, i+1, n-1){
            FOR(k, j+1, n){
                int a = L[i], b = L[j], c = L[k];
                if (a < b + c and b < a + c and c < a + b)
                    ans++;
            }
        }
    }
    print(ans);
}

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

int main()
{
    int a[4];
    string str;
    stack<char> s;
    
    while( getline( cin, str ) )
    {
        if( str == "." )
            break;

        while( !s.empty() )
            s.pop();

        bool j = true;
        for( int i = 0; i < str.size(); i++ )
        {
            if( str[i] == '(' )
                s.push('(');
            else if( str[i] == ')' && s.empty() == true )
            {
                j = false;
                break;
            }
            else if( str[i] == ')' && s.top() == '(' )
                s.pop();
            else if( str[i] == ')' && s.top() != '(' )
            {
                j = false;
                break;
            }
            else if( str[i] == '[' )
                s.push('[');
            else if( str[i] == ']' && s.empty() == true )
            {
                j = false;
                break;
            }
            else if( str[i] == ']' && s.top() == '[' )
                s.pop();
            else if( str[i] == ']' && s.top() != '[' )
            {
                j = false;
                break;
            }
            else;
        }
        if( j == true && s.empty() == true )
            cout << "yes" << endl;
        else
            cout << "no" << endl; 
    }
        return 0;
}



Measured memory_bytes: 3120
import math
#####segfunc#####
def segfunc(x, y):
    if x*y == 0:
        return max(x,y)
    return math.gcd(x,y)
#################

#####ide_ele　単位元#####
ide_ele = 0
#################



class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        """
        init_val: 配列の初期値
        segfunc: 区間にしたい操作
        ide_ele: 単位元
        n: 要素数
        num: n以上の最小の2のべき乗
        tree: セグメント木(1-index)
        """
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        """
        k番目の値をxに更新
        k: index(0-index)
        x: update value
        """
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        """
        [l, r)のsegfuncしたものを得る
        l: index(0-index)
        r: index(0-index)
        """
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

"""使用例"""

n=int(input())
A=[int(i) for i in input().split()]
tre=SegTree([0 for i in range(n)],segfunc,ide_ele)
for i in range(n):
    tre.update(i,A[i])

ans=0
for i in range(n):
    dat=segfunc(tre.query(0,i),tre.query(i+1,n))
    ans=max(dat,ans)
print(ans)


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

int main(){
    int ans=0,sum=0;
    int n;
    int H,W;
    cin >>H>>W>>n;
    int color[H*W];
    int print[H][W];

    int count=0;

    for (int i = 0; i < n; i++){
        int a;
        cin >>a;
        
        for (int j = 0; j < a; j++){
            color[count]=i+1;
            count++;
        }
    }

    count=0;
    for (int i = 0; i < H; i++){
        int st,g,di;

        if(i%2==0){
            
            for (int j = 0; j < W; ++j){
                print[i][j]=color[count];
                count++;
            }
            

        }else{
            for (int j = W-1; 0 <= j; --j){
                print[i][j]=color[count];
                count++;
            }
        }

    }
    

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cout << print[i][j] << " ";
        }
        cout << endl;
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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



int main() {

   char c;cin>>c;
   
   int ascii= (int) c;
//    cout<<ascii<<endl;

   if(ascii>=65 && ascii<=90)
   {
       cout<<'A';
   }
   else
   {
       cout<<'a';
   }
   

   return 0; 

}


Measured memory_bytes: 3640
ABM = list(map(int, input().split()))
refrigerator = list(map(int, input().split()))
microwave = list(map(int, input().split()))

commonMin = min(refrigerator) + min(microwave)

discount = []

for i in range(ABM[2]):
    discount.append(list(map(int, input().split())))

min = 200000
tmp = 0
for i in range(len(discount)):
    dis = discount[i]
    tmp = refrigerator[dis[0] - 1] + microwave[dis[1] - 1] - dis[2]
    if (tmp < min):
        min = tmp

if (commonMin < min):
    print(commonMin)
else:
    print(min)

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

//struct Point {
//	int x,y;
//};
//long long ccw(const Point& A, const Point& B, const Point& C) { // 시계방향이면 음수 
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}

int main() { // 골드 1, 플레 1
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n;
	cin >> n;
	cout << (int)pow(n, 3) << '\n';




}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

bool recur(
	int u, int p, int e,
	const vector<vector<int>>& g,
	vector<bool>& vis,
	vector<bool>& in_stack)
{
	in_stack[u] = true;
	vis[u] = true;
	for(const auto& v : g[u]){
		if(v == p || v == e){ continue; }
		if(in_stack[v]){ return true; }
		if(!vis[v]){
			if(recur(v, u, e, g, vis, in_stack)){ return true; }
		}
	}
	in_stack[u] = false;
	return false;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> g(n);
	for(int i = 0; i < m; ++i){
		int a, b;
		cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	bool euler = true;
	for(int i = 0; i < n; ++i){
		if(g[i].size() % 2 != 0){ euler = false; }
	}
	if(!euler){
		cout << "No" << endl;
		return 0;
	}
	int except = -1;
	for(int i = 0; i < n; ++i){
		if(g[i].size() >= 6){
			cout << "Yes" << endl;
			return 0;
		}else if(g[i].size() == 4){
			except = i;
		}
	}
	if(except < 0){
		cout << "No" << endl;
		return 0;
	}
	vector<bool> vis(n), in_stack(n);
	bool answer = false;
	for(const auto& r : g[except]){
		if(vis[r]){ continue; }
		if(recur(r, except, except, g, vis, in_stack)){ answer = true; }
	}
	cout << (answer ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 11264
using System;
using System.Linq;

namespace aizu
{
    class OnlineJudge
    {
        static void Main()
        {
            string input;
            while((input = Console.ReadLine()) != null) {
                int[] cards = input.Split().Select(q => int.Parse(q)).ToArray();
                Console.WriteLine(Enumerable.Range(1, 10).Where(q => !cards.Contains(q)).Where(p => p <= (20 - (cards[0] + cards[1]))).Count() >= 4 ? "YES" : "NO");
            }
        }
    }
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

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

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

  ll q;
  cin >> q;

  vector<ll> b(q);
  vector<ll> c(q);
  for (ll i = 0; i < q; ++i) {
    cin >> b[i] >> c[i];
  }

  vector<ll> sum(100010);
  for (ll i = 0; i < n; ++i) {
    sum[a[i]]++;
  }

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

  for (ll i = 0; i < q; ++i) {
    ans -= sum[b[i]] * b[i];
    ans += sum[b[i]] * c[i];
    
    sum[c[i]] += sum[b[i]];
    sum[b[i]] = 0;
    
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 6360
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
pair<int,pair<int,int> >edge[110000];
int p[110000];
int UF[110000];
int FIND(int a){
	if(UF[a]<0)return a;
	return UF[a]=FIND(UF[a]);
}
void UNION(int a,int b){
	a=FIND(a);b=FIND(b);if(a==b)return;UF[a]+=UF[b];UF[b]=a;
}
int has[110000];
vector<int>rem;
int las[110000];
int main(){
	int a,b,c;scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
		p[i]--;
		has[p[i]]++;
	}
	for(int i=0;i<c;i++)if(has[i]==0)rem.push_back(i);
	for(int i=0;i<b;i++){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);x--;y--;
		edge[i]=make_pair(z,make_pair(x,y));
	}
	std::sort(edge,edge+b);
	long long ret=0;
	for(int i=0;i<a;i++)UF[i]=-1;
	for(int i=0;i<c;i++)las[i]=-1;

	for(int i=0;i<a;i++){
		if(p[i]!=-1){
			if(las[p[i]]!=-1)UNION(las[p[i]],i);
			las[p[i]]=i;
		}
	}
	int cnt=0;
	for(int i=0;i<b;i++){
		int L=edge[i].second.first;
		int R=edge[i].second.second;
		if(FIND(L)!=FIND(R)){
			cnt++;
			ret+=edge[i].first;
			UNION(L,R);
		}
		if(cnt==c-1)break;
	}
	if(cnt<c-1)ret=-1;

	printf("%lld\n",ret);
}

Measured memory_bytes: 4476
import decimal
from operator import sub


# INPUT
n = int(input())

vector_x = list(map(decimal.Decimal, input().split()))
vector_y = list(map(decimal.Decimal, input().split()))


# CALC:d1, d2, d3
d1 = decimal.Decimal("0")
d2 = decimal.Decimal("0")
d3 = decimal.Decimal("0")

for i in range(n):
    d1 += abs(vector_x[i] - vector_y[i])

    d2 += abs(vector_x[i] - vector_y[i]) ** decimal.Decimal("2")

    d3 += abs(vector_x[i] - vector_y[i]) ** decimal.Decimal("3")


d2 = pow(d2, decimal.Decimal("1") / decimal.Decimal("2"))
d3 = pow(d3, decimal.Decimal("1") / decimal.Decimal("3"))


# CALC:dinf
vector_sub = map(abs, map(sub, vector_x, vector_y))
dinf = max(vector_sub)


# OUTPUT
for answer in [d1, d2, d3, dinf]:
    print(answer)



Measured memory_bytes: 6448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=305;
const int mod=998244353;
int n,a[max_n];
int dp[max_n][90005];
int f[max_n][90005];
int Pow(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b&1)res=1ll*res*a%mod;
        b>>=1;
        a=1ll*a*a%mod;
    }
    return res;
}
int main()
{
    scanf("%d",&n);
    int sum=0;
    for(int i=1;i<=n;i++)scanf("%d",a+i),sum+=a[i];
    int t=(sum+1)/2;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=sum;j++)
        {
            dp[i][j]+=dp[i-1][j]*2%mod,dp[i][j]%=mod;
            if(j>=a[i])dp[i][j]+=dp[i-1][j-a[i]],dp[i][j]%=mod;
        }
    }
    int ans=0;
    for(int i=t;i<=sum;i++)ans+=dp[n][i],ans%=mod;
    ans=1ll*ans*3%mod;
    if(sum%2==0)
    {
        f[0][0]=1;
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=sum;j++)
            {
                f[i][j]+=f[i-1][j],f[i][j]%=mod;
                if(j>=a[i])f[i][j]+=f[i-1][j-a[i]],f[i][j]%=mod;
            }
        }
        ans+=mod-1ll*3*f[n][t]%mod,ans%=mod;
    }
    ans=(Pow(3,n)+mod-ans)%mod;
    printf("%d\n",ans);
    return 0;
}


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

int main(){
  long long N,M;
  cin>>N>>M;
  if(N==1&&M==1){
    cout<<1<<endl;
  }
  else if(N==1&&M!=1){
    cout<<M-2<<endl;
  }
  else if(N!=1&&M==1){
    cout<<N-2<<endl;
  }
  else{
    cout<<(N-2)*(M-2)<<endl;
  }
  return 0;
}


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

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

    int A[N];
    int ans[N + 1] = {};
    for (int i = 0; i < N - 1; i++) {
        cin >> A[i];
        ans[A[i]]++;
    }

    for (int i = 1; i < N + 1; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 5200
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <cstdio>
#define INF 1000000000000
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	REP(i, a+1){
		REP(j, b+1){
			REP(k, c+1){
				if(500*i+100*j+50*k == x) ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 22.12.2019 03:24:13       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<long long> pref(n + 1);
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + a[i];
  }
  vector<vector<long long>> dp(n, vector<long long>(n));
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i + 1; j < n; j++) {
      dp[i][j] = (long long) 9e18;
      for (int k = i; k < j; k++) {
        dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j]);
      }
      dp[i][j] += pref[j + 1] - pref[i];
    }
  }
  cout << dp[0][n - 1] << '\n';
  return 0;
}


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

using namespace std;
typedef long long int lli;
typedef pair<int,int> pii;

string s;

bool isPalindrome(int l, int r)
{
	for(int i = l ; i <= r ; i++)
		if( s[i] != s[r - i + l] ) return false;
	return true;
}

int main()
{
	cin >> s;

	int mid = ( s.size() - 1 )/2;

	if( isPalindrome( 0 , s.size() - 1 ) && isPalindrome( 0 , mid - 1 ) && isPalindrome( mid + 1 , s.size() - 1 )) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define s(a) int(a.size())
#define f(i,a,b) for(long long int i=a;i<b;i++)
#define r(i,a,b) for(long long int i=a;i>b;i--) 
#define pb push_back
#define mkp make_pair
#define mod 1000000007;
#define negmod(X,Y) X % Y + (X % Y < 0 ? Y : 0)
#define debug(x) cout<< #x << ':' << x << endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long int ll;
#define INF 0x3f3f3f3f;
long long maximum=numeric_limits<int>:: max();
long long minimum=numeric_limits<int>:: min();
string gg="abcdefghijklmnopqrstuvwxyz";//"AOYEUI";
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int max3(int a, int b, int c){return max(a, max(b,c));}
int mint(int x, int y, int z) 
{   if (x < y) return (x < z)? x : z; 
    else return (y < z)? y : z; }
vector <pair<long long int,long long int>> v;
bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b){
    if(a.second==b.second){
        return (a.first > b.first);
    }
    return a.second>b.second;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif//freopen("error.txt", "w", stderr);
    fast
    long double n,m;cin>>n>>m;
    ll ans=(n*m);
    cout<<ans;
    return 0;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  vll a(n,INF), b(n,INF);
  rep(i,n){
    ll x; cin>>x;
    if(x<0){
      a[i]=-x;
    }else{
      b[i]=x;
    }
  }
  vsort(a);
  vsort(b);
  ll ans=INF;
  rep(i,k){
    if(i==k-1) chmin(ans,a[i]);
    else chmin(ans,a[i]*2+b[k-i-2]);
  }
  rep(i,k){
    if(i==k-1) chmin(ans,b[i]);
    else chmin(ans,b[i]*2+a[k-i-2]);
  }
  cout<<ans<<endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, K; scanf("%d %d", &N, &K);
  vector<ll> X(N), Y(N);
  vector<pair<ll, ll>> P(N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld %lld", &X[i], &Y[i]);
    P[i] = make_pair(X[i], Y[i]);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans = numeric_limits<ll>::max();
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      for (int k = 0; k < N; ++k) {
        for (int l = k + 1; l < N; ++l) {
          int cnt = 0;
          for (int a = 0; a < N; ++a) {
            if (X[i] <= P[a].first and P[a].first <= X[j] and
                Y[k] <= P[a].second and P[a].second <= Y[l]) { ++cnt; }
          }
          if (cnt >= K) {
            ans = min(ans, abs(X[i] - X[j]) * abs(Y[k] - Y[l]));
          }
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long H,W;
  cin >> H >> W;
  if(H == 1 || W == 1){
  	cout << 1 << endl;
  }else{
    if((H * W) % 2 == 0){
      cout << (H * W) / 2 << endl;
    }else{
      cout <<(H * W + 1) / 2 << endl;
    }
  }
}

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

using namespace std;
const int N = 200005;
int arr[N];

int main() {
    //  freopen("in.txt", "rt", stdin);
    int n;
    scanf("%d", &n);
    multiset<int> st;
    for (int i = 0; i < n; ++i) {
        scanf("%d", arr + i);
        st.insert(arr[i]);
    }
    for (int i = 0; i < n; ++i) {
        st.erase(st.find(arr[i]));
        printf("%d\n", *st.rbegin());
        st.insert(arr[i]);
    }
}

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

int main() {
  int k;
  cin >> k;
  int n = k%10;
  if (n == 3) {
    cout << "bon" << endl;
  }

  else if (n == 1 || n == 0) {
    cout << "pon" << endl;
  }
  else if (n ==6 || n == 8) {
    cout << "pon" << endl;
  }

  else {
    cout << "hon" << endl;
  }

}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    int num = 1;
    for(int i = 0; i < N; ++i) num *= 3;
    int num2 = 1;
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        if(a%2 == 0) num2 *= 2;
    }
    cout << num - num2 << endl;
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <map>
#include <cstdlib>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    cout <<(a%3==0||b%3==0||(a+b)%3==0 ?"Possible":"Impossible") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int a,b;
    cin>>a;
    cin>>b;
    if (a>=6 and a<=12)
    {
        int c=b/2;
        cout << c;
    }
    else if (a<=5)
    {
        int d=0;
        cout << d;
    }
    else{
        int e=b;
        cout << e;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int s;
    int n, m;
    cin >> s;
    n = s / 100;
    m = s % 100;
    if((m > 0 && m < 13) && (n > 0 && n < 13)){
        cout << "AMBIGUOUS" << endl;
    }else if(m > 0 && m < 13){
        cout << "YYMM" << endl;
    }else if(n > 0 && n < 13){
        cout << "MMYY" << endl;
    }else{
        cout << "NA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
/*
 * Click `Run` to execute the snippet below!
 */

import java.io.*;
import java.util.*;

/*
 * To execute Java, please define "static void main" on a class
 * named Solution.
 *
 * If you need more classes, simply define them inline.
 */

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long K = sc.nextLong();
    long arr[] = new long[N];
    for(int i = 0 ;i<N; i++){
      arr[i] = sc.nextLong(); 
    }
    long pre = 0, ans = 0;
    for(int k = 40; k>=0; k--){
      if(((1L<<k)&K) != 0){
        long tot = 0;
        for(int j = 0; j<k; j++){
          int cnt = 0;
          for(int i = 0; i<N; i++){
            if((arr[i]&(1L<<j)) != 0){
              cnt++; 
            }
          }
          tot += (1L*Math.max(cnt, N-cnt)*(1L<<j));
        }
        for(int j = k; j<=40; j++){
          int cnt = 0;
          for(int i = 0; i<N; i++){
            if((arr[i]&(1L<<j)) != 0){
              cnt++; 
            }
          }
          if((pre&(1L<<j)) != 0){
            tot += (1L*(N-cnt)*(1L<<j)); 
          }
          else{
            tot += (1L*cnt*(1L<<j)); 
          }
        }
        ans = Math.max(tot, ans);
        pre += (1L<<k);
      }
    }
    long tot = 0;
    for(int i = 0; i<N; i++){
      tot += (K^arr[i]); 
    }
    ans = Math.max(ans, tot);
    System.out.println(ans);
  }
}


Measured memory_bytes: 60188
from itertools import accumulate
N = int(input())
A = list(map(int, input().split()))
S = [0]+list(accumulate(A))
B = list(map(int, input().split()))
T = [0]+list(accumulate(B))
res = 0
for i in range(N):
    res = max(S[i+1] + T[N]-T[i], res)
print(res)

Measured memory_bytes: 62168
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int H, W, K; cin >> H >> W >> K;
	vector<vector<int>> dp(H + 1, vector<int>(W, 0)); dp[0][0] = 1;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			for (int k = 0; k < 1 << (W - 1); ++k) {
				bool ok = true;
				//2つ繋がった経路がないか調査する
				for (int l = 0; l < (W - 2); ++l) {
					if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
						ok = false;
					}
				}
				if (ok) {
					//右方向へ経路を辿る場合
					if (j >= 1 && (k >> (j - 1) & 1)) {
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= MOD;
				       //左方向へ経路を辿る場合
					} else if(j <= (W - 2) && (k >> j) & 1) {
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= MOD;
					} else {
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= MOD;
					}
				}
			}
		}
	}
	cout << dp[H][K - 1] << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3588
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

//code by lynmisakura.wish to be accepted!
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

/***************************/
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

class DFTRobot {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int i = 0,x,y,z,c;
        z = c = 0;
        string s;
        cin >> s >> x >> y;
        for(i=0;s[i] == 'F';i++);
        bitset<2*8010> bs[2];
        const int M = 8005;
        bs[0][i+M] = bs[1][M] = 1;
        for(;i<=s.size();i++){
            if(s[i] == 'F')c++;
            else bs[z] = (bs[z] >> c) | (bs[z] << c),z = !z,c=0;
        }
        if(bs[0][x+M]&bs[1][y+M])cout << "Yes"<<endl;else cout << "No" << endl;
    }
};

int main() {
	DFTRobot solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
random_device rnd;
mt19937 mt(rnd());

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main()
{
    int n, t;
    cin >> n >> t;
    VI v(n), w(n);
    rep(i, n) cin >> v[i];
    rep(tt, t)
    {
        bool check = false;
        w = v;
        VI imos(n + 1, 0);
        rep(j, n)
        {
            imos[max(0, j - v[j])]++;
            imos[min(n, j + v[j] + 1)]--;
        }
        int cur = 0;
        rep(j, n)
        {
            cur += imos[j];
            v[j] = cur;
            check |= (v[j] != n);
        }
        if (check == false)
            break;
        cerr << v[0] << endl;
    }
    rep(i, v.size())
    {
        cout << v[i] << " ";
    }
    cout << endl;

    return 0;
}

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

#define int long long

vector<int> basis;

bool ok(int x){
	for(int i = 0 ; i < 60 ; i++){
		if((x & 1LL << i) == 0) continue ;
		if(basis[i] == 0){
			return  false;
		}
		x ^= basis[i] ;
	}
	return  true;
}

void insert(int x){
	for(int i = 0 ; i < 60 ; i++){
		if((x & 1LL << i) == 0) continue ;
		if(basis[i] == 0){
			basis[i] = x ;
			return  ;
		}
		x ^= basis[i] ;
	}
	return  ;
}

int32_t main(){
	int t ;
	cin >> t ;
	while(t--){
		basis.clear() ;
		basis.resize(60) ;
		int n ; 
		cin >> n ;
		int a[n] ;
		for(int i = 0 ; i < n ; i++){
			cin >> a[i] ;
		}
		string s ; 
		cin >> s ;
		bool found = true ;
		for(int i = n - 1 ; i >= 0 ; i--){
			if(s[i] == '0') insert(a[i]) ;
			else{
				found &= ok(a[i]) ;
			}
		}
		cout << 1 - found << '\n' ;
	}
	return 0 ;
}



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

int main()
{
    int N,M,Input = 0;
    vector<int> student;
    cin >> N >> M;
    
    for(int i = 0;i < N;i++){
        cin >> Input;
        student.push_back(Input);
    }
    
    for(int k = 1;k <= M;k++){
        for(int i = 0;i < N-1;i++){
            if(student[i] % k > student[i+1] % k){
                swap(student[i],student[i+1]);
            }
        }
    }
    
    for(auto value : student){
        cout << value << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3156
def read_input():
    sx, sy, tx, ty = map(int, input().split())

    return (sx, sy), (tx, ty)


def get_right(point):
    return (point[0] + 1, point[1])


def get_left(point):
    return (point[0] - 1, point[1])


def get_up(point):
    return (point[0], point[1] + 1)


def get_down(point):
    return (point[0], point[1] - 1)


def go_right_up(sp, ep):
    move = []
    curr = sp

    while curr[0] < ep[0]:
        move.append('R')
        curr = get_right(curr)

    while curr[1] < ep[1]:
        move.append('U')
        curr = get_up(curr)

    return move


def go_left_down(sp, ep):
    move = []
    curr = sp

    while ep[0] < curr[0]:
        move.append('L')
        curr = get_left(curr)

    while ep[1] < curr[1]:
        move.append('D')
        curr = get_down(curr)

    return move


def submit():
    start, end = read_input()

    start1 = get_right(start)
    end1 = get_down(end)

    start2 = get_left(end)
    end2 = get_up(start)

    start3 = get_down(start)
    end3 = get_right(end)

    start4 = get_up(end)
    end4 = get_left(start)


    move = ['R']
    move += go_right_up(start1, end1)
    move += ['U']

    move += ['L']
    move += go_left_down(start2, end2)
    move += ['D']

    move += ['D']
    move += go_right_up(start3, end3)
    move += ['L']

    move += ['U']
    move += go_left_down(start4, end4)
    move += ['R']

    print(''.join(move))


if __name__ == '__main__':
    submit()


Measured memory_bytes: 39664
n=int(input())
e=[[i for i in input().split()] for j in range(n)]
#print(n,e)

ans=0
for i in range(n):
  if e[i][1]=='JPY':
    ans+=float(e[i][0])
  else: 
    ans+=380000*float(e[i][0])
    
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		if (N % 10 == 9 || N / 10 == 9)
			System.out.println("Yes");
		else
			System.out.println("No");
		scanner.close();
	}
}

Measured memory_bytes: 21844
/**
 * Copyright (c) 2017, xehoth
 * All rights reserved.
 * 「ARC 079D」Decrease (Contestant ver.) 26-08-2017
 * 构造
 * @author xehoth
 */
#include <bits/stdc++.h>

namespace {

typedef unsigned long long ulong;

const int MAXN = 50;
ulong a[MAXN];

inline void solve() {
    std::ios::sync_with_stdio(false), std::cin.tie(NULL), std::cout.tie(NULL);
    register ulong n;
    std::cin >> n;
    register ulong steps = n / MAXN, remain = n % MAXN;
    for (register int i = 0; i < MAXN; i++) a[i] = i + steps;
    for (register int i = 0; i < remain; i++) {
        a[i] += MAXN;
        for (register int j = 0; j < i; j++) a[j]--;
        for (register int j = i + 1; j < MAXN; j++) a[j]--;
    }
    std::cout << "50\n";
    for (register int i = 0; i < MAXN; i++) std::cout << a[i] << ' ';
}
}

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

Measured memory_bytes: 256
#include <stdio.h>

int N, K;
int A[271828];

int main(void) {
	int i;
	int ng = 0, ok = 1000000000;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	while (ng + 1 < ok) {
		int m = ng + (ok - ng) / 2;
		int count = 0;
		for (i = 0; i < N; i++) {
			count += (A[i] + m - 1) / m - 1;
		}
		if (count <= K) ok = m; else ng = m;
	}
	printf("%d\n", ok);
	return 0;
}


Measured memory_bytes: 2512
// acdart
#include <iostream>
#include <cstring>
#include <algorithm>
#include <stdio.h>
#include <cstring>
#include <cmath>
#include <cctype>
#include <string>
#include <numeric>
#include <utility>
#include <queue>
#include <memory>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <cstdlib>
#include <list>
#include <limits.h>
#include <utility>
#include <functional>
#include <iterator>
#include <deque>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define X first
#define Y second
#define F first
#define S second
#define MOD9 1000000009ll
#define MOD7 1000000007ll
#define MOD
#define INF  1023456789ll
#define INF16 10000000000000000ll
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define SZ(x) ((int)(x).size())
#define MAXN 10010
#define MAXM
#define ALL(x) ((x).begin()),((x).end())
#define RESET(a,b) memset(a,b, sizeof a)
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define LEN(X) strlen(X)
#define FI(a,b,c) for(int a=b; a<c; a++)
#define FD(a,b,c) for(int a=b; a>c; a--)
using namespace std;
typedef long long ll;
typedef long long LL;
typedef double db;
typedef double D;
typedef long double ld;
typedef long double LD;
/*********default*********/
// #define ONLINE_JUDGE
#define inf 0x3f3f3f3f
#define mod 
#define maxm 
#define maxn 
ll pow(ll x) {
	ll ans = 1, a = 2;
	while (x) {
		if (x & 1) {
			ans = ans * a;
		}
		a = a * a;
		x >>= 1;
	}
	return ans;
}
int main()
{/*
	#ifdef ONLINE_JUDGE
    	freopen("aplusb.in", "r", stdin);
    	freopen("aplusb.out", "w", stdout);
	#endif*/
	// ios::sync_with_stdio(false);
	int n, p, x, s = 0, t = 0;
	
	scanf("%d%d", &n, &p);
	for (int i = 0; i < n; i++) {
		scanf("%d", &x);
		if (x & 1) {
			s++;
		} else {
			t++;
		}
	} 
	if (p == 1 && s == 0) {
		printf("0\n");
	} else if (p == 0 && s <= 1) {
		printf("%lld\n", pow(t));
	} else
	printf("%lld\n", pow(s + t - 1));
}


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

using namespace std;

int main(){
int H,W; cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  
  int black = 0;
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> table[i][j]; if(table[i][j] == '#'){ black++;}
    }}
  vector<vector<int>> visited( H, vector<int> (W, -1));
    visited[0][0] = 0;
    
    queue<pair<int,int>> Q; 
    Q.push(make_pair(0,0));
    
    int dx[] = {1,0,-1,0}; int dy[] = {0,1,0,-1};
    
    while(!Q.empty()){
      pair<int,int> p = Q.front(); Q.pop();
     for( int  k = 0; k < 4; k++){
        int q = p.first + dx[k]; int r = p.second + dy[k];
        if( q < 0 || q >= H || r < 0 || r >= W){ continue;}
        if( table[q][r] == '#'){ continue;}
       else{
        if( visited[q][r] != -1){ continue;}
          visited[q][r] = visited[p.first][p.second] + 1;
          Q.push(make_pair(q,r));}
       }
    }
    if( visited[H-1][W-1] == -1){ cout << -1 << endl;}
    else{ // ( H, W) まで到達できた場合
      cout << H * W - visited[H-1][W-1] - 1 - black << endl; 
    }
    
    return 0;}
      

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

int main(){
  int n,t;
  cin >> n >> t;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a.at(i);
  
  int ans=t;
  
  for(int i=1;i<n;i++){
    ans+=min(t,a.at(i)-a.at(i-1));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string s[100005];

vector<char> res;

void print(char c){
	res.push_back(c);
}

int main(){
	int N, A, B, C;
	cin>>N>>A>>B>>C;
	for(int i=1; i<=N; ++i) cin>>s[i];
	if(A + B + C == 0){
		puts("No");
		return 0;
	}
	for(int i=1; i<=N; ++i){
		if(s[i] == "AB"){
			if(A > 1 && B > 1) A++, B--, print('A');
			else if(A > 1 && B <= 1) A--, B++, print('B');
			else if(A <= 1 && B > 1) A++, B--, print('A');
			else if(A == 0 && B == 0){
				puts("No");
				return 0;
			}
			else if(A == 1 && B == 0) A--, B++, print('B');
			else if(A == 0 && B == 1) A++, B--, print('A');
			else{
				if(s[i + 1] == "AC") A++, B--, print('A');
				else if(s[i + 1] == "BC") A--, B++, print('B');
				else A++, B--, print('A');
			}
		}
		else if(s[i] == "AC"){
			if(A > 1 && C > 1) A++, C--, print('A');
			else if(A > 1 && C <= 1) A--, C++, print('C');
			else if(A <= 1 && C > 1) A++, C--, print('A');
			else if(A == 0 && C == 0){
				puts("No");
				return 0;
			}
			else if(A == 1 && C == 0) A--, C++, print('C');
			else if(A == 0 && C == 1) A++, C--, print('A');
			else{
				if(s[i + 1] == "AB") A++, C--, print('A');
				else if(s[i + 1] == "BC") A--, C++, print('C');
				else A++, C--, print('A');
			}
		}
		else if(s[i] == "BC"){
			if(B > 1 && C > 1) B++, C--, print('B');
			else if(B > 1 && C <= 1) B--, C++, print('C');
			else if(B <= 1 && C > 1) B++, C--, print('B');
			else if(B == 0 && C == 0){
				puts("No");
				return 0;
			}
			else if(B == 1 && C == 0) B--, C++, print('C');
			else if(B == 0 && C == 1) B++, C--, print('B');
			else{
				if(s[i + 1] == "AB") B++, C--, print('B');
				else if(s[i + 1] == "AC") B--, C++, print('C');
				else B++, C--, print('B');
			}
		}
	}
	puts("Yes");
	for(int i=0; i<res.size(); ++i) printf("%c\n", res[i]);
	return 0;
}


Measured memory_bytes: 5700
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}
ll maxll(ll x, ll y){
    return x>y?x:y;
}
signed main() {
    ll n;
    cin>>n;
    vector<vector<ll>> a(2, vector<ll>(n,0));
    vector<vector<ll>> dp(2, vector<ll>(n,-1));
    rep(i,0,2){
        rep(j,0,n){
            cin>>a[i][j];
        }
    }
    dp[1][n-1] = a[1][n-1];
    for (ll i=1; i>=0; i--){
        for(ll j=n-1; j>=0; j--){
            if (dp[i][j]!=-1) continue;
            if (i<1)   dp[i][j] = maxll(dp[i][j], a[i][j]+dp[i+1][j]);
            if (j<n-1) dp[i][j] = maxll(dp[i][j], a[i][j]+dp[i][j+1]);
        }
    }
    cout<<dp[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


enum DIR{
	North,
	East,
	South,
	West,
};

struct Info{
	Info(int arg_row,int arg_col,int arg_sum_cost,DIR arg_dir){
		row = arg_row;
		col = arg_col;
		sum_cost = arg_sum_cost;
		dir = arg_dir;
	}
	int row,col,sum_cost;
	DIR dir;
};

int H,W;
int min_dist[26];
int diff_row[4] = {-1,0,0,1},diff_col[4] = {0,-1,1,0};
char table[50][51],start[2],goal[2];
DIR dir_array[4] = {North,West,East,South};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}


int main(){

	scanf("%d %d %s %s",&H,&W,start,goal);

	int start_row,start_col;
	for(int row = 0; row < H; row++){
		scanf("%s",table[row]);
		for(int col = 0; col < W; col++){
			if(table[row][col] == start[0]){
				start_row = row;
				start_col = col;
			}
		}
	}

	for(int i = 0; i < 26; i++)min_dist[i] = BIG_NUM;

	queue<Info> Q;
	min_dist[start[0]-'A'] = 0;

	for(int i = 0; i < 4; i++){
		Q.push(Info(start_row,start_col,0,dir_array[i]));
	}

	int adj_row,adj_col;

	while(!Q.empty()){

		if(table[Q.front().row][Q.front().col] == goal[0]){
			Q.pop();
		}else{

			for(int i = 0; i < 4; i++){

				if(Q.front().dir != dir_array[i])continue;

				adj_row = Q.front().row+diff_row[i];
				adj_col = Q.front().col+diff_col[i];

				if(rangeCheck(adj_row,adj_col) == false || table[adj_row][adj_col] == '.')continue;
				if(Q.front().dir == North || Q.front().dir == South){
					if(table[adj_row][adj_col] == '-')continue;

				}else{
					if(table[adj_row][adj_col] == '|')continue;
				}

				if(table[adj_row][adj_col] >= 'A' && table[adj_row][adj_col] <= 'Z'){
					if(min_dist[table[adj_row][adj_col]-'A'] <= Q.front().sum_cost+1)continue;
					min_dist[table[adj_row][adj_col]-'A'] = Q.front().sum_cost+1;

					for(int k = 0; k < 4; k++){
						Q.push(Info(adj_row,adj_col,min_dist[table[adj_row][adj_col]-'A'],dir_array[k]));
					}

				}else{
					Q.push(Info(adj_row,adj_col,Q.front().sum_cost,Q.front().dir));
				}
			}

			Q.pop();
		}
	}

	printf("%d\n",min_dist[goal[0]-'A']);

	return 0;
}



Measured memory_bytes: 3260
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector< vector<int> > G(N);
	for(int i = 0; i < N-1; i++) {
		int a, b;
		cin >> a >> b;
		G[--a].push_back(--b);
		G[b].push_back(a);
	}
	vector<int> dep0(N, -1);
	queue<int> q;
	q.push(0);
	dep0[0] = 0;
	while(!q.empty()) {
		ALL_THE(G[q.front()], it) if(dep0[*it] == -1) {
			dep0[*it] = dep0[q.front()]+1;
			q.push(*it);
		}
		q.pop();
	}
	int maxdep = 0, maxdep_id = 0;
	for(int i = 0; i < N; i++) if(dep0[i] > maxdep) {
		maxdep = dep0[i];
		maxdep_id = i;
	}
	vector<int> dep(N, -1);
	dep[maxdep_id] = 0;
	q.push(maxdep_id);
	while(!q.empty()) {
		ALL_THE(G[q.front()], it) if(dep[*it] == -1) {
			dep[*it] = dep[q.front()]+1;
			q.push(*it);
		}
		q.pop();
	}
	for(int i = 0; i < N; i++) maxdep = max(maxdep, dep[i]);
	maxdep++;
	vector<int> winner(maxdep+1, 0);
	for(int i = 2; i <= maxdep; i++) {
		if(winner[i-1]+winner[i-2] == 0) winner[i] = 1;
		else winner[i] = 0;
	}
	cout << (winner[maxdep] ? "Second\n" : "First\n");
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 14452