akhauriyash/Code-Regression huggingface dataset:
'''
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    def rep(r,c,nest):
        global cnt
        f=s[r][c]
        if f=='.':return
        s[r][c]='.'
        if r>0:
            if s[r-1][c]==f:rep(r-1,c,False)
        if r<a[0]-1:
            if s[r+1][c]==f:rep(r+1,c,False)
        if c>0:
            if s[r][c-1]==f:rep(r,c-1,False)
        if c<a[1]-1:
            if s[r][c+1]==f:rep(r,c+1,False)
        if nest==True:
            cnt+=1 
    for i in range(a[0]):
        s.append(list(input()))
    for i in range(a[0]):
        for j in range(a[1]):
            rep(i,j,True)
    print(cnt)
'''
import queue
dr=[0,0,1,-1]
dc=[1,-1,0,0]
while True:
    a=[int(num)for num in input().split(' ')]
    if a[0]==0:break
    s=[]
    cnt=0
    for i in range(a[0]):
        s.append(list(input()))
    q=queue.Queue()
    for i in range(a[0]):
        for j in range(a[1]):
            if s[i][j]=='.':continue
            f=s[i][j]
            l=[[i,j]]
            while len(l)!=0:
                next_depth=[]
                for cor in l:
                    for k in range(4):
                        r=cor[0]+dr[k]
                        c=cor[1]+dc[k]
                        if 0<=r<a[0] and 0<=c<a[1] and s[r][c]==f:
                            s[r][c]='.'
                            next_depth.append([r,c])
                l=next_depth
            cnt+=1
    print(cnt)

Measured memory_bytes: 8652
#include<iostream>
#include<vector>
#include<set>
#include<unordered_set>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<unordered_map>
#include<algorithm>
#include<cmath>
#include<tuple>
#include<iomanip>
#include<climits>
#define ll long long int
#define mod 1000000007
#define pi acos(-1)
using namespace std;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  int tmp=1;
  int count=0;
  for(int i=0;i<n;i++)
  {
    int t;
    cin>>t;
    if(tmp==t)
    {
      tmp++;
      count++;
    }
  }
  if(count==0)
   cout<<-1;
  else
  
  cout<<n-count<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    string s;
    cin >> s;

    int count{};

    for (int i = 0, j = s.size() - 1; i < j; ++i, --j)
    {
        if (s[i] != s[j])
            ++count;
    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


 int main(){
 	int s[101][101],r,c,a,b,i=0,l=0;
 	scanf("%d %d",&r,&c);
 	for(a=0;a<r;a++){
 	for(b=0;b<c;b++){
 		scanf(" %d",&s[a][b]);
 	};};
 	for(a=0;a<r;a++){
 		for(b=0;b<c;b++){
 		i=i+s[a][b];
 	};
 	s[a][c]=i;
 	l=l+i;
 	i=0;
 	};s[r][c]=l;
 	
 	for(b=0;b<c;b++){
 		for(a=0;a<r;a++){
 		i=i+s[a][b];
 	};
 	s[r][b]=i;
 	i=0;
 	};
 	
 	for(a=0;a<=r;a++){
 	for(b=0;b<=c;b++){
 		printf("%d",s[a][b]);if(b!=c){printf(" ");};
 	};printf("\n");};
 
 	
 return 0;}


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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	cout << fixed << setprecision(7);
	int N; cin >> N;
	vector<double> a(N); rep(i, 0, N) { cin >> a[i]; }
	sort(a.begin(), a.end());
	double ans = (a[0] + a[1]) / (a[2] - a[3]);
	rep(i, 1, a.size()) {
		double C = a[i];
		rrep(j, 0, i) {
			double D = a[j];
			double A, B;
			int cnt = 0;
			rrep(k, 0, a.size()) {
				if (cnt == 2)break;
				if (k == i || k == j)continue;
				if (cnt == 0)A = a[k];
				if (cnt == 1)B = a[k];
				cnt++;
			}
			dump(A);
			dump(B);
			dump(C);
			dump(D);
			ans = max(ans, (A + B) / (C - D));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3292
# coding : utf-8
lst = []
while True:
    h, w = map(int, input().split())
    lst.append([h, w])
    if h == 0 and w == 0:
        break
for l in lst:
    H = l[0]
    W = l[1]
    for i in range(H):
        for j in range(W):
            if (i + j) % 2 == 0:
                print ('#', end = '')
            else:
                print ('.', end = '')
        print ('')
    if i == H-1:
        print ('')



Measured memory_bytes: 7016
#include <bits/stdc++.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int64_t A, B, C, K;
    int64_t max_val = pow(10, 18);
    cin >> A >> B >> C >> K;
    int64_t cnt = 0;

    if (abs(A - B) > max_val) {
        cout << "Unfair" << endl;
        return 0;
    }

    int64_t x = A - B;
    int64_t ans = 0;
    if (K % 2 == 0) {
        cout << x << endl;
    } else {
        cout << -1 * x << endl;
    }

    return 0;
}

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

S = input()
para = [0]
for i, s in enumerate(S):
    if i == 0:
        para.append(1)
    else:
        if S[i] == S[i-1]:
            para[-1] += 1
        else:
            para.append(1+para[-1])

if S[-1] == '0':
    para.append(para[-1])


i = 0

tmpmax = 0

if S[0] == '1':
    if i + 2*k + 1 >= len(para) - 1:
        print(n)
    else:
        while i + 2*k + 1 <= len(para) - 1:
            j = i + 2*k + 1
            tmpmax = max(tmpmax, para[j] - para[i])

            i += 2
        print(tmpmax)

else:
    if i + 2*k >= len(para) - 1:
        print(n)
    else:
        while i + 2*k <= len(para) - 1:
            j = i + 2*k
            if i == 0:
                tmpmax = max(tmpmax, para[j] - para[i])
            else:
                tmpmax = max(tmpmax, para[j] - para[i-1])

            i += 2
        print(tmpmax)


Measured memory_bytes: 7156
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}



int chk[MAXN];

int main(){
  fio();
  int n,m; cin>>n>>m;
  vector<int> h(n+1);
  for1(i,n){
   cin>>h[i];
  	chk[i] = 1;
  }
  forn(i,m){
  	int u, v; cin>>u>>v;
  	chk[u] &= (h[v]<h[u]);
  	chk[v] &= (h[u]<h[v]);
  }
  int c = 0;
  for1(i,n) c+=chk[i];
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 4048
from collections import deque
S = deque(list(input().strip()))
Q = int(input())
cnt = 0
for _ in range(Q):
    q = list(input().split())
    if int(q[0])==1:
        cnt += 1
    else:
        if cnt%2==0:
            if int(q[1])==1:
                S.appendleft(q[2])
            else:
                S.append(q[2])
        else:
            if int(q[1])==1:
                S.append(q[2])
            else:
                S.appendleft(q[2])
if cnt%2==0:
    print("".join(S))
else:
    S.reverse()
    print("".join(S))

Measured memory_bytes: 76392
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long            ll;
typedef unsigned long long   ull;
typedef vector<int>          vi;
typedef vector<ll>           vl;
typedef pair<int, int>       pi;
typedef pair<ll, ll>         pl;
typedef vector<pi>           vpi;
typedef vector<pl>           vpl;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define read        freopen("in.c", "r", stdin)
#define write       freopen("out.c", "w", stdout)
#define all(a)      a.begin(), a.end()
#define bye         exit(0)
#define mp          make_pair
#define ff          first
#define ss          second
#define L(x)        ((x) << 1)
#define R(x)        ((x) << 1 | 1)
#define SZ(a)       (ll)(a).size()
#define pb          push_back
#define eb          emplace_back
#define eps         1e-9
#define inf         (1000000000)
#define infl        (1000000000000000000LL)
#define cs(p)       printf("Case %d:", (p)++)
#define ptc(c)      putchar(c)
#define gtc()       getchar()
#define nl          puts("")
#define sp          printf(" ")
#define out(a)      printf("%lld", (ll)(a))
#define SET(a, x)   memset((a), x, sizeof(a))
#define dbg(x)      cerr << "--- " << #x << " = " << (x) << '\n'

ll bgm(ll a, ll b, ll m) {
    b = (b == -1) ? (m - 2) : b;
    a %= m;
    ll rem = 1;
    while(b != 0) {
        if(b&1)
            rem = (rem * a) % m;
        a = (a * a) % m;
        b >>= 1;
    }
    return rem;
}

inline ll in() {
    ll a;
    assert(scanf("%lld", &a) != EOF);
    return a;
}

const int MAX = 100000 + 5;
const int LEN = 50;
const ll MOD = 1000000007;

int n, k;
int h[MAX];

int dp[2 * MAX];

int solve(int pos) {
    if(pos > n) {
        return inf;
    }
    if(pos == n) {
        return 0;
    }
    int &ret = dp[pos];
    if(ret != -1) {
        return ret;
    }
    ret = inf;
    for(int i = 1; i <= k; i++) {
        ret = min(ret, abs(h[pos + i] - h[pos]) + solve(pos + i));
    }
    return ret;
}

int main() {
    while(scanf("%d %d", &n, &k) != EOF) {
        SET(dp, -1);
        for(int i = 1; i <= n; i++) {
            h[i] = in();
        }
        out(solve(1)), nl;
    }
    return 0;

}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

int main() {
  int x,y,z;
  cin>>x>>y>>z;
  cout<<z<<" "<<x<<" "<<y<<endl;
  return 0;  
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back

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

constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;

template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
 
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
 

//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
	if(n==0) return (ll)1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
ll modinv(ll a, ll m) {
	if(m==0)return (ll)1;
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}

//radP
ll rad(ll u, ll p){
ll cnt=0;
	while(u%p==0){
		u/=p;
		cnt++;
	}
	return cnt;
}


////////////////////////////////////////////////////////////////////
ll pow2[24];
ll kekka[1000];
ll res;
ll ok;
void count(ll p, ll kai){
	
	if(p==0){res=kai;
	return;}

	ll keta=0;
for(ll i=0;i<=23;i++){
ll val=pow2[i];
if(p & (ll)1<<i)keta++;
}
count(p%keta, kai+1);
return;
}

int main(){
	
 ios::sync_with_stdio(false);
  ok=0;
res=0;
pow2[0]=1;
for(int i=1;i<=23;i++){
pow2[i]=(ll)2*pow2[i-1];
}

ll n;
cin>>n;

string s;
cin>>s;
  

ll cnt1=0;
for(int i=0;i<n;i++){
	if(s[i]=='1')cnt1++;
}



ll ans[n];
rep(i,n){
	ans[i-1]=0;
}

ll rem[3][n];
rem[0][n-1]=1;
rem[1][n-1]=1;
rem[2][n-1]=1;

for(int i=0;i<=2;i++){
	for(int j=n-2;j>=0;j--){
ll p=cnt1+i-1;
if(p>=1){
rem[i][j]=(rem[i][j+1]*2)%p;}
	}
}

ll r0wa=0;
ll r1wa=0;
ll r2wa=0;

for(int i=0;i<n;i++){
	if(s[i]=='1'){
		r0wa+=rem[0][i];
		if(cnt1>=2){
		r0wa%=cnt1-1;}
		r1wa+=rem[1][i];
		r1wa%=cnt1;
		r2wa+=rem[2][i];
		r2wa%=cnt1+1;
	}
}


for(int i=0;i<n;i++){
	res=0;
	ll val;
	if(s[i]=='0'){
		val=r2wa;
		val+=rem[2][i];
		val%=cnt1+1;
		count(val,1);
	}
	if(s[i]=='1'){
		val=r0wa;
		val-=rem[0][i];
		val+=cnt1*2-2;
		if(cnt1==1){ans[i]=0; continue;}
		val%=cnt1-1;
		count(val,1);
	}
	ans[i]=res;
}

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


return 0;
}




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

int main(){
int N;
cin >>N;
int a[N],b[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  for(int i=0;i<N;i++){
    cin >> b[i];
  }
  long long int s=0;
  int d=0;
  vector<int> v={};
  for(int i=0;i<N;i++){
    int x=a[i]-b[i];
    if(x>=0) v.push_back(x);
    else{
      s -= x;
      d++;
    }
  }
  if(d==0){
    cout << 0 << endl;
    return 0;
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  int l=v.size();
  long long int t=0;
  for(int i=0;i<l;i++){
    t+=v.at(i);
    d++;
    if(t>s) break;
    if(i==l-1){
      cout << -1 << endl;
      return 0;
    }
  }
  cout << d << endl;
}
    
    

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int f (int x) {
    int ret = 0;

    while (x >= 1) {
        ret += x % 10;
        x /= 10;
    }

    return ret;
}

int main (void) {
    int n;

    cin >> n;

    if (n % f(n) == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int func(ll i) {
    int ret = 0;
    while (i > 0) {
        ret++;
        i /= 10;
    }
    return ret;
}

int main() {
    ll n;
    cin >> n;
    int ans = 100;
    for (int i = 1; (ll)i * i <= n; i++) {
        if (n % i != 0) continue;
        ll j = n / i;
        ans = min(ans, max(func(i), func(j)));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}
const int n_max = 105;

int dist[n_max][n_max];
int G[n_max][n_max];


signed main(){
    int n,m;
    cin >> n >> m;
    REP(i,n) REP(j,n) dist[i][j] = INF;
    REP(i,m){
        int a,b,c;
        cin >> a >> b >> c;
        a --;
        b --;
        dist[a][b] = c;
        dist[b][a] = c;
        G[a][b] = c;
        G[b][a] = c;
    }
    



    REP(i,n){
        REP(j,n){
            REP(k,n){
                chmin(dist[j][k],dist[j][i] + dist[i][k]);
            }
        }
    }

    int ans = 0;
    REP(i,n) REP(j,n){
        if(G[i][j] != INF and G[i][j] > dist[i][j]) ans ++;
    }
    cout << ans / 2 << endl;




}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int n;

int A[25];

int q;

int m[210];

signed main()
{
    cin >>n;

    rep(i,n)cin >> A[i];

    cin >> q;

    rep(i,q)cin >> m[i];

    bool ans[210]={};

    for(int bit=0;bit<(1 << n);bit++)
    {
        int sum=0;

        for(int i=0;i<n;i++)
        {
            if(bit & (1 << i))sum += A[i];
        }

        for(int i=0;i<q;i++)
        {
            if(sum==m[i])
            {
                ans[i]=1;
            }
        }

        
    }

    for(int i=0;i<q;i++)
    {
        if(ans[i])cout << "yes" << endl;
        else cout << "no" << endl;         
    }
    
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

int main() {
  int D, N; cin>>D>>N;
  if(N<100) cout<<pow(100, D)*N<<endl;
  else if(N=100 && D==2) cout<<1010000<<endl;
  else if(N=100 && D!=2) cout<<pow(100, D)*101<<endl;
}

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

int main(){
    int x, y;
    int d, d_max;
    d_max = 1;
    
    cin >> x >> y;
    if(x > y)
    {
        d = x % y;
        for(int i = 2; i <= d; i++){
            if(d % i == 0 && x % i == 0) d_max = i;
        }
    }
    else if(x < y)
    {
        d = y % x;
        for(int i = 2; i <= d; i++){
            if(d % i == 0 && y % i == 0) d_max = i;
        }
    }
    else
    {
        d_max = x;
    }
    
    cout << d_max << endl;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    out(n * (n + 1) / 2);
}


Measured memory_bytes: 256
l = str(input());
s = l.split(',');
a = ''.join(s);
b = a.split('.');
c = ''.join(b);
d = c.split(' ');
L = [];
for i in range(0,len(d)):
    if len(d[i]) >= 3 and len(d[i]) <= 6:
        L.append(d[i]);
        
print(' '.join(L));


Measured memory_bytes: 5560
#include <iostream>

using namespace std;

int main()
{
	long N;
	int c = 0;
	cin >> N;
	

	for (long A = 1; A < N; A++) {
		c += N / A;
		if ((N % A) == 0)
			c--;
	}
	cout << c << endl;
	return (0);
}


Measured memory_bytes: 3196
#define N 100001
long p[N],r[N],n,m,i,b[N],a[N][2];int f(int x){if(p[x]==x){return x;}return p[x]=f(p[x]);}int u(int x,int y){x=f(x);y=f(y);if(r[x]<r[y])p[x]=y;else p[y]=x;r[y]+=r[x];r[x]=r[y];}int main(){scanf("%ld%ld",&n,&m);for(i=0;i<m;i++)scanf("%d%d",&a[i][0],&a[i][1]);b[m]=(long long)n*(n-1)/2;for(i=0;i<N;i++){p[i]=i;r[i]=1;};for(i=m-1;i>=0;i--){if(f(a[i][0])==f(a[i][1]))b[i]=b[i+1];else{b[i]=b[i+1]-r[f(a[i][0])]*r[f(a[i][1])];u(a[i][0],a[i][1]);}}for(i=1;i<=m;i++)printf("%ld\n",b[i]);return 0;}

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

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

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL H, W, A, B;
  cin >> H >> W >> A >> B;
    REP(j,H){
  REP(i,W){
      if(j!=0){
      }
      if((i<A&&j<B)||(i>=A&&j>=B)){
        cout << "0";
      }
      else
      {
        cout << "1";
      }
    }
    cout << endl;
  }
}


Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		if (a+b == c || b+c == a || c+a == b) {
			System.out.println("Yes");
		}
                else
		System.out.println("No");
	}
}


Measured memory_bytes: 19924
//package compilers;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner in=new Scanner(System.in);

		int n=in.nextInt();
		int m=in.nextInt();
		int arr[][]=new int [n][m];
		int mod=(int)1e9+7;
		for(int i=0;i<n;i++) {
			String s=in.next();
			for(int j=0;j<m;j++) {
				if(i==0 && j==0)
					arr[i][j]=1;
				else if(i==0) {
					if(s.charAt(j)=='#')
						arr[i][j]=0;
					else arr[i][j]=arr[i][j-1];
				}
				else if(j==0) {
					if(s.charAt(j)=='#')
						arr[i][j]=0;
					else arr[i][j]=arr[i-1][j];
				}
				else {
					if(s.charAt(j)=='#')
						arr[i][j]=0;
					/*
					 * else if(arr[i-1][j]==0 && arr[i][j-1]==0) arr[i][j]=0;
					 */
					/*
					 * else if(arr[i][j-1]==0) arr[i][j]=1;
					 */
					else arr[i][j]=(arr[i-1][j]%mod+ arr[i][j-1]%mod)%mod;
				}
				
					 
			}
		}
		System.out.println(arr[n-1][m-1]);
	}

}


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

int main(){
    int a,b,c,sum;

    scanf("%d %d %d",&a,&b,&c);

    sum=a+b;

    if(sum>a+c)
        sum=a+c;
    if(sum>b+c)
        sum=b+c;

    printf("%d",sum);

    return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()){
            int n= scan.nextInt();
            if(n==0)break;
            boolean [] prime  = new boolean[n+1];
            for(int i=0;i<=n;i++)prime[i]=true;
             
            for(int i=2;i<=n;i++)
                for(int j=i*2;j<=n;j+=i)prime[j]=false;
            int max=0;
            for(int i=2;i<=n-2;i++)
                if(prime[i]&&prime[i+2])max =i+2;
            System.out.println(max-2+" "+max);
             
        }
       
 
  }
  }

Measured memory_bytes: 12000
N,M = map(int,input().split())

A = []
B = []

for i in range(N):
    A.append(input())
for j in range(M):
    B.append(input())


for i in range(N - M + 1):
    for j in range(N - M + 1):
        l = 0
        i1 = i
        for l in range(M):
            
            if A[i1].find(B[l],j) != j:
                break   
            if l == M-1:
                print("Yes")
                exit()
            i1 +=1

print("No")
            

Measured memory_bytes: 3188
n, m, x = map(int, input().split())

li = []
for i in range(m):
    li.append([])

money = []
for i in range(n):
    a = list(map(int, input().split()))
    money.append(a[0])
    for j in range(m):
        li[j].append(a[j+1])

ans = sum(money) + 1
first = ans

for hh in range(1 << n):
    cnt = 0
    for i in range(m):
        s = 0
        for h in range(n):
            if (hh >> h)%2 == 1:
                continue
            s += li[i][h]
        if s >= x:
            cnt += 1
    if cnt == m:
        an = 0
        for h in range(n):
            if (hh >> h)%2 == 1:
                continue
            an += money[h]
        ans = min(ans, an)

if ans == first:
    ans = -1

print(ans)

Measured memory_bytes: 9080
//
// Created by 今村秀明 on 2017/01/20.
//

#include <stdio.h>

int main(){
    int n;
    char s[100];
    int m;
    int x = 0;
    int i;

    scanf("%d", &n);
    scanf("%s", s);
    m = x;
    for(i=0;i<n;i++){
        if(s[i]=='I'){
            x++;
        }else{
            x--;
        }
        if(m < x){
            m = x;
        }
    }
    printf("%d", m);
    return 0;
}

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

using namespace std;

int main(){
	int n, x;
	cin >> n >> x;
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n - i; j++){
			if (i * 10000 + j * 5000 + (n - i - j) * 1000 == x){
				cout << i << " " << j << " " << n - i - j << "\n";
				return 0;
			}
		}
	}
	cout << "-1 -1 -1\n";
}

Measured memory_bytes: 256
#!/bin/bash
''':'
docker run --rm -it -v $(cd $(dirname $0) && pwd):/vo:ro pypy:3-2.4.0 /bin/bash -c "pypy3 /vo/$(basename $0) < /vo/g.inp"; exit $?
exit 0
'''
import sys

def _ia(): return [ int(x) for x in sys.stdin.readline().strip().split() ]

# read input
h,w = _ia()
ab = []
for _ in range(h): ab.append(_ia())
for i in range(h):
    r = ab[i]
    for j,bj in enumerate(_ia()):
        r[j] = abs(r[j] - bj)
    t = max(r)

# initialize
dp = [[None for _ in range(w)] for _ in range(h)]
dp[0][0] = {ab[0][0]}
hw1 = h + w - 1
for ij in range(1,hw1):
    iend = ( hw1 - ij ) * 80
    for i in range(min(ij+1,h)):
        j = ij - i
        if j>=w: continue
        #
        ref = set()
        if i>0: ref|= dp[i-1][j]
        if j>0: ref|= dp[i][j-1]
        #
        x = ab[i][j]
        nxt = dp[i][j] = set()
        for idx in ref:
            ix = abs(idx-x)
            if ix<=iend: nxt.add(ix)
            ix = idx + x
            if ix<=iend: nxt.add(ix)
            
# stdout
print(min(dp[h-1][w-1]))


Measured memory_bytes: 764296
s = input()[::-1]
n = len(s)

i = 0
while i < n:
    if s[i:i+5] == 'maerd':
        i += 5
    elif s[i:i+7] == 'remaerd':
        i += 7
    elif s[i:i+5] == 'esare':
        i += 5
    elif s[i:i+6] == 'resare':
        i += 6
    else:
        print('NO')
        break
else:
    print('YES')

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n, m, mxs = 0;
  cin >> n >> m;
  vector<ll> s(m);
  vector<char> c(m);
  rep(i, m) cin >> s[i] >> c[i], s[i]--;

  rep(i, 1000) {
    string S = to_string(i);
    if (S.size() != n) continue;
    bool ok = true;
    rep(j, m) if (S[s[j]] != c[j]) ok = false;
    if (ok) {
      cout << i << endl;
      return 0;
    }
  }

  puts("-1");
  return 0;
}

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

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

int N;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	cin>>N;
	FOR(i,N) cin>>A[i];
	
	ll ret=0;
	FOR(i,N-1) {
		ret +=A[i]/2;
		A[i] %= 2;
		x = min(A[i],A[i+1]);
		A[i]-=x;
		A[i+1]-=x;
		ret += x;
	}
	ret += A[N-1]/2;
	cout<<ret<<endl;
	
	
}


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


Measured memory_bytes: 640
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;

    let am = a.(n - 1) in

    let rec loop i aj bs =
        if i < 0 then aj else
            if abs (a.(i) * 2 - am) < bs then loop (i - 1) a.(i) (a.(i) * 2 - am)
                                         else loop (i - 1) aj bs
    in
    let aj = loop (n - 2) 0 am in
    Printf.printf "%d %d\n" am aj
)

Measured memory_bytes: 6692
S = list(input())
n = []
a = 0
for i,s in enumerate(S) :
	if s in ["A","T","G","C"] :
		a += 1
	else :
		n.append(a)
		a = 0
	
	if i+1 == len(S) :
		n.append(a)
		break
print(max(n))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<map>
#include<deque>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<=n;i++)
#define ALLOF(c) (c).begin(), (c).end()
#define Pa pair<ll,ll>
const ll mod=1000000007;
const ll INF=10e12;
const ll inf=-1;
ll ABS(ll a){return max(a,-a);}


int main(void){
    ll N,M;
    cin>>N>>M;
    if(N%2){
        REP(i,M) cout<<i<<" "<<N-i<<endl;
    }
    else{
        ll a=N/2,b=N/2+1,repnum=N/4;
        rep(i,repnum){
            if(M<=0) return 0;
            cout<<a<<" "<<b<<endl;
            a--;
            b++;
            M--;
        }
        b++;
        while(M>0){
            cout<<a<<" "<<b<<endl;
            a--;
            b++;
            M--;
        }
        return 0;
    }
}


Measured memory_bytes: 3640
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
	int n, su = 0, m = 0, j = 0;;cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i = n - 1;i >= 0;i--) {
		if (j % 2 == 0) {
			su += a[i];
		}
		else {
			m += a[i];
		}
		j++;
	}
	cout << su - m << endl;
}

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

int main() {

    int n,k;

    cin >> n >> k;

    if (k > n) {
        cout << 0 << endl;
        return 0;
    }
    vector<long> h(n);

    long sum_a = 0;
    for (int i=0;i<n;i++){
        cin >> h.at(i);
        sum_a += h.at(i);
    }

    sort(h.begin(),h.end());

    long num_a = 0;
    for (int i=0;i<k;i++){
        num_a += h.at(n-i-1);
    }

    cout << sum_a - num_a << endl;

    return 0;
}

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

vector<vector<int>> G;
int A[2020], B[2020], dep[2020];

void dfs(int key){
	for(int i=0; i<G[key].size(); ++i){
		int nx=A[G[key][i]]+B[G[key][i]]-key;
		if(dep[nx]==4000){
			dep[nx]=dep[key]+1;
			dfs(nx);
		}
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	G.resize(N+1);
	for(int i=1; i<N; ++i){
		cin >> A[i] >> B[i];
		G[A[i]].emplace_back(i);
		G[B[i]].emplace_back(i);
	}
	int ans=0;
	if(K%2==0){
		for(int i=1; i<=N; ++i){
			for(int j=1; j<=N; ++j) dep[j]=4000;
			dep[i]=0;
			dfs(i);
			int cnt=0;
			for(int j=1; j<=N; ++j){
				if(dep[j]*2<=K) ++cnt;
			}
			ans=max(ans, cnt);
		}
	}else{
		for(int i=1; i<N; ++i){
			for(int j=1; j<=N; ++j) dep[j]=4000;
			dep[A[i]]=dep[B[i]]=0;
			dfs(A[i]);
			dfs(B[i]);
			int cnt=0;
			for(int j=1; j<=N; ++j){
				if(dep[j]*2<K) ++cnt;
			}
			ans=max(ans, cnt);
		}
	}
	cout << N-ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stack>
#include<string>
#include<cstdlib>
using namespace std;
int main()
{
  int x,y,z;
  string str;
  stack<int> a;
  while(cin >> str){
    if(str == "+"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = x + y;
      a.push(z);
    }
    else if(str == "-"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = y - x;
      a.push(z);
    }
    else if(str == "*"){
      x = a.top();
      a.pop();
      y = a.top();
      a.pop();
      z = x * y;
      a.push(z);
    }
    else{
      a.push(atoi(str.c_str()));
    }
  }
  cout << a.top() << endl;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h> // Include every standard library
using namespace std;
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
#define sqr(x) ((LL)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define TC(t) while (t--)
#define ms(s, n) memset(s, n, sizeof(s))
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define size(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed << setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pi> vii;
const int MOD = (int)1e9 + 7;
const int MOD2 = MOD + 2; //1007681537;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ld PI = acos((ld)-1);
const ld EPS = 1e-9;
inline ll gcd(ll a, ll b)
{
    ll r;
    while (b)
    {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
inline ll fpow(ll n, ll k, int p = MOD)
{
    ll r = 1;
    for (; k; k >>= 1)
    {
        if (k & 1)
            r = r * n % p;
        n = n * n % p;
    }
    return r;
}
inline ll isqrt(ll k)
{
    ll r = sqrt(k) + 1;
    while (r * r > k)
        r--;
    return r;
}
inline ll icbrt(ll k)
{
    ll r = cbrt(k) + 1;
    while (r * r * r > k)
        r--;
    return r;
}
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
int modulo(int a, int b) { return (a % b + b) % b; } 
#define db(x) cerr << #x << " = " << (x) << " ";

int main()
{
    IOS;
    int N,W;
    scanf("%d %d", &N,&W);
    vl dp(W+1);
    //dp[i]=max value when total weight is i
    vi w;
    vi v;
    for(int a=0;a<N;a++)
    {
        int wgt,val;
        scanf("%d %d", &wgt,&val);
        w.pb(wgt);
        v.pb(val);
    }
    for(int a=0;a<N;a++)
    {
        // using push forward dp
        //for(int b=0;b<=W-w[a];b++) picks up same item twice
        for(int b=W-w[a];b>=0;b--) //ierating over items that can already be in the knapsack if i pick up w[a]
        dp[b+w[a]]=max(dp[b+w[a]],dp[b]+v[a]);
    }
    ll res=*max_element(ALL(dp));
    printf("%lld", res);
}


Measured memory_bytes: 3964
#include <stdio.h>
#include <iostream>
using namespace std;

#define NUM 100
#define BLACK 0
#define GREY 1
#define WHITE 2
#define NIL -1
#define INF 1000000000
int A[NUM][NUM];

int V[NUM];
int color[NUM];

void init(){
    for(int i = 0; i < NUM; i++){
        color[i] = WHITE;
        V[i] = INF;
    }

}

int main(void){
    init();

    int n;
    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d", &A[i][j]);
        }
    }

    int next_node = 0;
    int sum = 0;
    while(1){
        color[next_node] = BLACK;
        for(int i = 0; i < n; i++){
            if(A[next_node][i] == NIL){
                continue;
            }
            V[i] = min(V[i], A[next_node][i]);
        }

        next_node = NIL;
        int min_dist = INF;
        for(int i = 0; i < n; i++){
            if(color[i] == BLACK){
                continue;
            }
            if(V[i] < min_dist){
                next_node = i;
                min_dist = V[i];
            }
        }
        if(min_dist == INF){
            break;
        }else{
            sum += min_dist;
        }
    }

    printf("%d\n", sum);
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define sz size
#define re return
#define gl getline
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,a,b) for(int i=a;i<=b;i++)
#define all(a) (a).begin(),(a).end()
#define inf 1<<30
int main(){
	ios::sync_with_stdio(false),cin.tie(0);
	int x;
	cin>>x;
	if(x<30)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	re 0;
}

Measured memory_bytes: 3660
#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());
  int m=a[n-1]/2;
  int p,q,ans;
  if(n==2){
    cout<<a[1]<<" "<<a[0]<<endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    if(a[i]>m){
      if(i==0){
        ans=a[0];
        break;
      }
      p=a[i-1];q=a[i];
     
      if(a[n-1]%2==0){
        if(abs(p-m)<abs(q-m)){
          ans=p;
          break;
        }
        else{
          ans=q;
          break;
        }
      }
      else{
        if(abs(p-m)<abs(q-m-1)){
          ans=p;
          break;
          
        }
        else{
          ans=q;
          
          
          break;
        }
      }
    }
  }
  cout<<a[n-1]<<" "<<ans<<endl;
}

Measured memory_bytes: 640
n = int(input())
T_point = 0
H_point = 0
for loop in range(n):
    T,H=map(str,input().split())
    if T > H:T_point += 3
    elif T == H:
        T_point += 1
        H_point += 1
    else:H_point += 3
print(T_point,H_point)


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<math.h>
using namespace std;


int main(){
    int N,A,B;

    cin>>A>>B;

    int a=A+B;
    int b=A-B;
    int c=A*B;

    if(max(c,b)==c  && max(a,c)==c){
        cout<<c;
    }
    else if(max(a,b)==a  && max(a,c)==a){
        cout<<a;
    }


    else if(max(a,b)==b  && max(b,c)==b){
        cout<<b;
    }
    



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<ll, ll> P;
#define INF 1e9 + 7

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

    ll w,h;
    long double x,y;
    cin >> w >> h >> x >> y;
    
    long double ans = w * h / 2.0;
    
    int ok = 0;
    
    if(x==w/2.0 && y==h/2.0){
        ok = 1;
    }
    
    printf("%.12Lf %d", ans, ok);

    return 0;
}

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

int main() {
  int n; cin >> n;
  vector<int> cards(n);
  for( int i = 0; i < n; i++) {
    cin >> cards.at(i);
  }
  stable_sort(cards.begin(), cards.end(),greater<int>()); 
  
  int ans = 0;
  
  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      ans += cards.at(i);
    } else {
      ans -= cards.at(i);
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
	char a[5];
	scanf("%s",a);
	if(a[0]=='A'&&a[1]=='A'&&a[2]=='A'){
		printf("No\n");
	}else if(a[0]=='B'&&a[1]=='B'&&a[2]=='B'){
		printf("No\n");
	}else{
		printf("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
let () = Scanf.scanf "%d %d\n" @@ fun h w ->
  let ass = Array.init h @@ fun _ ->
    Scanf.scanf "%s\n" @@ fun as_ -> as_ in
  let row = Array.make h false in
  let col = Array.make w false in
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if ass.(i).[j] = '#' then begin
        row.(i) <- true;
        col.(j) <- true
      end
    done
  done;
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      if row.(i) && col.(j) then
        print_char ass.(i).[j]
    done;
    print_newline ()
  done


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

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

    string event;

    for (int n = 0; n != N; ++n) {
        
        int runners = 0, points = 0, out = 0;
        
        while (out < 3) {
            cin >> event;
            if (event == "OUT") out++;
            if (event == "HIT") runners++;
            if (runners == 4) {
                points++;
                runners--;
            }
            if (event == "HOMERUN") {
                points += runners + 1;
                runners = 0;
            }
        }
        cout << points << endl;
    }
}

Measured memory_bytes: 1208
#include <iostream>
#include <cassert>
#include <queue>

#define INF 922337203685477580
typedef long long ll;

using namespace std;


priority_queue<ll, vector<ll>, greater<ll> > former; // 小さい順
priority_queue <ll> latter; // default 大きい順

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

  ll sums_f[3 * N];
  ll sum_f = 0;
  for (int i = 0; i < N; i++) {
    sum_f += a[i];
    former.push(a[i]);
  }

  // 0...N
  sums_f[N] = sum_f;

  for (int k = N; k < 2 * N; k++) {
    sum_f += a[k];
    former.push(a[k]);

    sum_f -= former.top();
    former.pop();
    // 0...k
    sums_f[k + 1] = sum_f;
  }


  ll sums_l[3 * N];
  ll sum_l = 0;
  for (int i = 2 * N; i < 3 * N; i++) {
    sum_l += a[i];
    latter.push(a[i]);
  }

  // 0...2N, 2N...3N
  sums_l[2 * N] = sum_l;

  for (int k = 2 * N - 1; k >= N; k--) {
    sum_l += a[k];
    latter.push(a[k]);

    sum_l -= latter.top();
    latter.pop();
    sums_l[k] = sum_l;
  }


  ll mx = -INF;
  for (int k = N; k <= 2 * N; k++) {
    // cout << "k = " << k << endl;
    // cout << "f[k] = " << sums_f[k] << endl;
    // cout << "l[k] = " << sums_l[k] << endl;
    mx = max(mx, sums_f[k] - sums_l[k]);
  }



  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 7156
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define VE vector<int>
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
//
int GCD(int A,int B){
  if(B==0){
    return A;
  }else{
    return GCD(B,A%B);
  }
}
int LCM(int A,int B){
    int G=GCD(A,B);
    return A/G*B;
}
int main(){
  int N;
  int A[10];
  cin>>N;
  FOR(i,0,N){
    cin>>A[i];
  }
  int ans=LCM(A[0],A[1]);
  FOR(i,2,N){
    ans=LCM(ans,A[i]);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3096
n,m=gets.split.map(&:to_i)
xs=gets.split.map(&:to_i)

if n >= m
    puts 0
    exit
end

xs.sort!
xs=xs.each_cons(2).map {|x1, x2| (x2-x1).abs }
xs.sort!
puts xs.first(m-n).inject(:+)

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

int s[111], n;
bool dp[11111];

int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> s[i];
    }
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        for(int j = 1e4 - 1; j >= 0; j--){
            if(dp[j] && j + s[i] <= 1e4){
                dp[j + s[i]] = 1;
            }
        }
    }
    for(int j = 1e4; j >= 0; j--){
        if(dp[j] && j % 10 != 0){
            cout << j;
            return 0;
        }
    }
    cout << 0;
    return 0;
}


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

using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

constexpr long long mod = 1000000007;

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

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

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    int m = 0;
    rep(i, n){
        m += a[i];
    }

    m = round(1.0 * m / n);

    int ans = 0;
    rep(i, n) {
        ans += (a[i] - m) * (a[i] - m);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3644
class Dice:
	# Label: 1=Up, 2=South, 3=East, 4=West, 5=North, 6=Down
	def __init__(self, nums):
		self.nums = nums
		self.cU = nums[0]
		self.cS = nums[1]
		self.cE = nums[2]
		self.cW = nums[3]
		self.cN = nums[4]
		self.cD = nums[5]
	def goN(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pS,pD,pU,pN
	def goE(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pW,pU,pD,pE
	def goW(self):
		pU,pE,pW,pD = self.cU,self.cE,self.cW,self.cD
		self.cU,self.cE,self.cW,self.cD = pE,pD,pU,pW
	def goS(self):
		pU,pS,pN,pD = self.cU,self.cS,self.cN,self.cD
		self.cU,self.cS,self.cN,self.cD = pN,pU,pD,pS
	def toU(self, num):
		if self.cD == num:
			for _ in range(2): self.goN()
		elif self.cN == num: self.goS()
		elif self.cE == num: self.goW()
		elif self.cW == num: self.goE()
		elif self.cS == num: self.goN()
	def right(self, num):
		if self.cN == num: return self.cW
		elif self.cE == num: return self.cN
		elif self.cW == num: return self.cS
		elif self.cS == num: return self.cE
		else: raise # ????????????
	def equals(self, dice):
		"""?????????????????¨????????????????????¢????????????????????§??¨???"""
		for i in self.nums:
			if dice.nums.count(i) == 1:
				self.toU(i)
				dice.toU(i)
				break
		if self.cU == dice.cU and self.cD == dice.cD:
			nesw1 = ''.join(list(map(str, [self.cN,self.cE,self.cS,self.cW])))
			nesw1 += nesw1
			nesw2 = ''.join(list(map(str, [dice.cN,dice.cE,dice.cS,dice.cW])))
			if nesw1.count(nesw2) > 0: return True
			else: return False
		else: return False
dice = [Dice(list(map(int, input().split(' ')))) for _ in range(int(input()))]
pre = None
rslt = True
for die in dice:
	if pre == None: 
		pre = die
		continue
	if pre.equals(die):
		rslt = False
		break
if rslt: print('Yes')
else: print('No')


Measured memory_bytes: 7908
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
using namespace std;
using ll = long long;
using vll = vector<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 long long INF = 1LL << 60;

int main(){
    ll N;
	cin>>N;
	vll h(N),dp(N,INF);
	REP(i,N) {
		cin>>h[i];
	}
	
	dp[0]=0;
	
	FOR(i,1,N){
		chmin(dp[i],dp[i-1] + abs(h[i]-h[i-1]));
		if(i>1) chmin(dp[i],dp[i-2] +abs(h[i]-h[i-2]));
	}
	
	
	cout<<dp[N-1]<<endl;
		
}
	


Measured memory_bytes: 1792