akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;
struct edge{ int to,cost; };

const int N=300, INF=123456789;
vector<edge> G[N];

int dp[16][1<<16];
int dist[16][16];

int d[N];
void dijkstra(int start)
{
    fill(d,d+N,INF);

    priority_queue<pi,vector<pi>,greater<pi>> que;
    d[start]=0;
    que.push(pi(0,start));
    while(!que.empty()){
        pi p=que.top();
        que.pop();
        int v=p.se;
        if(d[v]<p.fi) continue;
        rep(i,G[v].size())
        {
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost)
            {
                d[e.to]=d[v]+e.cost;
                que.push(pi(d[e.to],e.to));
            }
        }
    }
}

int main()
{
    int n,m,l,s,t;
    while(scanf(" %d %d %d %d %d", &n, &m, &l, &s, &t),n)
    {
        --s;
        rep(i,N) G[i].clear();

        rep(i,m)
        {
            int a,b,c;
            scanf(" %d %d %d", &a, &b, &c);
            --a;
            --b;
            G[a].pb(edge{b,c});
            G[b].pb(edge{a,c});
        }

        vector<int> J(l), E(l);
        rep(i,l)
        {
            scanf(" %d %d", &J[i], &E[i]);
            --J[i];
        }

        fill(dp[0],dp[16],INF);

        // ??????????????°?????????
        dijkstra(s);
        rep(i,l) dp[i][1<<i] = d[J[i]] + E[i];

        rep(i,l)
        {
            dijkstra(J[i]);
            rep(j,l) dist[i][j] = d[J[j]];
        }

        for(int mask=1; mask<(1<<l); ++mask)rep(last,l)
        {
            if(!(mask>>last&1)) continue;

            rep(nx,l)if(!(mask>>nx&1))
            {
                int nmask = mask|(1<<nx);
                dp[nx][nmask] = min(dp[nx][nmask], dp[last][mask] + dist[last][nx] + E[nx]);
            }
        }

        int ans=0;

        dijkstra(s);
        rep(mask,1<<l)
        {
            rep(i,l)
            {
                if(dp[i][mask] + d[J[i]] <= t) ans=max(ans,__builtin_popcount(mask));
            }
        }

        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 7368
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
	int x=0;
	char ch=' ';
	bool flag=false;
	while(!isdigit(ch))
	{
		if(ch=='-')flag=true;
		ch=getchar();
	}
	while(isdigit(ch))
	{
		x=(x<<3)+(x<<1)+ch-'0';
		ch=getchar();
	}
	return flag?-x:x;
}
const int MAX_N=2005;
int n;
int A[MAX_N];
bool vis[MAX_N];
vec g[MAX_N];
vec g2[MAX_N];
int in[MAX_N];
void dfs(int v)
{
	if(vis[v])return;
	vis[v]=true;
	Forenska(it,g[v])
	{
		if(!vis[*it])
		{
			g2[v].pb(*it);
			dfs(*it);
		}
	}
}
void topo()
{
	set <int> s;
	rep(i,0,n)if(!vis[i])
	{
		dfs(i);
		s.insert(-i);
	}
	while(!s.empty())
	{
		int t=-*s.begin();
		s.erase(s.begin());
		Forenska(it,g2[t])
		{
			s.insert(-*it);
		}
		cout<<A[t]<<" ";
	}
}
int main()
{
	cin>>n;
	rep(i,0,n)cin>>A[i];
	sort(A,A+n);
	rep(i,0,n)rep(j,0,n)if(__gcd(A[i],A[j])>1)
	{
		g[i].pb(j);
	}
	topo();
	return 0;
}

Measured memory_bytes: 15872
from fractions import gcd

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

S = []
for i in range(N):
    S.append(abs(a-X[i]))

ans = S[0]
for i in range(1, N):
    ans = gcd(ans,S[i])

print(ans)

Measured memory_bytes: 16284
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

int dp[2005][2005];

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

    
    int n; cin >> n;
    std::vector<int> p(n); rep(i,n) cin >> p[i];

    bool real_good = false;

    rep(i,n) rep(j,n){
        bool good = true;

        std::vector<int> v = p;
        int temp = v[i];
        v[i] = v[j];
        v[j] = temp;

        rep(k,n-1){
            if(v[k] > v[k+1]) good = false;
        }

        if(good) real_good = true;
    }

    if(real_good) cout << "YES" << endl;
    else cout << "NO" << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#define N 100005
using namespace std;

int n, a, ans, cnt1, cnt2, v[N];
vector<int> b, s;
queue<int> q1, q2;
int main()
{
    int i, j, k, t2, t1, t3;
//    freopen ("input.txt", "r", stdin);
    cin >> n;
    for (i = 0; i <n; i++) {
        scanf ("%d", &a);
        v[a]++;
    }
    for (i = 1; i <= 100000; i++) {
        if (v[i] > 0) {
                b.push_back(i);
                s.push_back(v[i]);
        }
    }
//    for (i = 0; i < b.size(); i++) {
//        if (s[i] >= 2) q2.push(i);
//        q1.push(i);
//    }
    for (i = 0; i < b.size(); i++) {
        while (s[i] > 2) s[i] -= 2;
        if (s[i] == 1) cnt1++;
        else cnt2++;
    }
    ans = cnt1 + cnt2;
    if (cnt2 % 2 == 1) ans--;
    cout << ans << endl;
//    for (i = 0; i < b.size(); i++) {
//        while (s[i] > 2) s[i] -= 2;
//        if (s[i] <= 1) continue;
//        while (!q2.empty()) {
//            t2 = q2.front();
//            if (t2 <= i || s[t2] < 2) q2.pop();
//            else break;
//        }
////        while (!q3.empty()) {
////            t3 = q3.front();
////            if (t3 <= i || s[t3] < 3) q3.pop();
////            else break;
////        }
//        t2 = t3 = -1;
//        if (!q2.empty()) t2 = q2.front();
////        if (!q3.empty()) t3 = q3.front();
//        if (t2 != -1) {
//            s[i]--;
//            s[t2]--;
//        } else {
//            s[i]--;
//            s[i + 1]--;
//        }
//    }
//    for (i = 0; i <b.size(); i++) {
//        if (s[i] == 1) cnt++;
//    }
//    cout << cnt << endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

int main() {
  int N;
  string K;
  cin >> N >> K;
  
  if((int)(K.length()) <= N)
    cout << K << endl;
  else{
    rep(i,N)
    	cout << K[i];
    cout << "..."<<endl;
  }
    
}

Measured memory_bytes: 3592
N,K=map(int,input().split())
P,C=[list(map(int,input().split())) for i in range(2)]
r=-10**18
for j in range(N):
    d=[0]*(N+1)
    p=j
    for i in range(N):
        p=P[p]-1
        d[i+1]=d[i]+C[p]
        if p==j:
            break
    q=max(d[1:K+1]) if K<i+1 else max(d[1:i+1]) if d[i+1]<0 else max(max(d)+d[(i+1)]*(K//(i+1)-1),max(d[:K%(i+1)+1])+d[i+1]*(K//(i+1)))
    r=max(r,q)
print(r)

Measured memory_bytes: 71584
X,Y=map(int,input().split())

def cnb(n,k,p):
  if k>n:
    return 0
  if k>n-k:
    k=n-k
  c,d=1,1
  for i in range(n-k+1,n+1):
    c = (c*i)%p
  for i in range(1,k+1):
    d = (d*i)%p
  return (c*pow(d,p-2,p))%p

p=10**9+7
ans=0
if X > 2*Y or Y > 2*X:
  pass
elif (X+Y)%3:
  pass
else:
  ans=cnb((X+Y)//3,(2*Y-X)//3,p)

print(ans)


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                double w = double.Parse(input);

                sb.AppendLine(CheckClass(w));
            }
            Console.Write(sb);
        }

        static string CheckClass(double w)
        {
            if (w > 91) return "heavy";
            if (w > 81) return "light heavy";
            if (w > 75) return "middle";
            if (w > 69) return "light middle";
            if (w > 64) return "welter";
            if (w > 60) return "light welter";
            if (w > 57) return "light";
            if (w > 54) return "feather";
            if (w > 51) return "bantam";
            if (w > 48) return "fly";
            return "light fly";
        }
    }
}

Measured memory_bytes: 9328
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string str;
    cin>>str;
    int s=0;
    for(int i=0;str[i];i++)
    {
        if(str[i]=='+')
        s++;
        else
        s--;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>

int main(void)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if((a!=b && b==c && a!=c )||(a!=b && b!=c && a==c )||(a==b && b!=c && a!=c)){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
mod = 998244353


N, M, K = map(int, input().split())


invs = {}


def inv(n):
    if n not in invs:
        invs[n] = pow(n, mod-2, mod)
    return invs[n]


powers = {(M-1, N-1): pow(M-1, N-1, mod)}


def power(x, y):
    if y == 0:
        return 1
    if (x, y) not in powers:
        powers[(x, y)] = powers[(x, y+1)] * inv(x)
        powers[(x, y)] %= mod
    return powers[(x, y)]


ans = 0
comb = 1
for i in range(K+1):
    now = M*power(M-1, N-1-i)*comb
    now %= mod
    ans += now
    ans %= mod
    comb *= ((N-i-1)*inv(i+1))
    comb %= mod

print(ans)


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

typedef long long int in;

vector<in> v[200005];

map<in,in> mp;

int main() 
{
	in n,k,i;
    cin>>n>>k;

    for(i=1;i<=n;++i)
    {
        in val;
        cin>>val;

        v[i].push_back(val);
    }

    in par=1,cnt=0;

    while(mp.find(par)==mp.end())
    {
        mp[par]=cnt;

        ++cnt;

        for(auto it:v[par])
        par=it;
    }
    
    if(mp[par]>=k)
    {
        par=1;

        while(k--)
        {
            for(auto it:v[par])
            par=it;
        }
    }
    else
    {
        k=k-mp[par];

        k=k%(cnt-mp[par]);

        while(k--)
        {
            for(auto it:v[par])
            par=it;
        }
    }

    cout<<par;

	return 0;
}





Measured memory_bytes: 26740
#include<iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include<string>
using namespace std;
int main(){
	int a = 0, b = 0, c=0, d[100000], e[100000],f=0, count = 0;
	char uc[100000];
	for (int i = 0; i < 4; i++) {
		cin >> uc[i];
	}
	if (uc[0] == uc[1]&& uc[1] == uc[2] || uc[1] == uc[2]&& uc[2] == uc[3]) {
		cout << "Yes" << endl;
	}
	else { cout << "No" << endl; }
		return 0;
}

Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
// typedef long long ll;

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  vector<pair<int,int>> S;
  rep(i,n){
    S.push_back(make_pair(a[i],i+1));
  }
  sort(S.begin(),S.end());
  rep(i,n){
    printf("%d ", S[i].second);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2164
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define MOD 1000000007
// a^b mod MOD
ll powmod(ll a,ll b){
	ll out=1;
	ll p=a%MOD;
	while(b){
		if(b&1)out=out*p%MOD;
		p=p*p%MOD;
		b>>=1;
	}
	return out;
}
ll gcd(ll a,ll b){
	return (b==0?a:gcd(b,a%b));
}
ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
#define M 10000
vector<ll> fact;
void init(){
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// nCr
ll nCr(ll n,ll r){
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%MOD,MOD-2)%MOD;
	return out;
}	
int main(){
	init();
	int n,a,b;
	cin>>n>>a>>b;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in));
	vector<int> co;
	int c=1;
	rep(i,n-1){
		if(in[i]!=in[i+1]){
			co.pb(c);
			c=1;
		}else c++;
	}
	co.pb(c);
	int t=co.size()-1;
	bool h=false;
	ll sum=0;
	rep(i,a)sum+=in[n-1-i];
	cout<<shosu(10)<<(double)sum/a<<endl;
	while(1){
		if(a<=co[t]){
			ll out=0;
			if(h){
				out=nCr(co[t],a);
			}else{
				ll w=co[t];
				loop(i,1,min(b,co[t])+1){
					if(a<=i)out+=w;
					ll S=(i+1),T=(co[t]-i);
					if(T==0)break;
					ll Q=gcd(S,T);
//					cout<<S<<" "<<T<<" "<<w<<endl;
	//				cout<<Q<<endl;
					S/=Q,T/=Q;
					w=w/S*T;
				}
			}
			cout<<out<<endl;
			return 0;
		}
		h=true;
		a-=co[t];
		b-=co[t];
		t--;
	}
}









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

typedef long long int ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll,ll>> lr(m);
    for(ll i = 0;i < m;i++){
        cin >> lr[i].first >> lr[i].second;
    }

    ll minr = lr[0].second, maxl = lr[0].first;

    for(ll i = 0;i < m;i++){
        minr = min(minr, lr[i].second);
        maxl = max(maxl, lr[i].first);
    }
    if(minr < maxl){
        cout << 0;
        return 0;
    }
    cout << minr - maxl + 1;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>  
#include <string>
#include <cstdio>
#include <iostream>
#include <algorithm> 

using namespace std;

typedef signed long long ll;
typedef unsigned long long ull;
typedef vector< pair<int, int> > vec_int_pairs;
typedef vector<int>  vecint;
typedef vector< vector<int> > vecint2;
typedef vecint2 graph;
typedef map<int, int> int_int_map;

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


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

int main() {
    long long N,K;
    cin>>N>>K;

    cout<<( (abs(N-N/K*K)>abs(N-N/K*K-K) )? abs(N-N/K*K-K):abs(N-N/K*K) )<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#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,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define INF (1e12)
#define MAX 500000



int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    while(a[n-2] != 0){
        int minv;
        int tmp;
        rep(i,n){
            if(a[i] != 0){
                minv = a[i];
                tmp = i;
                break;
            }
        }
        repR(i,n){
            if(i == tmp) continue;
            if(a[i] == 0) break;
            a[i] = a[i] % minv;
        }
        sort(all(a));
    }
    cout << a[n-1] << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int a;
  int b;
  cin >>a>>b;
  if(a>b) {
    cout <<a-1 << endl;
  }
  if (a<=b) {
    cout << a<< endl;
  }
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */


int f(int a, int k) {
	int ret = a;
	for (int i = 0; i < k; i++) {
		ret *= 2;
	}
	return ret;
}

int main() {
	cout << fixed << setprecision(12);	
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			for (int t = 0; t <= k; t++) {
				if (i + j + t > k) {
					continue;
				}
				int ta = f(a, i);
				int tb = f(b, j);
				int tc = f(c, t);
				if (tc > tb && tb > ta) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int cmin(int a,int b){
	if(a<b) return a;
	else return b;
}

int main() {
	int n;
	scanf("%d",&n);//足場の数の入力
	int h[n];
	for(int i=0;i<n;i++){//足場それぞれの高さの入力&総和の初期値入力(最大値)
		scanf("%d",&h[i]);
	}
	int sum[n];
	for(int i=0;i<n;i++){
			sum[i] = 1e9;
	}
	sum[0]=0;
	for(int i=0;i<n;i++){
		if(i>=1){
			sum[i]=cmin(sum[i],sum[i-1] + abs(h[i-1]-h[i]));
		}
		if(i>=2){
			sum[i]=cmin(sum[i],sum[i-2] + abs(h[i-2]-h[i]));
		}
	}
	printf("%d\n",sum[n-1]);
	return 0;
}

Measured memory_bytes: 2448
#include<stdio.h>
int main()
{
    int a,b,r1,r2,l1,l2,i,j,n;
    scanf("%d%d",&a,&b);
    if(b%a==0){
        printf("%d\n",a+b);
    } else{
        printf("%d\n",b-a);
    }

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define abs(a) (a>0) ? (a) : (-(a))

long long solve(int num[200010],int n,int b);
void quicksort(int data[],int left,int right);

int main()
{
    int n,i,j,num[200010],sa[200010],b,margin1,margin2;
	long long ans,kari1,kari2;
    scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&(num[i]));
		sa[i]=num[i]-i-1;//b=0
	}
	quicksort(sa,0,n-1);
	margin1=sa[n/2];
	margin2=sa[n-1-(n/2)];

	kari1=solve(num,n,margin1+1);
	kari2=solve(num,n,margin2+1);
	if(kari1<=kari2)ans=kari1;
	else ans=kari2;
	
    printf("%lld",ans);
}

long long solve(int num[200010],int n,int b)//bは初項
{
	int j;
	long long kari=0;
	for(j=0;j<n;j++)
	{
		kari+=abs(b+j-num[j]);
	}
	return kari;
}

void quicksort(int data[],int left,int right)
{
	int i,j;
	int std,work;
	if(left<right)
	{
		i=left,j=right;
		std=data[(i+j)/2];//基準
		do
		{
			while(data[i] > std)i++;
			while(data[j] < std)j--;
			if(i<=j)
			{
				if(i<j)
				{
					work=data[i];
					data[i]=data[j];
					data[j]=work;
				}
				i++; j--;
			}
		}while(i<=j);
		if(left<j)quicksort(data,left,j);
		if(i<right)quicksort(data,i,right);
	}
}

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

int main(){
 int H,a[251];
 cin>>H;
 for(int i=1;i<H+1;i++){
     cin>>a[i];
 }
 
 for(int i=1;i<H+1;i++){
     cout<<"node "<<i<<": key = "<<a[i]<<", ";
     if(i/2>=1)cout<<"parent key = "<<a[i/2]<<", ";
     if(2*i<=H)cout<<"left key = "<<a[2*i]<<", ";
     if(2*i+1<=H)cout<<"right key = "<<a[2*i+1]<<", ";
     cout<<endl;
}
return 0;
}


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

int main() {

   int n;
   cin>>n;
   
   int arr[n];
   
   for(int i=0;i<n;++i)
    cin>>arr[i];
    
    sort(arr,arr+n);
    
    int sum=0;
    for(int i=0;i<n-1;++i)
      sum+=arr[i];
   
   if(sum>arr[n-1])
      cout<<"Yes";
      
      else
      cout<<"No";
   
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807

int main(){
    
  string S;
  cin >> S;
  if(S.size() == 2) cout << S << endl;
  else{
    cout << S[2] << S[1] << S[0] << endl;
  }
  
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class ASumOfInteriorAngles {
        private InputReader in;
        private PrintWriter out;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            out.println((in.nextInt() - 2) * 180);
        }

    }

    static class InputReader extends InputStream {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 21460
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main()
	{
		long[] t = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => long.Parse(number));
		long n = long.Parse(Console.ReadLine());

		var datas = new[] {
			new {
				Ryo = 250,
				Cost = t[0],
				Perf = t[0] * 8,
			},
			new {
				Ryo = 500,
				Cost = t[1],
				Perf = t[1] * 4,
			},
			new {
				Ryo = 1000,
				Cost = t[2],
				Perf = t[2] * 2,
			},
			new {
				Ryo = 2000,
				Cost = t[3],
				Perf = t[3],
			},
		};

		Array.Sort(datas, (d1, d2) => d1.Perf < d2.Perf ? -1 : 1);

		long total = 0;
		long last = n * 1000;
		foreach (var data in datas) {
			if (last >= data.Ryo) {
				long ans = last / data.Ryo;
				total += ans * data.Cost;
				last = last % (ans * data.Ryo);
			}
		}

		Console.WriteLine(total);

		//デバッグ実行での確認用。そのまま提出しても問題なし
		Console.ReadKey();
	}
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

int main() {
    ll A;
    string B;
    cin >> A >> B;
    string tmp = "";
    rep(i, B.size()) {
        if (B[i] != '.') tmp += B[i];
    }
    ll tmp2 = stoi(tmp);
    cout << (A*tmp2)/100 << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<cstring>
#include<cstdio>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int n, K, t=1;
	scanf("%d%d", &n, &K);
	for(int i = 1; i <= n; i++)
	{
		if(2*t < t+K) t = 2*t;
		else t = t+K;
	}
	printf("%d\n", t);
	return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws NumberFormatException, IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] input = br.readLine().split(" ");
        int[] A = new int[n];

        int minj = 0;
        int changeBox = 0;
        int count = 0;

//      N????????´??°?????????A???????´?
        for(int i = 0; i < n; i++){
            A[i] = Integer.parseInt(input[i]);
        }

        for(int i = 0; i < n; i++){
            minj = i;

            for(int j = i; j < n; j++){
                if(A[j] < A[minj]){
                    minj = j;
                }
            }
            if(i != minj){
                changeBox = A[i];
                A[i] = A[minj];
                A[minj] = changeBox;
                count++;
            }
        }
        for(int i = 0; i < n; i++){
            if(i == 0){
                System.out.print(A[i]);
            }else{
                System.out.print(" " + A[i]);
            }
        }
        System.out.println();
        System.out.println(count);
    }
}

Measured memory_bytes: 24256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
//	cout << fixed << setprecision(15);
	int A, B, M;
	cin >> A >> B >> M;
	vi a(A), b(B);
	rep(i, A) cin >> a[i];
	rep(i, B) cin >> b[i];
	vi x(M), y(M), c(M);
	rep(i, M) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--;
		y[i]--;
	}

	int min_a = INF, min_b = INF;
	rep(i, A) min_a = min(a[i], min_a);
	rep(i, B) min_b = min(b[i], min_b);
	int ans = min_a + min_b;
	rep(i, M) {
		ans = min(a[x[i]] + b[y[i]] - c[i], ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 2176
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


pair<int, int> s[200000];
pair<int, int> arm[100000];

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

	int n, m;
	cin >> n >> m;
	rep(i, m) {
		cin >> arm[i].first >> arm[i].second;
	}
	sort(arm, arm + m);
	rep(i, n)s[i] = make_pair(i, i);

	rep(i,m){
		auto a = arm[i];
		pair<int, int> p = make_pair(s[a.second - 1].first, s[a.second].second);
		s[a.second - 1] = s[a.second] = p;
	}
	rep(i, n) {
		if (i)cout << ' ';
		cout << s[i].second - s[i].first + 1;
	}
	cout << endl;


	return 0;
}

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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
//const Int mod = 1e9+7;
const Int mod = 998244353;

bool print_space_enable = false;
void print() { 
    cout << endl; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int dp[3001][3001];

int main() {
    Int a, b, c, d;
    cin >> a >> b >> c >> d;
    dp[0][0] = 1;
    for (Int i = 0; i <= c - a; i++) {
        for (Int j = 0; j <= d - b; j++) {
            if (i == 0) {
                if (j > 0) {
                    dp[i][j] = dp[i][j - 1] * a % mod;
                }
                continue;
            }
            if (j == 0) {
                if (i > 0) {
                    dp[i][j] = dp[i - 1][j] * b % mod;
                }
                continue;
            }
            Int x = dp[i - 1][j] * (b + j) % mod;
            Int y = dp[i][j - 1] * (a + i) % mod;
            dp[i][j] = (x + y) % mod;
            Int z = dp[i - 1][j - 1] * (b + j - 1) % mod;
            z = z * (a + i - 1) % mod;
            dp[i][j] = (dp[i][j] - z + mod) % mod;
            // dp[i][j] = (dp[i][j] - dp[i - 1][j - 1] * (b + j - 1) * (a + i - 1) + mod) % mod;
        }
    }
    print(dp[c - a][d - b]);
    return 0;
}

Measured memory_bytes: 73852
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMod = 1e9 + 7;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  ll n = N % 10;
  if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
    cout << "hon" << endl;
  } else if (n == 0 || n == 1 || n == 6 || n == 8) {
    cout << "pon" << endl;
  } else {
    cout << "bon" << endl;
  }

  return 0;
}


Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &k, &s)

	p := "1"
	c := 0
	counts := []int{}
	for i := 0; i < n; i++ {
		t := s[i : i+1]
		if p != t {
			counts = append(counts, c)
			c = 0
		}
		c++
		p = t
	}
	counts = append(counts, c)
	if p == "0" {
		counts = append(counts, 0)
	}

	w := make([]int, len(counts)+1)
	for i := 0; i < len(counts); i++ {
		w[i+1] = w[i] + counts[i]
	}

	ans := 0
	for l := 0; l < len(w); l += 2 {
		r := l + k*2 + 1
		if r >= len(w) {
			r = len(w) - 1
		}
		c := w[r] - w[l]
		if ans < c {
			ans = c
		}
	}
	fmt.Println(ans)
}


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

int main() {

  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  ll tmp;
  ll max = -1e18;
  tmp = a * c;
  if(tmp > max){
    max = tmp;
  }
  tmp = a * d;
  if(tmp > max){
    max = tmp;
  }
  tmp = b * c;
  if(tmp > max){
    max = tmp;
  }
  tmp = b * d;
  if(tmp > max){
    max = tmp;
  }
  cout << max << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
#define MOD 1000000007

class Fenwick {
private:
	int n;
	vector<int> node;

public:
	Fenwick(int N): node(N + 1) {
		n = N;
	}

	void add(int i, int x) {
		i++;
		while(i <= n) {
			node[i] += x;
			i += i & -i;
		}
	}

	int sum(int i) {
		int s = 0;
		while(i > 0) {
			s += node[i];
			i -= i & -i;
		}
		return s;
	}

	int sum(int a, int b) {
		return sum(a) - sum(b);
	}
};
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N, Q;
    cin >> N >> Q;

    vector<int> c(N);
    vector<int> count(N);
    vector<int> n(N);
    vector<vector<int> > k(N);

    vector<vector<p> > q(N);
    vector<int> ans(Q);

    Fenwick fw(N);

    for(int i = 0; i < N; i++) {
        cin >> c[i];
        c[i]--;
        k[c[i]].push_back(i);
    }

    for(int i = 0; i < N; i++) {
        if(k[i].empty()) continue;
        fw.add(k[i][0], 1);
        k[i].push_back(0);
    }

    for(int i = 0; i < N; i++) {
        count[c[i]]++;
        n[i] = k[c[i]][count[c[i]]];
    }

    for(int i = 0; i < Q; i++) {
        int l, r;
        cin >> l >> r;
        l--;
        q[l].push_back(make_pair(r, i));
    }

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < q[i].size(); j++) {
            int r = q[i][j].first;
            int a = q[i][j].second;
            ans[a] = fw.sum(r, i);
        }
        fw.add(i, -1);
        fw.add(n[i], 1);
    }

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

Measured memory_bytes: 62628
n, k = list(map(int, input().split(' ')))

hs = []
for i in range(n):
    hs.append(int(input()))

sorted_hs = sorted(hs)

ret = None
for i in range(n-k+1):
    if ret is None or ret > sorted_hs[i+k-1] - sorted_hs[i]:
        ret = sorted_hs[i+k-1] - sorted_hs[i]

print(ret)

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

#define MX 200050
typedef long long ll;
int a[MX], n;
ll sl[MX], sr[MX];
pair<ll, ll> l[MX], r[MX];

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", a + i);
	for(int i = 1; i <= n; i++) sl[i] = sl[i - 1] + a[i];
	for(int i = n; i > 0; i--) sr[i] = sr[i + 1] + a[i];
	for(int i = 2; i < n; i++) {
		ll v = sl[i];
		int p = lower_bound(sl + 1, sl + i + 1, (v + 1) / 2) - sl;
		pair<ll, ll> res = make_pair(0, v);
		if(p < i && abs(res.first - res.second) > abs(sl[p] * 2 - v))	res = make_pair(sl[p], v - sl[p]);
		if(p > 1 && abs(res.first - res.second) > abs(sl[p - 1] * 2 - v))	res = make_pair(sl[p - 1], v - sl[p - 1]);
		l[i] = res;
	}
	for(int i = n - 1; i > 0; i--) {
		ll v = sr[i];
		int p = lower_bound(sr + i, sr + n + 1, (v + 1) / 2, greater<ll>()) - sr;
		pair<ll, ll> res = make_pair(0, v);
		if(p <= n && abs(res.first - res.second) > abs(sr[p] * 2 - v))	res = make_pair(sr[p], v - sr[p]);
		if(p > i + 1 && abs(res.first - res.second) > abs(sr[p - 1] * 2 - v))	res = make_pair(sr[p - 1], v - sr[p - 1]);
		r[i] = res;
	}
	long long res = sl[n];
	for(int i = 2; i < n - 1; i++) {
		ll mn = min(min(l[i].first, l[i].second), min(r[i + 1].first, r[i + 1].second));
		ll mx = max(max(l[i].first, l[i].second), max(r[i + 1].first, r[i + 1].second));
		res = min(res, mx - mn);
	}
	printf("%lld\n", res);
	return 0;
}


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


int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int  n,k;
  cin>>n>>k;
  int a[200005];
  int b[200005];
  for(int i=0;i<n;i++){
    cin>>a[i];
    b[i]=0;
  }
  b[n]=0;
  int d=min(50,k);
 
  for(int j=0;j<d;j++){
  for(int i=0;i<n;i++){
    int l=max(0,i-a[i]);
    int r=min(n,i+a[i]+1);
    b[l]++;
    b[r]--;
  }
    for(int i=1;i<n;i++){
     b[i]+=b[i-1];
      
    }
    for(int i=0;i<n;i++){
    a[i]=b[i];
      b[i]=0;
    }
   
  }
 
  
  for(int i=0;i<n;i++){
  cout<<a[i]<<" ";
  }
  






}

Measured memory_bytes: 5212
import math
#from functools import reduce

#def gcd(*numbers):
#    return reduce(math.gcd, numbers)

#def gcd_list(numbers):
#    return reduce(math.gcd, numbers)
  
n = int(input())
sum=0
for a in range(1, n+1):
    for b in range(1, n+1):
        ab=math.gcd(a,b)
        for c in range(1, n+1):
#            print(list(set([a,b,c])))
#            abc=list(set([a,b,c]))
#            sum=sum+gcd_list(abc)
            abc=math.gcd(ab,c)
            sum=sum+abc
print(sum)


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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h,w;
    cin >> h >> w;
    
    vector<vector<char>> board(h,vector<char>(w));
    rep(i,h){
        rep(j,w) cin >> board[i][j];
    }
    
    const int dx[4] = {0,0,1,-1};
    const int dy[4] = {1,-1,0,0};
    
    bool ans = true;
    
    rep(i,h){
        rep(j,w){
            if(board[i][j]=='#'){
                bool flag = false;
                for(int k = 0; k < 4; k++){
                    int x = dx[k];
                    int y = dy[k];
                    if(i+y >= 0 and i+y < h and j+x >= 0 and j+x < w){
                        if(board[i+y][j+x]=='#') flag = true;
                    } else continue;
                }
                if(flag == false){
                    ans = false;
                    break;
                }
            }
        }
    }
        
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
int A[100000];
int func(int X){
  rep(i,0,N) X=X/A[i]*A[i];
  return X;
}
signed main(){
  cin>>N;
  rep(i,0,N) cin>>A[i];
  int left=0,right=INF;
  while(left+1<right){
    int mid=(left+right)/2;
    int X=func(mid);
    if(X<2) left=mid;
    else right=mid;
  }
  int ans=-1;
  if(func(right)==2) ans=right;
  if(func(left)==2) ans=left;
  cout<<ans<<endl;
  if(ans!=-1){
    left=0;
    right=INF;
    while(left+1<right){
      int mid=(left+right)/2;
      int X=func(mid);
     if(X<=2) left=mid;
      else right=mid;
    }
    int ans;
    if(func(right)==2) ans=right;
    else ans=left;
    cout<<ans<<endl;
  }
  }



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
    int A,B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) {
        cout << "-1" << endl;
    }
    else {
        cout << A * B << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  int K, N;
  cin>>K>>N;
  vector<int> A;
  for(int i = 0; i < N; i++)
  {
    int j;
    cin>>j;
    A.push_back(j);
  }
  int max = 0;
  if(A[0] + K - A[N-1] > A[1] - A[0])
    max = A[0] + K - A[N-1];
  else
    max = A[1] - A[0];
  for(int i = 1; i < N-1; i++)
  {
    if((A[i] - A[i-1] > A[i+1] - A[i]) && A[i] - A[i-1] > max)
      max = A[i] - A[i-1];
    else if((A[i] - A[i-1] < A[i+1] - A[i]) && A[i+1] - A[i] > max)
      max = A[i+1] - A[i];
  }
  cout<<K - max<<endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define rep(i,a,n) for(ll i=a;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
  string s,t;
  cin>>s;
  cin>>t;
  ll ans=1000;
  ll memo=0;
  ll i=0;
  ll t_size = t.size();
  ll s_size = s.size();
  while(1){
    memo=0;
    rep(j,0,t_size){
      if(s[i+j]!=t[j])memo++;
    }
    if(memo<ans)ans=memo;
    if(i+t_size==s_size)break;
    i++;
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++) {
        string tp;
        cin >> tp;
        s.insert(tp);
    }
    cout << s.size() << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define ll long long
#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 dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

# define INF (1 <<29)
ll d[300][300];
int V;

void warshall_floyd() {
    for (int k = 0; k < V; k++) {
        for (int i = 0; i < V; i++) {
            for (int j = 0; j < V; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r;
    r.resize(R);
    int A[M], B[M], C[M];

    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }
    rep(i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;

    }
    V = N;

    rep(i, V) {
        rep(j, V){
            if (i != j) {
                d[i][j] = INF;
            } else {
                d[i][j] = 0;
            }
        }
    }

    rep(i, M){
        d[A[i]][B[i]] = C[i];
        d[B[i]][A[i]] = C[i];
    }

    warshall_floyd();

    ll ans = -1;
    vector<int> v;
    v.resize(R);
    rep(i, R){
        v[i] = i;
    }
    do {
        ll ans2 = 0;
        rep(i, R-1) {
            ans2 += d[r[v[i]]][r[v[i+1]]];
        }
        if (ans == -1 || ans > ans2) {
            ans = ans2;
        }

    } while (next_permutation(v.begin(), v.end()));


    cout << ans << endl;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a*b%2==0)cout<<"No\n";
	else cout<<"Yes\n";
}

Measured memory_bytes: 768
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] arr = new int[n];
        for(int i=0;i<n;i++)arr[i] = scan.nextInt();
        scan.close();
        int[] dp = new int[n+1];
        Arrays.fill(dp,1000000005);
        dp[0] = 0;
        for(int i= 0;i<n;i++){
            int n1 = i+1;
            int n2 = i+2;
            if(n1 < n){
                dp[n1] = Math.min(dp[n1],dp[i] + Math.abs(arr[i] - arr[n1]));
            }
            if(n2 < n){
                dp[n2] = Math.min(dp[n2],dp[i] + Math.abs(arr[i] - arr[n2]));
            }
        }
        System.out.println(dp[n-1]);
        }
}


Measured memory_bytes: 50628
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>

using namespace std ; 

typedef long long ll ; 

int a[22222] ; 
int b[22222] ; 
int p[22222] ; 

int main()
{
    int N ; 
    scanf("%d", &N) ; 
    for(int i = 1 ; i <= N ; i++) {
        scanf("%d", p+i) ;
    }
    int L = N*2 ; 
    for(int i = 1 ; i <= N ; i++) {
        a[i] = L*i ; 
        b[i] = (N-i+1)*L ; 
    }
    for(int i = 1 ; i <= N ; i++) {
        a[p[i]] += i ; 
    }
    for(int i = 1 ; i <= N ; i++)
        printf("%d ", a[i]) ; 
        puts("") ; 
    for(int i = 1 ; i <= N ; i++)
        printf("%d ", b[i]) ; 
    return 0 ; 
}



Measured memory_bytes: 768