akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		int n = int.Parse(Console.ReadLine());
    long[] answers = new long[n];
    List<int>[] nextList = new List<int>[n];
    List<int> nextVertex = new List<int>();
    for(int i = 0; i < n; i++) nextList[i] = new List<int>();
    for(int i = 0; i < n-1; i++)
    {
      int[] numsa = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
      nextList[numsa[0]-1].Add(numsa[1]-1);
      nextList[numsa[1]-1].Add(numsa[0]-1);
    }
		long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    Array.Sort(nums);
    long answer = 0;
    for(int i = 0; i < n-1; i++) answer += nums[i];

    int startVertex = 0;
    int nowVertex = 0;
    int answerCount = 0;
    while(true)
    {
      if(nextList[startVertex].Count == 1) break;
      else startVertex++;
    }
    nowVertex = startVertex;

      while(true)
      {
        answers[nowVertex] = nums[n-1-answerCount];
        answerCount++;
        if(answerCount == n) break;

        for(int i = 0; i < nextList[nowVertex].Count(); i++)
        {
          nextVertex.Add(((List<int>)nextList[nowVertex])[i]);
          nextList[((List<int>)nextList[nowVertex])[i]].Remove(nowVertex);
        }

        nowVertex = nextVertex[0];
        nextVertex.RemoveAt(0);
      }
    

		Console.WriteLine(answer);
    Console.WriteLine(string.Join(" ", answers));
	}
}

Measured memory_bytes: 21948
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int a, b; cin >> a >> b;
	int x, y; x = 0; y = 0;
	string x_s, y_s;
	rep (i, a) {
		x = (x * 10) + b;
	}
	rep (i, b) {
		y = (y * 10) + a;
	}
	if (a == b) {
		cout << x << endl;
		return;
	}
	x_s = to_string(x); y_s = to_string(y);
	int ans = strcmp(x_s.c_str(), y_s.c_str());
	if (ans < 0) {
		cout << x_s << endl;
	} else {
		cout << y_s << endl;
	}
	return;
}

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

Measured memory_bytes: 256
S = input()
Q = int(input())

Queries = []
for i in range(Q):
    Queries.append(list(input().split()))

rev = False
head = ""
tail = ""

# listの最初に要素を追加するのはO(N), dequeを使うという選択肢

for query in Queries:
    if query[0] == '1':
        tmp = head
        head = tail
        tail = tmp
        rev = 1 - rev  # True/Falseを入れ替える

    if query[0] == '2':
        if query[1] == '1':
            head += query[2]
        if query[1] == '2':
            tail += query[2]

if rev:
    S = S[::-1]
S = head[::-1] + S + tail
print(S)

Measured memory_bytes: 30964
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {   if (y & 1)
        res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	int ans=0;
	if(n==m)ans+=2*n;
	else
	ans=max(n,m)*2-1;
	cout<<ans;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long> a(N+1, 0);
    long long b;
    for(int i = 1; i <= N; i++) {
        cin >> b;
        a[i] = b + a[i-1];
    }

    long long ans = LLONG_MAX;

    for(int i = 1; i < N; i++) {
        long long x = a[i];
        long long y = a[N] - a[i];
        ans = min(ans, abs(x-y));
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
/*
Author :: Shourov Chowdhury
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

using namespace std;

typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

const int INF = 2000000009;
const int MX = 105;
const double EPS = 1e-9;
const int MOD = 1000000007;

/**********************Code starts here*********************************/


int main()
{
    //std::ios_base::sync_with_stdio(false);

    int n = II();
    char a[MX],b[MX],c[MX];
    scanf("%s %s %s",a,b,c);
    int ans = 0;
    for (int i = 0;i<n;i++){
        if (a[i]==b[i] && b[i]==c[i]) ans+=0;
        else if (a[i]==b[i] || a[i]==c[i] || b[i]==c[i]) ans+=1;
        else ans+=2;
    }
    printf("%d\n",ans );
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define pi acos(-1)
#define faster_io ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

int main()
{
    //freopen("/home/sohel/Documents/my_codes/out.txt", "wt", stdout);
    int n,temp;
    cin >> n;
    temp = n % 1000;
    if (temp == 0)
    {
        cout << 0 << endl;
    }
    else {
        cout << 1000 - temp << endl;
    }
    return 0;
}

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

int main()
{
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;

    if (s == u)
    {
        a--;
    }
    if (t == u)
    {
        b--;
    }

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

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 998244353;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

map<ld,Pll> mp;

ll a,b,c,d,e,f;
/*
ld dfs(ll wa, ll su){
    if(wa*100 + su > f) return 0;
    ld res = ld(ld(su)/ld(wa*100+su)); 
    mp[res] = Pll(wa,su);
    if(wa*e >= su+c){
        cmax(res, dfs(wa, su+c));
    }
    if(wa*e >= su+d){
        cmax(res, dfs(wa, su+d));
    }
    cmax(res, dfs(wa+a,su));
    cmax(res, dfs(wa+b,su));
    return res;
}*/

int main(){
    cin >> a >> b >> c >> d >> e >> f;
    //a *= 100;
    //b *= 100;
    //ld M = max(dfs(a,0), dfs(b,0));
    //cout << M << endl;
    vector<ll> dw(31), ds(1501);
    REP(i,1,31){
        if(i*a < 31){
            dw[i*a]++;
        }
    }
    dw[0] = 1;
    rep(i,31){
        if(dw[i]>0){
            if(i+b<31){
                dw[i+b]++;
            }
        }
    }
    REP(i,1,1501){
        if(i*c < 1501){
            ds[i*c]++;
        }
    }
    ds[0] = 1;
    rep(i,1501){
        if(ds[i]>0){
            if(i+d<1501){
                ds[i+d]++;
            }
        }
    }
    ld M = 0;
    REP(i,1,31){
        if(dw[i] > 0){
            ll tmp = 0;
            if(i*100 > f){
                break;
            }
            for(ll j=0;j<1501;j++){
                if(i*100+j > f) break;
                if(i*e < j) break;
                if(ds[j] == 0) continue;
                tmp = j;
            }
            if(tmp > 0){
                cmax(M, ld(tmp)/ld(i*100+tmp));
                mp[ld(tmp)/ld(i*100+tmp)] = Pll(i,tmp);
            }
        }
    }
    if(M==0){
        cout << a*100 << " "<< 0 << endl;
        return 0;
    }
    cout << mp[M].first*100 + mp[M].second << " " << mp[M].second << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(auto i = (n).begin(); i != (n).end(); i++)
#define in_arr(type, a, n) copy_n(istream_iterator<type>(cin), n, (a).begin());

int main(){
    int s, ret = 0;
    cin >> s;
    set<int> se;
    while(true){
        ret++;
        if(se.find(s) != se.end()){
            break;
        }
        se.insert(s);
        if(s % 2 == 0){
            s /= 2;
        }else{
            s = s * 3 + 1;
        }
    }
    cout << ret << endl;
    return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, n) for (auto i : (n))
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  CIN(string, S);
  COUT(string(S.size(), 'x'));
}


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

// definitions
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i, l, r) for (long long i = (l); i < (r); i++)
#define repb(i, r, l) for (long long i = (r); i > (l); i--)
#define pb push_back

using namespace std;
typedef vector<long long> vl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector< pair<long long, long long> > vp;
typedef vector<tuple<long long , long long , long long> > vtup;
typedef deque <long long> dq;
typedef long long int lli;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull; 

const int MAX_CHAR=256;
const ll mod = 1e9 + 7;
const ll mod1= 998244353;


// standard functions
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
} 
 


ll modexp(ll x, ll ex, ll modp) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x)%modp;
        ex >>= 1ll;
        x = (x * x)%modp;
    }
    return ans;
} 
 
ll nCrModp(ll n, ll r, ll p) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1; 
    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            C[j] = (C[j] + C[j-1])%p; 
    } 
    return C[r]; 
}
 
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true;  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
vl countFreq(ll arr[], ll n) 
{ 
    unordered_map<ll, ll> mp; 
    vector <ll> v;
    
    for (ll i = 0; i < n; i++) 
        mp[arr[i]]++; 
   
    for (auto x : mp) 
        v.pb(x.second);
    
    return v;
}

ll binarySearch(ll arr[], ll l, ll r, ll x) 
{ 
    while (l <= r) 
    { 
        ll m = l + (r - l) / 2; 
        if (arr[m] == x) 
            return m; 
        if (arr[m] < x) 
            l = m + 1; 
        else
            r = m - 1; 
    }
    return -1; 
}

const ll MAXSIEVE=(1e3);
ll spf[MAXSIEVE];
void sieve() 
{ 
    spf[1] = 1; 
    for (ll i=2; i<MAXSIEVE; i++) 
        spf[i] = i; 

    for (ll i=4; i<MAXSIEVE; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXSIEVE; i++) 
    { 
        if (spf[i] == i) 
        { 
            for (ll j=i*i; j<MAXSIEVE; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
}

// code beigns in main
int main()
{
    
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t=1;
    // cin >> t;
    
    while(t--)
    {
        string str;
        cin >> str;

        bool flag=false;
        rep(i,0,str.length())
        if(str[i]=='7')
        {
            flag=true;
            break;
        }

        if(flag)
        cout << "Yes" << endl;
        else
        cout << "No" << endl;
    }
}



Measured memory_bytes: 3624
//BISMILLAH
#include<bits/stdc++.h>
#define ll long long
#define max 100005
using namespace std;
vector<ll> freq(max);
//int DFS(int);

int main()
{
    ll n,flag=0,x,value=0,sum=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        sum+=x;
        freq[x]++;
    }

    int t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        sum -= freq[a] * a;
		sum += freq[a] * b;
        freq[b]+=freq[a];
        freq[a]=0;

        cout<<sum<<endl;
    }

}


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

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

typedef pair<int,int> pi;

struct edge{ int to,cost; };
vector<edge> G[110];

const int INF=123456789;
int dist[64][110];

int m,n,k,d;

inline int convert(string s)
{
    if(s[0]=='H') return 0;
    else if(s[0]=='D') return m+n+1;
    else if(s[0]=='C') return s[1]-'0';
    else return m+atoi(s.substr(1).c_str());
}

int main()
{
    cin.tie(0);ios::sync_with_stdio(false);
    while(cin >>m >>n >>k >>d,m)
    {
        rep(i,110) G[i].clear();
        fill(dist[0],dist[64],INF);

        vector<int> c(m);
        rep(i,m) cin >>c[i];

        rep(i,d)
        {
            string s,t;
            int e;
            cin >>s >>t >>e;
            int a=convert(s), b=convert(t);

            G[a].pb(edge{b,e});
            G[b].pb(edge{a,e});
        }

        queue<pi> que;
        que.push(pi(0,0));
        dist[0][0]=0;
        while(!que.empty())
        {
            pi now=que.front(); que.pop();
            int cake=now.fi;
            int v=now.se;
            rep(i,G[v].size())
            {
                edge e=G[v][i];
                if(1<=e.to && e.to<=m)
                {
                    if((cake>>(e.to-1))&1) continue;

                    int nc=cake|(1<<(e.to-1));
                    if(dist[nc][e.to]>dist[cake][v]+e.cost)
                    {
                        dist[nc][e.to]=dist[cake][v]+e.cost;
                        que.push(pi(nc,e.to));
                    }
                }
                else
                {
                    if(dist[cake][e.to]>dist[cake][v]+e.cost)
                    {
                        dist[cake][e.to]=dist[cake][v]+e.cost;
                        que.push(pi(cake,e.to));
                    }
                }
            }
        }

        int ans=INF;
        rep(i,1<<m)
        {
            if(dist[i][m+n+1]==INF) continue;

            int t=k*dist[i][m+n+1];
            rep(j,m) if(i>>j&1) t-=c[j];
            ans=min(ans,t);
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{
	int h, w; cin >> h >> w;
	
	vector<vector<char>> c(h + 1, vector<char>(w + 1));
	
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}

	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cout << c[i][j];
		}
		cout << endl;

		for (int j = 1; j <= w; j++) {
			cout << c[i][j];
		}
		cout << endl;
	}

	return 0;
}

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

using namespace std;

using ll = long long;

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

    ll a, b;
    cin >> a >> b;

    ll ans = 0;
    if (b % 4 == 0) ans = b;
    else if (b % 4 == 1) ans = 1;
    else if (b % 4 == 2) ans = b + 1;

    --a;
    if (a % 4 == 0) ans ^= a;
    else if (a % 4 == 1) ans ^= 1;
    else if (a % 4 == 2) ans ^= a + 1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int 
#define pb push_back
using namespace std;

const int INF= 1e9 +5;
typedef std::vector<int> vi;
typedef pair<int,int> ii;


int main() {

	//freopen("input.txt", "r", stdin); 
  	//freopen("output.txt", "w", stdout); 


  	string s,t;
  	cin>>s>>t;
  	int a=0;
  	if(s[0]==t[0])a++;
  	if(s[1]==t[1])a++;
  	if(s[2]==t[2])a++;

  	printf("%d\n",a );

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define mid(l,r) ((l)+((r)-(l))/2)
#define ALL(A) A.begin(), A.end()
#define sc(x) scanf("%d", &x)
#define pr(x) printf("x:%dn", x)
#define fastio ios::sync_with_stdio(0),cin.tie(0)
#define frein freopen("in.txt", "r", stdin)
#define freout freopen("out.txt", "w", stdout)
#define debug cout<<"???"<<endl
const ll mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll INF64 = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-7;
template<class T> T gcd(T a, T b){if(!b)return a;return gcd(b,a%b);}
const int maxn = 4e6;
int a[maxn];

bool cmp(int a, int b)
{
    return a > b;
}

int main()
{
    int n, k;
    sc(n);sc(k);
    for(int i = 0; i < n; i++){
        int x;
        sc(x);
        a[x]++;
    }
    sort(a + 1, a + n + 1, cmp);
    int ans = n;
    for(int i = 1; i <= k; i++){
        ans -= a[i];
    }
    printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define pii pair<int, int>
#define pll pair<long long,long long>
#define vl vector<long long>
#define vll vector<pll>
#define vi vector<int>
#define vii vector<pii>
#define sws ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl '\n'
#define tcase int tt; cin>>tt; while(tt--)
#define tcase2 int tt; cin>>tt; for(int qq=1;qq<=tt;qq++)
using namespace std;
typedef long long int ll;
typedef  unsigned long long int ull;
typedef long double ld;
const int MAX = 1000002;
const int MOD2 = 998244353;
const int MOD = 1000000007; 
const int INF = 1e8;
const ld EPS = 1e-7;
// Extra
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define forne(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define trav(a, x) for(auto& a : x)
#define fill(x,y) memset(x,y,sizeof(x))
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
ll dectobin(ll n,ll p[])
{
    ll i=0 ;
    while(n!=0)
    {
        p[i]=n%2 ;
        n/=2 ;
        i++ ;
    }
    return(i-1) ;
}
ll binarySearchCount(ll arr[], ll n, ll key) 
{ 
    ll left = 0; 
    ll right = n - 1; 
  
    ll count = 0; 
  
    while (left <= right) { 
        int mid = (right + left) / 2; 
  
        // Check if middle element is 
        // less than or equal to key 
        if (arr[mid] < key) { 
  
            // At least (mid + 1) elements are there 
            // whose values are less than 
            // or equal to key 
            count = mid + 1; 
            left = mid + 1; 
        } 
  
        // If key is smaller, ignore right half 
        else
            right = mid - 1; 
    } 
  
    return count; 
} 
void printDivisors(ll n,ll k) 
{  ll temp=1  ;
    // Note that this loop runs till square root 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            // If divisors are equal, print only one 
            if (n/i == i) 
                {
                	if(i<=k && i>temp)
                	temp=i ;
				}
  
            else // Otherwise print both 
                
                {
                if(i<=k && i>temp)
                	temp=i ;
                if(n/i<=k && n/i>temp)
                temp=n/i ;
				}
        } 
    }
	cout<<n/temp<<"\n" ;
	return ; 
} 

int main(int argc, char** argv)
{   sws ;
//tcase
{ 
  ll a,b ;
  cin>>a>>b ;
  cout<<a*b<<"\n" ;
}
  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

ll dp[3001][3001];
ll dps[3001][3001];

int main(){
  int n;cin>>n;
  string s;cin>>s;

  dp[0][0]=1;

  rep(i, n-1){
    dps[i][0]=dp[i][0];
    rep1(j, n){
      dps[i][j] += dps[i][j-1]+dp[i][j];
    }
    rep(j, i+2){
      if(s[i]=='<'){
        if(j)dp[i+1][j] += dps[i][j-1];
      }else{
        dp[i+1][j] += dps[i][i+1];
        if(j)dp[i+1][j] -= dps[i][j-1];
      }
      while(dp[i+1][j]<0)dp[i+1][j]+=MOD;
      dp[i+1][j] %= MOD;
    }
  }

  ll result=0;
  rep(j, n)result += dp[n-1][j];
  cout<<result%MOD<<endl;

  return 0;

rep(i, n){
rep(j, n)cout<<dp[i][j]<<' ';cout<<endl;
}

  return 0;
}

Measured memory_bytes: 120060
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int N;
	cin >> N;
	string current;
	string before = "";
	set<string> memo;

	for (int i = 0; i < N; i++)
	{
		cin >> current;
		if (before.size())
		{
			if (current[0] != before.back())
			{
				cout << "No" << endl;
				return;
			}
		}
		memo.insert(current);
		before = current;
	}

	if (memo.size() == N)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  int N;
  cin >> N;
  vector<int> ans(N+1,0);
  for(int x = 1;x*x<=N;x++){
    for(int y = 1;y*y<=N;y++){
      for(int z = 1;z*z<=N;z++){
        if(x*x+y*y+z*z+x*y+y*z+x*z<=N){
          ans[x*x+y*y+z*z+x*y+y*z+x*z]++;
        }
      }
    }
  }

  FOR(i,1,N+1){
    cout << ans[i] << endl;
  }
}

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


int main(){
  int n = 0;
  cin  >> n;
  vector<int>v(n);
  rep(i,n) cin >> v.at(i);
  int mn = 2147483647;
  for(int i = 0; i <100; i++){
    int temp = 0;
    for(int j = 0; j < n; j++){
      temp += (i - v.at(j))*(i - v.at(j));
    }
    mn = min(temp,mn);
  }
  cout << mn;
 
}



Measured memory_bytes: 256
import numpy as np
n = int(input())
A = np.array(list(map(int, input().split())))
mod = 10 ** 9 + 7

ans = 0
for i in range(64):
    tmp = (A >> i) & 1
    x = np.count_nonzero(tmp)
    x *= n - x
    ans += pow(2, i, mod) * x % mod

print(ans % mod)


Measured memory_bytes: 48808
#include<bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
typedef long long ll;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef set<int> SI;
typedef map<string, int> MSI;
typedef map<int, int> MII;
typedef pair<ll, ll> PLL;
typedef pair<ll, pair<ll, ll>> PLLL;

#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MP make_pair
#define PB push_back
#define FF first
#define SS second
#define MOD 1000000007
#define test ll t;cin>>t;while(t--)

void solve()
{
	int n,x,r;
	cin >> n >> x >> r;
	ll ans=r,k=x;
	while(n>k)
	{
		ans+=r;
		k+=x;
	}
	cout << ans << "\n";
	return;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	flash;

	// test
	// {
	// 	solve();
	// }
	solve();
#ifndef ONLINE_JUDGE
	cout << "\nTime Elapsed : " << 1000 * (double)clock() / (double)CLOCKS_PER_SEC
	     << " ms\n";
#endif
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N,M; cin>>N>>M;
    vector<vector<int>> G(N);
    for(int i=0;i<N-1;i++){
        int a,b; cin>>a>>b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    
    vector<int> dp(N);
    function<int(int,int)> dfs=[&](int v,int par)
    {
        int res=1;
        for(int u:G[v]) if(u!=par){
            res=res*(dfs(u,v)+1)%M;
        }
        return dp[v]=res;
    };

    vector<int> ans(N);
    vector<vector<int>> L(N),R(N);
    function<void(int,int)> dfs2=[&](int v,int par)
    {
        L[v].assign(G[v].size()+1,1);
        R[v].assign(G[v].size()+1,1);
        for(int i=0;i<G[v].size();i++){
            int u=G[v][i];
            L[v][i+1]=L[v][i]*(dp[u]+1)%M;
        }
        for(int i=G[v].size()-1;i>=0;i--){
            int u=G[v][i];
            R[v][i]=R[v][i+1]*(dp[u]+1)%M;
        }
        ans[v]=R[v][0];

        for(int i=0;i<G[v].size();i++){
            int u=G[v][i];
            if(u!=par){
                int tmp=dp[v];
                dp[v]=L[v][i]*R[v][i+1]%M;
                dfs2(u,v);
                dp[v]=tmp;
            }
        }
    };
    dfs(0,-1);
    dfs2(0,-1);
    for(int i=0;i<N;i++) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 26240
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!double;
    foreach (i; 0..50000+1) {
        if ((i * 1.08).to!int == N) {
            writeln(i);
            return;
        }
    }
    writeln(":(");
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
        char b;
        cin >> b;
        if(b =='A') cout << 'T';
        if(b =='T') cout << 'A';
        if(b =='C') cout << 'G';
        if(b =='G') cout << 'C';
        cout << endl;
        return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void keisann(int a, int b) {
	long long ac = a;
	long long bc = b;
	bool d = true;
	do {
		a = a%b;
		if (a == 0) {
			cout << b << " ";
			cout << ac*bc/ b << endl;
			d = false;
			continue;
		}
		b = b%a;
		if (b == 0) {
			cout << a << " ";
			cout << ac*bc / a << endl;
			d = false;
			continue;
		}
	} while (d == true);
}

int main()
{
	int a, b;
	while (cin >> a>>b) {
		if (a > b) { keisann(a, b); }
		else if (a < b) {
			int c = a;
			a = b;
			b = c;
			keisann(a, b);
		}
		else if (a == b) {
			cout << "1" << " " << a << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3016
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int i = 0;
    while (i < s.size()) {
        if (s.substr(i, 5) == "esare") i += 5;
        else if (s.substr(i, 5) == "maerd") i += 5;
        else if (s.substr(i, 7) == "remaerd") i += 7;
        else if (s.substr(i, 6) == "resare") i += 6;
        else {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}


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

int main() {
long long n;
cin >> n;
long long a[n];
long long ans = 0;
for(int i=0;i<n;i++){
    cin >> a[i];
}
long long sum[n+1];
sum[0]=0;
map<long long,long long> p;
p[0]=1;
for(long long i=0;i<n;i++){
    sum[i+1]=sum[i]+a[i];
}
for(long long i=0;i<n;i++){
    if(p.find(sum[i+1])==p.end()) p[sum[i+1]]=1;
    else p[sum[i+1]]++;
}
for(auto i:p){
    ans+=(i.second*(i.second-1))/2;
}
cout << ans << endl;
}


Measured memory_bytes: 15872
program atcoder
  implicit none
  integer d, n, i
  read *, d, n    ! 変数mに、標準入力から数字を読み込み代入する
  if (N<100) then
   i=100**D*N
  else
   i=100**D*101
  end if
  print'(i0)', i    !  ","のあとに解答となる変数を書く
end program atcoder

Measured memory_bytes: 896
w, b  =gets.strip.split.map(&:to_i)
result = Array.new(100){[]}

white_zone = Array.new(50) { ['.']*100 }
black_zone = Array.new(50) { ['#']*100 }

(b-1).times do |i|
  y = i/50*2+1
  x = i%50*2
  white_zone[y][x] = '#'
end

(w-1).times do |i|
  y = i/50*2+1
  x = i%50*2
  black_zone[y][x] = '.'
end

puts '100 100'
(white_zone+black_zone).each do |line|
  puts line.join('')
end



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



int main() {
  int N;
  cin>>N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  int64_t sum=100000000000;
  for(int j=-100;j<=100;j++){
    int64_t ksum=0;
    for(int i=0;i<N;i++){
      ksum+=(vec.at(i)-j)*(vec.at(i)-j);
    }
    sum=min(sum,ksum);
  }
  cout<<sum<<endl;
      
    
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int n; cin >> n;
    ll ans = n * (n-1ll) / 2ll;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define pii pair<int, int>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=1e5+3, INF=1e9;
int l;
double ans;
signed main()
{
    cout << setprecision(20);
    cin >> l;
    ans = (l/3.0) * (l/3.0) * (l/3.0);
    cout << ans;
}

Measured memory_bytes: 256
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R: std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read {
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    pub fn read_line(&mut self) {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_a<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
}

fn main() {
    let stdin = std::io::stdin();
    let stdin = std::io::BufReader::new(stdin.lock());
    let read = Read::new(stdin);
    let stdout = std::io::stdout();
    let stdout = std::io::BufWriter::new(stdout.lock());
    solve(read, stdout);
}
#[allow(unused_mut)]
use std::io::Write;
fn solve<R: std::io::BufRead>(mut r: Read<R>, mut w: std::io::BufWriter<std::io::StdoutLock>) {
    let n: i32 = r.read_a();
    let m: i32 = r.read_a();
    let x: i32 = r.read_a();
    let mut c: Vec<i32> = Vec::new();
    let mut a: Vec<Vec<i32>> = Vec::new();
    for i in 0..n as usize {
        c.push(r.read_a());
        a.push(Vec::new());
        for j in 0..m {
            a[i].push(r.read_a());
        }
    }

    let max = 2_i32.pow(n as u32);
    let mut ans = std::i32::MAX;
    for mut i in 1..max {
        let mut tmp = 0;
        let mut sum = vec![0; m as usize];
        for j in 0..n {
            if i & 1 == 1 {
                tmp += c[j as usize];
                for k in 0..m as usize {
                    sum[k] += a[j as usize][k];
                }
            }
            i >>= 1;
            if i <= 0 {
                break;
            }
        }
        let mut flg = true;
        for j in 0..m {
            if sum[j as usize] < x {
                flg = false;
            }
        }

        ans = if ans > tmp && flg { tmp } else { ans };
    }
    write!(w, "{}\n", if ans != std::i32::MAX { ans } else { -1 }).unwrap();
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class T>
class SegmentTree {

public:
    /**
     * @param N size
     * @param e identity element
     * @param operation operation for query
     * @param updater operation for update
     */
    SegmentTree(size_t N, T e, function<T(T, T)> operation, function<T(T, T)> updater)
            : e(e), operation(std::move(operation)), updater(move(updater)) {
        n = 1;
        while (n < N) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, e);
    }

    /**
     * iの値をxに更新
     * @param i index ( 0-indexed )
     * @param x  value
     */
    void update(int i, T x) {
        i += n - 1;
        data[i] = updater(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    T query(int a, int b) {
        return query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス
     * @param i index ( 0-indexed )
     */
    T operator[](int i) {
        return data[i + n - 1];
    }

private:
    int n;
    vector<T> data;
    T e;
    function<T(T, T)> operation;
    function<T(T, T)> updater;

    T query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return e;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        T c1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        T c2 = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }
};

void Main() {
    ll N;
    cin >> N;
    vector<ll> H(N), A(N);
    rep(i, N) cin >> H[i];
    rep(i, N) cin >> A[i];
    SegmentTree<ll> segmentTree(N + 1, 0, [](ll a, ll b) { return max(a, b); }, [](ll a, ll b) { return max(a, b); });
    rep(i, N) {
        ll h = H[i];
        ll a = A[i];
        ll res = segmentTree.query(0, h) + a;
        segmentTree.update(h, res);
    }
    cout << segmentTree.query(0, N + 1) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main () {
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  if (v <= w) {
    cout << "NO" << endl;
    return 0;
  }
  ll d = max(a - b, b - a);
  cout << ((d <= (t * (v - w))) ? "YES" : "NO") << endl;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    int v[N];
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    int ans = 0;
    for (int i = 0; i <= min(N, K); i++)
    {
        for (int j = 0; i + j <= min(N, K); j++)
        {
            vector<int> jewelry;
            for(int k = 0; k < i; k++) jewelry.push_back(v[k]);
            for(int k = 0; k < j; k++) jewelry.push_back(v[N-1-k]);

            sort(jewelry.begin(), jewelry.end());
            int s = 0;
            for (int k = 0; k < min(K - i - j, (int)jewelry.size()); k++)
            {
                if(jewelry[k] < 0) s++;
            }
            int tmp = 0;
            for (int k = s; k < jewelry.size(); k++)
            {
                tmp += jewelry[k];
            }
            ans = max(ans, tmp);
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n ,m;
	cin>>n>>m;
	ll ans=0;
	ll l=0;
	ll r=1e15;
	while(l<=r){
		ll mid=(l+r)/2;
		ll need=0;
		if(n<mid)
			need=(mid-n)*2;
		ll temp=m-need;
		ll t2=n+need;
		if(temp/2>=mid && t2>=mid)
		ans=mid,l=mid+1;
		else
		r=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define ll long long
#define str string
#define INF (1e9)

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

vector < pair<ll, ll> > v;
ll V[10000000] = {}, G[10000000] = {},m = 0,a = 0,b = 0,n = 0, k = 0,sum = 0;
str S,Sa;
bool ans = false;

int findSumOfDigits(int n) {
	int sum = 0;
	while (n > 0) {
		
		sum += n%10;
		n /= 10;
	}
	return sum;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
		//Code Line
cin >> n;
if(0 <= n && n <= 111)cout << 111 << endl;
else if(112 <= n && n <= 222)cout << 222 << endl;
else if(223 <= n && n <= 333)cout << 333 << endl;
else if(334 <= n && n <= 444)cout << 444 << endl;
else if(445 <= n && n <= 555)cout << 555 << endl;
else if(556 <= n && n <= 666)cout << 666 << endl;
else if(667 <= n && n <= 777)cout << 777 << endl;
else if(778 <= n && n <= 888)cout << 888 << endl;
else if(889 <= n && n <= 999)cout << 999 << endl;


		//Code Line
return 0; 
}


Measured memory_bytes: 256
# coding: utf-8
# Here your code !

def func():
    try:
        (n,m) = tuple( [ int(num) for num in input().rstrip().split(" ") ] )
        matrix = [ [int(num) for num in input().rstrip().split(" ")] for i in range(n) ]
        vector = [ int( input().rstrip() ) for i in range(m) ]
    except:
        return inputError()

    result = [ sum( [ matrix[j][i]*vector[i] for i in range(m) ] ) for j in range(n)  ] #????????¨??????????????????

    for num in result:
        print(num)
    
def inputError():
    print("input error")
    return -1

func()

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

int main() {
  int N;
  cin >> N;
  string number;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y"){
      number = "Four";
      cout << number << endl;
      break;
    }
  }
  
  if(number != "Four"){
    number ="Three";
    cout << number << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

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

int W, H, ans;
int A[1010][1010];
queue<pii> Q;

int main(){
    char ch;
    scanf("%d %d", &W, &H);

    memset(A, -1, sizeof A);
    for (int i=1; i<=W; i++){
        for (int j=1; j<=H; j++){
            scanf(" %c", &ch);
            A[i][j] = 0;
            if (ch == '#') {
                Q.push(pii(i, j));
                A[i][j] = 1;
            }
        }
    }
    while (!Q.empty()){
        pii F = Q.front();
        Q.pop();
        for (int i=0; i<4; i++){
            if (A[F.first+dx[i]][F.second+dy[i]]) continue;
            A[F.first+dx[i]][F.second+dy[i]] = A[F.first][F.second]+1;
            ans = max(ans, A[F.first][F.second]);
            Q.push(pii(F.first+dx[i], F.second+dy[i]));
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 12432
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



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

  int ans = 0;
  rep(i, n) {
    int l, r;
    cin >> l >> r;

    ans += (r-l+1);
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int i = 0;
  
  for (i = 0; i < N; i++) {
    cin  >> vec.at(i);
  }
  
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  int count = 0;
  int count_2 = 0;
  
  for (i = 0; i < N; i += 2) {
    count += vec.at(i);
  }
  
  for (i = 1; i < N; i += 2) {
    count_2 += vec.at(i);
  }
  
  cout << count - count_2 << endl;
  
}
    
    
    
    
    
    
    
    
    
    
    
    
    
      
    
  

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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

using namespace std;

int main ()
{
  int N,M;

  cin >> N >> M;
  
  if (N==M)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3608
n = int(input())
ans = 0
for i in range(1, 6):
    if n == 10 ** i:
        ans = 1

if ans == 1:
    print(10)
else:
    num = 0
    for i in range(1, 6):
        num += n % 10
        n = n // 10
    print(num)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
#define rep(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const double eps=1e-6;
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
const int N=1e5+5;
int prime[N],sum[N];
bool is_pr[N];
int cnt;
inline int Scan()
{
    int r = 0,f = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9')
    {
        if(ch == '-')f = -1;
        ch = getchar();
    }
    while(ch >= '0' && ch <= '9')
    {
        r = (r << 3) + (r << 1) + ch - '0';
        ch = getchar();
    }
    return r * f;
}
inline void Print(int x)
{
    if(x < 0)
    {
        x = -x;
        putchar('-');
    }
    if(x > 9)Print(x/10);
    putchar(x % 10 + '0');
}
void sieve()
{
    cnt=0;
    mem(is_pr,0);
    for(int i=2; i*i<=N; i++)
    {
        if(!is_pr[i])
        {
            for(int j=i*i; j<=N; j+=i)
                is_pr[j]=1;
        }
    }
    for(int i=2; i<N; i++)
        if(!is_pr[i]) prime[cnt++]=i;
    mem(sum,0);
    for(int i=1; i<cnt; i++)
    {
        int tmp=(prime[i]+1)/2;
        int pos=lower_bound(prime,prime+i,tmp)-prime;
        if(prime[pos]==tmp) sum[prime[i]]++;
    }
    for(int i=1; i<cnt; i++) sum[prime[i]]+=sum[prime[i-1]];
}
int main()
{
    sieve();
    int q;
    while(~scanf("%d",&q))
    {
        rep(i,0,q)
        {
            int l,r;
            l = Scan();
            r = Scan();
            int pos1=lower_bound(prime,prime+cnt,l)-prime;
            int pos2=lower_bound(prime,prime+cnt,r)-prime;
            if(prime[pos2]==r) r=prime[pos2];
            else r=prime[pos2-1];
            int ans=sum[r]-sum[prime[pos1-1]];
            Print(ans);
            puts("");
        }
    }
    return 0;
}


Measured memory_bytes: 1152
#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;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k;
    cin>>n>>k;
    ll a[n], i, sum = 0;
    for(i=0; i<n; i++) {
    	cin>>a[i];
    }
    sort(a, a + n);
    if(n - k <= 0) {
    	cout<<"0\n";
    }
    else {
    	for(i=0; i<n-k; i++) {
    		sum += a[i];
    	}
    	cout<<sum<<"\n";
    }
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>

int a;
int b;
double c;
int digits;

int main(){
	
	while(scanf("%d %d", &a, &b)!=EOF) {
	c = log10 (a + b);
	if(ceil(c) == c){
		digits = c+1;
		printf("%d\n",digits);
	}
	else{
		digits = ceil(c);
		printf("%d\n",digits);
	}	
}
	return 0;
}


Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int num;
	cin>>num;
	long long *nums=new long long[1005];
	for(int i=0;i<num;i++)
		cin>>nums[i];
	sort(nums,nums+num);
	cout<<nums[num-1]-nums[0]; 
    return 0;
}

Measured memory_bytes: 256