akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize ("-O3","unroll-loops")
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
//#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")

template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 200010;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;

int cumV[2020][2020], cumH[2020][2020], cumW[2020][2020];
char A[2020][2020];
void solve() {
	int N, M, Q; cin >> N >> M >> Q;
	REP(i, N)REP(j, M) {
		cin >> A[i][j];
	}
	REP(i, N) {
		REP(j, M) {
			if (A[i][j]=='1')cumV[i + 1][j + 1]++;
			if (A[i][j] == '1' && A[i + 1][j] == '1')cumH[i + 1][j + 1]++;
			if (A[i][j] == '1' && A[i][j + 1] == '1')cumW[i + 1][j + 1]++;
		}
	}
	FOR(i,1, N + 1) {
		FOR(j,1, M + 1) {
			cumV[i][j] += cumV[i - 1][j] + cumV[i][j - 1] - cumV[i - 1][j - 1];
			cumH[i][j] += cumH[i - 1][j] + cumH[i][j - 1] - cumH[i - 1][j - 1];
			cumW[i][j] += cumW[i - 1][j] + cumW[i][j - 1] - cumW[i - 1][j - 1];
		}
	}
	while (Q--) {
		int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
		int res = 0;
		res += cumV[x2][y2] + cumV[x1 - 1][y1 - 1] - cumV[x2][y1 - 1] - cumV[x1 - 1][y2];
		res -= cumH[x2-1][y2] + cumH[x1 - 1][y1 - 1] - cumH[x2-1][y1 - 1] - cumH[x1 - 1][y2];
		res -= cumW[x2][y2-1] + cumW[x1 - 1][y1 - 1] - cumW[x2][y1 - 1] - cumW[x1 - 1][y2-1];
		print(res);
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// int q;cin>>q;
	// while(q--)
	//test();
	solve();
}




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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




int main() {

	string s;
	cin >> s;

	if (s <= "2019/04/30")cout << "Heisei" << endl;
	else cout << "TBD" << endl;
	
	return 0;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
#define f first
#define s second

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

main(){
  int n,m;
  while(cin>>n>>m,n|m){
    char zu[m][n];
    int sx,sy;
    rep(i,m){
      rep(j,n){
        cin>>zu[i][j];
        if(zu[i][j]=='&')sx=i,sy=j;
      }
    }

    int dp[m][n];
    memset(dp,-1,sizeof(dp));

    queue<PI> Q;
    Q.push(mp(sx,sy));
    dp[sx][sy]=0;
    zu[sx][sy]='.';
    int bury=1;

    while(bury<m*n){
      queue<PI> nQ;
      while(!Q.empty()){
        int cx=Q.front().f,cy=Q.front().s;Q.pop();
        rep(i,4){
          int nx=cx+dx[i],ny=cy+dy[i];
          if(nx<0 || nx>=m || ny<0 || ny>=n || dp[nx][ny]!=-1)continue;
          if(zu[nx][ny]!=zu[cx][cy]){
            dp[nx][ny]=dp[cx][cy]+1;
            ++bury;
            nQ.push(mp(nx,ny));
          }else{
            dp[nx][ny]=dp[cx][cy];
            ++bury;
            Q.push(mp(nx,ny));
          }
        }
      }
      Q=nQ;
    }
/*
    rep(i,m){
      rep(j,n)printf("%2d",dp[i][j]);
      cout<<endl;
    }
*/   
    int ans=dp[0][0];
    rep(i,n){
      ans=min(ans,dp[0][i]);
      ans=min(ans,dp[m-1][i]);
    }
    rep(i,m){
      ans=min(ans,dp[i][0]);
      ans=min(ans,dp[i][n-1]);
    }
    cout<<(1+ans)/2<<endl;
  }
}
      

Measured memory_bytes: 0
using System;

class main{
	static void Main(){
		int N = int.Parse(Console.ReadLine().Trim().Replace(" ", ""));
		bool flag = false;
		for(int i = 0; i * i <= N; i++){
			if(i * i == N) flag = true;
		}
		if(flag) Console.WriteLine("Yes");
		else Console.WriteLine("No");
	}
}


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

int main(){
  int N;
  int side[3];
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> side[0] >> side[1] >> side[2];
    sort(side,side+3);
    if (side[0]*side[0]+side[1]*side[1] == side[2]*side[2]){
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3120
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? (a=b,1) : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);
    int N;
    i64 A, B;
    i64 x[100010];

    cin >> N >> A >> B;
    rep(i, N) cin >> x[i];

    i64 ans = 0;
    rep(i, N-1) {
        const i64 d = x[i+1] - x[i];
        ans += min(A * d, B);
    }

    cout << ans << endl;

    return 0;
}



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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
  string s ; 
  cin >> s ; 
  
  rep(i,s.size()-8) cout << s.at(i) ; 
  cout << endl ; 
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define READ(i, j) FOR(i, 0, j, 1)
#define RREAD(i, j) RFOR(i, j, 0, 1)



void solve() 
{
    float d,t,s;
    cin>>d>>t>>s;
    float time = d/s;


    if(time<=t)
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int tc = 1; 
    //cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 3736
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

vector<vector<pair<int,int>>> g(100000);
vector<int> dist(100000,-1);
vector<bool> visited(100000,false);


bool bfs(int i, int d){
  if(visited[i] && d != dist[i]) return false;
  if(visited[i] && d == dist[i]) return true;
  
  visited[i] = true;
  dist[i] = d;
  rep(j,g[i].size()){
    if(!bfs(g[i][j].first, d + g[i][j].second)) return false;
  }
  
  return true;
}

int main(){
  int n,m; cin >> n >> m;
  rep(i,m){
    int l,r,d; cin >> l >> r >> d;
    l--; r--;
    g[l].push_back({r,d});
    g[r].push_back({l,-1*d});
  }
  
  rep(i,n){
    if(!visited[i]){
      if(!bfs(i,0)){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
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;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

signed main() {
    INIT;
    cin >> W >> H >> N;
    ll a[4];
    a[0] = 0;
    a[1] = W;
    a[2] = 0;
    a[3] = H;
    REP(i, N) {
        cin >> X >> Y >> A;
        A--;
        if (A == 0) {
            chmax(a[0], X);
        } else if (A == 1) {
            chmin(a[1], X);
        } else if (A == 2) {
            chmax(a[2], Y);
        } else {
            chmin(a[3], Y);
        }
    }
    if (a[0] < a[1] && a[2] < a[3]) {
        cout << (a[1] - a[0]) * (a[3] - a[2]) << endl;
    } else
        cout << 0 << endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int W,H,N;
	int a,i;
	int xl,yu,xr,yd;
	int X,Y;
	cin>> W >> H >> N;
	xl=0; xr=W; yd=0; yu=H;
	for(i=0;i<N;i++)
	{
		cin >> X >> Y >>a;
		switch(a)
		{
			case 1:
			if(X>xl) xl=X;
			break;
			case 2:
			if(X<xr) xr=X;
			break;
			case 3:
			if(Y>yd) yd=Y;
			break;
			case 4:
			if(Y<yu) yu=Y;
			break;
		}
	}
		if( (xr-xl)>=0 && (yu-yd)>=0)
			cout << (xr-xl)*(yu-yd) << endl;
		else cout << 0 << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import Counter

if __name__ == '__main__':
    n = int(input())
    s = list(input())
    s = Counter(s)
    s = s.most_common()
    ans = 1

    for k, v in s:
        if v > 1:
            ans *= v + 1
        else:
            ans *= 2
        ans %= (10 ** 9 + 7)

    print(ans - 1)


Measured memory_bytes: 4340
# abc085_c.py
N,Y = map(int,input().split())
for i in range(N+1):
    for j in range(N+1):
        k = N-i-j
        if i*10000 + j*5000 + k*1000 == Y and k>=0:
            print(i,j,k)
            exit()
print(-1,-1,-1)


Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include<string>
#include<utility>
#include<iterator>
#include<regex>
#include<math.h>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007
typedef struct tree Tree;

using namespace std;

bool cmpf(pair<lli, lli> left, pair<lli, lli> right) {
	return left.first < right.first;
}
bool cmp(pair<lli, lli> left, pair<lli, lli> right) {
	if (left.first != right.first)return left.first < right.first;
	else return left.second < right.second;
}
int main() {
	lli n, temp, ans=0;
	cin >> n;
	rep0(i, n)cin >> temp, ans += temp;
	cout << ans - n;
}


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

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

   cout << max(a*b, c*d) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    int H,W,N;cin>>H>>W>>N;
    int ma = max(H,W);
    cout << ceil((double) N / ma) << endl;
}

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

#ifdef LOCAL
#include "../lib/dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve()
{
  int N;
  cin >> N;
  vector<ll> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h[i];
  }
  if (N == 1) {
    cout << 0 << endl;
    return;
  }
  int cnt = 0;
  int ans = 0;
  for (int i = N - 2; 0 <= i; i--) {
    if (h[i] >= h[i + 1]) {
      cnt++;
    } else {
      cnt = 0;
    }
    dump(i, cnt);
    ans = max(ans, cnt);
  }
  cout << ans << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 998244353;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool A[n + 1]; for (int i = 0; i < n + 1; i++) { A[i] = 1; }for (int i = 2; i < n + 1; i++) { if (A[i]) { prime.pb(i); ll b = i; while (b <= n) { A[b] = 0; b += i; } } } }

vector<vector<pair<int,int>>> Edge;
vector<int> node;

bool bellman_ford(int n,int s) {
	node = vector<int>(n,INF);
	node[s] = 0;
	REP (i,n) {
		REP (j,Edge.size()) {
			REP (k,Edge[j].size()) {
				int from = j,to = Edge[j][k].F;
				int cost = Edge[j][k].S;
				if (node[from] != INF && node[to] > node[from] + cost) {
					node[to] = node[from] + cost;
					if (i == n - 1 && to == n - 1) return true;
				}
			}
		}
	}
	return false;
}

int dp[100000];
int dp2[100000];

signed main() {
	int n;
	cin >> n;
	map<int,int> ma;
	REP (i,n) {
		int x;cin >> x;
		ma[x]++;
	}
	int ans = 0;
	for (auto i = ma.rbegin();i != ma.rend();i++) {
		int now = i->first;
		int cnt = i->second;
		int p = 1;
		while (p < now) {
			p *= 2;
		}
		if (p == now) {
			ans += cnt / 2;
			i->second -= (cnt / 2) * 2;
		} else {
			int mincnt = min(ma[p - now],cnt);
			ans += mincnt;
			ma[p - now] -= mincnt;
			i->second -= mincnt;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 85504
N = int(input())
L = [int(i) for i in input().split()]

import bisect
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect.bisect_left(L, L[i]+L[j])
        ans += (idx-(j+1))

print(ans)
          

Measured memory_bytes: 3188
# -*- coding: utf-8 -*-

from collections import deque as dq

mode = True

def prob_d(s, q):
    ans = dq(s)
    for i in range(q):
        ans = ope(ans)
    if not mode:
        ans = ''.join(list(ans)[::-1])
    else:
        ans = ''.join(ans)
    print(ans)

def ope(s):
    global mode
    op = input().split()
    if len(op) == 1 and op[0] == '1':
        mode = not mode 
    elif len(op) == 3 and op[0] == '2':
        if op[1] == "1":
            if mode:
                s.appendleft(op[2])
            else:
                s.append(op[2])
        elif op[1] == "2":
            if mode:
                s.append(op[2])
            else:
                s.appendleft(op[2])
        else:
            pass
    else:
        pass
    return s

if __name__ == '__main__':
    s = input()
    q = int(input())
    prob_d(s, q)
    


Measured memory_bytes: 10356
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<ctime>
#include<cassert>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;
 
i64 modpow(i64 a, i64 p = MOD - 2)
{
	if (p == 0) return 1;
	i64 tmp = modpow(a, p / 2);
	tmp = tmp * tmp % MOD;
	if (p % 2) tmp = tmp * a % MOD;
	return tmp;
}
 
int N, K;
i64 fact[4040404], frev[4040404];
 
i64 C(int a, int b)
{
	if (a < b) return 0;
	return fact[a] * frev[b] % MOD * frev[a - b] % MOD;
}
 
i64 dp[4020][2020];
 
i64 solve(int nz, int nk)
{
	if (dp[nz][nk] != -1) return dp[nz][nk];

	if (nz == N && nk == N) return dp[nz][nk] = 1;
	dp[nz][nk] = 0;
	if (nz < N) {
	//	ADD(dp[nz][nk], solve(nz + 1, nk));
		dp[nz][nk]=solve(nz+1,nk);
	}
	if (nk < N && nk < nz) {
	//	printf("%d %d, %d %d\n", nz, nk, N * K - nz - nk * (K - 1) - 1, K - 2);
	//	ADD(dp[nz][nk], solve(nz, nk + 1) * C(N * K - nz - nk * (K - 1) - 1, K - 2) % MOD);
		dp[nz][nk]+=solve(nz, nk + 1) * C(N * K - nz - nk * (K - 1) - 1, K - 2)%MOD;
		if(dp[nz][nk]>=MOD) dp[nz][nk]-=MOD;
	}
	//printf("%d %d: %lld\n", nz, nk, dp[nz][nk]);
	return dp[nz][nk];
}
 
int main()
{
	scanf("%d%d", &N, &K);
 
	if (K == 1) {
		puts("1");
		return 0;
	}
	//mod1
	frev[0]=frev[1]=1;
	for(int i=2;i<4040404;++i){
		frev[i]=MOD-(MOD/i)*frev[MOD%i]%MOD;
	}
	fact[0] = 1;
	for (int i = 1; i < 4040404; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
		frev[i] = frev[i]*frev[i-1]%MOD;
	}
 	//mod2
	for (int i = 0; i <= N; ++i) {
		for (int j = 0; j <= N; ++j) dp[i][j] = -1;
	}
	i64 sol = solve(0, 0);
	sol = sol * fact[N] % MOD;
	printf("%lld\n", sol);
	return 0;
}

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

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

#define MOD 1000000007

int main(void) {
    ll mini = LONG_LONG_MAX;
    ll N;
    ll count = 0;
    cin >> N;
    for(ll i = 0;i < N;i++) {
        ll temp;
        cin >> temp;
        if(temp <= mini) count++;
        mini = min(mini, temp);
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 384
def sum_digit(n):
    n_str = str(n)
    ans = 0
    for dig in n_str:
        ans += int(dig)
    return ans

def snuke(n):
    return n / sum_digit(n)

K = int(input())

ans = 1
print(ans)
for i in range(K - 1):
    s = len(str(ans))
    x = snuke(ans)
    L = [[ans + 10 ** k, snuke(ans + 10 ** k)] for k in range(s+1)]
    L.sort(key = lambda x: x[1])
    ans = L[0][0]
    print(ans)


Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

count = 0
for idx, b in enumerate(B):
    count += min(b, A[idx])
    rest = min(A[idx + 1], b - min(b, A[idx]))
    A[idx + 1] -= rest
    count += rest
print(count)


Measured memory_bytes: 18624
#include <iostream>
using namespace std;
//Ninda Irvany

int main() {
    int r;
    cin >> r;
    if(r<1200) {
        cout << "ABC" << endl;
    }else if(r<2800) {
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
}

Measured memory_bytes: 3624
N = int(input())
li = list(map(int,input().split()))
li2 = [i for i in range(1,N+1)]
cnt = 0
li3 = []
for i in range(N):
    if li[i] == li2[i]:
        pass
    else:
        cnt += 1
        li3.append(i)
if cnt > 2:
    ans = "NO"
elif cnt == 1:
    ans ="NO"
elif cnt == 0:
    ans = "YES"
else:
    ind = li3[0]
    ind2 = li3[1]
    if li[ind] == ind2+1:
        ans ="YES"
    else:
        ans = "NO"
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
    ll A,B,K;
    cin >> A >> B >> K;
    if(A-K >= 0) cout << A-K << " " << B << endl;
    else{
        if(B-(K-A)>=0) cout << 0 << " " << B-(K-A) << endl;
        else cout << 0 << " "<< 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a, b, c, d =  list(map(int, input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

def lcm(a,b):
    return a*b//gcd(a,b)
x = b//c - (a - 1)//c

y = b//d - (a - 1)//d

cd = lcm(c, d)

z = b//cd - (a - 1)//cd

ans = b - a + 1 - x - y + z
print(ans)


Measured memory_bytes: 3060
a=list(map(int,input().split()))
b=sum(a)
if b%2>0:
  if max(a)%2>0:
    g=max(a)
  else:
    g=max(a)+1
else:
  if max(a)%2>0:
    g=max(a)+1
  else:
    g=max(a)
print((g*3-b)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define int long long
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    vector<int> X(N);
    REP(i, N) cin >> X[i];
    vector<int> A(X);
    sort(All(A));

    REP(i, N){
        if(lower_bound(All(A), X[i])-A.begin() < N/2) cout << (A[N/2]) << "\n";
        else cout << (A[N/2 - 1]) << "\n";
    }
    return 0;
}

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

using namespace std;

void swapstr_one(string &str, string fstr, string tstr) {
  int pos = str.find(fstr);
  while (true) {
    if (pos == string::npos)
      break;
    str.replace(pos, fstr.length(), tstr);
    pos = str.find(fstr, pos+1);
  }
}

void swapstr(string &str, string const &rstr1, string const &rstr2) {
  string tmp = rstr2;
  tmp[0] = '\n';

  swapstr_one(str, rstr1, tmp);
  swapstr_one(str, rstr2, rstr1);
  swapstr_one(str, tmp, rstr2);
}

int main() {
  string str;
  getline(cin, str);
  swapstr(str, "apple", "peach");
  cout << str << endl;
}


Measured memory_bytes: 3092
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int X = scanner.nextInt();
        int A = scanner.nextInt();

        if(X < A) {
            System.out.println(0);
        } else {
            System.out.println(10);
        }
    }
}

Measured memory_bytes: 22356
// abc155_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int A, B, C;
    cin >> A >> B >> C;
    set<int> st;
    st.insert(A);
    st.insert(B);
    st.insert(C);
    if (st.size() == 2){
        print("Yes");
    } else{
        print("No");
    }



    return 0;
}


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

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl

void solve() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if ((a + b) >= k) {
    cout << ((k >= a) ? a : k) << '\n';
    return;
  }
  ll ans = a - (k - (a + b));
  cout << ans << '\n';
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  // cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define INF 100000000

int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    if(A*C>B)   cout<<B/A;
    if(A*C<=B)  cout<<C;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    int a[n], ans[n];
    memset(ans, 0, sizeof(ans));
    For(i, 1, n){
        scanf("%d", &a[i]);
        ++ans[a[i]-1];
    }
    rep(i, n) printf("%d\n", ans[i]);
}

Measured memory_bytes: 5384
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	string a,b;
	while(cin>>a>>b){
		int n=0;
		int la=a.size();
		int lb=b.size();
		for(int i=1-la;i<lb;i++){
			int k=0;
			for(int j=0;j<la;j++){
				if(j+i<0||j+i>lb-1){
					k=0;
				}
				else if(a[j]==b[j+i]){
					k++;
					n=max(n,k);
				}
				else{
					k=0;
				}
			}
		}
		cout<<n<<endl;
	}
    return 0;
}

Measured memory_bytes: 1208
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

int gcd(int a, int b) {
  if (b==0) return a;
  return gcd(b,a%b);
}


signed main() {
	int a,b;
	std::cin >> a >> b;
	print(a*b/gcd(a,b));

	return 0;
}


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

using namespace std;

int main() {
	int n; cin >> n;
	vector<pair<int, int> > ab(n);
	for (int i = 0; i < n; ++i) cin >> ab[i].second >> ab[i].first;
	sort(ab.begin(), ab.end());
	long long t = 0;
	bool flag = true;
	for (int i = 0; i < n; ++i) {
		t += ab[i].second;
		if (t > ab[i].first) flag = false;
	}
	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

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

int main()
{
	int N;
	double ans=0;
	cin >> N;
	if (N%2==0)
	{
		ans = 1.0*1 / 2;
	}
	else
	{
		ans = 1.0*(N + 1) / 2 / N;
	}
	cout << ans << endl;
	return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end()))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int X, N;
int p[110];
signed main() {
    cin >> X >> N;
    rep(i, N) { cin >> p[i]; }
    int ans = INT_MAX;
    for (int i = -1000; i <= 1000; i++) {
        bool ng = false;
        rep(j, N) { if (i == p[j]) { ng = true; }}
        if (ng) { continue; }
        if (abs(X - i) < abs(X - ans)) { ans = i; }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int N){
	int width,height;
	scanf("%d %d",&width,&height);
	int table[height][width];

	for(int i = 0; i < height; i++){
		for(int k = 0; k < width; k++)table[i][k] = 0;
	}

	int x,y;

	for(int i = 0; i < N; i++){
		scanf("%d %d",&x,&y);
		table[y-1][x-1] = 1;
	}

	int W,H,tmp,pre,pre_row,maximum;
	scanf("%d %d",&W,&H);

	for(int row = 0; row <= height-H;row++){
		for(int col = 0; col <= width-W; col++){
			if(col == 0){
				if(row == 0){
					tmp = 0;
					for(int i = 0; i < H; i++){
						for(int k = 0; k < W; k++)tmp += table[i][k];
					}
					maximum = tmp;
					pre = tmp;
					pre_row = tmp;
				}else{
					for(int i = 0; i < W; i++)pre_row -= table[row-1][i];
					for(int i = 0; i < W; i++)pre_row += table[row+H-1][i];
					maximum = max(maximum,pre_row);
					pre = pre_row;
				}
			}else{
				for(int i = 0; i < H; i++)pre -= table[row+i][col-1];
				for(int i = 0; i < H; i++)pre += table[row+i][col+W-1];
				maximum = max(maximum,pre);
			}
		}
	}

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

}

int main(){

	int N;

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func(N);
	}

	return 0;
}

Measured memory_bytes: 2616
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define rg register
#define ll long long 
#define inf 0x3f3f3f3f
inline int read()
{
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    return x*f;
}
int n;
int a[305][305],flag[305][305];
int main(){

    n=read();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            a[i][j]=read();
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
        {
            if(i==k) continue;
            for(int j=1;j<=n;j++)
            {
                if(i==j||k==j) continue;
                if(a[i][j]>a[i][k]+a[k][j])
                {
                    printf("-1\n");
                    return 0;
                }
                if(a[i][j]==a[i][k]+a[k][j])
                {
                    flag[i][j]=flag[j][i]=1;
                }
            }
        }
    ll ans=0;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
            if(!flag[i][j])
                ans+=a[i][j];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 1024
#ABC 070: C [beta]
from fractions import gcd

N = int(input())
clocks = []
for i in range(N):
  clocks.append(int(input()))

b = clocks[0]
for i in range(1, N):
  a = gcd(b, clocks[i])
  b = b * clocks[i] // a

print(b)

Measured memory_bytes: 5304
import math
A,B,H,N = map(int,input().split())

def kakudo(type):
    if type=="n":
        return N*6
    elif type=="n2":
        return abs(360-N*6)
    else:
        return (H*30)+(N*(1/2))

ans=(A**2)+(B**2)-2*A*B*math.cos(math.radians((abs(kakudo("n")-kakudo("h")))))
ans2=(A**2)+(B**2)-2*A*B*math.cos(math.radians((abs(kakudo("n2")-kakudo("h")))))

print(math.sqrt(ans))


Measured memory_bytes: 9528
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
for i in range(n):
    lis[i]-=i+1
lis.sort()
c=lis[(n-1)//2] if n%2==1 else lis[n//2]
ans=0
for i in range(n):
    ans+=abs(lis[i]-c)
print(ans)

Measured memory_bytes: 78544
#include <stdio.h>

int main(){
  int A[100][100],n,i,j,u,k,v;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j]=0;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      A[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=NULL){
	printf(" ");
      }
      printf("%d",A[i][j]);
    }
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2132
#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 ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define fast ios::sync_with_stdio(false); cin.tie(NULL);
const double eps = 1e-6;

/////////////////////////////////////////////

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

////////////////////////////////

#define int long long

const int N = 1e5 + 10;
int par[N];
int size[N];
int dost[N];
int dushman[N];
int candidate[N];
int getPar(int x){

	while(x!=par[x]){
		x = par[x];
	}
	return x;
}

void unite(int x , int y){

	x = getPar(x);
	y = getPar(y);
	if(x==y)
		return ;
	if(size[x] < size[y]){

		par[x] = y;
		size[y] += size[x];
	}
	else {

		par[y] = x;
		size[x] += size[y];
	}
}

void solve(){

	int n , m , k;
	cin>>n>>m>>k;

	for(int i = 1 ; i <= n ; ++i)
		par[i] = i , size[i] = 1;

	for(int i = 1 ; i <= m ; ++i){

		int x , y;

		cin>>x>>y;
		dost[x]++ , dost[y]++;
		unite(x , y);
	}

	for(int i = 1 ; i <= n ; ++i){

		int p = getPar(i);

		int val = size[p];

		int should = val - 1;
		candidate[i] += should - dost[i];
	}

	for(int i = 1 ; i <= k ; ++i){

		int x, y;
		cin>>x>>y;

		if(getPar(x)==getPar(y))
			--candidate[x] , --candidate[y];
	}

	for(int i = 1 ;i <= n ; ++i)
		cout<<candidate[i]<<" ";
	cout<<endl;
}

signed main(){

    fast;
    int t = 1;
    //cin>>t;
    for(int i = 1 ; i <= t; ++i){

    	solve();
    }
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define inf 1<<31

#define MX 100

int main()
{
    //freopen("input.txt","r",stdin);

    int a,b;
    cin>>a>>b;
    string st;
    cin>>st;

    if((st.size()<a+b+1)||(st[a]!='-'))
    {
        puts("No");
        return 0;
    }

bool fl=1;

    for(int i=0;i<st.size();i++)
    {
        if(i==a&&st[i]=='-')continue;
        else if(st[i]>='0'&&st[i]<='9')continue;
        else{
            fl=0;
            break;
        }

    }

    if(fl)puts("Yes");
    else puts("No");




    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

void solve(void)
{
  int N,M,K;
  cin>>N>>M>>K;
  UnionFind UF(N);
  vector<vector<int> > Fr(N);
  vector<vector<int> > Bl(N);
  for (int i = 0; i < M; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    UF.unite(A,B);
    Fr[A].push_back(B);
    Fr[B].push_back(A);
  }
  for (int i = 0; i < K; i++)
  {
    int A,B;
    cin>>A>>B;
    A--;B--;
    Bl[A].push_back(B);
    Bl[B].push_back(A);
  }
  
  for (int i = 0; i < N; i++)
  {
    if(i != 0)cout<<char(32);
    int P = i;
    int ANS = UF.size(P);
    for (auto &&p : Fr[P])
    {
      if(UF.find(p) == UF.find(P))ANS --;
    }
      for (auto &&p : Bl[P])
    {
      if(UF.find(p) == UF.find(P))ANS --;
    }
    cout<<ANS-1;
    
  }
  cout<<endl;
  
  
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 13684
using System;
using System.Linq;

namespace ARC071_D
{
    class Program
    {
        static void Main(string[] args)
        {
            var mod = 1000000007;
            var nm = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var n = nm[0];
            var m = nm[1];
            var x = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var y = Console.ReadLine().Split().Select(long.Parse).ToArray();

            long sumx = 0;
            for (long i = 1; i < n + 1; i++)
            {
                sumx += (i - 1) * x[i - 1] - (n - i) * x[i - 1];
                sumx %= mod;
            }

            long sumy = 0;
            for (long i = 1; i < m + 1; i++)
            {
                sumy += (i - 1) * y[i - 1] - (m - i) * y[i - 1];
                sumy %= mod;
            }

            Console.WriteLine(sumx * sumy % mod);

        }
    }
}

Measured memory_bytes: 39200