akhauriyash/Code-Regression huggingface dataset:
//***********************************************************************************************************//
//    TOPIC :
//***********************************************************************************************************//
#include <iostream>
using namespace std;
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
#define ll long long int
#define ull unsigned long long int
#define INF 99999999
ll mod = 1e9 + 7;

// int mod = 1e9 + 7;
#define fr(a, b, c) for (int a = b; a < c; a++)
#define fre(a, b, c) for (int a = b; a <= c; a++)

void the_martian()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif
}

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll powm(ll a, ull b)
{
    // m_steps = 0;
    ll res = 1;
    while (b)
    {
        // m_steps++;
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
        // cout << a << " " << b << endl;
        b >>= 1;
    }
    return res;
}

int main()
{
    
    int n;
    cin >> n;
    int arr[n];
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    int dp[n + 1];
    dp[0] = 0;
    dp[1] = 0;

    for (int i = 2; i <= n; i++)
    {
        int ans = INT_MAX;
        if ((i - 2) != 0)
        {
            ans = min(ans, dp[i - 2] + abs(arr[i - 1] - arr[i - 3]));
        }
        ans = min(ans, dp[i - 1] + abs(arr[i - 1] - arr[i - 2]));
        // cout << ans << endl;
        dp[i] = ans;
    }
    cout << dp[n] << endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner scanner = new Scanner(System.in);

		String temp = scanner.nextLine();
		String[] list = new String[4];
		int s = 0;
		for(int i = 0; i < 4;i++) {
			list[i] = String.valueOf(temp.charAt(i));
			if(list[i].equals("+")) {
				s++;
			}else {
				s--;
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 22228
N = int(input())
hs = list(map(int, input().split()))

INF = float('Inf')
tbl = [INF] * N
tbl[0] = 0
tbl[1] = abs(hs[1]-hs[0])

for i in range(2,N):
    tbl[i] = min(tbl[i-2]+abs(hs[i]-hs[i-2]),
                 tbl[i-1]+abs(hs[i]-hs[i-1]))

print(tbl[N-1])

Measured memory_bytes: 13928
def resolve():
    h, w = map(int, input().split())
    n = int(input())
    a = list(map(int, input().split()))
    colors = []
    for i, ai in enumerate(a):
        colors += [str(i + 1)] * ai
    for i in range(h):
        if i % 2 == 1:
            print(" ".join(colors[w * i:w * (i + 1)][::-1]))
        else:
            print(" ".join(colors[w * i:w * (i + 1)]))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 40908
#include<bits/stdc++.h>
using namespace std;
int fa[500000];
int fb[500000];
int finda(int x)
{
    return x==fa[x]?x:fa[x]=finda(fa[x]);
}
int findb(int x)
{
    return x==fb[x]?x:fb[x]=findb(fb[x]);
}
int main()
{
    int n,k,l;
    scanf("%d%d%d",&n,&k,&l);
    for(int i=1;i<=n;i++)
    {
        fa[i]=i;
        fb[i]=i;
    }
    for(int i=1;i<=k;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        int fu=finda(u);
        int fv=finda(v);
        if(fu!=fv)
        {
            fa[fu]=fv;
        }
    }
    for(int i=1;i<=l;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        int fu=findb(u);
        int fv=findb(v);
        if(fu!=fv)
        {
            fb[fu]=fv;
        }
    }
    for(int i=1;i<=n;i++)
    {
        finda(i);
        findb(i);
    }
    map<pair<int,int>,int>mmp;
    for(int i=1;i<=n;i++)
    {
        mmp[make_pair(fa[i],fb[i])]++;
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ", mmp[make_pair(fa[i],fb[i])]);
    }
    printf("\n");
}


Measured memory_bytes: 13568
#include<stdio.h>
int main()
{
    int N,a,b,c,d,e,f,g,h;
    scanf("%d",&N);
    if(N%1000==0)
        printf("0\n");
    else if(N<1000){
        a=1000-N;
        printf("%d\n",a);}
    else if(N>1000 && N<2000){
        b=2000-N;
        printf("%d\n",b);}
    else if(N>2000 && N<3000){
        c=3000-N;
        printf("%d\n",c);}
    else if(N>3000 && N<4000){
        d=4000-N;
        printf("%d\n",d);}
    else if(N>4000 && N<5000){
        e=5000-N;
        printf("%d\n",e);}
    else if(N>5000 && N<6000){
        f=6000-N;
        printf("%d\n",f);}
    else if(N>6000 && N<7000){
        g=7000-N;
        printf("%d\n",g);}
    else if(N>7000 && N<8000){
        f=8000-N;
        printf("%d\n",f);}
    else if(N>8000 && N<9000){
        g=9000-N;
        printf("%d\n",g);}
    else if(N>9000 && N<10000){
        h=10000-N;
        printf("%d\n",h);}

return 0;

}


Measured memory_bytes: 1724
#include <iostream>
 
using namespace std;
 
int main()
{
    int a, b, c;
    cin  >> a >> b >> c;
 
    if(a >= b && b >= c)
        cout << c << " " << b << " " << a << endl;
     
    else if(a >= c && c >= b)
        cout << b << " " << c << " " << a << endl;
     
    else if(b >= a && a >= c)
        cout << c << " " << a << " " << b << endl;
     
    else if(b >= c && c >= a)
        cout << a << " " << c << " " << b << endl;
     
    else if(c >= a && a >= b)
        cout << b << " " << a << " " << c << endl;
     
    else if(c >= b && b >= a)
        cout << a << " " << b << " " << c << endl;
    
    return 0;
}

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

using namespace std;

int main(){
  double W,H,x,y;
  cin >> W >> H >> x >> y;
  double ans = W * H / 2;
  
  string s;
  if( (int)W % 2 == 0 && (int)H % 2 == 0 && (int) W /2 == (int) x && (int) H / 2 == (int) y){
    s = "1";
  } else {
    s = "0";
  }
  cout << setprecision(10) << ans << " " << s << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int * l = new int[2 * n];
	for(int i = 0; i < 2 * n; i++){
			cin >> l[i];
	}
	sort(l, l + 2 * n);
	int sum = 0;
	for(int i = 0; i < n; i++){
			sum += l[2 * i];
	}
	cout << sum << endl;
	return 0;
}


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

void main_()
{
    ll N;
    cin >> N;
    string ans;
    if (N == 0) {
        ans.push_back('0');
    }
    for (ll i = 1; N != 0; i++) {
        auto rem = N % (ll)pow(-2, i);
        if (rem != 0) {
            ans.push_back('1');
            N -= (ll)pow(-2, i - 1);
        } else {
            ans.push_back('0');
        }
    }

    copy(rbegin(ans), rend(ans), ostreambuf_iterator<char>(cout));
    cout << "\n";
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
#include <string>
using namespace std;


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

    int num = (int)sqrt(N);

    cout << num*num << endl;

    return 0;
}

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

using ll = long long;
using pii = pair<int, int>;

template<class T>
using max_heap = priority_queue<T>;
template<class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long H){
    ll x = 0;
    ll h = H;
    ll cnt = 0;
    ll ans = 0;
    while(h > 0) {
        ans += (1LL<<cnt);
        cnt++;

        if (h % 2 > 0) x++;
        h /= 2LL;
    }
    cout << ans << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 256
///****In the name of ALLAH, most Gracious, most Compassionate****//

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair <int, int> pii;

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=3e5+5;
const int oo=1e9+7;

int a[N];

int32_t main()
{
    FastIO;
    int n;
    cin>>n;
    for(int i=0;i<n*3;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n*3);
    ll ans = 0;
    int i=n*3-1;
    int k=n;
    while(k--)
        i-=2 , ans+=a[i+1];
    cout<<ans<<"\n";
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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;
typedef long long ll;
const ll MOD = 1000000007;
ll getDigit(ll n) {
	ll cnt = 0;
	while (n != 0) {
		n /= 10;
		cnt++;
	}
	return cnt;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
typedef pair<double, long long> pair_t;
bool comp(const pair_t& a, const pair_t& b) {
	if (a.first == b.first)return  a.second > b.second;
	else {
		return a.first > b.first;
	}
}

int main() {
	ll n;
	cin >> n;
	cout << (n % 2 == 0 ? n/2 :n/2+1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a[3];
int main()
{
	for(int i=1;i<=3;i++)
	{
		cin>>a[i];
		if(a[i]=="ABC")
		{
			cout<<"ARC";
			return 0;
		}
		else
		cout<<"ABC";
		return 0;
	}
	return 0;
}


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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    vector<pii> v;
    for(int i=0;;i++)
    {
        int num = 1;
        for(int j=0;j<5;j++)num*=i;
        if(num>=1e15)break;
        v.pb({num,i});
    }
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        for(int i=0;i<v.size();i++)
        {
            for(int j=0;j<v.size();j++)
            {
                if(v[i].ff+v[j].ff == n)
                return cout<<v[i].ss<<" "<<-v[j].ss<<endl,0;
                if(v[i].ff-v[j].ff == n)
                return cout<<v[i].ss<<" "<<v[j].ss<<endl,0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    string s,t;
    cin >> s;
    cout << ((s[0] == '+') + (s[1] == '+') + (s[2] == '+') + (s[3] == '+')) - ((s[0] != '+') + (s[1] != '+') + (s[2] != '+') + (s[3] != '+')) << endl;
    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<int> D1(N);
    vector<int> D2(N);
    string ans = "No";
    for(int i=0;i<N;i++)
    {
        cin >> D1.at(i) >> D2.at(i);
    }
    // Di,1 = Di,2 かつ Di+1,1 = Di+1,2 かつ Di+2,1 = Di+2,2
    for(int i=0;i<N-2;i++)
    {
        if((D1.at(i)==D2.at(i)) && (D1.at(i+1)==D2.at(i+1)) && (D1.at(i+2)==D2.at(i+2)))
        {
            ans = "Yes";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N,A,x;
  
  cin >> N;
  cin >> A;
  
  x = N % 500;
    
    if (x <= A) {
      cout << "Yes" << endl;
    }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import heapq
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))
A = [-A[_] for _ in range(N)]
heapq.heapify(A)
for i in range(M):
    B = math.ceil(heapq.heappop(A)/2)
    heapq.heappush(A,B)
print(-sum(A))



Measured memory_bytes: 98584
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll mod = 1000000007;

//bool operator< (pint a, pint b) {
	//return a.second < b.second;

//}



ll gcd(ll a, ll b) {

	if (b == 0)
		return a;

	return gcd(b, a % b);


}

ll max(ll a, ll b) {
	if (a < b) {
		return b;
	}
	else
		return a;

}

ll min(ll a, ll b) {
	if (a < b)
		return a;

	return b;
}




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

vector<pint> list;










void floyd(int N, ll** d) {

	rep(k, N+1){
		rep(i, N+1) {
			if (d[i+1][k+1] == inf) continue;
			rep(j, N+1) {
				if (d[j+1][k+1] == inf) continue;

				d[i+1][j+1] = min(d[i+1][j+1], d[i+1][k+1] + d[j+1][k+1]);

			}

		}
	}




}


ull modpow(ull a, ull b) {
	ll retval = 0;

	if (b == 0) { return 1; }

	else if (b % 2 == 0) {
		retval = modpow(a, b / 2) % mod;
		return (retval * retval) % mod;
	}

	else {
		
		return ((a % mod) * modpow(a, b - 1)) % mod;
	}
}

ull modkaijou(ull a) {

	if (a == 1 || a == 0) { return 1; }

	ll retval = 1;

	for (ull i = a; i >= 1; i--) {
		retval = (retval * (i % mod)) % mod;
	}

	return retval % mod;
}

ull modcomb(ull a, ull b) {

	if (a == 0 || b == 0) return 1;

	return (((modkaijou(a) * modpow(modkaijou(a-b), mod - 2)) % mod) * modpow(modkaijou(b), mod - 2)) % mod;
}


ll d[100005];
vector<ll> M[100005];
vector<ll> anslist;


stack<int> to_1;







ll x[51];
ll dp[2501][51][51];
int main() {
	ll N, A;

	cin >> N >> A;


	rep(i, N)
		cin >> x[i + 1];



	rep(i, 51) {
		dp[0][0][i] = 1;
	}

	

	rep(i, 50) {
		rep(j, 50) {
			dp[0][j + 1][i] = 0;

		}

	}





	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= i; j++) {
			for (int k = 0; k <= 2500; k++) {

				if (k >= x[i]) {
					dp[k][j][i] = dp[k - x[i]][j - 1][i-1] + dp[k][j][i-1];
				}

				else if (k < x[i]) {
		
					dp[k][j][i] = dp[k][j][i-1];
				}
				
			}
		}
	}

	ll ans = 0;
	rep(i, N) {
		ans += dp[A * (i + 1)][i + 1][N];
	}


	cout << ans << endl;
	
	return 0;
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<long long> h(n), dp(n);

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

    dp[0] = 0;

    for (int i = 1; i < n; ++i) {
        dp[i] = INT_MAX;
        for (int j = 1; j <= k && i - j >= 0; ++j) {
            if (abs(h[i] - h[i - j]) + dp[i - j] < dp[i]) {
                dp[i] = abs(h[i] - h[i - j]) + dp[i - j];
            }
        }
    }

    cout << dp[n - 1] << '\n';

    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,f,n) for(ll i=(f); (i) < (n); i++)
#define repe(i,f,n) for(ll i=(f); (i) <= (n); i++)
using namespace std;
using ll = long long;
#define MOD (ll)1000000007
#define PI 3.14159265359
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define P pair<ll, ll>
#define dvec vector<vector<ll>>
//printf("%.10f\n")
//cout << fixed << setprecision(10);
template<class T> inline bool chmax(T& a, T b){if (a < b) { a = b; return true; } return false;}
template<class T> inline bool chmin(T& a, T b){if (a > b) { a = b; return true; } return false;}
ll INF = 1e+18;
int iINF = 1e9;

int main()
{
  vector<int> arr(5);
  rep(i, 0, 5) cin >> arr[i];
  rep(i, 0, 5){
    if(arr[i] == 0){
      cout << i + 1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 3524
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){

    
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (u == s) a--;
    else b--;

    cout << a << " " << b << endl;





}





//              g++ -std=c++1z

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  if(s==1||s==2||s==3||s==5||s==6||s==9||s==10||s==13||s==17){
    cout << "No";
  }
  else{
    cout << "Yes";
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  int cnt = 0;
  for(int i=0; i<N; i++){
    while(true){
     if(a[i] % 2 == 0){
       a[i] /= 2;
       cnt++;
     }
      else {
       break; 
      }
    }    
  }  
  
  cout << cnt << endl;
 return 0; 
}

Measured memory_bytes: 256
from collections import deque

H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]
p = deque()
for i, Ai in enumerate(A):
    for j, Aij in enumerate(Ai):
        if Aij == "#":
            p.append([i, j, 0])

while p:
    y, x, cnt = p.popleft()
    for dx, dy in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        if 0 <= y + dy < H and 0 <= x + dx < W and A[y + dy][x + dx] == ".":
            p.append([y + dy, x + dx, cnt + 1])
            A[y + dy][x + dx] = "#"
print(cnt)


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

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

    map<int, int> A;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }

    if (A.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<bool> dp(A.rbegin()->first + 1, true);

    for (auto num : A) {
        int count = 2;
        while (count * num.first < dp.size()) {
            dp[count * num.first] = false;
            count++;
        }
    }

    int output = 0;
    for (auto num : A) {
        if (dp[num.first] && num.second == 1) {
            output++;
        }
    }

    cout << output << endl;

    return 0;
}


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

int A, B;
vector<int> ans = {1, 2, 3};

int main() {
  cin >> A >> B;
  
  for (int i = 0; i < 3; i++){
  if(ans.at(i) != A && ans.at(i) != B) cout << ans.at(i) << endl;
  }
  
}

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

int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    while (a <= b)
    {
        if (a % k == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
        a++;
    }
    cout << "NG" << endl;

    return 0;
}

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

using namespace std;

#define reps(i, n, m) for (int i = (int) (n); i < (int) (m); i++)
#define rep(i, n) reps(i, 0, (n))
#define all(v) (v).begin(), (v).end()

int main() {
    int n; cin >> n;
    vector<int> v(n);
    iota(all(v), 1);
    do {
        rep(i, n) {
            cout << v[i] << " \n"[i==n-1];
        }
    } while (next_permutation(all(v)));
}


Measured memory_bytes: 3076
import math as m

K = int(input())

res = 0
for a in range(1, K + 1):
    for b in range(a, K + 1):
        for c in range(b, K + 1):
            if a == b == c:
                res += a
            elif (a == b and a != c) or (b == c and b != a) or (a == c and a != b):
                res += m.gcd(max(a, b, c), min(a, b, c)) * 3
            else:
                res += m.gcd(m.gcd(a, b), c) * 6

print(res)


Measured memory_bytes: 9144
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

const int MAXN = 101010;
ll dp[MAXN][3];

int main() {
    int N;
    cin >> N;
    vector<int> a(N), b(N), c(N);
    rep(i,N) {
        cin >> a[i] >> b[i] >> c[i];        
    }
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    srep(i,1,N) {
        dp[i][0] = LINF;
        dp[i][1] = LINF;
        dp[i][2] = LINF;
    }
    srep(i,1,N) {
        dp[i][0] = max(dp[i-1][1]+a[i], dp[i-1][2]+a[i]);
        dp[i][1] = max(dp[i-1][0]+b[i], dp[i-1][2]+b[i]);
        dp[i][2] = max(dp[i-1][0]+c[i], dp[i-1][1]+c[i]);
    }
    ll ans = max({dp[N-1][0], dp[N-1][1], dp[N-1][2]});
    cout << ans << endl;
    return 0;
}












Measured memory_bytes: 3712
#include <stdio.h>

int main(void) {
    int high, width, expect;
    scanf("%d", &high);
    scanf("%d", &width);
    scanf("%d", &expect);

    int max = high > width ? high : width;
    int rest = expect % max ? 1 : 0;

    printf("%d\n", expect / max + rest);

    return 0;
}


Measured memory_bytes: 128
// youngjinp20
// 2020 03

#include <bits/stdc++.h>
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; }
#define byr(x) [](const auto& a, const auto& b) { return a.x > b.x; }
#define smax(a, b) ((a) < (b) ? ((a)=(b), true) : false)
#define smin(a, b) ((a) > (b) ? ((a)=(b), true) : false)
using namespace std;

typedef long long ll;

const int MOD = 1e9+7;
const int MAX = 1<<21;
int N;
int a[21][21];
int dp[MAX];

int solve(int msk, int idx) {
	if (dp[msk] != -1) return dp[msk];
	if (idx < 0) return 1;

	int ct=0;

	for (int i=0; i<N; i++) {
		if (msk&(1<<i) && a[i][idx]) {
			int nmsk = msk ^ (1<<i);
			ct += solve(nmsk, idx-1);
			ct %= MOD;
		}
	}

	return dp[msk] = ct;
}

int main() {
	cin >> N;
	for (int i=0; i<N; i++) {
		for (int j=0; j<N; j++) {
			cin >> a[i][j];
		}
	}
	for (int i=0; i<(1<<N); i++) {
		dp[i] = -1;
	}
	cout << solve((1<<N)-1, N-1);
	return 0;
}


Measured memory_bytes: 8576
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <vector>
#include <queue>
using namespace std;
#define mod 1000000007
#define INF 0x7fffffffff
#define N 100100
#define endl '\n'
char a[]={"CODEFESTIVAL2016"};
char b[20];
int main()
{
    scanf("%s",b);
    int n=strlen(b),ans=0;
    for(int i=0;i<n;i++)
        if(a[i]!=b[i]) ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    int i=0,j=s.length()-1;
    int ans=0;
    while(i<j){
	if(s[i++] != s[j--])
	    ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

long long int a,b,c,d,e,n,t,i,j,k;
vector<long long int> v,s;
cin>>n;
for(i=0;i<n;i++){cin>>a;v.push_back(a);}
sort(v.begin(),v.end(),greater<long long int>());
n= n-2;
c=v[0];
    d=n/2;
    for(i=1;i<=d;i++){
    c = c+(v[i]*2);
}
if(n%2==1)c=c+v[d+1];
cout<<c<<endl;
}

Measured memory_bytes: 5352
#include <iostream>
#include <stdio.h>
#include <vector>
#include <cmath>
using namespace std;

int main(){
    
    int L;
    vector< vector<int> > ans;
    int r = 1, i = 1;
    
    cin >> L;
    
    while( 2*r <= L ) {
        ans.push_back( {i,i+1,0} );
        ans.push_back( {i,i+1,r} );
        i++; r*=2;
    }

    while( r != L ) {
        int j = (int)log2(L-r);
        ans.push_back( {j+1,i,r} );
        r += (int)pow(2,j);
    }
    
    printf("%d %d\n", i, (int)ans.size());
    for ( int i = 0; i < ans.size(); i++) {
        printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2] );
    }
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
	int main()
	{
		char A[1001];
		int B[5] = {0};
		scanf("%s",A);
		int n = strlen(A);
		int i;
		for(i=0;i<n;++i)
		{
			if( A[i] == 'N')
				B[1] = 1;
			else if( A[i] == 'S')
				B[2] = 1;
			else if( A[i] == 'W')
				B[3] = 1;
			else 
				B[4] = 1;	
		}
	//	for(i=1;i<5;++i)
	//	{
	//		printf("%d\n",B[i]);
	//	}
		if( B[1] == B[2] && B[3] == B[4])
			printf("Yes");
		else
			printf("No");
		return 0;
	}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdint.h>
#include <limits.h>

#define MIN(A,B) \
  ( (A) < (B) ? (A) : (B) )
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

static uint64_t
sqrt2 (
  uint64_t a
  )
{
  uint64_t res = MAX( a, 2 );

  for ( ; ; )
  {
    res = ( res * res + a ) / 2 / res;
    if ( a >= res * res
      && a < ( res + 1 ) * ( res + 1 ) )  break ;
  }

  return ( res );
}

static uint64_t
cbrt2 (
  uint64_t a
  )
{
  uint64_t res = MAX( a, 2 );

  for ( ; ; )
  {
    res = ( 2 * res * res * res + a ) / 3 / res / res;
    if ( a >= res * res * res
      && a < ( res + 1 ) * ( res + 1 ) * ( res + 1 ) )  break ;
  }

  return ( res );
}

static int
solve (
  int z,
  int e
  )
{
  int y;

  z += cbrt2 ( e );
  y  = sqrt2 ( e - z * z * z );

  return ( z + y + ( e - y * y ) );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int y, z;

  for ( ; ; )
  {
    int res = INT_MAX;
    int e;

    scanf ( "%d", &e );
    if ( !( e ) ) break ;

    for ( z = cbrt2 ( e ); z >= 0; --z )
    for ( y = sqrt2 ( e - z * z * z ); y >= 0; --y )
    {
      res = MIN( res
               , z + y + ( e - z * z * z - y * y ) );
    }

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

  return ( 0 );
}

Measured memory_bytes: 0
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int n;
ll ans=1;
int main(){
	scanf("%d",&n);
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=1000000007;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define mp make_pair
#define endl "\n"
#define N 100001
#define INF 1e9


int main(){
    
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    
    ll n , i  ;
    cin >> n ;
    pair<ll , ll >  d[n] ;
    ll siz[n+1] ;
    for(i=0 ; i<n ; i++){
        cin >> d[ i ].F  ;
        d[i].S = i+1 ;
        siz[i+1]=1 ;
    }
    sort(d , d+n) ;
    ll dis=0 ;
    vector<pair<ll , ll > > ans ;
    for(i=n-1 ; i>0 ; i--){
        ll sum = d[i].F-n+2*siz[d[i].S] ;
        ll pos = (ll)(lower_bound(d , d+n , mp(sum , 0LL)) - d) ;
        if(d[pos].F!=sum){cout << -1 ; return 0 ;}
        ll u = d[i].S , v = d[pos].S ;
        ans.pb(mp(u , v)) ;
        siz[v]+=siz[u] ;
        dis+=siz[u] ;
    }
    if(dis!=d[0].F){cout << -1 ; return 0 ;}
    for(i=0 ; i<n-1 ; i++){
        cout << ans[i].F << " " << ans[i].S << endl ;
    }


    return 0 ;
    
}


Measured memory_bytes: 5488
n,k = map(int,input().split())
if k ==0:
    print(n*n)
    exit()
ans = 0
for b in range(k+1,n+1):
    p = n//b
    r = n%b
    ans += max(b-k,0)*p + max(r+1-k,0)
print(ans)

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

int main(){
	int i,n,sum,f;
	char s[1000010];
	scanf("%s",&s);
	n=strlen(s);
	sum=0;f=0;
	for(i=n-1;i>=0;i--){
		if(s[i]>='5'){
			if(f==0&&s[i]=='5'){
				f=1;
				sum+=5;
			}
			else{
				if(f)s[i]++;
				sum+='0'+10-s[i];
				if(i!=0)s[i-1]++;
				else sum++;
				f=0;
			}
		}
		else if(s[i]<'5'){
			f=0;
			sum+=s[i]-'0';
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 1280
#![allow(unused_mut, unused_macros, unused_variables, unused_assignments, non_snake_case, unused_imports)]

use std::cmp::*;
use std::collections::*;

// [Rustで競技プログラミングの入力をスッキリ記述するマクロ - Qiita]
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 から拝借
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    // ABC128-C-Switches用に拡張
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, $t);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        N : usize,
        A : [usize; N]
    }
    let a2 = {
        let mut a2 = Vec::new();
        for a in A {
            a2.push(a * 2);
        }
        a2
    };
    let x = {
        let mut offset = 0usize;
        for a in &a2 {
            offset = a - offset;
        }
        offset / 2
    };

    let mut current = x;
    for a in a2 {
        println!("{}", current);
        current = a - current;
    }
}


Measured memory_bytes: 7420
# include <bits/stdc++.h>
using namespace std;
int n, cnt, mx;
string s;
int main (){
    cin >> n >> s;
    for (int i = 0; i < n; i ++){
        if (s[i] == 'I') {
            cnt ++;
            mx = max (mx, cnt);
        }
        else if (s[i] == 'D') cnt --;
    }
    cout << mx;
}


Measured memory_bytes: 256
import std.stdio, std.math, std.algorithm, std.array, std.string, std.conv, std.container, std.range;
pragma(inline, true) T[] Reads(T)() { return readln.split.to!(T[]); }
alias reads = Reads!int;
pragma(inline, true) void scan(Args...)(ref Args args) {
    string[] ss = readln.split;
    foreach (i, ref arg ; args) arg = ss[i].parse!int;
}

void main() {
    int n; scan(n);
    int[string] cnt;
    foreach (i; 0..n) {
        cnt[readln.chomp.dup.to!(char[]).representation.sort().to!string]++;
    }
    long ans;
    foreach (i, v ; cnt) {
        ans += (1L * v * (v-1)) / 2;
    }
    writeln(ans);
}


Measured memory_bytes: 19580
from collections import*
n,*a=map(int,open(0).read().split())


def main():
  
  if 1 not in a:
    print(-1);exit()

  b=deque(a)
  #print(b)

  i=1
  cnt=0
  while True:

    if len(b)==0:
      break

    if b[0]!=i:
      cnt+=1
      b.popleft()

    else:#b[0]==i
      cnt+=0
      b.popleft()
      i+=1

    #print(b,cnt)

  print(cnt)

  
main()

Measured memory_bytes: 24900
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
signed main(){
    string s;cin>>s;
    string ans={};
    for(int i=0;i<s.size();i+=2){
        ans+=s[i];
    }cout<<ans<<endl;return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<ll> v32;
typedef vector<vector<ll> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// #define INF 1e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
int LIM=2e5+100;
vv64 adj(LIM); 
ll func(int n,v64 &dp)
{
	if (dp[n]!=-1)
		return dp[n];
	dp[n]=0;
	for (int i=0; i<adj[n].size(); i++)
	{
		dp[n]=max(dp[n],func(adj[n][i],dp)+1);
	}
	return dp[n];
}
void solve()
{
	int n,m;
	cin>>n>>m;
	for (int i=1; i<=m; i++)
	{
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
	}
	v64 dp(n+1,-1);
	ll ans=0;
	for (int i=1; i<=n; i++)
	{
		dp[i]=func(i,dp);
		ans=max(ans,dp[i]);
	}
	cout<<ans<<endl;


}
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t=1;
    while (t--)
    {
        solve();
    }
    return 0;   
} 

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

using namespace std;

struct expand_type {
    template <typename... T>
    expand_type (T&&...) {}
};
template <typename... ArgTypes>
void print (ArgTypes... args) {
    expand_type {0, (cerr << args << ", ", 0)...};
    cerr << "\b\b \n";
}
#define printv(x) cerr << "["; for(auto i : (x)) cerr << i << ", "; cerr << "\b\b]\n";
#define __lcm(a,b) a * b / __gcd(a, b)

typedef unsigned long long ull;
typedef long double ld;


int main () {
    std::ios::sync_with_stdio (false);
    cin.tie (nullptr);
    cout.tie (nullptr);
    unordered_map<int, int> m;
    long long n, ans = 0, k, a, b, q;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> k;
		m[k]++;
		ans += k;
	}
	cin >> q;
	while (q--)
	{
		cin >> a >> b;
		int counta = m[a];
		ans -= counta * a;
		ans += counta * b;
		cout << ans << endl;
		m.erase(a);
		m[b] += counta;
	}
    return 0;
}


Measured memory_bytes: 6640
package main

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

type Row []string

type Data []Row

func main() {
	nextReader = newScanner()
	A := nextInt()
	B := nextInt()
	C := nextInt()
	fmt.Printf("%d %d %d", C, A, B)
}

var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	// r.Split(bufio.ScanLines)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func CustomScan(data []byte, atEOF bool) (advance int, token []byte, err error) {
	for i := 0; i < len(data); i++ {
		if data[i] == ' ' {
			return i + 1, data[:i], nil
		}
	}
	fmt.Println(data)
	return 0, data, bufio.ErrFinalToken
}

func nextStrings() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	// r.Split(bufio.ScanWords)
	r.Split(CustomScan)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}


Measured memory_bytes: 640
N=int(input())
T, A=map(int, input().split())
h=list(map(int, input().split()))
dif=10**7

for i in range(N):
    if abs(A-(T-0.006*h[i]))<=dif:
        t=i
        dif=abs(A-(T-0.006*h[i]))
print(t+1)

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

const int mod=1e9+7;
long long int dp[2005];

int main(){
  int s;
  scanf("%d", &s);
  dp[0]=1;
  dp[1]=dp[2]=0;
  for(int a=3;a<=s;a++){
  	for(int b=3;b<=a;b++){
  		(dp[a]+=dp[a-b])%=mod;
  	}
  }
  printf("%lld ", dp[s]);
}


Measured memory_bytes: 3788
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	s = int(rl())

	def binom_tables(n, q):
		fact = [1 for _ in range(n + 1)]
		inv = [1 for _ in range(n + 1)]
		for i in range(1, n+1):
			fact[i] = (fact[i-1] * i) % q
			inv[i] = pow(fact[i], q-2, q)
		return fact, inv

	F, I = binom_tables(s + s//3 + 10, MOD)

	def binom(n, k, q):
		return (F[n]*((I[k]*I[n-k])%q))%q

	ans = 0
	for r in range(1, 700):
		objects = s - 3*r
		if objects < 0: break
		x = binom(objects + r - 1, objects, MOD)
		ans += x
		ans %= MOD 

	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 70268
from itertools import product
from copy import deepcopy

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for hl in product([0, 1], repeat=h):
    for wl in product([0, 1], repeat=w):
        cc = deepcopy(c)
        for i, hi in enumerate(hl):
            for j, wj in enumerate(wl):
                if hi == 1 or wj == 1:
                    cc[i][j] = 'r'
        cnt = 0
        for s in cc:
            cnt += sum(si == '#' for si in s)
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9248
n,l = map(int,input().split(" "))
if l >= 0:
    a = int(((l+1)+(l+n-1))*(n-1)/2)
elif l+n-1 >= 0:
    a = int((l+(l+n-1))*n/2)
else:
    a = int((l+(l+n-2))*(n-1)/2)
print(a)

Measured memory_bytes: 9120
#include<bits/stdc++.h>
using namespace std;
const int N=4e3+10;

int n,st[N],tp=0;

int query(int x,int y) {
	cout<<'?'<<' '<<x-1<<' '<<y-1<<endl;
	string s;cin>>s;
	return s=="Y";
}

int main() {
	int a,b;cin>>a>>b;n=a+b;
	if(a<=b) cout<<"Impossible",exit(0);
	for(int i=1;i<=n;i++) {
		if(!tp||query(st[tp],i)) st[++tp]=i;
		else --tp;
	}
	string s;
	for(int i=1;i<=n;i++) s+=char(query(st[tp],i)+'0');
	cout<<"! "<<s;
	return 0;
}
///////////////////////////////////////////////////wryyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

Measured memory_bytes: 724
#include<stdio.h>
int main(){
    int a[4],i,i5,i7;
    i5=0;i7=0;
    for(i=0;i<3;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<3;i++){
        if(a[i]==5)   i5++;
        else if(a[i]==7)    i7++;
    }
    if(i5==2&&i7==1)   printf("YES");
    else printf("NO");
return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

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

	int i = 0;
	int subs = 0;
	while (i < n) {
		while (i < n - 1 && arr[i] == arr[i + 1]) {
			++i;
		}

		if (arr[i] < arr[i + 1]) {
			while (i < n - 1 && arr[i] <= arr[i + 1]) {
				++i;
			}
		} else {
			while (i < n - 1 && arr[i] >= arr[i + 1]) {
				++i;
			}
		}

		++i;
		++subs;
	}

	cout << subs << "\n";

	return 0;

}

Measured memory_bytes: 640
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {

	int list[4];
	for (int i = 0; i != 4; i++)cin >> list[i];

	sort(list, list + 4);

	if (list[0] == 1) {
		if (list[1] == 4) {
			if (list[2] == 7) {
				if (list[3] == 9) {
					cout << "YES" << endl;
					return 0;
				}
			}
		}
	}

	cout << "NO" << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  int x, a, b;
  cin >> x;

  a = (x / 500);
  b = x - a * 500;
  cout << a * 1000 + (b / 5) * 5 << endl;

  return 0;
}


Measured memory_bytes: 504
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<cstdio>
#include<iomanip>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int INF = 1e9 + 7;
int main() {
	vector<int>V;
	for (int i = 0; i < 3; ++i) {
		int a;
		cin >> a;
		V.push_back(a);
	}
	sort(V.begin(), V.end());
	cout << V[0] * V[1] / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
N=int(input())

ans=0

def is_ok(A,B,N):
    if A*B<N:
        return True
    else:
        return False

for a in range(1,N):

    ok=0
    ng=10**6+100
    while abs(ng-ok)>1:
        mid=(ok+ng)//2
        
        if is_ok(a,mid,N):
            ok=mid
        else:
            ng=mid
    
    ans+=ok
    
print(ans)

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

int main()
{
        int x, y;

        cin >> x >> y;
        
        if( x>y ){ cout << "a > b"<< endl; }
        else if( x<y ){ cout << "a < b" << endl; }
        else if( x==y ){ cout << "a == b" << endl; }

        return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
using namespace std;
//
int main(){
  int N,cnt2=0,cnt4=0;
  cin>>N;
  FOR(i,0,N){
    int A;
    cin>>A;
    if(A%4==0){
      cnt4++;
    }else if(A%2==0){
      cnt2++;
    }
  }
  if(N<=2*cnt4+1){
    Yes(1);
  }else if(N<=2*cnt4+cnt2){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr << #x <<": "<<(x)<<endl
#define debug2(x,y) cerr << #x <<": "<< (x) <<", "<< #y <<": "<< (y) << endl
#define answer(x) cout << (x) <<endl
#define answer_fixed(x, p) cout << fixed << setprecision(p) << (x) << endl
using namespace std;
//static const int INF = 1e9;
//static const double PI = acos(-1.0);
//static const double EPS = 1e-10;
//static const int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
//static const int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
typedef long long int LL;
typedef unsigned long long int ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<double> VD;
typedef vector<VD> VVD;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int, int> PII;

int main() {
  ios_base::sync_with_stdio(false);
  int N;
  cin >> N;
  VI A(N), B(N), D(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  REP(i, N) D[i] = A[i] - B[i];
  sort(all(D));
  LL sum = accumulate(all(D), 0LL);
  if(sum < 0) {
    cout << -1 << endl;
    exit(0);
  }

  int rans = 0;
  auto itr = lower_bound(all(D), 0);
  while(itr != D.end() && sum >= *itr) {
    sum -= *(itr++);
    rans++;
  }
  answer(N - rans);
  return 0;
}



Measured memory_bytes: 1408