akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <tuple>
#include <bitset>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

static const ll INF = 1001001001;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    ll N_{};
    vector<ll> v_{};
    explicit C1(vector<ll> v) : N_(v.size()), v_(move(v)){}
    ll resolve() {
        std::sort(v_.begin(), v_.end());
        ll count = 0;
        for(ll i=0; i < N_; ++i) {
            for(ll j=0; j < i; ++j) {
                auto a = v_[j];
                auto b = v_[i];
                auto u = upper_bound(&v_[j+1], &v_[i], a+b);
                auto l = lower_bound(&v_[j+1], &v_[i], b-a+1);
                if(l == &v_[N_] || l > u) {
                    continue;
                }
                count += distance(l, u);
            }
        }
        return count;
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{move(v)};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


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

using namespace std;
typedef long long int ll;

const ll mod = 1e9 + 7;


void solve()
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({b*d,a*c,a*d,b*c});
}

int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3656
#include<cstdio>
#include<algorithm>
using namespace std;

int n,dp[100005],h[100005];

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	printf("%d",dp[n]);
	return 0;
}

Measured memory_bytes: 896
import java.util.*;
import java.math.*;

class Main{
	public static void main(String Args[]){
		Scanner sc = new Scanner(System.in);
		String str = sc.next();
		BigInteger A = new BigInteger(str);
		str = sc.next();
		BigInteger B = new BigInteger(str);
		System.out.println(A.multiply(B));
	}
}



Measured memory_bytes: 255296
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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 (b<a) { a=b; return 1; } return 0; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll a,b;
    cin>>a>>b;
    if(a<=0&&b>=0){
        cout<<"Zero"<<endl;
        return 0;
    }
    if(a>0&&b>0){
        cout<<"Positive"<<endl;
        return 0;
    }
    cout<<((b-a+1)%2?"Negative":"Positive")<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);
    int k;
    cin>>k;
    while(k--)
    {
        cout<<"ACL";
    }
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>

using namespace std;

typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i){
        cin >> A[i];
        A[i] -= i + 1;
    }
    
    sort(A.begin(), A.end());
    
    int mediam;
    if(N % 2 != 0){
        mediam = -A[N / 2];
    }
    else{
        mediam = -(A[N / 2] + A[N / 2 - 1]) / 2;
    }
    for(int i = 0; i < N; ++i){
        A[i] += mediam;
        A[i] = abs(A[i]);
    }
    ll res = accumulate(A.begin(), A.end(), (ll)0);
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};

int main() {


	int a,b;
	cin>>a>>b;
	cout<<a*b<<endl;

	return 0;
}


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

using namespace std;
using namespace __gnu_pbds;

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "Yes" : "No")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

template <class T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree <T, null_type, less_equal <T>, rb_tree_tag, tree_order_statistics_node_update>;

const int siz = 3e5 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "1";

int sumc[siz], sumr[siz];

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

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    int m, n, k;
    cin >> m >> n >> k;
    set <ii> se;
    while (k--) {
        int x, y;
        cin >> x >> y;

        sumr[x]++;
        sumc[y]++;
        se.insert(ii(x, y));
    }

    int mxr = *max_element(sumr + 1, sumr + 1 + m);
    int mxc = *max_element(sumc + 1, sumc + 1 + n);

    vector <int> mxrs, mxcs;
    for (int i = 1; i <= m; i++) {
        if (sumr[i] == mxr) {
            mxrs.push_back(i);
        }
    }
    for (int i = 1; i <= n; i++) {
        if (sumc[i] == mxc) {
            mxcs.push_back(i);
        }
    }

    for (auto &x : mxrs) {
        for (auto &y : mxcs) {
            if (se.find(ii(x, y)) == se.end()) {
                return cout << mxr + mxc << "\n", 0;
            }
        }
    }

    cout << mxr + mxc - 1 << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 35036
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

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)]);
  }
};

int main(){
  ll n,m;cin>>n>>m;
  int a[m],b[m];rep(i,m)cin>>a[m-1-i]>>b[m-1-i];
  rep(i,m){
    --a[i];--b[i];
  }
  UnionFind uf(n);
  vector<ll> ans(m,0);
  rep(i,m-1){
    ll comb=uf.size(a[i])*uf.size(b[i]);
    if(uf.unite(a[i],b[i])){
      ans[i+1]=ans[i]+comb;
    }
    else ans[i+1]=ans[i];
  }
  reverse(all(ans));
  rep(i,m){
    cout<<n*(n-1)/2-ans[i]<<endl;
  }
}






Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define rrep(i, a, b) for (int i = (a); i < (b); ++i)
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n; cin>>n;
    vl as(n); cin>>as;
    ll ans = 0;
    rep(i, n) rep(j, n) chmax(ans, abs(as[i] - as[j]));
    cout<<ans<<endl;
}

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

int main() {
  int n,q;

  while(1) {
  cin >> n >> q;
  if(n == 0 && q == 0) break;
    int a[101]={};
  for(int i=0;i<n;i++){
    int m;
    cin >> m;
    for(int j=0;j<m;j++){
      int d;
      cin >> d;
      a[d]++;
    }
  }
  int ans=0;
  int cnt = 0;
  for(int i=0;i<101;i++){
    if(a[i] > cnt && a[i] >= q) ans = i,cnt = a[i];
    }
  cout << ans <<endl;
  }

  return 0;
}

Measured memory_bytes: 1160
M,D = map(int,input().split())

if D < 22:
  print("0")
  exit()

count = 0

for m in range(1,M+1):
  for d in range(22,D+1):
    if int(str(d)[1]) < 2:
      continue
    if int(str(d)[0]) * int(str(d)[1]) == m:
      count += 1
print(count)

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int main(){
    int a, b, c, cont=0;
    scanf("%d %d %d", &a, &b, &c);
    if (a != b)
        cont++;
    if (b !=c)
        cont++;
    if (c !=a)
        cont++;
    if( a== b && b==c)
        cont=1;
    printf("%d\n", cont);

    return 0;
	
}


Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n,m;
  cin>>n>>m;
  vector<int>v(n,-1);
  bool check=true;
  if(n>=2)check=false;
  bool ng=false;
  rep(i,m){
    int s,c;
    cin>>s>>c;
    s--;
    if(c!=0)check=false;
    if(v[s]==-1)v[s]=c;
    if(s==0&&c==0)ng=true;
    else {
      if(v[s]!=-1&&v[s]!=c)ng=true;
    }
  }
  if(check)cout<<0;
  else if(ng)cout<<-1;
  else {
    int ans=0;
    rep(i,n){
      ans*=10;
      if(i==0){
        if(v[0]==-1)ans+=1;
        else ans+=v[0];
      }
      else {
        if(v[i]==-1)ans+=0;
        else ans+=v[i];
      }
    }
    cout<<ans;
  }
}

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

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
map<int,int>H;
const int INF=1000000007;
int N;
ll r=1;
int main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		int a;
		cin>>a;
		if(!((N%2==1&&a%2==0)||(N%2==0&&a%2==1)))r=0;
		H[a]++;
		if((a==0&&H[a]>1)||(a!=0&&H[a]>2))r=0;
	}
	if(r!=0)
	{
		int t=N%2?H.size()-1:H.size();
		for(int i=0;i<t;i++)
		{
			r=(r*2)%INF;
		}
	}
	cout<<r<<"\n";
}




Measured memory_bytes: 3200
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
to_n = 0
to_0 = 0

for i in a:
    if i < x:
        to_0 += 1
    else:
        to_n += 1

ans = min(to_0, to_n)
print(ans)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a, b, c, d, e, f;
double ans; 
int Max_1, Max_2;
int main() {
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
	for(int i = 0; ; i++) {
		if(i * a * 100 > f)break;
		for(int j = 0; ; j++) {
			int tmp_1 = (i * a + b * j) * 100;
			if(tmp_1 > f)break;
			if(tmp_1 == 0)continue;
			for(int k = 0; ; k++) {
				if(tmp_1 + c * k > f)break;
				for(int x = 0; ; x++) {
					int tmp_2 = k * c + x * d;
					if(tmp_1 + tmp_2 > f)break;
					if(tmp_2 * 100 <= tmp_1 * e) {
						double tmp = (tmp_2 * 1.0) / ((tmp_2 + tmp_1) * 1.0);
						if(Max_1 == 0 && Max_2 == 0)Max_1 = tmp_2 + tmp_1, Max_2 = tmp_2;
						if(tmp > ans){
							ans = tmp, Max_1 = tmp_2 + tmp_1, Max_2 = tmp_2;
						}
					}
				}
			}
		}
	}
	printf("%d %d\n", Max_1, Max_2);
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
ab.sort()
#print(n,m,ab)
total = 0#合計金額
num = 0#本数
i = 0
while num < m:
    if num + ab[i][1] <= m:
        num += ab[i][1]
        total += ab[i][0]*ab[i][1]
        i += 1
        #print(num,total,i,0)
    elif num + ab[i][1] > m:
        total += ab[i][0]*(m - num)
        num = m
        i += 1
        #print(num,total,i,1)
print(total)

Measured memory_bytes: 27760
a,b,c,d,e,f=map(int,input().split())
x=input()
for i in range(len(x)):
    if x[i]=="S":
        a,b,c,d,e,f=e,a,c,d,f,b
    if x[i]=="E":
        a,b,c,d,e,f=d,b,a,f,e,c
    if x[i]=="N":
        a,b,c,d,e,f=b,f,c,d,a,e
    if x[i]=="W":
        a,b,c,d,e,f=c,b,f,a,e,d
print(a)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll int64_t 
#define f(i,s,e) for(i=s;i<e;++i)
#define endl << "\n"
#define sp << " "
#define INF INFINITY
#define mset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define crap ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846264338327950288419716939937510
#define pb(a) push_back(a)
#define pf(a) push_front(a)

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

int main()
{
	crap;
	ll i,j,k,n;
	cin >> n;
	map <string,ll> map1 ;
	vector <string> s(4) ;
	s[0] = "AC" ; s[1] = "WA" ; s[2] = "TLE" ;s[3] = "RE" ;
	f(i,0,4)
		map1.insert(mp(s[i],0)) ;
	while(n--)
	{
		string s1;
		cin >> s1;
		map1[s1]++ ;
	}
	f(i,0,s.size())
	{
		cout << s[i] << " x " << map1[s[i]] endl ;
	}
	return 0;
}

Measured memory_bytes: 3664
def main():
    W, H, x, y = map(int, input().split(" "))
    S = W * H / 2
    ans = 0
    if 2 * x == W:
        ans += 1
    if 2 * y == H:
        ans += 1
    if x * H == y * W:
        ans += 1
    if ans > 1:
        ans = 1
    else:
        ans = 0
    print(str(S) + " " + str(ans))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll x;
    cin >> x;
    cout << "Christmas" << " " <<  endl;
    for (ll i=x;i<25;++i){
        cout << "Eve" << " " <<  endl;
    }
    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 ALL(v) v.begin(), v.end()
#define TM_T template <class T>
using namespace std;
typedef long long ll;
TM_T T inp(){T it;cin >> it;return it;}

int N, W;
vector<ll> w;
vector<ll> v;
vector<ll> dp;

int input(){
  cin >> N >> W;
  REP(i,N) {
    w.push_back( inp<ll>() );
    v.push_back( inp<ll>() );
  }
}

int main()
{
  input();
  
  REP(i,2*W+2) dp.push_back( -INF );
  dp[0] = 0;
  
  REP(i,N){
    ll iw = w[i];
    ll iv = v[i];
    REPR(j,W+1){
      dp[j+iw] = max( dp[j+iw], dp[j] + v[i] );
    }
  }
  
  ll maxv = 0;
  REP(i,W+1){
    maxv = max(maxv, dp[i]);
  }
  cout << maxv << endl;
}

Measured memory_bytes: 2424
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk

const int MAXN = 25;

int n;
vector< pair<int, int> > v[MAXN];

int main() { 

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    int num = 0;
    scanf("%d", &num);
    for (int j = 0; j < num; j++) {
      int x, y;
      scanf("%d %d", &x, &y);
      v[i].push_back(make_pair(x - 1, y));
    }
  }

  int ans = 0;

  for (int mask = 0; mask < (1 << n); mask++) {
    bool ok = true;

    for (int i = 0; i < n; i++) {
      if ((mask & (1 << i)) == 0) {
        continue;
      }
      for (pair<int, int> p : v[i]) {
        int x = p.first, y = p.second;
        bool good = (mask & (1 << x)) > 0;
        if (good != (y == 1)) {
          ok = false;
        }
      }
    }

    if (ok) {
      ans = max(ans, __builtin_popcount(mask));
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n,x;
	cin>>n>>x;
	int a,b;
	a=n*2;
	b=n*4;
	if(x%2==0 && x>=a && x<=b) {
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int sum=0;
	sum=min(a,b)+min(c,d);
	cout<<sum<<endl;
	return 0;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;

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

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 (b<a) { a=b; return 1; } return 0; }

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	vll a(3);
	rep(i,3) cin >> a[i];
	sort(all(a));
	int sum = 0;
	rep(i,2) sum += a[i + 1] - a[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Card{
    string suit;
    int value;
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int A, B, K;
    float f;
    string s;
    
    cin >> A >> B >> K;
    //for (int i=0;i<N;i++) cin >> A[i];
    
    int count = 0;
    for (int i=A;i>=1;i--) {
        if (A%i==0 and B%i==0) count += 1;
        if (count==K) {
            cout << i << endl;
            break;
        }
    }
    


    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

char a[22][22];

int main()
{
  int n,x,y,m,s;
  int i;
  char d[3];

  while(1){
    scanf("%d", &n);
    if(n==0)
      break;

    memset(a,0,sizeof(a));

    for(i=0;i<n;i++){
      scanf("%d%d", &x, &y);
      a[x][y]=1;
    }

    scanf("%d", &m);
    x=10,y=10;
    while(m-- > 0){
      scanf("%s%d", d, &s);
      while(s-- > 0){
	if(d[0] == 'E')x++;
	else if(d[0] == 'S')y--;
	else if(d[0] == 'W')x--;
	else if(d[0] == 'N')y++;
	
	if(a[x][y])n--,a[x][y]=0;
      }
    }

    if(n==0)
      printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}



Measured memory_bytes: 2580
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    d, n = f.read_int_list()
    if n == 100: n = 101
    return n * 100**d


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5004
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define ALLG(v) v.begin(), v.end() ,greater<int>()
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
ll GCD(ll x, ll y) { return y ? GCD(y, x % y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }
ll GetDigit(ll num) {
	ll digit = 0;
	while (num != 0) {
		num /= 10;
		digit++;
	}
	return digit;
}


int facctorialMethod(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

using namespace std;
int main() {

	ll X;



	cin >> X;
	
	ll kingaku = 100;
	ll nen = 0;
	while (true)
	{
		nen++;

		ll risi = kingaku * 0.01;

		kingaku += risi;

		if (X <= kingaku) {
			break;
		}
	}
	


	cout << nen << endl;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <iostream>
#include <string>

int main()
{
    std::string str;
    std::cin >> str;
    bool ans = true;

    for (int i = 0; i < str.size(); i++) {
        if (str.at(i) == 'd') {
            if ((i + 5) < str.size() && str.substr(i, 6) == "dreamd") {
                i += 4;
                continue;
            }
            if ((i + 7) < str.size()) {
                if (str.substr(i, 8) == "dreamera") {
                    i += 4;
                    continue;
                }
                if (str.substr(i, 8) == "dreamere"
                    || str.substr(i, 8) == "dreamerd") {
                    i += 6;
                    continue;
                }
            }
            if (((i + 4) == (str.size() - 1) && str.substr(i, 5) == "dream")
                || ((i + 6) == (str.size() - 1) && str.substr(i, 7) == "dreamer")) {
                break;
            }
        }
        if (str.at(i) == 'e') {
            if ((i + 5) < str.size()) {
                if (str.substr(i, 6) == "erased"
                    || str.substr(i, 6) == "erasee") {
                    i += 4;
                    continue;
                }
            }
            if ((i + 6) < str.size()) {
                if (str.substr(i, 7) == "eraserd"
                    || str.substr(i, 7) == "erasere") {
                    i += 5;
                    continue;
                }
            }
            if (((i + 4) == (str.size() - 1) && str.substr(i, 5) == "erase")
                || ((i + 5) == (str.size() - 1) && str.substr(i, 6) == "eraser")) {
                break;
            }
        }
        ans = false;
        break;
    }
    if (ans)
        std::cout << "YES\n";
    else
        std::cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

ll n;
vl g[100005];
bool vis[100005];
map <pll, ll> m;
map <pll, ll> col;
map <ll, pll> edges;

void dfs(ll i, ll par){
    vis[i] = true;
    ll curr = 1;
    ll used = col[{par, i}];
    for(auto j:g[i]){
        if(vis[j]){
            continue;
        }
            if(curr==used){
                curr++;
                col[{i, j}] = curr;
                col[{j, i}] = curr;
                curr++;
                dfs(j, i);
            }
            else{
                col[{i, j}] = curr;
                col[{j, i}] = curr;
                curr++;
                dfs(j, i);
            }
    }
}

int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    cin >> n;
    for(int i=0; i<n-1; i++){
        inps(u, v);
        g[u].pb(v);
        g[v].pb(u);
        m[{u, v}] = i;
        m[{v, u}] = i;
        edges[i] = {u, v};
    }
    ll ans = 0;
    for(int i=1; i<=n; i++){
        ans = max(ans, (ll)g[i].size());
    }
    cout << ans << endl;
    dfs(1, -1);
    for(int i=0; i<n-1; i++){
        cout << col[edges[i]] << endl;
    }
}

Measured memory_bytes: 37888
import numpy as np
N = input()
B = np.array(input().split()).astype(int)
B_left = np.insert(B, 0, B[0])
B_right = np.insert(B, len(B)-1, B[-1])
print(np.min(np.array([B_left, B_right]).T, axis=1).sum())

Measured memory_bytes: 12508
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
#endif
using namespace std;
using namespace atcoder;
namespace defines{
    typedef long long ll;
    typedef pair<ll,ll> P;
    #define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b)
    #define REP(i,n) for(ll i = 0 ; i < n ; i++) // for i in range(b)
    #define FORD(i,a,b) for(ll i = a ; i > b ; i--) // for i in range(a,b,-1)
    #define ALL(x) x.begin(),x.end()
    template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
    template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){ return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

    /* for debug print */
    #define DEBUG(x) cerr << #x << ": " << x << '\n'
    #define DEBUGP(x) cerr << #x << ": (" << x.first << ", " << x.second << ")" << '\n' 
    #define DEBUGL(xl) dbgl_f(#xl,xl)
    #define DEBUGLP(xl) dbglp_f(#xl,xl)
    #define DEBUGLL(xll) dbgll_f(#xll,xll)
    #define DEBUGM(xl) dbgm_f(#xl,xl)
    template<class T> void dbgl_f(string name, vector<T> xl){cerr<<name<<": "; for(T x: xl) cerr<<x<<" "; cerr << '\n';}
    template<class T, class U> void dbgm_f(string name, map<T,U> xl){cerr<<name<<": ";for(auto x: xl)cerr<<"("<<x.first<<": "<<x.second<<") ";cerr<<'\n';}
    template<class T> void dbglp_f(string name, vector<T> xl){cerr<<name<<": ";for(T x: xl)cerr<<"("<<x.first<<", "<< x.second<<") ";cerr<<'\n';}
    template<class T> void dbgll_f(string name, vector<vector<T>> xll){
        cerr<< name << ": " << '\n'; 
        for(vector<T> xl: xll){
            for(T x : xl) cerr << x << " ";
            cerr << '\n';
        }
    }
}
using namespace defines;

const int IINF = 1'001'001'001;
const ll INF = 1'001'001'001'001'001'001ll;
const int MOD = 1'000'000'007;

const int MAX_A = 300000;

int op(int a, int b){
    return max(a,b);
}

int e(){
    return 0;
}

void solve(){
    segtree<int, op, e> st(MAX_A+1);
    int n,k; cin >> n >> k;
    REP(i,n){
        int a; cin >> a;
        int l = max(0,a-k);
        int r = min(MAX_A+1, a+k+1);
        int range_max = st.prod(l,r);
        st.set(a, range_max+1);
    }
    cout << st.all_prod() << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 8452
N,T = list(map(int,input().split(" ")))
a = [list(map(int,input().split(" "))) for i in range(N)]
#print(a)
mini = 10000
for i,j in a:
    if j>T:
        continue
    else:
        #print(i,j)
        mini = min(mini,i)

if mini==10000:
    print("TLE")
else:
    print(mini)

Measured memory_bytes: 3060
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll h, w;
  cin >> h >> w;
  vvll dist(10, vll(10, INF));
  rep(i, 10) rep(j, 10) { cin >> dist[i][j]; }

  rep(k, 10) rep(i, 10) rep(j, 10) chmin(dist[i][j], dist[i][k] + dist[k][j]);

  ll ysf = 0;
  rep(i, h) rep(j, w) { ll a;
    cin >> a;
    if (a == -1) continue;
    ysf += dist[a][1];
  }

  cout << ysf << endl;

  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main()
{
    ll H, W, D;
    cin >> H >> W >> D;
    vector<vector<ll>> A(H, vector<ll>(W, 0));
    map<ll, pair<ll, ll>> P;
    rep(i, H){
        rep(j, W){
            cin >> A.at(i).at(j);
            A.at(i).at(j)--;
            P[A.at(i).at(j)] = make_pair(i, j);
        }
    }
    vector<vector<ll>> S(D, vector<ll>(H*W/D +3, 0));
    rep(i, D){
        ll j = 0;
        while(D*(j+1) + i < H*W){
            ll x = P.at(D*j+i).first;
            ll y = P.at(D*j+i).second;
            ll nx = P.at(D*(j+1)+i).first;
            ll ny = P.at(D*(j+1)+i).second;
            S.at(i).at(j+1) = S.at(i).at(j) + abs(nx-x) + abs(ny-y);
            j++;
        }
    }
    ll Q;
    cin >> Q;
    rep(i, Q){
        ll L, R;
        cin >> L >> R;
        L--;
        R--;
        ll k = L % D;
        ll j1 = L / D;
        ll j2 = R / D;
        cout << S.at(k).at(j2) - S.at(k).at(j1) << endl;
    }
}

Measured memory_bytes: 15756
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int P[] = new int[N+1];
		int Q[] = new int[N+1];
		for(int i = 1;i <= N;i++){
			P[i] = sc.nextInt();
		}
		for(int i = 1;i <= N;i++){
			Q[i] = sc.nextInt();
		}
		sc.close();

		int a = 0;
		for (int i = 1; i <= N; i++) {
			int count = 1;
			for (int j = 1; j < i; j++) {
				if (P[i] > P[j])
					count++;
			}
			a += fact(N - i) * (P[i] - count);
		}

		int b = 0;
		for (int i = 1; i <= N; i++) {
			int count = 1;
			for (int j = 1; j < i; j++) {
				if (Q[i] > Q[j])
					count++;
			}
			b += fact(N - i) * (Q[i] - count);
		}

		System.out.println(Math.abs(a - b));
	}

	static int fact(int n){
		if(n <= 1) return 1;
		return n * fact(n-1);
	}

}

Measured memory_bytes: 23124
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

using I = std::int_fast64_t;

struct uf_s {
  struct node {
    I x;
    bool sut;
  };
  std::vector<node> c;
  std::vector<I> st;
  I ans;

  uf_s():c(),st(),ans(0){}
  void set(I n) {
    c.resize(n, { -1,false });
  }

  I get() const { return ans; }
  void clear() {
    ans = 0;
    for (const auto e : st) {
      c[e] = { -1, false };
    }
    st.clear();
  }
  I find(I x) const {
    while (c[x].x >= 0) {
      x = c[x].x;
    }
    return x;
  }
  void unite(I x, I y) {
    x = find(x);
    y = find(y);
    if (x == y) {
      if (c[x].sut) {
        // do nothing
      }
      else {
        c[x].sut = true;
        ++ans;
        st.push_back(x);
      }
    }
    else {
      if (c[x].x > c[y].x) {
        std::swap(x, y);
      }
      c[x].x += c[y].x;
      c[y].x = x;
      if (c[x].sut) {
        if (c[y].sut) {
          // do nothing
        }
        else {
          ans += 1;
        }
      }
      else {
        if (c[y].sut) {
          c[x].sut = true;
          ans += 1;
        }
        else {
          ans += 1;
        }
      }
      st.push_back(x);
      st.push_back(y);
    }
  }
};

uf_s uf;

I n, k;
std::vector<std::vector<I>> g;
std::vector<I> c, d, ans, siz;

void sizrec(const I v, const I p) {
  siz[v] = 1;
  auto& a = g[v];
  for (I i = 0; i < a.size(); ++i) {
    if (a[i] == p) {
      a.erase(a.begin() + i);
      break;
    }
  }
  for (I i = 0; i < a.size(); ++i) {
    sizrec(a[i], v);
    siz[v] += siz[a[i]];
    if (siz[a.front()] < siz[a[i]]) {
      std::swap(a.front(), a[i]);
    }
  }
}


void run(const I v) {
  for (const auto e : g[v]) {
    run(e);
  }
  uf.unite(c[v], d[v]);
}

void solve(const I v) {
  const auto& a = g[v];
  if (!a.empty()) {
    for (I i = 1; i < a.size(); ++i) {
      solve(a[i]);
      uf.clear();
    }
    solve(a[0]);
    for (I i = 1; i < a.size(); ++i) {
      run(a[i]);
    }
  }
  uf.unite(c[v], d[v]);
  ans[v] = uf.get();
}


int main() {
  std::cin >> n >> k;
  uf.set(k);
  g.resize(n);
  for (I i = 1; i != n; ++i) {
    I u, v;
    std::cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  c.resize(n);
  d.resize(n);
  for (I i = 0; i != n; ++i) {
    std::cin >> c[i] >> d[i];
    --c[i];
    --d[i];
  }
  siz.resize(n);
  ans.resize(n);
  sizrec(0, n);
  solve(0);
  for (const auto e : ans) {
    std::cout << e << std::endl;
  }
  return 0;
}



Measured memory_bytes: 21276
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
    int a[12],i;
	for(i=0;i<12;i++){
	    scanf("%d",&a[i]);
	}
	sort(a,a+12);
	if(a[0]==a[3]&&a[4]==a[7]&&a[8]==a[11]) printf("yes\n");
	else printf("no\n");
	return 0;
}

Measured memory_bytes: 2576
#include<iostream>
#include<stdlib.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int main()
{
  long long int sum=0;
  long long int n=0;
  
  cin>>n;
  
  for(int i=1;i<=n;i++)
  {
    if(!(i%3==0))
    {
      if(!(i%5==0))
      {
        sum=sum+i;
      }
    }
  }
  
  cout<<sum<<endl;

  return 0;
}

Measured memory_bytes: 3636
import numpy as np
import sys
read = sys.stdin.read

def solve(stdin):
	h, w, m = stdin[:3]

	row = np.zeros(h, np.int)
	col = np.zeros(w, np.int)
	for i in range(3, m * 2 + 3, 2):
		y, x = stdin[i: i + 2] - 1
		row[y] += 1
		col[x] += 1

	max_cnt_y = max(row)
	max_cnt_x = max(col)
	max_pair = np.sum(row == max_cnt_y) * np.sum(col == max_cnt_x)
	for i in range(3, m * 2 + 3, 2):
		y, x = stdin[i: i + 2] - 1
		if row[y] == max_cnt_y and col[x] == max_cnt_x:
			max_pair -= 1

	return max_cnt_y + max_cnt_x - (max_pair == 0)

print(solve(np.fromstring(read(), dtype=np.int, sep=' ')))

Measured memory_bytes: 39352
#include<stdio.h>
#include<string.h>
int main(){
    int flag = 1, i, j, n, count = 0, s[200], key;
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &s[i]);
    while ( flag == 1) {
        flag = 0;
        for ( j = n - 1; j >= 1; j-- ) {
            if ( s[j] < s[j - 1] ) {
                key = s[j];
                s[j] = s[j - 1];
                s[j - 1] = key;
                count++;
                flag = 1;
            }
        }
    }
    printf("%d", s[0]);
    for ( i = 1; i < n; i++ ) {
        printf(" %d", s[i]);
    }
    printf("\n%d\n", count);
    return 0;
}

Measured memory_bytes: 1824
#include<stdio.h>
 
int main(void){
  int i;
  int n;
  int m;
  int a[10000];
  scanf("%d%d",&n, &m);
  for(i = 0; i < m; i++){
    scanf("%d", &a[i]);
    n -= a[i];
  }
  if (n < -1)
    n=-1;
  printf("%d",n);
}

Measured memory_bytes: 1772
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------

void solve(){
}
int main(){
    int n;
    cin >> n;
    vector<int>hn(n);
    for(int i = 0; i < n; i++){
        cin >> hn.at(i);
    }
    int num = 0;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        num = max(num, hn.at(i));
        if(hn.at(i) >= num){
            cnt++;
        }
    }
    cout << cnt << endl;
    solve();
    return 0;
}



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

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

    vector<int> c(n-1), s(n-1), f(n-1);

    for (int i = 0; i < n-1; i++)
    {
        cin >> c[i] >> s[i] >> f[i];
    }
    
    int cur, t, ts;

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

        while (cur != n-1)
        {
            if (t <= s[cur])
            {
                t = s[cur]+c[cur];
            }
            else
            {
                ts = t-s[cur];
                if (ts % f[cur] != 0) t += f[cur] - (ts % f[cur]);
                t += c[cur];
            }
            //cout << t << " ";
            cur++;
        }

        cout << t << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  cin >> N;
  vector<int> W(N), S(N+1);
  rep(i, N) {
    cin >> W[i];
    S[i+1] = S[i] + W[i];
  }
  int ans = inf;
  rep(i, N+1)
    ans = min(abs(S[N]-S[i]-S[i]), ans);
  cout << ans << endl;
  return 0;
}


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

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

    int N, W;
    cin >> N >> W;

    vector<ll> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N + 1, vector<ll>(100001, 1LL << 60));

    dp[0][0] = 0;

    REP(i, N) REP(j, 100001) {
        if (j - v[i] >= 0)
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }

    int ans = 0;
    REP(j, 100001)
        if (dp[N][j] <= W)
            ans = j;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 80256
#include <iostream>

using namespace std;

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

    int r = 1;
    for (int i = 1; i * i <= m; i++) {
        if (m % i == 0) {
            if (i <= m / n) {
                r = i;
            }

            if (m / i <= m / n) {
                r = m / i;
                break;
            }
        }
    }

    cout << r << endl;
}


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

def divisor(n):
    res = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            res.append(i)
            if n % n//i == 0:
                res.append(n//i)

    res.sort()
    return res

d = divisor(M)
ans = 1
for x in d:
    m = M
    m -= x * (N - 1)
    if m > 0 and m % x == 0:
        ans = x

print(ans)


Measured memory_bytes: 3064
array = gets.chomp.split("")
ll= array.length
array2 = [0]
answerArray = []
ll.times {
    answerArray.push(0)
}


i = 0
(ll-1).times {
    
    if array[i] != array[i+1]
        array2.push(i+1)
    end
    i+=1
}

array2.push(ll)


j = 1
ll2 = array2.length

(ll2/2).times {
    left = array2[j] - array2[j-1]
    right = array2[j+1] - array2[j]
    sum = left + right
    
    if sum%2 == 0
        answerArray[array2[j]-1] = sum/2
        answerArray[array2[j]] = sum/2
    elsif left%2 == 0
        answerArray[array2[j]-1] = sum/2
        answerArray[array2[j]] = sum/2 + 1
    else  
        answerArray[array2[j]-1] = sum/2 + 1
        answerArray[array2[j]] = sum/2
    end
    j+=2
}

puts answerArray.join(" ")

Measured memory_bytes: 11516
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define int long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define w(x) int x;cin>>x;while(t--)
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int POSITIVE_INFINITY = 9223372036854775807;
const int NEGATIVE_INFINITY = -9223372036854775807;
const int MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int32_t main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    ld h,w,n;
    cin>>h>>w>>n;
    cout<<ceil(n/max(h,w))<<endl;
 

 
    
 
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL dst[100010]={0};
LL fat[100010];
LL n,m,l,r,d;
int getfat(int x){
	if(x==fat[x])return x;
	LL i=getfat(fat[x]);
	dst[x]+=dst[fat[x]];
	fat[x]=i;
	return i;
}
int main(){
	LL i,j,k;
	for(i=0;i<100010;i++)fat[i]=i;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>l>>r>>d;
		j=getfat(l);
		k=getfat(r);
		if(j==k&&d!=dst[l]-dst[r]){
			cout<<"No"<<endl;
			return 0;
		}
		if(j==k&&d==dst[l]-dst[r])	continue;
		if(j!=k){
			if(d>dst[l]){
				fat[j]=k;
				dst[j]=dst[r]+d-dst[l];
			}
			else if(d+dst[r]>dst[l]){
				fat[j]=k;
				dst[j]=dst[r]+d-dst[l];
			}
			else if(d+dst[r]<dst[l]){
				fat[k]=j;
				dst[k]=dst[l]-d-dst[r];
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 1792