akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int c[4][4];
  for(int i = 1;i <= 3;i++)for(int j = 1;j <= 3;j++)cin >> c[i][j];
  bool ans = 1;
  if(c[1][1] - c[1][2] != c[2][1] - c[2][2])ans = 0;
  if(c[1][1] - c[1][2] != c[3][1] - c[3][2])ans = 0;
  if(c[1][1] - c[1][3] != c[2][1] - c[2][3])ans = 0;
  if(c[1][1] - c[1][3] != c[3][1] - c[3][3])ans = 0;
  if(c[1][1] - c[2][1] != c[1][2] - c[2][2])ans = 0;
  if(c[1][1] - c[2][1] != c[1][3] - c[2][3])ans = 0;
  if(c[1][1] - c[3][1] != c[1][2] - c[3][2])ans = 0;
  if(c[1][1] - c[3][1] != c[1][3] - c[3][3])ans = 0;
  if(ans)cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    char s[100003];
    Scs(s);

    ll e = 1;
    ll a = 0;
    ll ab = 0;
    ll abc = 0;
    ll mod = 1000000007;
    for( int i = 0; s[i]; i++ ){
        switch( s[i] ){
            case 'A' :
                a += e;
                break;
            case 'B' :
                ab += a;
                break;
            case 'C' :
                abc += ab;
                break;
            case '?' :
                abc *= 3;
                abc += ab;
                ab *= 3;
                ab += a;
                a *= 3;
                a += e;
                e *= 3;
                break;
        }
        e %= mod;
        a %= mod;
        ab %= mod;
        abc %= mod;
    }
    printf ("%llu\n", abc );

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;


int main()
{
	int N,x;
	cin >> N >> x;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (a[i] > x) {
			break;
		}
		if (i == N - 1 && a[i] != x) {
			break;
		}
		ans++;
		x -= a[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){

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

    int memo = 0; int cnt = 0; int ans = 0;

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

        if(a[i] == memo){cnt++;}
        else{ 
            if(cnt < memo){ans+=cnt;}
            else if(cnt > memo){ans+=(cnt-memo);}
            memo = a[i]; cnt = 1;
        }

        if(i == N-1){if(cnt < memo){ans+=cnt;}else if(cnt > memo){ans+=(cnt-memo);}}
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll A[100001];

int main(){
  ll n,x;
  cin>>n>>x;
 
  for(int i=0;i<n;i++)scanf("%d",&A[i]);

  ll ans=0;
  if(A[0]>x)ans=A[0]-x,A[0]=x;
  for(int i=1;i<n;i++){
    ll a=A[i]+A[i-1]-x;
    if(A[i]+A[i-1]>x)ans+=a,A[i]-=a;
  }
  cout <<ans<<endl;
			

}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <cctype>

using namespace std;

#define Int int64_t

void printVec(std::vector<int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

int vector_finder(std::vector<string> vec, string number) {
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

#include <sstream> 
std::vector<std::string> StringSplit(const std::string& str, char sep)
{
	std::vector<std::string> v;
	std::stringstream ss(str);
	std::string buffer;
	while (std::getline(ss, buffer, sep)) {
		v.push_back(buffer);
	}
	return v;
}



int main() {
	int n, m; cin >> n >> m;
	int a, b;
	vector<int>count(n,0);
	//count[0]++;
	for (int i = 0; i < m; i++){
		cin >> a >> b;
		count[a-1]++;
		count[b-1]++;
	}
	for (int i = 0; i < n; i++) {
		cout << count[i] << endl;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
#define MOD int(1e9 + 7)

int main()
{
    string A, B;
    cin >> A >> B;

    if (stol(A + B) == long(pow(double(long(sqrt(stod(A + B)))), 2)))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
import fractions
c=0
N=int(input())
L=list(map(int,input().split()))
a=L[0]
for i in range(1,N):
  a=(L[i]*a)//fractions.gcd(L[i], a)
for i in range(N):
  c+=(a//L[i])
print(c%(10**9+7))

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

using namespace std;

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

	int ans = 0;

	for (int i = 0; i < 10000; i++)
	{
		if (a*i%b == c) {
			ans = i;
			break;
		}
	}

	if (a*ans%b == c) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];    
  }
  
  sort(a.begin(),a.end(),greater<int>());
      
  cout << a[0]-a[n-1] << endl;
}


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

int main(){
	int A, B, C;
	bool flag = false;
	cin >> A >> B >> C;
	
	for(int i = 0; i < 20000; ++i){
		if((A * i) % B == C) flag = true;
	}
	
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long v[1010];
long long w[1010];
// item i, y quieres tener ganancia v,
// queremos saber el minimo W
int n;
long long dp[110][100010];
long long f(int pos , int g){
    if(pos == n ){
        return g==0 ? 0:1e12;
    }
    if( g < 0 ) return 1e12;
    long long &re = dp[pos][g];
    if(re != -1) return re;    
    re = min (f(pos+1 ,  g-v[pos]) + w[pos] , f(pos + 1 , g));
    return re;
}
int main(){
    
    long long W;
    while(cin>>n>>W){
        for(int i = 0 ; i < n ; i++){
            cin>>w[i]>>v[i];
        }
        memset(dp,-1,sizeof dp);
        long long re = 0;
        for(long long i = 0 ; i <=1e5+1 ; i++){
            if( f(0,i) <= W){
                re = max(re,i);      
            }
        }
        cout<<re<<"\n";
    }
    return 0;
}

Measured memory_bytes: 89556
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) for(int sz=0;sz<int(vec.size());sz++) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    V<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vll dp(n + 1, 0);
    dp[0] = 1000;

    for (int i = 1; i <= n; i++) {
        chmax(dp[i], dp[i - 1]);
        for (int j = 1; j < i; j++) {
            ll kabu =  dp[j] / a[j - 1];
            chmax(dp[i], dp[j] - (a[j - 1] * kabu) + kabu * a[i - 1]);
        }
    }
    // DEBUG_VLL(dp)
    cout << dp[n] << '\n';
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
signed main(){
  ll n,l,a[100000],sun[100000],sum=0,b;
  cin>>n>>l;
  vector<pair<ll, ll> > pp(n); 
  for(ll i=0;i<n;i++){
	a[i] = l+i;
    sum += a[i];
  }
  for(ll i=0;i<n;i++){
    sun[i] = sum - a[i];
    b = abs(sum - sun[i]);
    pp[i] = make_pair(b,sun[i]);
  }
  sort(pp.begin(),pp.end());
  cout<<pp[0].second<<"\n";
  return(0);
}

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

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

    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (p.at(i) == i + 1) {
            swap(p.at(i), p.at(i + 1));
            ans++;
        }
    }
    
    if (p.at(n - 1) == n) ans++;
    cout << ans << endl;
}

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

int main() {
  ll n; cin >> n;
  vector<int> p(n+1);
  for(int i=1; i<=n; i++) cin >> p[i];
  
  int a = 1;  int cnt = 0;
  vector<bool> v(n+1,false);
  rep(i, n){
    if(a == 2)  { cout << cnt << endl; return 0; }
    if(v[a] == true)  { cout << -1 << endl; return 0; }
    v[a] = true;
    a = p[a];
    cnt++;
  }
}

Measured memory_bytes: 3792
#coding:utf-8
from collections import defaultdict
import sys
from Queue import Queue
N=input()
U=[];V=[];W=[]
G=defaultdict(list)
Dist={}
for _ in range(N-1):
    u,v,w=map(int,raw_input().split())
    u,v=min(u,v),max(u,v)
    U.append(u);V.append(v);W.append(w)    
    G[u].append(v)
    G[v].append(u)
    Dist[(u,v)]=Dist[(v,u)]=w

vis=[False]*(10**5+1)
color=[None]*(10**5+1)
q=Queue()
vis[1]=True
color[1]=0
curCol=1
for u in G[1]:q.put(u)
while not q.empty():
    child=q.get()
    vis[child]=True
    par=None
    for n in G[child]:
        if vis[n]: 
            par=n;break
    dist=Dist[(par,child)]
    if dist%2==0: color[child]=color[par]
    else: color[child]=color[par]^1
    for ch in G[child]:
        if not vis[ch]: q.put(ch)

for c in color[1:N+1]:print(c)








Measured memory_bytes: 120660
N = [int(i) for i in input().split()]
A = list(map(int, input().split()))
evenList = [i for i in A if i % 2 == 0]
if len(evenList) == 0:
    print("APPROVED")
else:
    result = [i for i in evenList if i % 3 != 0 and  i % 5 != 0]
    if len(result) > 0:
        print("DENIED")
    else:
        print("APPROVED")

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

int W,H,T;
int p;
int x[50],y[50],t[50];
int mp[50][50];

int main(){
  cin>>W>>H>>T>>p;
  for(int i=0;i<p;i++){
    cin>>x[i]>>y[i]>>t[i];
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>mp[i][j];
    }
  }

  int ans=0;
  for(int i=0;i<p;i++){
    if( mp[ y[i] ][ x[i] ] == 1 ){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
  
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <vector>
// #include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define FOR(i, j, k) for(int i=j ; i<k ; i++)
#define RFOR(i, j, k) for(int i=j ; i>=k ; i--)
#define REP(i, j) FOR(i, 0, j)
#define RREP(i, j) RFOR(i, j, 0)
#define PI 3.1415926535897932384626433832795
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

#define UNION_FIND_MAX_N 200005

struct union_find {

    int par[UNION_FIND_MAX_N];
    int ran[UNION_FIND_MAX_N];

    union_find(int __n) {
        init(__n);
    }
    
    void init(int n){
        for(int i=0; i<n; i++){
            par[i] = i;
            ran[i] = 0;
        }
    }
    
    int find(int x){
        if( par[x] == x ) return x;
        else return par[x] = find(par[x]);
    }
    
    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if( x == y ) return;
    
        if( ran[x] < ran[y] ){
            par[x] = y;
        } else {
            par[y] = x;
            if( ran[x] == ran[y] ) ran[x]++;
        }
    }
    
    bool same(int x, int y){
        return find(x) == find(y);
    }
    
};

int main() {

    int N, K, L; cin >> N >> K >> L;
    union_find uf1(N);
    int p, q;
    REP(i, K) {
        cin >> p >> q;
        p--;
        q--;

        uf1.unite(p, q);
    }

    union_find uf2(N);
    int r, s;
    REP(i, L) {
        cin >> r >> s;
        r--;
        s--;

        uf2.unite(r, s);
    }

    map<pair<int, int>, int> m;
    REP(i, N) {
        pair<int, int> p = make_pair(uf1.find(i), uf2.find(i));
        m[p]++;
    }

    REP(i, N) {
        pair<int, int> p = make_pair(uf1.find(i), uf2.find(i));
        cout << m[p] << " ";
//        cout << res[i] << " ";
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 15104
#include <stdio.h>
#define MAX 100
#define INF 2001
#define WHITE 0
#define GRAY 1
#define BLACK 2

int M[MAX][MAX];

int MST(int n)
{
  int color[n],d[n],p[n],min,u,v,i,ans=0;
  for(i=0;i<n;i++){
    color[i]=WHITE;
    d[i]=INF;
  }
  d[0]=0;
  p[0]=-1;
  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(color[i] != BLACK && d[i]<min){
	min=d[i];
	u=i;
      }
    }
    if(min ==INF)break;
    color[u]=BLACK;

    for(v=0;v<n;v++){
      if(color[v] != BLACK && M[u][v] != INF){
	if(M[u][v] < d[v]){
	  p[v]=u;
	  d[v]=M[u][v];
	  color[v]=GRAY;
	}
      }
    }
  }
  for(i=0;i<n;i++) ans+=d[i];
  return ans;
}
  
int main()
{
  int n,i,j,num;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      scanf("%d",&num);
      if(num==-1) M[i][j]=INF;
      else M[i][j]=num;
    }
  }
  
  printf("%d\n",MST(n));

  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main() {
    fastio;
	int n,t;
	    cin>>n;
	    int a[n],b[n]={0},c[n]={0},s2=0,s1=0;
	    for(int i=0;i<n;i++){ cin>>a[i];
	    }
	    
	  int s=999999,m;
	  for(int j=1;j<n;j++){
	    s1=0,s2=0;
	    for(int i=0;i<n;i++){
	      if(i<j) s2+=a[i];
	      else s1+=a[i];
	    }
	    m = abs(s2-s1);
	    if(s>m){
	          s=m;
	      }
	      
	  }
	cout<<s;
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

vi A(5);

int solve() {
    ll ans = 1e9;
    do {
        ll res = A[4];
        REP (i, 4) {
            res += A[i]/10*10;
            if (A[i]%10) res += 10;
        }
        ans = min(ans, res);
    } while (next_permutation(ALL(A)));
    return ans;
}

int main() {
    REP (i, 5) cin >> A[i];
    cout << solve() << endl;
}

Measured memory_bytes: 256
from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math

g   = lambda : stdin.readline().strip()
gl  = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1e9)+7
inf = float("inf")

n, = gil()
if n:
	print("0")
else:
	print("1")

Measured memory_bytes: 65320
def read():
	return list(map(int, input().split()))

def main():
	n, m = read()
	a = read()
	total_vote = sum(a)
	number_of_popular_items = 0
	for i in range(n):
		if a[i]*(4*m) >= total_vote:
			number_of_popular_items += 1
	if number_of_popular_items >= m: print("Yes")
	else: print("No")
main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'

typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;
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 INF = 1LL<<60;


int main(){
    int N;cin >> N;
    vector<int> a(N,-1);
    int m;cin >> m;
    rep(mi,m){
        int s,c;cin >> s >> c;s--;
        if(a[s]==-1){
            a[s] = c;
        }else{
            if(a[s]!=c){
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if(N==1){
        cout << (a[0]==-1?0:a[0]) << endl;
        return 0;
    }
    if(a[0]==0){
        cout << -1 << endl;
        return 0;
    }
    for(int i=0;i<N;i++){
        if(a[i]==-1){
            if(i==0) cout << 1;
            else cout << 0;
        }else{
            cout << a[i];
        }
    }
    cout << endl;
}

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

int main() {
    string N;
    int A = 0;
    cin >> N;

    for (int i = 0; i < N.size(); i++) {
        A += N.at(i) - '0';
    }

    if (A % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
long long int dp[100040] = {};
int main() {
	int n;
	cin >> n;
	dp[0] = 2;
	dp[1] = 1;
	for (int i = 2; i <= 86; i++) {
		dp[i] = dp[i - 1] + dp[i - 2];
	}
	cout << dp[n];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define debug(x) cout << #x << " : " << x << endl
#include <iostream>
#define fastinput ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


LL POW(LL x,LL y)
{
    LL ans=1;
    LL base=x;
    while(y)
    {
        if(y&1)
        {
            ans*=base;
        }
        base=base*base;
        y=y>>1;
    }
    return ans;
}


int main()
{    
    fastinput;
    LL n,i,j,k,t,temp;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>j;
        if(j%2==0)
        {
            if(j%3!=0 && j%5!=0)
            {
                cout<<"DENIED\n";
                return 0;
            }
        }
    }
    cout<<"APPROVED\n";
    


    
    return 0;
}

Measured memory_bytes: 256
s = int(input())
ok = 0
c = 0
for _ in range(s):
  x,y = list(map(int,input().split()))
  
  if x==y:
    c+=1
    
  else:
    c=0

  if c==3:
    ok = 1
    
if ok==1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 62472
//判分标准
//您花费在获取当前分数上的时间)+(5分钟)*(错误尝试的次数)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b,c;
	cin>>a>>b>>c;
	
	swap(a,b);
	swap(a,c);
	
	cout<<a<<' '<<b<<' '<<c<< endl; 
	return 0;
}


Measured memory_bytes: 256
n, k = map(int,input().split())

ans = 0
#a,b,c = pk,qk,rk
pk = n//k
ans += pk**3

#a,b,c = pk/2,qk/2,rk/2
if k%2 == 0:
    qk = n//(k//2) - pk
    ans += qk**3

print(ans)

Measured memory_bytes: 61808
def shortpath(C):
    #魔力表Cの任意のパスを最小化したい
    update = True
    while update:
        update = False
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    if C[i][j] > C[i][k] + C[k][j]:
                        C[i][j] = C[i][k] + C[k][j]
                        update = True
    return C

def main():
    H,W = map(int,input().split())
    C = [list(map(int,input().split())) for _ in range(10)]
    A = [list(map(int,input().split())) for _ in range(H)]

    C = shortpath(C)
    ans = 0
    for i in range(H):
        for j in range(W):
            if abs(A[i][j]) != 1:
                ans += C[A[i][j]][1]

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3444
<?php
fscanf(STDIN, "%d %d", $n, $k);
$height = explode(' ',trim(fgets(STDIN)));
arsort($height);
$count = 0;
foreach ($height as $item) {
    if ($k <= $item) {
        $count++;
    } else {
        break;
    }
}
echo $count;

Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    SPEED
    int N; cin >> N;
    vector<ll> A(100001,0);
    for(int i = 0; i < N; ++i) {
        int a; cin >> a;
        A[a]++;
    }
    ll sum = 0;
    for(int i = 0; i <= 100000; ++i) {
        sum += A[i]*i;
    }
    int Q; cin >> Q;
    while(Q--){
        int B,C;
        cin >> B >> C;
        ll x = A[B];
        A[B] = 0;
        sum -= x*B;
        sum += x*C;
        A[C] += x;
        cout << sum << endl;
    }
    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////




int main(){fastio
    
    ll n;cin>>n;
    ll used[n];memset(used,0,sizeof(used));//0は未使用1はスタック2は使用
    ll a[n];rep(i,0,n-1)cin>>a[i];
    vector<ll>ans;
    rep(q,1,n){
        //スタック確認
        bool flag=false;
        for(ll i=n-1;i>=0;i--){
            if(used[i]<=1){
                ll c=0;
                rep(j,0,i-1){
                    if(used[j]==2)c++;
                }
                if(a[i]==c+1){
                    ans.pb(a[i]);
                    used[i]=2;
                    flag=true;
                    break;
                }
            }
        }
        //if(flag)continue;
        
    }
    
    if(ans.size()==n){
        for(auto x:ans)cout<<x<<endl;
        return 0;
    }
    cout<<-1;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep_r(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=((int)(m));i<(int)(n);++i)
#define FOR_R(i,m,n) for(int i=((int)(m)-1);i>=(int)(n);--i)
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vp vector<pii>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define INF 1e9
#define LLINF 1e18
#define PI (acos(-1))
#define MOD 1e9+7

int main(){
	int n;
	cin >> n;
	
	vi h(n);
	rep(i, n){
		cin >> h[i];
	}
	
	int cnt = 0, ans = 0;
	rep(i, n - 1){
		if(h[i] >= h[i + 1]){
			cnt++;
		}
		else{
			ans = max(ans, cnt);
			cnt = 0;
		}
	}
	ans = max(ans , cnt);
	cout << ans << endl;
	return 0;
}

	
	

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

using P = std::pair<int, int>;

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

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

    int s[N];
    std::memcpy(s, x, sizeof(int) * N);
    std::sort(s, s + N);

    int m1 = s[(N - 1) / 2]; 
    int m2 = s[N / 2]; 
    for (int i = 0; i < N; ++i) {
        if (x[i] <= m1) {
             std::cout << m2 << std::endl;
        } else {
             std::cout << m1 << std::endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3712
// pana1-1
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

ll a[32] = {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 main(){

    ll b;
    cin >> b;
    cout << a[b-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

int main() {
  ll n;
  cin >> n;
  fact(n);
  vec x(n);
  for(ll i=0;i<n;i++) cin >> x[i];
  stack<ll> q;
  ll ans=1;
  for(ll i=0;i<n;i++) {
    q.push(x[i]);
    ll k=q.size();
    if(x[i]<2*k-1) {
      (ans*=k)%=mod;
      q.pop();
    }
  }
  (ans*=tfact[q.size()])%=mod;
  cout << ans << endl;
}

Measured memory_bytes: 80000
#!/usr/bin/env python3

import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

res = 0
for b in B:
    index_a = bisect.bisect_left(A, b)
    index_c = bisect.bisect_right(C, b)
    res += index_a * (N - index_c)

print(res)


Measured memory_bytes: 107108
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll ans=LLINF,now=0,cnt=0;
    string s;
    cin>>s;
    map<int,int> mp;
    ll n=s.size();
    rep(i,n){
        mp[s[i]-'a']++;
    }
    for(auto i:mp){
        rep(j,n){
            if((s[j]-'a')!=i.first) cnt++;
            else{
                now=max(cnt,now);
                cnt=0;
            }
        }
        now=max(cnt,now);
        ans=min(ans,now);
        now=0;cnt=0;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;

#define sci(x) scanf("%d", &x)
#define scd(x) scanf("%lf", &x)
#define scs(x) scanf("%s", x)
#define pri(x) printf("%d\n", x)
#define prd(x) printf("%f\n", x)
#define prs(x) printf("%s\n", x)

#define modp(x, y) (((y) + (x) % (y)) % (y))

char S[100001];

int main(int argc, char* argv[])
{
	scs(S);
	int N = strlen(S);

	int ans = 0;
	for(int i = 1; i < N; i++)
	{
		if(S[i - 1] != S[i]) ans++;
	}
	pri(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int D; cin >> D;
    vector<int> C(26 + 1);
    for (int i = 1; i <= 26; i++) cin >> C[i];
    vector<vector<int>> S(D + 1, vector<int>(26 + 1));
    for (int i = 1; i <= D; i++) {
        for (int j = 1; j <= 26; j++) cin >> S[i][j];
    }

    vector<int> T(365 + 1);
    vector<vector<int>> last(D + 1, vector<int>(26 + 1));
    ll sum = 0;
    for (int d = 1; d <= D; d++) {
        int num = 0;
        ll grd = (-1) * INF;
        int daybef = 0;
        for (int t = 1; t <= 26; t++) {
            ll tmp = 0;
            tmp += (ll)S[d][t];
            int bef = last[d][t];
            last[d][t] = d;
            for (int i = 1; i <= 26; i++) {
                tmp -= (ll)C[i] * (d - last[d][i]);
            }
            if (chmax(grd, tmp)) {
                num = t;
                daybef = bef;
            }
            last[d][t] = bef;
        }
        last[d][num] = d;
        for (int i = daybef; i < d; i++) {
            last[i][num] = daybef;
        }
        T[d] = num;
        sum += (ll)S[d][num];
        for (int i = 1; i <= 26; i++) {
            sum -= (ll)C[i] * (d - last[d][i]);
        }
    }

    for (int q = 0; q <= 100000; q++) {
        int d =  rand() % D + 1;
        int u = rand() % 26 + 1;
        ll oldSum = sum;
        sum -= S[d][T[d]];
        for (int i = 1; i <= 26; i++) {
            sum += (ll)C[i] * (d - last[d][i]);
        }
        int oldT = T[d];
        T[d] = u;
        sum += S[d][u];
        last[d][oldT] = last[d - 1][oldT];
        int bef = last[d][u];
        last[d][u] = d;
        for (int i = 1; i <= 26; i++) {
            sum -= (ll)C[i] * (d - last[d][i]);
        }
        if (oldSum >= sum) {
            T[d] = oldT;
            last[d][T[d]] = d;
            last[d][u] = bef;
            sum = oldSum;
        }
    }

    for (int i = 1; i <= D; i++) {
        printf("%d\n", T[i]);
    }

    return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
  }
    cout << str << endl;
  return 0;
}


Measured memory_bytes: 3208
import sys

N, M, K = [int(s) for s in sys.stdin.readline().split()]
n = 0
A = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    A.append(n)

n = 0
B = [0]
for s in sys.stdin.readline().split():
    n = n + int(s)
    B.append(n)

ans = 0
for i in range(N + 1):
    if A[i] > K:
        break
    for j in range(M, -1, -1):
        if A[i] + B[j] <= K:
            ans = max(ans, i + j)
            M = j
            break

print(ans)

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

using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ll long long
#define li long int
#define ld long double
#define lld long long double

#define pb push_back
#define mk make_pair
#define F first
#define S second

#define all(v) (v).begin(),(v).end()
#define fill(a) memset(a, 0, sizeof(a))

const int MX = 1e6;
const int MI = -1e6;
const int MOD = 1e9 + 7;
const string ALPHA = "abcdefghijklmnopqrstuvwxyz";
const double PI = 3.1415926535;

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

const int mod=1e9+7;
inline int add(int x,int y){
  x+=y;
  if (x>=mod) return x-mod;
  return x;
}
inline int sub(int x,int y){
  x-=y;
  if (x<0) return x+mod;
  return x;
}
inline int mul(int x,int y){
  return (x*1ll*y)%mod;
}
inline int power(int x,int y){
  int ans=1;
  while(y){
    if (y&1) ans=mul(ans,x);
    x=mul(x,x);
    y>>=1;
  }
  return ans;
}
inline int inv(int x){
  return power(x,mod-2);
}

int main()
{
  IOS;
  string s;
  cin >> s;
  if (s[2]==s[3] && s[4]==s[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3616
s = input()
yy = int(s[:2])
mm = int(s[2:])
if (not 1<=yy<=12) and (1<=mm<=12):
    print("YYMM")
elif (1<=yy<=12) and (not 1<=mm<=12):
    print("MMYY")
elif (1<=yy<=12) and (1<=mm<=12):
    print("AMBIGUOUS")
else:
    print("NA")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

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

    int migiuex = w;
    int migiuey = h;
    int hidarishitax = 0;
    int hidarishitay = 0;

    rep(i,n){
        int x, y, a; cin >> x >> y >> a;
        if(a == 2) migiuex = min(migiuex,x);
        if(a == 1) hidarishitax = max(hidarishitax,x);
        if(a == 4) migiuey = min(migiuey,y);
        if(a == 3) hidarishitay = max(hidarishitay,y);
    }

    if(migiuex-hidarishitax <= 0 || migiuey-hidarishitay <= 0){
        cout << 0 << endl;
        return 0;
    }

    cout << max((migiuex-hidarishitax) * (migiuey-hidarishitay) , 0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define re register int
#define F(x,y,z) for(re x=y;x<=z;x++)
#define FOR(x,y,z) for(re x=y;x>=z;x--)
typedef long long ll;
#define I inline void
#define IN inline int
#define C(x,y) memset(x,y,sizeof(x))
#define STS system("pause")
template<class D>I read(D &res){
	res=0;register D g=1;register char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')g=-1;
		ch=getchar();
	}
	while(isdigit(ch)){
		res=(res<<3)+(res<<1)+(ch^48);
		ch=getchar();
	}
	res*=g;
}
#define x first
#define y second
typedef pair<int,int>pii;
char c[220][220];
int n,m,dis[220][220],a[220][220],w,ans;
pii p;
queue<pii>q;
int main(){
	read(n);read(m);
	F(i,1,n)cin>>c[i]+1;
	F(i,1,n)F(j,1,m)a[i][j]=(c[i][j]=='.'?1:0);
	C(dis,-1);
	dis[1][1]=0;
	q.emplace(make_pair(1,1));
	while(!q.empty()){
		p=q.front();q.pop();
		if(p.x<n&&!a[p.x][p.y]&&a[p.x+1][p.y])w=1;else w=0;
		if(p.x<n&&(dis[p.x+1][p.y]==-1||dis[p.x+1][p.y]>dis[p.x][p.y]+w)){
			dis[p.x+1][p.y]=dis[p.x][p.y]+w;q.emplace(make_pair(p.x+1,p.y));
		}
		if(p.y<m&&!a[p.x][p.y]&&a[p.x][p.y+1])w=1;else w=0;
		if(p.y<m&&(dis[p.x][p.y+1]==-1||dis[p.x][p.y+1]>dis[p.x][p.y]+w)){
			dis[p.x][p.y+1]=dis[p.x][p.y]+w;q.emplace(make_pair(p.x,p.y+1));
		}
	}
	ans=dis[n][m];
	if(!a[n][m])ans++;
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
// let coding = begin

#include <bits/stdc++.h>

#define ll long long
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;
const int MAX = 1e9 + 9;
const int MIN = -1e9;
const int N = (1e5 + 9) * 2 + 9;
const double PI = 3.14159265;

int tab[5];
int k;
int main()
{
  clock_t start;
  for (int i = 0; i < 5; i++)
  {
    cin >> tab[i];
  }
  cin >> k;
  for (int i = 0; i < 5; i++)
  {
    for (int j = 0; j < 5; j++)
    {
      if (i != j)
      {
        if (abs(tab[i] - tab[j]) > k)
        {
          cout << ":(" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yay!" << endl;
  cerr << "Time: " << (clock() - start) / (double)(CLOCKS_PER_SEC / 1000) << " ms" << endl;
  return 0;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int x,y;
		cin >> x >> y;
		if(x==1 && y==1) 
		{
			cout << 1000000 << endl;
			return 0;
		}
		int mon = 0;
		if (x==1) mon+=300000;
		else if (x==2) mon+=200000;
		else if (x==3) mon+=100000;
		else mon+=0;
		if (y==1) mon+=300000;
		else if (y==2) mon+=200000;
		else if (y==3) mon+=100000;
		else mon+=0;
		cout << mon << endl;
		return 0;  
}  


Measured memory_bytes: 3652
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int p = 0;
		for (int i=0; i<n; i++) {
			String s = in.next();
			if ("A".equals(s)) {
				p++;
			} else {
				p--;
			}

			if (p < 0) {
				out.println("NO");
				return;
			}
		}

		if (p == 0) {
			out.println("YES");
		} else {
			out.println("NO");
		}
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 26284
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int n;
    cin >> n;
    vi a(n);
    rep(i, n){
        cin >> a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    string s;
    cin >> s;

    int ret = 0;
    for (char c : s)
        ret = (ret * 10 + c - '0') % 9;
    cout << (ret ? "No" : "Yes") << "\n";

    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stack>
#include<set>
#include<string>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
    ll N,D,ans=0;
    cin>>N>>D;
    while(N--)
    {
        ll x,y;
        cin>>x>>y;
        if(x*x+y*y<=D*D)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Solve(vector<int> & d, int s) {
	int i, j, ans = 0;
	rep(i, s) {
		if (d[i] == d[s])
			continue;
		for (j = i + 1; j < s; j++) {
			if (d[i] == d[j] || d[j] == d[s])
				continue;
			if(d[i] + d[j] > d[s])
				ans++;
		}
	}
	return ans;
}

int main(void) {
	int num, i;
	ll ans = 0;
	cin >> num;
	vector<int> d(num);
	rep(i, num)
		cin >> d[i];
	sort(d.begin(), d.end());
	for (i = 2; i < d.size(); i++) {
		ans += Solve(d, i);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long

using namespace std;

string S;

int main(){
    ll N,K;
    cin >> N >> K;
    cout << N*N-K << endl;
    return 0;
}


Measured memory_bytes: 256
# python3

#===============================================================================
from collections import defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
from math import gcd, floor, ceil
from sys import stdin, stdout

def ilist():
    return [int(x) for x in stdin.readline().strip().split(" ")]
def iint():
    return int(stdin.readline().strip())
def istr():
    return stdin.readline().strip()
##==============================================================================


def solve(X):
    c = {}
    for i in range(1000):
        c[i] = i ** 5
        c[-i] = -c[i]
    for i in c:
        for j in c:
            if c[i] - c[j] == X:
                return str(i) + " " + str(j)


if __name__ == '__main__':
    X = iint()
    print(solve(X))


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

public class Main {
    public static void main(String[] arg) {

        try (Scanner scanner = new Scanner(System.in)){
            String input = scanner.nextLine();
            int[] i = Arrays.stream(input.split(" ")).mapToInt(Integer::parseInt).toArray();
            System.out.println(i[0] >= i[1] ? "10" : "0");
        }

    }
}


Measured memory_bytes: 26960